37 #include <sys/types.h>
38 #include <sys/resource.h>
61 char *str, uint64_t component)
65 printf(
"Too many string-to-component mappings.\n");
72 debug(
"adding ARC component mapping: 0x%08x = %s\n",
87 static void arcbios_get_dsp_stat(
struct cpu *
cpu,
108 static void arcbios_putcell(
struct cpu *
cpu,
int ch,
int x,
int y)
110 unsigned char buf[2];
114 buf[1] = ((buf[1] & 0x70) >> 4) | ((buf[1] & 7) << 4)
128 static void handle_esc_seq(
struct cpu *
cpu)
131 int row, col, color, code, start, stop;
199 default:
fatal(
"{ handle_esc_seq: color %i }\n", color);
222 if (i != 0 && i != 2)
223 fatal(
"{ handle_esc_seq(): %iJ }\n", i);
227 arcbios_putcell(
cpu,
' ', col,
232 arcbios_putcell(
cpu,
' ', col, row);
242 for (i=start; i<=stop; i++)
243 arcbios_putcell(
cpu,
' ', i,
249 fatal(
"{ handle_esc_seq(): unimplemented escape sequence: ");
250 for (i=0; i<len; i++) {
255 if (x >=
' ' && x < 127)
258 fatal(
"[0x%02x]", x);
267 static void scroll_if_necessary(
struct cpu *
cpu)
272 unsigned char buf[2];
280 console_maxx * (y+1)),
295 arcbios_putcell(
cpu,
' ', x,
307 static void arcbios_putchar(
struct cpu *
cpu,
int ch)
331 if ((ch >=
'a' && ch <=
'z') ||
340 }
else if (ch == 0x9b) {
344 }
else if (ch ==
'\b') {
347 }
else if (ch ==
'\r') {
349 }
else if (ch ==
'\n') {
351 }
else if (ch ==
'\t') {
362 scroll_if_necessary(
cpu);
364 arcbios_putcell(
cpu, ch,
371 scroll_if_necessary(
cpu);
382 console_ctrlregs + 0x14,
384 byte = (
addr >> 8) & 255;
386 console_ctrlregs + 0x15,
390 console_ctrlregs + 0x14,
394 console_ctrlregs + 0x15,
402 static void arcbios_putstring(
struct cpu *
cpu,
const char *s)
406 arcbios_putchar(
cpu,
'\r');
407 arcbios_putchar(
cpu, *s++);
416 uint64_t scsicontroller_component)
438 uint64_t base, uint64_t len,
int arctype)
440 uint64_t memdesc_addr;
446 debug(
"arcbios_add_memory_descriptor: base=0x%llx len=0x%llx arctype=%i\n",
447 (
long long)base, (
long long)len, arctype);
463 case 0: arctype = 0;
break;
464 case 1: arctype = 1;
break;
465 case 2: arctype = 3;
break;
466 case 3: arctype = 4;
break;
467 case 4: arctype = 5;
break;
468 case 5: arctype = 6;
break;
469 case 6: arctype = 7;
break;
470 case 7: arctype = 2;
break;
519 static uint64_t arcbios_addchild(
struct cpu *
cpu,
521 const char *identifier, uint32_t parent)
550 uint32_t eparent, echild, epeer, tmp;
551 unsigned char buf[4];
561 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
562 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
564 epeer = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
571 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
572 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
574 echild = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
581 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
582 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
584 eparent = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
589 if ((uint32_t)eparent == (uint32_t)parent &&
590 (uint32_t)epeer == 0) {
596 if ((uint32_t)peeraddr == (uint32_t)parent &&
597 (uint32_t)echild == 0) {
609 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
610 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
613 tmp = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
616 peeraddr = ((peeraddr - 1) | 3) + 1;
627 65536 * host_tmp_component->
Version);
632 ConfigurationDataSize);
641 if (identifier != NULL)
670 static uint64_t arcbios_addchild64(
struct cpu *
cpu,
672 const char *identifier, uint64_t parent)
701 uint64_t eparent, echild, epeer, tmp;
702 unsigned char buf[8];
712 tmp2 = buf[0]; buf[0] = buf[7]; buf[7] = tmp2;
713 tmp2 = buf[1]; buf[1] = buf[6]; buf[6] = tmp2;
714 tmp2 = buf[2]; buf[2] = buf[5]; buf[5] = tmp2;
715 tmp2 = buf[3]; buf[3] = buf[4]; buf[4] = tmp2;
717 epeer = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24)
718 + ((uint64_t)buf[4] << 32) + ((uint64_t)buf[5] << 40)
719 + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
726 tmp2 = buf[0]; buf[0] = buf[7]; buf[7] = tmp2;
727 tmp2 = buf[1]; buf[1] = buf[6]; buf[6] = tmp2;
728 tmp2 = buf[2]; buf[2] = buf[5]; buf[5] = tmp2;
729 tmp2 = buf[3]; buf[3] = buf[4]; buf[4] = tmp2;
731 echild = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24)
732 + ((uint64_t)buf[4] << 32) + ((uint64_t)buf[5] << 40)
733 + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
740 tmp2 = buf[0]; buf[0] = buf[7]; buf[7] = tmp2;
741 tmp2 = buf[1]; buf[1] = buf[6]; buf[6] = tmp2;
742 tmp2 = buf[2]; buf[2] = buf[5]; buf[5] = tmp2;
743 tmp2 = buf[3]; buf[3] = buf[4]; buf[4] = tmp2;
745 eparent = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24)
746 + ((uint64_t)buf[4] << 32) + ((uint64_t)buf[5] << 40)
747 + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
753 if (eparent == parent && epeer == 0) {
761 if (peeraddr == parent && echild == 0) {
775 tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
776 tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
778 tmp = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
784 peeraddr = ((peeraddr - 1) | 3) + 1;
796 ((uint64_t)host_tmp_component->
Revision << 16));
800 ConfigurationDataSize);
811 if (identifier != NULL)
836 uint64_t cclass, uint64_t type, uint64_t flags,
837 uint64_t version, uint64_t revision, uint64_t key,
838 uint64_t affinitymask,
const char *identifier, uint64_t parent,
839 void *config_data,
size_t config_len)
846 if (config_data != NULL) {
847 unsigned char *p = (
unsigned char *) config_data;
851 printf(
"fatal error: you need to increase "
852 "MAX_CONFIG_DATA\n");
856 for (i=0; i<config_len; i++) {
857 unsigned char ch = p[i];
886 component.
Class = cclass;
887 component.
Type = type;
888 component.
Flags = flags;
896 if (identifier != NULL) {
900 return arcbios_addchild(
cpu, &component, identifier, parent);
902 component64.
Class = cclass;
903 component64.
Type = type;
904 component64.
Flags = flags;
907 component64.
Key = key;
912 if (identifier != NULL) {
916 return arcbios_addchild64(
cpu, &component64, identifier,
936 static void arcbios_get_msdos_partition_size(
struct machine *
machine,
937 int disk_id,
int disk_type,
int partition_nr, uint64_t *start,
940 int res, i, partition_type, cur_partition = 0;
941 unsigned char sector[512];
942 unsigned char buf[16];
943 uint64_t offset = 0, st;
948 if (partition_nr == 0)
952 *start = 0; *size = 0;
958 sector,
sizeof(sector));
960 fatal(
"[ arcbios_get_msdos_partition_size(): couldn't "
961 "read the disk image, id %i, offset 0x%" PRIx64
" ]\n",
962 disk_id, (uint64_t) offset);
966 if (sector[510] != 0x55 || sector[511] != 0xaa) {
967 fatal(
"[ arcbios_get_msdos_partition_size(): not an "
968 "MSDOS partition table ]\n");
973 for (i=0; i<4; i++) {
975 printf(
" partition %i: ", i+1);
977 printf(
" %02x", sector[446 + i*16 + j]);
982 for (i=0; i<4; i++) {
983 memmove(buf, sector + 446 + 16*i, 16);
985 partition_type = buf[4];
987 if (partition_type == 0)
990 st = (buf[8] + (buf[9] << 8) + (buf[10] << 16) +
991 (buf[11] << 24)) * 512;
996 *size = (buf[12] + (buf[13] << 8) + (buf[14] << 16) +
997 (buf[15] << 24)) * 512;
1000 if (partition_type == 5) {
1007 if (cur_partition == partition_nr)
1011 fatal(
"[ partition(%i) NOT found ]\n", partition_nr);
1018 static int arcbios_handle_to_disk_id_and_type(
struct machine *
machine,
1019 int handle,
int *typep)
1036 if (strncmp(s,
"scsi(", 5) != 0 ||
strlen(s) < 13)
1041 cdrom = (s[7] ==
'c');
1042 id = cdrom? atoi(s + 13) : atoi(s + 12);
1051 static void arcbios_handle_to_start_and_size(
struct machine *
machine,
1052 int handle, uint64_t *start, uint64_t *size)
1056 int disk_id, disk_type;
1058 disk_id = arcbios_handle_to_disk_id_and_type(
machine,
1059 handle, &disk_type);
1068 s2 = strstr(s,
"partition(");
1070 int partition_nr = atoi(s2 + 10);
1072 if (partition_nr != 0)
1073 arcbios_get_msdos_partition_size(
machine,
1074 disk_id, disk_type, partition_nr, start, size);
1086 static int arcbios_getfileinformation(
struct cpu *
cpu)
1090 uint64_t start, size;
1092 arcbios_handle_to_start_and_size(
cpu->
machine, handle, &start, &size);
1116 int vector =
cpu->
pc & 0xfff;
1120 debug(
"[ ARCBIOS PRIVATE get nvram table(): TODO ]\n");
1125 debug(
"a0 points to: ");
1128 fatal(
"ARCBIOS: unimplemented PRIVATE vector 0x%x\n", vector);
1167 int vector =
cpu->
pc & 0xfff;
1170 unsigned char buf[40];
1182 if (vector == 0 && (
cpu->
pc & 0xffffffffULL) == 0xbfc00000ULL)
1192 debug(
"[ ARCBIOS Halt() or similar ]\n");
1211 unsigned char tmp; tmp = buf[0];
1212 buf[0] = buf[7]; buf[7] = tmp;
1213 tmp = buf[1]; buf[1] = buf[6];
1215 tmp = buf[2]; buf[2] = buf[5];
1217 tmp = buf[3]; buf[3] = buf[4];
1220 peer = (uint64_t)buf[0] + ((uint64_t)buf[1]<<8)
1221 + ((uint64_t)buf[2]<<16)
1222 + ((uint64_t)buf[3]<<24)
1223 + ((uint64_t)buf[4]<<32)
1224 + ((uint64_t)buf[5]<<40)
1225 + ((uint64_t)buf[6]<<48)
1226 + ((uint64_t)buf[7]<<56);
1229 unsigned char tmp; tmp = buf[0];
1230 buf[0] = buf[3]; buf[3] = tmp;
1231 tmp = buf[1]; buf[1] = buf[2];
1234 peer = buf[0] + (buf[1]<<8) + (buf[2]<<16)
1244 debug(
"[ ARCBIOS GetPeer(node 0x%016" PRIx64
"): 0x%016" PRIx64
1261 unsigned char tmp; tmp = buf[0];
1262 buf[0] = buf[7]; buf[7] = tmp;
1263 tmp = buf[1]; buf[1] = buf[6];
1265 tmp = buf[2]; buf[2] = buf[5];
1267 tmp = buf[3]; buf[3] = buf[4];
1270 child = (uint64_t)buf[0] +
1271 ((uint64_t)buf[1]<<8) +
1272 ((uint64_t)buf[2]<<16) +
1273 ((uint64_t)buf[3]<<24) +
1274 ((uint64_t)buf[4]<<32) +
1275 ((uint64_t)buf[5]<<40) +
1276 ((uint64_t)buf[6]<<48) +
1277 ((uint64_t)buf[7]<<56);
1280 unsigned char tmp; tmp = buf[0];
1281 buf[0] = buf[3]; buf[3] = tmp;
1282 tmp = buf[1]; buf[1] = buf[2];
1285 child = buf[0] + (buf[1]<<8) + (buf[2]<<16) +
1295 debug(
"[ ARCBIOS GetChild(node 0x%016" PRIx64
"): 0x%016"
1310 unsigned char tmp; tmp = buf[0];
1311 buf[0] = buf[7]; buf[7] = tmp;
1312 tmp = buf[1]; buf[1] = buf[6];
1314 tmp = buf[2]; buf[2] = buf[5];
1316 tmp = buf[3]; buf[3] = buf[4];
1319 parent = (uint64_t)buf[0] +
1320 ((uint64_t)buf[1]<<8) +
1321 ((uint64_t)buf[2]<<16) +
1322 ((uint64_t)buf[3]<<24) +
1323 ((uint64_t)buf[4]<<32) +
1324 ((uint64_t)buf[5]<<40) +
1325 ((uint64_t)buf[6]<<48) +
1326 ((uint64_t)buf[7]<<56);
1329 unsigned char tmp; tmp = buf[0];
1330 buf[0] = buf[3]; buf[3] = tmp;
1331 tmp = buf[1]; buf[1] = buf[2];
1334 parent = buf[0] + (buf[1]<<8) +
1335 (buf[2]<<16) + (buf[3]<<24);
1344 debug(
"[ ARCBIOS GetParent(node 0x%016" PRIx64
"): 0x%016"
1362 md.arc->configuration_data_len[i]; j++) {
1366 configuration_data_configdata[i] +
1377 debug(
"[ ARCBIOS GetComponent(\"");
1382 fatal(
"[ ARCBIOS GetComponent: NULL ptr ]\n");
1384 unsigned char buf2[500];
1385 int match_index = -1;
1388 memset(buf2, 0,
sizeof(buf2));
1389 for (i=0; i<(ssize_t)
sizeof(buf2); i++) {
1393 if (buf2[i] ==
'\0')
1396 buf2[
sizeof(buf2) - 1] =
'\0';
1409 string_to_component[i][m] &&
1413 if (m > match_len) {
1419 if (match_index >= 0) {
1430 debug(
"[ ARCBIOS GetSystemId() ]\n");
1434 debug(
"[ ARCBIOS GetMemoryDescriptor(0x%08x) ]\n",
1444 : sizeof(struct arcbios_mem);
1446 machine->md.arc->memdescriptor_base;
1450 machine->md.arc->memdescriptor_base + s * nr;
1451 if (nr >=
machine->md.arc->n_memdescriptors)
1456 debug("[ ARCBIOS GetTime() ]\n");
1461 debug("[ ARCBIOS GetRelativeTime() ]\n");
1465 debug("[ ARCBIOS Open(\"");
1475 while (machine->md.arc->file_handle_in_use[handle]) {
1484 fatal(
"[ ARCBIOS Open: out of file handles ]\n");
1486 fatal(
"[ ARCBIOS Open: NULL ptr ]\n");
1493 unsigned char *buf2;
1500 if (buf2[i] ==
'\0')
1511 debug(
" = handle %i ]\n", (
int)handle);
1516 debug(
" = ERROR %i ]\n",
1520 debug(
"[ ARCBIOS Close(%i) ]\n",
1524 fatal(
"ARCBIOS Close(%i): bad handle\n",
1544 int j2, nread = 0, a2;
1559 for (j2=0; j2<a2; j2++) {
1580 if (x ==
'[' || x ==
'O')
1602 int disk_id = arcbios_handle_to_disk_id_and_type(
1603 machine, handleTmp, &disk_type);
1604 uint64_t partition_offset = 0;
1607 unsigned char *tmp_buf;
1609 arcbios_handle_to_start_and_size(
machine, handleTmp,
1610 &partition_offset, &size);
1612 debug(
"[ ARCBIOS Read(%i,0x%08x,0x%08x,0x%08x) ]\n",
1623 current_seek_offset[handleTmp], tmp_buf,
1655 fatal(
"[ ARCBIOS GetReadStatus(%i) from "
1656 "something other than STDIN: TODO ]\n",
1669 int disk_id = arcbios_handle_to_disk_id_and_type(
1670 machine, handleTmp, &disk_type);
1671 uint64_t partition_offset = 0;
1674 unsigned char *tmp_buf;
1676 arcbios_handle_to_start_and_size(
machine,
1677 handleTmp, &partition_offset, &size);
1679 debug(
"[ ARCBIOS Write(%i,0x%08" PRIx64
",%i,0x%08"
1691 &tmp_buf[tmpi],
sizeof(
char),
MEM_READ,
1696 current_seek_offset[handleTmp], tmp_buf,
1712 unsigned char ch =
'\0';
1717 arcbios_putchar(
cpu, ch);
1726 debug(
"[ ARCBIOS Seek(%i,0x%08" PRIx64
",%i): ",
1732 fatal(
"[ ARCBIOS Seek(%i,0x%08" PRIx64
",%i): "
1733 "UNIMPLEMENTED whence=%i ]\n",
1741 unsigned char bufTmp[8];
1748 tmp = bufTmp[0]; bufTmp[0] = bufTmp[7]; bufTmp[7] = tmp;
1749 tmp = bufTmp[1]; bufTmp[1] = bufTmp[6]; bufTmp[6] = tmp;
1750 tmp = bufTmp[2]; bufTmp[2] = bufTmp[5]; bufTmp[5] = tmp;
1751 tmp = bufTmp[3]; bufTmp[3] = bufTmp[4]; bufTmp[4] = tmp;
1753 ofs = bufTmp[0] + (bufTmp[1] << 8) + (bufTmp[2] << 16) +
1754 (bufTmp[3] << 24) + ((uint64_t)bufTmp[4] << 32) +
1755 ((uint64_t)bufTmp[5] << 40) + ((uint64_t)bufTmp[6] << 48)
1756 + ((uint64_t)bufTmp[7] << 56);
1760 debug(
"%016" PRIx64
" ]\n", (uint64_t) ofs);
1768 for (i=0; i<(ssize_t)
sizeof(buf); i++)
1772 buf[
sizeof(buf)-1] =
'\0';
1773 debug(
"[ ARCBIOS GetEnvironmentVariable(\"%s\") ]\n", buf);
1774 for (i=0; i<0x1000; i++) {
1778 for (j=0; j<(ssize_t)
strlen((
char *)buf); j++) {
1780 (uint64_t)(envptr + i + j),
1786 (uint64_t)(envptr + i +
1787 strlen((
char *)buf)), &ch2,
sizeof(
char),
1789 if (nmatches == (
int)
strlen((
char *)buf) && ch2==
'=') {
1800 debug(
"[ ARCBIOS SetEnvironmentVariable(\"");
1809 debug(
"[ ARCBIOS GetFileInformation(%i,0x%x): ",
1814 debug(
"invalid file handle ]\n");
1818 debug(
"file handle not in use! ]\n");
1824 arcbios_getfileinformation(
cpu);
1828 debug(
"[ ARCBIOS FlushAllCaches(): TODO ]\n");
1832 debug(
"[ ARCBIOS GetDisplayStatus(%i) ]\n",
1841 debug(
"[ ARCBIOS: IRIX 0x100 (?) ]\n");
1849 fatal(
"EXCEPTION, but no exception handler installed yet.\n");
1857 debug(
"a0 points to: ");
1860 fatal(
"ARCBIOS: unimplemented vector 0x%x\n", vector);
1905 static void arcbios_add_other_components(
struct machine *
machine,
1913 uint64_t jazzbus, ali_s3, vxl;
1914 uint64_t diskcontroller, floppy, kbdctl, kbd;
1915 uint64_t ptrctl, ptr, paral, audio;
1916 uint64_t eisa, scsi;
1922 0, 1, 2, 0, 0xffffffff,
"Jazz-Internal Bus",
1936 0xffffffffe1000000ULL,
1937 0x0fff00000ULL, 0, 1, 0, 0, 0, 1, 0, 2, 0);
1942 0xffffffffe0000000ULL,
1943 0x080000000ULL, 0, 1, 0, 1, 0, 1, 0, 2, 0);
1948 (uint64_t)0xffffffffe00e0000ULL,
1949 (uint64_t)0x0800e0000ULL,
1950 (uint64_t)0x0800f0000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1955 (uint64_t)0xffffffffe0100000ULL,
1956 (uint64_t)0x0f0000000ULL, 0,1, 0, 1, 0, 1, 0, 2, 0);
1961 0xffffffffe0200000ULL,
1962 0x060000000ULL, 0x060100000ULL,1,1,1,1,1, 0, 2, 2);
1967 0xffffffffe0400000ULL, 0x060200000ULL,
1968 0x060300000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1973 0xffffffffe0800000ULL, 0x040000000ULL,
1974 0x040400000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1979 0xffffffffe2000000ULL, 0x090000000ULL,
1980 0x091000000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1988 1, 2, 0, 0xffffffff,
"ALI_S3",
1996 1, 2, 0, 0xffffffff,
"1024x768",
2007 1, 2, 0, 0xffffffff,
"VXL",
2015 1, 2, 0, 0xffffffff,
"1024x768",
2025 1, 2, 0, 0xffffffff,
"I82077", jazzbus, NULL, 0);
2032 1, 2, 0, 0xffffffff, NULL, diskcontroller, NULL, 0);
2038 1, 2, 0, 0xffffffff,
"I8742", jazzbus, NULL, 0);
2044 1, 2, 0, 0xffffffff,
"PCAT_ENHANCED", kbdctl, NULL, 0);
2049 1, 2, 0, 0xffffffff,
"I8742", jazzbus, NULL, 0);
2054 1, 2, 0, 0xffffffff,
"PS2 MOUSE", ptrctl, NULL, 0);
2062 1, 2, 0, 0xffffffff,
"COM1", jazzbus, NULL, 0);
2068 1, 2, 0, 0xffffffff,
"COM1", jazzbus, NULL, 0);
2075 1, 2, 0, 0xffffffff,
"LPT1", jazzbus, NULL, 0);
2081 1, 2, 0, 0xffffffff,
"MAGNUM", jazzbus, NULL, 0);
2085 0, 1, 2, 0, 0xffffffff,
"EISA", system, NULL, 0);
2088 unsigned char config[78];
2089 memset(config, 0,
sizeof(config));
2092 config[0] = 0x01; config[1] = 0x00;
2093 config[2] = 0x02; config[3] = 0x00;
2094 config[4] = 0x04; config[5] = 0x00; config[6] = 0x00; config[7] = 0x00;
2116 config[28] = 0x00; config[29] = 0x20; config[30] = 0x00; config[31] = 0x80;
2117 config[32] = 0x00; config[33] = 0x00; config[34] = 0x00; config[35] = 0x00;
2118 config[36] = 0x00; config[37] = 0x10; config[38] = 0x00; config[39] = 0x00;
2140 config[72] = 0x01; config[73] = 0x00; config[74] = 0x02;
2141 config[75] = 0x00; config[76] = 0x07; config[77] = 0x30;
2145 0, 1, 2, 0, 0xffffffff,
"ESP216",
2146 system, config,
sizeof(config));
2161 uint64_t vram, uint64_t ctrlregs)
2185 static void arc_environment_setup(
struct machine *
machine,
int is64bit,
2186 const char *primary_ether_addr)
2188 size_t bootpath_len = 500;
2189 char *init_bootpath;
2190 uint64_t
addr, addr2;
2200 init_bootpath[0] =
'\0';
2203 snprintf(init_bootpath, bootpath_len,
"tftp()");
2208 strlcat(init_bootpath,
"xio(0)pci(15)",
2211 strlcat(init_bootpath,
"pci(0)",
2217 snprintf(init_bootpath +
strlen(init_bootpath),
2218 bootpath_len -
strlen(init_bootpath),
2221 snprintf(init_bootpath +
strlen(init_bootpath),
2222 bootpath_len -
strlen(init_bootpath),
2223 "scsi(0)disk(%i)rdisk(0)partition(1)",
2228 strlcat(init_bootpath,
"\\", bootpath_len);
2235 fprintf(stderr,
"boot string too long?\n");
2348 "SystemPartition=bootp()10.0.0.2:/var/boot/client",
2356 "OSLoadPartition=bootp()10.0.0.2:/var/boot/client",
2364 "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)",
2368 "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)",
2439 "OSLOADPARTITION=scsi(0)disk(%d)rdisk(0)partition(1)",
2447 "CONSOLEIN=multi()key()keyboard()console()", &
addr);
2450 "CONSOLEOUT=multi()video()monitor()console()",
2456 "CONSOLEIN=multi()serial(0)", &
addr);
2459 "CONSOLEOUT=multi()serial(0)", &
addr);
2482 const char *primary_ether_addr, uint8_t *primary_ether_macaddr)
2484 int i, alloclen = 20;
2486 uint64_t arc_reserved, mem_base;
2490 uint64_t system = 0;
2507 fprintf(stderr,
"WARNING! The ARC platform specification "
2508 "doesn't allow less than 16 MB of RAM. Continuing "
2515 (i==0?
"(stdin)" : (i==1?
"(stdout)" :
"(stderr)"));
2529 arcbios_putcell(
cpu,
' ', x, y);
2534 arcbios_putstring(
cpu,
"GXemul " VERSION
" ARCBIOS emulation\n");
2536 snprintf(tmpstr,
sizeof(tmpstr),
"%i cpu%s (%s), %i MB "
2540 arcbios_putstring(
cpu, tmpstr);
2573 fatal(
"error in machine.c sysid\n");
2598 int reserved_bottom_mem_in_mb = 12;
2603 arc_reserved = 0x2000;
2605 arc_reserved = 0x4000;
2615 mem_base = sgi_ram_offset / 1048576;
2617 while (ram < machine->physical_ram_in_mb) {
2625 ram += reserved_bottom_mem_in_mb;
2626 mem_base += reserved_bottom_mem_in_mb;
2627 to_add -= reserved_bottom_mem_in_mb;
2631 to_add * 1048576, free_type);
2636 if (mem_base == 256) {
2646 fatal(
"Ignoring RAM above 256 MB! (Not yet "
2647 "implemented for this machine type.)\n");
2671 fatal(
"ERROR: machine_name == NULL\n");
2677 snprintf(name, alloclen,
"SGI-IP%i",
2683 snprintf(name, alloclen,
"SGI-IP22");
2689 name = strdup(
"PICA-61");
2692 name = strdup(
"Microsoft-Jazz");
2695 fatal(
"Unimplemented ARC machine type %i\n",
2701 fatal(
"ERROR: non-SGI and non-ARC?\n");
2707 debug(
"ARC system @ 0x%" PRIx64
" (\"%s\")\n", (uint64_t) system, name);
2715 uint64_t cpuaddr, fpu=0, picache, pdcache, sdcache=0;
2716 int cache_size, cache_line_size;
2718 char arc_cpu_name[100];
2719 char arc_fpc_name[105];
2721 snprintf(arc_cpu_name,
sizeof(arc_cpu_name),
2724 arc_cpu_name[
sizeof(arc_cpu_name)-1] = 0;
2725 for (jj=0; jj<
strlen(arc_cpu_name); jj++)
2726 if (arc_cpu_name[jj] >=
'a' && arc_cpu_name[jj] <=
'z')
2727 arc_cpu_name[jj] += (
'A' -
'a');
2729 strlcpy(arc_fpc_name, arc_cpu_name,
sizeof(arc_fpc_name));
2730 strlcat(arc_fpc_name,
"FPC",
sizeof(arc_fpc_name));
2734 0, 1, 2, i, 0xffffffff, arc_cpu_name, system, NULL, 0);
2743 0, 1, 2, 0, 0xffffffff, arc_fpc_name, cpuaddr,
2755 if (cache_line_size < 0)
2756 cache_line_size = 0;
2767 0x01000000 + (cache_line_size << 16) + cache_size,
2769 0xffffffff, NULL, cpuaddr, NULL, 0);
2780 if (cache_line_size < 0)
2781 cache_line_size = 0;
2791 0x01000000 + (cache_line_size << 16) + cache_size,
2793 0xffffffff, NULL, cpuaddr, NULL, 0);
2798 cache_line_size = 6;
2801 cache_secondary_linesize;
2802 if (cache_line_size < 0)
2803 cache_line_size = 0;
2813 0x01000000 + (cache_line_size << 16) + cache_size,
2815 0xffffffff, NULL, cpuaddr, NULL, 0);
2818 debug(
"ARC cpu%i @ 0x%" PRIx64, i, (uint64_t) cpuaddr);
2821 debug(
" (fpu @ 0x%" PRIx64
")\n", (uint64_t) fpu);
2825 debug(
" picache @ 0x%" PRIx64
", pdcache @ 0x%" PRIx64
"\n",
2826 (uint64_t) picache, (uint64_t) pdcache);
2829 debug(
" sdcache @ 0x%" PRIx64
"\n",
2830 (uint64_t) sdcache);
2837 0xffffffff,
"memory", cpuaddr, NULL, 0);
2838 debug(
"ARC memory @ 0x%" PRIx64
"\n", (uint64_t)
memory);
2850 arcbios_add_other_components(
machine, system);
2866 0xc000000000000000ULL, 0, 1048576*16, 1,1,1,1,1, 0, 2, 2);
2877 for (i=0; i<100; i++) {
2950 arc_environment_setup(
machine, is64bit, primary_ether_addr);