bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1 | 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 |
| 2 | --- OpenHackWare-release-0.4.org/src/bios.h 2005-04-06 23:20:22.000000000 +0200 |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 3 | +++ OpenHackWare-release-0.4/src/bios.h 2005-07-07 01:10:20.000000000 +0200 |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 4 | @@ -64,6 +64,7 @@ |
| 5 | ARCH_CHRP, |
| 6 | ARCH_MAC99, |
| 7 | ARCH_POP, |
| 8 | + ARCH_HEATHROW, |
| 9 | }; |
| 10 | |
| 11 | /* Hardware definition(s) */ |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 12 | @@ -174,6 +175,7 @@ |
| 13 | int bd_ioctl (bloc_device_t *bd, int func, void *args); |
| 14 | uint32_t bd_seclen (bloc_device_t *bd); |
| 15 | void bd_close (bloc_device_t *bd); |
| 16 | +void bd_reset_all(void); |
| 17 | uint32_t bd_seclen (bloc_device_t *bd); |
| 18 | uint32_t bd_maxbloc (bloc_device_t *bd); |
| 19 | void bd_sect2CHS (bloc_device_t *bd, uint32_t secnum, |
| 20 | @@ -183,12 +185,12 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 21 | part_t *bd_probe (int boot_device); |
| 22 | bloc_device_t *bd_get (int device); |
| 23 | void bd_put (bloc_device_t *bd); |
| 24 | -void bd_set_boot_part (bloc_device_t *bd, part_t *partition); |
| 25 | +void bd_set_boot_part (bloc_device_t *bd, part_t *partition, int partnum); |
| 26 | part_t **_bd_parts (bloc_device_t *bd); |
| 27 | |
| 28 | void ide_pci_pc_register (uint32_t io_base0, uint32_t io_base1, |
| 29 | uint32_t io_base2, uint32_t io_base3, |
| 30 | - void *OF_private); |
| 31 | + void *OF_private0, void *OF_private1); |
| 32 | void ide_pci_pmac_register (uint32_t io_base0, uint32_t io_base1, |
| 33 | void *OF_private); |
| 34 | |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 35 | @@ -399,17 +401,23 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 36 | uint16_t min_grant, uint16_t max_latency); |
| 37 | void OF_finalize_pci_host (void *dev, int first_bus, int nb_busses); |
| 38 | void OF_finalize_pci_device (void *dev, uint8_t bus, uint8_t devfn, |
| 39 | - uint32_t *regions, uint32_t *sizes); |
| 40 | + uint32_t *regions, uint32_t *sizes, |
| 41 | + int irq_line); |
| 42 | void OF_finalize_pci_macio (void *dev, uint32_t base_address, uint32_t size, |
| 43 | void *private_data); |
| 44 | +void OF_finalize_pci_ide (void *dev, |
| 45 | + uint32_t io_base0, uint32_t io_base1, |
| 46 | + uint32_t io_base2, uint32_t io_base3); |
| 47 | int OF_register_bus (const unsigned char *name, uint32_t address, |
| 48 | const unsigned char *type); |
| 49 | int OF_register_serial (const unsigned char *bus, const unsigned char *name, |
| 50 | uint32_t io_base, int irq); |
| 51 | int OF_register_stdio (const unsigned char *dev_in, |
| 52 | const unsigned char *dev_out); |
| 53 | -void OF_vga_register (const unsigned char *name, uint32_t address, |
| 54 | - int width, int height, int depth); |
| 55 | +void OF_vga_register (const unsigned char *name, unused uint32_t address, |
| 56 | + int width, int height, int depth, |
| 57 | + unsigned long vga_bios_addr, |
| 58 | + unsigned long vga_bios_size); |
| 59 | void *OF_blockdev_register (void *parent, void *private, |
| 60 | const unsigned char *type, |
| 61 | const unsigned char *name, int devnum, |
| 62 | 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 |
| 63 | --- OpenHackWare-release-0.4.org/src/bloc.c 2005-04-06 23:21:00.000000000 +0200 |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 64 | +++ OpenHackWare-release-0.4/src/bloc.c 2005-07-08 00:28:26.000000000 +0200 |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 65 | @@ -55,6 +55,7 @@ |
| 66 | /* Partitions */ |
| 67 | part_t *parts, *bparts; |
| 68 | part_t *boot_part; |
| 69 | + int bpartnum; |
| 70 | /* Chain */ |
| 71 | bloc_device_t *next; |
| 72 | }; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 73 | @@ -66,6 +67,7 @@ |
| 74 | |
| 75 | static int ide_initialize (bloc_device_t *bd, int device); |
| 76 | static int ide_read_sector (bloc_device_t *bd, void *buffer, int secnum); |
| 77 | +static int ide_reset (bloc_device_t *bd); |
| 78 | |
| 79 | static int mem_initialize (bloc_device_t *bd, int device); |
| 80 | static int mem_read_sector (bloc_device_t *bd, void *buffer, int secnum); |
| 81 | @@ -212,6 +214,17 @@ |
| 82 | { |
| 83 | } |
| 84 | |
| 85 | +void bd_reset_all(void) |
| 86 | +{ |
| 87 | + bloc_device_t *bd; |
| 88 | + for (bd = bd_list; bd != NULL; bd = bd->next) { |
| 89 | + if (bd->init == &ide_initialize) { |
| 90 | + /* reset IDE drive because Darwin wants all IDE devices to be reset */ |
| 91 | + ide_reset(bd); |
| 92 | + } |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | uint32_t bd_seclen (bloc_device_t *bd) |
| 97 | { |
| 98 | return bd->seclen; |
| 99 | @@ -223,10 +236,12 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* XXX: to be suppressed */ |
| 103 | -void bd_set_boot_part (bloc_device_t *bd, part_t *partition) |
| 104 | +void bd_set_boot_part (bloc_device_t *bd, part_t *partition, int partnum) |
| 105 | { |
| 106 | + dprintf("%s: part %p (%p) %d\n", __func__, partition, bd->boot_part, partnum); |
| 107 | if (bd->boot_part == NULL) { |
| 108 | bd->boot_part = partition; |
| 109 | + bd->bpartnum = partnum; |
| 110 | } |
| 111 | } |
| 112 | |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 113 | @@ -240,6 +255,13 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 114 | return &bd->bparts; |
| 115 | } |
| 116 | |
| 117 | +void bd_set_boot_device (bloc_device_t *bd) |
| 118 | +{ |
| 119 | +#if defined (USE_OPENFIRMWARE) |
| 120 | + OF_blockdev_set_boot_device(bd->OF_private, bd->bpartnum, "\\\\ofwboot"); |
| 121 | +#endif |
| 122 | +} |
| 123 | + |
| 124 | part_t *bd_probe (int boot_device) |
| 125 | { |
| 126 | char devices[] = { /*'a', 'b',*/ 'c', 'd', 'e', 'f', 'm', '\0', }; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 127 | @@ -272,9 +294,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 128 | tmp = part_probe(bd, force_raw); |
| 129 | if (boot_device == bd->device) { |
| 130 | boot_part = tmp; |
| 131 | -#if defined (USE_OPENFIRMWARE) |
| 132 | - OF_blockdev_set_boot_device(bd->OF_private, 2, "\\\\ofwboot"); |
| 133 | -#endif |
| 134 | + bd_set_boot_device(bd); |
| 135 | } |
| 136 | } |
| 137 | |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 138 | @@ -717,34 +737,29 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 139 | /* IDE PCI access for pc */ |
| 140 | static uint8_t ide_pci_port_read (bloc_device_t *bd, int port) |
| 141 | { |
| 142 | - eieio(); |
| 143 | - |
| 144 | - return *(uint8_t *)(bd->io_base + port); |
| 145 | + uint8_t value; |
| 146 | + value = inb(bd->io_base + port); |
| 147 | + return value; |
| 148 | } |
| 149 | |
| 150 | static void ide_pci_port_write (bloc_device_t *bd, int port, uint8_t value) |
| 151 | { |
| 152 | - *(uint8_t *)(bd->io_base + port) = value; |
| 153 | - eieio(); |
| 154 | + outb(bd->io_base + port, value); |
| 155 | } |
| 156 | |
| 157 | static uint32_t ide_pci_data_readl (bloc_device_t *bd) |
| 158 | { |
| 159 | - eieio(); |
| 160 | - |
| 161 | - return *((uint32_t *)bd->io_base); |
| 162 | + return inl(bd->io_base); |
| 163 | } |
| 164 | |
| 165 | static void ide_pci_data_writel (bloc_device_t *bd, uint32_t val) |
| 166 | { |
| 167 | - *(uint32_t *)(bd->io_base) = val; |
| 168 | - eieio(); |
| 169 | + outl(bd->io_base, val); |
| 170 | } |
| 171 | |
| 172 | static void ide_pci_control_write (bloc_device_t *bd, uint32_t val) |
| 173 | { |
| 174 | - *((uint8_t *)bd->tmp) = val; |
| 175 | - eieio(); |
| 176 | + outb(bd->tmp + 2, val); |
| 177 | } |
| 178 | |
| 179 | static ide_ops_t ide_pci_pc_ops = { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 180 | @@ -761,7 +776,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 181 | |
| 182 | void ide_pci_pc_register (uint32_t io_base0, uint32_t io_base1, |
| 183 | uint32_t io_base2, uint32_t io_base3, |
| 184 | - unused void *OF_private) |
| 185 | + void *OF_private0, void *OF_private1) |
| 186 | { |
| 187 | if (ide_pci_ops == NULL) { |
| 188 | ide_pci_ops = malloc(sizeof(ide_ops_t)); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 189 | @@ -770,19 +785,19 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 190 | memcpy(ide_pci_ops, &ide_pci_pc_ops, sizeof(ide_ops_t)); |
| 191 | } |
| 192 | if ((io_base0 != 0 || io_base1 != 0) && |
| 193 | - ide_pci_ops->base[0] == 0 && ide_pci_ops->base[1] == 0) { |
| 194 | + ide_pci_ops->base[0] == 0 && ide_pci_ops->base[2] == 0) { |
| 195 | ide_pci_ops->base[0] = io_base0; |
| 196 | - ide_pci_ops->base[1] = io_base1; |
| 197 | + ide_pci_ops->base[2] = io_base1; |
| 198 | #ifdef USE_OPENFIRMWARE |
| 199 | - ide_pci_ops->OF_private[0] = OF_private; |
| 200 | + ide_pci_ops->OF_private[0] = OF_private0; |
| 201 | #endif |
| 202 | } |
| 203 | if ((io_base2 != 0 || io_base3 != 0) && |
| 204 | - ide_pci_ops->base[2] == 0 && ide_pci_ops->base[3] == 0) { |
| 205 | - ide_pci_ops->base[2] = io_base2; |
| 206 | + ide_pci_ops->base[1] == 0 && ide_pci_ops->base[3] == 0) { |
| 207 | + ide_pci_ops->base[1] = io_base2; |
| 208 | ide_pci_ops->base[3] = io_base3; |
| 209 | #ifdef USE_OPENFIRMWARE |
| 210 | - ide_pci_ops->OF_private[1] = OF_private; |
| 211 | + ide_pci_ops->OF_private[1] = OF_private1; |
| 212 | #endif |
| 213 | } |
| 214 | } |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 215 | @@ -935,6 +950,8 @@ |
| 216 | } |
| 217 | |
| 218 | static void atapi_pad_req (void *buffer, int len); |
| 219 | +static void atapi_make_req (bloc_device_t *bd, uint32_t *buffer, |
| 220 | + int maxlen); |
| 221 | static int atapi_read_sector (bloc_device_t *bd, void *buffer, int secnum); |
| 222 | |
| 223 | static int ide_initialize (bloc_device_t *bd, int device) |
| 224 | @@ -1035,9 +1052,7 @@ |
| 225 | DPRINTF("INQUIRY\n"); |
| 226 | len = spc_inquiry_req(&atapi_buffer, 36); |
| 227 | atapi_pad_req(&atapi_buffer, len); |
| 228 | - ide_port_write(bd, 0x07, 0xA0); |
| 229 | - for (i = 0; i < 3; i++) |
| 230 | - ide_data_writel(bd, ldswap32(&atapi_buffer[i])); |
| 231 | + atapi_make_req(bd, atapi_buffer, 36); |
| 232 | status = ide_port_read(bd, 0x07); |
| 233 | if (status != 0x48) { |
| 234 | ERROR("ATAPI INQUIRY : status %0x != 0x48\n", status); |
| 235 | @@ -1053,9 +1068,7 @@ |
| 236 | DPRINTF("READ_CAPACITY\n"); |
| 237 | len = mmc_read_capacity_req(&atapi_buffer); |
| 238 | atapi_pad_req(&atapi_buffer, len); |
| 239 | - ide_port_write(bd, 0x07, 0xA0); |
| 240 | - for (i = 0; i < 3; i++) |
| 241 | - ide_data_writel(bd, ldswap32(&atapi_buffer[i])); |
| 242 | + atapi_make_req(bd, atapi_buffer, 8); |
| 243 | status = ide_port_read(bd, 0x07); |
| 244 | if (status != 0x48) { |
| 245 | ERROR("ATAPI READ_CAPACITY : status %0x != 0x48\n", status); |
| 246 | @@ -1105,6 +1118,22 @@ |
| 247 | memset(p + len, 0, 12 - len); |
| 248 | } |
| 249 | |
| 250 | +static void atapi_make_req (bloc_device_t *bd, uint32_t *buffer, |
| 251 | + int maxlen) |
| 252 | +{ |
| 253 | + int i; |
| 254 | + /* select drive */ |
| 255 | + if (bd->drv == 0) |
| 256 | + ide_port_write(bd, 0x06, 0x40); |
| 257 | + else |
| 258 | + ide_port_write(bd, 0x06, 0x50); |
| 259 | + ide_port_write(bd, 0x04, maxlen & 0xff); |
| 260 | + ide_port_write(bd, 0x05, (maxlen >> 8) & 0xff); |
| 261 | + ide_port_write(bd, 0x07, 0xA0); |
| 262 | + for (i = 0; i < 3; i++) |
| 263 | + ide_data_writel(bd, ldswap32(&buffer[i])); |
| 264 | +} |
| 265 | + |
| 266 | static int atapi_read_sector (bloc_device_t *bd, void *buffer, int secnum) |
| 267 | { |
| 268 | uint32_t atapi_buffer[4]; |
| 269 | @@ -1112,16 +1141,9 @@ |
| 270 | uint32_t status, value; |
| 271 | int i, len; |
| 272 | |
| 273 | - /* select drive */ |
| 274 | - if (bd->drv == 0) |
| 275 | - ide_port_write(bd, 0x06, 0x40); |
| 276 | - else |
| 277 | - ide_port_write(bd, 0x06, 0x50); |
| 278 | len = mmc_read12_req(atapi_buffer, secnum, 1); |
| 279 | atapi_pad_req(&atapi_buffer, len); |
| 280 | - ide_port_write(bd, 0x07, 0xA0); |
| 281 | - for (i = 0; i < 3; i++) |
| 282 | - ide_data_writel(bd, ldswap32(&atapi_buffer[i])); |
| 283 | + atapi_make_req(bd, atapi_buffer, bd->seclen); |
| 284 | status = ide_port_read(bd, 0x07); |
| 285 | if (status != 0x48) { |
| 286 | ERROR("ATAPI READ12 : status %0x != 0x48\n", status); |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 287 | 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 |
| 288 | --- OpenHackWare-release-0.4.org/src/libpart/apple.c 2005-03-31 09:23:33.000000000 +0200 |
| 289 | +++ OpenHackWare-release-0.4/src/libpart/apple.c 2005-07-03 16:17:41.000000000 +0200 |
| 290 | @@ -199,14 +199,18 @@ |
| 291 | if (len == 0) { |
| 292 | /* Place holder. Skip it */ |
| 293 | DPRINTF("%s placeholder part\t%d\n", __func__, i); |
| 294 | + part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; |
| 295 | + part_register(bd, part, name, i); |
| 296 | } else if (strncmp("Apple_Void", type, 32) == 0) { |
| 297 | /* Void partition. Skip it */ |
| 298 | DPRINTF("%s Void part\t%d [%s]\n", __func__, i, type); |
| 299 | + part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; |
| 300 | + part_register(bd, part, name, i); |
| 301 | } else if (strncmp("Apple_Free", type, 32) == 0) { |
| 302 | /* Free space. Skip it */ |
| 303 | DPRINTF("%s Free part (%d)\n", __func__, i); |
| 304 | part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; |
| 305 | - part_register(bd, part, name); |
| 306 | + part_register(bd, part, name, i); |
| 307 | } else if (strncmp("Apple_partition_map", type, 32) == 0 || |
| 308 | strncmp("Apple_Partition_Map", type, 32) == 0 |
| 309 | #if 0 // Is this really used or is it just a mistake ? |
| 310 | @@ -226,7 +230,7 @@ |
| 311 | */ |
| 312 | } |
| 313 | part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; |
| 314 | - part_register(bd, part, name); |
| 315 | + part_register(bd, part, name, i); |
| 316 | } else if (strncmp("Apple_Driver", type, 32) == 0 || |
| 317 | strncmp("Apple_Driver43", type, 32) == 0 || |
| 318 | strncmp("Apple_Driver43_CD", type, 32) == 0 || |
| 319 | @@ -236,8 +240,12 @@ |
| 320 | strncmp("Apple_Driver_IOKit", type, 32) == 0) { |
| 321 | /* Drivers. don't care for now */ |
| 322 | DPRINTF("%s Drivers part\t%d [%s]\n", __func__, i, type); |
| 323 | + part->flags = PART_TYPE_APPLE | PART_FLAG_DRIVER; |
| 324 | + part_register(bd, part, name, i); |
| 325 | } else if (strncmp("Apple_Patches", type, 32) == 0) { |
| 326 | /* Patches: don't care for now */ |
| 327 | + part->flags = PART_TYPE_APPLE | PART_FLAG_PATCH; |
| 328 | + part_register(bd, part, name, i); |
| 329 | DPRINTF("%s Patches part\t%d [%s]\n", __func__, i, type); |
| 330 | } else if (strncmp("Apple_HFS", type, 32) == 0 || |
| 331 | strncmp("Apple_MFS", type, 32) == 0 || |
| 332 | @@ -256,9 +264,8 @@ |
| 333 | count = partmap->bloc_cnt * HFS_BLOCSIZE; |
| 334 | if (partmap->boot_size == 0 || partmap->boot_load == 0) { |
| 335 | printf("Not a bootable partition %d %d (%p %p)\n", |
| 336 | - partmap->boot_size, partmap->boot_load,boot_part, part); |
| 337 | - if (boot_part == NULL) |
| 338 | - boot_part = part; |
| 339 | + partmap->boot_size, partmap->boot_load, |
| 340 | + boot_part, part); |
| 341 | part->flags = PART_TYPE_APPLE | PART_FLAG_FS; |
| 342 | } else { |
| 343 | part->boot_start.bloc = partmap->boot_start; |
| 344 | @@ -278,8 +285,8 @@ |
| 345 | boot_part = part; |
| 346 | part->flags = PART_TYPE_APPLE | PART_FLAG_FS | PART_FLAG_BOOT; |
| 347 | } |
| 348 | - printf("Partition: %d %s st %0x size %0x", |
| 349 | - i, name, partmap->start_bloc, partmap->bloc_cnt); |
| 350 | + printf("Partition: %d '%s' '%s' st %0x size %0x", |
| 351 | + i, name, type, partmap->start_bloc, partmap->bloc_cnt); |
| 352 | #ifndef DEBUG |
| 353 | printf("\n"); |
| 354 | #endif |
| 355 | @@ -290,11 +297,13 @@ |
| 356 | part->boot_load, part->boot_entry); |
| 357 | DPRINTF(" load %0x entry %0x %0x\n", |
| 358 | partmap->boot_load2, partmap->boot_entry2, HFS_BLOCSIZE); |
| 359 | - part_register(bd, part, name); |
| 360 | + part_register(bd, part, name, i); |
| 361 | } else { |
| 362 | memcpy(tmp, type, 32); |
| 363 | tmp[32] = '\0'; |
| 364 | ERROR("Unknown partition type [%s]\n", tmp); |
| 365 | + part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; |
| 366 | + part_register(bd, part, name, i); |
| 367 | } |
| 368 | } |
| 369 | error: |
| 370 | 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 |
| 371 | --- OpenHackWare-release-0.4.org/src/libpart/core.c 2005-03-31 09:23:33.000000000 +0200 |
| 372 | +++ OpenHackWare-release-0.4/src/libpart/core.c 2005-07-03 16:17:41.000000000 +0200 |
| 373 | @@ -126,7 +126,7 @@ |
| 374 | } |
| 375 | |
| 376 | int part_register (bloc_device_t *bd, part_t *partition, |
| 377 | - const unsigned char *name) |
| 378 | + const unsigned char *name, int partnum) |
| 379 | { |
| 380 | part_t **cur; |
| 381 | |
| 382 | @@ -134,6 +134,7 @@ |
| 383 | partition->bd = bd; |
| 384 | partition->next = NULL; |
| 385 | partition->name = strdup(name); |
| 386 | + partition->partnum = partnum; |
| 387 | for (cur = _bd_parts(bd); *cur != NULL; cur = &(*cur)->next) |
| 388 | continue; |
| 389 | *cur = partition; |
| 390 | @@ -141,29 +142,15 @@ |
| 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | -static inline int set_boot_part (bloc_device_t *bd, int partnum) |
| 395 | -{ |
| 396 | - part_t *cur; |
| 397 | - |
| 398 | - cur = part_get(bd, partnum); |
| 399 | - if (cur == NULL) |
| 400 | - return -1; |
| 401 | - bd_set_boot_part(bd, cur); |
| 402 | - |
| 403 | - return 0; |
| 404 | -} |
| 405 | - |
| 406 | part_t *part_get (bloc_device_t *bd, int partnum) |
| 407 | { |
| 408 | part_t **listp, *cur; |
| 409 | - int i; |
| 410 | |
| 411 | listp = _bd_parts(bd); |
| 412 | - cur = *listp; |
| 413 | - for (i = 0; i != partnum; i++) { |
| 414 | - if (cur == NULL) |
| 415 | + |
| 416 | + for (cur = *listp; cur != NULL; cur = cur->next) { |
| 417 | + if (cur->partnum == partnum) |
| 418 | break; |
| 419 | - cur = cur->next; |
| 420 | } |
| 421 | |
| 422 | return cur; |
| 423 | @@ -192,17 +179,20 @@ |
| 424 | part_set_blocsize(bd, part, 512); |
| 425 | part->bd = bd; |
| 426 | part->flags = PART_TYPE_RAW | PART_FLAG_BOOT; |
| 427 | - part_register(bd, part, "Raw"); |
| 428 | + part_register(bd, part, "Raw", 0); |
| 429 | |
| 430 | return part; |
| 431 | } |
| 432 | |
| 433 | +bloc_device_t *part_get_bd (part_t *part) |
| 434 | +{ |
| 435 | + return part->bd; |
| 436 | +} |
| 437 | + |
| 438 | part_t *part_probe (bloc_device_t *bd, int set_raw) |
| 439 | { |
| 440 | - part_t *part0, *boot_part, **cur; |
| 441 | + part_t *part0 = NULL, *boot_part, **cur; |
| 442 | |
| 443 | - /* Register the 0 partition: raw partition containing the whole disk */ |
| 444 | - part0 = part_get_raw(bd); |
| 445 | /* Try to find a valid boot partition */ |
| 446 | boot_part = Apple_probe_partitions(bd); |
| 447 | if (boot_part == NULL) { |
| 448 | @@ -210,10 +200,13 @@ |
| 449 | if (boot_part == NULL && arch == ARCH_PREP) |
| 450 | boot_part = PREP_find_partition(bd); |
| 451 | if (boot_part == NULL && set_raw != 0) { |
| 452 | - boot_part = part0; |
| 453 | - set_boot_part(bd, 0); |
| 454 | + dprintf("Use bloc device as raw partition\n"); |
| 455 | } |
| 456 | } |
| 457 | + if (_bd_parts(bd) == NULL) { |
| 458 | + /* Register the 0 partition: raw partition containing the whole disk */ |
| 459 | + part0 = part_get_raw(bd); |
| 460 | + } |
| 461 | /* Probe filesystem on each found partition */ |
| 462 | for (cur = _bd_parts(bd); *cur != NULL; cur = &(*cur)->next) { |
| 463 | const unsigned char *map, *type; |
| 464 | @@ -248,23 +241,28 @@ |
| 465 | type = "unknown"; |
| 466 | break; |
| 467 | } |
| 468 | - DPRINTF("Probe filesystem on %s %s partition '%s' %s\n", |
| 469 | + dprintf("Probe filesystem on %s %s partition '%s' %s %p\n", |
| 470 | type, map, (*cur)->name, |
| 471 | - ((*cur)->flags) & PART_FLAG_BOOT ? "(bootable)" : ""); |
| 472 | + ((*cur)->flags) & PART_FLAG_BOOT ? "(bootable)" : "", *cur); |
| 473 | if (((*cur)->flags) & PART_FLAG_FS) { |
| 474 | if (((*cur)->flags) & PART_FLAG_BOOT) |
| 475 | (*cur)->fs = fs_probe(*cur, 1); |
| 476 | else |
| 477 | (*cur)->fs = fs_probe(*cur, 0); |
| 478 | + } else if (((*cur)->flags) & PART_TYPE_RAW) { |
| 479 | + (*cur)->fs = fs_probe(*cur, 2); |
| 480 | } else { |
| 481 | (*cur)->fs = fs_probe(*cur, 2); |
| 482 | } |
| 483 | - if (((*cur)->flags) & PART_FLAG_BOOT) { |
| 484 | - bd_set_boot_part(bd, *cur); |
| 485 | fs_get_bootfile((*cur)->fs); |
| 486 | + if (((*cur)->flags) & PART_FLAG_BOOT) { |
| 487 | + dprintf("Partition is bootable (%d)\n", (*cur)->partnum); |
| 488 | + bd_set_boot_part(bd, *cur, (*cur)->partnum); |
| 489 | + if (boot_part == NULL) |
| 490 | + boot_part = *cur; |
| 491 | } |
| 492 | } |
| 493 | - DPRINTF("Boot partition: %p %p %p %p\n", boot_part, boot_part->fs, |
| 494 | + dprintf("Boot partition: %p %p %p %p\n", boot_part, boot_part->fs, |
| 495 | part_fs(boot_part), part0); |
| 496 | |
| 497 | return boot_part; |
| 498 | @@ -279,6 +277,7 @@ |
| 499 | part->boot_size.offset = 0; |
| 500 | part->boot_load = 0; |
| 501 | part->boot_entry = 0; |
| 502 | + part->flags |= PART_FLAG_BOOT; |
| 503 | |
| 504 | return 0; |
| 505 | } |
| 506 | 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 |
| 507 | --- OpenHackWare-release-0.4.org/src/libpart/isofs.c 2005-03-31 09:23:33.000000000 +0200 |
| 508 | +++ OpenHackWare-release-0.4/src/libpart/isofs.c 2005-07-03 16:17:41.000000000 +0200 |
| 509 | @@ -242,7 +242,7 @@ |
| 510 | part->boot_start.bloc, part->boot_size.bloc, |
| 511 | part->boot_load, part->boot_entry); |
| 512 | part->flags = PART_TYPE_ISO9660 | PART_FLAG_BOOT; |
| 513 | - part_register(bd, part, name); |
| 514 | + part_register(bd, part, name, i + 1); |
| 515 | fs_raw_set_bootfile(part, part->boot_start.bloc, |
| 516 | part->boot_start.offset, |
| 517 | part->boot_size.bloc, |
| 518 | 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 |
| 519 | --- OpenHackWare-release-0.4.org/src/libpart/libpart.h 2005-03-31 09:23:33.000000000 +0200 |
| 520 | +++ OpenHackWare-release-0.4/src/libpart/libpart.h 2005-07-03 16:17:41.000000000 +0200 |
| 521 | @@ -30,6 +30,7 @@ |
| 522 | |
| 523 | struct part_t { |
| 524 | bloc_device_t *bd; |
| 525 | + int partnum; |
| 526 | uint32_t start; /* Partition first bloc */ |
| 527 | uint32_t size; /* Partition size, in blocs */ |
| 528 | uint32_t spb; |
| 529 | @@ -54,7 +55,7 @@ |
| 530 | }; |
| 531 | |
| 532 | int part_register (bloc_device_t *bd, part_t *partition, |
| 533 | - const unsigned char *name); |
| 534 | + const unsigned char *name, int partnum); |
| 535 | void part_set_blocsize (bloc_device_t *bd, part_t *part, uint32_t blocsize); |
| 536 | void part_private_set (part_t *part, void *private); |
| 537 | void *part_private_get (part_t *part); |
| 538 | 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 |
| 539 | --- OpenHackWare-release-0.4.org/src/libpart/prep.c 2005-03-31 09:23:33.000000000 +0200 |
| 540 | +++ OpenHackWare-release-0.4/src/libpart/prep.c 2005-07-03 16:17:41.000000000 +0200 |
| 541 | @@ -164,7 +164,7 @@ |
| 542 | part->boot_load = 0; |
| 543 | part->boot_entry = boot_offset - part->bloc_size; |
| 544 | part->flags = PART_TYPE_PREP | PART_FLAG_BOOT; |
| 545 | - part_register(bd, part, "PREP boot"); |
| 546 | + part_register(bd, part, "PREP boot", i); |
| 547 | fs_raw_set_bootfile(part, part->boot_start.bloc, |
| 548 | part->boot_start.offset, |
| 549 | part->boot_size.bloc, |
| 550 | 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 |
| 551 | --- OpenHackWare-release-0.4.org/src/main.c 2005-03-31 09:23:33.000000000 +0200 |
| 552 | +++ OpenHackWare-release-0.4/src/main.c 2005-06-07 23:48:39.000000000 +0200 |
| 553 | @@ -364,20 +364,24 @@ |
| 554 | void *load_base, *load_entry, *last_alloc, *load_end; |
| 555 | uint32_t memsize, boot_image_size, cmdline_size, ramdisk_size; |
| 556 | uint32_t boot_base, boot_nb; |
| 557 | - int boot_device; |
| 558 | + int boot_device, i; |
| 559 | + static const uint32_t isa_base_tab[3] = { |
| 560 | + 0x80000000, /* PREP */ |
| 561 | + 0xFE000000, /* Grackle (Heathrow) */ |
| 562 | + 0xF2000000, /* UniNorth (Mac99) */ |
| 563 | + }; |
| 564 | |
| 565 | /* Retrieve NVRAM configuration */ |
| 566 | - nvram_retry: |
| 567 | + for(i = 0; i < 3; i++) { |
| 568 | + isa_io_base = isa_base_tab[i]; |
| 569 | nvram = NVRAM_get_config(&memsize, &boot_device, |
| 570 | &boot_image, &boot_image_size, |
| 571 | &cmdline, &cmdline_size, |
| 572 | &ramdisk, &ramdisk_size); |
| 573 | - if (nvram == NULL) { |
| 574 | - /* Retry with another isa_io_base */ |
| 575 | - if (isa_io_base == 0x80000000) { |
| 576 | - isa_io_base = 0xF2000000; |
| 577 | - goto nvram_retry; |
| 578 | + if (nvram) |
| 579 | + break; |
| 580 | } |
| 581 | + if (i == 3) { |
| 582 | ERROR("Unable to load configuration from NVRAM. Aborting...\n"); |
| 583 | return -1; |
| 584 | } |
| 585 | @@ -402,7 +406,7 @@ |
| 586 | cpu_name = CPU_get_name(pvr); |
| 587 | OF_register_cpu(cpu_name, 0, pvr, |
| 588 | 200 * 1000 * 1000, 200 * 1000 * 1000, |
| 589 | - 100 * 1000 * 1000, 10 * 1000 * 1000, |
| 590 | + 100 * 1000 * 1000, 100 * 1000 * 1000, |
| 591 | 0x0092); |
| 592 | } |
| 593 | OF_register_memory(memsize, 512 * 1024 /* TOFIX */); |
| 594 | @@ -433,9 +437,12 @@ |
| 595 | vga_puts(copyright); |
| 596 | vga_puts("\n"); |
| 597 | |
| 598 | +#if 0 |
| 599 | /* QEMU is quite incoherent: d is cdrom, not second drive */ |
| 600 | + /* XXX: should probe CD-ROM position */ |
| 601 | if (boot_device == 'd') |
| 602 | boot_device = 'e'; |
| 603 | +#endif |
| 604 | /* Open boot device */ |
| 605 | boot_part = bd_probe(boot_device); |
| 606 | if (boot_device == 'm') { |
| 607 | 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 |
| 608 | --- OpenHackWare-release-0.4.org/src/nvram.c 2005-03-31 09:23:33.000000000 +0200 |
| 609 | +++ OpenHackWare-release-0.4/src/nvram.c 2005-06-04 23:44:03.000000000 +0200 |
| 610 | @@ -334,6 +334,7 @@ |
| 611 | ret = NVRAM_chrp_format(nvram); |
| 612 | break; |
| 613 | case ARCH_MAC99: |
| 614 | + case ARCH_HEATHROW: /* XXX: may be incorrect */ |
| 615 | ret = NVRAM_mac99_format(nvram); |
| 616 | break; |
| 617 | case ARCH_POP: |
| 618 | @@ -409,13 +410,12 @@ |
| 619 | arch = ARCH_MAC99; |
| 620 | } else if (strcmp(sign, "POP") == 0) { |
| 621 | arch = ARCH_POP; |
| 622 | + } else if (strcmp(sign, "HEATHROW") == 0) { |
| 623 | + arch = ARCH_HEATHROW; |
| 624 | } else { |
| 625 | ERROR("Unknown PPC architecture: '%s'\n", sign); |
| 626 | return NULL; |
| 627 | } |
| 628 | - /* HACK */ |
| 629 | - if (arch == ARCH_CHRP) |
| 630 | - arch = ARCH_MAC99; |
| 631 | lword = NVRAM_get_lword(nvram, 0x30); |
| 632 | *RAM_size = lword; |
| 633 | byte = NVRAM_get_byte(nvram, 0x34); |
| 634 | 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 |
| 635 | --- OpenHackWare-release-0.4.org/src/of.c 2005-04-06 23:17:26.000000000 +0200 |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 636 | +++ OpenHackWare-release-0.4/src/of.c 2005-07-07 23:30:08.000000000 +0200 |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 637 | @@ -489,7 +489,7 @@ |
| 638 | ERROR("%s can't alloc new node '%s' name\n", __func__, name); |
| 639 | return NULL; |
| 640 | } |
| 641 | - new->prop_address = OF_prop_int_new(env, new, "address", address); |
| 642 | + new->prop_address = OF_prop_int_new(env, new, "unit-address", address); |
| 643 | if (new->prop_address == NULL) { |
| 644 | free(new->prop_name->value); |
| 645 | free(new->prop_name); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 646 | @@ -1017,6 +1017,33 @@ |
| 647 | string, strlen(string) + 1); |
| 648 | } |
| 649 | |
| 650 | +/* convert '\1' char to '\0' */ |
| 651 | +static OF_prop_t *OF_prop_string_new1 (OF_env_t *env, OF_node_t *node, |
| 652 | + const unsigned char *name, |
| 653 | + const unsigned char *string) |
| 654 | +{ |
| 655 | + int len, i; |
| 656 | + OF_prop_t *ret; |
| 657 | + unsigned char *str; |
| 658 | + |
| 659 | + if (strchr(string, '\1') == NULL) { |
| 660 | + return OF_prop_string_new(env, node, name, string); |
| 661 | + } else { |
| 662 | + len = strlen(string) + 1; |
| 663 | + str = malloc(len); |
| 664 | + if (!str) |
| 665 | + return NULL; |
| 666 | + memcpy(str, string, len); |
| 667 | + for(i = 0; i < len; i++) |
| 668 | + if (str[i] == '\1') |
| 669 | + str[i] = '\0'; |
| 670 | + ret = OF_property_new(env, node, name, |
| 671 | + str, len); |
| 672 | + free(str); |
| 673 | + return ret; |
| 674 | + } |
| 675 | +} |
| 676 | + |
| 677 | __attribute__ (( section (".OpenFirmware") )) |
| 678 | static OF_prop_t *OF_prop_int_new (OF_env_t *env, OF_node_t *node, |
| 679 | const unsigned char *name, uint32_t value) |
| 680 | @@ -1421,15 +1448,12 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 681 | __attribute__ (( section (".OpenFirmware") )) |
| 682 | int OF_init (void) |
| 683 | { |
| 684 | - const unsigned char compat_str[] = |
| 685 | #if 0 |
| 686 | "PowerMac3,1\0MacRISC\0Power Macintosh\0"; |
| 687 | "PowerMac1,2\0MacRISC\0Power Macintosh\0"; |
| 688 | "AAPL,PowerMac G3\0PowerMac G3\0MacRISC\0Power Macintosh\0"; |
| 689 | "AAPL,PowerMac3,0\0MacRISC\0Power Macintosh\0"; |
| 690 | "AAPL,Gossamer\0MacRISC\0Power Macintosh\0"; |
| 691 | -#else |
| 692 | - "AAPL,PowerMac G3\0PowerMac G3\0MacRISC\0Power Macintosh\0"; |
| 693 | #endif |
| 694 | OF_env_t *OF_env; |
| 695 | OF_node_t *als, *opt, *chs, *pks; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 696 | @@ -1455,15 +1479,21 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 697 | return -1; |
| 698 | } |
| 699 | OF_prop_string_new(OF_env, OF_node_root, "device_type", "bootrom"); |
| 700 | -#if 0 |
| 701 | - OF_prop_string_new(OF_env, OF_node_root, |
| 702 | - "model", "PPC Open Hack'Ware " BIOS_VERSION); |
| 703 | -#else |
| 704 | + if (arch == ARCH_HEATHROW) { |
| 705 | + const unsigned char compat_str[] = |
| 706 | + "PowerMac1,1\0MacRISC\0Power Macintosh"; |
| 707 | + OF_property_new(OF_env, OF_node_root, "compatible", |
| 708 | + compat_str, sizeof(compat_str)); |
| 709 | OF_prop_string_new(OF_env, OF_node_root, |
| 710 | - "model", compat_str); |
| 711 | -#endif |
| 712 | + "model", "Power Macintosh"); |
| 713 | + } else { |
| 714 | + const unsigned char compat_str[] = |
| 715 | + "PowerMac3,1\0MacRISC\0Power Macintosh"; |
| 716 | OF_property_new(OF_env, OF_node_root, "compatible", |
| 717 | compat_str, sizeof(compat_str)); |
| 718 | + OF_prop_string_new(OF_env, OF_node_root, |
| 719 | + "model", "PowerMac3,1"); |
| 720 | + } |
| 721 | #if 0 |
| 722 | OF_prop_string_new(OF_env, OF_node_root, "copyright", copyright); |
| 723 | #else |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 724 | @@ -1561,14 +1591,15 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 725 | range.size = 0x00800000; |
| 726 | OF_property_new(OF_env, rom, "ranges", &range, sizeof(OF_range_t)); |
| 727 | OF_prop_int_new(OF_env, rom, "#address-cells", 1); |
| 728 | + |
| 729 | /* "/rom/boot-rom@fff00000" node */ |
| 730 | - brom = OF_node_new(OF_env, OF_node_root, "boot-rom", 0xfff00000); |
| 731 | + brom = OF_node_new(OF_env, rom, "boot-rom", 0xfff00000); |
| 732 | if (brom == NULL) { |
| 733 | ERROR("Cannot create 'boot-rom'\n"); |
| 734 | return -1; |
| 735 | } |
| 736 | regs.address = 0xFFF00000; |
| 737 | - regs.size = 0x00010000; |
| 738 | + regs.size = 0x00100000; |
| 739 | OF_property_new(OF_env, brom, "reg", ®s, sizeof(OF_regprop_t)); |
| 740 | OF_prop_string_new(OF_env, brom, "write-characteristic", "flash"); |
| 741 | OF_prop_string_new(OF_env, brom, "BootROM-build-date", |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 742 | @@ -1577,7 +1608,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 743 | OF_prop_string_new(OF_env, brom, "copyright", copyright); |
| 744 | OF_prop_string_new(OF_env, brom, "model", BIOS_str); |
| 745 | OF_prop_int_new(OF_env, brom, "result", 0); |
| 746 | -#if 0 |
| 747 | +#if 1 |
| 748 | { |
| 749 | /* Hack taken 'as-is' from PearPC */ |
| 750 | unsigned char info[] = { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 751 | @@ -1596,7 +1627,9 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 752 | OF_node_put(OF_env, brom); |
| 753 | OF_node_put(OF_env, rom); |
| 754 | } |
| 755 | +#if 0 |
| 756 | /* From here, hardcoded hacks to get a Mac-like machine */ |
| 757 | + /* XXX: Core99 does not seem to like this NVRAM tree */ |
| 758 | /* "/nvram@fff04000" node */ |
| 759 | { |
| 760 | OF_regprop_t regs; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 761 | @@ -1617,6 +1650,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 762 | OF_prop_int_new(OF_env, chs, "nvram", OF_pack_handle(OF_env, nvr)); |
| 763 | OF_node_put(OF_env, nvr); |
| 764 | } |
| 765 | +#endif |
| 766 | /* "/pseudo-hid" : hid emulation as Apple does */ |
| 767 | { |
| 768 | OF_node_t *hid; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 769 | @@ -1663,7 +1697,27 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 770 | } |
| 771 | OF_node_put(OF_env, hid); |
| 772 | } |
| 773 | + if (arch == ARCH_MAC99) { |
| 774 | + OF_node_t *unin; |
| 775 | + OF_regprop_t regs; |
| 776 | |
| 777 | + unin = OF_node_new(OF_env, OF_node_root, |
| 778 | + "uni-n", 0xf8000000); |
| 779 | + if (unin == NULL) { |
| 780 | + ERROR("Cannot create 'uni-n'\n"); |
| 781 | + return -1; |
| 782 | + } |
| 783 | + OF_prop_string_new(OF_env, unin, "device-type", "memory-controller"); |
| 784 | + OF_prop_string_new(OF_env, unin, "model", "AAPL,UniNorth"); |
| 785 | + OF_prop_string_new(OF_env, unin, "compatible", "uni-north"); |
| 786 | + regs.address = 0xf8000000; |
| 787 | + regs.size = 0x01000000; |
| 788 | + OF_property_new(OF_env, unin, "reg", ®s, sizeof(regs)); |
| 789 | + OF_prop_int_new(OF_env, unin, "#address-cells", 1); |
| 790 | + OF_prop_int_new(OF_env, unin, "#size-cells", 1); |
| 791 | + OF_prop_int_new(OF_env, unin, "device-rev", 3); |
| 792 | + OF_node_put(OF_env, unin); |
| 793 | + } |
| 794 | |
| 795 | #if 1 /* This is mandatory for claim to work |
| 796 | * but I don't know where it should really be (in cpu ?) |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 797 | @@ -1693,7 +1747,9 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 798 | |
| 799 | /* "/options/boot-args" node */ |
| 800 | { |
| 801 | - const unsigned char *args = "-v rootdev cdrom"; |
| 802 | + // const unsigned char *args = "-v rootdev cdrom"; |
| 803 | + //const unsigned char *args = "-v io=0xffffffff"; |
| 804 | + const unsigned char *args = "-v"; |
| 805 | /* Ask MacOS X to print debug messages */ |
| 806 | // OF_prop_string_new(OF_env, chs, "machargs", args); |
| 807 | // OF_prop_string_new(OF_env, opt, "boot-command", args); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 808 | @@ -2013,17 +2069,17 @@ |
| 809 | OF_prop_int_new(OF_env, node, "min-grant", min_grant); |
| 810 | OF_prop_int_new(OF_env, node, "max-latency", max_latency); |
| 811 | if (dev->type != NULL) |
| 812 | - OF_prop_string_new(OF_env, node, "device_type", dev->type); |
| 813 | + OF_prop_string_new1(OF_env, node, "device_type", dev->type); |
| 814 | if (dev->compat != NULL) |
| 815 | - OF_prop_string_new(OF_env, node, "compatible", dev->compat); |
| 816 | + OF_prop_string_new1(OF_env, node, "compatible", dev->compat); |
| 817 | if (dev->model != NULL) |
| 818 | - OF_prop_string_new(OF_env, node, "model", dev->model); |
| 819 | + OF_prop_string_new1(OF_env, node, "model", dev->model); |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 820 | if (dev->acells != 0) |
| 821 | OF_prop_int_new(OF_env, node, "#address-cells", dev->acells); |
| 822 | if (dev->scells != 0) |
| 823 | - OF_prop_int_new(OF_env, node, "#interrupt-cells", dev->acells); |
| 824 | + OF_prop_int_new(OF_env, node, "#size-cells", dev->scells); |
| 825 | if (dev->icells != 0) |
| 826 | - OF_prop_int_new(OF_env, node, "#size-cells", dev->acells); |
| 827 | + OF_prop_int_new(OF_env, node, "#interrupt-cells", dev->icells); |
| 828 | dprintf("Done %p %p\n", parent, node); |
| 829 | |
| 830 | return node; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 831 | @@ -2040,8 +2096,9 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 832 | OF_env_t *OF_env; |
| 833 | pci_range_t ranges[3]; |
| 834 | OF_regprop_t regs[1]; |
| 835 | - OF_node_t *pci_host; |
| 836 | + OF_node_t *pci_host, *als; |
| 837 | int nranges; |
| 838 | + unsigned char buffer[OF_NAMELEN_MAX]; |
| 839 | |
| 840 | OF_env = OF_env_main; |
| 841 | dprintf("register PCI host '%s' '%s' '%s' '%s'\n", |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 842 | @@ -2052,6 +2109,17 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 843 | ERROR("Cannot create pci host\n"); |
| 844 | return NULL; |
| 845 | } |
| 846 | + |
| 847 | + als = OF_node_get(OF_env, "aliases"); |
| 848 | + if (als == NULL) { |
| 849 | + ERROR("Cannot get 'aliases'\n"); |
| 850 | + return NULL; |
| 851 | + } |
| 852 | + sprintf(buffer, "/%s", dev->name); |
| 853 | + OF_prop_string_set(OF_env, als, "pci", buffer); |
| 854 | + OF_node_put(OF_env, als); |
| 855 | + |
| 856 | + |
| 857 | regs[0].address = cfg_base; |
| 858 | regs[0].size = cfg_len; |
| 859 | OF_property_new(OF_env, pci_host, "reg", regs, sizeof(OF_regprop_t)); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 860 | @@ -2136,6 +2204,11 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 861 | return pci_dev; |
| 862 | } |
| 863 | |
| 864 | +/* XXX: suppress that, used for interrupt map init */ |
| 865 | +OF_node_t *pci_host_node; |
| 866 | +uint32_t pci_host_interrupt_map[7 * 32]; |
| 867 | +int pci_host_interrupt_map_len = 0; |
| 868 | + |
| 869 | void OF_finalize_pci_host (void *dev, int first_bus, int nb_busses) |
| 870 | { |
| 871 | OF_env_t *OF_env; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 872 | @@ -2145,10 +2218,12 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 873 | regs[0].address = first_bus; |
| 874 | regs[0].size = nb_busses; |
| 875 | OF_property_new(OF_env, dev, "bus-range", regs, sizeof(OF_regprop_t)); |
| 876 | + pci_host_node = dev; |
| 877 | } |
| 878 | |
| 879 | void OF_finalize_pci_device (void *dev, uint8_t bus, uint8_t devfn, |
| 880 | - uint32_t *regions, uint32_t *sizes) |
| 881 | + uint32_t *regions, uint32_t *sizes, |
| 882 | + int irq_line) |
| 883 | { |
| 884 | OF_env_t *OF_env; |
| 885 | pci_reg_prop_t pregs[6], rregs[6]; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 886 | @@ -2156,6 +2231,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 887 | int i, j, k; |
| 888 | |
| 889 | OF_env = OF_env_main; |
| 890 | + /* XXX: only useful for VGA card in fact */ |
| 891 | if (regions[0] != 0x00000000) |
| 892 | OF_prop_int_set(OF_env, dev, "address", regions[0] & ~0x0000000F); |
| 893 | for (i = 0, j = 0, k = 0; i < 6; i++) { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 894 | @@ -2222,7 +2298,22 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 895 | } else { |
| 896 | OF_property_new(OF_env, dev, "assigned-addresses", NULL, 0); |
| 897 | } |
| 898 | -#if 0 |
| 899 | + if (irq_line >= 0) { |
| 900 | + int i; |
| 901 | + OF_prop_int_new(OF_env, dev, "interrupts", 1); |
| 902 | + i = pci_host_interrupt_map_len; |
| 903 | + pci_host_interrupt_map[i++] = (devfn << 8) & 0xf800; |
| 904 | + pci_host_interrupt_map[i++] = 0; |
| 905 | + pci_host_interrupt_map[i++] = 0; |
| 906 | + pci_host_interrupt_map[i++] = 0; |
| 907 | + pci_host_interrupt_map[i++] = 0; /* pic handle will be patched later */ |
| 908 | + pci_host_interrupt_map[i++] = irq_line; |
| 909 | + if (arch != ARCH_HEATHROW) { |
| 910 | + pci_host_interrupt_map[i++] = 1; |
| 911 | + } |
| 912 | + pci_host_interrupt_map_len = i; |
| 913 | + } |
| 914 | +#if 1 |
| 915 | { |
| 916 | OF_prop_t *prop_name = ((OF_node_t *)dev)->prop_name; |
| 917 | |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 918 | @@ -2390,6 +2481,54 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | +static void keylargo_ata(OF_node_t *mio, uint32_t base_address, |
| 923 | + uint32_t base, int irq1, int irq2, |
| 924 | + uint16_t pic_phandle) |
| 925 | +{ |
| 926 | + OF_env_t *OF_env = OF_env_main; |
| 927 | + OF_node_t *ata; |
| 928 | + OF_regprop_t regs[2]; |
| 929 | + |
| 930 | + ata = OF_node_new(OF_env, mio, "ata-4", base); |
| 931 | + if (ata == NULL) { |
| 932 | + ERROR("Cannot create 'ata-4'\n"); |
| 933 | + return; |
| 934 | + } |
| 935 | + OF_prop_string_new(OF_env, ata, "device_type", "ata"); |
| 936 | +#if 1 |
| 937 | + OF_prop_string_new(OF_env, ata, "compatible", "key2largo-ata"); |
| 938 | + OF_prop_string_new(OF_env, ata, "model", "ata-4"); |
| 939 | + OF_prop_string_new(OF_env, ata, "cable-type", "80-conductor"); |
| 940 | +#else |
| 941 | + OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata"); |
| 942 | + OF_prop_string_new(OF_env, ata, "model", "ata-4"); |
| 943 | +#endif |
| 944 | + OF_prop_int_new(OF_env, ata, "#address-cells", 1); |
| 945 | + OF_prop_int_new(OF_env, ata, "#size-cells", 0); |
| 946 | + regs[0].address = base; |
| 947 | + regs[0].size = 0x00001000; |
| 948 | +#if 0 // HACK: Don't set up DMA registers |
| 949 | + regs[1].address = 0x00008A00; |
| 950 | + regs[1].size = 0x00001000; |
| 951 | + OF_property_new(OF_env, ata, "reg", |
| 952 | + regs, 2 * sizeof(OF_regprop_t)); |
| 953 | +#else |
| 954 | + OF_property_new(OF_env, ata, "reg", |
| 955 | + regs, sizeof(OF_regprop_t)); |
| 956 | +#endif |
| 957 | + OF_prop_int_new(OF_env, ata, "interrupt-parent", pic_phandle); |
| 958 | + regs[0].address = irq1; |
| 959 | + regs[0].size = 0x00000001; |
| 960 | + regs[1].address = irq2; |
| 961 | + regs[1].size = 0x00000000; |
| 962 | + OF_property_new(OF_env, ata, "interrupts", |
| 963 | + regs, 2 * sizeof(OF_regprop_t)); |
| 964 | + if (base == 0x1f000) |
| 965 | + ide_pci_pmac_register(base_address + base, 0x00000000, ata); |
| 966 | + else |
| 967 | + ide_pci_pmac_register(0x00000000, base_address + base, ata); |
| 968 | +} |
| 969 | + |
| 970 | void OF_finalize_pci_macio (void *dev, uint32_t base_address, uint32_t size, |
| 971 | void *private_data) |
| 972 | { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 973 | @@ -2398,6 +2537,8 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 974 | pci_reg_prop_t pregs[2]; |
| 975 | OF_node_t *mio, *chs, *als; |
| 976 | uint16_t pic_phandle; |
| 977 | + int rec_len; |
| 978 | + OF_prop_t *mio_reg; |
| 979 | |
| 980 | OF_DPRINTF("mac-io: %p\n", dev); |
| 981 | OF_env = OF_env_main; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 982 | @@ -2416,10 +2557,14 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 983 | mio = dev; |
| 984 | mio->private_data = private_data; |
| 985 | pregs[0].addr.hi = 0x00000000; |
| 986 | - pregs[0].addr.mid = 0x82013810; |
| 987 | + pregs[0].addr.mid = 0x00000000; |
| 988 | pregs[0].addr.lo = 0x00000000; |
| 989 | pregs[0].size_hi = base_address; |
| 990 | pregs[0].size_lo = size; |
| 991 | + mio_reg = OF_property_get(OF_env, mio, "reg"); |
| 992 | + if (mio_reg && mio_reg->vlen >= 5 * 4) { |
| 993 | + pregs[0].addr.mid = ((pci_reg_prop_t *)mio_reg->value)->addr.hi; |
| 994 | + } |
| 995 | OF_property_new(OF_env, mio, "ranges", |
| 996 | &pregs, sizeof(pci_reg_prop_t)); |
| 997 | #if 0 |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 998 | @@ -2431,8 +2576,32 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 999 | OF_property_new(OF_env, mio, "assigned-addresses", |
| 1000 | &pregs, sizeof(pci_reg_prop_t)); |
| 1001 | #endif |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1002 | + |
| 1003 | + if (arch == ARCH_HEATHROW) { |
| 1004 | + /* Heathrow PIC */ |
| 1005 | + OF_regprop_t regs; |
| 1006 | + OF_node_t *mpic; |
| 1007 | + const char compat_str[] = "heathrow\0mac-risc"; |
| 1008 | + |
| 1009 | + mpic = OF_node_new(OF_env, mio, "interrupt-controller", 0x10); |
| 1010 | + if (mpic == NULL) { |
| 1011 | + ERROR("Cannot create 'mpic'\n"); |
| 1012 | + goto out; |
| 1013 | + } |
| 1014 | + OF_prop_string_new(OF_env, mpic, "device_type", "interrupt-controller"); |
| 1015 | + OF_property_new(OF_env, mpic, "compatible", compat_str, sizeof(compat_str)); |
| 1016 | + OF_prop_int_new(OF_env, mpic, "#interrupt-cells", 1); |
| 1017 | + regs.address = 0x10; |
| 1018 | + regs.size = 0x20; |
| 1019 | + OF_property_new(OF_env, mpic, "reg", |
| 1020 | + ®s, sizeof(regs)); |
| 1021 | + OF_property_new(OF_env, mpic, "interrupt-controller", NULL, 0); |
| 1022 | + pic_phandle = OF_pack_handle(OF_env, mpic); |
| 1023 | + OF_prop_int_new(OF_env, chs, "interrupt-controller", pic_phandle); |
| 1024 | + OF_node_put(OF_env, mpic); |
| 1025 | + rec_len = 6; |
| 1026 | + } else { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1027 | /* OpenPIC */ |
| 1028 | - { |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1029 | OF_regprop_t regs[4]; |
| 1030 | OF_node_t *mpic; |
| 1031 | mpic = OF_node_new(OF_env, mio, "interrupt-controller", 0x40000); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1032 | @@ -2455,8 +2624,37 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1033 | pic_phandle = OF_pack_handle(OF_env, mpic); |
| 1034 | OF_prop_int_new(OF_env, chs, "interrupt-controller", pic_phandle); |
| 1035 | OF_node_put(OF_env, mpic); |
| 1036 | + rec_len = 7; |
| 1037 | } |
| 1038 | -#if 1 |
| 1039 | + |
| 1040 | + /* patch pci host table */ |
| 1041 | + /* XXX: do it after the PCI init */ |
| 1042 | + { |
| 1043 | + int i; |
| 1044 | + uint32_t tab[4]; |
| 1045 | + |
| 1046 | + for(i = 0; i < pci_host_interrupt_map_len; i += rec_len) |
| 1047 | + pci_host_interrupt_map[i + 4] = pic_phandle; |
| 1048 | +#if 0 |
| 1049 | + dprintf("interrupt-map:\n"); |
| 1050 | + for(i = 0; i < pci_host_interrupt_map_len; i++) { |
| 1051 | + dprintf(" %08x", pci_host_interrupt_map[i]); |
| 1052 | + if ((i % rec_len) == (rec_len - 1)) |
| 1053 | + dprintf("\n"); |
| 1054 | + } |
| 1055 | + dprintf("\n"); |
| 1056 | +#endif |
| 1057 | + OF_property_new(OF_env, pci_host_node, "interrupt-map", |
| 1058 | + pci_host_interrupt_map, |
| 1059 | + pci_host_interrupt_map_len * sizeof(uint32_t)); |
| 1060 | + tab[0] = 0xf800; |
| 1061 | + tab[1] = 0; |
| 1062 | + tab[2] = 0; |
| 1063 | + tab[3] = 0; |
| 1064 | + OF_property_new(OF_env, pci_host_node, "interrupt-map-mask", |
| 1065 | + tab, 4 * sizeof(uint32_t)); |
| 1066 | + } |
| 1067 | +#if 0 |
Stefan Weil | e7d8100 | 2011-12-10 00:19:46 +0100 | [diff] [blame] | 1068 | /* escc is useful to get MacOS X debug messages */ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1069 | { |
| 1070 | OF_regprop_t regs[8]; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1071 | @@ -2645,85 +2843,12 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1072 | OF_node_put(OF_env, scc); |
| 1073 | } |
| 1074 | #endif |
| 1075 | - /* IDE controller */ |
| 1076 | - { |
| 1077 | - OF_node_t *ata; |
| 1078 | - OF_regprop_t regs[2]; |
| 1079 | - ata = OF_node_new(OF_env, mio, "ata-4", 0x1f000); |
| 1080 | - if (ata == NULL) { |
| 1081 | - ERROR("Cannot create 'ata-4'\n"); |
| 1082 | - goto out; |
| 1083 | - } |
| 1084 | - OF_prop_string_new(OF_env, ata, "device_type", "ata"); |
| 1085 | -#if 1 |
| 1086 | - OF_prop_string_new(OF_env, ata, "compatible", "keylargo-ata"); |
| 1087 | - OF_prop_string_new(OF_env, ata, "model", "ata-4"); |
| 1088 | -#else |
| 1089 | - OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata"); |
| 1090 | - OF_prop_string_new(OF_env, ata, "model", "ata-4"); |
| 1091 | -#endif |
| 1092 | - OF_prop_int_new(OF_env, ata, "#address-cells", 1); |
| 1093 | - OF_prop_int_new(OF_env, ata, "#size-cells", 0); |
| 1094 | - regs[0].address = 0x0001F000; |
| 1095 | - regs[0].size = 0x00001000; |
| 1096 | -#if 0 // HACK: Don't set up DMA registers |
| 1097 | - regs[1].address = 0x00008A00; |
| 1098 | - regs[1].size = 0x00001000; |
| 1099 | - OF_property_new(OF_env, ata, "reg", |
| 1100 | - regs, 2 * sizeof(OF_regprop_t)); |
| 1101 | -#else |
| 1102 | - OF_property_new(OF_env, ata, "reg", |
| 1103 | - regs, sizeof(OF_regprop_t)); |
| 1104 | -#endif |
| 1105 | - OF_prop_int_new(OF_env, ata, "interrupt-parent", pic_phandle); |
| 1106 | - regs[0].address = 0x00000013; |
| 1107 | - regs[0].size = 0x00000001; |
| 1108 | - regs[1].address = 0x0000000B; |
| 1109 | - regs[1].size = 0x00000000; |
| 1110 | - OF_property_new(OF_env, ata, "interrupts", |
| 1111 | - regs, 2 * sizeof(OF_regprop_t)); |
| 1112 | - ide_pci_pmac_register(base_address + 0x1f000, 0x00000000, ata); |
| 1113 | - |
| 1114 | - } |
| 1115 | - { |
| 1116 | - OF_node_t *ata; |
| 1117 | - OF_regprop_t regs[2]; |
| 1118 | - ata = OF_node_new(OF_env, mio, "ata-4", 0x20000); |
| 1119 | - if (ata == NULL) { |
| 1120 | - ERROR("Cannot create 'ata-4'\n"); |
| 1121 | - goto out; |
| 1122 | - } |
| 1123 | - OF_prop_string_new(OF_env, ata, "device_type", "ata"); |
| 1124 | -#if 1 |
| 1125 | - OF_prop_string_new(OF_env, ata, "compatible", "keylargo-ata"); |
| 1126 | - OF_prop_string_new(OF_env, ata, "model", "ata-4"); |
| 1127 | -#else |
| 1128 | - OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata"); |
| 1129 | - OF_prop_string_new(OF_env, ata, "model", "ata-4"); |
| 1130 | -#endif |
| 1131 | - OF_prop_int_new(OF_env, ata, "#address-cells", 1); |
| 1132 | - OF_prop_int_new(OF_env, ata, "#size-cells", 0); |
| 1133 | - regs[0].address = 0x00020000; |
| 1134 | - regs[0].size = 0x00001000; |
| 1135 | -#if 0 // HACK: Don't set up DMA registers |
| 1136 | - regs[1].address = 0x00008A00; |
| 1137 | - regs[1].size = 0x00001000; |
| 1138 | - OF_property_new(OF_env, ata, "reg", |
| 1139 | - regs, 2 * sizeof(OF_regprop_t)); |
| 1140 | -#else |
| 1141 | - OF_property_new(OF_env, ata, "reg", |
| 1142 | - regs, sizeof(OF_regprop_t)); |
| 1143 | -#endif |
| 1144 | - OF_prop_int_new(OF_env, ata, "interrupt-parent", pic_phandle); |
| 1145 | - regs[0].address = 0x00000014; |
| 1146 | - regs[0].size = 0x00000001; |
| 1147 | - regs[1].address = 0x0000000B; |
| 1148 | - regs[1].size = 0x00000000; |
| 1149 | - OF_property_new(OF_env, ata, "interrupts", |
| 1150 | - regs, 2 * sizeof(OF_regprop_t)); |
| 1151 | - ide_pci_pmac_register(0x00000000, base_address + 0x20000, ata); |
| 1152 | - |
| 1153 | + /* Keylargo IDE controller: need some work (DMA problem ?) */ |
| 1154 | + if (arch == ARCH_MAC99) { |
| 1155 | + keylargo_ata(mio, base_address, 0x1f000, 0x13, 0xb, pic_phandle); |
| 1156 | + keylargo_ata(mio, base_address, 0x20000, 0x14, 0xb, pic_phandle); |
| 1157 | } |
| 1158 | +#if 0 |
| 1159 | /* Timer */ |
| 1160 | { |
| 1161 | OF_node_t *tmr; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1162 | @@ -2746,10 +2871,11 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1163 | regs, sizeof(OF_regprop_t)); |
| 1164 | OF_node_put(OF_env, tmr); |
| 1165 | } |
| 1166 | +#endif |
| 1167 | /* VIA-PMU */ |
| 1168 | { |
| 1169 | /* Controls adb, RTC and power-mgt (forget it !) */ |
| 1170 | - OF_node_t *via, *adb, *rtc; |
| 1171 | + OF_node_t *via, *adb; |
| 1172 | OF_regprop_t regs[1]; |
| 1173 | #if 0 // THIS IS A HACK AND IS COMPLETELY ABSURD ! |
| 1174 | // (but needed has Qemu doesn't emulate via-pmu). |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1175 | @@ -2773,14 +2899,21 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1176 | regs[0].size = 0x00002000; |
| 1177 | OF_property_new(OF_env, via, "reg", regs, sizeof(OF_regprop_t)); |
| 1178 | OF_prop_int_new(OF_env, via, "interrupt-parent", pic_phandle); |
| 1179 | + if (arch == ARCH_HEATHROW) { |
| 1180 | + OF_prop_int_new(OF_env, via, "interrupts", 0x12); |
| 1181 | + } else { |
| 1182 | regs[0].address = 0x00000019; |
| 1183 | regs[0].size = 0x00000001; |
| 1184 | OF_property_new(OF_env, via, "interrupts", |
| 1185 | regs, sizeof(OF_regprop_t)); |
| 1186 | + } |
| 1187 | + /* force usage of OF bus speeds */ |
| 1188 | + OF_prop_int_new(OF_env, via, "BusSpeedCorrect", 1); |
| 1189 | #if 0 |
| 1190 | OF_prop_int_new(OF_env, via, "pmu-version", 0x00D0740C); |
| 1191 | #endif |
| 1192 | -#if 1 |
| 1193 | + { |
| 1194 | + OF_node_t *kbd, *mouse; |
| 1195 | /* ADB pseudo-device */ |
| 1196 | adb = OF_node_new(OF_env, via, "adb", OF_ADDRESS_NONE); |
| 1197 | if (adb == NULL) { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1198 | @@ -2797,9 +2930,26 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1199 | OF_prop_int_new(OF_env, adb, "#size-cells", 0); |
| 1200 | OF_pack_get_path(OF_env, tmp, 512, adb); |
| 1201 | OF_prop_string_new(OF_env, als, "adb", tmp); |
| 1202 | - /* XXX: add "keyboard@2" and "mouse@3" */ |
| 1203 | - OF_node_put(OF_env, adb); |
| 1204 | -#endif |
| 1205 | + |
| 1206 | + kbd = OF_node_new(OF_env, adb, "keyboard", 2); |
| 1207 | + if (kbd == NULL) { |
| 1208 | + ERROR("Cannot create 'kbd'\n"); |
| 1209 | + goto out; |
| 1210 | + } |
| 1211 | + OF_prop_string_new(OF_env, kbd, "device_type", "keyboard"); |
| 1212 | + OF_prop_int_new(OF_env, kbd, "reg", 2); |
| 1213 | + |
| 1214 | + mouse = OF_node_new(OF_env, adb, "mouse", 3); |
| 1215 | + if (mouse == NULL) { |
| 1216 | + ERROR("Cannot create 'mouse'\n"); |
| 1217 | + goto out; |
| 1218 | + } |
| 1219 | + OF_prop_string_new(OF_env, mouse, "device_type", "mouse"); |
| 1220 | + OF_prop_int_new(OF_env, mouse, "reg", 3); |
| 1221 | + OF_prop_int_new(OF_env, mouse, "#buttons", 3); |
| 1222 | + } |
| 1223 | + { |
| 1224 | + OF_node_t *rtc; |
| 1225 | |
| 1226 | rtc = OF_node_new(OF_env, via, "rtc", OF_ADDRESS_NONE); |
| 1227 | if (rtc == NULL) { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1228 | @@ -2813,14 +2963,68 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1229 | OF_prop_string_new(OF_env, rtc, "compatible", "rtc"); |
| 1230 | #endif |
| 1231 | OF_node_put(OF_env, rtc); |
| 1232 | - OF_node_put(OF_env, via); |
| 1233 | } |
| 1234 | + // OF_node_put(OF_env, via); |
| 1235 | + } |
| 1236 | + { |
| 1237 | + OF_node_t *pmgt; |
| 1238 | + pmgt = OF_node_new(OF_env, mio, "power-mgt", OF_ADDRESS_NONE); |
| 1239 | + OF_prop_string_new(OF_env, pmgt, "device_type", "power-mgt"); |
| 1240 | + OF_prop_string_new(OF_env, pmgt, "compatible", "cuda"); |
| 1241 | + OF_prop_string_new(OF_env, pmgt, "mgt-kind", "min-consumption-pwm-led"); |
| 1242 | + OF_node_put(OF_env, pmgt); |
| 1243 | + } |
| 1244 | + |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1245 | + if (arch == ARCH_HEATHROW) { |
| 1246 | + /* NVRAM */ |
| 1247 | + OF_node_t *nvr; |
| 1248 | + OF_regprop_t regs; |
| 1249 | + nvr = OF_node_new(OF_env, mio, "nvram", 0x60000); |
| 1250 | + OF_prop_string_new(OF_env, nvr, "device_type", "nvram"); |
| 1251 | + regs.address = 0x60000; |
| 1252 | + regs.size = 0x00020000; |
| 1253 | + OF_property_new(OF_env, nvr, "reg", ®s, sizeof(regs)); |
| 1254 | + OF_prop_int_new(OF_env, nvr, "#bytes", 0x2000); |
| 1255 | + OF_node_put(OF_env, nvr); |
| 1256 | + } |
| 1257 | + |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1258 | out: |
| 1259 | // OF_node_put(OF_env, mio); |
| 1260 | OF_node_put(OF_env, chs); |
| 1261 | OF_node_put(OF_env, als); |
| 1262 | } |
| 1263 | |
| 1264 | +void OF_finalize_pci_ide (void *dev, |
| 1265 | + uint32_t io_base0, uint32_t io_base1, |
| 1266 | + uint32_t io_base2, uint32_t io_base3) |
| 1267 | +{ |
| 1268 | + OF_env_t *OF_env = OF_env_main; |
| 1269 | + OF_node_t *pci_ata = dev; |
| 1270 | + OF_node_t *ata, *atas[2]; |
| 1271 | + int i; |
| 1272 | + |
| 1273 | + OF_prop_int_new(OF_env, pci_ata, "#address-cells", 1); |
| 1274 | + OF_prop_int_new(OF_env, pci_ata, "#size-cells", 0); |
| 1275 | + |
| 1276 | + /* XXX: Darwin handles only one device */ |
| 1277 | + for(i = 0; i < 1; i++) { |
| 1278 | + ata = OF_node_new(OF_env, pci_ata, "ata-4", i); |
| 1279 | + if (ata == NULL) { |
| 1280 | + ERROR("Cannot create 'ata-4'\n"); |
| 1281 | + return; |
| 1282 | + } |
| 1283 | + OF_prop_string_new(OF_env, ata, "device_type", "ata"); |
| 1284 | + OF_prop_string_new(OF_env, ata, "compatible", "cmd646-ata"); |
| 1285 | + OF_prop_string_new(OF_env, ata, "model", "ata-4"); |
| 1286 | + OF_prop_int_new(OF_env, ata, "#address-cells", 1); |
| 1287 | + OF_prop_int_new(OF_env, ata, "#size-cells", 0); |
| 1288 | + OF_prop_int_new(OF_env, ata, "reg", i); |
| 1289 | + atas[i] = ata; |
| 1290 | + } |
| 1291 | + ide_pci_pc_register(io_base0, io_base1, io_base2, io_base3, |
| 1292 | + atas[0], atas[1]); |
| 1293 | +} |
| 1294 | + |
| 1295 | /*****************************************************************************/ |
| 1296 | /* Fake package */ |
| 1297 | static void OF_method_fake (OF_env_t *OF_env) |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1298 | @@ -2862,11 +3066,11 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1299 | /* As we get a 1:1 mapping, do nothing */ |
| 1300 | ihandle = popd(OF_env); |
| 1301 | args = (void *)popd(OF_env); |
| 1302 | - address = popd(OF_env); |
| 1303 | - virt = popd(OF_env); |
| 1304 | - size = popd(OF_env); |
| 1305 | popd(OF_env); |
| 1306 | - OF_DPRINTF("Translate address %0x %0x %0x %0x\n", ihandle, address, |
| 1307 | + size = popd(OF_env); |
| 1308 | + virt = popd(OF_env); |
| 1309 | + address = popd(OF_env); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1310 | + OF_DPRINTF("Map %0x %0x %0x %0x\n", ihandle, address, |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1311 | virt, size); |
| 1312 | pushd(OF_env, 0); |
| 1313 | } |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1314 | @@ -3270,7 +3474,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1315 | OF_prop_string_new(OF_env, dsk, "device_type", "block"); |
| 1316 | OF_prop_string_new(OF_env, dsk, "category", type); |
| 1317 | OF_prop_int_new(OF_env, dsk, "device_id", devnum); |
| 1318 | - OF_prop_int_new(OF_env, dsk, "reg", 0); |
| 1319 | + OF_prop_int_new(OF_env, dsk, "reg", devnum); |
| 1320 | OF_method_new(OF_env, dsk, "open", &OF_blockdev_open); |
| 1321 | OF_method_new(OF_env, dsk, "seek", &OF_blockdev_seek); |
| 1322 | OF_method_new(OF_env, dsk, "read", &OF_blockdev_read); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1323 | @@ -3432,7 +3636,8 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1324 | } |
| 1325 | |
| 1326 | void OF_vga_register (const unsigned char *name, unused uint32_t address, |
| 1327 | - int width, int height, int depth) |
| 1328 | + int width, int height, int depth, |
| 1329 | + unsigned long vga_bios_addr, unsigned long vga_bios_size) |
| 1330 | { |
| 1331 | OF_env_t *OF_env; |
| 1332 | unsigned char tmp[OF_NAMELEN_MAX]; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1333 | @@ -3504,6 +3709,18 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1334 | OF_prop_string_new(OF_env, als, "display", tmp); |
| 1335 | OF_node_put(OF_env, als); |
| 1336 | /* XXX: may also need read-rectangle */ |
| 1337 | + |
| 1338 | + if (vga_bios_size >= 8) { |
| 1339 | + const uint8_t *p; |
| 1340 | + int size; |
| 1341 | + /* check the QEMU VGA BIOS header */ |
| 1342 | + p = (const uint8_t *)vga_bios_addr; |
| 1343 | + if (p[0] == 'N' && p[1] == 'D' && p[2] == 'R' && p[3] == 'V') { |
| 1344 | + size = *(uint32_t *)(p + 4); |
| 1345 | + OF_property_new(OF_env, disp, "driver,AAPL,MacOS,PowerPC", |
| 1346 | + p + 8, size); |
| 1347 | + } |
| 1348 | + } |
| 1349 | out: |
| 1350 | OF_node_put(OF_env, disp); |
| 1351 | } |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1352 | @@ -4451,7 +4668,10 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1353 | break; |
| 1354 | case 0x233441d3: /* MacOS X 10.2 and OpenDarwin 1.41 */ |
| 1355 | /* Create "memory-map" pseudo device */ |
| 1356 | - popd(OF_env); |
| 1357 | + { |
| 1358 | + OF_node_t *map; |
| 1359 | + uint32_t phandle; |
| 1360 | + |
| 1361 | /* Find "/packages" */ |
| 1362 | chs = OF_pack_find_by_name(OF_env, OF_node_root, "/chosen"); |
| 1363 | if (chs == NULL) { |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1364 | @@ -4459,10 +4679,6 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1365 | ERROR("Cannot get '/chosen'\n"); |
| 1366 | break; |
| 1367 | } |
| 1368 | - { |
| 1369 | -#if 1 |
| 1370 | - OF_node_t *map; |
| 1371 | - uint32_t phandle; |
| 1372 | map = OF_node_new(OF_env, chs, "memory-map", OF_ADDRESS_NONE); |
| 1373 | if (map == NULL) { |
| 1374 | pushd(OF_env, -1); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1375 | @@ -4473,11 +4689,8 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1376 | OF_node_put(OF_env, map); |
| 1377 | OF_node_put(OF_env, chs); |
| 1378 | pushd(OF_env, phandle); |
| 1379 | - } |
| 1380 | -#else |
| 1381 | - pushd(OF_env, 0); |
| 1382 | -#endif |
| 1383 | pushd(OF_env, 0); |
| 1384 | + } |
| 1385 | break; |
| 1386 | case 0x32a2d18e: /* MacOS X 10.2 and OpenDarwin 6.02 */ |
| 1387 | /* Return screen ihandle */ |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1388 | @@ -4540,9 +4753,10 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1389 | case 0x4ad41f2d: |
| 1390 | /* Yaboot: wait 10 ms: sure ! */ |
| 1391 | break; |
| 1392 | + |
| 1393 | default: |
| 1394 | /* ERROR */ |
| 1395 | - printf("Script:\n%s\n", FString); |
| 1396 | + printf("Script: len=%d\n%s\n", (int)strlen(FString), FString); |
| 1397 | printf("Call %0x NOT IMPLEMENTED !\n", crc); |
| 1398 | bug(); |
| 1399 | break; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1400 | @@ -4581,6 +4795,7 @@ |
| 1401 | { |
| 1402 | OF_CHECK_NBARGS(OF_env, 0); |
| 1403 | /* Should free all OF resources */ |
| 1404 | + bd_reset_all(); |
| 1405 | #if defined (DEBUG_BIOS) |
| 1406 | { |
| 1407 | uint16_t loglevel = 0x02 | 0x10 | 0x80; |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1408 | 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 |
| 1409 | --- OpenHackWare-release-0.4.org/src/pci.c 2005-03-31 09:23:33.000000000 +0200 |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1410 | +++ OpenHackWare-release-0.4/src/pci.c 2005-07-07 23:27:37.000000000 +0200 |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1411 | @@ -99,8 +99,8 @@ |
| 1412 | uint16_t min_grant; |
| 1413 | uint16_t max_latency; |
| 1414 | uint8_t irq_line; |
| 1415 | - uint32_t regions[6]; |
| 1416 | - uint32_t sizes[6]; |
| 1417 | + uint32_t regions[7]; /* the region 6 is the PCI ROM */ |
| 1418 | + uint32_t sizes[7]; |
| 1419 | pci_device_t *next; |
| 1420 | }; |
| 1421 | |
| 1422 | @@ -158,6 +158,7 @@ |
| 1423 | |
| 1424 | /* IRQ numbers assigned to PCI IRQs */ |
| 1425 | static uint8_t prep_pci_irqs[4] = { 9, 11, 9, 11 }; |
| 1426 | +static uint8_t heathrow_pci_irqs[4] = { 0x15, 0x16, 0x17, 0x18 }; |
| 1427 | static uint8_t pmac_pci_irqs[4] = { 8, 9, 10, 11 }; |
| 1428 | |
| 1429 | /* PREP PCI host */ |
| 1430 | @@ -399,6 +400,79 @@ |
| 1431 | &uninorth_config_readl, &uninorth_config_writel, |
| 1432 | }; |
| 1433 | |
| 1434 | +/* Grackle PCI host */ |
| 1435 | + |
| 1436 | +static uint32_t grackle_cfg_address (pci_bridge_t *bridge, |
| 1437 | + uint8_t bus, uint8_t devfn, |
| 1438 | + uint8_t offset) |
| 1439 | +{ |
| 1440 | + uint32_t addr; |
| 1441 | + addr = 0x80000000 | (bus << 16) | (devfn << 8) | (offset & 0xfc); |
| 1442 | + stswap32((uint32_t *)bridge->cfg_addr, addr); |
| 1443 | + return bridge->cfg_data + (offset & 3); |
| 1444 | +} |
| 1445 | + |
| 1446 | +static uint8_t grackle_config_readb (pci_bridge_t *bridge, |
| 1447 | + uint8_t bus, uint8_t devfn, |
| 1448 | + uint8_t offset) |
| 1449 | +{ |
| 1450 | + uint32_t addr; |
| 1451 | + addr = grackle_cfg_address(bridge, bus, devfn, offset); |
| 1452 | + return *((uint8_t *)addr); |
| 1453 | +} |
| 1454 | + |
| 1455 | +static void grackle_config_writeb (pci_bridge_t *bridge, |
| 1456 | + uint8_t bus, uint8_t devfn, |
| 1457 | + uint8_t offset, uint8_t val) |
| 1458 | +{ |
| 1459 | + uint32_t addr; |
| 1460 | + addr = grackle_cfg_address(bridge, bus, devfn, offset); |
| 1461 | + *((uint8_t *)addr) = val; |
| 1462 | +} |
| 1463 | + |
| 1464 | +static uint16_t grackle_config_readw (pci_bridge_t *bridge, |
| 1465 | + uint8_t bus, uint8_t devfn, |
| 1466 | + uint8_t offset) |
| 1467 | +{ |
| 1468 | + uint32_t addr; |
| 1469 | + addr = grackle_cfg_address(bridge, bus, devfn, offset); |
| 1470 | + return ldswap16((uint16_t *)addr); |
| 1471 | +} |
| 1472 | + |
| 1473 | +static void grackle_config_writew (pci_bridge_t *bridge, |
| 1474 | + uint8_t bus, uint8_t devfn, |
| 1475 | + uint8_t offset, uint16_t val) |
| 1476 | +{ |
| 1477 | + uint32_t addr; |
| 1478 | + addr = grackle_cfg_address(bridge, bus, devfn, offset); |
| 1479 | + stswap16((uint16_t *)addr, val); |
| 1480 | +} |
| 1481 | + |
| 1482 | +static uint32_t grackle_config_readl (pci_bridge_t *bridge, |
| 1483 | + uint8_t bus, uint8_t devfn, |
| 1484 | + uint8_t offset) |
| 1485 | +{ |
| 1486 | + uint32_t addr; |
| 1487 | + addr = grackle_cfg_address(bridge, bus, devfn, offset); |
| 1488 | + return ldswap32((uint32_t *)addr); |
| 1489 | +} |
| 1490 | + |
| 1491 | +static void grackle_config_writel (pci_bridge_t *bridge, |
| 1492 | + uint8_t bus, uint8_t devfn, |
| 1493 | + uint8_t offset, uint32_t val) |
| 1494 | +{ |
| 1495 | + uint32_t addr; |
| 1496 | + |
| 1497 | + addr = grackle_cfg_address(bridge, bus, devfn, offset); |
| 1498 | + stswap32((uint32_t *)addr, val); |
| 1499 | +} |
| 1500 | + |
| 1501 | +static pci_ops_t grackle_pci_ops = { |
| 1502 | + &grackle_config_readb, &grackle_config_writeb, |
| 1503 | + &grackle_config_readw, &grackle_config_writew, |
| 1504 | + &grackle_config_readl, &grackle_config_writel, |
| 1505 | +}; |
| 1506 | + |
| 1507 | static inline uint8_t pci_config_readb (pci_bridge_t *bridge, |
| 1508 | uint8_t bus, uint8_t devfn, |
| 1509 | uint8_t offset) |
| 1510 | @@ -466,12 +540,22 @@ |
| 1511 | }, |
| 1512 | }; |
| 1513 | |
| 1514 | +static int ide_config_cb2 (pci_device_t *device) |
| 1515 | +{ |
| 1516 | + OF_finalize_pci_ide(device->common.OF_private, |
| 1517 | + device->regions[0] & ~0x0000000F, |
| 1518 | + device->regions[1] & ~0x0000000F, |
| 1519 | + device->regions[2] & ~0x0000000F, |
| 1520 | + device->regions[3] & ~0x0000000F); |
| 1521 | + return 0; |
| 1522 | +} |
| 1523 | + |
| 1524 | static pci_dev_t ide_devices[] = { |
| 1525 | { |
| 1526 | - 0x8086, 0x0100, |
| 1527 | - NULL, "Qemu IDE", "Qemu IDE", "ide", |
| 1528 | + 0x1095, 0x0646, /* CMD646 IDE controller */ |
| 1529 | + "pci-ide", "pci-ata", NULL, NULL, |
| 1530 | 0, 0, 0, |
| 1531 | - NULL, NULL, |
| 1532 | + ide_config_cb2, NULL, |
| 1533 | }, |
| 1534 | { |
| 1535 | 0xFFFF, 0xFFFF, |
| 1536 | @@ -481,7 +565,9 @@ |
| 1537 | }, |
| 1538 | }; |
| 1539 | |
| 1540 | -static int ide_config_cb (pci_device_t *device) |
| 1541 | +#if 0 |
| 1542 | +/* should base it on PCI ID, not on arch */ |
| 1543 | +static int ide_config_cb (unused pci_device_t *device) |
| 1544 | { |
| 1545 | printf("Register IDE controller\n"); |
| 1546 | switch (arch) { |
| 1547 | @@ -491,14 +577,8 @@ |
| 1548 | device->common.OF_private); |
| 1549 | break; |
| 1550 | default: |
| 1551 | - ide_pci_pc_register(device->regions[0] & ~0x0000000F, |
| 1552 | - device->regions[1] & ~0x0000000F, |
| 1553 | - device->regions[2] & ~0x0000000F, |
| 1554 | - device->regions[3] & ~0x0000000F, |
| 1555 | - device->common.OF_private); |
| 1556 | break; |
| 1557 | } |
| 1558 | - |
| 1559 | return 0; |
| 1560 | } |
| 1561 | |
| 1562 | @@ -512,16 +592,12 @@ |
| 1563 | device->common.OF_private); |
| 1564 | break; |
| 1565 | default: |
| 1566 | - ide_pci_pc_register(device->regions[0] & ~0x0000000F, |
| 1567 | - device->regions[1] & ~0x0000000F, |
| 1568 | - device->regions[2] & ~0x0000000F, |
| 1569 | - device->regions[3] & ~0x0000000F, |
| 1570 | - device->common.OF_private); |
| 1571 | break; |
| 1572 | } |
| 1573 | |
| 1574 | return 0; |
| 1575 | } |
| 1576 | +#endif |
| 1577 | |
| 1578 | static pci_subclass_t mass_subclass[] = { |
| 1579 | { |
| 1580 | @@ -530,7 +606,7 @@ |
| 1581 | }, |
| 1582 | { |
| 1583 | 0x01, "IDE controller", "ide", ide_devices, NULL, |
| 1584 | - &ide_config_cb, NULL, |
| 1585 | + NULL, NULL, |
| 1586 | }, |
| 1587 | { |
| 1588 | 0x02, "Floppy disk controller", NULL, NULL, NULL, |
| 1589 | @@ -546,7 +622,7 @@ |
| 1590 | }, |
| 1591 | { |
| 1592 | 0x05, "ATA controller", "ata", NULL, NULL, |
| 1593 | - &ata_config_cb, NULL, |
| 1594 | + NULL, NULL, |
| 1595 | }, |
| 1596 | { |
| 1597 | 0x80, "misc mass-storage controller", NULL, NULL, NULL, |
| 1598 | @@ -646,7 +722,9 @@ |
| 1599 | /* VGA 640x480x16 */ |
| 1600 | OF_vga_register(device->common.device->name, |
| 1601 | device->regions[0] & ~0x0000000F, |
| 1602 | - vga_width, vga_height, vga_depth); |
| 1603 | + vga_width, vga_height, vga_depth, |
| 1604 | + device->regions[6] & ~0x0000000F, |
| 1605 | + device->sizes[6]); |
| 1606 | } |
| 1607 | vga_console_register(); |
| 1608 | |
| 1609 | @@ -750,6 +828,13 @@ |
| 1610 | NULL, &PREP_pci_ops, |
| 1611 | }; |
| 1612 | |
| 1613 | +pci_dev_t grackle_fake_bridge = { |
| 1614 | + 0xFFFF, 0xFFFF, |
| 1615 | + "pci", "pci-bridge", "DEC,21154", "DEC,21154.pci-bridge", |
| 1616 | + -1, -1, -1, |
| 1617 | + NULL, &grackle_pci_ops, |
| 1618 | +}; |
| 1619 | + |
| 1620 | static pci_dev_t hbrg_devices[] = { |
| 1621 | { |
| 1622 | 0x106B, 0x0020, NULL, |
| 1623 | @@ -758,8 +843,8 @@ |
| 1624 | NULL, &uninorth_agp_fake_bridge, |
| 1625 | }, |
| 1626 | { |
| 1627 | - 0x106B, 0x001F, |
| 1628 | - NULL, "pci", "AAPL,UniNorth", "uni-north", |
| 1629 | + 0x106B, 0x001F, NULL, |
| 1630 | + "pci", "AAPL,UniNorth", "uni-north", |
| 1631 | 3, 2, 1, |
| 1632 | NULL, &uninorth_fake_bridge, |
| 1633 | }, |
| 1634 | @@ -770,10 +855,10 @@ |
| 1635 | NULL, &uninorth_fake_bridge, |
| 1636 | }, |
| 1637 | { |
| 1638 | - 0x1011, 0x0026, NULL, |
| 1639 | - "pci-bridge", NULL, NULL, |
| 1640 | + 0x1057, 0x0002, "pci", |
| 1641 | + "pci", "MOT,MPC106", "grackle", |
| 1642 | 3, 2, 1, |
| 1643 | - NULL, &PREP_pci_ops, |
| 1644 | + NULL, &grackle_fake_bridge, |
| 1645 | }, |
| 1646 | { |
| 1647 | 0x1057, 0x4801, NULL, |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1648 | @@ -1443,7 +1528,14 @@ |
| 1649 | } |
| 1650 | |
| 1651 | static const pci_dev_t misc_pci[] = { |
| 1652 | - /* Apple Mac-io controller */ |
| 1653 | + /* Paddington Mac I/O */ |
| 1654 | + { |
| 1655 | + 0x106B, 0x0017, |
| 1656 | + "mac-io", "mac-io", "AAPL,343S1211", "paddington\1heathrow", |
| 1657 | + 1, 1, 1, |
| 1658 | + &macio_config_cb, NULL, |
| 1659 | + }, |
| 1660 | + /* KeyLargo Mac I/O */ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1661 | { |
| 1662 | 0x106B, 0x0022, |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1663 | "mac-io", "mac-io", "AAPL,Keylargo", "Keylargo", |
| 1664 | @@ -1599,7 +1691,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1665 | uint8_t min_grant, uint8_t max_latency, |
| 1666 | int irq_line) |
| 1667 | { |
| 1668 | - uint32_t cmd; |
| 1669 | + uint32_t cmd, addr; |
| 1670 | int i; |
| 1671 | |
| 1672 | device->min_grant = min_grant; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1673 | @@ -1611,22 +1703,28 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1674 | printf("MAP PCI device %d:%d to IRQ %d\n", |
| 1675 | device->bus, device->devfn, irq_line); |
| 1676 | } |
| 1677 | - for (i = 0; i < 6; i++) { |
| 1678 | + for (i = 0; i < 7; i++) { |
| 1679 | if ((device->regions[i] & ~0xF) != 0x00000000 && |
| 1680 | (device->regions[i] & ~0xF) != 0xFFFFFFF0) { |
| 1681 | printf("Map PCI device %d:%d %d to %0x %0x (%s)\n", |
| 1682 | device->bus, device->devfn, i, |
| 1683 | device->regions[i], device->sizes[i], |
| 1684 | - device->regions[i] & 0x00000001 ? "I/O" : "memory"); |
| 1685 | + (device->regions[i] & 0x00000001) && i != 6 ? "I/O" : |
| 1686 | + "memory"); |
| 1687 | + if (i != 6) { |
| 1688 | cmd = pci_config_readl(bridge, device->bus, device->devfn, 0x04); |
| 1689 | if (device->regions[i] & 0x00000001) |
| 1690 | cmd |= 0x00000001; |
| 1691 | else |
| 1692 | cmd |= 0x00000002; |
| 1693 | pci_config_writel(bridge, device->bus, device->devfn, 0x04, cmd); |
| 1694 | + } |
| 1695 | + if (i == 6) |
| 1696 | + addr = 0x30; /* PCI ROM */ |
| 1697 | + else |
| 1698 | + addr = 0x10 + (i * sizeof(uint32_t)); |
| 1699 | pci_config_writel(bridge, device->bus, device->devfn, |
| 1700 | - 0x10 + (i * sizeof(uint32_t)), |
| 1701 | - device->regions[i]); |
| 1702 | + addr, device->regions[i]); |
| 1703 | } |
| 1704 | } |
| 1705 | } |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1706 | @@ -1900,7 +1998,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1707 | goto out; |
| 1708 | } |
| 1709 | ret = (pci_u_t *)newd; |
| 1710 | - max_areas = 6; |
| 1711 | + max_areas = 7; |
| 1712 | /* register PCI device in OF tree */ |
| 1713 | if (bridge->dev.common.type == PCI_FAKE_BRIDGE) { |
| 1714 | newd->common.OF_private = |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1715 | @@ -1927,6 +2025,9 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1716 | /* Handle 64 bits memory mapping */ |
| 1717 | continue; |
| 1718 | } |
| 1719 | + if (i == 6) |
| 1720 | + addr = 0x30; /* PCI ROM */ |
| 1721 | + else |
| 1722 | addr = 0x10 + (i * sizeof(uint32_t)); |
| 1723 | /* Get region size |
| 1724 | * Note: we assume it's always a power of 2 |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1725 | @@ -1935,7 +2036,7 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1726 | smask = pci_config_readl(bridge, bus, devfn, addr); |
| 1727 | if (smask == 0x00000000 || smask == 0xFFFFFFFF) |
| 1728 | continue; |
| 1729 | - if (smask & 0x00000001) { |
| 1730 | + if ((smask & 0x00000001) != 0 && i != 6) { |
| 1731 | /* I/O space */ |
| 1732 | base = io_base; |
| 1733 | /* Align to a minimum of 256 bytes (arbitrary) */ |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1734 | @@ -1947,6 +2048,8 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1735 | /* Align to a minimum of 64 kB (arbitrary) */ |
| 1736 | min_align = 1 << 16; |
| 1737 | amask = 0x0000000F; |
| 1738 | + if (i == 6) |
| 1739 | + smask |= 1; /* PCI ROM enable */ |
| 1740 | } |
| 1741 | omask = smask & amask; |
| 1742 | smask &= ~amask; |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1743 | @@ -1980,7 +2083,10 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1744 | if (irq_pin > 0) { |
| 1745 | /* assign the IRQ */ |
| 1746 | irq_pin = ((devfn >> 3) + irq_pin - 1) & 3; |
| 1747 | - if (arch == ARCH_PREP) { |
| 1748 | + /* XXX: should base it on the PCI bridge type, not the arch */ |
| 1749 | + switch(arch) { |
| 1750 | + case ARCH_PREP: |
| 1751 | + { |
| 1752 | int elcr_port, val; |
| 1753 | irq_line = prep_pci_irqs[irq_pin]; |
| 1754 | /* set the IRQ to level-sensitive */ |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1755 | @@ -1988,14 +2094,22 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1756 | val = inb(elcr_port); |
| 1757 | val |= 1 << (irq_line & 7); |
| 1758 | outb(elcr_port, val); |
| 1759 | - } else { |
| 1760 | + } |
| 1761 | + break; |
| 1762 | + case ARCH_MAC99: |
| 1763 | irq_line = pmac_pci_irqs[irq_pin]; |
| 1764 | + break; |
| 1765 | + case ARCH_HEATHROW: |
| 1766 | + irq_line = heathrow_pci_irqs[irq_pin]; |
| 1767 | + break; |
| 1768 | + default: |
| 1769 | + break; |
| 1770 | } |
| 1771 | } |
| 1772 | update_device: |
| 1773 | pci_update_device(bridge, newd, min_grant, max_latency, irq_line); |
| 1774 | OF_finalize_pci_device(newd->common.OF_private, bus, devfn, |
| 1775 | - newd->regions, newd->sizes); |
| 1776 | + newd->regions, newd->sizes, irq_line); |
| 1777 | /* Call special inits if needed */ |
| 1778 | if (dev->config_cb != NULL) |
| 1779 | (*dev->config_cb)(newd); |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1780 | @@ -2049,6 +2163,32 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1781 | case ARCH_CHRP: |
| 1782 | /* TODO */ |
| 1783 | break; |
| 1784 | + case ARCH_HEATHROW: |
| 1785 | + dev = pci_find_device(0x06, 0x00, 0xFF, checkv, checkp); |
| 1786 | + if (dev == NULL) |
| 1787 | + return -1; |
| 1788 | + fake_host = pci_add_host(hostp, dev, |
| 1789 | + (0x06 << 24) | (0x00 << 16) | (0xFF << 8)); |
| 1790 | + if (fake_host == NULL) |
| 1791 | + return -1; |
| 1792 | + fake_host->dev.common.type = PCI_FAKE_HOST; |
| 1793 | + dev = &grackle_fake_bridge; |
| 1794 | + if (dev == NULL) |
| 1795 | + goto free_fake_host; |
| 1796 | + fake_bridge = pci_add_bridge(fake_host, 0, 0, dev, |
| 1797 | + (0x06 << 24) | (0x04 << 16) | (0xFF << 8), |
| 1798 | + cfg_base, cfg_len, |
| 1799 | + cfg_base + 0x7ec00000, |
| 1800 | + cfg_base + 0x7ee00000, |
| 1801 | + mem_base, mem_len, |
| 1802 | + io_base, io_len, |
| 1803 | + rbase, rlen, |
| 1804 | + 0, |
| 1805 | + &grackle_pci_ops); |
| 1806 | + if (fake_bridge == NULL) |
| 1807 | + goto free_fake_host; |
| 1808 | + fake_bridge->dev.common.type = PCI_FAKE_BRIDGE; |
| 1809 | + break; |
| 1810 | case ARCH_MAC99: |
| 1811 | dev = pci_find_device(0x06, 0x00, 0xFF, checkv, checkp); |
| 1812 | if (dev == NULL) |
bellard | 9835236 | 2005-07-07 22:38:00 +0000 | [diff] [blame] | 1813 | @@ -2167,6 +2307,30 @@ |
bellard | 97067eb | 2005-07-03 16:25:26 +0000 | [diff] [blame] | 1814 | case ARCH_CHRP: |
| 1815 | /* TODO */ |
| 1816 | break; |
| 1817 | + case ARCH_HEATHROW: |
| 1818 | + cfg_base = 0x80000000; |
| 1819 | + cfg_len = 0x7f000000; |
| 1820 | + mem_base = 0x80000000; |
| 1821 | + mem_len = 0x01000000; |
| 1822 | + io_base = 0xfe000000; |
| 1823 | + io_len = 0x00800000; |
| 1824 | +#if 1 |
| 1825 | + rbase = 0xfd000000; |
| 1826 | + rlen = 0x01000000; |
| 1827 | +#else |
| 1828 | + rbase = 0x00000000; |
| 1829 | + rlen = 0x01000000; |
| 1830 | +#endif |
| 1831 | + if (pci_check_host(&pci_main, cfg_base, cfg_len, |
| 1832 | + mem_base, mem_len, io_base, io_len, rbase, rlen, |
| 1833 | + 0x1057, 0x0002) == 0) { |
| 1834 | + isa_io_base = io_base; |
| 1835 | + busnum++; |
| 1836 | + } |
| 1837 | + for (curh = pci_main; curh->next != NULL; curh = curh->next) |
| 1838 | + continue; |
| 1839 | + pci_check_devices(curh); |
| 1840 | + break; |
| 1841 | case ARCH_MAC99: |
| 1842 | /* We are supposed to have 3 host bridges: |
| 1843 | * - the uninorth AGP bridge at 0xF0000000 |