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 | |
---|---|
|
|
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 64 64 ARCH_CHRP, 65 65 ARCH_MAC99, 66 66 ARCH_POP, 67 ARCH_HEATHROW, 67 68 }; 68 69 69 70 /* Hardware definition(s) */ … … 174 175 int bd_ioctl (bloc_device_t *bd, int func, void *args); 175 176 uint32_t bd_seclen (bloc_device_t *bd); 176 177 void bd_close (bloc_device_t *bd); 178 void bd_reset_all(void); 177 179 uint32_t bd_seclen (bloc_device_t *bd); 178 180 uint32_t bd_maxbloc (bloc_device_t *bd); 179 181 void bd_sect2CHS (bloc_device_t *bd, uint32_t secnum, … … 183 185 part_t *bd_probe (int boot_device); 184 186 bloc_device_t *bd_get (int device); 185 187 void bd_put (bloc_device_t *bd); 186 void bd_set_boot_part (bloc_device_t *bd, part_t *partition );188 void bd_set_boot_part (bloc_device_t *bd, part_t *partition, int partnum); 187 189 part_t **_bd_parts (bloc_device_t *bd); 188 190 189 191 void ide_pci_pc_register (uint32_t io_base0, uint32_t io_base1, 190 192 uint32_t io_base2, uint32_t io_base3, 191 void *OF_private );193 void *OF_private0, void *OF_private1); 192 194 void ide_pci_pmac_register (uint32_t io_base0, uint32_t io_base1, 193 195 void *OF_private); 194 196 … … 399 401 uint16_t min_grant, uint16_t max_latency); 400 402 void OF_finalize_pci_host (void *dev, int first_bus, int nb_busses); 401 403 void 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); 403 406 void OF_finalize_pci_macio (void *dev, uint32_t base_address, uint32_t size, 404 407 void *private_data); 408 void OF_finalize_pci_ide (void *dev, 409 uint32_t io_base0, uint32_t io_base1, 410 uint32_t io_base2, uint32_t io_base3); 405 411 int OF_register_bus (const unsigned char *name, uint32_t address, 406 412 const unsigned char *type); 407 413 int OF_register_serial (const unsigned char *bus, const unsigned char *name, 408 414 uint32_t io_base, int irq); 409 415 int OF_register_stdio (const unsigned char *dev_in, 410 416 const unsigned char *dev_out); 411 void OF_vga_register (const unsigned char *name, uint32_t address, 412 int width, int height, int depth); 417 void 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); 413 421 void *OF_blockdev_register (void *parent, void *private, 414 422 const unsigned char *type, 415 423 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 55 55 /* Partitions */ 56 56 part_t *parts, *bparts; 57 57 part_t *boot_part; 58 int bpartnum; 58 59 /* Chain */ 59 60 bloc_device_t *next; 60 61 }; … … 66 67 67 68 static int ide_initialize (bloc_device_t *bd, int device); 68 69 static int ide_read_sector (bloc_device_t *bd, void *buffer, int secnum); 70 static int ide_reset (bloc_device_t *bd); 69 71 70 72 static int mem_initialize (bloc_device_t *bd, int device); 71 73 static int mem_read_sector (bloc_device_t *bd, void *buffer, int secnum); … … 212 214 { 213 215 } 214 216 217 void 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 215 228 uint32_t bd_seclen (bloc_device_t *bd) 216 229 { 217 230 return bd->seclen; … … 223 236 } 224 237 225 238 /* XXX: to be suppressed */ 226 void bd_set_boot_part (bloc_device_t *bd, part_t *partition )239 void bd_set_boot_part (bloc_device_t *bd, part_t *partition, int partnum) 227 240 { 241 dprintf("%s: part %p (%p) %d\n", __func__, partition, bd->boot_part, partnum); 228 242 if (bd->boot_part == NULL) { 229 243 bd->boot_part = partition; 244 bd->bpartnum = partnum; 230 245 } 231 246 } 232 247 … … 240 255 return &bd->bparts; 241 256 } 242 257 258 void 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 243 265 part_t *bd_probe (int boot_device) 244 266 { 245 267 char devices[] = { /*'a', 'b',*/ 'c', 'd', 'e', 'f', 'm', '\0', }; … … 272 294 tmp = part_probe(bd, force_raw); 273 295 if (boot_device == bd->device) { 274 296 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); 278 298 } 279 299 } 280 300 … … 717 737 /* IDE PCI access for pc */ 718 738 static uint8_t ide_pci_port_read (bloc_device_t *bd, int port) 719 739 { 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; 723 743 } 724 744 725 745 static void ide_pci_port_write (bloc_device_t *bd, int port, uint8_t value) 726 746 { 727 *(uint8_t *)(bd->io_base + port) = value; 728 eieio(); 747 outb(bd->io_base + port, value); 729 748 } 730 749 731 750 static uint32_t ide_pci_data_readl (bloc_device_t *bd) 732 751 { 733 eieio(); 734 735 return *((uint32_t *)bd->io_base); 752 return inl(bd->io_base); 736 753 } 737 754 738 755 static void ide_pci_data_writel (bloc_device_t *bd, uint32_t val) 739 756 { 740 *(uint32_t *)(bd->io_base) = val; 741 eieio(); 757 outl(bd->io_base, val); 742 758 } 743 759 744 760 static void ide_pci_control_write (bloc_device_t *bd, uint32_t val) 745 761 { 746 *((uint8_t *)bd->tmp) = val; 747 eieio(); 762 outb(bd->tmp + 2, val); 748 763 } 749 764 750 765 static ide_ops_t ide_pci_pc_ops = { … … 761 776 762 777 void ide_pci_pc_register (uint32_t io_base0, uint32_t io_base1, 763 778 uint32_t io_base2, uint32_t io_base3, 764 unused void *OF_private)779 void *OF_private0, void *OF_private1) 765 780 { 766 781 if (ide_pci_ops == NULL) { 767 782 ide_pci_ops = malloc(sizeof(ide_ops_t)); … … 770 785 memcpy(ide_pci_ops, &ide_pci_pc_ops, sizeof(ide_ops_t)); 771 786 } 772 787 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) { 774 789 ide_pci_ops->base[0] = io_base0; 775 ide_pci_ops->base[ 1] = io_base1;790 ide_pci_ops->base[2] = io_base1; 776 791 #ifdef USE_OPENFIRMWARE 777 ide_pci_ops->OF_private[0] = OF_private ;792 ide_pci_ops->OF_private[0] = OF_private0; 778 793 #endif 779 794 } 780 795 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; 783 798 ide_pci_ops->base[3] = io_base3; 784 799 #ifdef USE_OPENFIRMWARE 785 ide_pci_ops->OF_private[1] = OF_private ;800 ide_pci_ops->OF_private[1] = OF_private1; 786 801 #endif 787 802 } 788 803 } … … 935 950 } 936 951 937 952 static void atapi_pad_req (void *buffer, int len); 953 static void atapi_make_req (bloc_device_t *bd, uint32_t *buffer, 954 int maxlen); 938 955 static int atapi_read_sector (bloc_device_t *bd, void *buffer, int secnum); 939 956 940 957 static int ide_initialize (bloc_device_t *bd, int device) … … 1035 1052 DPRINTF("INQUIRY\n"); 1036 1053 len = spc_inquiry_req(&atapi_buffer, 36); 1037 1054 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); 1041 1056 status = ide_port_read(bd, 0x07); 1042 1057 if (status != 0x48) { 1043 1058 ERROR("ATAPI INQUIRY : status %0x != 0x48\n", status); … … 1053 1068 DPRINTF("READ_CAPACITY\n"); 1054 1069 len = mmc_read_capacity_req(&atapi_buffer); 1055 1070 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); 1059 1072 status = ide_port_read(bd, 0x07); 1060 1073 if (status != 0x48) { 1061 1074 ERROR("ATAPI READ_CAPACITY : status %0x != 0x48\n", status); … … 1105 1118 memset(p + len, 0, 12 - len); 1106 1119 } 1107 1120 1121 static 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 1108 1137 static int atapi_read_sector (bloc_device_t *bd, void *buffer, int secnum) 1109 1138 { 1110 1139 uint32_t atapi_buffer[4]; … … 1112 1141 uint32_t status, value; 1113 1142 int i, len; 1114 1143 1115 /* select drive */1116 if (bd->drv == 0)1117 ide_port_write(bd, 0x06, 0x40);1118 else1119 ide_port_write(bd, 0x06, 0x50);1120 1144 len = mmc_read12_req(atapi_buffer, secnum, 1); 1121 1145 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); 1125 1147 status = ide_port_read(bd, 0x07); 1126 1148 if (status != 0x48) { 1127 1149 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 199 199 if (len == 0) { 200 200 /* Place holder. Skip it */ 201 201 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); 202 204 } else if (strncmp("Apple_Void", type, 32) == 0) { 203 205 /* Void partition. Skip it */ 204 206 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); 205 209 } else if (strncmp("Apple_Free", type, 32) == 0) { 206 210 /* Free space. Skip it */ 207 211 DPRINTF("%s Free part (%d)\n", __func__, i); 208 212 part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; 209 part_register(bd, part, name );213 part_register(bd, part, name, i); 210 214 } else if (strncmp("Apple_partition_map", type, 32) == 0 || 211 215 strncmp("Apple_Partition_Map", type, 32) == 0 212 216 #if 0 // Is this really used or is it just a mistake ? … … 226 230 */ 227 231 } 228 232 part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; 229 part_register(bd, part, name );233 part_register(bd, part, name, i); 230 234 } else if (strncmp("Apple_Driver", type, 32) == 0 || 231 235 strncmp("Apple_Driver43", type, 32) == 0 || 232 236 strncmp("Apple_Driver43_CD", type, 32) == 0 || … … 236 240 strncmp("Apple_Driver_IOKit", type, 32) == 0) { 237 241 /* Drivers. don't care for now */ 238 242 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); 239 245 } else if (strncmp("Apple_Patches", type, 32) == 0) { 240 246 /* Patches: don't care for now */ 247 part->flags = PART_TYPE_APPLE | PART_FLAG_PATCH; 248 part_register(bd, part, name, i); 241 249 DPRINTF("%s Patches part\t%d [%s]\n", __func__, i, type); 242 250 } else if (strncmp("Apple_HFS", type, 32) == 0 || 243 251 strncmp("Apple_MFS", type, 32) == 0 || … … 256 264 count = partmap->bloc_cnt * HFS_BLOCSIZE; 257 265 if (partmap->boot_size == 0 || partmap->boot_load == 0) { 258 266 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); 262 269 part->flags = PART_TYPE_APPLE | PART_FLAG_FS; 263 270 } else { 264 271 part->boot_start.bloc = partmap->boot_start; … … 278 285 boot_part = part; 279 286 part->flags = PART_TYPE_APPLE | PART_FLAG_FS | PART_FLAG_BOOT; 280 287 } 281 printf("Partition: %d %sst %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); 283 290 #ifndef DEBUG 284 291 printf("\n"); 285 292 #endif … … 290 297 part->boot_load, part->boot_entry); 291 298 DPRINTF(" load %0x entry %0x %0x\n", 292 299 partmap->boot_load2, partmap->boot_entry2, HFS_BLOCSIZE); 293 part_register(bd, part, name );300 part_register(bd, part, name, i); 294 301 } else { 295 302 memcpy(tmp, type, 32); 296 303 tmp[32] = '\0'; 297 304 ERROR("Unknown partition type [%s]\n", tmp); 305 part->flags = PART_TYPE_APPLE | PART_FLAG_DUMMY; 306 part_register(bd, part, name, i); 298 307 } 299 308 } 300 309 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 126 126 } 127 127 128 128 int part_register (bloc_device_t *bd, part_t *partition, 129 const unsigned char *name )129 const unsigned char *name, int partnum) 130 130 { 131 131 part_t **cur; 132 132 … … 134 134 partition->bd = bd; 135 135 partition->next = NULL; 136 136 partition->name = strdup(name); 137 partition->partnum = partnum; 137 138 for (cur = _bd_parts(bd); *cur != NULL; cur = &(*cur)->next) 138 139 continue; 139 140 *cur = partition; … … 141 142 return 0; 142 143 } 143 144 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 156 145 part_t *part_get (bloc_device_t *bd, int partnum) 157 146 { 158 147 part_t **listp, *cur; 159 int i;160 148 161 149 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) 165 153 break; 166 cur = cur->next;167 154 } 168 155 169 156 return cur; … … 192 179 part_set_blocsize(bd, part, 512); 193 180 part->bd = bd; 194 181 part->flags = PART_TYPE_RAW | PART_FLAG_BOOT; 195 part_register(bd, part, "Raw" );182 part_register(bd, part, "Raw", 0); 196 183 197 184 return part; 198 185 } 199 186 187 bloc_device_t *part_get_bd (part_t *part) 188 { 189 return part->bd; 190 } 191 200 192 part_t *part_probe (bloc_device_t *bd, int set_raw) 201 193 { 202 part_t *part0 , *boot_part, **cur;194 part_t *part0 = NULL, *boot_part, **cur; 203 195 204 /* Register the 0 partition: raw partition containing the whole disk */205 part0 = part_get_raw(bd);206 196 /* Try to find a valid boot partition */ 207 197 boot_part = Apple_probe_partitions(bd); 208 198 if (boot_part == NULL) { … … 210 200 if (boot_part == NULL && arch == ARCH_PREP) 211 201 boot_part = PREP_find_partition(bd); 212 202 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"); 215 204 } 216 205 } 206 if (_bd_parts(bd) == NULL) { 207 /* Register the 0 partition: raw partition containing the whole disk */ 208 part0 = part_get_raw(bd); 209 } 217 210 /* Probe filesystem on each found partition */ 218 211 for (cur = _bd_parts(bd); *cur != NULL; cur = &(*cur)->next) { 219 212 const unsigned char *map, *type; … … 248 241 type = "unknown"; 249 242 break; 250 243 } 251 DPRINTF("Probe filesystem on %s %s partition '%s' %s\n",244 dprintf("Probe filesystem on %s %s partition '%s' %s %p\n", 252 245 type, map, (*cur)->name, 253 ((*cur)->flags) & PART_FLAG_BOOT ? "(bootable)" : "" );246 ((*cur)->flags) & PART_FLAG_BOOT ? "(bootable)" : "", *cur); 254 247 if (((*cur)->flags) & PART_FLAG_FS) { 255 248 if (((*cur)->flags) & PART_FLAG_BOOT) 256 249 (*cur)->fs = fs_probe(*cur, 1); 257 250 else 258 251 (*cur)->fs = fs_probe(*cur, 0); 252 } else if (((*cur)->flags) & PART_TYPE_RAW) { 253 (*cur)->fs = fs_probe(*cur, 2); 259 254 } else { 260 255 (*cur)->fs = fs_probe(*cur, 2); 261 256 } 262 if (((*cur)->flags) & PART_FLAG_BOOT) {263 bd_set_boot_part(bd, *cur);264 257 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; 265 263 } 266 264 } 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, 268 266 part_fs(boot_part), part0); 269 267 270 268 return boot_part; … … 279 277 part->boot_size.offset = 0; 280 278 part->boot_load = 0; 281 279 part->boot_entry = 0; 280 part->flags |= PART_FLAG_BOOT; 282 281 283 282 return 0; 284 283 } -
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 242 242 part->boot_start.bloc, part->boot_size.bloc, 243 243 part->boot_load, part->boot_entry); 244 244 part->flags = PART_TYPE_ISO9660 | PART_FLAG_BOOT; 245 part_register(bd, part, name );245 part_register(bd, part, name, i + 1); 246 246 fs_raw_set_bootfile(part, part->boot_start.bloc, 247 247 part->boot_start.offset, 248 248 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 30 30 31 31 struct part_t { 32 32 bloc_device_t *bd; 33 int partnum; 33 34 uint32_t start; /* Partition first bloc */ 34 35 uint32_t size; /* Partition size, in blocs */ 35 36 uint32_t spb; … … 54 55 }; 55 56 56 57 int part_register (bloc_device_t *bd, part_t *partition, 57 const unsigned char *name );58 const unsigned char *name, int partnum); 58 59 void part_set_blocsize (bloc_device_t *bd, part_t *part, uint32_t blocsize); 59 60 void part_private_set (part_t *part, void *private); 60 61 void *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 164 164 part->boot_load = 0; 165 165 part->boot_entry = boot_offset - part->bloc_size; 166 166 part->flags = PART_TYPE_PREP | PART_FLAG_BOOT; 167 part_register(bd, part, "PREP boot" );167 part_register(bd, part, "PREP boot", i); 168 168 fs_raw_set_bootfile(part, part->boot_start.bloc, 169 169 part->boot_start.offset, 170 170 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 364 364 void *load_base, *load_entry, *last_alloc, *load_end; 365 365 uint32_t memsize, boot_image_size, cmdline_size, ramdisk_size; 366 366 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 }; 368 373 369 374 /* Retrieve NVRAM configuration */ 370 nvram_retry: 375 for(i = 0; i < 3; i++) { 376 isa_io_base = isa_base_tab[i]; 371 377 nvram = NVRAM_get_config(&memsize, &boot_device, 372 378 &boot_image, &boot_image_size, 373 379 &cmdline, &cmdline_size, 374 380 &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; 380 383 } 384 if (i == 3) { 381 385 ERROR("Unable to load configuration from NVRAM. Aborting...\n"); 382 386 return -1; 383 387 } … … 402 406 cpu_name = CPU_get_name(pvr); 403 407 OF_register_cpu(cpu_name, 0, pvr, 404 408 200 * 1000 * 1000, 200 * 1000 * 1000, 405 100 * 1000 * 1000, 10 * 1000 * 1000,409 100 * 1000 * 1000, 100 * 1000 * 1000, 406 410 0x0092); 407 411 } 408 412 OF_register_memory(memsize, 512 * 1024 /* TOFIX */); … … 433 437 vga_puts(copyright); 434 438 vga_puts("\n"); 435 439 440 #if 0 436 441 /* QEMU is quite incoherent: d is cdrom, not second drive */ 442 /* XXX: should probe CD-ROM position */ 437 443 if (boot_device == 'd') 438 444 boot_device = 'e'; 445 #endif 439 446 /* Open boot device */ 440 447 boot_part = bd_probe(boot_device); 441 448 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 334 334 ret = NVRAM_chrp_format(nvram); 335 335 break; 336 336 case ARCH_MAC99: 337 case ARCH_HEATHROW: /* XXX: may be incorrect */ 337 338 ret = NVRAM_mac99_format(nvram); 338 339 break; 339 340 case ARCH_POP: … … 409 410 arch = ARCH_MAC99; 410 411 } else if (strcmp(sign, "POP") == 0) { 411 412 arch = ARCH_POP; 413 } else if (strcmp(sign, "HEATHROW") == 0) { 414 arch = ARCH_HEATHROW; 412 415 } else { 413 416 ERROR("Unknown PPC architecture: '%s'\n", sign); 414 417 return NULL; 415 418 } 416 /* HACK */417 if (arch == ARCH_CHRP)418 arch = ARCH_MAC99;419 419 lword = NVRAM_get_lword(nvram, 0x30); 420 420 *RAM_size = lword; 421 421 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 489 489 ERROR("%s can't alloc new node '%s' name\n", __func__, name); 490 490 return NULL; 491 491 } 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); 493 493 if (new->prop_address == NULL) { 494 494 free(new->prop_name->value); 495 495 free(new->prop_name); … … 1017 1017 string, strlen(string) + 1); 1018 1018 } 1019 1019 1020 /* convert '\1' char to '\0' */ 1021 static 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 1020 1047 __attribute__ (( section (".OpenFirmware") )) 1021 1048 static OF_prop_t *OF_prop_int_new (OF_env_t *env, OF_node_t *node, 1022 1049 const unsigned char *name, uint32_t value) … … 1421 1448 __attribute__ (( section (".OpenFirmware") )) 1422 1449 int OF_init (void) 1423 1450 { 1424 const unsigned char compat_str[] =1425 1451 #if 0 1426 1452 "PowerMac3,1\0MacRISC\0Power Macintosh\0"; 1427 1453 "PowerMac1,2\0MacRISC\0Power Macintosh\0"; 1428 1454 "AAPL,PowerMac G3\0PowerMac G3\0MacRISC\0Power Macintosh\0"; 1429 1455 "AAPL,PowerMac3,0\0MacRISC\0Power Macintosh\0"; 1430 1456 "AAPL,Gossamer\0MacRISC\0Power Macintosh\0"; 1431 #else1432 "AAPL,PowerMac G3\0PowerMac G3\0MacRISC\0Power Macintosh\0";1433 1457 #endif 1434 1458 OF_env_t *OF_env; 1435 1459 OF_node_t *als, *opt, *chs, *pks; … … 1455 1479 return -1; 1456 1480 } 1457 1481 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)); 1462 1487 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"; 1465 1492 OF_property_new(OF_env, OF_node_root, "compatible", 1466 1493 compat_str, sizeof(compat_str)); 1494 OF_prop_string_new(OF_env, OF_node_root, 1495 "model", "PowerMac3,1"); 1496 } 1467 1497 #if 0 1468 1498 OF_prop_string_new(OF_env, OF_node_root, "copyright", copyright); 1469 1499 #else … … 1561 1591 range.size = 0x00800000; 1562 1592 OF_property_new(OF_env, rom, "ranges", &range, sizeof(OF_range_t)); 1563 1593 OF_prop_int_new(OF_env, rom, "#address-cells", 1); 1594 1564 1595 /* "/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); 1566 1597 if (brom == NULL) { 1567 1598 ERROR("Cannot create 'boot-rom'\n"); 1568 1599 return -1; 1569 1600 } 1570 1601 regs.address = 0xFFF00000; 1571 regs.size = 0x00 010000;1602 regs.size = 0x00100000; 1572 1603 OF_property_new(OF_env, brom, "reg", ®s, sizeof(OF_regprop_t)); 1573 1604 OF_prop_string_new(OF_env, brom, "write-characteristic", "flash"); 1574 1605 OF_prop_string_new(OF_env, brom, "BootROM-build-date", … … 1577 1608 OF_prop_string_new(OF_env, brom, "copyright", copyright); 1578 1609 OF_prop_string_new(OF_env, brom, "model", BIOS_str); 1579 1610 OF_prop_int_new(OF_env, brom, "result", 0); 1580 #if 01611 #if 1 1581 1612 { 1582 1613 /* Hack taken 'as-is' from PearPC */ 1583 1614 unsigned char info[] = { … … 1596 1627 OF_node_put(OF_env, brom); 1597 1628 OF_node_put(OF_env, rom); 1598 1629 } 1630 #if 0 1599 1631 /* From here, hardcoded hacks to get a Mac-like machine */ 1632 /* XXX: Core99 does not seem to like this NVRAM tree */ 1600 1633 /* "/nvram@fff04000" node */ 1601 1634 { 1602 1635 OF_regprop_t regs; … … 1617 1650 OF_prop_int_new(OF_env, chs, "nvram", OF_pack_handle(OF_env, nvr)); 1618 1651 OF_node_put(OF_env, nvr); 1619 1652 } 1653 #endif 1620 1654 /* "/pseudo-hid" : hid emulation as Apple does */ 1621 1655 { 1622 1656 OF_node_t *hid; … … 1663 1697 } 1664 1698 OF_node_put(OF_env, hid); 1665 1699 } 1700 if (arch == ARCH_MAC99) { 1701 OF_node_t *unin; 1702 OF_regprop_t regs; 1666 1703 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", ®s, 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 } 1667 1721 1668 1722 #if 1 /* This is mandatory for claim to work 1669 1723 * but I don't know where it should really be (in cpu ?) … … 1693 1747 1694 1748 /* "/options/boot-args" node */ 1695 1749 { 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"; 1697 1753 /* Ask MacOS X to print debug messages */ 1698 1754 // OF_prop_string_new(OF_env, chs, "machargs", args); 1699 1755 // OF_prop_string_new(OF_env, opt, "boot-command", args); … … 2013 2069 OF_prop_int_new(OF_env, node, "min-grant", min_grant); 2014 2070 OF_prop_int_new(OF_env, node, "max-latency", max_latency); 2015 2071 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); 2017 2073 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); 2019 2075 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); 2021 2077 if (dev->acells != 0) 2022 2078 OF_prop_int_new(OF_env, node, "#address-cells", dev->acells); 2023 2079 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); 2025 2081 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); 2027 2083 dprintf("Done %p %p\n", parent, node); 2028 2084 2029 2085 return node; … … 2040 2096 OF_env_t *OF_env; 2041 2097 pci_range_t ranges[3]; 2042 2098 OF_regprop_t regs[1]; 2043 OF_node_t *pci_host ;2099 OF_node_t *pci_host, *als; 2044 2100 int nranges; 2101 unsigned char buffer[OF_NAMELEN_MAX]; 2045 2102 2046 2103 OF_env = OF_env_main; 2047 2104 dprintf("register PCI host '%s' '%s' '%s' '%s'\n", … … 2052 2109 ERROR("Cannot create pci host\n"); 2053 2110 return NULL; 2054 2111 } 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 2055 2123 regs[0].address = cfg_base; 2056 2124 regs[0].size = cfg_len; 2057 2125 OF_property_new(OF_env, pci_host, "reg", regs, sizeof(OF_regprop_t)); … … 2136 2204 return pci_dev; 2137 2205 } 2138 2206 2207 /* XXX: suppress that, used for interrupt map init */ 2208 OF_node_t *pci_host_node; 2209 uint32_t pci_host_interrupt_map[7 * 32]; 2210 int pci_host_interrupt_map_len = 0; 2211 2139 2212 void OF_finalize_pci_host (void *dev, int first_bus, int nb_busses) 2140 2213 { 2141 2214 OF_env_t *OF_env; … … 2145 2218 regs[0].address = first_bus; 2146 2219 regs[0].size = nb_busses; 2147 2220 OF_property_new(OF_env, dev, "bus-range", regs, sizeof(OF_regprop_t)); 2221 pci_host_node = dev; 2148 2222 } 2149 2223 2150 2224 void 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) 2152 2227 { 2153 2228 OF_env_t *OF_env; 2154 2229 pci_reg_prop_t pregs[6], rregs[6]; … … 2156 2231 int i, j, k; 2157 2232 2158 2233 OF_env = OF_env_main; 2234 /* XXX: only useful for VGA card in fact */ 2159 2235 if (regions[0] != 0x00000000) 2160 2236 OF_prop_int_set(OF_env, dev, "address", regions[0] & ~0x0000000F); 2161 2237 for (i = 0, j = 0, k = 0; i < 6; i++) { … … 2222 2298 } else { 2223 2299 OF_property_new(OF_env, dev, "assigned-addresses", NULL, 0); 2224 2300 } 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 2226 2317 { 2227 2318 OF_prop_t *prop_name = ((OF_node_t *)dev)->prop_name; 2228 2319 … … 2390 2481 return 0; 2391 2482 } 2392 2483 2484 static 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 2393 2532 void OF_finalize_pci_macio (void *dev, uint32_t base_address, uint32_t size, 2394 2533 void *private_data) 2395 2534 { … … 2398 2537 pci_reg_prop_t pregs[2]; 2399 2538 OF_node_t *mio, *chs, *als; 2400 2539 uint16_t pic_phandle; 2540 int rec_len; 2541 OF_prop_t *mio_reg; 2401 2542 2402 2543 OF_DPRINTF("mac-io: %p\n", dev); 2403 2544 OF_env = OF_env_main; … … 2416 2557 mio = dev; 2417 2558 mio->private_data = private_data; 2418 2559 pregs[0].addr.hi = 0x00000000; 2419 pregs[0].addr.mid = 0x 82013810;2560 pregs[0].addr.mid = 0x00000000; 2420 2561 pregs[0].addr.lo = 0x00000000; 2421 2562 pregs[0].size_hi = base_address; 2422 2563 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 } 2423 2568 OF_property_new(OF_env, mio, "ranges", 2424 2569 &pregs, sizeof(pci_reg_prop_t)); 2425 2570 #if 0 … … 2431 2576 OF_property_new(OF_env, mio, "assigned-addresses", 2432 2577 &pregs, sizeof(pci_reg_prop_t)); 2433 2578 #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 ®s, 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 { 2434 2604 /* OpenPIC */ 2435 {2436 2605 OF_regprop_t regs[4]; 2437 2606 OF_node_t *mpic; 2438 2607 mpic = OF_node_new(OF_env, mio, "interrupt-controller", 0x40000); … … 2455 2624 pic_phandle = OF_pack_handle(OF_env, mpic); 2456 2625 OF_prop_int_new(OF_env, chs, "interrupt-controller", pic_phandle); 2457 2626 OF_node_put(OF_env, mpic); 2627 rec_len = 7; 2458 2628 } 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 2460 2658 /* escc is usefull to get MacOS X debug messages */ 2461 2659 { 2462 2660 OF_regprop_t regs[8]; … … 2645 2843 OF_node_put(OF_env, scc); 2646 2844 } 2647 2845 #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); 2726 2850 } 2851 #if 0 2727 2852 /* Timer */ 2728 2853 { 2729 2854 OF_node_t *tmr; … … 2746 2871 regs, sizeof(OF_regprop_t)); 2747 2872 OF_node_put(OF_env, tmr); 2748 2873 } 2874 #endif 2749 2875 /* VIA-PMU */ 2750 2876 { 2751 2877 /* Controls adb, RTC and power-mgt (forget it !) */ 2752 OF_node_t *via, *adb , *rtc;2878 OF_node_t *via, *adb; 2753 2879 OF_regprop_t regs[1]; 2754 2880 #if 0 // THIS IS A HACK AND IS COMPLETELY ABSURD ! 2755 2881 // (but needed has Qemu doesn't emulate via-pmu). … … 2773 2899 regs[0].size = 0x00002000; 2774 2900 OF_property_new(OF_env, via, "reg", regs, sizeof(OF_regprop_t)); 2775 2901 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 { 2776 2905 regs[0].address = 0x00000019; 2777 2906 regs[0].size = 0x00000001; 2778 2907 OF_property_new(OF_env, via, "interrupts", 2779 2908 regs, sizeof(OF_regprop_t)); 2909 } 2910 /* force usage of OF bus speeds */ 2911 OF_prop_int_new(OF_env, via, "BusSpeedCorrect", 1); 2780 2912 #if 0 2781 2913 OF_prop_int_new(OF_env, via, "pmu-version", 0x00D0740C); 2782 2914 #endif 2783 #if 1 2915 { 2916 OF_node_t *kbd, *mouse; 2784 2917 /* ADB pseudo-device */ 2785 2918 adb = OF_node_new(OF_env, via, "adb", OF_ADDRESS_NONE); 2786 2919 if (adb == NULL) { … … 2797 2930 OF_prop_int_new(OF_env, adb, "#size-cells", 0); 2798 2931 OF_pack_get_path(OF_env, tmp, 512, adb); 2799 2932 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; 2803 2953 2804 2954 rtc = OF_node_new(OF_env, via, "rtc", OF_ADDRESS_NONE); 2805 2955 if (rtc == NULL) { … … 2813 2963 OF_prop_string_new(OF_env, rtc, "compatible", "rtc"); 2814 2964 #endif 2815 2965 OF_node_put(OF_env, rtc); 2816 OF_node_put(OF_env, via);2817 2966 } 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", ®s, sizeof(regs)); 2987 OF_prop_int_new(OF_env, nvr, "#bytes", 0x2000); 2988 OF_node_put(OF_env, nvr); 2989 } 2990 2818 2991 out: 2819 2992 // OF_node_put(OF_env, mio); 2820 2993 OF_node_put(OF_env, chs); 2821 2994 OF_node_put(OF_env, als); 2822 2995 } 2823 2996 2997 void 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 2824 3028 /*****************************************************************************/ 2825 3029 /* Fake package */ 2826 3030 static void OF_method_fake (OF_env_t *OF_env) … … 2862 3066 /* As we get a 1:1 mapping, do nothing */ 2863 3067 ihandle = popd(OF_env); 2864 3068 args = (void *)popd(OF_env); 2865 address = popd(OF_env);2866 virt = popd(OF_env);2867 size = popd(OF_env);2868 3069 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, 2870 3074 virt, size); 2871 3075 pushd(OF_env, 0); 2872 3076 } … … 3270 3474 OF_prop_string_new(OF_env, dsk, "device_type", "block"); 3271 3475 OF_prop_string_new(OF_env, dsk, "category", type); 3272 3476 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); 3274 3478 OF_method_new(OF_env, dsk, "open", &OF_blockdev_open); 3275 3479 OF_method_new(OF_env, dsk, "seek", &OF_blockdev_seek); 3276 3480 OF_method_new(OF_env, dsk, "read", &OF_blockdev_read); … … 3432 3636 } 3433 3637 3434 3638 void 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) 3436 3641 { 3437 3642 OF_env_t *OF_env; 3438 3643 unsigned char tmp[OF_NAMELEN_MAX]; … … 3504 3709 OF_prop_string_new(OF_env, als, "display", tmp); 3505 3710 OF_node_put(OF_env, als); 3506 3711 /* 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 } 3507 3724 out: 3508 3725 OF_node_put(OF_env, disp); 3509 3726 } … … 4451 4668 break; 4452 4669 case 0x233441d3: /* MacOS X 10.2 and OpenDarwin 1.41 */ 4453 4670 /* Create "memory-map" pseudo device */ 4454 popd(OF_env); 4671 { 4672 OF_node_t *map; 4673 uint32_t phandle; 4674 4455 4675 /* Find "/packages" */ 4456 4676 chs = OF_pack_find_by_name(OF_env, OF_node_root, "/chosen"); 4457 4677 if (chs == NULL) { … … 4459 4679 ERROR("Cannot get '/chosen'\n"); 4460 4680 break; 4461 4681 } 4462 {4463 #if 14464 OF_node_t *map;4465 uint32_t phandle;4466 4682 map = OF_node_new(OF_env, chs, "memory-map", OF_ADDRESS_NONE); 4467 4683 if (map == NULL) { 4468 4684 pushd(OF_env, -1); … … 4473 4689 OF_node_put(OF_env, map); 4474 4690 OF_node_put(OF_env, chs); 4475 4691 pushd(OF_env, phandle); 4476 }4477 #else4478 pushd(OF_env, 0);4479 #endif4480 4692 pushd(OF_env, 0); 4693 } 4481 4694 break; 4482 4695 case 0x32a2d18e: /* MacOS X 10.2 and OpenDarwin 6.02 */ 4483 4696 /* Return screen ihandle */ … … 4540 4753 case 0x4ad41f2d: 4541 4754 /* Yaboot: wait 10 ms: sure ! */ 4542 4755 break; 4756 4543 4757 default: 4544 4758 /* ERROR */ 4545 printf("Script: \n%s\n", FString);4759 printf("Script: len=%d\n%s\n", (int)strlen(FString), FString); 4546 4760 printf("Call %0x NOT IMPLEMENTED !\n", crc); 4547 4761 bug(); 4548 4762 break; … … 4581 4795 { 4582 4796 OF_CHECK_NBARGS(OF_env, 0); 4583 4797 /* Should free all OF resources */ 4798 bd_reset_all(); 4584 4799 #if defined (DEBUG_BIOS) 4585 4800 { 4586 4801 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 99 99 uint16_t min_grant; 100 100 uint16_t max_latency; 101 101 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]; 104 104 pci_device_t *next; 105 105 }; 106 106 … … 158 158 159 159 /* IRQ numbers assigned to PCI IRQs */ 160 160 static uint8_t prep_pci_irqs[4] = { 9, 11, 9, 11 }; 161 static uint8_t heathrow_pci_irqs[4] = { 0x15, 0x16, 0x17, 0x18 }; 161 162 static uint8_t pmac_pci_irqs[4] = { 8, 9, 10, 11 }; 162 163 163 164 /* PREP PCI host */ … … 399 400 &uninorth_config_readl, &uninorth_config_writel, 400 401 }; 401 402 403 /* Grackle PCI host */ 404 405 static 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 415 static 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 424 static 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 433 static 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 442 static 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 451 static 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 460 static 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 470 static 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 402 476 static inline uint8_t pci_config_readb (pci_bridge_t *bridge, 403 477 uint8_t bus, uint8_t devfn, 404 478 uint8_t offset) … … 466 540 }, 467 541 }; 468 542 543 static 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 469 553 static pci_dev_t ide_devices[] = { 470 554 { 471 0x 8086, 0x0100,472 NULL, "Qemu IDE", "Qemu IDE", "ide",555 0x1095, 0x0646, /* CMD646 IDE controller */ 556 "pci-ide", "pci-ata", NULL, NULL, 473 557 0, 0, 0, 474 NULL, NULL,558 ide_config_cb2, NULL, 475 559 }, 476 560 { 477 561 0xFFFF, 0xFFFF, … … 481 565 }, 482 566 }; 483 567 484 static int ide_config_cb (pci_device_t *device) 568 #if 0 569 /* should base it on PCI ID, not on arch */ 570 static int ide_config_cb (unused pci_device_t *device) 485 571 { 486 572 printf("Register IDE controller\n"); 487 573 switch (arch) { … … 491 577 device->common.OF_private); 492 578 break; 493 579 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);499 580 break; 500 581 } 501 502 582 return 0; 503 583 } 504 584 … … 512 592 device->common.OF_private); 513 593 break; 514 594 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);520 595 break; 521 596 } 522 597 523 598 return 0; 524 599 } 600 #endif 525 601 526 602 static pci_subclass_t mass_subclass[] = { 527 603 { … … 530 606 }, 531 607 { 532 608 0x01, "IDE controller", "ide", ide_devices, NULL, 533 &ide_config_cb, NULL,609 NULL, NULL, 534 610 }, 535 611 { 536 612 0x02, "Floppy disk controller", NULL, NULL, NULL, … … 546 622 }, 547 623 { 548 624 0x05, "ATA controller", "ata", NULL, NULL, 549 &ata_config_cb, NULL,625 NULL, NULL, 550 626 }, 551 627 { 552 628 0x80, "misc mass-storage controller", NULL, NULL, NULL, … … 646 722 /* VGA 640x480x16 */ 647 723 OF_vga_register(device->common.device->name, 648 724 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]); 650 728 } 651 729 vga_console_register(); 652 730 … … 750 828 NULL, &PREP_pci_ops, 751 829 }; 752 830 831 pci_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 753 838 static pci_dev_t hbrg_devices[] = { 754 839 { 755 840 0x106B, 0x0020, NULL, … … 758 843 NULL, &uninorth_agp_fake_bridge, 759 844 }, 760 845 { 761 0x106B, 0x001F, 762 NULL,"pci", "AAPL,UniNorth", "uni-north",846 0x106B, 0x001F, NULL, 847 "pci", "AAPL,UniNorth", "uni-north", 763 848 3, 2, 1, 764 849 NULL, &uninorth_fake_bridge, 765 850 }, … … 770 855 NULL, &uninorth_fake_bridge, 771 856 }, 772 857 { 773 0x10 11, 0x0026, NULL,774 "pci -bridge", NULL, NULL,858 0x1057, 0x0002, "pci", 859 "pci", "MOT,MPC106", "grackle", 775 860 3, 2, 1, 776 NULL, & PREP_pci_ops,861 NULL, &grackle_fake_bridge, 777 862 }, 778 863 { 779 864 0x1057, 0x4801, NULL, … … 1443 1528 } 1444 1529 1445 1530 static 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 */ 1447 1539 { 1448 1540 0x106B, 0x0022, 1449 1541 "mac-io", "mac-io", "AAPL,Keylargo", "Keylargo", … … 1599 1691 uint8_t min_grant, uint8_t max_latency, 1600 1692 int irq_line) 1601 1693 { 1602 uint32_t cmd ;1694 uint32_t cmd, addr; 1603 1695 int i; 1604 1696 1605 1697 device->min_grant = min_grant; … … 1611 1703 printf("MAP PCI device %d:%d to IRQ %d\n", 1612 1704 device->bus, device->devfn, irq_line); 1613 1705 } 1614 for (i = 0; i < 6; i++) {1706 for (i = 0; i < 7; i++) { 1615 1707 if ((device->regions[i] & ~0xF) != 0x00000000 && 1616 1708 (device->regions[i] & ~0xF) != 0xFFFFFFF0) { 1617 1709 printf("Map PCI device %d:%d %d to %0x %0x (%s)\n", 1618 1710 device->bus, device->devfn, i, 1619 1711 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) { 1621 1715 cmd = pci_config_readl(bridge, device->bus, device->devfn, 0x04); 1622 1716 if (device->regions[i] & 0x00000001) 1623 1717 cmd |= 0x00000001; 1624 1718 else 1625 1719 cmd |= 0x00000002; 1626 1720 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)); 1627 1726 pci_config_writel(bridge, device->bus, device->devfn, 1628 0x10 + (i * sizeof(uint32_t)), 1629 device->regions[i]); 1727 addr, device->regions[i]); 1630 1728 } 1631 1729 } 1632 1730 } … … 1900 1998 goto out; 1901 1999 } 1902 2000 ret = (pci_u_t *)newd; 1903 max_areas = 6;2001 max_areas = 7; 1904 2002 /* register PCI device in OF tree */ 1905 2003 if (bridge->dev.common.type == PCI_FAKE_BRIDGE) { 1906 2004 newd->common.OF_private = … … 1927 2025 /* Handle 64 bits memory mapping */ 1928 2026 continue; 1929 2027 } 2028 if (i == 6) 2029 addr = 0x30; /* PCI ROM */ 2030 else 1930 2031 addr = 0x10 + (i * sizeof(uint32_t)); 1931 2032 /* Get region size 1932 2033 * Note: we assume it's always a power of 2 … … 1935 2036 smask = pci_config_readl(bridge, bus, devfn, addr); 1936 2037 if (smask == 0x00000000 || smask == 0xFFFFFFFF) 1937 2038 continue; 1938 if ( smask & 0x00000001) {2039 if ((smask & 0x00000001) != 0 && i != 6) { 1939 2040 /* I/O space */ 1940 2041 base = io_base; 1941 2042 /* Align to a minimum of 256 bytes (arbitrary) */ … … 1947 2048 /* Align to a minimum of 64 kB (arbitrary) */ 1948 2049 min_align = 1 << 16; 1949 2050 amask = 0x0000000F; 2051 if (i == 6) 2052 smask |= 1; /* PCI ROM enable */ 1950 2053 } 1951 2054 omask = smask & amask; 1952 2055 smask &= ~amask; … … 1980 2083 if (irq_pin > 0) { 1981 2084 /* assign the IRQ */ 1982 2085 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 { 1984 2090 int elcr_port, val; 1985 2091 irq_line = prep_pci_irqs[irq_pin]; 1986 2092 /* set the IRQ to level-sensitive */ … … 1988 2094 val = inb(elcr_port); 1989 2095 val |= 1 << (irq_line & 7); 1990 2096 outb(elcr_port, val); 1991 } else { 2097 } 2098 break; 2099 case ARCH_MAC99: 1992 2100 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; 1993 2107 } 1994 2108 } 1995 2109 update_device: 1996 2110 pci_update_device(bridge, newd, min_grant, max_latency, irq_line); 1997 2111 OF_finalize_pci_device(newd->common.OF_private, bus, devfn, 1998 newd->regions, newd->sizes );2112 newd->regions, newd->sizes, irq_line); 1999 2113 /* Call special inits if needed */ 2000 2114 if (dev->config_cb != NULL) 2001 2115 (*dev->config_cb)(newd); … … 2049 2163 case ARCH_CHRP: 2050 2164 /* TODO */ 2051 2165 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; 2052 2192 case ARCH_MAC99: 2053 2193 dev = pci_find_device(0x06, 0x00, 0xFF, checkv, checkp); 2054 2194 if (dev == NULL) … … 2167 2307 case ARCH_CHRP: 2168 2308 /* TODO */ 2169 2309 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; 2170 2334 case ARCH_MAC99: 2171 2335 /* We are supposed to have 3 host bridges: 2172 2336 * - the uninorth AGP bridge at 0xF0000000
Note: See TracBrowser
for help on using the repository browser.