source: trunk/packages/xen-3.1/xen-3.1/tools/ioemu/pc-bios/ohw.diff @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

  • Property svn:mime-type set to text/x-patch
File size: 65.0 KB
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/bios.h OpenHackWare-release-0.4/src/bios.h
    old new  
    6464    ARCH_CHRP,
    6565    ARCH_MAC99,
    6666    ARCH_POP,
     67    ARCH_HEATHROW,
    6768};
    6869
    6970/* Hardware definition(s) */
     
    174175int bd_ioctl (bloc_device_t *bd, int func, void *args);
    175176uint32_t bd_seclen (bloc_device_t *bd);
    176177void bd_close (bloc_device_t *bd);
     178void bd_reset_all(void);
    177179uint32_t bd_seclen (bloc_device_t *bd);
    178180uint32_t bd_maxbloc (bloc_device_t *bd);
    179181void bd_sect2CHS (bloc_device_t *bd, uint32_t secnum,
     
    183185part_t *bd_probe (int boot_device);
    184186bloc_device_t *bd_get (int device);
    185187void bd_put (bloc_device_t *bd);
    186 void bd_set_boot_part (bloc_device_t *bd, part_t *partition);
     188void bd_set_boot_part (bloc_device_t *bd, part_t *partition, int partnum);
    187189part_t **_bd_parts (bloc_device_t *bd);
    188190
    189191void ide_pci_pc_register (uint32_t io_base0, uint32_t io_base1,
    190192                          uint32_t io_base2, uint32_t io_base3,
    191                           void *OF_private);
     193                          void *OF_private0, void *OF_private1);
    192194void ide_pci_pmac_register (uint32_t io_base0, uint32_t io_base1,
    193195                            void *OF_private);
    194196
     
    399401                              uint16_t min_grant, uint16_t max_latency);
    400402void OF_finalize_pci_host (void *dev, int first_bus, int nb_busses);
    401403void OF_finalize_pci_device (void *dev, uint8_t bus, uint8_t devfn,
    402                              uint32_t *regions, uint32_t *sizes);
     404                             uint32_t *regions, uint32_t *sizes,
     405                             int irq_line);
    403406void OF_finalize_pci_macio (void *dev, uint32_t base_address, uint32_t size,
    404407                            void *private_data);
     408void OF_finalize_pci_ide (void *dev,
     409                          uint32_t io_base0, uint32_t io_base1,
     410                          uint32_t io_base2, uint32_t io_base3);
    405411int OF_register_bus (const unsigned char *name, uint32_t address,
    406412                     const unsigned char *type);
    407413int OF_register_serial (const unsigned char *bus, const unsigned char *name,
    408414                        uint32_t io_base, int irq);
    409415int OF_register_stdio (const unsigned char *dev_in,
    410416                       const unsigned char *dev_out);
    411 void OF_vga_register (const unsigned char *name, uint32_t address,
    412                       int width, int height, int depth);
     417void OF_vga_register (const unsigned char *name, unused uint32_t address,
     418                      int width, int height, int depth,
     419                      unsigned long vga_bios_addr,
     420                      unsigned long vga_bios_size);
    413421void *OF_blockdev_register (void *parent, void *private,
    414422                            const unsigned char *type,
    415423                            const unsigned char *name, int devnum,
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/bloc.c OpenHackWare-release-0.4/src/bloc.c
    old new  
    5555    /* Partitions */
    5656    part_t *parts, *bparts;
    5757    part_t *boot_part;
     58    int bpartnum;
    5859    /* Chain */
    5960    bloc_device_t *next;
    6061};
     
    6667
    6768static int ide_initialize (bloc_device_t *bd, int device);
    6869static int ide_read_sector (bloc_device_t *bd, void *buffer, int secnum);
     70static int ide_reset (bloc_device_t *bd);
    6971
    7072static int mem_initialize (bloc_device_t *bd, int device);
    7173static int mem_read_sector (bloc_device_t *bd, void *buffer, int secnum);
     
    212214{
    213215}
    214216
     217void bd_reset_all(void)
     218{
     219    bloc_device_t *bd;
     220    for (bd = bd_list; bd != NULL; bd = bd->next) {
     221        if (bd->init == &ide_initialize) {
     222            /* reset IDE drive because Darwin wants all IDE devices to be reset */
     223            ide_reset(bd);
     224        }
     225    }
     226}
     227
    215228uint32_t bd_seclen (bloc_device_t *bd)
    216229{
    217230    return bd->seclen;
     
    223236}
    224237
    225238/* XXX: to be suppressed */
    226 void bd_set_boot_part (bloc_device_t *bd, part_t *partition)
     239void bd_set_boot_part (bloc_device_t *bd, part_t *partition, int partnum)
    227240{
     241    dprintf("%s: part %p (%p) %d\n", __func__, partition, bd->boot_part, partnum);
    228242    if (bd->boot_part == NULL) {
    229243        bd->boot_part = partition;
     244        bd->bpartnum = partnum;
    230245    }
    231246}
    232247
     
    240255    return &bd->bparts;
    241256}
    242257
     258void bd_set_boot_device (bloc_device_t *bd)
     259{
     260#if defined (USE_OPENFIRMWARE)
     261    OF_blockdev_set_boot_device(bd->OF_private, bd->bpartnum, "\\\\ofwboot");
     262#endif
     263}
     264
    243265part_t *bd_probe (int boot_device)
    244266{
    245267    char devices[] = { /*'a', 'b',*/ 'c', 'd', 'e', 'f', 'm', '\0', };
     
    272294        tmp = part_probe(bd, force_raw);
    273295        if (boot_device == bd->device) {
    274296            boot_part = tmp;
    275 #if defined (USE_OPENFIRMWARE)
    276             OF_blockdev_set_boot_device(bd->OF_private, 2, "\\\\ofwboot");
    277 #endif
     297            bd_set_boot_device(bd);
    278298        }
    279299    }
    280300
     
    717737/* IDE PCI access for pc */
    718738static uint8_t ide_pci_port_read (bloc_device_t *bd, int port)
    719739{
    720     eieio();
    721 
    722     return *(uint8_t *)(bd->io_base + port);
     740    uint8_t value;
     741    value = inb(bd->io_base + port);
     742    return value;
    723743}
    724744
    725745static void ide_pci_port_write (bloc_device_t *bd, int port, uint8_t value)
    726746{
    727     *(uint8_t *)(bd->io_base + port) = value;
    728     eieio();
     747    outb(bd->io_base + port, value);
    729748}
    730749
    731750static uint32_t ide_pci_data_readl (bloc_device_t *bd)
    732751{
    733     eieio();
    734 
    735     return *((uint32_t *)bd->io_base);
     752    return inl(bd->io_base);
    736753}
    737754
    738755static void ide_pci_data_writel (bloc_device_t *bd, uint32_t val)
    739756{
    740     *(uint32_t *)(bd->io_base) = val;
    741     eieio();
     757    outl(bd->io_base, val);
    742758}
    743759
    744760static void ide_pci_control_write (bloc_device_t *bd, uint32_t val)
    745761{
    746     *((uint8_t *)bd->tmp) = val;
    747     eieio();
     762    outb(bd->tmp + 2, val);
    748763}
    749764
    750765static ide_ops_t ide_pci_pc_ops = {
     
    761776
    762777void ide_pci_pc_register (uint32_t io_base0, uint32_t io_base1,
    763778                          uint32_t io_base2, uint32_t io_base3,
    764                           unused void *OF_private)
     779                          void *OF_private0, void *OF_private1)
    765780{
    766781    if (ide_pci_ops == NULL) {
    767782        ide_pci_ops = malloc(sizeof(ide_ops_t));
     
    770785        memcpy(ide_pci_ops, &ide_pci_pc_ops, sizeof(ide_ops_t));
    771786    }
    772787    if ((io_base0 != 0 || io_base1 != 0) &&
    773         ide_pci_ops->base[0] == 0 && ide_pci_ops->base[1] == 0) {
     788        ide_pci_ops->base[0] == 0 && ide_pci_ops->base[2] == 0) {
    774789        ide_pci_ops->base[0] = io_base0;
    775         ide_pci_ops->base[1] = io_base1;
     790        ide_pci_ops->base[2] = io_base1;
    776791#ifdef USE_OPENFIRMWARE
    777         ide_pci_ops->OF_private[0] = OF_private;
     792        ide_pci_ops->OF_private[0] = OF_private0;
    778793#endif
    779794    }
    780795    if ((io_base2 != 0 || io_base3 != 0) &&
    781         ide_pci_ops->base[2] == 0 && ide_pci_ops->base[3] == 0) {
    782         ide_pci_ops->base[2] = io_base2;
     796        ide_pci_ops->base[1] == 0 && ide_pci_ops->base[3] == 0) {
     797        ide_pci_ops->base[1] = io_base2;
    783798        ide_pci_ops->base[3] = io_base3;
    784799#ifdef USE_OPENFIRMWARE
    785         ide_pci_ops->OF_private[1] = OF_private;
     800        ide_pci_ops->OF_private[1] = OF_private1;
    786801#endif
    787802    }
    788803}
     
    935950}
    936951
    937952static void atapi_pad_req (void *buffer, int len);
     953static void atapi_make_req (bloc_device_t *bd, uint32_t *buffer,
     954                            int maxlen);
    938955static int atapi_read_sector (bloc_device_t *bd, void *buffer, int secnum);
    939956
    940957static int ide_initialize (bloc_device_t *bd, int device)
     
    10351052        DPRINTF("INQUIRY\n");
    10361053        len = spc_inquiry_req(&atapi_buffer, 36);
    10371054        atapi_pad_req(&atapi_buffer, len);
    1038         ide_port_write(bd, 0x07, 0xA0);
    1039         for (i = 0; i < 3; i++)
    1040             ide_data_writel(bd, ldswap32(&atapi_buffer[i]));
     1055        atapi_make_req(bd, atapi_buffer, 36);
    10411056        status = ide_port_read(bd, 0x07);
    10421057        if (status != 0x48) {
    10431058            ERROR("ATAPI INQUIRY : status %0x != 0x48\n", status);
     
    10531068        DPRINTF("READ_CAPACITY\n");
    10541069        len = mmc_read_capacity_req(&atapi_buffer);
    10551070        atapi_pad_req(&atapi_buffer, len);
    1056         ide_port_write(bd, 0x07, 0xA0);
    1057         for (i = 0; i < 3; i++)
    1058             ide_data_writel(bd, ldswap32(&atapi_buffer[i]));
     1071        atapi_make_req(bd, atapi_buffer, 8);
    10591072        status = ide_port_read(bd, 0x07);
    10601073        if (status != 0x48) {
    10611074            ERROR("ATAPI READ_CAPACITY : status %0x != 0x48\n", status);
     
    11051118    memset(p + len, 0, 12 - len);
    11061119}
    11071120
     1121static void atapi_make_req (bloc_device_t *bd, uint32_t *buffer,
     1122                            int maxlen)
     1123{
     1124    int i;
     1125    /* select drive */
     1126    if (bd->drv == 0)
     1127        ide_port_write(bd, 0x06, 0x40);
     1128    else
     1129        ide_port_write(bd, 0x06, 0x50);
     1130    ide_port_write(bd, 0x04, maxlen & 0xff);
     1131    ide_port_write(bd, 0x05, (maxlen >> 8) & 0xff);
     1132    ide_port_write(bd, 0x07, 0xA0);
     1133    for (i = 0; i < 3; i++)
     1134        ide_data_writel(bd, ldswap32(&buffer[i]));
     1135}
     1136
    11081137static int atapi_read_sector (bloc_device_t *bd, void *buffer, int secnum)
    11091138{
    11101139    uint32_t atapi_buffer[4];
     
    11121141    uint32_t status, value;
    11131142    int i, len;
    11141143
    1115     /* select drive */
    1116     if (bd->drv == 0)
    1117         ide_port_write(bd, 0x06, 0x40);
    1118     else
    1119         ide_port_write(bd, 0x06, 0x50);
    11201144    len = mmc_read12_req(atapi_buffer, secnum, 1);
    11211145    atapi_pad_req(&atapi_buffer, len);
    1122     ide_port_write(bd, 0x07, 0xA0);
    1123     for (i = 0; i < 3; i++)
    1124         ide_data_writel(bd, ldswap32(&atapi_buffer[i]));
     1146    atapi_make_req(bd, atapi_buffer, bd->seclen);
    11251147    status = ide_port_read(bd, 0x07);
    11261148    if (status != 0x48) {
    11271149        ERROR("ATAPI READ12 : status %0x != 0x48\n", status);
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/libpart/apple.c OpenHackWare-release-0.4/src/libpart/apple.c
    old new  
    199199        if (len == 0) {
    200200            /* Place holder. Skip it */
    201201            DPRINTF("%s placeholder part\t%d\n", __func__, i);
     202            part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY;
     203            part_register(bd, part, name, i);
    202204        } else if (strncmp("Apple_Void", type, 32) == 0) {
    203205            /* Void partition. Skip it */
    204206            DPRINTF("%s Void part\t%d [%s]\n", __func__, i, type);
     207            part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY;
     208            part_register(bd, part, name, i);
    205209        } else if (strncmp("Apple_Free", type, 32) == 0) {
    206210            /* Free space. Skip it */
    207211            DPRINTF("%s Free part (%d)\n", __func__, i);
    208212            part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY;
    209             part_register(bd, part, name);
     213            part_register(bd, part, name, i);
    210214        } else if (strncmp("Apple_partition_map", type, 32) == 0 ||
    211215                   strncmp("Apple_Partition_Map", type, 32) == 0
    212216#if 0 // Is this really used or is it just a mistake ?
     
    226230                 */
    227231            }
    228232            part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY;
    229             part_register(bd, part, name);
     233            part_register(bd, part, name, i);
    230234        } else if (strncmp("Apple_Driver", type, 32) == 0 ||
    231235                   strncmp("Apple_Driver43", type, 32) == 0 ||
    232236                   strncmp("Apple_Driver43_CD", type, 32) == 0 ||
     
    236240                   strncmp("Apple_Driver_IOKit", type, 32) == 0) {
    237241            /* Drivers. don't care for now */
    238242            DPRINTF("%s Drivers part\t%d [%s]\n", __func__, i, type);
     243            part->flags = PART_TYPE_APPLE | PART_FLAG_DRIVER;
     244            part_register(bd, part, name, i);
    239245        } else if (strncmp("Apple_Patches", type, 32) == 0) {
    240246            /* Patches: don't care for now */
     247            part->flags = PART_TYPE_APPLE | PART_FLAG_PATCH;
     248            part_register(bd, part, name, i);
    241249            DPRINTF("%s Patches part\t%d [%s]\n", __func__, i, type);
    242250        } else if (strncmp("Apple_HFS", type, 32) == 0 ||
    243251                   strncmp("Apple_MFS", type, 32) == 0 ||
     
    256264            count = partmap->bloc_cnt * HFS_BLOCSIZE;
    257265            if (partmap->boot_size == 0 || partmap->boot_load == 0) {
    258266                printf("Not a bootable partition %d %d (%p %p)\n",
    259                        partmap->boot_size, partmap->boot_load,boot_part, part);
    260                 if (boot_part == NULL)
    261                     boot_part = part;
     267                       partmap->boot_size, partmap->boot_load,
     268                       boot_part, part);
    262269                part->flags = PART_TYPE_APPLE | PART_FLAG_FS;
    263270            } else {
    264271                part->boot_start.bloc = partmap->boot_start;
     
    278285                boot_part = part;
    279286                part->flags = PART_TYPE_APPLE | PART_FLAG_FS | PART_FLAG_BOOT;
    280287            }
    281             printf("Partition: %d %s st %0x size %0x",
    282                     i, name, partmap->start_bloc, partmap->bloc_cnt);
     288            printf("Partition: %d '%s' '%s' st %0x size %0x",
     289                    i, name, type, partmap->start_bloc, partmap->bloc_cnt);
    283290#ifndef DEBUG
    284291            printf("\n");
    285292#endif
     
    290297                    part->boot_load, part->boot_entry);
    291298            DPRINTF("                           load %0x entry %0x %0x\n",
    292299                    partmap->boot_load2, partmap->boot_entry2, HFS_BLOCSIZE);
    293             part_register(bd, part, name);
     300            part_register(bd, part, name, i);
    294301        } else {
    295302            memcpy(tmp, type, 32);
    296303            tmp[32] = '\0';
    297304            ERROR("Unknown partition type [%s]\n", tmp);
     305            part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY;
     306            part_register(bd, part, name, i);
    298307        }
    299308    }
    300309 error:
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/libpart/core.c OpenHackWare-release-0.4/src/libpart/core.c
    old new  
    126126}
    127127
    128128int part_register (bloc_device_t *bd, part_t *partition,
    129                    const unsigned char *name)
     129                   const unsigned char *name, int partnum)
    130130{
    131131    part_t **cur;
    132132
     
    134134    partition->bd = bd;
    135135    partition->next = NULL;
    136136    partition->name = strdup(name);
     137    partition->partnum = partnum;
    137138    for (cur = _bd_parts(bd); *cur != NULL; cur = &(*cur)->next)
    138139        continue;
    139140    *cur = partition;
     
    141142    return 0;
    142143}
    143144
    144 static inline int set_boot_part (bloc_device_t *bd, int partnum)
    145 {
    146     part_t *cur;
    147 
    148     cur = part_get(bd, partnum);
    149     if (cur == NULL)
    150         return -1;
    151     bd_set_boot_part(bd, cur);
    152 
    153     return 0;
    154 }
    155 
    156145part_t *part_get (bloc_device_t *bd, int partnum)
    157146{
    158147    part_t **listp, *cur;
    159     int i;
    160148
    161149    listp = _bd_parts(bd);
    162     cur = *listp;
    163     for (i = 0; i != partnum; i++) {
    164         if (cur == NULL)
     150   
     151    for (cur = *listp; cur != NULL; cur = cur->next) {
     152        if (cur->partnum == partnum)
    165153            break;
    166         cur = cur->next;
    167154    }
    168155   
    169156    return cur;
     
    192179    part_set_blocsize(bd, part, 512);
    193180    part->bd = bd;
    194181    part->flags = PART_TYPE_RAW | PART_FLAG_BOOT;
    195     part_register(bd, part, "Raw");
     182    part_register(bd, part, "Raw", 0);
    196183
    197184    return part;
    198185}
    199186
     187bloc_device_t *part_get_bd (part_t *part)
     188{
     189    return part->bd;
     190}
     191
    200192part_t *part_probe (bloc_device_t *bd, int set_raw)
    201193{
    202     part_t *part0, *boot_part, **cur;
     194    part_t *part0 = NULL, *boot_part, **cur;
    203195
    204     /* Register the 0 partition: raw partition containing the whole disk */
    205     part0 = part_get_raw(bd);
    206196    /* Try to find a valid boot partition */
    207197    boot_part = Apple_probe_partitions(bd);
    208198    if (boot_part == NULL) {
     
    210200        if (boot_part == NULL && arch == ARCH_PREP)
    211201            boot_part = PREP_find_partition(bd);
    212202        if (boot_part == NULL && set_raw != 0) {
    213             boot_part = part0;
    214             set_boot_part(bd, 0);
     203            dprintf("Use bloc device as raw partition\n");
    215204        }
    216205    }
     206    if (_bd_parts(bd) == NULL) {
     207        /* Register the 0 partition: raw partition containing the whole disk */
     208        part0 = part_get_raw(bd);
     209    }
    217210    /* Probe filesystem on each found partition */
    218211    for (cur = _bd_parts(bd); *cur != NULL; cur = &(*cur)->next) {
    219212        const unsigned char *map, *type;
     
    248241            type = "unknown";
    249242            break;
    250243        }
    251         DPRINTF("Probe filesystem on %s %s partition '%s' %s\n",
     244        dprintf("Probe filesystem on %s %s partition '%s' %s %p\n",
    252245                type, map, (*cur)->name,
    253                 ((*cur)->flags) & PART_FLAG_BOOT ? "(bootable)" : "");
     246                ((*cur)->flags) & PART_FLAG_BOOT ? "(bootable)" : "", *cur);
    254247        if (((*cur)->flags) & PART_FLAG_FS) {
    255248            if (((*cur)->flags) & PART_FLAG_BOOT)
    256249                (*cur)->fs = fs_probe(*cur, 1);
    257250            else
    258251                (*cur)->fs = fs_probe(*cur, 0);
     252        } else if (((*cur)->flags) & PART_TYPE_RAW) {
     253            (*cur)->fs = fs_probe(*cur, 2);
    259254        } else {
    260255            (*cur)->fs = fs_probe(*cur, 2);
    261256        }
    262         if (((*cur)->flags) & PART_FLAG_BOOT) {
    263             bd_set_boot_part(bd, *cur);
    264257            fs_get_bootfile((*cur)->fs);
     258        if (((*cur)->flags) & PART_FLAG_BOOT) {
     259            dprintf("Partition is bootable (%d)\n", (*cur)->partnum);
     260            bd_set_boot_part(bd, *cur, (*cur)->partnum);
     261            if (boot_part == NULL)
     262                boot_part = *cur;
    265263        }
    266264    }
    267     DPRINTF("Boot partition: %p %p %p %p\n", boot_part, boot_part->fs,
     265    dprintf("Boot partition: %p %p %p %p\n", boot_part, boot_part->fs,
    268266            part_fs(boot_part), part0);
    269267
    270268    return boot_part;
     
    279277    part->boot_size.offset = 0;
    280278    part->boot_load = 0;
    281279    part->boot_entry = 0;
     280    part->flags |= PART_FLAG_BOOT;
    282281
    283282    return 0;
    284283}
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/libpart/isofs.c OpenHackWare-release-0.4/src/libpart/isofs.c
    old new  
    242242                   part->boot_start.bloc, part->boot_size.bloc,
    243243                   part->boot_load, part->boot_entry);
    244244            part->flags = PART_TYPE_ISO9660 | PART_FLAG_BOOT;
    245             part_register(bd, part, name);
     245            part_register(bd, part, name, i + 1);
    246246            fs_raw_set_bootfile(part, part->boot_start.bloc,
    247247                                part->boot_start.offset,
    248248                                part->boot_size.bloc,
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/libpart/libpart.h OpenHackWare-release-0.4/src/libpart/libpart.h
    old new  
    3030
    3131struct part_t {
    3232    bloc_device_t *bd;
     33    int partnum;
    3334    uint32_t start;      /* Partition first bloc             */
    3435    uint32_t size;       /* Partition size, in blocs         */
    3536    uint32_t spb;
     
    5455};
    5556
    5657int part_register (bloc_device_t *bd, part_t *partition,
    57                    const unsigned char *name);
     58                   const unsigned char *name, int partnum);
    5859void part_set_blocsize (bloc_device_t *bd, part_t *part, uint32_t blocsize);
    5960void part_private_set (part_t *part, void *private);
    6061void *part_private_get (part_t *part);
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/libpart/prep.c OpenHackWare-release-0.4/src/libpart/prep.c
    old new  
    164164            part->boot_load = 0;
    165165            part->boot_entry = boot_offset - part->bloc_size;
    166166            part->flags = PART_TYPE_PREP | PART_FLAG_BOOT;
    167             part_register(bd, part, "PREP boot");
     167            part_register(bd, part, "PREP boot", i);
    168168            fs_raw_set_bootfile(part, part->boot_start.bloc,
    169169                                part->boot_start.offset,
    170170                                part->boot_size.bloc,
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/main.c OpenHackWare-release-0.4/src/main.c
    old new  
    364364    void *load_base, *load_entry, *last_alloc, *load_end;
    365365    uint32_t memsize, boot_image_size, cmdline_size, ramdisk_size;
    366366    uint32_t boot_base, boot_nb;
    367     int boot_device;
     367    int boot_device, i;
     368    static const uint32_t isa_base_tab[3] = {
     369        0x80000000, /* PREP */
     370        0xFE000000, /* Grackle (Heathrow) */
     371        0xF2000000, /* UniNorth (Mac99)  */
     372    };
    368373
    369374    /* Retrieve NVRAM configuration */
    370  nvram_retry:
     375    for(i = 0; i < 3; i++) {
     376        isa_io_base = isa_base_tab[i];
    371377    nvram = NVRAM_get_config(&memsize, &boot_device,
    372378                             &boot_image, &boot_image_size,
    373379                             &cmdline, &cmdline_size,
    374380                             &ramdisk, &ramdisk_size);
    375     if (nvram == NULL) {
    376         /* Retry with another isa_io_base */
    377         if (isa_io_base == 0x80000000) {
    378             isa_io_base = 0xF2000000;
    379             goto nvram_retry;
     381        if (nvram)
     382            break;
    380383        }
     384    if (i == 3) {
    381385        ERROR("Unable to load configuration from NVRAM. Aborting...\n");
    382386        return -1;
    383387    }
     
    402406        cpu_name = CPU_get_name(pvr);
    403407        OF_register_cpu(cpu_name, 0, pvr,
    404408                        200 * 1000 * 1000, 200 * 1000 * 1000,
    405                         100 * 1000 * 1000, 10 * 1000 * 1000,
     409                        100 * 1000 * 1000, 100 * 1000 * 1000,
    406410                        0x0092);
    407411    }
    408412    OF_register_memory(memsize, 512 * 1024 /* TOFIX */);
     
    433437    vga_puts(copyright);
    434438    vga_puts("\n");
    435439
     440#if 0
    436441    /* QEMU is quite incoherent: d is cdrom, not second drive */
     442    /* XXX: should probe CD-ROM position */
    437443    if (boot_device == 'd')
    438444        boot_device = 'e';
     445#endif
    439446    /* Open boot device */
    440447    boot_part = bd_probe(boot_device);
    441448    if (boot_device == 'm') {
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/nvram.c OpenHackWare-release-0.4/src/nvram.c
    old new  
    334334        ret = NVRAM_chrp_format(nvram);
    335335        break;
    336336    case ARCH_MAC99:
     337    case ARCH_HEATHROW: /* XXX: may be incorrect */
    337338        ret = NVRAM_mac99_format(nvram);
    338339        break;
    339340    case ARCH_POP:
     
    409410        arch = ARCH_MAC99;
    410411    } else if (strcmp(sign, "POP") == 0) {
    411412        arch = ARCH_POP;
     413    } else if (strcmp(sign, "HEATHROW") == 0) {
     414        arch = ARCH_HEATHROW;
    412415    } else {
    413416        ERROR("Unknown PPC architecture: '%s'\n", sign);
    414417        return NULL;
    415418    }
    416     /* HACK */
    417     if (arch == ARCH_CHRP)
    418         arch = ARCH_MAC99;
    419419    lword = NVRAM_get_lword(nvram, 0x30);
    420420    *RAM_size = lword;
    421421    byte = NVRAM_get_byte(nvram, 0x34);
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/of.c OpenHackWare-release-0.4/src/of.c
    old new  
    489489        ERROR("%s can't alloc new node '%s' name\n", __func__, name);
    490490        return NULL;
    491491    }
    492     new->prop_address = OF_prop_int_new(env, new, "address", address);
     492    new->prop_address = OF_prop_int_new(env, new, "unit-address", address);
    493493    if (new->prop_address == NULL) {
    494494        free(new->prop_name->value);
    495495        free(new->prop_name);
     
    10171017                           string, strlen(string) + 1);
    10181018}
    10191019
     1020/* convert '\1' char to '\0' */
     1021static OF_prop_t *OF_prop_string_new1 (OF_env_t *env, OF_node_t *node,
     1022                                       const unsigned char *name,
     1023                                       const unsigned char *string)
     1024{
     1025    int len, i;
     1026    OF_prop_t *ret;
     1027    unsigned char *str;
     1028
     1029    if (strchr(string, '\1') == NULL) {
     1030        return OF_prop_string_new(env, node, name, string);
     1031    } else {
     1032        len = strlen(string) + 1;
     1033        str = malloc(len);
     1034        if (!str)
     1035            return NULL;
     1036        memcpy(str, string, len);
     1037        for(i = 0; i < len; i++)
     1038            if (str[i] == '\1')
     1039                str[i] = '\0';
     1040        ret = OF_property_new(env, node, name,
     1041                              str, len);
     1042        free(str);
     1043        return ret;
     1044    }
     1045}
     1046
    10201047__attribute__ (( section (".OpenFirmware") ))
    10211048static OF_prop_t *OF_prop_int_new (OF_env_t *env, OF_node_t *node,
    10221049                                   const unsigned char *name, uint32_t value)
     
    14211448__attribute__ (( section (".OpenFirmware") ))
    14221449int OF_init (void)
    14231450{
    1424     const unsigned char compat_str[] =
    14251451#if 0
    14261452        "PowerMac3,1\0MacRISC\0Power Macintosh\0";
    14271453        "PowerMac1,2\0MacRISC\0Power Macintosh\0";
    14281454        "AAPL,PowerMac G3\0PowerMac G3\0MacRISC\0Power Macintosh\0";
    14291455        "AAPL,PowerMac3,0\0MacRISC\0Power Macintosh\0";
    14301456        "AAPL,Gossamer\0MacRISC\0Power Macintosh\0";
    1431 #else
    1432         "AAPL,PowerMac G3\0PowerMac G3\0MacRISC\0Power Macintosh\0";
    14331457#endif
    14341458    OF_env_t *OF_env;
    14351459    OF_node_t *als, *opt, *chs, *pks;
     
    14551479        return -1;
    14561480    }
    14571481    OF_prop_string_new(OF_env, OF_node_root, "device_type", "bootrom");
    1458 #if 0
    1459     OF_prop_string_new(OF_env, OF_node_root,
    1460                        "model", "PPC Open Hack'Ware " BIOS_VERSION);
    1461 #else
     1482    if (arch == ARCH_HEATHROW) {
     1483        const unsigned char compat_str[] =
     1484            "PowerMac1,1\0MacRISC\0Power Macintosh";
     1485        OF_property_new(OF_env, OF_node_root, "compatible",
     1486                        compat_str, sizeof(compat_str));
    14621487    OF_prop_string_new(OF_env, OF_node_root,
    1463                        "model", compat_str);
    1464 #endif
     1488                           "model", "Power Macintosh");
     1489    } else {
     1490        const unsigned char compat_str[] =
     1491            "PowerMac3,1\0MacRISC\0Power Macintosh";
    14651492    OF_property_new(OF_env, OF_node_root, "compatible",
    14661493                    compat_str, sizeof(compat_str));
     1494        OF_prop_string_new(OF_env, OF_node_root,
     1495                           "model", "PowerMac3,1");
     1496    }
    14671497#if 0
    14681498    OF_prop_string_new(OF_env, OF_node_root, "copyright", copyright);
    14691499#else
     
    15611591        range.size = 0x00800000;
    15621592        OF_property_new(OF_env, rom, "ranges", &range, sizeof(OF_range_t));
    15631593        OF_prop_int_new(OF_env, rom, "#address-cells", 1);
     1594
    15641595        /* "/rom/boot-rom@fff00000" node */
    1565         brom = OF_node_new(OF_env, OF_node_root, "boot-rom", 0xfff00000);
     1596        brom = OF_node_new(OF_env, rom, "boot-rom", 0xfff00000);
    15661597        if (brom == NULL) {
    15671598            ERROR("Cannot create 'boot-rom'\n");
    15681599            return -1;
    15691600        }
    15701601        regs.address = 0xFFF00000;
    1571         regs.size = 0x00010000;
     1602        regs.size = 0x00100000;
    15721603        OF_property_new(OF_env, brom, "reg", &regs, sizeof(OF_regprop_t));
    15731604        OF_prop_string_new(OF_env, brom, "write-characteristic", "flash");
    15741605        OF_prop_string_new(OF_env, brom, "BootROM-build-date",
     
    15771608        OF_prop_string_new(OF_env, brom, "copyright", copyright);
    15781609        OF_prop_string_new(OF_env, brom, "model", BIOS_str);
    15791610        OF_prop_int_new(OF_env, brom, "result", 0);
    1580 #if 0
     1611#if 1
    15811612        {
    15821613            /* Hack taken 'as-is' from PearPC */
    15831614            unsigned char info[] = {
     
    15961627        OF_node_put(OF_env, brom);
    15971628        OF_node_put(OF_env, rom);
    15981629    }
     1630#if 0
    15991631    /* From here, hardcoded hacks to get a Mac-like machine */
     1632    /* XXX: Core99 does not seem to like this NVRAM tree */
    16001633    /* "/nvram@fff04000" node */
    16011634    {
    16021635        OF_regprop_t regs;
     
    16171650        OF_prop_int_new(OF_env, chs, "nvram", OF_pack_handle(OF_env, nvr));
    16181651        OF_node_put(OF_env, nvr);
    16191652    }
     1653#endif
    16201654    /* "/pseudo-hid" : hid emulation as Apple does */
    16211655    {
    16221656        OF_node_t *hid;
     
    16631697        }
    16641698        OF_node_put(OF_env, hid);
    16651699    }
     1700    if (arch == ARCH_MAC99) {
     1701        OF_node_t *unin;
     1702        OF_regprop_t regs;
    16661703
     1704        unin = OF_node_new(OF_env, OF_node_root,
     1705                           "uni-n", 0xf8000000);
     1706        if (unin == NULL) {
     1707            ERROR("Cannot create 'uni-n'\n");
     1708            return -1;
     1709        }
     1710        OF_prop_string_new(OF_env, unin, "device-type", "memory-controller");
     1711        OF_prop_string_new(OF_env, unin, "model", "AAPL,UniNorth");
     1712        OF_prop_string_new(OF_env, unin, "compatible", "uni-north");
     1713        regs.address = 0xf8000000;
     1714        regs.size = 0x01000000;
     1715        OF_property_new(OF_env, unin, "reg", &regs, sizeof(regs));
     1716        OF_prop_int_new(OF_env, unin, "#address-cells", 1);
     1717        OF_prop_int_new(OF_env, unin, "#size-cells", 1);
     1718        OF_prop_int_new(OF_env, unin, "device-rev", 3);
     1719        OF_node_put(OF_env, unin);
     1720    }
    16671721   
    16681722#if 1 /* This is mandatory for claim to work
    16691723       * but I don't know where it should really be (in cpu ?)
     
    16931747
    16941748    /* "/options/boot-args" node */
    16951749    {
    1696         const unsigned char *args = "-v rootdev cdrom";
     1750        //        const unsigned char *args = "-v rootdev cdrom";
     1751        //const unsigned char *args = "-v io=0xffffffff";
     1752        const unsigned char *args = "-v";
    16971753        /* Ask MacOS X to print debug messages */
    16981754        //        OF_prop_string_new(OF_env, chs, "machargs", args);
    16991755        //        OF_prop_string_new(OF_env, opt, "boot-command", args);
     
    20132069    OF_prop_int_new(OF_env, node, "min-grant", min_grant);
    20142070    OF_prop_int_new(OF_env, node, "max-latency", max_latency);
    20152071    if (dev->type != NULL)
    2016         OF_prop_string_new(OF_env, node, "device_type", dev->type);
     2072        OF_prop_string_new1(OF_env, node, "device_type", dev->type);
    20172073    if (dev->compat != NULL)
    2018         OF_prop_string_new(OF_env, node, "compatible", dev->compat);
     2074        OF_prop_string_new1(OF_env, node, "compatible", dev->compat);
    20192075    if (dev->model != NULL)
    2020         OF_prop_string_new(OF_env, node, "model", dev->model);
     2076        OF_prop_string_new1(OF_env, node, "model", dev->model);
    20212077    if (dev->acells != 0)
    20222078        OF_prop_int_new(OF_env, node, "#address-cells", dev->acells);
    20232079    if (dev->scells != 0)
    2024         OF_prop_int_new(OF_env, node, "#interrupt-cells", dev->acells);
     2080        OF_prop_int_new(OF_env, node, "#size-cells", dev->scells);
    20252081    if (dev->icells != 0)
    2026         OF_prop_int_new(OF_env, node, "#size-cells", dev->acells);
     2082        OF_prop_int_new(OF_env, node, "#interrupt-cells", dev->icells);
    20272083    dprintf("Done %p %p\n", parent, node);
    20282084   
    20292085    return node;
     
    20402096    OF_env_t *OF_env;
    20412097    pci_range_t ranges[3];
    20422098    OF_regprop_t regs[1];
    2043     OF_node_t *pci_host;
     2099    OF_node_t *pci_host, *als;
    20442100    int nranges;
     2101    unsigned char buffer[OF_NAMELEN_MAX];
    20452102
    20462103    OF_env = OF_env_main;
    20472104    dprintf("register PCI host '%s' '%s' '%s' '%s'\n",
     
    20522109        ERROR("Cannot create pci host\n");
    20532110        return NULL;
    20542111    }
     2112   
     2113    als = OF_node_get(OF_env, "aliases");
     2114    if (als == NULL) {
     2115        ERROR("Cannot get 'aliases'\n");
     2116        return NULL;
     2117    }
     2118    sprintf(buffer, "/%s", dev->name);
     2119    OF_prop_string_set(OF_env, als, "pci", buffer);
     2120    OF_node_put(OF_env, als);
     2121   
     2122
    20552123    regs[0].address = cfg_base;
    20562124    regs[0].size = cfg_len;
    20572125    OF_property_new(OF_env, pci_host, "reg", regs, sizeof(OF_regprop_t));
     
    21362204    return pci_dev;
    21372205}
    21382206
     2207/* XXX: suppress that, used for interrupt map init */
     2208OF_node_t *pci_host_node;
     2209uint32_t pci_host_interrupt_map[7 * 32];
     2210int pci_host_interrupt_map_len = 0;
     2211
    21392212void OF_finalize_pci_host (void *dev, int first_bus, int nb_busses)
    21402213{
    21412214    OF_env_t *OF_env;
     
    21452218    regs[0].address = first_bus;
    21462219    regs[0].size = nb_busses;
    21472220    OF_property_new(OF_env, dev, "bus-range", regs, sizeof(OF_regprop_t));
     2221    pci_host_node = dev;
    21482222}
    21492223
    21502224void OF_finalize_pci_device (void *dev, uint8_t bus, uint8_t devfn,
    2151                              uint32_t *regions, uint32_t *sizes)
     2225                             uint32_t *regions, uint32_t *sizes,
     2226                             int irq_line)
    21522227{
    21532228    OF_env_t *OF_env;
    21542229    pci_reg_prop_t pregs[6], rregs[6];
     
    21562231    int i, j, k;
    21572232
    21582233    OF_env = OF_env_main;
     2234    /* XXX: only useful for VGA card in fact */
    21592235    if (regions[0] != 0x00000000)
    21602236        OF_prop_int_set(OF_env, dev, "address", regions[0] & ~0x0000000F);
    21612237    for (i = 0, j = 0, k = 0; i < 6; i++) {
     
    22222298    } else {
    22232299        OF_property_new(OF_env, dev, "assigned-addresses", NULL, 0);
    22242300    }
    2225 #if 0
     2301    if (irq_line >= 0) {
     2302        int i;
     2303        OF_prop_int_new(OF_env, dev, "interrupts", 1);
     2304        i = pci_host_interrupt_map_len;
     2305        pci_host_interrupt_map[i++] = (devfn << 8) & 0xf800;
     2306        pci_host_interrupt_map[i++] = 0;
     2307        pci_host_interrupt_map[i++] = 0;
     2308        pci_host_interrupt_map[i++] = 0;
     2309        pci_host_interrupt_map[i++] = 0; /* pic handle will be patched later */
     2310        pci_host_interrupt_map[i++] = irq_line;
     2311        if (arch != ARCH_HEATHROW) {
     2312            pci_host_interrupt_map[i++] = 1;
     2313        }
     2314        pci_host_interrupt_map_len = i;
     2315    }
     2316#if 1
    22262317    {
    22272318        OF_prop_t *prop_name = ((OF_node_t *)dev)->prop_name;
    22282319
     
    23902481    return 0;
    23912482}
    23922483
     2484static void keylargo_ata(OF_node_t *mio, uint32_t base_address,
     2485                         uint32_t base, int irq1, int irq2,
     2486                         uint16_t pic_phandle)
     2487{
     2488    OF_env_t *OF_env = OF_env_main;
     2489    OF_node_t *ata;
     2490    OF_regprop_t regs[2];
     2491
     2492    ata = OF_node_new(OF_env, mio, "ata-4", base);
     2493    if (ata == NULL) {
     2494        ERROR("Cannot create 'ata-4'\n");
     2495        return;
     2496    }
     2497    OF_prop_string_new(OF_env, ata, "device_type", "ata");
     2498#if 1
     2499    OF_prop_string_new(OF_env, ata, "compatible", "key2largo-ata");
     2500    OF_prop_string_new(OF_env, ata, "model", "ata-4");
     2501    OF_prop_string_new(OF_env, ata, "cable-type", "80-conductor");
     2502#else
     2503    OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata");
     2504    OF_prop_string_new(OF_env, ata, "model", "ata-4");
     2505#endif
     2506    OF_prop_int_new(OF_env, ata, "#address-cells", 1);
     2507    OF_prop_int_new(OF_env, ata, "#size-cells", 0);
     2508    regs[0].address = base;
     2509    regs[0].size = 0x00001000;
     2510#if 0 // HACK: Don't set up DMA registers
     2511    regs[1].address = 0x00008A00;
     2512    regs[1].size = 0x00001000;
     2513    OF_property_new(OF_env, ata, "reg",
     2514                    regs, 2 * sizeof(OF_regprop_t));
     2515#else
     2516    OF_property_new(OF_env, ata, "reg",
     2517                    regs, sizeof(OF_regprop_t));
     2518#endif
     2519    OF_prop_int_new(OF_env, ata, "interrupt-parent", pic_phandle);
     2520    regs[0].address = irq1;
     2521    regs[0].size = 0x00000001;
     2522    regs[1].address = irq2;
     2523    regs[1].size = 0x00000000;
     2524    OF_property_new(OF_env, ata, "interrupts",
     2525                    regs, 2 * sizeof(OF_regprop_t));
     2526    if (base == 0x1f000)
     2527        ide_pci_pmac_register(base_address + base, 0x00000000, ata);
     2528    else
     2529        ide_pci_pmac_register(0x00000000, base_address + base, ata);
     2530}
     2531
    23932532void OF_finalize_pci_macio (void *dev, uint32_t base_address, uint32_t size,
    23942533                            void *private_data)
    23952534{
     
    23982537    pci_reg_prop_t pregs[2];
    23992538    OF_node_t *mio, *chs, *als;
    24002539    uint16_t pic_phandle;
     2540    int rec_len;
     2541    OF_prop_t *mio_reg;
    24012542
    24022543    OF_DPRINTF("mac-io: %p\n", dev);
    24032544    OF_env = OF_env_main;
     
    24162557    mio = dev;
    24172558    mio->private_data = private_data;
    24182559    pregs[0].addr.hi = 0x00000000;
    2419     pregs[0].addr.mid = 0x82013810;
     2560    pregs[0].addr.mid = 0x00000000;
    24202561    pregs[0].addr.lo = 0x00000000;
    24212562    pregs[0].size_hi = base_address;
    24222563    pregs[0].size_lo = size;
     2564    mio_reg = OF_property_get(OF_env, mio, "reg");
     2565    if (mio_reg && mio_reg->vlen >= 5 * 4) {
     2566        pregs[0].addr.mid = ((pci_reg_prop_t *)mio_reg->value)->addr.hi;
     2567    }
    24232568    OF_property_new(OF_env, mio, "ranges",
    24242569                    &pregs, sizeof(pci_reg_prop_t));
    24252570#if 0
     
    24312576    OF_property_new(OF_env, mio, "assigned-addresses",
    24322577                    &pregs, sizeof(pci_reg_prop_t));
    24332578#endif
     2579
     2580    if (arch == ARCH_HEATHROW) {
     2581        /* Heathrow PIC */
     2582        OF_regprop_t regs;
     2583        OF_node_t *mpic;
     2584        const char compat_str[] = "heathrow\0mac-risc";
     2585
     2586        mpic = OF_node_new(OF_env, mio, "interrupt-controller", 0x10);
     2587        if (mpic == NULL) {
     2588            ERROR("Cannot create 'mpic'\n");
     2589            goto out;
     2590        }
     2591        OF_prop_string_new(OF_env, mpic, "device_type", "interrupt-controller");
     2592        OF_property_new(OF_env, mpic, "compatible", compat_str, sizeof(compat_str));
     2593        OF_prop_int_new(OF_env, mpic, "#interrupt-cells", 1);
     2594        regs.address = 0x10;
     2595        regs.size = 0x20;
     2596        OF_property_new(OF_env, mpic, "reg",
     2597                        &regs, sizeof(regs));
     2598        OF_property_new(OF_env, mpic, "interrupt-controller", NULL, 0);
     2599        pic_phandle = OF_pack_handle(OF_env, mpic);
     2600        OF_prop_int_new(OF_env, chs, "interrupt-controller", pic_phandle);
     2601        OF_node_put(OF_env, mpic);
     2602        rec_len = 6;
     2603    } else {
    24342604    /* OpenPIC */
    2435     {
    24362605        OF_regprop_t regs[4];
    24372606        OF_node_t *mpic;
    24382607        mpic = OF_node_new(OF_env, mio, "interrupt-controller", 0x40000);
     
    24552624        pic_phandle = OF_pack_handle(OF_env, mpic);
    24562625        OF_prop_int_new(OF_env, chs, "interrupt-controller", pic_phandle);
    24572626        OF_node_put(OF_env, mpic);
     2627        rec_len = 7;
    24582628    }
    2459 #if 1
     2629
     2630    /* patch pci host table */
     2631    /* XXX: do it after the PCI init */
     2632    {
     2633        int i;
     2634        uint32_t tab[4];
     2635
     2636        for(i = 0; i < pci_host_interrupt_map_len; i += rec_len)
     2637            pci_host_interrupt_map[i + 4] = pic_phandle;
     2638#if 0
     2639        dprintf("interrupt-map:\n");
     2640        for(i = 0; i < pci_host_interrupt_map_len; i++) {
     2641            dprintf(" %08x", pci_host_interrupt_map[i]);
     2642            if ((i % rec_len) == (rec_len - 1))
     2643                dprintf("\n");
     2644        }
     2645        dprintf("\n");
     2646#endif
     2647        OF_property_new(OF_env, pci_host_node, "interrupt-map",
     2648                        pci_host_interrupt_map,
     2649                        pci_host_interrupt_map_len * sizeof(uint32_t));
     2650        tab[0] = 0xf800;
     2651        tab[1] = 0;
     2652        tab[2] = 0;
     2653        tab[3] = 0;
     2654        OF_property_new(OF_env, pci_host_node, "interrupt-map-mask",
     2655                        tab, 4 * sizeof(uint32_t));
     2656    }
     2657#if 0
    24602658    /* escc is usefull to get MacOS X debug messages */
    24612659    {
    24622660        OF_regprop_t regs[8];
     
    26452843        OF_node_put(OF_env, scc);
    26462844    }
    26472845#endif
    2648     /* IDE controller */
    2649     {
    2650         OF_node_t *ata;
    2651         OF_regprop_t regs[2];
    2652         ata = OF_node_new(OF_env, mio, "ata-4", 0x1f000);
    2653         if (ata == NULL) {
    2654             ERROR("Cannot create 'ata-4'\n");
    2655             goto out;
    2656         }
    2657         OF_prop_string_new(OF_env, ata, "device_type", "ata");
    2658 #if 1
    2659         OF_prop_string_new(OF_env, ata, "compatible", "keylargo-ata");
    2660         OF_prop_string_new(OF_env, ata, "model", "ata-4");
    2661 #else
    2662         OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata");
    2663         OF_prop_string_new(OF_env, ata, "model", "ata-4");
    2664 #endif
    2665         OF_prop_int_new(OF_env, ata, "#address-cells", 1);
    2666         OF_prop_int_new(OF_env, ata, "#size-cells", 0);
    2667         regs[0].address = 0x0001F000;
    2668         regs[0].size = 0x00001000;
    2669 #if 0 // HACK: Don't set up DMA registers
    2670         regs[1].address = 0x00008A00;
    2671         regs[1].size = 0x00001000;
    2672         OF_property_new(OF_env, ata, "reg",
    2673                         regs, 2 * sizeof(OF_regprop_t));
    2674 #else
    2675         OF_property_new(OF_env, ata, "reg",
    2676                         regs, sizeof(OF_regprop_t));
    2677 #endif
    2678         OF_prop_int_new(OF_env, ata, "interrupt-parent", pic_phandle);
    2679         regs[0].address = 0x00000013;
    2680         regs[0].size = 0x00000001;
    2681         regs[1].address = 0x0000000B;
    2682         regs[1].size = 0x00000000;
    2683         OF_property_new(OF_env, ata, "interrupts",
    2684                         regs, 2 * sizeof(OF_regprop_t));
    2685         ide_pci_pmac_register(base_address + 0x1f000, 0x00000000, ata);
    2686 
    2687     }
    2688     {
    2689         OF_node_t *ata;
    2690         OF_regprop_t regs[2];
    2691         ata = OF_node_new(OF_env, mio, "ata-4", 0x20000);
    2692         if (ata == NULL) {
    2693             ERROR("Cannot create 'ata-4'\n");
    2694             goto out;
    2695         }
    2696         OF_prop_string_new(OF_env, ata, "device_type", "ata");
    2697 #if 1
    2698         OF_prop_string_new(OF_env, ata, "compatible", "keylargo-ata");
    2699         OF_prop_string_new(OF_env, ata, "model", "ata-4");
    2700 #else
    2701         OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata");
    2702         OF_prop_string_new(OF_env, ata, "model", "ata-4");
    2703 #endif
    2704         OF_prop_int_new(OF_env, ata, "#address-cells", 1);
    2705         OF_prop_int_new(OF_env, ata, "#size-cells", 0);
    2706         regs[0].address = 0x00020000;
    2707         regs[0].size = 0x00001000;
    2708 #if 0 // HACK: Don't set up DMA registers
    2709         regs[1].address = 0x00008A00;
    2710         regs[1].size = 0x00001000;
    2711         OF_property_new(OF_env, ata, "reg",
    2712                         regs, 2 * sizeof(OF_regprop_t));
    2713 #else
    2714         OF_property_new(OF_env, ata, "reg",
    2715                         regs, sizeof(OF_regprop_t));
    2716 #endif
    2717         OF_prop_int_new(OF_env, ata, "interrupt-parent", pic_phandle);
    2718         regs[0].address = 0x00000014;
    2719         regs[0].size = 0x00000001;
    2720         regs[1].address = 0x0000000B;
    2721         regs[1].size = 0x00000000;
    2722         OF_property_new(OF_env, ata, "interrupts",
    2723                         regs, 2 * sizeof(OF_regprop_t));
    2724         ide_pci_pmac_register(0x00000000, base_address + 0x20000, ata);
    2725 
     2846    /* Keylargo IDE controller: need some work (DMA problem ?) */
     2847    if (arch == ARCH_MAC99) {
     2848        keylargo_ata(mio, base_address, 0x1f000, 0x13, 0xb, pic_phandle);
     2849        keylargo_ata(mio, base_address, 0x20000, 0x14, 0xb, pic_phandle);
    27262850    }
     2851#if 0
    27272852    /* Timer */
    27282853    {
    27292854        OF_node_t *tmr;
     
    27462871                        regs, sizeof(OF_regprop_t));
    27472872        OF_node_put(OF_env, tmr);
    27482873    }
     2874#endif
    27492875    /* VIA-PMU */
    27502876    {
    27512877        /* Controls adb, RTC and power-mgt (forget it !) */
    2752         OF_node_t *via, *adb, *rtc;
     2878        OF_node_t *via, *adb;
    27532879        OF_regprop_t regs[1];
    27542880#if 0 // THIS IS A HACK AND IS COMPLETELY ABSURD !
    27552881      // (but needed has Qemu doesn't emulate via-pmu).
     
    27732899        regs[0].size = 0x00002000;
    27742900        OF_property_new(OF_env, via, "reg", regs, sizeof(OF_regprop_t));
    27752901        OF_prop_int_new(OF_env, via, "interrupt-parent", pic_phandle);
     2902        if (arch == ARCH_HEATHROW) {
     2903            OF_prop_int_new(OF_env, via, "interrupts", 0x12);
     2904        } else {
    27762905        regs[0].address = 0x00000019;
    27772906        regs[0].size = 0x00000001;
    27782907        OF_property_new(OF_env, via, "interrupts",
    27792908                        regs, sizeof(OF_regprop_t));
     2909        }
     2910        /* force usage of OF bus speeds */
     2911        OF_prop_int_new(OF_env, via, "BusSpeedCorrect", 1);
    27802912#if 0
    27812913        OF_prop_int_new(OF_env, via, "pmu-version", 0x00D0740C);
    27822914#endif
    2783 #if 1
     2915        {
     2916            OF_node_t *kbd, *mouse;
    27842917        /* ADB pseudo-device */
    27852918        adb = OF_node_new(OF_env, via, "adb", OF_ADDRESS_NONE);
    27862919        if (adb == NULL) {
     
    27972930        OF_prop_int_new(OF_env, adb, "#size-cells", 0);
    27982931        OF_pack_get_path(OF_env, tmp, 512, adb);
    27992932        OF_prop_string_new(OF_env, als, "adb", tmp);
    2800         /* XXX: add "keyboard@2" and "mouse@3" */
    2801         OF_node_put(OF_env, adb);
    2802 #endif
     2933
     2934            kbd = OF_node_new(OF_env, adb, "keyboard", 2);
     2935            if (kbd == NULL) {
     2936                ERROR("Cannot create 'kbd'\n");
     2937                goto out;
     2938            }
     2939            OF_prop_string_new(OF_env, kbd, "device_type", "keyboard");
     2940            OF_prop_int_new(OF_env, kbd, "reg", 2);
     2941
     2942            mouse = OF_node_new(OF_env, adb, "mouse", 3);
     2943            if (mouse == NULL) {
     2944                ERROR("Cannot create 'mouse'\n");
     2945                goto out;
     2946            }
     2947            OF_prop_string_new(OF_env, mouse, "device_type", "mouse");
     2948            OF_prop_int_new(OF_env, mouse, "reg", 3);
     2949            OF_prop_int_new(OF_env, mouse, "#buttons", 3);
     2950        }
     2951        {
     2952            OF_node_t *rtc;
    28032953       
    28042954        rtc = OF_node_new(OF_env, via, "rtc", OF_ADDRESS_NONE);
    28052955        if (rtc == NULL) {
     
    28132963        OF_prop_string_new(OF_env, rtc, "compatible", "rtc");
    28142964#endif
    28152965        OF_node_put(OF_env, rtc);
    2816         OF_node_put(OF_env, via);
    28172966    }
     2967        //        OF_node_put(OF_env, via);
     2968    }
     2969    {
     2970        OF_node_t *pmgt;
     2971        pmgt = OF_node_new(OF_env, mio, "power-mgt", OF_ADDRESS_NONE);
     2972        OF_prop_string_new(OF_env, pmgt, "device_type", "power-mgt");
     2973        OF_prop_string_new(OF_env, pmgt, "compatible", "cuda");
     2974        OF_prop_string_new(OF_env, pmgt, "mgt-kind", "min-consumption-pwm-led");
     2975        OF_node_put(OF_env, pmgt);
     2976    }
     2977
     2978    if (arch == ARCH_HEATHROW) {
     2979        /* NVRAM */
     2980        OF_node_t *nvr;
     2981        OF_regprop_t regs;
     2982        nvr = OF_node_new(OF_env, mio, "nvram", 0x60000);
     2983        OF_prop_string_new(OF_env, nvr, "device_type", "nvram");
     2984        regs.address = 0x60000;
     2985        regs.size = 0x00020000;
     2986        OF_property_new(OF_env, nvr, "reg", &regs, sizeof(regs));
     2987        OF_prop_int_new(OF_env, nvr, "#bytes", 0x2000);
     2988        OF_node_put(OF_env, nvr);
     2989    }
     2990
    28182991 out:
    28192992    //    OF_node_put(OF_env, mio);
    28202993    OF_node_put(OF_env, chs);
    28212994    OF_node_put(OF_env, als);
    28222995}
    28232996
     2997void OF_finalize_pci_ide (void *dev,
     2998                          uint32_t io_base0, uint32_t io_base1,
     2999                          uint32_t io_base2, uint32_t io_base3)
     3000{
     3001    OF_env_t *OF_env = OF_env_main;
     3002    OF_node_t *pci_ata = dev;
     3003    OF_node_t *ata, *atas[2];
     3004    int i;
     3005
     3006    OF_prop_int_new(OF_env, pci_ata, "#address-cells", 1);
     3007    OF_prop_int_new(OF_env, pci_ata, "#size-cells", 0);
     3008
     3009    /* XXX: Darwin handles only one device */
     3010    for(i = 0; i < 1; i++) {
     3011        ata = OF_node_new(OF_env, pci_ata, "ata-4", i);
     3012        if (ata == NULL) {
     3013            ERROR("Cannot create 'ata-4'\n");
     3014            return;
     3015        }
     3016        OF_prop_string_new(OF_env, ata, "device_type", "ata");
     3017        OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata");
     3018        OF_prop_string_new(OF_env, ata, "model", "ata-4");
     3019        OF_prop_int_new(OF_env, ata, "#address-cells", 1);
     3020        OF_prop_int_new(OF_env, ata, "#size-cells", 0);
     3021        OF_prop_int_new(OF_env, ata, "reg", i);
     3022        atas[i] = ata;
     3023    }
     3024    ide_pci_pc_register(io_base0, io_base1, io_base2, io_base3,
     3025                        atas[0], atas[1]);
     3026}
     3027
    28243028/*****************************************************************************/
    28253029/* Fake package */
    28263030static void OF_method_fake (OF_env_t *OF_env)
     
    28623066    /* As we get a 1:1 mapping, do nothing */
    28633067    ihandle = popd(OF_env);
    28643068    args = (void *)popd(OF_env);
    2865     address = popd(OF_env);
    2866     virt = popd(OF_env);
    2867     size = popd(OF_env);
    28683069    popd(OF_env);
    2869     OF_DPRINTF("Translate address %0x %0x %0x %0x\n", ihandle, address,
     3070    size = popd(OF_env);
     3071    virt = popd(OF_env);
     3072    address = popd(OF_env);
     3073    OF_DPRINTF("Map %0x %0x %0x %0x\n", ihandle, address,
    28703074               virt, size);
    28713075    pushd(OF_env, 0);
    28723076}
     
    32703474    OF_prop_string_new(OF_env, dsk, "device_type", "block");
    32713475    OF_prop_string_new(OF_env, dsk, "category", type);
    32723476    OF_prop_int_new(OF_env, dsk, "device_id", devnum);
    3273     OF_prop_int_new(OF_env, dsk, "reg", 0);
     3477    OF_prop_int_new(OF_env, dsk, "reg", devnum);
    32743478    OF_method_new(OF_env, dsk, "open", &OF_blockdev_open);
    32753479    OF_method_new(OF_env, dsk, "seek", &OF_blockdev_seek);
    32763480    OF_method_new(OF_env, dsk, "read", &OF_blockdev_read);
     
    34323636}
    34333637
    34343638void OF_vga_register (const unsigned char *name, unused uint32_t address,
    3435                       int width, int height, int depth)
     3639                      int width, int height, int depth,
     3640                      unsigned long vga_bios_addr, unsigned long vga_bios_size)
    34363641{
    34373642    OF_env_t *OF_env;
    34383643    unsigned char tmp[OF_NAMELEN_MAX];
     
    35043709    OF_prop_string_new(OF_env, als, "display", tmp);
    35053710    OF_node_put(OF_env, als);
    35063711    /* XXX: may also need read-rectangle */
     3712
     3713    if (vga_bios_size >= 8) {
     3714        const uint8_t *p;
     3715        int size;
     3716        /* check the QEMU VGA BIOS header */
     3717        p = (const uint8_t *)vga_bios_addr;
     3718        if (p[0] == 'N' && p[1] == 'D' && p[2] == 'R' && p[3] == 'V') {
     3719            size = *(uint32_t *)(p + 4);
     3720            OF_property_new(OF_env, disp, "driver,AAPL,MacOS,PowerPC",
     3721                            p + 8, size);
     3722        }
     3723    }
    35073724 out:
    35083725    OF_node_put(OF_env, disp);
    35093726}
     
    44514668        break;
    44524669    case 0x233441d3: /* MacOS X 10.2 and OpenDarwin 1.41 */
    44534670        /* Create "memory-map" pseudo device */
    4454         popd(OF_env);
     4671        {
     4672            OF_node_t *map;
     4673            uint32_t phandle;
     4674
    44554675        /* Find "/packages" */
    44564676        chs = OF_pack_find_by_name(OF_env, OF_node_root, "/chosen");
    44574677        if (chs == NULL) {
     
    44594679            ERROR("Cannot get '/chosen'\n");
    44604680            break;
    44614681        }
    4462         {
    4463 #if 1
    4464             OF_node_t *map;
    4465             uint32_t phandle;
    44664682            map = OF_node_new(OF_env, chs, "memory-map", OF_ADDRESS_NONE);
    44674683            if (map == NULL) {
    44684684                pushd(OF_env, -1);
     
    44734689            OF_node_put(OF_env, map);
    44744690            OF_node_put(OF_env, chs);
    44754691            pushd(OF_env, phandle);
    4476         }
    4477 #else
    4478         pushd(OF_env, 0);
    4479 #endif
    44804692        pushd(OF_env, 0);
     4693        }
    44814694        break;
    44824695    case 0x32a2d18e: /* MacOS X 10.2 and OpenDarwin 6.02 */
    44834696        /* Return screen ihandle */
     
    45404753    case 0x4ad41f2d:
    45414754        /* Yaboot: wait 10 ms: sure ! */
    45424755        break;
     4756
    45434757    default:
    45444758        /* ERROR */
    4545         printf("Script:\n%s\n", FString);
     4759        printf("Script: len=%d\n%s\n", (int)strlen(FString), FString);
    45464760        printf("Call %0x NOT IMPLEMENTED !\n", crc);
    45474761        bug();
    45484762        break;
     
    45814795{
    45824796    OF_CHECK_NBARGS(OF_env, 0);
    45834797    /* Should free all OF resources */
     4798    bd_reset_all();
    45844799#if defined (DEBUG_BIOS)
    45854800    {
    45864801        uint16_t loglevel = 0x02 | 0x10 | 0x80;
  • OpenHackWare-release-0.4

    diff -wruN --exclude '*~' --exclude '*.o' --exclude '*.bin' --exclude '*.out' --exclude mkdiff OpenHackWare-release-0.4.org/src/pci.c OpenHackWare-release-0.4/src/pci.c
    old new  
    9999    uint16_t min_grant;
    100100    uint16_t max_latency;
    101101    uint8_t  irq_line;
    102     uint32_t regions[6];
    103     uint32_t sizes[6];
     102    uint32_t regions[7]; /* the region 6 is the PCI ROM */
     103    uint32_t sizes[7];
    104104    pci_device_t *next;
    105105};
    106106
     
    158158
    159159/* IRQ numbers assigned to PCI IRQs */
    160160static uint8_t prep_pci_irqs[4] = { 9, 11, 9, 11 };
     161static uint8_t heathrow_pci_irqs[4] = { 0x15, 0x16, 0x17, 0x18 };
    161162static uint8_t pmac_pci_irqs[4] = { 8, 9, 10, 11 };
    162163
    163164/* PREP PCI host */
     
    399400    &uninorth_config_readl, &uninorth_config_writel,
    400401};
    401402
     403/* Grackle PCI host */
     404
     405static uint32_t grackle_cfg_address (pci_bridge_t *bridge,
     406                                     uint8_t bus, uint8_t devfn,
     407                                     uint8_t offset)
     408{
     409    uint32_t addr;
     410    addr = 0x80000000 | (bus << 16) | (devfn << 8) | (offset & 0xfc);
     411    stswap32((uint32_t *)bridge->cfg_addr, addr);
     412    return bridge->cfg_data + (offset & 3);
     413}
     414
     415static uint8_t grackle_config_readb (pci_bridge_t *bridge,
     416                                      uint8_t bus, uint8_t devfn,
     417                                      uint8_t offset)
     418{
     419    uint32_t addr;
     420    addr = grackle_cfg_address(bridge, bus, devfn, offset);
     421    return *((uint8_t *)addr);
     422}
     423
     424static void grackle_config_writeb (pci_bridge_t *bridge,
     425                                    uint8_t bus, uint8_t devfn,
     426                                    uint8_t offset, uint8_t val)
     427{
     428    uint32_t addr;
     429    addr = grackle_cfg_address(bridge, bus, devfn, offset);
     430    *((uint8_t *)addr) = val;
     431}
     432
     433static uint16_t grackle_config_readw (pci_bridge_t *bridge,
     434                                       uint8_t bus, uint8_t devfn,
     435                                       uint8_t offset)
     436{
     437    uint32_t addr;
     438    addr = grackle_cfg_address(bridge, bus, devfn, offset);
     439    return ldswap16((uint16_t *)addr);
     440}
     441
     442static void grackle_config_writew (pci_bridge_t *bridge,
     443                                    uint8_t bus, uint8_t devfn,
     444                                    uint8_t offset, uint16_t val)
     445{
     446    uint32_t addr;
     447    addr = grackle_cfg_address(bridge, bus, devfn, offset);
     448    stswap16((uint16_t *)addr, val);
     449}
     450
     451static uint32_t grackle_config_readl (pci_bridge_t *bridge,
     452                                       uint8_t bus, uint8_t devfn,
     453                                       uint8_t offset)
     454{
     455    uint32_t addr;
     456    addr = grackle_cfg_address(bridge, bus, devfn, offset);
     457    return ldswap32((uint32_t *)addr);
     458}
     459
     460static void grackle_config_writel (pci_bridge_t *bridge,
     461                                    uint8_t bus, uint8_t devfn,
     462                                    uint8_t offset, uint32_t val)
     463{
     464    uint32_t addr;
     465
     466    addr = grackle_cfg_address(bridge, bus, devfn, offset);
     467    stswap32((uint32_t *)addr, val);
     468}
     469
     470static pci_ops_t grackle_pci_ops = {
     471    &grackle_config_readb, &grackle_config_writeb,
     472    &grackle_config_readw, &grackle_config_writew,
     473    &grackle_config_readl, &grackle_config_writel,
     474};
     475
    402476static inline uint8_t pci_config_readb (pci_bridge_t *bridge,
    403477                                        uint8_t bus, uint8_t devfn,
    404478                                        uint8_t offset)
     
    466540    },
    467541};
    468542
     543static int ide_config_cb2 (pci_device_t *device)
     544{
     545    OF_finalize_pci_ide(device->common.OF_private,
     546                        device->regions[0] & ~0x0000000F,
     547                        device->regions[1] & ~0x0000000F,
     548                        device->regions[2] & ~0x0000000F,
     549                        device->regions[3] & ~0x0000000F);
     550    return 0;
     551}
     552
    469553static pci_dev_t ide_devices[] = {
    470554    {
    471         0x8086, 0x0100,
    472         NULL, "Qemu IDE", "Qemu IDE",    "ide",
     555        0x1095, 0x0646, /* CMD646 IDE controller */
     556        "pci-ide", "pci-ata", NULL, NULL,
    473557        0, 0, 0,
    474         NULL, NULL,
     558        ide_config_cb2, NULL,
    475559    },
    476560    {
    477561        0xFFFF, 0xFFFF,
     
    481565    },
    482566};
    483567
    484 static int ide_config_cb (pci_device_t *device)
     568#if 0
     569/* should base it on PCI ID, not on arch */
     570static int ide_config_cb (unused pci_device_t *device)
    485571{
    486572    printf("Register IDE controller\n");
    487573    switch (arch) {
     
    491577                              device->common.OF_private);
    492578        break;
    493579    default:
    494         ide_pci_pc_register(device->regions[0] & ~0x0000000F,
    495                             device->regions[1] & ~0x0000000F,
    496                             device->regions[2] & ~0x0000000F,
    497                             device->regions[3] & ~0x0000000F,
    498                             device->common.OF_private);
    499580        break;
    500581    }
    501 
    502582    return 0;
    503583}
    504584
     
    512592                              device->common.OF_private);
    513593        break;
    514594    default:
    515         ide_pci_pc_register(device->regions[0] & ~0x0000000F,
    516                             device->regions[1] & ~0x0000000F,
    517                             device->regions[2] & ~0x0000000F,
    518                             device->regions[3] & ~0x0000000F,
    519                             device->common.OF_private);
    520595        break;
    521596    }
    522597
    523598    return 0;
    524599}
     600#endif
    525601
    526602static pci_subclass_t mass_subclass[] = {
    527603    {
     
    530606    },
    531607    {
    532608        0x01, "IDE controller",             "ide", ide_devices, NULL,
    533         &ide_config_cb, NULL,
     609        NULL, NULL,
    534610    },
    535611    {
    536612        0x02, "Floppy disk controller",     NULL,  NULL, NULL,
     
    546622    },
    547623    {
    548624        0x05, "ATA controller",             "ata", NULL, NULL,
    549         &ata_config_cb, NULL,
     625        NULL, NULL,
    550626    },
    551627    {
    552628        0x80, "misc mass-storage controller", NULL, NULL, NULL,
     
    646722        /* VGA 640x480x16 */
    647723        OF_vga_register(device->common.device->name,
    648724                        device->regions[0] & ~0x0000000F,
    649                         vga_width, vga_height, vga_depth);
     725                        vga_width, vga_height, vga_depth,
     726                        device->regions[6] & ~0x0000000F,
     727                        device->sizes[6]);
    650728    }
    651729    vga_console_register();
    652730
     
    750828    NULL, &PREP_pci_ops,
    751829};
    752830
     831pci_dev_t grackle_fake_bridge = {
     832    0xFFFF, 0xFFFF,
     833    "pci", "pci-bridge", "DEC,21154", "DEC,21154.pci-bridge",
     834    -1, -1, -1,
     835    NULL, &grackle_pci_ops,
     836};
     837
    753838static pci_dev_t hbrg_devices[] = {
    754839    {
    755840        0x106B, 0x0020, NULL,
     
    758843        NULL, &uninorth_agp_fake_bridge,
    759844    },
    760845    {
    761         0x106B, 0x001F,
    762         NULL, "pci", "AAPL,UniNorth", "uni-north",
     846        0x106B, 0x001F, NULL,
     847        "pci", "AAPL,UniNorth", "uni-north",
    763848        3, 2, 1,
    764849        NULL, &uninorth_fake_bridge,
    765850    },
     
    770855        NULL, &uninorth_fake_bridge,
    771856    },
    772857    {
    773         0x1011, 0x0026, NULL,
    774         "pci-bridge", NULL, NULL,
     858        0x1057, 0x0002, "pci",
     859        "pci", "MOT,MPC106", "grackle",
    775860        3, 2, 1,
    776         NULL, &PREP_pci_ops,
     861        NULL, &grackle_fake_bridge,
    777862    },
    778863    {
    779864        0x1057, 0x4801, NULL,
     
    14431528}
    14441529
    14451530static const pci_dev_t misc_pci[] = {
    1446     /* Apple Mac-io controller */
     1531    /* Paddington Mac I/O */
     1532    {
     1533        0x106B, 0x0017,
     1534        "mac-io", "mac-io", "AAPL,343S1211", "paddington\1heathrow",
     1535        1, 1, 1,
     1536        &macio_config_cb, NULL,
     1537    },
     1538    /* KeyLargo Mac I/O */
    14471539    {
    14481540        0x106B, 0x0022,
    14491541        "mac-io", "mac-io", "AAPL,Keylargo", "Keylargo",
     
    15991691                                      uint8_t min_grant, uint8_t max_latency,
    16001692                                      int irq_line)
    16011693{
    1602     uint32_t cmd;
     1694    uint32_t cmd, addr;
    16031695    int i;
    16041696
    16051697    device->min_grant = min_grant;
     
    16111703        printf("MAP PCI device %d:%d to IRQ %d\n",
    16121704               device->bus, device->devfn, irq_line);
    16131705    }
    1614     for (i = 0; i < 6; i++) {
     1706    for (i = 0; i < 7; i++) {
    16151707        if ((device->regions[i] & ~0xF) != 0x00000000 &&
    16161708            (device->regions[i] & ~0xF) != 0xFFFFFFF0) {
    16171709            printf("Map PCI device %d:%d %d to %0x %0x (%s)\n",
    16181710                   device->bus, device->devfn, i,
    16191711                   device->regions[i], device->sizes[i],
    1620                    device->regions[i] & 0x00000001 ? "I/O" : "memory");
     1712                   (device->regions[i] & 0x00000001) && i != 6 ? "I/O" :
     1713                    "memory");
     1714            if (i != 6) {
    16211715            cmd = pci_config_readl(bridge, device->bus, device->devfn, 0x04);
    16221716            if (device->regions[i] & 0x00000001)
    16231717                cmd |= 0x00000001;
    16241718            else
    16251719                cmd |= 0x00000002;
    16261720            pci_config_writel(bridge, device->bus, device->devfn, 0x04, cmd);
     1721            }
     1722            if (i == 6)
     1723                addr = 0x30; /* PCI ROM */
     1724            else
     1725                addr = 0x10 + (i * sizeof(uint32_t));
    16271726            pci_config_writel(bridge, device->bus, device->devfn,
    1628                               0x10 + (i * sizeof(uint32_t)),
    1629                               device->regions[i]);
     1727                              addr, device->regions[i]);
    16301728        }
    16311729    }
    16321730}
     
    19001998        goto out;
    19011999    }
    19022000    ret = (pci_u_t *)newd;
    1903     max_areas = 6;
     2001    max_areas = 7;
    19042002    /* register PCI device in OF tree */
    19052003    if (bridge->dev.common.type == PCI_FAKE_BRIDGE) {
    19062004        newd->common.OF_private =
     
    19272025            /* Handle 64 bits memory mapping */
    19282026            continue;
    19292027        }
     2028        if (i == 6)
     2029            addr = 0x30; /* PCI ROM */
     2030        else
    19302031        addr = 0x10 + (i * sizeof(uint32_t));
    19312032        /* Get region size
    19322033         * Note: we assume it's always a power of 2
     
    19352036        smask = pci_config_readl(bridge, bus, devfn, addr);
    19362037        if (smask == 0x00000000 || smask == 0xFFFFFFFF)
    19372038            continue;
    1938         if (smask & 0x00000001) {
     2039        if ((smask & 0x00000001) != 0 && i != 6) {
    19392040            /* I/O space */
    19402041            base = io_base;
    19412042            /* Align to a minimum of 256 bytes (arbitrary) */
     
    19472048            /* Align to a minimum of 64 kB (arbitrary) */
    19482049            min_align = 1 << 16;
    19492050            amask = 0x0000000F;
     2051            if (i == 6)
     2052                smask |= 1; /* PCI ROM enable */
    19502053        }
    19512054        omask = smask & amask;
    19522055        smask &= ~amask;
     
    19802083    if (irq_pin > 0) {
    19812084        /* assign the IRQ */
    19822085        irq_pin = ((devfn >> 3) + irq_pin - 1) & 3;
    1983         if (arch == ARCH_PREP) {
     2086        /* XXX: should base it on the PCI bridge type, not the arch */
     2087        switch(arch) {
     2088        case ARCH_PREP:
     2089            {
    19842090            int elcr_port, val;
    19852091            irq_line = prep_pci_irqs[irq_pin];
    19862092            /* set the IRQ to level-sensitive */
     
    19882094            val = inb(elcr_port);
    19892095            val |= 1 << (irq_line & 7);
    19902096            outb(elcr_port, val);
    1991         } else {
     2097            }
     2098            break;
     2099        case ARCH_MAC99:
    19922100            irq_line = pmac_pci_irqs[irq_pin];
     2101            break;
     2102        case ARCH_HEATHROW:
     2103            irq_line = heathrow_pci_irqs[irq_pin];
     2104            break;
     2105        default:
     2106            break;
    19932107        }
    19942108    }
    19952109 update_device:
    19962110    pci_update_device(bridge, newd, min_grant, max_latency, irq_line);
    19972111    OF_finalize_pci_device(newd->common.OF_private, bus, devfn,
    1998                            newd->regions, newd->sizes);
     2112                           newd->regions, newd->sizes, irq_line);
    19992113    /* Call special inits if needed */
    20002114    if (dev->config_cb != NULL)
    20012115        (*dev->config_cb)(newd);
     
    20492163    case ARCH_CHRP:
    20502164        /* TODO */
    20512165        break;
     2166    case ARCH_HEATHROW:
     2167        dev = pci_find_device(0x06, 0x00, 0xFF, checkv, checkp);
     2168        if (dev == NULL)
     2169            return -1;
     2170        fake_host = pci_add_host(hostp, dev,
     2171                                 (0x06 << 24) | (0x00 << 16) | (0xFF << 8));
     2172        if (fake_host == NULL)
     2173            return -1;
     2174        fake_host->dev.common.type = PCI_FAKE_HOST;
     2175        dev = &grackle_fake_bridge;
     2176        if (dev == NULL)
     2177            goto free_fake_host;
     2178        fake_bridge = pci_add_bridge(fake_host, 0, 0, dev,
     2179                                     (0x06 << 24) | (0x04 << 16) | (0xFF << 8),
     2180                                     cfg_base, cfg_len,
     2181                                     cfg_base + 0x7ec00000,
     2182                                     cfg_base + 0x7ee00000,
     2183                                     mem_base, mem_len,
     2184                                     io_base, io_len,
     2185                                     rbase, rlen,
     2186                                     0,
     2187                                     &grackle_pci_ops);
     2188        if (fake_bridge == NULL)
     2189            goto free_fake_host;
     2190        fake_bridge->dev.common.type = PCI_FAKE_BRIDGE;
     2191        break;
    20522192    case ARCH_MAC99:
    20532193        dev = pci_find_device(0x06, 0x00, 0xFF, checkv, checkp);
    20542194        if (dev == NULL)
     
    21672307    case ARCH_CHRP:
    21682308        /* TODO */
    21692309        break;
     2310    case ARCH_HEATHROW:
     2311        cfg_base = 0x80000000;
     2312        cfg_len  = 0x7f000000;
     2313        mem_base = 0x80000000;
     2314        mem_len  = 0x01000000;
     2315        io_base  = 0xfe000000;
     2316        io_len   = 0x00800000;
     2317#if 1
     2318        rbase    = 0xfd000000;
     2319        rlen     = 0x01000000;
     2320#else
     2321        rbase    = 0x00000000;
     2322        rlen     = 0x01000000;
     2323#endif
     2324        if (pci_check_host(&pci_main, cfg_base, cfg_len,
     2325                           mem_base, mem_len, io_base, io_len, rbase, rlen,
     2326                           0x1057, 0x0002) == 0) {
     2327            isa_io_base = io_base;
     2328            busnum++;
     2329        }
     2330        for (curh = pci_main; curh->next != NULL; curh = curh->next)
     2331            continue;
     2332        pci_check_devices(curh);
     2333        break;
    21702334    case ARCH_MAC99:
    21712335        /* We are supposed to have 3 host bridges:
    21722336         * - the uninorth AGP bridge at 0xF0000000
Note: See TracBrowser for help on using the repository browser.