37 #include <sys/types.h>
38 #include <sys/resource.h>
60 char *str, uint64_t component)
64 printf(
"Too many string-to-component mappings.\n");
71 debug(
"adding ARC component mapping: 0x%08x = %s\n",
86 static void arcbios_get_dsp_stat(
struct cpu *
cpu,
107 static void arcbios_putcell(
struct cpu *
cpu,
int ch,
int x,
int y)
109 unsigned char buf[2];
113 buf[1] = ((buf[1] & 0x70) >> 4) | ((buf[1] & 7) << 4)
127 static void handle_esc_seq(
struct cpu *
cpu)
130 int row, col, color, code, start, stop;
198 default:
fatal(
"{ handle_esc_seq: color %i }\n", color);
221 if (i != 0 && i != 2)
222 fatal(
"{ handle_esc_seq(): %iJ }\n", i);
226 arcbios_putcell(
cpu,
' ', col,
231 arcbios_putcell(
cpu,
' ', col, row);
241 for (i=start; i<=stop; i++)
242 arcbios_putcell(
cpu,
' ', i,
248 fatal(
"{ handle_esc_seq(): unimplemented escape sequence: ");
249 for (i=0; i<len; i++) {
254 if (x >=
' ' && x < 127)
257 fatal(
"[0x%02x]", x);
266 static void scroll_if_necessary(
struct cpu *
cpu)
271 unsigned char buf[2];
279 console_maxx * (y+1)),
294 arcbios_putcell(
cpu,
' ', x,
306 static void arcbios_putchar(
struct cpu *
cpu,
int ch)
330 if ((ch >=
'a' && ch <=
'z') ||
339 }
else if (ch == 0x9b) {
343 }
else if (ch ==
'\b') {
346 }
else if (ch ==
'\r') {
348 }
else if (ch ==
'\n') {
350 }
else if (ch ==
'\t') {
361 scroll_if_necessary(
cpu);
363 arcbios_putcell(
cpu, ch,
370 scroll_if_necessary(
cpu);
381 console_ctrlregs + 0x14,
383 byte = (
addr >> 8) & 255;
385 console_ctrlregs + 0x15,
389 console_ctrlregs + 0x14,
393 console_ctrlregs + 0x15,
401 static void arcbios_putstring(
struct cpu *
cpu,
const char *s)
405 arcbios_putchar(
cpu,
'\r');
406 arcbios_putchar(
cpu, *s++);
415 uint64_t scsicontroller_component)
437 uint64_t base, uint64_t len,
int arctype)
439 uint64_t memdesc_addr;
458 case 0: arctype = 0;
break;
459 case 1: arctype = 1;
break;
460 case 2: arctype = 3;
break;
461 case 3: arctype = 4;
break;
462 case 4: arctype = 5;
break;
463 case 5: arctype = 6;
break;
464 case 6: arctype = 7;
break;
465 case 7: arctype = 2;
break;
514 static uint64_t arcbios_addchild(
struct cpu *
cpu,
516 const char *identifier, uint32_t parent)
545 uint32_t eparent, echild, epeer, tmp;
546 unsigned char buf[4];
556 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
557 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
559 epeer = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
566 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
567 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
569 echild = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
576 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
577 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
579 eparent = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
584 if ((uint32_t)eparent == (uint32_t)parent &&
585 (uint32_t)epeer == 0) {
591 if ((uint32_t)peeraddr == (uint32_t)parent &&
592 (uint32_t)echild == 0) {
604 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
605 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
608 tmp = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
611 peeraddr = ((peeraddr - 1) | 3) + 1;
622 65536 * host_tmp_component->
Version);
627 ConfigurationDataSize);
636 if (identifier != NULL)
665 static uint64_t arcbios_addchild64(
struct cpu *
cpu,
667 const char *identifier, uint64_t parent)
696 uint64_t eparent, echild, epeer, tmp;
697 unsigned char buf[8];
707 tmp2 = buf[0]; buf[0] = buf[7]; buf[7] = tmp2;
708 tmp2 = buf[1]; buf[1] = buf[6]; buf[6] = tmp2;
709 tmp2 = buf[2]; buf[2] = buf[5]; buf[5] = tmp2;
710 tmp2 = buf[3]; buf[3] = buf[4]; buf[4] = tmp2;
712 epeer = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24)
713 + ((uint64_t)buf[4] << 32) + ((uint64_t)buf[5] << 40)
714 + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
721 tmp2 = buf[0]; buf[0] = buf[7]; buf[7] = tmp2;
722 tmp2 = buf[1]; buf[1] = buf[6]; buf[6] = tmp2;
723 tmp2 = buf[2]; buf[2] = buf[5]; buf[5] = tmp2;
724 tmp2 = buf[3]; buf[3] = buf[4]; buf[4] = tmp2;
726 echild = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24)
727 + ((uint64_t)buf[4] << 32) + ((uint64_t)buf[5] << 40)
728 + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
735 tmp2 = buf[0]; buf[0] = buf[7]; buf[7] = tmp2;
736 tmp2 = buf[1]; buf[1] = buf[6]; buf[6] = tmp2;
737 tmp2 = buf[2]; buf[2] = buf[5]; buf[5] = tmp2;
738 tmp2 = buf[3]; buf[3] = buf[4]; buf[4] = tmp2;
740 eparent = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24)
741 + ((uint64_t)buf[4] << 32) + ((uint64_t)buf[5] << 40)
742 + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
748 if (eparent == parent && epeer == 0) {
756 if (peeraddr == parent && echild == 0) {
770 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
771 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
773 tmp = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
779 peeraddr = ((peeraddr - 1) | 3) + 1;
791 ((uint64_t)host_tmp_component->
Revision << 16));
795 ConfigurationDataSize);
806 if (identifier != NULL)
831 uint64_t cclass, uint64_t type, uint64_t flags,
832 uint64_t version, uint64_t revision, uint64_t key,
833 uint64_t affinitymask,
const char *identifier, uint64_t parent,
834 void *config_data,
size_t config_len)
841 if (config_data != NULL) {
842 unsigned char *p = (
unsigned char *) config_data;
846 printf(
"fatal error: you need to increase "
847 "MAX_CONFIG_DATA\n");
851 for (i=0; i<config_len; i++) {
852 unsigned char ch = p[i];
881 component.
Class = cclass;
882 component.
Type = type;
883 component.
Flags = flags;
891 if (identifier != NULL) {
895 return arcbios_addchild(
cpu, &component, identifier, parent);
897 component64.
Class = cclass;
898 component64.
Type = type;
899 component64.
Flags = flags;
902 component64.
Key = key;
907 if (identifier != NULL) {
911 return arcbios_addchild64(
cpu, &component64, identifier,
931 static void arcbios_get_msdos_partition_size(
struct machine *
machine,
932 int disk_id,
int disk_type,
int partition_nr, uint64_t *start,
935 int res, i, partition_type, cur_partition = 0;
936 unsigned char sector[512];
937 unsigned char buf[16];
938 uint64_t offset = 0, st;
943 if (partition_nr == 0)
947 *start = 0; *size = 0;
953 sector,
sizeof(sector));
955 fatal(
"[ arcbios_get_msdos_partition_size(): couldn't "
956 "read the disk image, id %i, offset 0x%" PRIx64
" ]\n",
957 disk_id, (uint64_t) offset);
961 if (sector[510] != 0x55 || sector[511] != 0xaa) {
962 fatal(
"[ arcbios_get_msdos_partition_size(): not an "
963 "MSDOS partition table ]\n");
968 for (i=0; i<4; i++) {
970 printf(
" partition %i: ", i+1);
972 printf(
" %02x", sector[446 + i*16 + j]);
977 for (i=0; i<4; i++) {
978 memmove(buf, sector + 446 + 16*i, 16);
980 partition_type = buf[4];
982 if (partition_type == 0)
985 st = (buf[8] + (buf[9] << 8) + (buf[10] << 16) +
986 (buf[11] << 24)) * 512;
991 *size = (buf[12] + (buf[13] << 8) + (buf[14] << 16) +
992 (buf[15] << 24)) * 512;
995 if (partition_type == 5) {
1002 if (cur_partition == partition_nr)
1006 fatal(
"[ partition(%i) NOT found ]\n", partition_nr);
1013 static int arcbios_handle_to_disk_id_and_type(
struct machine *
machine,
1014 int handle,
int *typep)
1031 if (strncmp(s,
"scsi(", 5) != 0 ||
strlen(s) < 13)
1036 cdrom = (s[7] ==
'c');
1037 id = cdrom? atoi(s + 13) : atoi(s + 12);
1046 static void arcbios_handle_to_start_and_size(
struct machine *
machine,
1047 int handle, uint64_t *start, uint64_t *size)
1051 int disk_id, disk_type;
1053 disk_id = arcbios_handle_to_disk_id_and_type(
machine,
1054 handle, &disk_type);
1063 s2 = strstr(s,
"partition(");
1065 int partition_nr = atoi(s2 + 10);
1067 if (partition_nr != 0)
1068 arcbios_get_msdos_partition_size(
machine,
1069 disk_id, disk_type, partition_nr, start, size);
1081 static int arcbios_getfileinformation(
struct cpu *
cpu)
1085 uint64_t start, size;
1087 arcbios_handle_to_start_and_size(
cpu->
machine, handle, &start, &size);
1111 int vector =
cpu->
pc & 0xfff;
1115 debug(
"[ ARCBIOS PRIVATE get nvram table(): TODO ]\n");
1120 debug(
"a0 points to: ");
1123 fatal(
"ARCBIOS: unimplemented PRIVATE vector 0x%x\n", vector);
1162 int vector =
cpu->
pc & 0xfff;
1165 unsigned char buf[40];
1177 if (vector == 0 && (
cpu->
pc & 0xffffffffULL) == 0xbfc00000ULL)
1187 debug(
"[ ARCBIOS Halt() or similar ]\n");
1206 unsigned char tmp; tmp = buf[0];
1207 buf[0] = buf[7]; buf[7] = tmp;
1208 tmp = buf[1]; buf[1] = buf[6];
1210 tmp = buf[2]; buf[2] = buf[5];
1212 tmp = buf[3]; buf[3] = buf[4];
1215 peer = (uint64_t)buf[0] + ((uint64_t)buf[1]<<8)
1216 + ((uint64_t)buf[2]<<16)
1217 + ((uint64_t)buf[3]<<24)
1218 + ((uint64_t)buf[4]<<32)
1219 + ((uint64_t)buf[5]<<40)
1220 + ((uint64_t)buf[6]<<48)
1221 + ((uint64_t)buf[7]<<56);
1224 unsigned char tmp; tmp = buf[0];
1225 buf[0] = buf[3]; buf[3] = tmp;
1226 tmp = buf[1]; buf[1] = buf[2];
1229 peer = buf[0] + (buf[1]<<8) + (buf[2]<<16)
1239 debug(
"[ ARCBIOS GetPeer(node 0x%016" PRIx64
"): 0x%016" PRIx64
1256 unsigned char tmp; tmp = buf[0];
1257 buf[0] = buf[7]; buf[7] = tmp;
1258 tmp = buf[1]; buf[1] = buf[6];
1260 tmp = buf[2]; buf[2] = buf[5];
1262 tmp = buf[3]; buf[3] = buf[4];
1265 child = (uint64_t)buf[0] +
1266 ((uint64_t)buf[1]<<8) +
1267 ((uint64_t)buf[2]<<16) +
1268 ((uint64_t)buf[3]<<24) +
1269 ((uint64_t)buf[4]<<32) +
1270 ((uint64_t)buf[5]<<40) +
1271 ((uint64_t)buf[6]<<48) +
1272 ((uint64_t)buf[7]<<56);
1275 unsigned char tmp; tmp = buf[0];
1276 buf[0] = buf[3]; buf[3] = tmp;
1277 tmp = buf[1]; buf[1] = buf[2];
1280 child = buf[0] + (buf[1]<<8) + (buf[2]<<16) +
1290 debug(
"[ ARCBIOS GetChild(node 0x%016" PRIx64
"): 0x%016"
1305 unsigned char tmp; tmp = buf[0];
1306 buf[0] = buf[7]; buf[7] = tmp;
1307 tmp = buf[1]; buf[1] = buf[6];
1309 tmp = buf[2]; buf[2] = buf[5];
1311 tmp = buf[3]; buf[3] = buf[4];
1314 parent = (uint64_t)buf[0] +
1315 ((uint64_t)buf[1]<<8) +
1316 ((uint64_t)buf[2]<<16) +
1317 ((uint64_t)buf[3]<<24) +
1318 ((uint64_t)buf[4]<<32) +
1319 ((uint64_t)buf[5]<<40) +
1320 ((uint64_t)buf[6]<<48) +
1321 ((uint64_t)buf[7]<<56);
1324 unsigned char tmp; tmp = buf[0];
1325 buf[0] = buf[3]; buf[3] = tmp;
1326 tmp = buf[1]; buf[1] = buf[2];
1329 parent = buf[0] + (buf[1]<<8) +
1330 (buf[2]<<16) + (buf[3]<<24);
1339 debug(
"[ ARCBIOS GetParent(node 0x%016" PRIx64
"): 0x%016"
1357 md.arc->configuration_data_len[i]; j++) {
1361 configuration_data_configdata[i] +
1372 debug(
"[ ARCBIOS GetComponent(\"");
1377 fatal(
"[ ARCBIOS GetComponent: NULL ptr ]\n");
1379 unsigned char buf2[500];
1380 int match_index = -1;
1383 memset(buf2, 0,
sizeof(buf2));
1384 for (i=0; i<(ssize_t)
sizeof(buf2); i++) {
1388 if (buf2[i] ==
'\0')
1391 buf2[
sizeof(buf2) - 1] =
'\0';
1404 string_to_component[i][m] &&
1408 if (m > match_len) {
1414 if (match_index >= 0) {
1425 debug(
"[ ARCBIOS GetSystemId() ]\n");
1429 debug(
"[ ARCBIOS GetMemoryDescriptor(0x%08x) ]\n",
1439 : sizeof(struct arcbios_mem);
1441 machine->md.arc->memdescriptor_base;
1445 machine->md.arc->memdescriptor_base + s * nr;
1446 if (nr >=
machine->md.arc->n_memdescriptors)
1451 debug("[ ARCBIOS GetTime() ]\n");
1456 debug("[ ARCBIOS GetRelativeTime() ]\n");
1460 debug("[ ARCBIOS Open(\"");
1470 while (machine->md.arc->file_handle_in_use[handle]) {
1479 fatal(
"[ ARCBIOS Open: out of file handles ]\n");
1481 fatal(
"[ ARCBIOS Open: NULL ptr ]\n");
1488 unsigned char *buf2;
1495 if (buf2[i] ==
'\0')
1506 debug(
" = handle %i ]\n", (
int)handle);
1511 debug(
" = ERROR %i ]\n",
1515 debug(
"[ ARCBIOS Close(%i) ]\n",
1519 fatal(
"ARCBIOS Close(%i): bad handle\n",
1539 int j2, nread = 0, a2;
1554 for (j2=0; j2<a2; j2++) {
1575 if (x ==
'[' || x ==
'O')
1597 int disk_id = arcbios_handle_to_disk_id_and_type(
1598 machine, handleTmp, &disk_type);
1599 uint64_t partition_offset = 0;
1602 unsigned char *tmp_buf;
1604 arcbios_handle_to_start_and_size(
machine, handleTmp,
1605 &partition_offset, &size);
1607 debug(
"[ ARCBIOS Read(%i,0x%08x,0x%08x,0x%08x) ]\n",
1618 current_seek_offset[handleTmp], tmp_buf,
1650 fatal(
"[ ARCBIOS GetReadStatus(%i) from "
1651 "something other than STDIN: TODO ]\n",
1664 int disk_id = arcbios_handle_to_disk_id_and_type(
1665 machine, handleTmp, &disk_type);
1666 uint64_t partition_offset = 0;
1669 unsigned char *tmp_buf;
1671 arcbios_handle_to_start_and_size(
machine,
1672 handleTmp, &partition_offset, &size);
1674 debug(
"[ ARCBIOS Write(%i,0x%08" PRIx64
",%i,0x%08"
1686 &tmp_buf[tmpi],
sizeof(
char),
MEM_READ,
1691 current_seek_offset[handleTmp], tmp_buf,
1707 unsigned char ch =
'\0';
1712 arcbios_putchar(
cpu, ch);
1721 debug(
"[ ARCBIOS Seek(%i,0x%08" PRIx64
",%i): ",
1727 fatal(
"[ ARCBIOS Seek(%i,0x%08" PRIx64
",%i): "
1728 "UNIMPLEMENTED whence=%i ]\n",
1736 unsigned char bufTmp[8];
1743 tmp = bufTmp[0]; bufTmp[0] = bufTmp[7]; bufTmp[7] = tmp;
1744 tmp = bufTmp[1]; bufTmp[1] = bufTmp[6]; bufTmp[6] = tmp;
1745 tmp = bufTmp[2]; bufTmp[2] = bufTmp[5]; bufTmp[5] = tmp;
1746 tmp = bufTmp[3]; bufTmp[3] = bufTmp[4]; bufTmp[4] = tmp;
1748 ofs = bufTmp[0] + (bufTmp[1] << 8) + (bufTmp[2] << 16) +
1749 (bufTmp[3] << 24) + ((uint64_t)bufTmp[4] << 32) +
1750 ((uint64_t)bufTmp[5] << 40) + ((uint64_t)bufTmp[6] << 48)
1751 + ((uint64_t)bufTmp[7] << 56);
1755 debug(
"%016" PRIx64
" ]\n", (uint64_t) ofs);
1763 for (i=0; i<(ssize_t)
sizeof(buf); i++)
1767 buf[
sizeof(buf)-1] =
'\0';
1768 debug(
"[ ARCBIOS GetEnvironmentVariable(\"%s\") ]\n", buf);
1769 for (i=0; i<0x1000; i++) {
1773 for (j=0; j<(ssize_t)
strlen((
char *)buf); j++) {
1775 (uint64_t)(envptr + i + j),
1781 (uint64_t)(envptr + i +
1782 strlen((
char *)buf)), &ch2,
sizeof(
char),
1784 if (nmatches == (
int)
strlen((
char *)buf) && ch2==
'=') {
1795 debug(
"[ ARCBIOS SetEnvironmentVariable(\"");
1804 debug(
"[ ARCBIOS GetFileInformation(%i,0x%x): ",
1809 debug(
"invalid file handle ]\n");
1813 debug(
"file handle not in use! ]\n");
1819 arcbios_getfileinformation(
cpu);
1823 debug(
"[ ARCBIOS FlushAllCaches(): TODO ]\n");
1827 debug(
"[ ARCBIOS GetDisplayStatus(%i) ]\n",
1836 debug(
"[ ARCBIOS: IRIX 0x100 (?) ]\n");
1844 fatal(
"EXCEPTION, but no exception handler installed yet.\n");
1852 debug(
"a0 points to: ");
1855 fatal(
"ARCBIOS: unimplemented vector 0x%x\n", vector);
1900 static void arcbios_add_other_components(
struct machine *
machine,
1908 uint64_t jazzbus, ali_s3, vxl;
1909 uint64_t diskcontroller, floppy, kbdctl, kbd;
1910 uint64_t ptrctl, ptr, paral, audio;
1911 uint64_t eisa, scsi;
1917 0, 1, 2, 0, 0xffffffff,
"Jazz-Internal Bus",
1931 0xffffffffe1000000ULL,
1932 0x0fff00000ULL, 0, 1, 0, 0, 0, 1, 0, 2, 0);
1937 0xffffffffe0000000ULL,
1938 0x080000000ULL, 0, 1, 0, 1, 0, 1, 0, 2, 0);
1943 (uint64_t)0xffffffffe00e0000ULL,
1944 (uint64_t)0x0800e0000ULL,
1945 (uint64_t)0x0800f0000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1950 (uint64_t)0xffffffffe0100000ULL,
1951 (uint64_t)0x0f0000000ULL, 0,1, 0, 1, 0, 1, 0, 2, 0);
1956 0xffffffffe0200000ULL,
1957 0x060000000ULL, 0x060100000ULL,1,1,1,1,1, 0, 2, 2);
1962 0xffffffffe0400000ULL, 0x060200000ULL,
1963 0x060300000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1968 0xffffffffe0800000ULL, 0x040000000ULL,
1969 0x040400000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1974 0xffffffffe2000000ULL, 0x090000000ULL,
1975 0x091000000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1983 1, 2, 0, 0xffffffff,
"ALI_S3",
1991 1, 2, 0, 0xffffffff,
"1024x768",
2002 1, 2, 0, 0xffffffff,
"VXL",
2010 1, 2, 0, 0xffffffff,
"1024x768",
2020 1, 2, 0, 0xffffffff,
"I82077", jazzbus, NULL, 0);
2027 1, 2, 0, 0xffffffff, NULL, diskcontroller, NULL, 0);
2033 1, 2, 0, 0xffffffff,
"I8742", jazzbus, NULL, 0);
2039 1, 2, 0, 0xffffffff,
"PCAT_ENHANCED", kbdctl, NULL, 0);
2044 1, 2, 0, 0xffffffff,
"I8742", jazzbus, NULL, 0);
2049 1, 2, 0, 0xffffffff,
"PS2 MOUSE", ptrctl, NULL, 0);
2057 1, 2, 0, 0xffffffff,
"COM1", jazzbus, NULL, 0);
2063 1, 2, 0, 0xffffffff,
"COM1", jazzbus, NULL, 0);
2070 1, 2, 0, 0xffffffff,
"LPT1", jazzbus, NULL, 0);
2076 1, 2, 0, 0xffffffff,
"MAGNUM", jazzbus, NULL, 0);
2080 0, 1, 2, 0, 0xffffffff,
"EISA", system, NULL, 0);
2083 unsigned char config[78];
2084 memset(config, 0,
sizeof(config));
2087 config[0] = 0x01; config[1] = 0x00;
2088 config[2] = 0x02; config[3] = 0x00;
2089 config[4] = 0x04; config[5] = 0x00; config[6] = 0x00; config[7] = 0x00;
2111 config[28] = 0x00; config[29] = 0x20; config[30] = 0x00; config[31] = 0x80;
2112 config[32] = 0x00; config[33] = 0x00; config[34] = 0x00; config[35] = 0x00;
2113 config[36] = 0x00; config[37] = 0x10; config[38] = 0x00; config[39] = 0x00;
2135 config[72] = 0x01; config[73] = 0x00; config[74] = 0x02;
2136 config[75] = 0x00; config[76] = 0x07; config[77] = 0x30;
2140 0, 1, 2, 0, 0xffffffff,
"ESP216",
2141 system, config,
sizeof(config));
2156 uint64_t vram, uint64_t ctrlregs)
2180 static void arc_environment_setup(
struct machine *
machine,
int is64bit,
2181 const char *primary_ether_addr)
2183 size_t bootpath_len = 500;
2184 char *init_bootpath;
2185 uint64_t
addr, addr2;
2195 init_bootpath[0] =
'\0';
2198 snprintf(init_bootpath, bootpath_len,
"tftp()");
2203 strlcat(init_bootpath,
"xio(0)pci(15)",
2206 strlcat(init_bootpath,
"pci(0)",
2212 snprintf(init_bootpath +
strlen(init_bootpath),
2213 bootpath_len -
strlen(init_bootpath),
2216 snprintf(init_bootpath +
strlen(init_bootpath),
2217 bootpath_len -
strlen(init_bootpath),
2218 "scsi(0)disk(%i)rdisk(0)partition(1)",
2223 strlcat(init_bootpath,
"\\", bootpath_len);
2230 fprintf(stderr,
"boot string too long?\n");
2343 "SystemPartition=bootp()10.0.0.2:/var/boot/client",
2351 "OSLoadPartition=bootp()10.0.0.2:/var/boot/client",
2359 "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)",
2363 "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)",
2434 "OSLOADPARTITION=scsi(0)disk(%d)rdisk(0)partition(1)",
2442 "CONSOLEIN=multi()key()keyboard()console()", &
addr);
2445 "CONSOLEOUT=multi()video()monitor()console()",
2451 "CONSOLEIN=multi()serial(0)", &
addr);
2454 "CONSOLEOUT=multi()serial(0)", &
addr);
2477 const char *primary_ether_addr, uint8_t *primary_ether_macaddr)
2479 int i, alloclen = 20;
2481 uint64_t arc_reserved, mem_base, mem_count;
2485 uint64_t system = 0;
2502 fprintf(stderr,
"WARNING! The ARC platform specification "
2503 "doesn't allow less than 16 MB of RAM. Continuing "
2510 (i==0?
"(stdin)" : (i==1?
"(stdout)" :
"(stderr)"));
2524 arcbios_putcell(
cpu,
' ', x, y);
2529 arcbios_putstring(
cpu,
"GXemul " VERSION
" ARCBIOS emulation\n");
2531 snprintf(tmpstr,
sizeof(tmpstr),
"%i cpu%s (%s), %i MB "
2535 arcbios_putstring(
cpu, tmpstr);
2568 fatal(
"error in machine.c sysid\n");
2592 arc_reserved = 0x2000;
2594 arc_reserved = 0x4000;
2602 mem_base += sgi_ram_offset / 1048576;
2604 while (mem_base < machine->physical_ram_in_mb+sgi_ram_offset/1048576) {
2609 if (mem_base < 256 && mem_base + mem_count > 256) {
2610 mem_count = 256-mem_base;
2615 if (mem_count > 512)
2621 mem_base += mem_count;
2624 if (mem_base == 256)
2646 fatal(
"ERROR: machine_name == NULL\n");
2652 snprintf(name, alloclen,
"SGI-IP%i",
2658 snprintf(name, alloclen,
"SGI-IP22");
2664 name = strdup(
"PICA-61");
2667 name = strdup(
"Microsoft-Jazz");
2670 fatal(
"Unimplemented ARC machine type %i\n",
2676 fatal(
"ERROR: non-SGI and non-ARC?\n");
2682 debug(
"ARC system @ 0x%" PRIx64
" (\"%s\")\n", (uint64_t) system, name);
2690 uint64_t cpuaddr, fpu=0, picache, pdcache, sdcache=0;
2691 int cache_size, cache_line_size;
2693 char arc_cpu_name[100];
2694 char arc_fpc_name[105];
2696 snprintf(arc_cpu_name,
sizeof(arc_cpu_name),
2699 arc_cpu_name[
sizeof(arc_cpu_name)-1] = 0;
2700 for (jj=0; jj<
strlen(arc_cpu_name); jj++)
2701 if (arc_cpu_name[jj] >=
'a' && arc_cpu_name[jj] <=
'z')
2702 arc_cpu_name[jj] += (
'A' -
'a');
2704 strlcpy(arc_fpc_name, arc_cpu_name,
sizeof(arc_fpc_name));
2705 strlcat(arc_fpc_name,
"FPC",
sizeof(arc_fpc_name));
2709 0, 1, 2, i, 0xffffffff, arc_cpu_name, system, NULL, 0);
2718 0, 1, 2, 0, 0xffffffff, arc_fpc_name, cpuaddr,
2730 if (cache_line_size < 0)
2731 cache_line_size = 0;
2742 0x01000000 + (cache_line_size << 16) + cache_size,
2744 0xffffffff, NULL, cpuaddr, NULL, 0);
2755 if (cache_line_size < 0)
2756 cache_line_size = 0;
2766 0x01000000 + (cache_line_size << 16) + cache_size,
2768 0xffffffff, NULL, cpuaddr, NULL, 0);
2773 cache_line_size = 6;
2776 cache_secondary_linesize;
2777 if (cache_line_size < 0)
2778 cache_line_size = 0;
2788 0x01000000 + (cache_line_size << 16) + cache_size,
2790 0xffffffff, NULL, cpuaddr, NULL, 0);
2793 debug(
"ARC cpu%i @ 0x%" PRIx64, i, (uint64_t) cpuaddr);
2796 debug(
" (fpu @ 0x%" PRIx64
")\n", (uint64_t) fpu);
2800 debug(
" picache @ 0x%" PRIx64
", pdcache @ 0x%" PRIx64
"\n",
2801 (uint64_t) picache, (uint64_t) pdcache);
2804 debug(
" sdcache @ 0x%" PRIx64
"\n",
2805 (uint64_t) sdcache);
2812 0xffffffff,
"memory", cpuaddr, NULL, 0);
2813 debug(
"ARC memory @ 0x%" PRIx64
"\n", (uint64_t)
memory);
2825 arcbios_add_other_components(
machine, system);
2835 0xc000000000000000ULL, 0, 1048576*16, 1,1,1,1,1, 0, 2, 2);
2845 for (i=0; i<100; i++) {
2918 arc_environment_setup(
machine, is64bit, primary_ether_addr);