Changeset 3627


Ignore:
Timestamp:
12/10/07 18:51:36 (5 years ago)
Author:
andrew
Message:

Weekly sync with cvs.savannah.nongnu.org.

Location:
trunk/src/host/qemu-neo1973
Files:
1 added
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/host/qemu-neo1973/Makefile

    r3517 r3627  
    265265        $(bindir)/qemu-system-m68k \ 
    266266        $(bindir)/qemu-system-sh4 \ 
     267        $(bindir)/qemu-system-sh4eb \ 
    267268        $(bindir)/qemu-i386 \ 
    268269        $(bindir)/qemu-arm \ 
     
    280281        $(bindir)/qemu-m68k \ 
    281282        $(bindir)/qemu-sh4 \ 
     283        $(bindir)/qemu-sh4eb \ 
    282284        $(bindir)/qemu-img \ 
    283285        $(datadir)/bios.bin \ 
  • trunk/src/host/qemu-neo1973/Makefile.target

    r3555 r3627  
    491491VL_OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o 
    492492VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o sparc32_dma.o 
    493 VL_OBJS+= cs4231.o ptimer.o 
     493VL_OBJS+= cs4231.o ptimer.o eccmemctl.o 
    494494endif 
    495495endif 
  • trunk/src/host/qemu-neo1973/configure

    r3443 r3627  
    527527# these targets are portable 
    528528    if [ "$softmmu" = "yes" ] ; then 
    529         target_list="i386-softmmu sparc-softmmu x86_64-softmmu mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu arm-softmmu ppc-softmmu ppcemb-softmmu ppc64-softmmu m68k-softmmu sh4-softmmu cris-softmmu" 
     529        target_list="i386-softmmu sparc-softmmu x86_64-softmmu mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu arm-softmmu ppc-softmmu ppcemb-softmmu ppc64-softmmu m68k-softmmu sh4-softmmu sh4eb-softmmu cris-softmmu" 
    530530    fi 
    531531# the following are Linux specific 
    532532    if [ "$linux_user" = "yes" ] ; then 
    533         target_list="i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user sparc64-linux-user sparc32plus-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user sh4-linux-user ppc-linux-user ppc64-linux-user ppc64abi32-linux-user x86_64-linux-user cris-linux-user $target_list" 
     533        target_list="i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user sparc64-linux-user sparc32plus-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user sh4-linux-user sh4eb-linux-user ppc-linux-user ppc64-linux-user ppc64abi32-linux-user x86_64-linux-user cris-linux-user $target_list" 
    534534    fi 
    535535# the following are Darwin specific 
  • trunk/src/host/qemu-neo1973/cpu-defs.h

    r3443 r3627  
    147147    int cpu_index; /* CPU index (informative) */                        \ 
    148148    /* user data */                                                     \ 
    149     void *opaque; 
     149    void *opaque;                                                       \ 
     150                                                                        \ 
     151    const char *cpu_model_str; 
    150152 
    151153#endif 
  • trunk/src/host/qemu-neo1973/exec.c

    r3517 r3627  
    13181318CPUState *cpu_copy(CPUState *env) 
    13191319{ 
    1320 #if 0 
    1321     /* XXX: broken, must be handled by each CPU */ 
    1322     CPUState *new_env = cpu_init(); 
     1320    CPUState *new_env = cpu_init(env->cpu_model_str); 
    13231321    /* preserve chaining and index */ 
    13241322    CPUState *next_cpu = new_env->next_cpu; 
     
    13281326    new_env->cpu_index = cpu_index; 
    13291327    return new_env; 
    1330 #else 
    1331     return NULL; 
    1332 #endif 
    13331328} 
    13341329 
  • trunk/src/host/qemu-neo1973/hw/esp.c

    r3555 r3627  
    166166    if (s->current_dev) { 
    167167        /* Started a new command before the old one finished.  Cancel it.  */ 
    168         scsi_cancel_io(s->current_dev, 0); 
     168        s->current_dev->cancel_io(s->current_dev, 0); 
    169169        s->async_len = 0; 
    170170    } 
     
    189189    DPRINTF("do_cmd: busid 0x%x\n", buf[0]); 
    190190    lun = buf[0] & 7; 
    191     datalen = scsi_send_command(s->current_dev, 0, &buf[1], lun); 
     191    datalen = s->current_dev->send_command(s->current_dev, 0, &buf[1], lun); 
    192192    s->ti_size = datalen; 
    193193    if (datalen != 0) { 
     
    197197        if (datalen > 0) { 
    198198            s->rregs[ESP_RSTAT] |= STAT_DI; 
    199             scsi_read_data(s->current_dev, 0); 
     199            s->current_dev->read_data(s->current_dev, 0); 
    200200        } else { 
    201201            s->rregs[ESP_RSTAT] |= STAT_DO; 
    202             scsi_write_data(s->current_dev, 0); 
     202            s->current_dev->write_data(s->current_dev, 0); 
    203203        } 
    204204    } 
     
    299299        if (to_device) { 
    300300            // ti_size is negative 
    301             scsi_write_data(s->current_dev, 0); 
     301            s->current_dev->write_data(s->current_dev, 0); 
    302302        } else { 
    303             scsi_read_data(s->current_dev, 0); 
     303            s->current_dev->read_data(s->current_dev, 0); 
    304304            /* If there is still data to be read from the device then 
    305305               complete the DMA operation immeriately.  Otherwise defer 
     
    336336        DPRINTF("transfer %d/%d\n", s->dma_left, s->ti_size); 
    337337        s->async_len = arg; 
    338         s->async_buf = scsi_get_buf(s->current_dev, 0); 
     338        s->async_buf = s->current_dev->get_buf(s->current_dev, 0); 
    339339        if (s->dma_left) { 
    340340            esp_do_dma(s); 
     
    612612    if (s->scsi_dev[id]) { 
    613613        DPRINTF("Destroying device %d\n", id); 
    614         scsi_disk_destroy(s->scsi_dev[id]); 
     614        s->scsi_dev[id]->destroy(s->scsi_dev[id]); 
    615615    } 
    616616    DPRINTF("Attaching block device %d\n", id); 
  • trunk/src/host/qemu-neo1973/hw/flash.h

    r3443 r3627  
    22typedef struct pflash_t pflash_t; 
    33 
    4 pflash_t *pflash_register (target_phys_addr_t base, ram_addr_t off, 
    5                            BlockDriverState *bs, 
    6                            uint32_t sector_len, int nb_blocs, int width, 
    7                            uint16_t id0, uint16_t id1, 
    8                            uint16_t id2, uint16_t id3); 
     4/* pflash_cfi01.c */ 
     5pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off, 
     6                                BlockDriverState *bs, 
     7                                uint32_t sector_len, int nb_blocs, int width, 
     8                                uint16_t id0, uint16_t id1, 
     9                                uint16_t id2, uint16_t id3); 
     10 
     11/* pflash_cfi02.c */ 
     12pflash_t *pflash_cfi02_register(target_phys_addr_t base, ram_addr_t off, 
     13                                BlockDriverState *bs, uint32_t sector_len, 
     14                                int nb_blocs, int width, 
     15                                uint16_t id0, uint16_t id1, 
     16                                uint16_t id2, uint16_t id3); 
    917 
    1018/* nand.c */ 
     
    3846void ecc_put(QEMUFile *f, struct ecc_state_s *s); 
    3947void ecc_get(QEMUFile *f, struct ecc_state_s *s); 
    40  
  • trunk/src/host/qemu-neo1973/hw/gumstix.c

    r3555 r3627  
    6868    } 
    6969 
    70     if (!pflash_register(0x00000000, qemu_ram_alloc(connex_rom), 
     70    if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(connex_rom), 
    7171            drives_table[index].bdrv, sector_len, connex_rom / sector_len, 
    7272            2, 0, 0, 0, 0)) { 
     
    108108    } 
    109109 
    110     if (!pflash_register(0x00000000, qemu_ram_alloc(verdex_rom), 
     110    if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(verdex_rom), 
    111111            drives_table[index].bdrv, sector_len, verdex_rom / sector_len, 
    112112            2, 0, 0, 0, 0)) { 
  • trunk/src/host/qemu-neo1973/hw/ide.c

    r3443 r3627  
    13621362                    buf[8] = 0x2a; 
    13631363                    buf[9] = 0x12; 
    1364                     buf[10] = 0x08; 
     1364                    buf[10] = 0x00; 
    13651365                    buf[11] = 0x00; 
    13661366 
  • trunk/src/host/qemu-neo1973/hw/lsi53c895a.c

    r3555 r3627  
    188188    uint32_t current_tag; 
    189189    uint32_t current_dma_len; 
     190    int command_complete; 
    190191    uint8_t *dma_buf; 
    191192    lsi_queue *queue; 
     
    466467 
    467468    if (s->dma_buf == NULL) { 
    468         s->dma_buf = scsi_get_buf(s->current_dev, s->current_tag); 
     469        s->dma_buf = s->current_dev->get_buf(s->current_dev, 
     470                                             s->current_tag); 
    469471    } 
    470472 
     
    480482        if (out) { 
    481483            /* Write the data.  */ 
    482             scsi_write_data(s->current_dev, s->current_tag); 
     484            s->current_dev->write_data(s->current_dev, s->current_tag); 
    483485        } else { 
    484486            /* Request any remaining data.  */ 
    485             scsi_read_data(s->current_dev, s->current_tag); 
     487            s->current_dev->read_data(s->current_dev, s->current_tag); 
    486488        } 
    487489    } else { 
     
    597599        DPRINTF("Command complete sense=%d\n", (int)arg); 
    598600        s->sense = arg; 
     601        s->command_complete = 2; 
    599602        if (s->waiting && s->dbc != 0) { 
    600603            /* Raise phase mismatch for short transfers.  */ 
     
    613616    DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg); 
    614617    s->current_dma_len = arg; 
     618    s->command_complete = 1; 
    615619    if (!s->waiting) 
    616620        return; 
     
    632636    cpu_physical_memory_read(s->dnad, buf, s->dbc); 
    633637    s->sfbr = buf[0]; 
    634     n = scsi_send_command(s->current_dev, s->current_tag, buf, s->current_lun); 
     638    s->command_complete = 0; 
     639    n = s->current_dev->send_command(s->current_dev, s->current_tag, buf, 
     640                                     s->current_lun); 
    635641    if (n > 0) { 
    636642        lsi_set_phase(s, PHASE_DI); 
    637         scsi_read_data(s->current_dev, s->current_tag); 
     643        s->current_dev->read_data(s->current_dev, s->current_tag); 
    638644    } else if (n < 0) { 
    639645        lsi_set_phase(s, PHASE_DO); 
    640         scsi_write_data(s->current_dev, s->current_tag); 
    641     } 
    642     if (n && s->current_dma_len == 0) { 
    643         /* Command did not complete immediately so disconnect.  */ 
    644         lsi_add_msg_byte(s, 2); /* SAVE DATA POINTER */ 
    645         lsi_add_msg_byte(s, 4); /* DISCONNECT */ 
    646         lsi_set_phase(s, PHASE_MI); 
    647         s->msg_action = 1; 
    648         lsi_queue_command(s); 
     646        s->current_dev->write_data(s->current_dev, s->current_tag); 
     647    } 
     648 
     649    if (!s->command_complete) { 
     650        if (n) { 
     651            /* Command did not complete immediately so disconnect.  */ 
     652            lsi_add_msg_byte(s, 2); /* SAVE DATA POINTER */ 
     653            lsi_add_msg_byte(s, 4); /* DISCONNECT */ 
     654            /* wait data */ 
     655            lsi_set_phase(s, PHASE_MI); 
     656            s->msg_action = 1; 
     657            lsi_queue_command(s); 
     658        } else { 
     659            /* wait command complete */ 
     660            lsi_set_phase(s, PHASE_DI); 
     661        } 
    649662    } 
    650663} 
     
    18231836    if (s->scsi_dev[id]) { 
    18241837        DPRINTF("Destroying device %d\n", id); 
    1825         scsi_disk_destroy(s->scsi_dev[id]); 
     1838        s->scsi_dev[id]->destroy(s->scsi_dev[id]); 
    18261839    } 
    18271840    DPRINTF("Attaching block device %d\n", id); 
  • trunk/src/host/qemu-neo1973/hw/mainstone.c

    r3555 r3627  
    5656        exit(1); 
    5757    } 
    58     if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE, 
     58    if (!pflash_cfi01_register(MST_FLASH_0, 
     59                         mainstone_ram + PXA2XX_INTERNAL_SIZE, 
    5960                         drives_table[index].bdrv, 
    6061                         256 * 1024, 128, 4, 0, 0, 0, 0)) { 
     
    6970        exit(1); 
    7071    } 
    71     if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE, 
     72    if (!pflash_cfi01_register(MST_FLASH_1, 
     73                         mainstone_ram + PXA2XX_INTERNAL_SIZE, 
    7274                         drives_table[index].bdrv, 
    7375                         256 * 1024, 128, 4, 0, 0, 0, 0)) { 
     
    7779 
    7880    mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0); 
     81 
     82    /* MMC/SD host */ 
     83    pxa2xx_mmci_handlers(cpu->mmc, NULL, mst_irq[MMC_IRQ]); 
     84 
    7985    smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]); 
    8086 
  • trunk/src/host/qemu-neo1973/hw/mainstone.h

    r3555 r3627  
    1818 
    1919/* IRQ definitions */ 
    20 #define ETHERNET_IRQ    3 
     20#define MMC_IRQ       0 
     21#define USIM_IRQ      1 
     22#define USBC_IRQ      2 
     23#define ETHERNET_IRQ  3 
     24#define AC97_IRQ      4 
     25#define PEN_IRQ       5 
     26#define MSINS_IRQ     6 
     27#define EXBRD_IRQ     7 
     28#define S0_CD_IRQ     9 
     29#define S0_STSCHG_IRQ 10 
     30#define S0_IRQ        11 
     31#define S1_CD_IRQ     13 
     32#define S1_STSCHG_IRQ 14 
     33#define S1_IRQ        15 
    2134 
    2235extern qemu_irq 
  • trunk/src/host/qemu-neo1973/hw/mips_r4k.c

    r3555 r3627  
    3939static PITState *pit; /* PIT i8254 */ 
    4040 
    41 /*i8254 PIT is attached to the IRQ0 at PIC i8259 */ 
     41/* i8254 PIT is attached to the IRQ0 at PIC i8259 */ 
    4242 
    4343static struct _loaderparams { 
     
    269269 
    270270    i8042_init(i8259[1], i8259[12], 0x60); 
    271     ds1225y_init(0x9000, "nvram"); 
    272271} 
    273272 
  • trunk/src/host/qemu-neo1973/hw/omap.c

    r3613 r3627  
    403403 
    404404/* OMAP1 DMA module */ 
    405 typedef enum { 
    406     constant = 0, 
    407     post_incremented, 
    408     single_index, 
    409     double_index, 
    410 } omap_dma_addressing_t; 
    411  
    412405struct omap_dma_channel_s { 
     406    /* transfer data */ 
    413407    int burst[2]; 
    414408    int pack[2]; 
     
    416410    target_phys_addr_t addr[2]; 
    417411    omap_dma_addressing_t mode[2]; 
     412    uint16_t elements; 
     413    uint16_t frames; 
     414    int16_t frame_index[2]; 
     415    int16_t element_index[2]; 
    418416    int data_type; 
     417 
     418    /* transfer type */ 
     419    int transparent_copy; 
     420    int constant_fill; 
     421    uint32_t color; 
     422 
     423    /* auto init and linked channel data */ 
    419424    int end_prog; 
    420425    int repeat; 
    421426    int auto_init; 
    422     int priority; 
    423     int fs; 
    424     int sync; 
    425     int running; 
     427    int link_enabled; 
     428    int link_next_ch; 
     429 
     430    /* interruption data */ 
    426431    int interrupts; 
    427432    int status; 
    428     int signalled; 
    429     int post_sync; 
    430     int transfer; 
    431     uint16_t elements; 
    432     uint16_t frames; 
    433     uint16_t frame_index; 
    434     uint16_t element_index; 
     433 
     434    /* state data */ 
     435    int active; 
     436    int enable; 
     437    int sync; 
     438    int pending_request; 
     439    int waiting_end_prog; 
    435440    uint16_t cpc; 
     441 
     442    /* sync type */ 
     443    int fs; 
     444    int bs; 
     445 
     446    /* compatibility */ 
     447    int omap_3_1_compatible_disable; 
     448 
     449    qemu_irq irq; 
     450    struct omap_dma_channel_s *sibling; 
    436451 
    437452    struct omap_dma_reg_set_s { 
     
    444459        int elements; 
    445460    } active_set; 
     461 
     462    /* unused parameters */ 
     463    int priority; 
     464    int interleave_disabled; 
     465    int type; 
    446466}; 
    447467 
    448468struct omap_dma_s { 
    449     qemu_irq *ih; 
    450469    QEMUTimer *tm; 
    451470    struct omap_mpu_state_s *mpu; 
     
    454473    int64_t delay; 
    455474    uint32_t drq; 
     475    enum omap_dma_model model; 
     476    int omap_3_1_mapping_disabled; 
    456477 
    457478    uint16_t gcr; 
     
    463484}; 
    464485 
     486/* Interrupts */ 
     487#define TIMEOUT_INTR    (1 << 0) 
     488#define EVENT_DROP_INTR (1 << 1) 
     489#define HALF_FRAME_INTR (1 << 2) 
     490#define END_FRAME_INTR  (1 << 3) 
     491#define LAST_FRAME_INTR (1 << 4) 
     492#define END_BLOCK_INTR  (1 << 5) 
     493#define SYNC            (1 << 6) 
     494 
    465495static void omap_dma_interrupts_update(struct omap_dma_s *s) 
    466496{ 
    467     /* First three interrupts are shared between two channels each.  */ 
    468     qemu_set_irq(s->ih[OMAP_INT_DMA_CH0_6], 
    469                     (s->ch[0].status | s->ch[6].status) & 0x3f); 
    470     qemu_set_irq(s->ih[OMAP_INT_DMA_CH1_7], 
    471                     (s->ch[1].status | s->ch[7].status) & 0x3f); 
    472     qemu_set_irq(s->ih[OMAP_INT_DMA_CH2_8], 
    473                     (s->ch[2].status | s->ch[8].status) & 0x3f); 
    474     qemu_set_irq(s->ih[OMAP_INT_DMA_CH3], 
    475                     (s->ch[3].status) & 0x3f); 
    476     qemu_set_irq(s->ih[OMAP_INT_DMA_CH4], 
    477                     (s->ch[4].status) & 0x3f); 
    478     qemu_set_irq(s->ih[OMAP_INT_DMA_CH5], 
    479                     (s->ch[5].status) & 0x3f); 
    480 } 
    481  
    482 static void omap_dma_channel_load(struct omap_dma_s *s, int ch) 
    483 { 
    484     struct omap_dma_reg_set_s *a = &s->ch[ch].active_set; 
     497    struct omap_dma_channel_s *ch = s->ch; 
    485498    int i; 
     499 
     500    if (s->omap_3_1_mapping_disabled) { 
     501        for (i = 0; i < s->chans; i ++, ch ++) 
     502            if (ch->status) 
     503                qemu_irq_raise(ch->irq); 
     504    } else { 
     505        /* First three interrupts are shared between two channels each. */ 
     506        for (i = 0; i < 6; i ++, ch ++) { 
     507            if (ch->status || (ch->sibling && ch->sibling->status)) 
     508                qemu_irq_raise(ch->irq); 
     509        } 
     510    } 
     511} 
     512 
     513static void omap_dma_channel_load(struct omap_dma_s *s, 
     514                struct omap_dma_channel_s *ch) 
     515{ 
     516    struct omap_dma_reg_set_s *a = &ch->active_set; 
     517    int i; 
     518    int omap_3_1 = !ch->omap_3_1_compatible_disable; 
    486519 
    487520    /* 
     
    490523     */ 
    491524 
    492     a->src = s->ch[ch].addr[0]; 
    493     a->dest = s->ch[ch].addr[1]; 
    494     a->frames = s->ch[ch].frames; 
    495     a->elements = s->ch[ch].elements; 
     525    a->src = ch->addr[0]; 
     526    a->dest = ch->addr[1]; 
     527    a->frames = ch->frames; 
     528    a->elements = ch->elements; 
    496529    a->frame = 0; 
    497530    a->element = 0; 
    498531 
    499     if (unlikely(!s->ch[ch].elements || !s->ch[ch].frames)) { 
     532    if (unlikely(!ch->elements || !ch->frames)) { 
    500533        printf("%s: bad DMA request\n", __FUNCTION__); 
    501534        return; 
     
    503536 
    504537    for (i = 0; i < 2; i ++) 
    505         switch (s->ch[ch].mode[i]) { 
     538        switch (ch->mode[i]) { 
    506539        case constant: 
    507540            a->elem_delta[i] = 0; 
     
    509542            break; 
    510543        case post_incremented: 
    511             a->elem_delta[i] = s->ch[ch].data_type; 
     544            a->elem_delta[i] = ch->data_type; 
    512545            a->frame_delta[i] = 0; 
    513546            break; 
    514547        case single_index: 
    515             a->elem_delta[i] = s->ch[ch].data_type + 
    516                 s->ch[ch].element_index - 1; 
    517             if (s->ch[ch].element_index > 0x7fff) 
    518                 a->elem_delta[i] -= 0x10000; 
     548            a->elem_delta[i] = ch->data_type + 
     549                    ch->element_index[omap_3_1 ? 0 : i] - 1; 
    519550            a->frame_delta[i] = 0; 
    520551            break; 
    521552        case double_index: 
    522             a->elem_delta[i] = s->ch[ch].data_type + 
    523                 s->ch[ch].element_index - 1; 
    524             if (s->ch[ch].element_index > 0x7fff) 
    525                 a->elem_delta[i] -= 0x10000; 
    526             a->frame_delta[i] = s->ch[ch].frame_index - 
    527                 s->ch[ch].element_index; 
    528             if (s->ch[ch].frame_index > 0x7fff) 
    529                 a->frame_delta[i] -= 0x10000; 
     553            a->elem_delta[i] = ch->data_type + 
     554                    ch->element_index[omap_3_1 ? 0 : i] - 1; 
     555            a->frame_delta[i] = ch->frame_index[omap_3_1 ? 0 : i] - 
     556                    ch->element_index[omap_3_1 ? 0 : i]; 
    530557            break; 
    531558        default: 
     
    534561} 
    535562 
    536 static inline void omap_dma_request_run(struct omap_dma_s *s, 
    537                 int channel, int request) 
    538 { 
    539 next_channel: 
    540     if (request > 0) 
    541         for (; channel < 9; channel ++) 
    542             if (s->ch[channel].sync == request && s->ch[channel].running) 
    543                 break; 
    544     if (channel >= 9) 
    545         return; 
    546  
    547     if (s->ch[channel].transfer) { 
    548         if (request > 0) { 
    549             s->ch[channel ++].post_sync = request; 
    550             goto next_channel; 
    551         } 
    552         s->ch[channel].status |= 0x02;  /* Synchronisation drop */ 
    553         omap_dma_interrupts_update(s); 
    554         return; 
    555     } 
    556  
    557     if (!s->ch[channel].signalled) 
     563static void omap_dma_activate_channel(struct omap_dma_s *s, 
     564                struct omap_dma_channel_s *ch) 
     565{ 
     566    if (!ch->active) { 
     567        ch->active = 1; 
     568        if (ch->sync) 
     569            ch->status |= SYNC; 
    558570        s->run_count ++; 
    559     s->ch[channel].signalled = 1; 
    560  
    561     if (request > 0) 
    562         s->ch[channel].status |= 0x40;  /* External request */ 
     571    } 
    563572 
    564573    if (s->delay && !qemu_timer_pending(s->tm)) 
    565574        qemu_mod_timer(s->tm, qemu_get_clock(vm_clock) + s->delay); 
    566  
    567     if (request > 0) { 
    568         channel ++; 
    569         goto next_channel; 
    570     } 
    571 } 
    572  
    573 static inline void omap_dma_request_stop(struct omap_dma_s *s, int channel) 
    574 { 
    575     if (s->ch[channel].signalled) 
     575} 
     576 
     577static void omap_dma_deactivate_channel(struct omap_dma_s *s, 
     578                struct omap_dma_channel_s *ch) 
     579{ 
     580    /* Update cpc */ 
     581    ch->cpc = ch->active_set.dest & 0xffff; 
     582 
     583    if (ch->pending_request && !ch->waiting_end_prog) { 
     584        /* Don't deactivate the channel */ 
     585        ch->pending_request = 0; 
     586        return; 
     587    } 
     588 
     589    /* Don't deactive the channel if it is synchronized and the DMA request is 
     590       active */ 
     591    if (ch->sync && (s->drq & (1 << ch->sync))) 
     592        return; 
     593 
     594    if (ch->active) { 
     595        ch->active = 0; 
     596        ch->status &= ~SYNC; 
    576597        s->run_count --; 
    577     s->ch[channel].signalled = 0; 
     598    } 
    578599 
    579600    if (!s->run_count) 
     
    581602} 
    582603 
     604static void omap_dma_enable_channel(struct omap_dma_s *s, 
     605                struct omap_dma_channel_s *ch) 
     606{ 
     607    if (!ch->enable) { 
     608        ch->enable = 1; 
     609        ch->waiting_end_prog = 0; 
     610        omap_dma_channel_load(s, ch); 
     611        if ((!ch->sync) || (s->drq & (1 << ch->sync))) 
     612            omap_dma_activate_channel(s, ch); 
     613    } 
     614} 
     615 
     616static void omap_dma_disable_channel(struct omap_dma_s *s, 
     617                struct omap_dma_channel_s *ch) 
     618{ 
     619    if (ch->enable) { 
     620        ch->enable = 0; 
     621        /* Discard any pending request */ 
     622        ch->pending_request = 0; 
     623        omap_dma_deactivate_channel(s, ch); 
     624    } 
     625} 
     626 
     627static void omap_dma_channel_end_prog(struct omap_dma_s *s, 
     628                struct omap_dma_channel_s *ch) 
     629{ 
     630    if (ch->waiting_end_prog) { 
     631        ch->waiting_end_prog = 0; 
     632        if (!ch->sync || ch->pending_request) { 
     633            ch->pending_request = 0; 
     634            omap_dma_activate_channel(s, ch); 
     635        } 
     636    } 
     637} 
     638 
     639static void omap_dma_enable_3_1_mapping(struct omap_dma_s *s) 
     640{ 
     641    s->omap_3_1_mapping_disabled = 0; 
     642    s->chans = 9; 
     643} 
     644 
     645static void omap_dma_disable_3_1_mapping(struct omap_dma_s *s) 
     646{ 
     647    s->omap_3_1_mapping_disabled = 1; 
     648    s->chans = 16; 
     649} 
     650 
     651static void omap_dma_process_request(struct omap_dma_s *s, int request) 
     652{ 
     653    int channel; 
     654    int drop_event = 0; 
     655    struct omap_dma_channel_s *ch = s->ch; 
     656 
     657    for (channel = 0; channel < s->chans; channel ++, ch ++) { 
     658        if (ch->enable && ch->sync == request) { 
     659            if (!ch->active) 
     660                omap_dma_activate_channel(s, ch); 
     661            else if (!ch->pending_request) 
     662                ch->pending_request = 1; 
     663            else { 
     664                /* Request collision */ 
     665                /* Second request received while processing other request */ 
     666                ch->status |= EVENT_DROP_INTR; 
     667                drop_event = 1; 
     668            } 
     669        } 
     670    } 
     671 
     672    if (drop_event) 
     673        omap_dma_interrupts_update(s); 
     674} 
     675 
    583676static void omap_dma_channel_run(struct omap_dma_s *s) 
    584677{ 
    585     int ch; 
     678    int n = s->chans; 
    586679    uint16_t status; 
    587680    uint8_t value[4]; 
    588681    struct omap_dma_port_if_s *src_p, *dest_p; 
    589682    struct omap_dma_reg_set_s *a; 
    590  
    591     for (ch = 0; ch < 9; ch ++) { 
    592         a = &s->ch[ch].active_set; 
    593  
    594         src_p = &s->mpu->port[s->ch[ch].port[0]]; 
    595         dest_p = &s->mpu->port[s->ch[ch].port[1]]; 
    596         if (s->ch[ch].signalled && (!src_p->addr_valid(s->mpu, a->src) || 
    597                     !dest_p->addr_valid(s->mpu, a->dest))) { 
     683    struct omap_dma_channel_s *ch; 
     684 
     685    for (ch = s->ch; n; n --, ch ++) { 
     686        if (!ch->active) 
     687            continue; 
     688 
     689        a = &ch->active_set; 
     690 
     691        src_p = &s->mpu->port[ch->port[0]]; 
     692        dest_p = &s->mpu->port[ch->port[1]]; 
     693        if ((!ch->constant_fill && !src_p->addr_valid(s->mpu, a->src)) || 
     694                        (!dest_p->addr_valid(s->mpu, a->dest))) { 
    598695#if 0 
    599696            /* Bus time-out */ 
    600             if (s->ch[ch].interrupts & 0x01) 
    601                 s->ch[ch].status |= 0x01; 
    602             omap_dma_request_stop(s, ch); 
     697            if (ch->interrupts & TIMEOUT_INTR) 
     698                ch->status |= TIMEOUT_INTR; 
     699            omap_dma_deactivate_channel(s, ch); 
    603700            continue; 
    604701#endif 
    605             printf("%s: Bus time-out in DMA%i operation\n", __FUNCTION__, ch); 
     702            printf("%s: Bus time-out in DMA%i operation\n", 
     703                            __FUNCTION__, s->chans - n); 
    606704        } 
    607705 
    608         status = s->ch[ch].status; 
    609         while (status == s->ch[ch].status && s->ch[ch].signalled) { 
     706        status = ch->status; 
     707        while (status == ch->status && ch->active) { 
    610708            /* Transfer a single element */ 
    611             s->ch[ch].transfer = 1; 
    612             cpu_physical_memory_read(a->src, value, s->ch[ch].data_type); 
    613             cpu_physical_memory_write(a->dest, value, s->ch[ch].data_type); 
    614             s->ch[ch].transfer = 0; 
     709            /* FIXME: check the endianness */ 
     710            if (!ch->constant_fill) 
     711                cpu_physical_memory_read(a->src, value, ch->data_type); 
     712            else 
     713                *(uint32_t *) value = ch->color; 
     714 
     715            if (!ch->transparent_copy || 
     716                    *(uint32_t *) value != ch->color) 
     717                cpu_physical_memory_write(a->dest, value, ch->data_type); 
    615718 
    616719            a->src += a->elem_delta[0]; 
     
    618721            a->element ++; 
    619722 
    620             /* Check interrupt conditions */ 
     723            /* If the channel is element synchronized, deactivate it */ 
     724            if (ch->sync && !ch->fs && !ch->bs) 
     725                omap_dma_deactivate_channel(s, ch); 
     726 
     727            /* If it is the last frame, set the LAST_FRAME interrupt */ 
     728            if (a->element == 1 && a->frame == a->frames - 1) 
     729                if (ch->interrupts & LAST_FRAME_INTR) 
     730                    ch->status |= LAST_FRAME_INTR; 
     731 
     732            /* If the half of the frame was reached, set the HALF_FRAME 
     733               interrupt */ 
     734            if (a->element == (a->elements >> 1)) 
     735                if (ch->interrupts & HALF_FRAME_INTR) 
     736                    ch->status |= HALF_FRAME_INTR; 
     737 
    621738            if (a->element == a->elements) { 
     739                /* End of Frame */ 
    622740                a->element = 0; 
    623741                a->src += a->frame_delta[0]; 
     
    625743                a->frame ++; 
    626744 
     745                /* If the channel is frame synchronized, deactivate it */ 
     746                if (ch->sync && ch->fs) 
     747                    omap_dma_deactivate_channel(s, ch); 
     748 
     749                /* If the channel is async, update cpc */ 
     750                if (!ch->sync) 
     751                    ch->cpc = a->dest & 0xffff; 
     752 
     753                /* Set the END_FRAME interrupt */ 
     754                if (ch->interrupts & END_FRAME_INTR) 
     755                    ch->status |= END_FRAME_INTR; 
     756 
    627757                if (a->frame == a->frames) { 
    628                     if (!s->ch[ch].repeat || !s->ch[ch].auto_init) 
    629                         s->ch[ch].running = 0; 
    630  
    631                     if (s->ch[ch].auto_init && 
    632                             (s->ch[ch].repeat || 
    633                              s->ch[ch].end_prog)) 
    634                         omap_dma_channel_load(s, ch); 
    635  
    636                     if (s->ch[ch].interrupts & 0x20) 
    637                         s->ch[ch].status |= 0x20; 
    638  
    639                     if (!s->ch[ch].sync) 
    640                         omap_dma_request_stop(s, ch); 
    641                 } 
    642  
    643                 if (s->ch[ch].interrupts & 0x08) 
    644                     s->ch[ch].status |= 0x08; 
    645  
    646                 if (s->ch[ch].sync && s->ch[ch].fs && 
    647                                 !(s->drq & (1 << s->ch[ch].sync))) { 
    648                     s->ch[ch].status &= ~0x40; 
    649                     omap_dma_request_stop(s, ch); 
     758                    /* End of Block */ 
     759                    /* Disable the channel */ 
     760 
     761                    if (ch->omap_3_1_compatible_disable) { 
     762                        omap_dma_disable_channel(s, ch); 
     763                        if (ch->link_enabled) 
     764                            omap_dma_enable_channel(s, 
     765                                            &s->ch[ch->link_next_ch]); 
     766                    } else { 
     767                        if (!ch->auto_init) 
     768                            omap_dma_disable_channel(s, ch); 
     769                        else if (ch->repeat || ch->end_prog) 
     770                            omap_dma_channel_load(s, ch); 
     771                        else { 
     772                            ch->waiting_end_prog = 1; 
     773                            omap_dma_deactivate_channel(s, ch); 
     774                        } 
     775                    } 
     776 
     777                    if (ch->interrupts & END_BLOCK_INTR) 
     778                        ch->status |= END_BLOCK_INTR; 
    650779                } 
    651780            } 
    652  
    653             if (a->element == 1 && a->frame == a->frames - 1) 
    654                 if (s->ch[ch].interrupts & 0x10) 
    655                     s->ch[ch].status |= 0x10; 
    656  
    657             if (a->element == (a->elements >> 1)) 
    658                 if (s->ch[ch].interrupts & 0x04) 
    659                     s->ch[ch].status |= 0x04; 
    660  
    661             if (s->ch[ch].sync && !s->ch[ch].fs && 
    662                             !(s->drq & (1 << s->ch[ch].sync))) { 
    663                 s->ch[ch].status &= ~0x40; 
    664                 omap_dma_request_stop(s, ch); 
    665             } 
    666  
    667             /* 
    668              * Process requests made while the element was 
    669              * being transferred. 
    670              */ 
    671             if (s->ch[ch].post_sync) { 
    672                 omap_dma_request_run(s, 0, s->ch[ch].post_sync); 
    673                 s->ch[ch].post_sync = 0; 
    674             } 
    675  
    676 #if 0 
    677             break; 
    678 #endif 
    679781        } 
    680  
    681         s->ch[ch].cpc = a->dest & 0x0000ffff; 
    682782    } 
    683783 
     
    687787} 
    688788 
     789static void omap_dma_reset(struct omap_dma_s *s) 
     790{ 
     791    int i; 
     792 
     793    qemu_del_timer(s->tm); 
     794    s->gcr = 0x0004; 
     795    s->drq = 0x00000000; 
     796    s->run_count = 0; 
     797    s->lcd_ch.src = emiff; 
     798    s->lcd_ch.condition = 0; 
     799    s->lcd_ch.interrupts = 0; 
     800    s->lcd_ch.dual = 0; 
     801    omap_dma_enable_3_1_mapping(s); 
     802    for (i = 0; i < s->chans; i ++) { 
     803        memset(&s->ch[i].burst, 0, sizeof(s->ch[i].burst)); 
     804        memset(&s->ch[i].port, 0, sizeof(s->ch[i].port)); 
     805        memset(&s->ch[i].mode, 0, sizeof(s->ch[i].mode)); 
     806        memset(&s->ch[i].elements, 0, sizeof(s->ch[i].elements)); 
     807        memset(&s->ch[i].frames, 0, sizeof(s->ch[i].frames)); 
     808        memset(&s->ch[i].frame_index, 0, sizeof(s->ch[i].frame_index)); 
     809        memset(&s->ch[i].element_index, 0, sizeof(s->ch[i].element_index)); 
     810        memset(&s->ch[i].data_type, 0, sizeof(s->ch[i].data_type)); 
     811        memset(&s->ch[i].transparent_copy, 0, 
     812                        sizeof(s->ch[i].transparent_copy)); 
     813        memset(&s->ch[i].constant_fill, 0, sizeof(s->ch[i].constant_fill)); 
     814        memset(&s->ch[i].color, 0, sizeof(s->ch[i].color)); 
     815        memset(&s->ch[i].end_prog, 0, sizeof(s->ch[i].end_prog)); 
     816        memset(&s->ch[i].repeat, 0, sizeof(s->ch[i].repeat)); 
     817        memset(&s->ch[i].auto_init, 0, sizeof(s->ch[i].auto_init)); 
     818        memset(&s->ch[i].link_enabled, 0, sizeof(s->ch[i].link_enabled)); 
     819        memset(&s->ch[i].link_next_ch, 0, sizeof(s->ch[i].link_next_ch)); 
     820        s->ch[i].interrupts = 0x0003; 
     821        memset(&s->ch[i].status, 0, sizeof(s->ch[i].status)); 
     822        memset(&s->ch[i].active, 0, sizeof(s->ch[i].active)); 
     823        memset(&s->ch[i].enable, 0, sizeof(s->ch[i].enable)); 
     824        memset(&s->ch[i].sync, 0, sizeof(s->ch[i].sync)); 
     825        memset(&s->ch[i].pending_request, 0, sizeof(s->ch[i].pending_request)); 
     826        memset(&s->ch[i].waiting_end_prog, 0, 
     827                        sizeof(s->ch[i].waiting_end_prog)); 
     828        memset(&s->ch[i].cpc, 0, sizeof(s->ch[i].cpc)); 
     829        memset(&s->ch[i].fs, 0, sizeof(s->ch[i].fs)); 
     830        memset(&s->ch[i].bs, 0, sizeof(s->ch[i].bs)); 
     831        memset(&s->ch[i].omap_3_1_compatible_disable, 0, 
     832                        sizeof(s->ch[i].omap_3_1_compatible_disable)); 
     833        memset(&s->ch[i].active_set, 0, sizeof(s->ch[i].active_set)); 
     834        memset(&s->ch[i].priority, 0, sizeof(s->ch[i].priority)); 
     835        memset(&s->ch[i].interleave_disabled, 0, 
     836                        sizeof(s->ch[i].interleave_disabled)); 
     837        memset(&s->ch[i].type, 0, sizeof(s->ch[i].type)); 
     838    } 
     839} 
     840 
    689841static int omap_dma_ch_reg_read(struct omap_dma_s *s, 
    690                 int ch, int reg, uint16_t *value) { 
     842                struct omap_dma_channel_s *ch, int reg, uint16_t *value) 
     843{ 
    691844    switch (reg) { 
    692845    case 0x00:  /* SYS_DMA_CSDP_CH0 */ 
    693         *value = (s->ch[ch].burst[1] << 14) | 
    694                 (s->ch[ch].pack[1] << 13) | 
    695                 (s->ch[ch].port[1] << 9) | 
    696                 (s->ch[ch].burst[0] << 7) | 
    697                 (s->ch[ch].pack[0] << 6) | 
    698                 (s->ch[ch].port[0] << 2) | 
    699                 (s->ch[ch].data_type >> 1); 
     846        *value = (ch->burst[1] << 14) | 
     847                (ch->pack[1] << 13) | 
     848                (ch->port[1] << 9) | 
     849                (ch->burst[0] << 7) | 
     850                (ch->pack[0] << 6) | 
     851                (ch->port[0] << 2) | 
     852                (ch->data_type >> 1); 
    700853        break; 
    701854 
    702855    case 0x02:  /* SYS_DMA_CCR_CH0 */ 
    703         *value = (s->ch[ch].mode[1] << 14) | 
    704                 (s->ch[ch].mode[0] << 12) | 
    705                 (s->ch[ch].end_prog << 11) | 
    706                 (s->ch[ch].repeat << 9) | 
    707                 (s->ch[ch].auto_init << 8) | 
    708                 (s->ch[ch].running << 7) | 
    709                 (s->ch[ch].priority << 6) | 
    710                 (s->ch[ch].fs << 5) | s->ch[ch].sync; 
     856        if (s->model == omap_dma_3_1) 
     857            *value = 0 << 10;                   /* FIFO_FLUSH reads as 0 */ 
     858        else 
     859            *value = ch->omap_3_1_compatible_disable << 10; 
     860        *value |= (ch->mode[1] << 14) | 
     861                (ch->mode[0] << 12) | 
     862                (ch->end_prog << 11) | 
     863                (ch->repeat << 9) | 
     864                (ch->auto_init << 8) | 
     865                (ch->enable << 7) | 
     866                (ch->priority << 6) | 
     867                (ch->fs << 5) | ch->sync; 
    711868        break; 
    712869 
    713870    case 0x04:  /* SYS_DMA_CICR_CH0 */ 
    714         *value = s->ch[ch].interrupts; 
     871        *value = ch->interrupts; 
    715872        break; 
    716873 
    717874    case 0x06:  /* SYS_DMA_CSR_CH0 */ 
    718         /* FIXME: shared CSR for channels sharing the interrupts */ 
    719         *value = s->ch[ch].status; 
    720         s->ch[ch].status &= 0x40; 
    721         omap_dma_interrupts_update(s); 
     875        *value = ch->status; 
     876        ch->status &= SYNC; 
     877        if (!ch->omap_3_1_compatible_disable && ch->sibling) { 
     878            *value |= (ch->sibling->status & 0x3f) << 6; 
     879            ch->sibling->status &= SYNC; 
     880        } 
     881        qemu_irq_lower(ch->irq); 
    722882        break; 
    723883 
    724884    case 0x08:  /* SYS_DMA_CSSA_L_CH0 */ 
    725         *value = s->ch[ch].addr[0] & 0x0000ffff; 
     885        *value = ch->addr[0] & 0x0000ffff; 
    726886        break; 
    727887 
    728888    case 0x0a:  /* SYS_DMA_CSSA_U_CH0 */ 
    729         *value = s->ch[ch].addr[0] >> 16; 
     889        *value = ch->addr[0] >> 16; 
    730890        break; 
    731891 
    732892    case 0x0c:  /* SYS_DMA_CDSA_L_CH0 */ 
    733         *value = s->ch[ch].addr[1] & 0x0000ffff; 
     893        *value = ch->addr[1] & 0x0000ffff; 
    734894        break; 
    735895 
    736896    case 0x0e:  /* SYS_DMA_CDSA_U_CH0 */ 
    737         *value = s->ch[ch].addr[1] >> 16; 
     897        *value = ch->addr[1] >> 16; 
    738898        break; 
    739899 
    740900    case 0x10:  /* SYS_DMA_CEN_CH0 */ 
    741         *value = s->ch[ch].elements; 
     901        *value = ch->elements; 
    742902        break; 
    743903 
    744904    case 0x12:  /* SYS_DMA_CFN_CH0 */ 
    745         *value = s->ch[ch].frames; 
     905        *value = ch->frames; 
    746906        break; 
    747907 
    748908    case 0x14:  /* SYS_DMA_CFI_CH0 */ 
    749         *value = s->ch[ch].frame_index; 
     909        *value = ch->frame_index[0]; 
    750910        break; 
    751911 
    752912    case 0x16:  /* SYS_DMA_CEI_CH0 */ 
    753         *value = s->ch[ch].element_index; 
    754         break; 
    755  
    756     case 0x18:  /* SYS_DMA_CPC_CH0 */ 
    757         *value = s->ch[ch].cpc; 
     913        *value = ch->element_index[0]; 
     914        break; 
     915 
     916    case 0x18:  /* SYS_DMA_CPC_CH0 or DMA_CSAC */ 
     917        if (ch->omap_3_1_compatible_disable) 
     918            *value = ch->active_set.src & 0xffff;       /* CSAC */ 
     919        else 
     920            *value = ch->cpc; 
     921        break; 
     922 
     923    case 0x1a:  /* DMA_CDAC */ 
     924        *value = ch->active_set.dest & 0xffff;  /* CDAC */ 
     925        break; 
     926 
     927    case 0x1c:  /* DMA_CDEI */ 
     928        *value = ch->element_index[1]; 
     929        break; 
     930 
     931    case 0x1e:  /* DMA_CDFI */ 
     932        *value = ch->frame_index[1]; 
     933        break; 
     934 
     935    case 0x20:  /* DMA_COLOR_L */ 
     936        *value = ch->color & 0xffff; 
     937        break; 
     938 
     939    case 0x22:  /* DMA_COLOR_U */ 
     940        *value = ch->color >> 16; 
     941        break; 
     942 
     943    case 0x24:  /* DMA_CCR2 */ 
     944        *value = (ch->bs << 2) | 
     945                (ch->transparent_copy << 1) | 
     946                ch->constant_fill; 
     947        break; 
     948 
     949    case 0x28:  /* DMA_CLNK_CTRL */ 
     950        *value = (ch->link_enabled << 15) | 
     951                (ch->link_next_ch & 0xf); 
     952        break; 
     953 
     954    case 0x2a:  /* DMA_LCH_CTRL */ 
     955        *value = (ch->interleave_disabled << 15) | 
     956                ch->type; 
    758957        break; 
    759958 
     
    765964 
    766965static int omap_dma_ch_reg_write(struct omap_dma_s *s, 
    767                 int ch, int reg, uint16_t value) { 
     966                struct omap_dma_channel_s *ch, int reg, uint16_t value) 
     967{ 
    768968    switch (reg) { 
    769969    case 0x00:  /* SYS_DMA_CSDP_CH0 */ 
    770         s->ch[ch].burst[1] = (value & 0xc000) >> 14; 
    771         s->ch[ch].pack[1] = (value & 0x2000) >> 13; 
    772         s->ch[ch].port[1] = (enum omap_dma_port) ((value & 0x1e00) >> 9); 
    773         s->ch[ch].burst[0] = (value & 0x0180) >> 7; 
    774         s->ch[ch].pack[0] = (value & 0x0040) >> 6; 
    775         s->ch[ch].port[0] = (enum omap_dma_port) ((value & 0x003c) >> 2); 
    776         s->ch[ch].data_type = (1 << (value & 3)); 
    777         if (s->ch[ch].port[0] >= omap_dma_port_last) 
     970        ch->burst[1] = (value & 0xc000) >> 14; 
     971        ch->pack[1] = (value & 0x2000) >> 13; 
     972        ch->port[1] = (enum omap_dma_port) ((value & 0x1e00) >> 9); 
     973        ch->burst[0] = (value & 0x0180) >> 7; 
     974        ch->pack[0] = (value & 0x0040) >> 6; 
     975        ch->port[0] = (enum omap_dma_port) ((value & 0x003c) >> 2); 
     976        ch->data_type = (1 << (value & 3)); 
     977        if (ch->port[0] >= omap_dma_port_last) 
    778978            printf("%s: invalid DMA port %i\n", __FUNCTION__, 
    779                             s->ch[ch].port[0]); 
    780         if (s->ch[ch].port[1] >= omap_dma_port_last) 
     979                            ch->port[0]); 
     980        if (ch->port[1] >= omap_dma_port_last) 
    781981            printf("%s: invalid DMA port %i\n", __FUNCTION__, 
    782                             s->ch[ch].port[1]); 
     982                            ch->port[1]); 
    783983        if ((value & 3) == 3) 
    784             printf("%s: bad data_type for DMA channel %i\n", __FUNCTION__, ch); 
     984            printf("%s: bad data_type for DMA channel\n", __FUNCTION__); 
    785985        break; 
    786986 
    787987    case 0x02:  /* SYS_DMA_CCR_CH0 */ 
    788         s->ch[ch].mode[1] = (omap_dma_addressing_t) ((value & 0xc000) >> 14); 
    789         s->ch[ch].mode[0] = (omap_dma_addressing_t) ((value & 0x3000) >> 12); 
    790         s->ch[ch].end_prog = (value & 0x0800) >> 11; 
    791         s->ch[ch].repeat = (value & 0x0200) >> 9; 
    792         s->ch[ch].auto_init = (value & 0x0100) >> 8; 
    793         s->ch[ch].priority = (value & 0x0040) >> 6; 
    794         s->ch[ch].fs = (value & 0x0020) >> 5; 
    795         s->ch[ch].sync = value & 0x001f; 
    796         if (value & 0x0080) { 
    797             if (s->ch[ch].running) { 
    798                 if (!s->ch[ch].signalled && 
    799                                 s->ch[ch].auto_init && s->ch[ch].end_prog) 
    800                     omap_dma_channel_load(s, ch); 
    801             } else { 
    802                 s->ch[ch].running = 1; 
    803                 omap_dma_channel_load(s, ch); 
    804             } 
    805             if (!s->ch[ch].sync || (s->drq & (1 << s->ch[ch].sync))) 
    806                 omap_dma_request_run(s, ch, 0); 
    807         } else { 
    808             s->ch[ch].running = 0; 
    809             omap_dma_request_stop(s, ch); 
     988        ch->mode[1] = (omap_dma_addressing_t) ((value & 0xc000) >> 14); 
     989        ch->mode[0] = (omap_dma_addressing_t) ((value & 0x3000) >> 12); 
     990        ch->end_prog = (value & 0x0800) >> 11; 
     991        if (s->model > omap_dma_3_1) 
     992            ch->omap_3_1_compatible_disable  = (value >> 10) & 0x1; 
     993        ch->repeat = (value & 0x0200) >> 9; 
     994        ch->auto_init = (value & 0x0100) >> 8; 
     995        ch->priority = (value & 0x0040) >> 6; 
     996        ch->fs = (value & 0x0020) >> 5; 
     997        ch->sync = value & 0x001f; 
     998 
     999        if (value & 0x0080) 
     1000            omap_dma_enable_channel(s, ch); 
     1001        else 
     1002            omap_dma_disable_channel(s, ch); 
     1003 
     1004        if (ch->end_prog) 
     1005            omap_dma_channel_end_prog(s, ch); 
     1006 
     1007        break; 
     1008 
     1009    case 0x04:  /* SYS_DMA_CICR_CH0 */ 
     1010        ch->interrupts = value; 
     1011        break; 
     1012 
     1013    case 0x06:  /* SYS_DMA_CSR_CH0 */ 
     1014        OMAP_RO_REG((target_phys_addr_t) reg); 
     1015        break; 
     1016 
     1017    case 0x08:  /* SYS_DMA_CSSA_L_CH0 */ 
     1018        ch->addr[0] &= 0xffff0000; 
     1019        ch->addr[0] |= value; 
     1020        break; 
     1021 
     1022    case 0x0a:  /* SYS_DMA_CSSA_U_CH0 */ 
     1023        ch->addr[0] &= 0x0000ffff; 
     1024        ch->addr[0] |= (uint32_t) value << 16; 
     1025        break; 
     1026 
     1027    case 0x0c:  /* SYS_DMA_CDSA_L_CH0 */ 
     1028        ch->addr[1] &= 0xffff0000; 
     1029        ch->addr[1] |= value; 
     1030        break; 
     1031 
     1032    case 0x0e:  /* SYS_DMA_CDSA_U_CH0 */ 
     1033        ch->addr[1] &= 0x0000ffff; 
     1034        ch->addr[1] |= (uint32_t) value << 16; 
     1035        break; 
     1036 
     1037    case 0x10:  /* SYS_DMA_CEN_CH0 */ 
     1038        ch->elements = value; 
     1039        break; 
     1040 
     1041    case 0x12:  /* SYS_DMA_CFN_CH0 */ 
     1042        ch->frames = value; 
     1043        break; 
     1044 
     1045    case 0x14:  /* SYS_DMA_CFI_CH0 */ 
     1046        ch->frame_index[0] = (int16_t) value; 
     1047        break; 
     1048 
     1049    case 0x16:  /* SYS_DMA_CEI_CH0 */ 
     1050        ch->element_index[0] = (int16_t) value; 
     1051        break; 
     1052 
     1053    case 0x18:  /* SYS_DMA_CPC_CH0 or DMA_CSAC */ 
     1054        OMAP_RO_REG((target_phys_addr_t) reg); 
     1055        break; 
     1056 
     1057    case 0x1c:  /* DMA_CDEI */ 
     1058        ch->element_index[1] = (int16_t) value; 
     1059        break; 
     1060 
     1061    case 0x1e:  /* DMA_CDFI */ 
     1062        ch->frame_index[1] = (int16_t) value; 
     1063        break; 
     1064 
     1065    case 0x20:  /* DMA_COLOR_L */ 
     1066        ch->color &= 0xffff0000; 
     1067        ch->color |= value; 
     1068        break; 
     1069 
     1070    case 0x22:  /* DMA_COLOR_U */ 
     1071        ch->color &= 0xffff; 
     1072        ch->color |= value << 16; 
     1073        break; 
     1074 
     1075    case 0x24:  /* DMA_CCR2 */ 
     1076        ch->bs  = (value >> 2) & 0x1; 
     1077        ch->transparent_copy = (value >> 1) & 0x1; 
     1078        ch->constant_fill = value & 0x1; 
     1079        break; 
     1080 
     1081    case 0x28:  /* DMA_CLNK_CTRL */ 
     1082        ch->link_enabled = (value >> 15) & 0x1; 
     1083        if (value & (1 << 14)) {                        /* Stop_Lnk */ 
     1084            ch->link_enabled = 0; 
     1085            omap_dma_disable_channel(s, ch); 
    8101086        } 
    811         break; 
    812  
    813     case 0x04:  /* SYS_DMA_CICR_CH0 */ 
    814         s->ch[ch].interrupts = value & 0x003f; 
    815         break; 
    816  
    817     case 0x06:  /* SYS_DMA_CSR_CH0 */ 
     1087        ch->link_next_ch = value & 0x1f; 
     1088        break; 
     1089 
     1090    case 0x2a:  /* DMA_LCH_CTRL */ 
     1091        ch->interleave_disabled = (value >> 15) & 0x1; 
     1092        ch->type = value & 0xf; 
     1093        break; 
     1094 
     1095    default: 
    8181096        return 1; 
    819  
    820     case 0x08:  /* SYS_DMA_CSSA_L_CH0 */ 
    821         s->ch[ch].addr[0] &= 0xffff0000; 
    822         s->ch[ch].addr[0] |= value; 
    823         break; 
    824  
    825     case 0x0a:  /* SYS_DMA_CSSA_U_CH0 */ 
    826         s->ch[ch].addr[0] &= 0x0000ffff; 
    827         s->ch[ch].addr[0] |= (uint32_t) value << 16; 
    828         break; 
    829  
    830     case 0x0c:  /* SYS_DMA_CDSA_L_CH0 */ 
    831         s->ch[ch].addr[1] &= 0xffff0000; 
    832         s->ch[ch].addr[1] |= value; 
    833         break; 
    834  
    835     case 0x0e:  /* SYS_DMA_CDSA_U_CH0 */ 
    836         s->ch[ch].addr[1] &= 0x0000ffff; 
    837         s->ch[ch].addr[1] |= (uint32_t) value << 16; 
    838         break; 
    839  
    840     case 0x10:  /* SYS_DMA_CEN_CH0 */ 
    841         s->ch[ch].elements = value & 0xffff; 
    842         break; 
    843  
    844     case 0x12:  /* SYS_DMA_CFN_CH0 */ 
    845         s->ch[ch].frames = value & 0xffff; 
    846         break; 
    847  
    848     case 0x14:  /* SYS_DMA_CFI_CH0 */ 
    849         s->ch[ch].frame_index = value & 0xffff; 
    850         break; 
    851  
    852     case 0x16:  /* SYS_DMA_CEI_CH0 */ 
    853         s->ch[ch].element_index = value & 0xffff; 
    854         break; 
    855  
    856     case 0x18:  /* SYS_DMA_CPC_CH0 */ 
     1097    } 
     1098    return 0; 
     1099} 
     1100 
     1101static int omap_dma_3_2_lcd_write(struct omap_dma_lcd_channel_s *s, int offset, 
     1102                uint16_t value) 
     1103{ 
     1104    switch (offset) { 
     1105    case 0xbc0: /* DMA_LCD_CSDP */ 
     1106        s->brust_f2 = (value >> 14) & 0x3; 
     1107        s->pack_f2 = (value >> 13) & 0x1; 
     1108        s->data_type_f2 = (1 << ((value >> 11) & 0x3)); 
     1109        s->brust_f1 = (value >> 7) & 0x3; 
     1110        s->pack_f1 = (value >> 6) & 0x1; 
     1111        s->data_type_f1 = (1 << ((value >> 0) & 0x3)); 
     1112        break; 
     1113 
     1114    case 0xbc2: /* DMA_LCD_CCR */ 
     1115        s->mode_f2 = (value >> 14) & 0x3; 
     1116        s->mode_f1 = (value >> 12) & 0x3; 
     1117        s->end_prog = (value >> 11) & 0x1; 
     1118        s->omap_3_1_compatible_disable = (value >> 10) & 0x1; 
     1119        s->repeat = (value >> 9) & 0x1; 
     1120        s->auto_init = (value >> 8) & 0x1; 
     1121        s->running = (value >> 7) & 0x1; 
     1122        s->priority = (value >> 6) & 0x1; 
     1123        s->bs = (value >> 4) & 0x1; 
     1124        break; 
     1125 
     1126    case 0xbc4: /* DMA_LCD_CTRL */ 
     1127        s->dst = (value >> 8) & 0x1; 
     1128        s->src = ((value >> 6) & 0x3) << 1; 
     1129        s->condition = 0; 
     1130        /* Assume no bus errors and thus no BUS_ERROR irq bits.  */ 
     1131        s->interrupts = (value >> 1) & 1; 
     1132        s->dual = value & 1; 
     1133        break; 
     1134 
     1135    case 0xbc8: /* TOP_B1_L */ 
     1136        s->src_f1_top &= 0xffff0000; 
     1137        s->src_f1_top |= 0x0000ffff & value; 
     1138        break; 
     1139 
     1140    case 0xbca: /* TOP_B1_U */ 
     1141        s->src_f1_top &= 0x0000ffff; 
     1142        s->src_f1_top |= value << 16; 
     1143        break; 
     1144 
     1145    case 0xbcc: /* BOT_B1_L */ 
     1146        s->src_f1_bottom &= 0xffff0000; 
     1147        s->src_f1_bottom |= 0x0000ffff & value; 
     1148        break; 
     1149 
     1150    case 0xbce: /* BOT_B1_U */ 
     1151        s->src_f1_bottom &= 0x0000ffff; 
     1152        s->src_f1_bottom |= (uint32_t) value << 16; 
     1153        break; 
     1154 
     1155    case 0xbd0: /* TOP_B2_L */ 
     1156        s->src_f2_top &= 0xffff0000; 
     1157        s->src_f2_top |= 0x0000ffff & value; 
     1158        break; 
     1159 
     1160    case 0xbd2: /* TOP_B2_U */ 
     1161        s->src_f2_top &= 0x0000ffff; 
     1162        s->src_f2_top |= (uint32_t) value << 16; 
     1163        break; 
     1164 
     1165    case 0xbd4: /* BOT_B2_L */ 
     1166        s->src_f2_bottom &= 0xffff0000; 
     1167        s->src_f2_bottom |= 0x0000ffff & value; 
     1168        break; 
     1169 
     1170    case 0xbd6: /* BOT_B2_U */ 
     1171        s->src_f2_bottom &= 0x0000ffff; 
     1172        s->src_f2_bottom |= (uint32_t) value << 16; 
     1173        break; 
     1174 
     1175    case 0xbd8: /* DMA_LCD_SRC_EI_B1 */ 
     1176        s->element_index_f1 = value; 
     1177        break; 
     1178 
     1179    case 0xbda: /* DMA_LCD_SRC_FI_B1_L */ 
     1180        s->frame_index_f1 &= 0xffff0000; 
     1181        s->frame_index_f1 |= 0x0000ffff & value; 
     1182        break; 
     1183 
     1184    case 0xbf4: /* DMA_LCD_SRC_FI_B1_U */ 
     1185        s->frame_index_f1 &= 0x0000ffff; 
     1186        s->frame_index_f1 |= (uint32_t) value << 16; 
     1187        break; 
     1188 
     1189    case 0xbdc: /* DMA_LCD_SRC_EI_B2 */ 
     1190        s->element_index_f2 = value; 
     1191        break; 
     1192 
     1193    case 0xbde: /* DMA_LCD_SRC_FI_B2_L */ 
     1194        s->frame_index_f2 &= 0xffff0000; 
     1195        s->frame_index_f2 |= 0x0000ffff & value; 
     1196        break; 
     1197 
     1198    case 0xbf6: /* DMA_LCD_SRC_FI_B2_U */ 
     1199        s->frame_index_f2 &= 0x0000ffff; 
     1200        s->frame_index_f2 |= (uint32_t) value << 16; 
     1201        break; 
     1202 
     1203    case 0xbe0: /* DMA_LCD_SRC_EN_B1 */ 
     1204        s->elements_f1 = value; 
     1205        break; 
     1206 
     1207    case 0xbe4: /* DMA_LCD_SRC_FN_B1 */ 
     1208        s->frames_f1 = value; 
     1209        break; 
     1210 
     1211    case 0xbe2: /* DMA_LCD_SRC_EN_B2 */ 
     1212        s->elements_f2 = value; 
     1213        break; 
     1214 
     1215    case 0xbe6: /* DMA_LCD_SRC_FN_B2 */ 
     1216        s->frames_f2 = value; 
     1217        break; 
     1218 
     1219    case 0xbea: /* DMA_LCD_LCH_CTRL */ 
     1220        s->lch_type = value & 0xf; 
     1221        break; 
     1222 
     1223    default: 
    8571224        return 1; 
     1225    } 
     1226    return 0; 
     1227} 
     1228 
     1229static int omap_dma_3_2_lcd_read(struct omap_dma_lcd_channel_s *s, int offset, 
     1230                uint16_t *ret) 
     1231{ 
     1232    switch (offset) { 
     1233    case 0xbc0: /* DMA_LCD_CSDP */ 
     1234        *ret = (s->brust_f2 << 14) | 
     1235            (s->pack_f2 << 13) | 
     1236            ((s->data_type_f2 >> 1) << 11) | 
     1237            (s->brust_f1 << 7) | 
     1238            (s->pack_f1 << 6) | 
     1239            ((s->data_type_f1 >> 1) << 0); 
     1240        break; 
     1241 
     1242    case 0xbc2: /* DMA_LCD_CCR */ 
     1243        *ret = (s->mode_f2 << 14) | 
     1244            (s->mode_f1 << 12) | 
     1245            (s->end_prog << 11) | 
     1246            (s->omap_3_1_compatible_disable << 10) | 
     1247            (s->repeat << 9) | 
     1248            (s->auto_init << 8) | 
     1249            (s->running << 7) | 
     1250            (s->priority << 6) | 
     1251            (s->bs << 4); 
     1252        break; 
     1253 
     1254    case 0xbc4: /* DMA_LCD_CTRL */ 
     1255        qemu_irq_lower(s->irq); 
     1256        *ret = (s->dst << 8) | 
     1257            ((s->src & 0x6) << 5) | 
     1258            (s->condition << 3) | 
     1259            (s->interrupts << 1) | 
     1260            s->dual; 
     1261        break; 
     1262 
     1263    case 0xbc8: /* TOP_B1_L */ 
     1264        *ret = s->src_f1_top & 0xffff; 
     1265        break; 
     1266 
     1267    case 0xbca: /* TOP_B1_U */ 
     1268        *ret = s->src_f1_top >> 16; 
     1269        break; 
     1270 
     1271    case 0xbcc: /* BOT_B1_L */ 
     1272        *ret = s->src_f1_bottom & 0xffff; 
     1273        break; 
     1274 
     1275    case 0xbce: /* BOT_B1_U */ 
     1276        *ret = s->src_f1_bottom >> 16; 
     1277        break; 
     1278 
     1279    case 0xbd0: /* TOP_B2_L */ 
     1280        *ret = s->src_f2_top & 0xffff; 
     1281        break; 
     1282 
     1283    case 0xbd2: /* TOP_B2_U */ 
     1284        *ret = s->src_f2_top >> 16; 
     1285        break; 
     1286 
     1287    case 0xbd4: /* BOT_B2_L */ 
     1288        *ret = s->src_f2_bottom & 0xffff; 
     1289        break; 
     1290 
     1291    case 0xbd6: /* BOT_B2_U */ 
     1292        *ret = s->src_f2_bottom >> 16; 
     1293        break; 
     1294 
     1295    case 0xbd8: /* DMA_LCD_SRC_EI_B1 */ 
     1296        *ret = s->element_index_f1; 
     1297        break; 
     1298 
     1299    case 0xbda: /* DMA_LCD_SRC_FI_B1_L */ 
     1300        *ret = s->frame_index_f1 & 0xffff; 
     1301        break; 
     1302 
     1303    case 0xbf4: /* DMA_LCD_SRC_FI_B1_U */ 
     1304        *ret = s->frame_index_f1 >> 16; 
     1305        break; 
     1306 
     1307    case 0xbdc: /* DMA_LCD_SRC_EI_B2 */ 
     1308        *ret = s->element_index_f2; 
     1309        break; 
     1310 
     1311    case 0xbde: /* DMA_LCD_SRC_FI_B2_L */ 
     1312        *ret = s->frame_index_f2 & 0xffff; 
     1313        break; 
     1314 
     1315    case 0xbf6: /* DMA_LCD_SRC_FI_B2_U */ 
     1316        *ret = s->frame_index_f2 >> 16; 
     1317        break; 
     1318 
     1319    case 0xbe0: /* DMA_LCD_SRC_EN_B1 */ 
     1320        *ret = s->elements_f1; 
     1321        break; 
     1322 
     1323    case 0xbe4: /* DMA_LCD_SRC_FN_B1 */ 
     1324        *ret = s->frames_f1; 
     1325        break; 
     1326 
     1327    case 0xbe2: /* DMA_LCD_SRC_EN_B2 */ 
     1328        *ret = s->elements_f2; 
     1329        break; 
     1330 
     1331    case 0xbe6: /* DMA_LCD_SRC_FN_B2 */ 
     1332        *ret = s->frames_f2; 
     1333        break; 
     1334 
     1335    case 0xbea: /* DMA_LCD_LCH_CTRL */ 
     1336        *ret = s->lch_type; 
     1337        break; 
    8581338 
    8591339    default: 
    860         OMAP_BAD_REG((target_phys_addr_t) reg); 
     1340        return 1; 
    8611341    } 
    8621342    return 0; 
    8631343} 
    8641344 
     1345static int omap_dma_3_1_lcd_write(struct omap_dma_lcd_channel_s *s, int offset, 
     1346                uint16_t value) 
     1347{ 
     1348    switch (offset) { 
     1349    case 0x300: /* SYS_DMA_LCD_CTRL */ 
     1350        s->src = (value & 0x40) ? imif : emiff; 
     1351        s->condition = 0; 
     1352        /* Assume no bus errors and thus no BUS_ERROR irq bits.  */ 
     1353        s->interrupts = (value >> 1) & 1; 
     1354        s->dual = value & 1; 
     1355        break; 
     1356 
     1357    case 0x302: /* SYS_DMA_LCD_TOP_F1_L */ 
     1358        s->src_f1_top &= 0xffff0000; 
     1359        s->src_f1_top |= 0x0000ffff & value; 
     1360        break; 
     1361 
     1362    case 0x304: /* SYS_DMA_LCD_TOP_F1_U */ 
     1363        s->src_f1_top &= 0x0000ffff; 
     1364        s->src_f1_top |= value << 16; 
     1365        break; 
     1366 
     1367    case 0x306: /* SYS_DMA_LCD_BOT_F1_L */ 
     1368        s->src_f1_bottom &= 0xffff0000; 
     1369        s->src_f1_bottom |= 0x0000ffff & value; 
     1370        break; 
     1371 
     1372    case 0x308: /* SYS_DMA_LCD_BOT_F1_U */ 
     1373        s->src_f1_bottom &= 0x0000ffff; 
     1374        s->src_f1_bottom |= value << 16; 
     1375        break; 
     1376 
     1377    case 0x30a: /* SYS_DMA_LCD_TOP_F2_L */ 
     1378        s->src_f2_top &= 0xffff0000; 
     1379        s->src_f2_top |= 0x0000ffff & value; 
     1380        break; 
     1381 
     1382    case 0x30c: /* SYS_DMA_LCD_TOP_F2_U */ 
     1383        s->src_f2_top &= 0x0000ffff; 
     1384        s->src_f2_top |= value << 16; 
     1385        break; 
     1386 
     1387    case 0x30e: /* SYS_DMA_LCD_BOT_F2_L */ 
     1388        s->src_f2_bottom &= 0xffff0000; 
     1389        s->src_f2_bottom |= 0x0000ffff & value; 
     1390        break; 
     1391 
     1392    case 0x310: /* SYS_DMA_LCD_BOT_F2_U */ 
     1393        s->src_f2_bottom &= 0x0000ffff; 
     1394        s->src_f2_bottom |= value << 16; 
     1395        break; 
     1396 
     1397    default: 
     1398        return 1; 
     1399    } 
     1400    return 0; 
     1401} 
     1402 
     1403static int omap_dma_3_1_lcd_read(struct omap_dma_lcd_channel_s *s, int offset, 
     1404                uint16_t *ret) 
     1405{ 
     1406    int i; 
     1407 
     1408    switch (offset) { 
     1409    case 0x300: /* SYS_DMA_LCD_CTRL */ 
     1410        i = s->condition; 
     1411        s->condition = 0; 
     1412        qemu_irq_lower(s->irq); 
     1413        *ret = ((s->src == imif) << 6) | (i << 3) | 
     1414                (s->interrupts << 1) | s->dual; 
     1415        break; 
     1416 
     1417    case 0x302: /* SYS_DMA_LCD_TOP_F1_L */ 
     1418        *ret = s->src_f1_top & 0xffff; 
     1419        break; 
     1420 
     1421    case 0x304: /* SYS_DMA_LCD_TOP_F1_U */ 
     1422        *ret = s->src_f1_top >> 16; 
     1423        break; 
     1424 
     1425    case 0x306: /* SYS_DMA_LCD_BOT_F1_L */ 
     1426        *ret = s->src_f1_bottom & 0xffff; 
     1427        break; 
     1428 
     1429    case 0x308: /* SYS_DMA_LCD_BOT_F1_U */ 
     1430        *ret = s->src_f1_bottom >> 16; 
     1431        break; 
     1432 
     1433    case 0x30a: /* SYS_DMA_LCD_TOP_F2_L */ 
     1434        *ret = s->src_f2_top & 0xffff; 
     1435        break; 
     1436 
     1437    case 0x30c: /* SYS_DMA_LCD_TOP_F2_U */ 
     1438        *ret = s->src_f2_top >> 16; 
     1439        break; 
     1440 
     1441    case 0x30e: /* SYS_DMA_LCD_BOT_F2_L */ 
     1442        *ret = s->src_f2_bottom & 0xffff; 
     1443        break; 
     1444 
     1445    case 0x310: /* SYS_DMA_LCD_BOT_F2_U */ 
     1446        *ret = s->src_f2_bottom >> 16; 
     1447        break; 
     1448 
     1449    default: 
     1450        return 1; 
     1451    } 
     1452    return 0; 
     1453} 
     1454 
     1455static int omap_dma_sys_write(struct omap_dma_s *s, int offset, uint16_t value) 
     1456{ 
     1457    switch (offset) { 
     1458    case 0x400: /* SYS_DMA_GCR */ 
     1459        s->gcr = value; 
     1460        break; 
     1461 
     1462    case 0x404: /* DMA_GSCR */ 
     1463        if (value & 0x8) 
     1464            omap_dma_disable_3_1_mapping(s); 
     1465        else 
     1466            omap_dma_enable_3_1_mapping(s); 
     1467        break; 
     1468 
     1469    case 0x408: /* DMA_GRST */ 
     1470        if (value & 0x1) 
     1471            omap_dma_reset(s); 
     1472        break; 
     1473 
     1474    default: 
     1475        return 1; 
     1476    } 
     1477    return 0; 
     1478} 
     1479 
     1480static int omap_dma_sys_read(struct omap_dma_s *s, int offset, 
     1481                uint16_t *ret) 
     1482{ 
     1483    switch (offset) { 
     1484    case 0x400: /* SYS_DMA_GCR */ 
     1485        *ret = s->gcr; 
     1486        break; 
     1487 
     1488    case 0x404: /* DMA_GSCR */ 
     1489        *ret = s->omap_3_1_mapping_disabled << 3; 
     1490        break; 
     1491 
     1492    case 0x408: /* DMA_GRST */ 
     1493        *ret = 0; 
     1494        break; 
     1495 
     1496    case 0x442: /* DMA_HW_ID */ 
     1497    case 0x444: /* DMA_PCh2_ID */ 
     1498    case 0x446: /* DMA_PCh0_ID */ 
     1499    case 0x448: /* DMA_PCh1_ID */ 
     1500    case 0x44a: /* DMA_PChG_ID */ 
     1501    case 0x44c: /* DMA_PChD_ID */ 
     1502        *ret = 1; 
     1503        break; 
     1504 
     1505    case 0x44e: /* DMA_CAPS_0_U */ 
     1506        *ret = (1 << 3) | /* Constant Fill Capacity */ 
     1507            (1 << 2);     /* Transparent BLT Capacity */ 
     1508        break; 
     1509 
     1510    case 0x450: /* DMA_CAPS_0_L */ 
     1511    case 0x452: /* DMA_CAPS_1_U */ 
     1512        *ret = 0; 
     1513        break; 
     1514 
     1515    case 0x454: /* DMA_CAPS_1_L */ 
     1516        *ret = (1 << 1); /* 1-bit palletized capability */ 
     1517        break; 
     1518 
     1519    case 0x456: /* DMA_CAPS_2 */ 
     1520        *ret = (1 << 8) | /* SSDIC */ 
     1521            (1 << 7) |    /* DDIAC */ 
     1522            (1 << 6) |    /* DSIAC */ 
     1523            (1 << 5) |    /* DPIAC */ 
     1524            (1 << 4) |    /* DCAC  */ 
     1525            (1 << 3) |    /* SDIAC */ 
     1526            (1 << 2) |    /* SSIAC */ 
     1527            (1 << 1) |    /* SPIAC */ 
     1528            1;            /* SCAC  */ 
     1529        break; 
     1530 
     1531    case 0x458: /* DMA_CAPS_3 */ 
     1532        *ret = (1 << 5) | /* CCC */ 
     1533            (1 << 4) |    /* IC  */ 
     1534            (1 << 3) |    /* ARC */ 
     1535            (1 << 2) |    /* AEC */ 
     1536            (1 << 1) |    /* FSC */ 
     1537            1;            /* ESC */ 
     1538        break; 
     1539 
     1540    case 0x45a: /* DMA_CAPS_4 */ 
     1541        *ret = (1 << 6) | /* SSC  */ 
     1542            (1 << 5) |    /* BIC  */ 
     1543            (1 << 4) |    /* LFIC */ 
     1544            (1 << 3) |    /* FIC  */ 
     1545            (1 << 2) |    /* HFIC */ 
     1546            (1 << 1) |    /* EDIC */ 
     1547            1;            /* TOIC */ 
     1548        break; 
     1549 
     1550    case 0x460: /* DMA_PCh2_SR */ 
     1551    case 0x480: /* DMA_PCh0_SR */ 
     1552    case 0x482: /* DMA_PCh1_SR */ 
     1553    case 0x4c0: /* DMA_PChD_SR_0 */ 
     1554        printf("%s: Physical Channel Status Registers not implemented.\n", 
     1555               __FUNCTION__); 
     1556        *ret = 0xff; 
     1557        break; 
     1558 
     1559    default: 
     1560        return 1; 
     1561    } 
     1562    return 0; 
     1563} 
     1564 
    8651565static uint32_t omap_dma_read(void *opaque, target_phys_addr_t addr) 
    8661566{ 
    8671567    struct omap_dma_s *s = (struct omap_dma_s *) opaque; 
    868     int i, reg, ch, offset = addr - s->base; 
     1568    int reg, ch, offset = addr - s->base; 
    8691569    uint16_t ret; 
    8701570 
    8711571    switch (offset) { 
     1572    case 0x300 ... 0x3fe: 
     1573        if (s->model == omap_dma_3_1 || !s->omap_3_1_mapping_disabled) { 
     1574            if (omap_dma_3_1_lcd_read(&s->lcd_ch, offset, &ret)) 
     1575                break; 
     1576            return ret; 
     1577        } 
     1578        /* Fall through. */ 
    8721579    case 0x000 ... 0x2fe: 
    8731580        reg = offset & 0x3f; 
    8741581        ch = (offset >> 6) & 0x0f; 
    875         if (omap_dma_ch_reg_read(s, ch, reg, &ret)) 
     1582        if (omap_dma_ch_reg_read(s, &s->ch[ch], reg, &ret)) 
    8761583            break; 
    8771584        return ret; 
    8781585 
    879     case 0x300: /* SYS_DMA_LCD_CTRL */ 
    880         i = s->lcd_ch.condition; 
    881         s->lcd_ch.condition = 0; 
    882         qemu_irq_lower(s->lcd_ch.irq); 
    883         return ((s->lcd_ch.src == imif) << 6) | (i << 3) | 
    884                 (s->lcd_ch.interrupts << 1) | s->lcd_ch.dual; 
    885  
    886     case 0x302: /* SYS_DMA_LCD_TOP_F1_L */ 
    887         return s->lcd_ch.src_f1_top & 0xffff; 
    888  
    889     case 0x304: /* SYS_DMA_LCD_TOP_F1_U */ 
    890         return s->lcd_ch.src_f1_top >> 16; 
    891  
    892     case 0x306: /* SYS_DMA_LCD_BOT_F1_L */ 
    893         return s->lcd_ch.src_f1_bottom & 0xffff; 
    894  
    895     case 0x308: /* SYS_DMA_LCD_BOT_F1_U */ 
    896         return s->lcd_ch.src_f1_bottom >> 16; 
    897  
    898     case 0x30a: /* SYS_DMA_LCD_TOP_F2_L */ 
    899         return s->lcd_ch.src_f2_top & 0xffff; 
    900  
    901     case 0x30c: /* SYS_DMA_LCD_TOP_F2_U */ 
    902         return s->lcd_ch.src_f2_top >> 16; 
    903  
    904     case 0x30e: /* SYS_DMA_LCD_BOT_F2_L */ 
    905         return s->lcd_ch.src_f2_bottom & 0xffff; 
    906  
    907     case 0x310: /* SYS_DMA_LCD_BOT_F2_U */ 
    908         return s->lcd_ch.src_f2_bottom >> 16; 
    909  
    910     case 0x400: /* SYS_DMA_GCR */ 
    911         return s->gcr; 
     1586    case 0x404 ... 0x4fe: 
     1587        if (s->model == omap_dma_3_1) 
     1588            break; 
     1589        /* Fall through. */ 
     1590    case 0x400: 
     1591        if (omap_dma_sys_read(s, offset, &ret)) 
     1592            break; 
     1593        return ret; 
     1594 
     1595    case 0xb00 ... 0xbfe: 
     1596        if (s->model == omap_dma_3_2 && s->omap_3_1_mapping_disabled) { 
     1597            if (omap_dma_3_2_lcd_read(&s->lcd_ch, offset, &ret)) 
     1598                break; 
     1599            return ret; 
     1600        } 
     1601        break; 
    9121602    } 
    9131603 
     
    9231613 
    9241614    switch (offset) { 
     1615    case 0x300 ... 0x3fe: 
     1616        if (s->model == omap_dma_3_1 || !s->omap_3_1_mapping_disabled) { 
     1617            if (omap_dma_3_1_lcd_write(&s->lcd_ch, offset, value)) 
     1618                break; 
     1619            return; 
     1620        } 
     1621        /* Fall through.  */ 
    9251622    case 0x000 ... 0x2fe: 
    9261623        reg = offset & 0x3f; 
    9271624        ch = (offset >> 6) & 0x0f; 
    928         if (omap_dma_ch_reg_write(s, ch, reg, value)) 
    929             OMAP_RO_REG(addr); 
    930         break; 
    931  
    932     case 0x300: /* SYS_DMA_LCD_CTRL */ 
    933         s->lcd_ch.src = (value & 0x40) ? imif : emiff; 
    934         s->lcd_ch.condition = 0; 
    935         /* Assume no bus errors and thus no BUS_ERROR irq bits.  */ 
    936         s->lcd_ch.interrupts = (value >> 1) & 1; 
    937         s->lcd_ch.dual = value & 1; 
    938         break; 
    939  
    940     case 0x302: /* SYS_DMA_LCD_TOP_F1_L */ 
    941         s->lcd_ch.src_f1_top &= 0xffff0000; 
    942         s->lcd_ch.src_f1_top |= 0x0000ffff & value; 
    943         break; 
    944  
    945     case 0x304: /* SYS_DMA_LCD_TOP_F1_U */ 
    946         s->lcd_ch.src_f1_top &= 0x0000ffff; 
    947         s->lcd_ch.src_f1_top |= value << 16; 
    948         break; 
    949  
    950     case 0x306: /* SYS_DMA_LCD_BOT_F1_L */ 
    951         s->lcd_ch.src_f1_bottom &= 0xffff0000; 
    952         s->lcd_ch.src_f1_bottom |= 0x0000ffff & value; 
    953         break; 
    954  
    955     case 0x308: /* SYS_DMA_LCD_BOT_F1_U */ 
    956         s->lcd_ch.src_f1_bottom &= 0x0000ffff; 
    957         s->lcd_ch.src_f1_bottom |= value << 16; 
    958         break; 
    959  
    960     case 0x30a: /* SYS_DMA_LCD_TOP_F2_L */ 
    961         s->lcd_ch.src_f2_top &= 0xffff0000; 
    962         s->lcd_ch.src_f2_top |= 0x0000ffff & value; 
    963         break; 
    964  
    965     case 0x30c: /* SYS_DMA_LCD_TOP_F2_U */ 
    966         s->lcd_ch.src_f2_top &= 0x0000ffff; 
    967         s->lcd_ch.src_f2_top |= value << 16; 
    968         break; 
    969  
    970     case 0x30e: /* SYS_DMA_LCD_BOT_F2_L */ 
    971         s->lcd_ch.src_f2_bottom &= 0xffff0000; 
    972         s->lcd_ch.src_f2_bottom |= 0x0000ffff & value; 
    973         break; 
    974  
    975     case 0x310: /* SYS_DMA_LCD_BOT_F2_U */ 
    976         s->lcd_ch.src_f2_bottom &= 0x0000ffff; 
    977         s->lcd_ch.src_f2_bottom |= value << 16; 
    978         break; 
    979  
    980     case 0x400: /* SYS_DMA_GCR */ 
    981         s->gcr = value & 0x000c; 
    982         break; 
    983  
    984     default: 
    985         OMAP_BAD_REG(addr); 
    986     } 
     1625        if (omap_dma_ch_reg_write(s, &s->ch[ch], reg, value)) 
     1626            break; 
     1627        return; 
     1628 
     1629    case 0x404 ... 0x4fe: 
     1630        if (s->model == omap_dma_3_1) 
     1631            break; 
     1632    case 0x400: 
     1633        /* Fall through. */ 
     1634        if (omap_dma_sys_write(s, offset, value)) 
     1635            break; 
     1636        return; 
     1637 
     1638    case 0xb00 ... 0xbfe: 
     1639        if (s->model == omap_dma_3_2 && s->omap_3_1_mapping_disabled) { 
     1640            if (omap_dma_3_2_lcd_write(&s->lcd_ch, offset, value)) 
     1641                break; 
     1642            return; 
     1643        } 
     1644        break; 
     1645    } 
     1646 
     1647    OMAP_BAD_REG(addr); 
    9871648} 
    9881649 
     
    10061667        if (~s->drq & (1 << drq)) { 
    10071668            s->drq |= 1 << drq; 
    1008             omap_dma_request_run(s, 0, drq); 
     1669            omap_dma_process_request(s, drq); 
    10091670        } 
    10101671    } else 
     
    10271688} 
    10281689 
    1029 static void omap_dma_reset(struct omap_dma_s *s) 
    1030 { 
    1031     int i; 
    1032  
    1033     qemu_del_timer(s->tm); 
    1034     s->gcr = 0x0004; 
    1035     s->drq = 0x00000000; 
    1036     s->run_count = 0; 
    1037     s->lcd_ch.src = emiff; 
    1038     s->lcd_ch.condition = 0; 
    1039     s->lcd_ch.interrupts = 0; 
    1040     s->lcd_ch.dual = 0; 
    1041     memset(s->ch, 0, sizeof(s->ch)); 
    1042     for (i = 0; i < s->chans; i ++) 
    1043         s->ch[i].interrupts = 0x0003; 
    1044 } 
    1045  
    1046 struct omap_dma_s *omap_dma_init(target_phys_addr_t base, 
    1047                 qemu_irq pic[], struct omap_mpu_state_s *mpu, omap_clk clk) 
    1048 { 
    1049     int iomemtype; 
     1690struct omap_dma_s *omap_dma_init(target_phys_addr_t base, qemu_irq *irqs, 
     1691                qemu_irq lcd_irq, struct omap_mpu_state_s *mpu, omap_clk clk, 
     1692                enum omap_dma_model model) 
     1693{ 
     1694    int iomemtype, num_irqs, memsize, i; 
    10501695    struct omap_dma_s *s = (struct omap_dma_s *) 
    10511696            qemu_mallocz(sizeof(struct omap_dma_s)); 
    10521697 
    1053     s->ih = pic; 
     1698    if (model == omap_dma_3_1) { 
     1699        num_irqs = 6; 
     1700        memsize = 0x800; 
     1701    } else { 
     1702        num_irqs = 16; 
     1703        memsize = 0xc00; 
     1704    } 
    10541705    s->base = base; 
    1055     s->chans = 9; 
     1706    s->model = model; 
    10561707    s->mpu = mpu; 
    10571708    s->clk = clk; 
    1058     s->lcd_ch.irq = pic[OMAP_INT_DMA_LCD]; 
     1709    s->lcd_ch.irq = lcd_irq; 
    10591710    s->lcd_ch.mpu = mpu; 
     1711    while (num_irqs --) 
     1712        s->ch[num_irqs].irq = irqs[num_irqs]; 
     1713    for (i = 0; i < 3; i ++) { 
     1714        s->ch[i].sibling = &s->ch[i + 6]; 
     1715        s->ch[i + 6].sibling = &s->ch[i]; 
     1716    } 
    10601717    s->tm = qemu_new_timer(vm_clock, (QEMUTimerCB *) omap_dma_channel_run, s); 
    10611718    omap_clk_adduser(s->clk, qemu_allocate_irqs(omap_dma_clk_update, s, 1)[0]); 
     
    10661723    iomemtype = cpu_register_io_memory(0, omap_dma_readfn, 
    10671724                    omap_dma_writefn, s); 
    1068     cpu_register_physical_memory(s->base, 0x800, iomemtype); 
     1725    cpu_register_physical_memory(s->base, memsize, iomemtype); 
    10691726 
    10701727    return s; 
     
    29203577            rows |= i; 
    29213578 
    2922     qemu_set_irq(s->kbd_irq, rows && ~s->kbd_mask && s->clk); 
    2923     s->row_latch = rows ^ 0x1f; 
     3579    qemu_set_irq(s->kbd_irq, rows && !s->kbd_mask && s->clk); 
     3580    s->row_latch = ~rows; 
    29243581} 
    29253582 
     
    29533610 
    29543611    case 0x20:  /* KBD_INT */ 
    2955         return (s->row_latch != 0x1f) && !s->kbd_mask; 
     3612        return (~s->row_latch & 0x1f) && !s->kbd_mask; 
    29563613 
    29573614    case 0x24:  /* GPIO_INT */ 
     
    49205577} 
    49215578 
     5579struct dma_irq_map { 
     5580    int ih; 
     5581    int intr; 
     5582}; 
     5583 
     5584static const struct dma_irq_map omap_dma_irq_map[] = { 
     5585    { 0, OMAP_INT_DMA_CH0_6 }, 
     5586    { 0, OMAP_INT_DMA_CH1_7 }, 
     5587    { 0, OMAP_INT_DMA_CH2_8 }, 
     5588    { 0, OMAP_INT_DMA_CH3 }, 
     5589    { 0, OMAP_INT_DMA_CH4 }, 
     5590    { 0, OMAP_INT_DMA_CH5 }, 
     5591    { 1, OMAP_INT_1610_DMA_CH6 }, 
     5592    { 1, OMAP_INT_1610_DMA_CH7 }, 
     5593    { 1, OMAP_INT_1610_DMA_CH8 }, 
     5594    { 1, OMAP_INT_1610_DMA_CH9 }, 
     5595    { 1, OMAP_INT_1610_DMA_CH10 }, 
     5596    { 1, OMAP_INT_1610_DMA_CH11 }, 
     5597    { 1, OMAP_INT_1610_DMA_CH12 }, 
     5598    { 1, OMAP_INT_1610_DMA_CH13 }, 
     5599    { 1, OMAP_INT_1610_DMA_CH14 }, 
     5600    { 1, OMAP_INT_1610_DMA_CH15 } 
     5601}; 
     5602 
    49225603struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size, 
    49235604                DisplayState *ds, const char *core) 
    49245605{ 
     5606    int i; 
    49255607    struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) 
    49265608            qemu_mallocz(sizeof(struct omap_mpu_state_s)); 
    49275609    ram_addr_t imif_base, emiff_base; 
    49285610    qemu_irq *cpu_irq; 
     5611    qemu_irq dma_irqs[6]; 
    49295612    int sdindex; 
    49305613 
     
    49655648    s->irq[1] = s->ih[1]->pins; 
    49665649 
    4967     s->dma = omap_dma_init(0xfffed800, s->irq[0], s, 
    4968                     omap_findclk(s, "dma_ck")); 
     5650    for (i = 0; i < 6; i ++) 
     5651        dma_irqs[i] = s->irq[omap_dma_irq_map[i].ih][omap_dma_irq_map[i].intr]; 
     5652    s->dma = omap_dma_init(0xfffed800, dma_irqs, s->irq[0][OMAP_INT_DMA_LCD], 
     5653                           s, omap_findclk(s, "dma_ck"), omap_dma_3_1); 
     5654 
    49695655    s->port[emiff    ].addr_valid = omap_validate_emiff_addr; 
    49705656    s->port[emifs    ].addr_valid = omap_validate_emifs_addr; 
  • trunk/src/host/qemu-neo1973/hw/omap.h

    r3613 r3627  
    337337# define OMAP_INT_243X_CARKIT           94 
    338338 
     339enum omap_dma_model { 
     340    omap_dma_3_1 = 0, 
     341    omap_dma_3_2 
     342}; 
     343 
    339344struct omap_dma_s; 
    340 struct omap_dma_s *omap_dma_init(target_phys_addr_t base, 
    341                 qemu_irq pic[], struct omap_mpu_state_s *mpu, omap_clk clk); 
     345struct omap_dma_s *omap_dma_init(target_phys_addr_t base, qemu_irq *irqs, 
     346                qemu_irq lcd_irq, struct omap_mpu_state_s *mpu, omap_clk clk, 
     347                enum omap_dma_model model); 
    342348 
    343349enum omap_dma_port { 
    344350    emiff = 0, 
    345351    emifs, 
    346     imif, 
     352    imif,       /* omap16xx: ocp_t1 */ 
    347353    tipb, 
    348     local, 
     354    local,      /* omap16xx: ocp_t2 */ 
    349355    tipb_mpui, 
    350356    omap_dma_port_last, 
    351357}; 
     358 
     359typedef enum { 
     360    constant = 0, 
     361    post_incremented, 
     362    single_index, 
     363    double_index, 
     364} omap_dma_addressing_t; 
    352365 
    353366struct omap_dma_lcd_channel_s { 
     
    357370    target_phys_addr_t src_f2_top; 
    358371    target_phys_addr_t src_f2_bottom; 
     372 
     373    /* Used in OMAP DMA 3.2 gigacell */ 
     374    unsigned char brust_f1; 
     375    unsigned char pack_f1; 
     376    unsigned char data_type_f1; 
     377    unsigned char brust_f2; 
     378    unsigned char pack_f2; 
     379    unsigned char data_type_f2; 
     380    unsigned char end_prog; 
     381    unsigned char repeat; 
     382    unsigned char auto_init; 
     383    unsigned char priority; 
     384    unsigned char fs; 
     385    unsigned char running; 
     386    unsigned char bs; 
     387    unsigned char omap_3_1_compatible_disable; 
     388    unsigned char dst; 
     389    unsigned char lch_type; 
     390    int16_t element_index_f1; 
     391    int16_t element_index_f2; 
     392    int32_t frame_index_f1; 
     393    int32_t frame_index_f2; 
     394    uint16_t elements_f1; 
     395    uint16_t frames_f1; 
     396    uint16_t elements_f2; 
     397    uint16_t frames_f2; 
     398    omap_dma_addressing_t mode_f1; 
     399    omap_dma_addressing_t mode_f2; 
     400 
    359401    /* Destination port is fixed.  */ 
    360402    int interrupts; 
  • trunk/src/host/qemu-neo1973/hw/pci.c

    r3443 r3627  
    4343    /* The bus IRQ state is the logical OR of the connected devices. 
    4444       Keep a count of the number of devices with raised IRQs.  */ 
     45    int nirq; 
    4546    int irq_count[]; 
    4647}; 
     
    5354static PCIBus *first_bus; 
    5455 
     56static void pcibus_save(QEMUFile *f, void *opaque) 
     57{ 
     58    PCIBus *bus = (PCIBus *)opaque; 
     59    int i; 
     60 
     61    qemu_put_be32(f, bus->nirq); 
     62    for (i = 0; i < bus->nirq; i++) 
     63        qemu_put_be32(f, bus->irq_count[i]); 
     64} 
     65 
     66static int  pcibus_load(QEMUFile *f, void *opaque, int version_id) 
     67{ 
     68    PCIBus *bus = (PCIBus *)opaque; 
     69    int i, nirq; 
     70 
     71    if (version_id != 1) 
     72        return -EINVAL; 
     73 
     74    nirq = qemu_get_be32(f); 
     75    if (bus->nirq != nirq) { 
     76        fprintf(stderr, "pcibus_load: nirq mismatch: src=%d dst=%d\n", 
     77                nirq, bus->nirq); 
     78        return -EINVAL; 
     79    } 
     80 
     81    for (i = 0; i < nirq; i++) 
     82        bus->irq_count[i] = qemu_get_be32(f); 
     83 
     84    return 0; 
     85} 
     86 
    5587PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, 
    5688                         qemu_irq *pic, int devfn_min, int nirq) 
    5789{ 
    5890    PCIBus *bus; 
     91    static int nbus = 0; 
     92 
    5993    bus = qemu_mallocz(sizeof(PCIBus) + (nirq * sizeof(int))); 
    6094    bus->set_irq = set_irq; 
     
    6296    bus->irq_opaque = pic; 
    6397    bus->devfn_min = devfn_min; 
     98    bus->nirq = nirq; 
    6499    first_bus = bus; 
     100    register_savevm("PCIBUS", nbus++, 1, pcibus_save, pcibus_load, bus); 
    65101    return bus; 
    66102} 
     
    84120void pci_device_save(PCIDevice *s, QEMUFile *f) 
    85121{ 
    86     qemu_put_be32(f, 1); /* PCI device version */ 
     122    int i; 
     123 
     124    qemu_put_be32(f, 2); /* PCI device version */ 
    87125    qemu_put_buffer(f, s->config, 256); 
     126    for (i = 0; i < 4; i++) 
     127        qemu_put_be32(f, s->irq_state[i]); 
    88128} 
    89129 
     
    91131{ 
    92132    uint32_t version_id; 
     133    int i; 
     134 
    93135    version_id = qemu_get_be32(f); 
    94     if (version_id != 1) 
     136    if (version_id > 2) 
    95137        return -EINVAL; 
    96138    qemu_get_buffer(f, s->config, 256); 
    97139    pci_update_mappings(s); 
     140 
     141    if (version_id >= 2) 
     142        for (i = 0; i < 4; i ++) 
     143            s->irq_state[i] = qemu_get_be32(f); 
     144 
    98145    return 0; 
    99146} 
  • trunk/src/host/qemu-neo1973/hw/pflash_cfi01.c

    r3443 r3627  
    484484} 
    485485 
    486 pflash_t *pflash_register (target_phys_addr_t base, ram_addr_t off, 
    487                            BlockDriverState *bs, 
    488                            target_ulong sector_len, int nb_blocs, int width, 
    489                            uint16_t id0, uint16_t id1, 
    490                            uint16_t id2, uint16_t id3) 
     486pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off, 
     487                                BlockDriverState *bs, target_ulong sector_len, 
     488                               int nb_blocs, int width, 
     489                                uint16_t id0, uint16_t id1, 
     490                                uint16_t id2, uint16_t id3) 
    491491{ 
    492492    pflash_t *pfl; 
  • trunk/src/host/qemu-neo1973/hw/pflash_cfi02.c

    r3443 r3627  
    525525} 
    526526 
    527 pflash_t *pflash_register (target_phys_addr_t base, ram_addr_t off, 
    528                            BlockDriverState *bs, 
    529                            uint32_t sector_len, int nb_blocs, int width, 
    530                            uint16_t id0, uint16_t id1, 
    531                            uint16_t id2, uint16_t id3) 
     527pflash_t *pflash_cfi02_register(target_phys_addr_t base, ram_addr_t off, 
     528                                BlockDriverState *bs, uint32_t sector_len, 
     529                               int nb_blocs, int width, 
     530                                uint16_t id0, uint16_t id1, 
     531                                uint16_t id2, uint16_t id3) 
    532532{ 
    533533    pflash_t *pfl; 
  • trunk/src/host/qemu-neo1973/hw/piix_pci.c

    r3443 r3627  
    5858static uint32_t isa_page_descs[384 / 4]; 
    5959static uint8_t smm_enabled; 
     60static int pci_irq_levels[4]; 
    6061 
    6162static void update_pam(PCIDevice *d, uint32_t start, uint32_t end, int r) 
     
    140141{ 
    141142    PCIDevice *d = opaque; 
     143    int i; 
     144 
    142145    pci_device_save(d, f); 
    143146    qemu_put_8s(f, &smm_enabled); 
     147 
     148    for (i = 0; i < 4; i++) 
     149        qemu_put_be32(f, pci_irq_levels[i]); 
    144150} 
    145151 
     
    147153{ 
    148154    PCIDevice *d = opaque; 
    149     int ret; 
    150  
    151     if (version_id != 1) 
     155    int ret, i; 
     156 
     157    if (version_id > 2) 
    152158        return -EINVAL; 
    153159    ret = pci_device_load(d, f); 
     
    156162    i440fx_update_memory_mappings(d); 
    157163    qemu_get_8s(f, &smm_enabled); 
     164 
     165    if (version_id >= 2) 
     166        for (i = 0; i < 4; i++) 
     167            pci_irq_levels[i] = qemu_get_be32(f); 
     168 
    158169    return 0; 
    159170} 
     
    193204    d->config[0x72] = 0x02; /* SMRAM */ 
    194205 
    195     register_savevm("I440FX", 0, 1, i440fx_save, i440fx_load, d); 
     206    register_savevm("I440FX", 0, 2, i440fx_save, i440fx_load, d); 
    196207    *pi440fx_state = d; 
    197208    return b; 
     
    205216/* just used for simpler irq handling. */ 
    206217#define PCI_IRQ_WORDS   ((PCI_DEVICES_MAX + 31) / 32) 
    207  
    208 static int pci_irq_levels[4]; 
    209218 
    210219static void piix3_set_irq(qemu_irq *pic, int irq_num, int level) 
     
    315324} 
    316325 
    317 static int piix_init(PCIBus *bus, int devfn) 
    318 { 
    319     PCIDevice *d; 
    320     uint8_t *pci_conf; 
    321  
    322     d = pci_register_device(bus, "PIIX", sizeof(PCIDevice), 
    323                                     devfn, NULL, NULL); 
    324     register_savevm("PIIX", 0, 2, piix_save, piix_load, d); 
    325  
    326     piix3_dev = d; 
    327     pci_conf = d->config; 
    328  
    329     pci_conf[0x00] = 0x86; // Intel 
    330     pci_conf[0x01] = 0x80; 
    331     pci_conf[0x02] = 0x2E; // 82371FB PIIX PCI-to-ISA bridge 
    332     pci_conf[0x03] = 0x12; 
    333     pci_conf[0x08] = 0x02; // Step A1 
    334     pci_conf[0x0a] = 0x01; // class_sub = PCI_ISA 
    335     pci_conf[0x0b] = 0x06; // class_base = PCI_bridge 
    336     pci_conf[0x0e] = 0x80; // header_type = PCI_multifunction, generic 
    337  
    338     piix3_reset(d); 
    339     return d->devfn; 
    340 } 
    341  
    342326int piix3_init(PCIBus *bus, int devfn) 
    343327{ 
  • trunk/src/host/qemu-neo1973/hw/ppc405_boards.c

    r3555 r3627  
    235235               bdrv_get_device_name(drives_table[index].bdrv), fl_sectors); 
    236236#endif 
    237         pflash_register((uint32_t)(-bios_size), bios_offset, 
    238                         drives_table[index].bdrv, 65536, fl_sectors, 2, 
    239                         0x0001, 0x22DA, 0x0000, 0x0000); 
     237        pflash_cfi02_register((uint32_t)(-bios_size), bios_offset, 
     238                              drives_table[index].bdrv, 65536, fl_sectors, 2, 
     239                              0x0001, 0x22DA, 0x0000, 0x0000); 
    240240        fl_idx++; 
    241241    } else 
     
    552552               bdrv_get_device_name(drives_table[index].bdrv), fl_sectors); 
    553553#endif 
    554         pflash_register((uint32_t)(-bios_size), bios_offset, 
    555                         drives_table[index].bdrv, 65536, fl_sectors, 4, 
    556                         0x0001, 0x22DA, 0x0000, 0x0000); 
     554        pflash_cfi02_register((uint32_t)(-bios_size), bios_offset, 
     555                              drives_table[index].bdrv, 65536, fl_sectors, 4, 
     556                              0x0001, 0x22DA, 0x0000, 0x0000); 
    557557        fl_idx++; 
    558558    } else 
     
    588588               bdrv_get_device_name(drives_table[index].bdrv)); 
    589589#endif 
    590         pflash_register(0xfc000000, bios_offset, drives_table[index].bdrv, 
    591                         65536, fl_sectors, 4, 
    592                         0x0001, 0x22DA, 0x0000, 0x0000); 
     590        pflash_cfi02_register(0xfc000000, bios_offset, 
     591                              drives_table[index].bdrv, 65536, fl_sectors, 4, 
     592                              0x0001, 0x22DA, 0x0000, 0x0000); 
    593593        fl_idx++; 
    594594    } 
  • trunk/src/host/qemu-neo1973/hw/scsi-disk.c

    r3443 r3627  
    3838 
    3939typedef struct SCSIRequest { 
    40     SCSIDevice *dev; 
     40    SCSIDeviceState *dev; 
    4141    uint32_t tag; 
    4242    /* ??? We should probably keep track of whether the data trasfer is 
     
    5252} SCSIRequest; 
    5353 
    54 struct SCSIDevice 
     54struct SCSIDeviceState 
    5555{ 
    5656    BlockDriverState *bdrv; 
     
    7070static SCSIRequest *free_requests = NULL; 
    7171 
    72 static SCSIRequest *scsi_new_request(SCSIDevice *s, uint32_t tag) 
     72static SCSIRequest *scsi_new_request(SCSIDeviceState *s, uint32_t tag) 
    7373{ 
    7474    SCSIRequest *r; 
     
    9494{ 
    9595    SCSIRequest *last; 
    96     SCSIDevice *s = r->dev; 
     96    SCSIDeviceState *s = r->dev; 
    9797 
    9898    if (s->requests == r) { 
     
    112112} 
    113113 
    114 static SCSIRequest *scsi_find_request(SCSIDevice *s, uint32_t tag) 
     114static SCSIRequest *scsi_find_request(SCSIDeviceState *s, uint32_t tag) 
    115115{ 
    116116    SCSIRequest *r; 
     
    126126static void scsi_command_complete(SCSIRequest *r, int sense) 
    127127{ 
    128     SCSIDevice *s = r->dev; 
     128    SCSIDeviceState *s = r->dev; 
    129129    uint32_t tag; 
    130130    DPRINTF("Command complete tag=0x%x sense=%d\n", r->tag, sense); 
     
    136136 
    137137/* Cancel a pending data transfer.  */ 
    138 void scsi_cancel_io(SCSIDevice *s, uint32_t tag) 
    139 { 
     138static void scsi_cancel_io(SCSIDevice *d, uint32_t tag) 
     139{ 
     140    SCSIDeviceState *s = d->state; 
    140141    SCSIRequest *r; 
    141142    DPRINTF("Cancel tag=0x%x\n", tag); 
     
    152153{ 
    153154    SCSIRequest *r = (SCSIRequest *)opaque; 
    154     SCSIDevice *s = r->dev; 
     155    SCSIDeviceState *s = r->dev; 
    155156 
    156157    if (ret) { 
     
    165166 
    166167/* Read more data from scsi device into buffer.  */ 
    167 void scsi_read_data(SCSIDevice *s, uint32_t tag) 
    168 { 
     168static void scsi_read_data(SCSIDevice *d, uint32_t tag) 
     169{ 
     170    SCSIDeviceState *s = d->state; 
    169171    SCSIRequest *r; 
    170172    uint32_t n; 
     
    205207{ 
    206208    SCSIRequest *r = (SCSIRequest *)opaque; 
    207     SCSIDevice *s = r->dev; 
     209    SCSIDeviceState *s = r->dev; 
    208210    uint32_t len; 
    209211 
     
    229231/* Write data to a scsi device.  Returns nonzero on failure. 
    230232   The transfer may complete asynchronously.  */ 
    231 int scsi_write_data(SCSIDevice *s, uint32_t tag) 
    232 { 
     233static int scsi_write_data(SCSIDevice *d, uint32_t tag) 
     234{ 
     235    SCSIDeviceState *s = d->state; 
    233236    SCSIRequest *r; 
    234237    uint32_t n; 
     
    260263 
    261264/* Return a pointer to the data buffer.  */ 
    262 uint8_t *scsi_get_buf(SCSIDevice *s, uint32_t tag) 
    263 { 
     265static uint8_t *scsi_get_buf(SCSIDevice *d, uint32_t tag) 
     266{ 
     267    SCSIDeviceState *s = d->state; 
    264268    SCSIRequest *r; 
    265269 
     
    277281   and zero if the command does not transfer any data.  */ 
    278282 
    279 int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun) 
    280 { 
     283static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, 
     284                                 uint8_t *buf, int lun) 
     285{ 
     286    SCSIDeviceState *s = d->state; 
    281287    int64_t nb_sectors; 
    282288    uint32_t lba; 
     
    292298    if (r) { 
    293299        BADF("Tag 0x%x already in use\n", tag); 
    294         scsi_cancel_io(s, tag); 
     300        scsi_cancel_io(d, tag); 
    295301    } 
    296302    /* ??? Tags are not unique for different luns.  We only implement a 
     
    577583} 
    578584 
    579 void scsi_disk_destroy(SCSIDevice *s) 
    580 { 
    581     qemu_free(s); 
    582 } 
    583  
    584 SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, 
    585                           int tcq, 
    586                            scsi_completionfn completion, 
    587                            void *opaque) 
    588 { 
    589     SCSIDevice *s; 
    590  
    591     s = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice)); 
     585static void scsi_destroy(SCSIDevice *d) 
     586{ 
     587    qemu_free(d->state); 
     588    qemu_free(d); 
     589} 
     590 
     591SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, int tcq, 
     592                           scsi_completionfn completion, void *opaque) 
     593{ 
     594    SCSIDevice *d; 
     595    SCSIDeviceState *s; 
     596 
     597    s = (SCSIDeviceState *)qemu_mallocz(sizeof(SCSIDeviceState)); 
    592598    s->bdrv = bdrv; 
    593599    s->tcq = tcq; 
     
    600606    } 
    601607 
    602     return s; 
    603 } 
    604  
     608    d = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice)); 
     609    d->state = s; 
     610    d->destroy = scsi_destroy; 
     611    d->send_command = scsi_send_command; 
     612    d->read_data = scsi_read_data; 
     613    d->write_data = scsi_write_data; 
     614    d->cancel_io = scsi_cancel_io; 
     615    d->get_buf = scsi_get_buf; 
     616 
     617    return d; 
     618} 
  • trunk/src/host/qemu-neo1973/hw/scsi-disk.h

    r3443 r3627  
    88}; 
    99 
     10typedef struct SCSIDeviceState SCSIDeviceState; 
    1011typedef struct SCSIDevice SCSIDevice; 
    1112typedef void (*scsi_completionfn)(void *opaque, int reason, uint32_t tag, 
    1213                                  uint32_t arg); 
    1314 
    14 SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, 
    15                            int tcq, 
    16                            scsi_completionfn completion, 
    17                            void *opaque); 
    18 void scsi_disk_destroy(SCSIDevice *s); 
     15struct SCSIDevice 
     16{ 
     17    SCSIDeviceState *state; 
     18    void (*destroy)(SCSIDevice *s); 
     19    int32_t (*send_command)(SCSIDevice *s, uint32_t tag, uint8_t *buf, 
     20                            int lun); 
     21    void (*read_data)(SCSIDevice *s, uint32_t tag); 
     22    int (*write_data)(SCSIDevice *s, uint32_t tag); 
     23    void (*cancel_io)(SCSIDevice *s, uint32_t tag); 
     24    uint8_t *(*get_buf)(SCSIDevice *s, uint32_t tag); 
     25}; 
    1926 
    20 int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun); 
    21 /* SCSI data transfers are asynchrnonous.  However, unlike the block IO 
    22    layer the completion routine may be called directly by 
    23    scsi_{read,write}_data.  */ 
    24 void scsi_read_data(SCSIDevice *s, uint32_t tag); 
    25 int scsi_write_data(SCSIDevice *s, uint32_t tag); 
    26 void scsi_cancel_io(SCSIDevice *s, uint32_t tag); 
    27 uint8_t *scsi_get_buf(SCSIDevice *s, uint32_t tag); 
     27SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, int tcq, 
     28                           scsi_completionfn completion, void *opaque); 
    2829 
    2930/* cdrom.c */ 
  • trunk/src/host/qemu-neo1973/hw/sun4m.c

    r3613 r3627  
    7373    target_phys_addr_t dma_base, esp_base, le_base; 
    7474    target_phys_addr_t tcx_base, cs_base, power_base; 
     75    target_phys_addr_t ecc_base; 
     76    uint32_t ecc_version; 
    7577    long vram_size, nvram_size; 
    7678    // IRQ numbers are not PIL ones, but master interrupt controller register 
     
    480482               boot_device, RAM_size, kernel_size, graphic_width, 
    481483               graphic_height, graphic_depth, hwdef->machine_id); 
     484 
     485    if (hwdef->ecc_base != (target_phys_addr_t)-1) 
     486        ecc_init(hwdef->ecc_base, hwdef->ecc_version); 
    482487} 
    483488 
     
    499504        .le_base      = 0x78c00000, 
    500505        .power_base   = 0x7a000000, 
     506        .ecc_base     = -1, 
    501507        .vram_size    = 0x00100000, 
    502508        .nvram_size   = 0x2000, 
     
    535541        .le_base      = 0xef0c00000ULL, 
    536542        .power_base   = 0xefa000000ULL, 
     543        .ecc_base     = 0xf00000000ULL, 
     544        .ecc_version  = 0x10000000, // version 0, implementation 1 
    537545        .vram_size    = 0x00100000, 
    538546        .nvram_size   = 0x2000, 
     
    571579        .le_base      = 0xef0060000ULL, 
    572580        .power_base   = 0xefa000000ULL, 
     581        .ecc_base     = 0xf00000000ULL, 
     582        .ecc_version  = 0x00000000, // version 0, implementation 0 
    573583        .vram_size    = 0x00100000, 
    574584        .nvram_size   = 0x2000, 
  • trunk/src/host/qemu-neo1973/hw/sun4m.h

    r3613 r3627  
    7373                qemu_irq irq, qemu_irq *reset); 
    7474 
     75/* eccmemctl.c */ 
     76void *ecc_init(target_phys_addr_t base, uint32_t version); 
     77 
    7578#endif 
  • trunk/src/host/qemu-neo1973/hw/usb-msd.c

    r3443 r3627  
    150150    if (s->scsi_len == 0) { 
    151151        if (s->mode == USB_MSDM_DATAIN) { 
    152             scsi_read_data(s->scsi_dev, s->tag); 
     152            s->scsi_dev->read_data(s->scsi_dev, s->tag); 
    153153        } else if (s->mode == USB_MSDM_DATAOUT) { 
    154             scsi_write_data(s->scsi_dev, s->tag); 
     154            s->scsi_dev->write_data(s->scsi_dev, s->tag); 
    155155        } 
    156156    } 
     
    205205    } 
    206206    s->scsi_len = arg; 
    207     s->scsi_buf = scsi_get_buf(s->scsi_dev, tag); 
     207    s->scsi_buf = s->scsi_dev->get_buf(s->scsi_dev, tag); 
    208208    if (p) { 
    209209        usb_msd_copy_data(s); 
     
    343343{ 
    344344    MSDState *s = opaque; 
    345     scsi_cancel_io(s->scsi_dev, s->tag); 
     345    s->scsi_dev->cancel_io(s->scsi_dev, s->tag); 
    346346    s->packet = NULL; 
    347347    s->scsi_len = 0; 
     
    391391                    s->tag, cbw.flags, cbw.cmd_len, s->data_len); 
    392392            s->residue = 0; 
    393             scsi_send_command(s->scsi_dev, s->tag, cbw.cmd, 0); 
     393            s->scsi_dev->send_command(s->scsi_dev, s->tag, cbw.cmd, 0); 
    394394            /* ??? Should check that USB and SCSI data transfer 
    395395               directions match.  */ 
    396396            if (s->residue == 0) { 
    397397                if (s->mode == USB_MSDM_DATAIN) { 
    398                     scsi_read_data(s->scsi_dev, s->tag); 
     398                    s->scsi_dev->read_data(s->scsi_dev, s->tag); 
    399399                } else if (s->mode == USB_MSDM_DATAOUT) { 
    400                     scsi_write_data(s->scsi_dev, s->tag); 
     400                    s->scsi_dev->write_data(s->scsi_dev, s->tag); 
    401401                } 
    402402            } 
     
    509509    MSDState *s = (MSDState *)dev; 
    510510 
    511     scsi_disk_destroy(s->scsi_dev); 
     511    s->scsi_dev->destroy(s->scsi_dev); 
    512512    bdrv_delete(s->bs); 
    513513    qemu_free(s); 
  • trunk/src/host/qemu-neo1973/linux-user/ppc/syscall.h

    r3303 r3627  
    2727 
    2828struct target_pt_regs { 
    29         unsigned long gpr[32]; 
    30         unsigned long nip; 
    31         unsigned long msr; 
    32         unsigned long orig_gpr3;        /* Used for restarting system calls */ 
    33         unsigned long ctr; 
    34         unsigned long link; 
    35         unsigned long xer; 
    36         unsigned long ccr; 
    37         unsigned long mq;               /* 601 only (not used at present) */ 
     29        abi_ulong gpr[32]; 
     30        abi_ulong nip; 
     31        abi_ulong msr; 
     32        abi_ulong orig_gpr3;    /* Used for restarting system calls */ 
     33        abi_ulong ctr; 
     34        abi_ulong link; 
     35        abi_ulong xer; 
     36        abi_ulong ccr; 
     37#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) 
     38        abi_ulong softe; 
     39#else 
     40        abi_ulong mq;           /* 601 only (not used at present) */ 
     41#endif 
    3842                                        /* Used on APUS to hold IPL value. */ 
    39         unsigned long trap;             /* Reason for being here */ 
    40         unsigned long dar;              /* Fault registers */ 
    41         unsigned long dsisr; 
    42         unsigned long result;           /* Result of a system call */ 
     43        abi_ulong trap;         /* Reason for being here */ 
     44        abi_ulong dar;          /* Fault registers */ 
     45        abi_ulong dsisr; 
     46        abi_ulong result;               /* Result of a system call */ 
    4347}; 
    4448 
  • trunk/src/host/qemu-neo1973/linux-user/ppc/target_signal.h

    r3303 r3627  
    88typedef struct target_sigaltstack { 
    99        abi_ulong ss_sp; 
    10         abi_long ss_flags; 
     10        int ss_flags; 
    1111        abi_ulong ss_size; 
    1212} target_stack_t; 
  • trunk/src/host/qemu-neo1973/linux-user/socket.h

    r1640 r3627  
    110110        #define TARGET_SO_BSDCOMPAT    14 
    111111        /* To add :#define TARGET_SO_REUSEPORT 15 */ 
     112#if defined(TARGET_PPC) 
     113        #define TARGET_SO_RCVLOWAT     16 
     114        #define TARGET_SO_SNDLOWAT     17 
     115        #define TARGET_SO_RCVTIMEO     18 
     116        #define TARGET_SO_SNDTIMEO     19 
     117        #define TARGET_SO_PASSCRED     20 
     118        #define TARGET_SO_PEERCRED     21 
     119#else 
    112120        #define TARGET_SO_PASSCRED     16 
    113121        #define TARGET_SO_PEERCRED     17 
     
    116124        #define TARGET_SO_RCVTIMEO     20 
    117125        #define TARGET_SO_SNDTIMEO     21 
     126#endif 
    118127 
    119128        /* Security levels - as per NRL IPv6 - don't actually do anything */ 
  • trunk/src/host/qemu-neo1973/linux-user/syscall.c

    r3555 r3627  
    444444} 
    445445 
    446 static inline fd_set *target_to_host_fds(fd_set *fds, 
    447                                          abi_long *target_fds, int n) 
    448 { 
    449 #if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN) 
    450     return (fd_set *)target_fds; 
    451 #else 
    452     int i, b; 
    453     if (target_fds) { 
    454         FD_ZERO(fds); 
    455         for(i = 0;i < n; i++) { 
    456             b = (tswapl(target_fds[i / TARGET_ABI_BITS]) >> 
    457                  (i & (TARGET_ABI_BITS - 1))) & 1; 
    458             if (b) 
    459                 FD_SET(i, fds); 
    460         } 
    461         return fds; 
    462     } else { 
    463         return NULL; 
     446static inline abi_long copy_from_user_fdset(fd_set *fds, 
     447                                            abi_ulong target_fds_addr, 
     448                                            int n) 
     449{ 
     450    int i, nw, j, k; 
     451    abi_ulong b, *target_fds; 
     452 
     453    nw = (n + TARGET_ABI_BITS - 1) / TARGET_ABI_BITS; 
     454    if (!(target_fds = lock_user(VERIFY_READ, 
     455                                 target_fds_addr, 
     456                                 sizeof(abi_ulong) * nw, 
     457                                 1))) 
     458        return -TARGET_EFAULT; 
     459 
     460    FD_ZERO(fds); 
     461    k = 0; 
     462    for (i = 0; i < nw; i++) { 
     463        /* grab the abi_ulong */ 
     464        __get_user(b, &target_fds[i]); 
     465        for (j = 0; j < TARGET_ABI_BITS; j++) { 
     466            /* check the bit inside the abi_ulong */ 
     467            if ((b >> j) & 1) 
     468                FD_SET(k, fds); 
     469            k++; 
     470        } 
    464471    } 
    465 #endif 
    466 } 
    467  
    468 static inline void host_to_target_fds(abi_long *target_fds, 
    469                                       fd_set *fds, int n) 
    470 { 
    471 #if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN) 
    472     /* nothing to do */ 
    473 #else 
     472 
     473    unlock_user(target_fds, target_fds_addr, 0); 
     474 
     475    return 0; 
     476} 
     477 
     478static inline abi_long copy_to_user_fdset(abi_ulong target_fds_addr, 
     479                                          const fd_set *fds, 
     480                                          int n) 
     481{ 
    474482    int i, nw, j, k; 
    475483    abi_long v; 
    476  
    477     if (target_fds) { 
    478         nw = (n + TARGET_ABI_BITS - 1) / TARGET_ABI_BITS; 
    479         k = 0; 
    480         for(i = 0;i < nw; i++) { 
    481             v = 0; 
    482             for(j = 0; j < TARGET_ABI_BITS; j++) { 
    483                 v |= ((FD_ISSET(k, fds) != 0) << j); 
    484                 k++; 
    485             } 
    486             target_fds[i] = tswapl(v); 
    487         } 
     484    abi_ulong *target_fds; 
     485 
     486    nw = (n + TARGET_ABI_BITS - 1) / TARGET_ABI_BITS; 
     487    if (!(target_fds = lock_user(VERIFY_WRITE, 
     488                                 target_fds_addr, 
     489                                 sizeof(abi_ulong) * nw, 
     490                                 0))) 
     491        return -TARGET_EFAULT; 
     492 
     493    k = 0; 
     494    for (i = 0; i < nw; i++) { 
     495        v = 0; 
     496        for (j = 0; j < TARGET_ABI_BITS; j++) { 
     497            v |= ((FD_ISSET(k, fds) != 0) << j); 
     498            k++; 
     499        } 
     500        __put_user(v, &target_fds[i]); 
    488501    } 
    489 #endif 
     502 
     503    unlock_user(target_fds, target_fds_addr, sizeof(abi_ulong) * nw); 
     504 
     505    return 0; 
    490506} 
    491507 
     
    535551} 
    536552 
    537 static inline abi_long target_to_host_timeval(struct timeval *tv, 
    538                                               abi_ulong target_addr) 
     553static inline abi_long copy_from_user_timeval(struct timeval *tv, 
     554                                              abi_ulong target_tv_addr) 
    539555{ 
    540556    struct target_timeval *target_tv; 
    541557 
    542     if (!lock_user_struct(VERIFY_READ, target_tv, target_addr, 1)) 
     558    if (!lock_user_struct(VERIFY_READ, target_tv, target_tv_addr, 1)) 
    543559        return -TARGET_EFAULT; 
    544     tv->tv_sec = tswapl(target_tv->tv_sec); 
    545     tv->tv_usec = tswapl(target_tv->tv_usec); 
    546     unlock_user_struct(target_tv, target_addr, 0); 
     560 
     561    __get_user(tv->tv_sec, &target_tv->tv_sec); 
     562    __get_user(tv->tv_usec, &target_tv->tv_usec); 
     563 
     564    unlock_user_struct(target_tv, target_tv_addr, 0); 
    547565 
    548566    return 0; 
    549567} 
    550568 
    551 static inline abi_long host_to_target_timeval(abi_ulong target_addr, 
    552                                               const struct timeval *tv) 
     569static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr, 
     570                                            const struct timeval *tv) 
    553571{ 
    554572    struct target_timeval *target_tv; 
    555573 
    556     if (!lock_user_struct(VERIFY_WRITE, target_tv, target_addr, 0)) 
     574    if (!lock_user_struct(VERIFY_WRITE, target_tv, target_tv_addr, 0)) 
    557575        return -TARGET_EFAULT; 
    558     target_tv->tv_sec = tswapl(tv->tv_sec); 
    559     target_tv->tv_usec = tswapl(tv->tv_usec); 
    560     unlock_user_struct(target_tv, target_addr, 1); 
     576 
     577    __put_user(tv->tv_sec, &target_tv->tv_sec); 
     578    __put_user(tv->tv_usec, &target_tv->tv_usec); 
     579 
     580    unlock_user_struct(target_tv, target_tv_addr, 1); 
    561581 
    562582    return 0; 
     
    566586/* do_select() must return target values and target errnos. */ 
    567587static abi_long do_select(int n, 
    568                           abi_ulong rfd_p, abi_ulong wfd_p, 
    569                           abi_ulong efd_p, abi_ulong target_tv) 
     588                          abi_ulong rfd_addr, abi_ulong wfd_addr, 
     589                          abi_ulong efd_addr, abi_ulong target_tv_addr) 
    570590{ 
    571591    fd_set rfds, wfds, efds; 
    572592    fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; 
    573     abi_long *target_rfds, *target_wfds, *target_efds; 
    574593    struct timeval tv, *tv_ptr; 
    575594    abi_long ret; 
    576     int ok; 
    577  
    578     if (rfd_p) { 
    579         target_rfds = lock_user(VERIFY_WRITE, rfd_p, sizeof(abi_long) * n, 1); 
    580         if (!target_rfds) { 
    581             ret = -TARGET_EFAULT; 
    582             goto end; 
    583         } 
    584         rfds_ptr = target_to_host_fds(&rfds, target_rfds, n); 
     595 
     596    if (rfd_addr) { 
     597        if (copy_from_user_fdset(&rfds, rfd_addr, n)) 
     598            return -TARGET_EFAULT; 
     599        rfds_ptr = &rfds; 
    585600    } else { 
    586         target_rfds = NULL; 
    587601        rfds_ptr = NULL; 
    588602    } 
    589     if (wfd_p) { 
    590         target_wfds = lock_user(VERIFY_WRITE, wfd_p, sizeof(abi_long) * n, 1); 
    591         if (!target_wfds) { 
    592             ret = -TARGET_EFAULT; 
    593             goto end; 
    594         } 
    595         wfds_ptr = target_to_host_fds(&wfds, target_wfds, n); 
     603    if (wfd_addr) { 
     604        if (copy_from_user_fdset(&wfds, wfd_addr, n)) 
     605            return -TARGET_EFAULT; 
     606        wfds_ptr = &wfds; 
    596607    } else { 
    597         target_wfds = NULL; 
    598608        wfds_ptr = NULL; 
    599609    } 
    600     if (efd_p) { 
    601         target_efds = lock_user(VERIFY_WRITE, efd_p, sizeof(abi_long) * n, 1); 
    602         if (!target_efds) { 
    603             ret = -TARGET_EFAULT; 
    604             goto end; 
    605         } 
    606         efds_ptr = target_to_host_fds(&efds, target_efds, n); 
     610    if (efd_addr) { 
     611        if (copy_from_user_fdset(&efds, efd_addr, n)) 
     612            return -TARGET_EFAULT; 
     613        efds_ptr = &efds; 
    607614    } else { 
    608         target_efds = NULL; 
    609615        efds_ptr = NULL; 
    610616    } 
    611617 
    612     if (target_tv) { 
    613         target_to_host_timeval(&tv, target_tv); 
     618    if (target_tv_addr) { 
     619        if (copy_from_user_timeval(&tv, target_tv_addr)) 
     620            return -TARGET_EFAULT; 
    614621        tv_ptr = &tv; 
    615622    } else { 
    616623        tv_ptr = NULL; 
    617624    } 
     625 
    618626    ret = get_errno(select(n, rfds_ptr, wfds_ptr, efds_ptr, tv_ptr)); 
    619     ok = !is_error(ret); 
    620  
    621     if (ok) { 
    622         host_to_target_fds(target_rfds, rfds_ptr, n); 
    623         host_to_target_fds(target_wfds, wfds_ptr, n); 
    624         host_to_target_fds(target_efds, efds_ptr, n); 
    625  
    626         if (target_tv) { 
    627             host_to_target_timeval(target_tv, &tv); 
    628         } 
     627 
     628    if (!is_error(ret)) { 
     629        if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) 
     630            return -TARGET_EFAULT; 
     631        if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) 
     632            return -TARGET_EFAULT; 
     633        if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) 
     634            return -TARGET_EFAULT; 
     635 
     636        if (target_tv_addr && copy_to_user_timeval(target_tv_addr, &tv)) 
     637            return -TARGET_EFAULT; 
    629638    } 
    630  
    631 end: 
    632     unlock_user(target_rfds, rfd_p, ok ? sizeof(abi_long) * n : 0); 
    633     unlock_user(target_wfds, wfd_p, ok ? sizeof(abi_long) * n : 0); 
    634     unlock_user(target_efds, efd_p, ok ? sizeof(abi_long) * n : 0); 
    635639 
    636640    return ret; 
     
    31873191            argc = 0; 
    31883192            guest_argp = arg2; 
    3189             for (gp = guest_argp; ; gp++) { 
     3193            for (gp = guest_argp; ; gp += sizeof(abi_ulong)) { 
    31903194                if (get_user_ual(addr, gp)) 
    31913195                    goto efault; 
     
    31963200            envc = 0; 
    31973201            guest_envp = arg3; 
    3198             for (gp = guest_envp; ; gp++) { 
     3202            for (gp = guest_envp; ; gp += sizeof(abi_ulong)) { 
    31993203                if (get_user_ual(addr, gp)) 
    32003204                    goto efault; 
     
    33923396            struct timeval *tvp, tv[2]; 
    33933397            if (arg2) { 
    3394                 target_to_host_timeval(&tv[0], arg2); 
    3395                 target_to_host_timeval(&tv[1], 
    3396                     arg2 + sizeof (struct target_timeval)); 
     3398                if (copy_from_user_timeval(&tv[0], arg2) 
     3399                    || copy_from_user_timeval(&tv[1], 
     3400                                              arg2 + sizeof(struct target_timeval))) 
     3401                    goto efault; 
    33973402                tvp = tv; 
    33983403            } else { 
     
    39333938            ret = get_errno(gettimeofday(&tv, NULL)); 
    39343939            if (!is_error(ret)) { 
    3935                 host_to_target_timeval(arg1, &tv); 
     3940                if (copy_to_user_timeval(arg1, &tv)) 
     3941                    goto efault; 
    39363942            } 
    39373943        } 
     
    39403946        { 
    39413947            struct timeval tv; 
    3942             target_to_host_timeval(&tv, arg1); 
     3948            if (copy_from_user_timeval(&tv, arg1)) 
     3949                goto efault; 
    39433950            ret = get_errno(settimeofday(&tv, NULL)); 
    39443951        } 
     
    43154322            if (arg2) { 
    43164323                pvalue = &value; 
    4317                 target_to_host_timeval(&pvalue->it_interval, 
    4318                                        arg2); 
    4319                 target_to_host_timeval(&pvalue->it_value, 
    4320                                        arg2 + sizeof(struct target_timeval)); 
     4324                if (copy_from_user_timeval(&pvalue->it_interval, arg2) 
     4325                    || copy_from_user_timeval(&pvalue->it_value, 
     4326                                              arg2 + sizeof(struct target_timeval))) 
     4327                    goto efault; 
    43214328            } else { 
    43224329                pvalue = NULL; 
     
    43244331            ret = get_errno(setitimer(arg1, pvalue, &ovalue)); 
    43254332            if (!is_error(ret) && arg3) { 
    4326                 host_to_target_timeval(arg3, 
    4327                                        &ovalue.it_interval); 
    4328                 host_to_target_timeval(arg3 + sizeof(struct target_timeval), 
    4329                                        &ovalue.it_value); 
     4333                if (copy_to_user_timeval(arg3, 
     4334                                         &ovalue.it_interval) 
     4335                    || copy_to_user_timeval(arg3 + sizeof(struct target_timeval), 
     4336                                            &ovalue.it_value)) 
     4337                    goto efault; 
    43304338            } 
    43314339        } 
     
    43374345            ret = get_errno(getitimer(arg1, &value)); 
    43384346            if (!is_error(ret) && arg2) { 
    4339                 host_to_target_timeval(arg2, 
    4340                                        &value.it_interval); 
    4341                 host_to_target_timeval(arg2 + sizeof(struct target_timeval), 
    4342                                        &value.it_value); 
     4347                if (copy_to_user_timeval(arg2, 
     4348                                         &value.it_interval) 
     4349                    || copy_to_user_timeval(arg2 + sizeof(struct target_timeval), 
     4350                                            &value.it_value)) 
     4351                    goto efault; 
    43434352            } 
    43444353        } 
  • trunk/src/host/qemu-neo1973/linux-user/syscall_defs.h

    r3517 r3627  
    10871087 
    10881088struct target_stat { 
    1089         unsigned short st_dev; 
     1089        abi_ulong st_dev; 
    10901090        abi_ulong st_ino; 
    10911091#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) 
    1092         unsigned short st_nlink; 
     1092        abi_ulong st_nlink; 
    10931093        unsigned int st_mode; 
    10941094#else 
     
    10981098        unsigned int st_uid; 
    10991099        unsigned int st_gid; 
    1100         unsigned short st_rdev; 
     1100        abi_ulong st_rdev; 
    11011101        abi_ulong  st_size; 
    11021102        abi_ulong  st_blksize; 
    11031103        abi_ulong  st_blocks; 
    11041104        abi_ulong  target_st_atime; 
    1105         abi_ulong  __unused1; 
     1105        abi_ulong  target_st_atime_nsec; 
    11061106        abi_ulong  target_st_mtime; 
    1107         abi_ulong  __unused2; 
     1107        abi_ulong  target_st_mtime_nsec; 
    11081108        abi_ulong  target_st_ctime; 
    1109         abi_ulong  __unused3; 
     1109        abi_ulong  target_st_ctime_nsec; 
    11101110        abi_ulong  __unused4; 
    11111111        abi_ulong  __unused5; 
     
    11231123        unsigned int st_gid; 
    11241124        unsigned long long st_rdev; 
    1125         long long pad0; 
    1126         long long st_size; 
    1127         abi_ulong       st_blksize; 
    1128         abi_ulong       pad1; 
    1129         long long       st_blocks;      /* Number 512-byte blocks allocated. */ 
    1130         abi_ulong       target_st_atime; 
    1131         abi_ulong    target_st_atime_nsec; 
    1132         abi_ulong       target_st_mtime; 
    1133         abi_ulong    target_st_mtime_nsec; 
    1134         abi_ulong       target_st_ctime; 
    1135         abi_ulong    target_st_ctime_nsec; 
    1136         abi_ulong    __unused4; 
    1137         abi_ulong    __unused5; 
     1125        unsigned short pad0; 
     1126        long long      st_size; 
     1127        int            st_blksize; 
     1128        long long      st_blocks;       /* Number 512-byte blocks allocated. */ 
     1129        int            target_st_atime; 
     1130        unsigned int   target_st_atime_nsec; 
     1131        int            target_st_mtime; 
     1132        unsigned int   target_st_mtime_nsec; 
     1133        int            target_st_ctime; 
     1134        unsigned int   target_st_ctime_nsec; 
     1135        unsigned int   __unused4; 
     1136        unsigned int   __unused5; 
    11381137}; 
    11391138 
  • trunk/src/host/qemu-neo1973/target-arm/helper.c

    r3517 r3627  
    188188        return NULL; 
    189189    cpu_exec_init(env); 
     190    env->cpu_model_str = cpu_model; 
    190191    env->cp15.c0_cpuid = id; 
    191192    cpu_reset(env); 
  • trunk/src/host/qemu-neo1973/target-i386/exec.h

    r3406 r3627  
    200200void helper_sysret(int dflag); 
    201201void helper_rdtsc(void); 
     202void helper_rdpmc(void); 
    202203void helper_rdmsr(void); 
    203204void helper_wrmsr(void); 
  • trunk/src/host/qemu-neo1973/target-i386/helper.c

    r3443 r3627  
    27442744} 
    27452745 
     2746void helper_rdpmc(void) 
     2747{ 
     2748    if ((env->cr[4] & CR4_PCE_MASK) && ((env->hflags & HF_CPL_MASK) != 0)) { 
     2749        raise_exception(EXCP0D_GPF); 
     2750    } 
     2751 
     2752    if (!svm_check_intercept_param(SVM_EXIT_RDPMC, 0)) { 
     2753        /* currently unimplemented */ 
     2754        raise_exception_err(EXCP06_ILLOP, 0); 
     2755    } 
     2756} 
     2757 
    27462758#if defined(CONFIG_USER_ONLY) 
    27472759void helper_wrmsr(void) 
     
    42514263            uint16_t port = (uint16_t) (param >> 16); 
    42524264 
    4253             if(ldub_phys(addr + port / 8) & (1 << (port % 8))) 
     4265            uint16_t mask = (1 << ((param >> 4) & 7)) - 1; 
     4266            if(lduw_phys(addr + port / 8) & (mask << (port & 7))) 
    42544267                vmexit(type, param); 
    42554268        } 
  • trunk/src/host/qemu-neo1973/target-i386/helper2.c

    r3517 r3627  
    100100        return NULL; 
    101101    cpu_exec_init(env); 
     102    env->cpu_model_str = cpu_model; 
    102103 
    103104    /* init various static tables */ 
     
    256257                x86_cpu_def->stepping = stepping; 
    257258            } else { 
    258                 fprintf(stderr, "unregnized feature %s\n", featurestr); 
     259                fprintf(stderr, "unrecognized feature %s\n", featurestr); 
    259260                x86_cpu_def = 0; 
    260261                goto error; 
  • trunk/src/host/qemu-neo1973/target-i386/op.c

    r3303 r3627  
    954954} 
    955955 
     956void OPPROTO op_rdpmc(void) 
     957{ 
     958    helper_rdpmc(); 
     959} 
     960 
    956961void OPPROTO op_cpuid(void) 
    957962{ 
  • trunk/src/host/qemu-neo1973/target-i386/translate.c

    r3387 r3627  
    56595659        gen_op_rdtsc(); 
    56605660        break; 
     5661    case 0x133: /* rdpmc */ 
     5662        gen_jmp_im(pc_start - s->cs_base); 
     5663        gen_op_rdpmc(); 
     5664        break; 
    56615665    case 0x134: /* sysenter */ 
    56625666        if (CODE64(s)) 
  • trunk/src/host/qemu-neo1973/target-m68k/helper.c

    r3443 r3627  
    127127    cpu_exec_init(env); 
    128128 
     129    env->cpu_model_str = cpu_model; 
     130 
    129131    if (cpu_m68k_set_model(env, cpu_model) < 0) { 
    130132        cpu_m68k_close(env); 
    131133        return NULL; 
    132134    } 
    133          
     135 
    134136    cpu_reset(env); 
    135137    return env; 
  • trunk/src/host/qemu-neo1973/target-mips/translate.c

    r3517 r3627  
    67876787 
    67886788    cpu_exec_init(env); 
     6789    env->cpu_model_str = cpu_model; 
    67896790    cpu_reset(env); 
    67906791    return env; 
  • trunk/src/host/qemu-neo1973/target-ppc/cpu.h

    r3517 r3627  
    2929/* PowerPC 64 definitions */ 
    3030typedef uint64_t ppc_gpr_t; 
    31 #define TARGET_GPR_BITS  64 
    3231#define TARGET_LONG_BITS 64 
    3332#define TARGET_PAGE_BITS 12 
     
    4241 */ 
    4342typedef uint64_t ppc_gpr_t; 
    44 #define TARGET_GPR_BITS  64 
    4543#else /* (HOST_LONG_BITS >= 64) */ 
    4644typedef uint32_t ppc_gpr_t; 
    47 #define TARGET_GPR_BITS  32 
    4845#endif /* (HOST_LONG_BITS >= 64) */ 
    4946 
     
    12361233#define SPR_L3PM              (0x3D7) 
    12371234#define SPR_403_CDBCR         (0x3D7) 
    1238 #define SPR_L3OHCR            (0x3D8) 
     1235#define SPR_L3ITCR0           (0x3D8) 
    12391236#define SPR_TCR               (0x3D8) 
    12401237#define SPR_40x_TSR           (0x3D8) 
     
    12491246#define SPR_SER               (0x3DF) 
    12501247#define SPR_40x_SRR3          (0x3DF) 
    1251 #define SPR_L3ITCR0           (0x3E8) 
     1248#define SPR_L3OHCR            (0x3E8) 
    12521249#define SPR_L3ITCR1           (0x3E9) 
    12531250#define SPR_L3ITCR2           (0x3EA) 
     
    12781275#define SPR_970_HID5          (0x3F6) 
    12791276#define SPR_MSSSR0            (0x3F7) 
     1277#define SPR_MSSCR1            (0x3F7) 
    12801278#define SPR_DABRX             (0x3F7) 
    12811279#define SPR_40x_DAC2          (0x3F7) 
  • trunk/src/host/qemu-neo1973/target-ppc/helper.c

    r3517 r3627  
    29772977        return NULL; 
    29782978    cpu_exec_init(env); 
     2979    env->cpu_model_str = cpu_model; 
    29792980    cpu_ppc_register_internal(env, def); 
    29802981    cpu_ppc_reset(env); 
  • trunk/src/host/qemu-neo1973/target-ppc/translate_init.c

    r3517 r3627  
    11501150                 0x00000000); 
    11511151    /* XXX : not implemented */ 
    1152     spr_register(env, SPR_UBAMR, "UBAMR", 
    1153                  &spr_read_ureg, SPR_NOACCESS, 
    1154                  &spr_read_ureg, SPR_NOACCESS, 
    1155                  0x00000000); 
    1156     /* XXX : not implemented */ 
    11571152    spr_register(env, SPR_MSSCR0, "MSSCR0", 
    11581153                 SPR_NOACCESS, SPR_NOACCESS, 
     
    11931188    /* XXX : not implemented */ 
    11941189    spr_register(env, SPR_L3ITCR0, "L3ITCR0", 
    1195                  SPR_NOACCESS, SPR_NOACCESS, 
    1196                  &spr_read_generic, &spr_write_generic, 
    1197                  0x00000000); 
    1198     /* L3ITCR1 */ 
    1199     /* XXX : not implemented */ 
    1200     spr_register(env, SPR_L3ITCR1, "L3ITCR1", 
    1201                  SPR_NOACCESS, SPR_NOACCESS, 
    1202                  &spr_read_generic, &spr_write_generic, 
    1203                  0x00000000); 
    1204     /* L3ITCR2 */ 
    1205     /* XXX : not implemented */ 
    1206     spr_register(env, SPR_L3ITCR2, "L3ITCR2", 
    1207                  SPR_NOACCESS, SPR_NOACCESS, 
    1208                  &spr_read_generic, &spr_write_generic, 
    1209                  0x00000000); 
    1210     /* L3ITCR3 */ 
    1211     /* XXX : not implemented */ 
    1212     spr_register(env, SPR_L3ITCR3, "L3ITCR3", 
    1213                  SPR_NOACCESS, SPR_NOACCESS, 
    1214                  &spr_read_generic, &spr_write_generic, 
    1215                  0x00000000); 
    1216     /* L3OHCR */ 
    1217     /* XXX : not implemented */ 
    1218     spr_register(env, SPR_L3OHCR, "L3OHCR", 
    12191190                 SPR_NOACCESS, SPR_NOACCESS, 
    12201191                 &spr_read_generic, &spr_write_generic, 
     
    30483019{ 
    30493020    if (env->spr[SPR_HID0] & 0x00E00000) 
     3021        return 1; 
     3022 
     3023    return 0; 
     3024} 
     3025 
     3026static int check_pow_hid0_74xx (CPUPPCState *env) 
     3027{ 
     3028    if (env->spr[SPR_HID0] & 0x00600000) 
    30503029        return 1; 
    30513030 
     
    48304809} 
    48314810 
     4811/* PowerPC 750CX                                                             */ 
    48324812#define POWERPC_INSNS_750cx  (PPC_INSNS_BASE | PPC_STRING | PPC_MFTB |        \ 
    48334813                              PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |   \ 
     
    48774857    /* Memory management */ 
    48784858    gen_low_BATs(env); 
    4879     /* XXX: high BATs are also present but are known to be bugged on 
    4880      *      die version 1.x 
    4881      */ 
     4859    /* PowerPC 750cx has 8 DBATs and 8 IBATs */ 
     4860    gen_high_BATs(env); 
    48824861    init_excp_750cx(env); 
    48834862    env->dcache_line_size = 32; 
     
    51485127                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM |            \ 
    51495128                              POWERPC_FLAG_BUS_CLK) 
    5150 #define check_pow_7400       check_pow_hid0 
     5129#define check_pow_7400       check_pow_hid0_74xx 
    51515130 
    51525131static void init_proc_7400 (CPUPPCState *env) 
     
    51585137    /* 74xx specific SPR */ 
    51595138    gen_spr_74xx(env); 
     5139    /* XXX : not implemented */ 
     5140    spr_register(env, SPR_UBAMR, "UBAMR", 
     5141                 &spr_read_ureg, SPR_NOACCESS, 
     5142                 &spr_read_ureg, SPR_NOACCESS, 
     5143                 0x00000000); 
     5144    /* XXX: this seems not implemented on all revisions. */ 
     5145    /* XXX : not implemented */ 
     5146    spr_register(env, SPR_MSSCR1, "MSSCR1", 
     5147                 SPR_NOACCESS, SPR_NOACCESS, 
     5148                 &spr_read_generic, &spr_write_generic, 
     5149                 0x00000000); 
    51605150    /* Thermal management */ 
    51615151    gen_spr_thrm(env); 
     
    51895179                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM |            \ 
    51905180                              POWERPC_FLAG_BUS_CLK) 
    5191 #define check_pow_7410       check_pow_hid0 
     5181#define check_pow_7410       check_pow_hid0_74xx 
    51925182 
    51935183static void init_proc_7410 (CPUPPCState *env) 
     
    51995189    /* 74xx specific SPR */ 
    52005190    gen_spr_74xx(env); 
     5191    /* XXX : not implemented */ 
     5192    spr_register(env, SPR_UBAMR, "UBAMR", 
     5193                 &spr_read_ureg, SPR_NOACCESS, 
     5194                 &spr_read_ureg, SPR_NOACCESS, 
     5195                 0x00000000); 
    52015196    /* Thermal management */ 
    52025197    gen_spr_thrm(env); 
     
    52425237                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM |            \ 
    52435238                              POWERPC_FLAG_BUS_CLK) 
    5244 #define check_pow_7440       check_pow_hid0 
     5239#define check_pow_7440       check_pow_hid0_74xx 
    52455240 
    52465241__attribute__ (( unused )) 
     
    52535248    /* 74xx specific SPR */ 
    52545249    gen_spr_74xx(env); 
     5250    /* XXX : not implemented */ 
     5251    spr_register(env, SPR_UBAMR, "UBAMR", 
     5252                 &spr_read_ureg, SPR_NOACCESS, 
     5253                 &spr_read_ureg, SPR_NOACCESS, 
     5254                 0x00000000); 
    52555255    /* LDSTCR */ 
    52565256    /* XXX : not implemented */ 
     
    53225322                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM |            \ 
    53235323                              POWERPC_FLAG_BUS_CLK) 
    5324 #define check_pow_7450       check_pow_hid0 
     5324#define check_pow_7450       check_pow_hid0_74xx 
    53255325 
    53265326__attribute__ (( unused )) 
     
    53355335    /* Level 3 cache control */ 
    53365336    gen_l3_ctrl(env); 
     5337    /* L3ITCR1 */ 
     5338    /* XXX : not implemented */ 
     5339    spr_register(env, SPR_L3ITCR1, "L3ITCR1", 
     5340                 SPR_NOACCESS, SPR_NOACCESS, 
     5341                 &spr_read_generic, &spr_write_generic, 
     5342                 0x00000000); 
     5343    /* L3ITCR2 */ 
     5344    /* XXX : not implemented */ 
     5345    spr_register(env, SPR_L3ITCR2, "L3ITCR2", 
     5346                 SPR_NOACCESS, SPR_NOACCESS, 
     5347                 &spr_read_generic, &spr_write_generic, 
     5348                 0x00000000); 
     5349    /* L3ITCR3 */ 
     5350    /* XXX : not implemented */ 
     5351    spr_register(env, SPR_L3ITCR3, "L3ITCR3", 
     5352                 SPR_NOACCESS, SPR_NOACCESS, 
     5353                 &spr_read_generic, &spr_write_generic, 
     5354                 0x00000000); 
     5355    /* L3OHCR */ 
     5356    /* XXX : not implemented */ 
     5357    spr_register(env, SPR_L3OHCR, "L3OHCR", 
     5358                 SPR_NOACCESS, SPR_NOACCESS, 
     5359                 &spr_read_generic, &spr_write_generic, 
     5360                 0x00000000); 
     5361    /* XXX : not implemented */ 
     5362    spr_register(env, SPR_UBAMR, "UBAMR", 
     5363                 &spr_read_ureg, SPR_NOACCESS, 
     5364                 &spr_read_ureg, SPR_NOACCESS, 
     5365                 0x00000000); 
    53375366    /* LDSTCR */ 
    53385367    /* XXX : not implemented */ 
     
    54045433                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM |            \ 
    54055434                              POWERPC_FLAG_BUS_CLK) 
    5406 #define check_pow_7445       check_pow_hid0 
     5435#define check_pow_7445       check_pow_hid0_74xx 
    54075436 
    54085437__attribute__ (( unused )) 
     
    55185547                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM |            \ 
    55195548                              POWERPC_FLAG_BUS_CLK) 
    5520 #define check_pow_7455       check_pow_hid0 
     5549#define check_pow_7455       check_pow_hid0_74xx 
    55215550 
    55225551__attribute__ (( unused )) 
     
    55315560    /* Level 3 cache control */ 
    55325561    gen_l3_ctrl(env); 
     5562    /* LDSTCR */ 
     5563    /* XXX : not implemented */ 
     5564    spr_register(env, SPR_LDSTCR, "LDSTCR", 
     5565                 SPR_NOACCESS, SPR_NOACCESS, 
     5566                 &spr_read_generic, &spr_write_generic, 
     5567                 0x00000000); 
     5568    /* ICTRL */ 
     5569    /* XXX : not implemented */ 
     5570    spr_register(env, SPR_ICTRL, "ICTRL", 
     5571                 SPR_NOACCESS, SPR_NOACCESS, 
     5572                 &spr_read_generic, &spr_write_generic, 
     5573                 0x00000000); 
     5574    /* MSSSR0 */ 
     5575    /* XXX : not implemented */ 
     5576    spr_register(env, SPR_MSSSR0, "MSSSR0", 
     5577                 SPR_NOACCESS, SPR_NOACCESS, 
     5578                 &spr_read_generic, &spr_write_generic, 
     5579                 0x00000000); 
     5580    /* PMC */ 
     5581    /* XXX : not implemented */ 
     5582    spr_register(env, SPR_PMC5, "PMC5", 
     5583                 SPR_NOACCESS, SPR_NOACCESS, 
     5584                 &spr_read_generic, &spr_write_generic, 
     5585                 0x00000000); 
     5586    /* XXX : not implemented */ 
     5587    spr_register(env, SPR_UPMC5, "UPMC5", 
     5588                 &spr_read_ureg, SPR_NOACCESS, 
     5589                 &spr_read_ureg, SPR_NOACCESS, 
     5590                 0x00000000); 
     5591    /* XXX : not implemented */ 
     5592    spr_register(env, SPR_PMC6, "PMC6", 
     5593                 SPR_NOACCESS, SPR_NOACCESS, 
     5594                 &spr_read_generic, &spr_write_generic, 
     5595                 0x00000000); 
     5596    /* XXX : not implemented */ 
     5597    spr_register(env, SPR_UPMC6, "UPMC6", 
     5598                 &spr_read_ureg, SPR_NOACCESS, 
     5599                 &spr_read_ureg, SPR_NOACCESS, 
     5600                 0x00000000); 
     5601    /* SPRGs */ 
     5602    spr_register(env, SPR_SPRG4, "SPRG4", 
     5603                 SPR_NOACCESS, SPR_NOACCESS, 
     5604                 &spr_read_generic, &spr_write_generic, 
     5605                 0x00000000); 
     5606    spr_register(env, SPR_USPRG4, "USPRG4", 
     5607                 &spr_read_ureg, SPR_NOACCESS, 
     5608                 &spr_read_ureg, SPR_NOACCESS, 
     5609                 0x00000000); 
     5610    spr_register(env, SPR_SPRG5, "SPRG5", 
     5611                 SPR_NOACCESS, SPR_NOACCESS, 
     5612                 &spr_read_generic, &spr_write_generic, 
     5613                 0x00000000); 
     5614    spr_register(env, SPR_USPRG5, "USPRG5", 
     5615                 &spr_read_ureg, SPR_NOACCESS, 
     5616                 &spr_read_ureg, SPR_NOACCESS, 
     5617                 0x00000000); 
     5618    spr_register(env, SPR_SPRG6, "SPRG6", 
     5619                 SPR_NOACCESS, SPR_NOACCESS, 
     5620                 &spr_read_generic, &spr_write_generic, 
     5621                 0x00000000); 
     5622    spr_register(env, SPR_USPRG6, "USPRG6", 
     5623                 &spr_read_ureg, SPR_NOACCESS, 
     5624                 &spr_read_ureg, SPR_NOACCESS, 
     5625                 0x00000000); 
     5626    spr_register(env, SPR_SPRG7, "SPRG7", 
     5627                 SPR_NOACCESS, SPR_NOACCESS, 
     5628                 &spr_read_generic, &spr_write_generic, 
     5629                 0x00000000); 
     5630    spr_register(env, SPR_USPRG7, "USPRG7", 
     5631                 &spr_read_ureg, SPR_NOACCESS, 
     5632                 &spr_read_ureg, SPR_NOACCESS, 
     5633                 0x00000000); 
     5634    /* Memory management */ 
     5635    gen_low_BATs(env); 
     5636    gen_high_BATs(env); 
     5637    gen_74xx_soft_tlb(env, 128, 2); 
     5638    init_excp_7450(env); 
     5639    env->dcache_line_size = 32; 
     5640    env->icache_line_size = 32; 
     5641    /* Allocate hardware IRQ controller */ 
     5642    ppc6xx_irq_init(env); 
     5643} 
     5644 
     5645/* PowerPC 7457 (aka G4)                                                     */ 
     5646#define POWERPC_INSNS_7457   (PPC_INSNS_BASE | PPC_STRING | PPC_MFTB |        \ 
     5647                              PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |   \ 
     5648                              PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |           \ 
     5649                              PPC_FLOAT_STFIWX |                              \ 
     5650                              PPC_CACHE | PPC_CACHE_ICBI |                    \ 
     5651                              PPC_CACHE_DCBA | PPC_CACHE_DCBZ |               \ 
     5652                              PPC_MEM_SYNC | PPC_MEM_EIEIO |                  \ 
     5653                              PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |               \ 
     5654                              PPC_MEM_TLBIA | PPC_74xx_TLB |                  \ 
     5655                              PPC_SEGMENT | PPC_EXTERN |                      \ 
     5656                              PPC_ALTIVEC) 
     5657#define POWERPC_MSRM_7457    (0x000000000205FF77ULL) 
     5658#define POWERPC_MMU_7457     (POWERPC_MMU_SOFT_74xx) 
     5659#define POWERPC_EXCP_7457    (POWERPC_EXCP_74xx) 
     5660#define POWERPC_INPUT_7457   (PPC_FLAGS_INPUT_6xx) 
     5661#define POWERPC_BFDM_7457    (bfd_mach_ppc_7400) 
     5662#define POWERPC_FLAG_7457    (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \ 
     5663                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM |            \ 
     5664                              POWERPC_FLAG_BUS_CLK) 
     5665#define check_pow_7457       check_pow_hid0_74xx 
     5666 
     5667__attribute__ (( unused )) 
     5668static void init_proc_7457 (CPUPPCState *env) 
     5669{ 
     5670    gen_spr_ne_601(env); 
     5671    gen_spr_7xx(env); 
     5672    /* Time base */ 
     5673    gen_tbl(env); 
     5674    /* 74xx specific SPR */ 
     5675    gen_spr_74xx(env); 
     5676    /* Level 3 cache control */ 
     5677    gen_l3_ctrl(env); 
     5678    /* L3ITCR1 */ 
     5679    /* XXX : not implemented */ 
     5680    spr_register(env, SPR_L3ITCR1, "L3ITCR1", 
     5681                 SPR_NOACCESS, SPR_NOACCESS, 
     5682                 &spr_read_generic, &spr_write_generic, 
     5683                 0x00000000); 
     5684    /* L3ITCR2 */ 
     5685    /* XXX : not implemented */ 
     5686    spr_register(env, SPR_L3ITCR2, "L3ITCR2", 
     5687                 SPR_NOACCESS, SPR_NOACCESS, 
     5688                 &spr_read_generic, &spr_write_generic, 
     5689                 0x00000000); 
     5690    /* L3ITCR3 */ 
     5691    /* XXX : not implemented */ 
     5692    spr_register(env, SPR_L3ITCR3, "L3ITCR3", 
     5693                 SPR_NOACCESS, SPR_NOACCESS, 
     5694                 &spr_read_generic, &spr_write_generic, 
     5695                 0x00000000); 
     5696    /* L3OHCR */ 
     5697    /* XXX : not implemented */ 
     5698    spr_register(env, SPR_L3OHCR, "L3OHCR", 
     5699                 SPR_NOACCESS, SPR_NOACCESS, 
     5700                 &spr_read_generic, &spr_write_generic, 
     5701                 0x00000000); 
    55335702    /* LDSTCR */ 
    55345703    /* XXX : not implemented */ 
     
    66526821    CPU_POWERPC_7400_v11           = 0x000C0101, 
    66536822    CPU_POWERPC_7400_v20           = 0x000C0200, 
     6823    CPU_POWERPC_7400_v21           = 0x000C0201, 
    66546824    CPU_POWERPC_7400_v22           = 0x000C0202, 
    66556825    CPU_POWERPC_7400_v26           = 0x000C0206, 
     
    66726842    CPU_POWERPC_7450_v11           = 0x80000101, 
    66736843    CPU_POWERPC_7450_v12           = 0x80000102, 
    6674     CPU_POWERPC_7450_v20           = 0x80000200, /* aka D: 2.04 */ 
     6844    CPU_POWERPC_7450_v20           = 0x80000200, /* aka A, B, C, D: 2.04 */ 
    66756845    CPU_POWERPC_7450_v21           = 0x80000201, /* aka E */ 
    6676     CPU_POWERPC_74x1               = 0x80000203, 
    6677     CPU_POWERPC_74x1G              = 0x80000210, /* aka G: 2.3 */ 
     6846#define CPU_POWERPC_74x1             CPU_POWERPC_74x1_v23 
     6847    CPU_POWERPC_74x1_v23           = 0x80000203, /* aka G: 2.3 */ 
     6848    /* XXX: this entry might be a bug in some documentation */ 
     6849    CPU_POWERPC_74x1_v210          = 0x80000210, /* aka G: 2.3 ? */ 
    66786850#define CPU_POWERPC_74x5             CPU_POWERPC_74x5_v32 
    66796851    CPU_POWERPC_74x5_v10           = 0x80010100, 
     
    83018473    /* PowerPC 7400 v2.0 (G4)                                                */ 
    83028474    POWERPC_DEF("7400_v2.0",     CPU_POWERPC_7400_v20,               7400), 
     8475    /* PowerPC 7400 v2.1 (G4)                                                */ 
     8476    POWERPC_DEF("7400_v2.1",     CPU_POWERPC_7400_v21,               7400), 
    83038477    /* PowerPC 7400 v2.2 (G4)                                                */ 
    83048478    POWERPC_DEF("7400_v2.2",     CPU_POWERPC_7400_v22,               7400), 
     
    83538527    /* PowerPC 7451 (G4)                                                     */ 
    83548528    POWERPC_DEF("7451",          CPU_POWERPC_74x1,                   7450), 
    8355     /* PowerPC 7441g (G4)                                                    */ 
    8356     POWERPC_DEF("7441g",         CPU_POWERPC_74x1G,                  7440), 
    8357     /* PowerPC 7451g (G4)                                                    */ 
    8358     POWERPC_DEF("7451g",         CPU_POWERPC_74x1G,                  7450), 
     8529    /* PowerPC 7441 v2.1 (G4)                                                */ 
     8530    POWERPC_DEF("7441_v2.1",     CPU_POWERPC_7450_v21,               7440), 
     8531    /* PowerPC 7441 v2.3 (G4)                                                */ 
     8532    POWERPC_DEF("7441_v2.3",     CPU_POWERPC_74x1_v23,               7440), 
     8533    /* PowerPC 7451 v2.3 (G4)                                                */ 
     8534    POWERPC_DEF("7451_v2.3",     CPU_POWERPC_74x1_v23,               7450), 
     8535    /* PowerPC 7441 v2.10 (G4)                                                */ 
     8536    POWERPC_DEF("7441_v2.10",    CPU_POWERPC_74x1_v210,              7440), 
     8537    /* PowerPC 7451 v2.10 (G4)                                               */ 
     8538    POWERPC_DEF("7451_v2.10",    CPU_POWERPC_74x1_v210,              7450), 
    83598539    /* PowerPC 7445 (G4)                                                     */ 
    83608540    POWERPC_DEF("7445",          CPU_POWERPC_74x5,                   7445), 
     
    83978577    /* PowerPC 7457 v1.1 (G4)                                                */ 
    83988578    POWERPC_DEF("7457_v1.1",     CPU_POWERPC_74x7_v11,               7455), 
    8399     /* PowerPC 7447 v1.2 (G4)                                                */ 
    8400     POWERPC_DEF("7447_v1.2",     CPU_POWERPC_74x7_v12,               7445), 
    84018579    /* PowerPC 7457 v1.2 (G4)                                                */ 
    84028580    POWERPC_DEF("7457_v1.2",     CPU_POWERPC_74x7_v12,               7455), 
  • trunk/src/host/qemu-neo1973/target-sparc/translate.c

    r3517 r3627  
    37933793        return NULL; 
    37943794    cpu_exec_init(env); 
     3795    env->cpu_model_str = cpu_model; 
    37953796    env->version = def->iu_version; 
    37963797    env->fsr = def->fpu_version; 
Note: See TracChangeset for help on using the changeset viewer.