--- trunk/src/promemul/arcbios.c 2007/10/08 16:19:37 22 +++ trunk/src/promemul/arcbios.c 2007/10/08 16:19:56 24 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: arcbios.c,v 1.5 2006/02/09 22:40:27 debug Exp $ + * $Id: arcbios.c,v 1.8 2006/04/15 08:21:07 debug Exp $ * * ARCBIOS emulation. */ @@ -699,8 +699,8 @@ uint64_t eparent, echild, epeer, tmp; unsigned char buf[8]; - /* debug("[ addchild: peeraddr = 0x%016llx ]\n", - (long long)peeraddr); */ + /* debug("[ addchild: peeraddr = 0x%016"PRIx64" ]\n", + (uint64_t) peeraddr); */ cpu->memory_rw(cpu, cpu->mem, peeraddr + 0 * machine->md.arc.wordlen, &buf[0], @@ -744,25 +744,25 @@ + ((uint64_t)buf[4] << 32) + ((uint64_t)buf[5] << 40) + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56); - /* debug(" epeer=%llx echild=%llx eparent=%llx\n", - (long long)epeer, (long long)echild, - (long long)eparent); */ + /* debug(" epeer=%"PRIx64" echild=%"PRIx64" eparent=%"PRIx64 + "\n", (uint64_t) epeer, (uint64_t) echild, + (uint64_t) eparent); */ if (eparent == parent && epeer == 0) { epeer = a; store_64bit_word(cpu, peeraddr + 0 * machine->md.arc.wordlen, epeer); - /* debug("[ addchild: adding 0x%016llx as peer " - "to 0x%016llx ]\n", (long long)a, - (long long)peeraddr); */ + /* debug("[ addchild: adding 0x%016"PRIx64" as peer " + "to 0x%016"PRIx64" ]\n", (uint64_t) a, + (uint64_t) peeraddr); */ } if (peeraddr == parent && echild == 0) { echild = a; store_64bit_word(cpu, peeraddr + 1 * machine->md.arc.wordlen, echild); - /* debug("[ addchild: adding 0x%016llx as child " - "to 0x%016llx ]\n", (long long)a, - (long long)peeraddr); */ + /* debug("[ addchild: adding 0x%016"PRIx64" as child " + "to 0x%016"PRIx64" ]\n", (uint64_t) a, + (uint64_t) peeraddr); */ } /* Go to the next component: */ @@ -869,12 +869,12 @@ machine->md.arc.next_component_address + (cpu->machine->md.arc.arc_64bit? 0x18 : 0x0c); - /* printf("& ADDING %i: configdata=0x%016llx " - "component=0x%016llx\n", + /* printf("& ADDING %i: configdata=0x%016"PRIx64" " + "component=0x%016"PRIx64"\n", machine->md.arc.n_configuration_data, - (long long)machine->md.arc.configuration_data_configdata[ + (uint64_t) machine->md.arc.configuration_data_configdata[ machine->md.arc.n_configuration_data], - (long long)machine->md.arc.configuration_data_component[ + (uint64_t) machine->md.arc.configuration_data_component[ machine->md.arc.n_configuration_data]); */ machine->md.arc.n_configuration_data ++; @@ -947,15 +947,15 @@ ugly_goto: *start = 0; *size = 0; - /* printf("reading MSDOS partition from offset 0x%llx\n", - (long long)offset); */ + /* printf("reading MSDOS partition from offset 0x%"PRIx64"\n", + (uint64_t) offset); */ res = diskimage_access(machine, disk_id, disk_type, 0, offset, sector, sizeof(sector)); if (!res) { fatal("[ arcbios_get_msdos_partition_size(): couldn't " - "read the disk image, id %i, offset 0x%llx ]\n", - disk_id, (long long)offset); + "read the disk image, id %i, offset 0x%"PRIx64" ]\n", + disk_id, (uint64_t) offset); return; } @@ -1239,9 +1239,9 @@ cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t) (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0]; } - debug("[ ARCBIOS GetPeer(node 0x%016llx): 0x%016llx ]\n", - (long long)cpu->cd.mips.gpr[MIPS_GPR_A0], - (long long)cpu->cd.mips.gpr[MIPS_GPR_V0]); + debug("[ ARCBIOS GetPeer(node 0x%016"PRIx64"): 0x%016"PRIx64 + " ]\n", (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0], + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_V0]); break; case 0x28: /* GetChild(node) */ /* 0 for the root, non-0 for children: */ @@ -1290,9 +1290,9 @@ cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t) (int32_t)cpu->cd.mips.gpr[MIPS_GPR_V0]; } - debug("[ ARCBIOS GetChild(node 0x%016llx): 0x%016llx ]\n", - (long long)cpu->cd.mips.gpr[MIPS_GPR_A0], - (long long)cpu->cd.mips.gpr[MIPS_GPR_V0]); + debug("[ ARCBIOS GetChild(node 0x%016"PRIx64"): 0x%016" + PRIx64" ]\n", (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0], + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_V0]); break; case 0x2c: /* GetParent(node) */ { @@ -1339,18 +1339,19 @@ cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t) (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0]; } - debug("[ ARCBIOS GetParent(node 0x%016llx): 0x%016llx ]\n", - (long long)cpu->cd.mips.gpr[MIPS_GPR_A0], - (long long)cpu->cd.mips.gpr[MIPS_GPR_V0]); + debug("[ ARCBIOS GetParent(node 0x%016"PRIx64"): 0x%016" + PRIx64" ]\n", (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0], + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_V0]); break; case 0x30: /* GetConfigurationData(void *configdata, void *node) */ - /* fatal("[ ARCBIOS GetConfigurationData(0x%016llx," - "0x%016llx) ]\n", (long long)cpu->cd.mips.gpr[MIPS_GPR_A0], - (long long)cpu->cd.mips.gpr[MIPS_GPR_A1]); */ + /* fatal("[ ARCBIOS GetConfigurationData(0x%016"PRIx64"," + "0x%016"PRIx64") ]\n", + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0], + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1]); */ cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EINVAL; for (i=0; imd.arc.n_configuration_data; i++) { /* fatal("configuration_data_component[%i] = " - "0x%016llx\n", i, (long long)machine-> + "0x%016"PRIx64"\n", i, (uint64_t) machine-> md.arc.configuration_data_component[i]); */ if (cpu->cd.mips.gpr[MIPS_GPR_A1] == machine->md.arc.configuration_data_component[i]) { @@ -1676,11 +1677,11 @@ arcbios_handle_to_start_and_size(machine, handle, &partition_offset, &size); - debug("[ ARCBIOS Write(%i,0x%08llx,%i,0x%08llx) ]\n", - (int)cpu->cd.mips.gpr[MIPS_GPR_A0], - (long long)cpu->cd.mips.gpr[MIPS_GPR_A1], - (int)cpu->cd.mips.gpr[MIPS_GPR_A2], - (long long)cpu->cd.mips.gpr[MIPS_GPR_A3]); + debug("[ ARCBIOS Write(%i,0x%08"PRIx64",%i,0x%08" + PRIx64") ]\n", (int) cpu->cd.mips.gpr[MIPS_GPR_A0], + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1], + (int) cpu->cd.mips.gpr[MIPS_GPR_A2], + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A3]); tmp_buf = malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]); if (tmp_buf == NULL) { @@ -1728,18 +1729,18 @@ break; case 0x70: /* Seek(uint32_t handle, int64_t *ofs, uint32_t whence): uint32_t */ - debug("[ ARCBIOS Seek(%i,0x%08llx,%i): ", - (int)cpu->cd.mips.gpr[MIPS_GPR_A0], - (long long)cpu->cd.mips.gpr[MIPS_GPR_A1], - (int)cpu->cd.mips.gpr[MIPS_GPR_A2]); + debug("[ ARCBIOS Seek(%i,0x%08"PRIx64",%i): ", + (int) cpu->cd.mips.gpr[MIPS_GPR_A0], + (uint64_t)cpu->cd.mips.gpr[MIPS_GPR_A1], + (int) cpu->cd.mips.gpr[MIPS_GPR_A2]); if (cpu->cd.mips.gpr[MIPS_GPR_A2] != 0) { - fatal("[ ARCBIOS Seek(%i,0x%08llx,%i): " + fatal("[ ARCBIOS Seek(%i,0x%08"PRIx64",%i): " "UNIMPLEMENTED whence=%i ]\n", - (int)cpu->cd.mips.gpr[MIPS_GPR_A0], - (long long)cpu->cd.mips.gpr[MIPS_GPR_A1], - (int)cpu->cd.mips.gpr[MIPS_GPR_A2], - (int)cpu->cd.mips.gpr[MIPS_GPR_A2]); + (int) cpu->cd.mips.gpr[MIPS_GPR_A0], + (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1], + (int) cpu->cd.mips.gpr[MIPS_GPR_A2], + (int) cpu->cd.mips.gpr[MIPS_GPR_A2]); } { @@ -1761,7 +1762,7 @@ + ((uint64_t)buf[7] << 56); machine->md.arc.current_seek_offset[ cpu->cd.mips.gpr[MIPS_GPR_A0]] = ofs; - debug("%016llx ]\n", (long long)ofs); + debug("%016"PRIx64" ]\n", (uint64_t) ofs); } cpu->cd.mips.gpr[MIPS_GPR_V0] = 0; /* Success. */ @@ -2722,7 +2723,7 @@ system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, 0,1,2,0, 0xffffffff, name, 0/*ROOT*/, NULL, 0); - debug("ARC system @ 0x%llx (\"%s\")\n", (long long)system, name); + debug("ARC system @ 0x%"PRIx64" (\"%s\")\n", (uint64_t) system, name); /* @@ -2838,19 +2839,19 @@ 0xffffffff, NULL, cpuaddr, NULL, 0); } - debug("ARC cpu%i @ 0x%llx", i, (long long)cpuaddr); + debug("ARC cpu%i @ 0x%"PRIx64, i, (uint64_t) cpuaddr); if (fpu != 0) - debug(" (fpu @ 0x%llx)\n", (long long)fpu); + debug(" (fpu @ 0x%"PRIx64")\n", (uint64_t) fpu); else debug("\n"); - debug(" picache @ 0x%llx, pdcache @ 0x%llx\n", - (long long)picache, (long long)pdcache); + debug(" picache @ 0x%"PRIx64", pdcache @ 0x%"PRIx64"\n", + (uint64_t) picache, (uint64_t) pdcache); if (machine->cache_secondary >= 12) - debug(" sdcache @ 0x%llx\n", - (long long)sdcache); + debug(" sdcache @ 0x%"PRIx64"\n", + (uint64_t) sdcache); if (machine->machine_type == MACHINE_SGI) { /* TODO: Memory amount (and base address?)! */ @@ -2858,7 +2859,7 @@ COMPONENT_CLASS_MemoryClass, COMPONENT_TYPE_MemoryUnit, 0, 1, 2, 0, 0xffffffff, "memory", cpuaddr, NULL, 0); - debug("ARC memory @ 0x%llx\n", (long long)memory); + debug("ARC memory @ 0x%"PRIx64"\n", (uint64_t) memory); } } @@ -2896,11 +2897,23 @@ ARC_FIRMWARE_ENTRIES + i*8); store_64bit_word(cpu, ARC_PRIVATE_VECTORS + i*8, ARC_PRIVATE_ENTRIES + i*8); + + /* "Magic trap" instruction: */ + store_32bit_word(cpu, ARC_FIRMWARE_ENTRIES + i*8, + 0x00c0de0c); + store_32bit_word(cpu, ARC_PRIVATE_ENTRIES + i*8, + 0x00c0de0c); } else { store_32bit_word(cpu, ARC_FIRMWARE_VECTORS + i*4, ARC_FIRMWARE_ENTRIES + i*4); store_32bit_word(cpu, ARC_PRIVATE_VECTORS + i*4, ARC_PRIVATE_ENTRIES + i*4); + + /* "Magic trap" instruction: */ + store_32bit_word(cpu, ARC_FIRMWARE_ENTRIES + i*4, + 0x00c0de0c); + store_32bit_word(cpu, ARC_PRIVATE_ENTRIES + i*4, + 0x00c0de0c); } }