arcbios.cc Source File

Back to the index.

arcbios.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2019 Anders Gavare. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. The name of the author may not be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  *
28  * COMMENT: ARCBIOS and ARCS emulation
29  */
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <time.h>
35 #include <unistd.h>
36 #include <sys/time.h>
37 #include <sys/types.h>
38 #include <sys/resource.h>
39 
40 #include "arcbios.h"
41 #include "console.h"
42 #include "cpu.h"
43 #include "cpu_mips.h"
44 #include "diskimage.h"
45 #include "machine.h"
46 #include "machine_arc.h"
47 #include "memory.h"
48 #include "misc.h"
49 
51 
52 
53 extern int quiet_mode;
54 extern int verbose;
55 
56 
57 /*
58  * arcbios_add_string_to_component():
59  */
61  char *str, uint64_t component)
62 {
65  printf("Too many string-to-component mappings.\n");
66  exit(1);
67  }
68 
70  md.arc->n_string_to_components] = strdup(str));
71 
72  debug("adding ARC component mapping: 0x%08x = %s\n",
73  (int)component, str);
74 
76  machine->md.arc->n_string_to_components] = component;
77 
79 }
80 
81 
82 /*
83  * arcbios_get_dsp_stat():
84  *
85  * Fills in an arcbios_dsp_stat struct with valid data.
86  */
87 static void arcbios_get_dsp_stat(struct cpu *cpu,
88  struct arcbios_dsp_stat *dspstat)
89 {
90  memset(dspstat, 0, sizeof(struct arcbios_dsp_stat));
91 
92  store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
93  CursorXPosition, cpu->machine->md.arc->console_curx + 1);
94  store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
95  CursorYPosition, cpu->machine->md.arc->console_cury + 1);
96  store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
97  CursorMaxXPosition, ARC_CONSOLE_MAX_X);
98  store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
99  CursorMaxYPosition, ARC_CONSOLE_MAX_Y);
101  dspstat->HighIntensity = cpu->machine->md.arc->console_curcolor ^ 0x08;
102 }
103 
104 
105 /*
106  * arcbios_putcell():
107  */
108 static void arcbios_putcell(struct cpu *cpu, int ch, int x, int y)
109 {
110  unsigned char buf[2];
111  buf[0] = ch;
112  buf[1] = cpu->machine->md.arc->console_curcolor;
114  buf[1] = ((buf[1] & 0x70) >> 4) | ((buf[1] & 7) << 4)
115  | (buf[1] & 0x88);
117  2*(x + cpu->machine->md.arc->console_maxx * y),
118  &buf[0], sizeof(buf), MEM_WRITE,
119  CACHE_NONE | PHYSICAL);
120 }
121 
122 
123 /*
124  * handle_esc_seq():
125  *
126  * Used by arcbios_putchar().
127  */
128 static void handle_esc_seq(struct cpu *cpu)
129 {
130  int i, len = strlen(cpu->machine->md.arc->escape_sequence);
131  int row, col, color, code, start, stop;
132  char *p;
133 
134  if (cpu->machine->md.arc->escape_sequence[0] != '[')
135  return;
136 
137  code = cpu->machine->md.arc->escape_sequence[len-1];
138  cpu->machine->md.arc->escape_sequence[len-1] = '\0';
139 
140  switch (code) {
141  case 'm':
142  color = atoi(cpu->machine->md.arc->escape_sequence + 1);
143  switch (color) {
144  case 0: /* Default. */
145  cpu->machine->md.arc->console_curcolor = 0x1f;
146  cpu->machine->md.arc->console_reverse = 0; break;
147  case 1: /* "Bold". */
148  cpu->machine->md.arc->console_curcolor |= 0x08; break;
149  case 7: /* "Reverse". */
150  cpu->machine->md.arc->console_reverse = 1; break;
151  case 30: /* Black foreground. */
152  cpu->machine->md.arc->console_curcolor &= 0xf0;
153  cpu->machine->md.arc->console_curcolor |= 0x00; break;
154  case 31: /* Red foreground. */
155  cpu->machine->md.arc->console_curcolor &= 0xf0;
156  cpu->machine->md.arc->console_curcolor |= 0x04; break;
157  case 32: /* Green foreground. */
158  cpu->machine->md.arc->console_curcolor &= 0xf0;
159  cpu->machine->md.arc->console_curcolor |= 0x02; break;
160  case 33: /* Yellow foreground. */
161  cpu->machine->md.arc->console_curcolor &= 0xf0;
162  cpu->machine->md.arc->console_curcolor |= 0x06; break;
163  case 34: /* Blue foreground. */
164  cpu->machine->md.arc->console_curcolor &= 0xf0;
165  cpu->machine->md.arc->console_curcolor |= 0x01; break;
166  case 35: /* Red-blue foreground. */
167  cpu->machine->md.arc->console_curcolor &= 0xf0;
168  cpu->machine->md.arc->console_curcolor |= 0x05; break;
169  case 36: /* Green-blue foreground. */
170  cpu->machine->md.arc->console_curcolor &= 0xf0;
171  cpu->machine->md.arc->console_curcolor |= 0x03; break;
172  case 37: /* White foreground. */
173  cpu->machine->md.arc->console_curcolor &= 0xf0;
174  cpu->machine->md.arc->console_curcolor |= 0x07; break;
175  case 40: /* Black background. */
176  cpu->machine->md.arc->console_curcolor &= 0x0f;
177  cpu->machine->md.arc->console_curcolor |= 0x00; break;
178  case 41: /* Red background. */
179  cpu->machine->md.arc->console_curcolor &= 0x0f;
180  cpu->machine->md.arc->console_curcolor |= 0x40; break;
181  case 42: /* Green background. */
182  cpu->machine->md.arc->console_curcolor &= 0x0f;
183  cpu->machine->md.arc->console_curcolor |= 0x20; break;
184  case 43: /* Yellow background. */
185  cpu->machine->md.arc->console_curcolor &= 0x0f;
186  cpu->machine->md.arc->console_curcolor |= 0x60; break;
187  case 44: /* Blue background. */
188  cpu->machine->md.arc->console_curcolor &= 0x0f;
189  cpu->machine->md.arc->console_curcolor |= 0x10; break;
190  case 45: /* Red-blue background. */
191  cpu->machine->md.arc->console_curcolor &= 0x0f;
192  cpu->machine->md.arc->console_curcolor |= 0x50; break;
193  case 46: /* Green-blue background. */
194  cpu->machine->md.arc->console_curcolor &= 0x0f;
195  cpu->machine->md.arc->console_curcolor |= 0x30; break;
196  case 47: /* White background. */
197  cpu->machine->md.arc->console_curcolor &= 0x0f;
198  cpu->machine->md.arc->console_curcolor |= 0x70; break;
199  default:fatal("{ handle_esc_seq: color %i }\n", color);
200  }
201  return;
202  case 'H':
203  p = strchr(cpu->machine->md.arc->escape_sequence, ';');
204  if (p == NULL)
205  return; /* TODO */
206  row = atoi(cpu->machine->md.arc->escape_sequence + 1);
207  col = atoi(p + 1);
208  if (col < 1)
209  col = 1;
210  if (row < 1)
211  row = 1;
212  cpu->machine->md.arc->console_curx = col - 1;
213  cpu->machine->md.arc->console_cury = row - 1;
214  return;
215  case 'J':
216  /*
217  * J = clear screen below cursor, and the rest of the
218  * current line,
219  * 2J = clear whole screen.
220  */
221  i = atoi(cpu->machine->md.arc->escape_sequence + 1);
222  if (i != 0 && i != 2)
223  fatal("{ handle_esc_seq(): %iJ }\n", i);
224  if (i == 0)
225  for (col = cpu->machine->md.arc->console_curx;
226  col < cpu->machine->md.arc->console_maxx; col++)
227  arcbios_putcell(cpu, ' ', col,
229  for (col = 0; col < cpu->machine->md.arc->console_maxx; col++)
230  for (row = i? 0 : cpu->machine->md.arc->console_cury+1;
231  row < cpu->machine->md.arc->console_maxy; row++)
232  arcbios_putcell(cpu, ' ', col, row);
233  return;
234  case 'K':
235  col = atoi(cpu->machine->md.arc->escape_sequence + 1);
236  /* 2 = clear line to the right. 1 = to the left (?) */
237  start = 0; stop = cpu->machine->md.arc->console_curx;
238  if (col == 2) {
239  start = cpu->machine->md.arc->console_curx;
240  stop = cpu->machine->md.arc->console_maxx - 1;
241  }
242  for (i=start; i<=stop; i++)
243  arcbios_putcell(cpu, ' ', i,
245 
246  return;
247  }
248 
249  fatal("{ handle_esc_seq(): unimplemented escape sequence: ");
250  for (i=0; i<len; i++) {
251  int x = cpu->machine->md.arc->escape_sequence[i];
252  if (i == len-1)
253  x = code;
254 
255  if (x >= ' ' && x < 127)
256  fatal("%c", x);
257  else
258  fatal("[0x%02x]", x);
259  }
260  fatal(" }\n");
261 }
262 
263 
264 /*
265  * scroll_if_necessary():
266  */
267 static void scroll_if_necessary(struct cpu *cpu)
268 {
269  /* Scroll? */
270  if (cpu->machine->md.arc->console_cury >=
272  unsigned char buf[2];
273  int x, y;
274  for (y=0; y<cpu->machine->md.arc->console_maxy-1; y++)
275  for (x=0; x<cpu->machine->md.arc->console_maxx;
276  x++) {
277  cpu->memory_rw(cpu, cpu->mem,
279  2*(x + cpu->machine->md.arc->
280  console_maxx * (y+1)),
281  &buf[0], sizeof(buf), MEM_READ,
282  CACHE_NONE | PHYSICAL);
283  cpu->memory_rw(cpu, cpu->mem,
285  2*(x + cpu->machine->md.arc->
286  console_maxx * y),
287  &buf[0], sizeof(buf), MEM_WRITE,
288  CACHE_NONE | PHYSICAL);
289  }
290 
292  cpu->machine->md.arc->console_maxy - 1;
293 
294  for (x=0; x<cpu->machine->md.arc->console_maxx; x++)
295  arcbios_putcell(cpu, ' ', x,
297  }
298 }
299 
300 
301 /*
302  * arcbios_putchar():
303  *
304  * If we're using X11 with VGA-style console, then output to that console.
305  * Otherwise, use console_putchar().
306  */
307 static void arcbios_putchar(struct cpu *cpu, int ch)
308 {
309  int addr;
310  unsigned char byte;
311 
312  if (!cpu->machine->md.arc->vgaconsole) {
313  /* Text console output: */
314 
315  /* Hack for Windows NT, which uses 0x9b instead of ESC + [ */
316  if (ch == 0x9b) {
318  ch = '[';
319  }
321  return;
322  }
323 
325  int len = strlen(cpu->machine->md.arc->escape_sequence);
326  cpu->machine->md.arc->escape_sequence[len] = ch;
327  len++;
328  if (len >= ARC_MAX_ESC)
329  len = ARC_MAX_ESC;
330  cpu->machine->md.arc->escape_sequence[len] = '\0';
331  if ((ch >= 'a' && ch <= 'z') ||
332  (ch >= 'A' && ch <= 'Z') || len >= ARC_MAX_ESC) {
333  handle_esc_seq(cpu);
335  }
336  } else {
337  if (ch == 27) {
339  cpu->machine->md.arc->escape_sequence[0] = '\0';
340  } else if (ch == 0x9b) {
342  cpu->machine->md.arc->escape_sequence[0] = '[';
343  cpu->machine->md.arc->escape_sequence[1] = '\0';
344  } else if (ch == '\b') {
345  if (cpu->machine->md.arc->console_curx > 0)
346  cpu->machine->md.arc->console_curx --;
347  } else if (ch == '\r') {
348  cpu->machine->md.arc->console_curx = 0;
349  } else if (ch == '\n') {
350  cpu->machine->md.arc->console_cury ++;
351  } else if (ch == '\t') {
353  ((cpu->machine->md.arc->console_curx - 1)
354  | 7) + 1;
355  /* TODO: Print spaces? */
356  } else {
357  /* Put char: */
358  if (cpu->machine->md.arc->console_curx >=
360  cpu->machine->md.arc->console_curx = 0;
361  cpu->machine->md.arc->console_cury ++;
362  scroll_if_necessary(cpu);
363  }
364  arcbios_putcell(cpu, ch,
367  cpu->machine->md.arc->console_curx ++;
368  }
369  }
370 
371  scroll_if_necessary(cpu);
372 
373  /* Update cursor position: */
374  addr = (cpu->machine->md.arc->console_curx >=
376  cpu->machine->md.arc->console_maxx - 1 :
380  byte = 0x0e;
382  console_ctrlregs + 0x14,
383  &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
384  byte = (addr >> 8) & 255;
386  console_ctrlregs + 0x15,
387  &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
388  byte = 0x0f;
390  console_ctrlregs + 0x14,
391  &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
392  byte = addr & 255;
394  console_ctrlregs + 0x15,
395  &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
396 }
397 
398 
399 /*
400  * arcbios_putstring():
401  */
402 static void arcbios_putstring(struct cpu *cpu, const char *s)
403 {
404  while (*s) {
405  if (*s == '\n')
406  arcbios_putchar(cpu, '\r');
407  arcbios_putchar(cpu, *s++);
408  }
409 }
410 
411 
412 /*
413  * arcbios_register_scsicontroller():
414  */
416  uint64_t scsicontroller_component)
417 {
418  machine->md.arc->scsicontroller = scsicontroller_component;
419 }
420 
421 
422 /*
423  * arcbios_get_scsicontroller():
424  */
426 {
427  return machine->md.arc->scsicontroller;
428 }
429 
430 
431 /*
432  * arcbios_add_memory_descriptor():
433  *
434  * NOTE: arctype is the ARC type, not the SGI type. This function takes
435  * care of converting, when necessary.
436  */
438  uint64_t base, uint64_t len, int arctype)
439 {
440  uint64_t memdesc_addr;
441  int s;
442  struct arcbios_mem arcbios_mem;
444 
445  if (verbose >= 2)
446  debug("arcbios_add_memory_descriptor: base=0x%llx len=0x%llx arctype=%i\n",
447  (long long)base, (long long)len, arctype);
448 
449  base /= 4096;
450  len /= 4096;
451 
452  /*
453  * TODO: Huh? Why isn't it necessary to convert from arc to sgi types?
454  *
455  * TODO 2: It seems that it _is_ necessary, but NetBSD's arcdiag
456  * doesn't handle the sgi case separately.
457  */
458 #if 1
459  if (cpu->machine->machine_type == MACHINE_SGI) {
460  /* arctype is SGI style */
461  /* printf("%i => ", arctype); */
462  switch (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;
471  }
472  /* printf("%i\n", arctype); */
473  }
474 #endif
475  if (cpu->machine->md.arc->arc_64bit)
476  s = sizeof(arcbios_mem64);
477  else
478  s = sizeof(arcbios_mem);
479 
480  memdesc_addr = cpu->machine->md.arc->memdescriptor_base +
482 
483  if (cpu->machine->md.arc->arc_64bit) {
484  memset(&arcbios_mem64, 0, s);
486  (unsigned char *)&arcbios_mem64.Type, arctype);
488  (unsigned char *)&arcbios_mem64.BasePage, base);
490  (unsigned char *)&arcbios_mem64.PageCount, len);
491  store_buf(cpu, memdesc_addr, (char *)&arcbios_mem64, s);
492  } else {
493  memset(&arcbios_mem, 0, s);
495  (unsigned char *)&arcbios_mem.Type, arctype);
497  (unsigned char *)&arcbios_mem.BasePage, base);
499  (unsigned char *)&arcbios_mem.PageCount, len);
500  store_buf(cpu, memdesc_addr, (char *)&arcbios_mem, s);
501  }
502 
504 }
505 
506 
507 /*
508  * arcbios_addchild():
509  *
510  * host_tmp_component is a temporary component, with data formated for
511  * the host system. It needs to be translated/copied into emulated RAM.
512  *
513  * Return value is the virtual (emulated) address of the added component.
514  *
515  * TODO: This function doesn't care about memory management, but simply
516  * stores the new child after the last stored child.
517  * TODO: This stuff is really ugly.
518  */
519 static uint64_t arcbios_addchild(struct cpu *cpu,
520  struct arcbios_component *host_tmp_component,
521  const char *identifier, uint32_t parent)
522 {
523  struct machine *machine = cpu->machine;
524  uint64_t a = machine->md.arc->next_component_address;
525  uint32_t peer=0;
526  uint32_t child=0;
527  int n_left;
528  uint64_t peeraddr = FIRST_ARC_COMPONENT;
529 
530  /*
531  * This component has no children yet, but it may have peers (that is,
532  * other components that share this component's parent) so we have to
533  * set the peer value correctly.
534  *
535  * Also, if this is the first child of some parent, the parent's child
536  * pointer should be set to point to this component. (But only if it
537  * is the first.)
538  *
539  * This is really ugly: scan through all components, starting from
540  * FIRST_ARC_COMPONENT, to find a component with the same parent as
541  * this component will have. If such a component is found, and its
542  * 'peer' value is NULL, then set it to this component's address (a).
543  *
544  * TODO: make this nicer
545  */
546 
547  n_left = machine->md.arc->n_components;
548  while (n_left > 0) {
549  /* Load parent, child, and peer values: */
550  uint32_t eparent, echild, epeer, tmp;
551  unsigned char buf[4];
552 
553  /* debug("[ addchild: peeraddr = 0x%08x ]\n",
554  (int)peeraddr); */
555 
556  cpu->memory_rw(cpu, cpu->mem,
557  peeraddr + 0 * machine->md.arc->wordlen, &buf[0],
558  sizeof(eparent), MEM_READ, CACHE_NONE);
559  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
560  unsigned char tmp2;
561  tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
562  tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
563  }
564  epeer = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
565 
566  cpu->memory_rw(cpu, cpu->mem, peeraddr + 1 *
567  machine->md.arc->wordlen,
568  &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
569  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
570  unsigned char tmp2;
571  tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
572  tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
573  }
574  echild = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
575 
576  cpu->memory_rw(cpu, cpu->mem, peeraddr + 2 *
577  machine->md.arc->wordlen,
578  &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
579  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
580  unsigned char tmp2;
581  tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
582  tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
583  }
584  eparent = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
585 
586  /* debug(" epeer=%x echild=%x eparent=%x\n",
587  (int)epeer,(int)echild,(int)eparent); */
588 
589  if ((uint32_t)eparent == (uint32_t)parent &&
590  (uint32_t)epeer == 0) {
591  epeer = a;
592  store_32bit_word(cpu, peeraddr + 0x00, epeer);
593  /* debug("[ addchild: adding 0x%08x as peer "
594  "to 0x%08x ]\n", (int)a, (int)peeraddr); */
595  }
596  if ((uint32_t)peeraddr == (uint32_t)parent &&
597  (uint32_t)echild == 0) {
598  echild = a;
599  store_32bit_word(cpu, peeraddr + 0x04, echild);
600  /* debug("[ addchild: adding 0x%08x as "
601  "child to 0x%08x ]\n", (int)a, (int)peeraddr); */
602  }
603 
604  /* Go to the next component: */
605  cpu->memory_rw(cpu, cpu->mem, peeraddr + 0x28, &buf[0],
606  sizeof(eparent), MEM_READ, CACHE_NONE);
607  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
608  unsigned char tmp2;
609  tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
610  tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
611  }
612 
613  tmp = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
614  peeraddr += 0x30;
615  peeraddr += tmp + 1;
616  peeraddr = ((peeraddr - 1) | 3) + 1;
617 
618  n_left --;
619  }
620 
621  store_32bit_word(cpu, a + 0x00, peer);
622  store_32bit_word(cpu, a + 0x04, child);
623  store_32bit_word(cpu, a + 0x08, parent);
624  store_32bit_word(cpu, a+ 0x0c, host_tmp_component->Class);
625  store_32bit_word(cpu, a+ 0x10, host_tmp_component->Type);
626  store_32bit_word(cpu, a+ 0x14, host_tmp_component->Flags +
627  65536 * host_tmp_component->Version);
628  store_32bit_word(cpu, a+ 0x18, host_tmp_component->Revision);
629  store_32bit_word(cpu, a+ 0x1c, host_tmp_component->Key);
630  store_32bit_word(cpu, a+ 0x20, host_tmp_component->AffinityMask);
631  store_32bit_word(cpu, a+ 0x24, host_tmp_component->
632  ConfigurationDataSize);
633  store_32bit_word(cpu, a+ 0x28, host_tmp_component->IdentifierLength);
634  store_32bit_word(cpu, a+ 0x2c, host_tmp_component->Identifier);
635 
637 
638  if (host_tmp_component->IdentifierLength != 0) {
639  store_32bit_word(cpu, a + 0x2c, a + 0x30);
640  store_string(cpu, a + 0x30, identifier);
641  if (identifier != NULL)
643  strlen(identifier) + 1;
644  }
645 
647 
648  /* Round up to next 0x4 bytes: */
650  ((machine->md.arc->next_component_address - 1) | 3) + 1;
651 
652  machine->md.arc->n_components ++;
653 
654  return a;
655 }
656 
657 
658 /*
659  * arcbios_addchild64():
660  *
661  * host_tmp_component is a temporary component, with data formated for
662  * the host system. It needs to be translated/copied into emulated RAM.
663  *
664  * Return value is the virtual (emulated) address of the added component.
665  *
666  * TODO: This function doesn't care about memory management, but simply
667  * stores the new child after the last stored child.
668  * TODO: This stuff is really ugly.
669  */
670 static uint64_t arcbios_addchild64(struct cpu *cpu,
671  struct arcbios_component64 *host_tmp_component,
672  const char *identifier, uint64_t parent)
673 {
674  struct machine *machine = cpu->machine;
675  uint64_t a = machine->md.arc->next_component_address;
676  uint64_t peer=0;
677  uint64_t child=0;
678  int n_left;
679  uint64_t peeraddr = FIRST_ARC_COMPONENT;
680 
681  /*
682  * This component has no children yet, but it may have peers (that is,
683  * other components that share this component's parent) so we have to
684  * set the peer value correctly.
685  *
686  * Also, if this is the first child of some parent, the parent's child
687  * pointer should be set to point to this component. (But only if it
688  * is the first.)
689  *
690  * This is really ugly: scan through all components, starting from
691  * FIRST_ARC_COMPONENT, to find a component with the same parent as
692  * this component will have. If such a component is found, and its
693  * 'peer' value is NULL, then set it to this component's address (a).
694  *
695  * TODO: make this nicer
696  */
697 
698  n_left = machine->md.arc->n_components;
699  while (n_left > 0) {
700  /* Load parent, child, and peer values: */
701  uint64_t eparent, echild, epeer, tmp;
702  unsigned char buf[8];
703 
704  /* debug("[ addchild: peeraddr = 0x%016" PRIx64" ]\n",
705  (uint64_t) peeraddr); */
706 
707  cpu->memory_rw(cpu, cpu->mem,
708  peeraddr + 0 * machine->md.arc->wordlen, &buf[0],
709  sizeof(eparent), MEM_READ, CACHE_NONE);
710  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
711  unsigned char tmp2;
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;
716  }
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);
720 
721  cpu->memory_rw(cpu, cpu->mem, peeraddr + 1 *
722  machine->md.arc->wordlen,
723  &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
724  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
725  unsigned char tmp2;
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;
730  }
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);
734 
735  cpu->memory_rw(cpu, cpu->mem, peeraddr + 2 *
736  machine->md.arc->wordlen,
737  &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
738  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
739  unsigned char tmp2;
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;
744  }
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);
748 
749  /* debug(" epeer=%" PRIx64" echild=%" PRIx64" eparent=%" PRIx64
750  "\n", (uint64_t) epeer, (uint64_t) echild,
751  (uint64_t) eparent); */
752 
753  if (eparent == parent && epeer == 0) {
754  epeer = a;
755  store_64bit_word(cpu, peeraddr + 0 *
756  machine->md.arc->wordlen, epeer);
757  /* debug("[ addchild: adding 0x%016" PRIx64" as peer "
758  "to 0x%016" PRIx64" ]\n", (uint64_t) a,
759  (uint64_t) peeraddr); */
760  }
761  if (peeraddr == parent && echild == 0) {
762  echild = a;
763  store_64bit_word(cpu, peeraddr + 1 *
764  machine->md.arc->wordlen, echild);
765  /* debug("[ addchild: adding 0x%016" PRIx64" as child "
766  "to 0x%016" PRIx64" ]\n", (uint64_t) a,
767  (uint64_t) peeraddr); */
768  }
769 
770  /* Go to the next component: */
771  cpu->memory_rw(cpu, cpu->mem, peeraddr + 0x34,
772  &buf[0], sizeof(uint32_t), MEM_READ, CACHE_NONE);
773  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
774  unsigned char tmp2;
775  tmp2 = buf[0]; buf[0] = buf[3]; buf[3] = tmp2;
776  tmp2 = buf[1]; buf[1] = buf[2]; buf[2] = tmp2;
777  }
778  tmp = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
779 
780  tmp &= 0xfffff;
781 
782  peeraddr += 0x50;
783  peeraddr += tmp + 1;
784  peeraddr = ((peeraddr - 1) | 3) + 1;
785 
786  n_left --;
787  }
788 
789  store_64bit_word(cpu, a + 0x00, peer);
790  store_64bit_word(cpu, a + 0x08, child);
791  store_64bit_word(cpu, a + 0x10, parent);
792  store_32bit_word(cpu, a+ 0x18, host_tmp_component->Class);
793  store_32bit_word(cpu, a+ 0x1c, host_tmp_component->Type);
794  store_32bit_word(cpu, a+ 0x20, host_tmp_component->Flags);
795  store_32bit_word(cpu, a+ 0x24, host_tmp_component->Version +
796  ((uint64_t)host_tmp_component->Revision << 16));
797  store_32bit_word(cpu, a+ 0x28, host_tmp_component->Key);
798  store_64bit_word(cpu, a+ 0x30, host_tmp_component->AffinityMask);
799  store_64bit_word(cpu, a+ 0x38, host_tmp_component->
800  ConfigurationDataSize);
801  store_64bit_word(cpu, a+ 0x40, host_tmp_component->IdentifierLength);
802  store_64bit_word(cpu, a+ 0x48, host_tmp_component->Identifier);
803 
804  /* TODO: Find out how a REAL ARCS64 implementation does it. */
805 
807 
808  if (host_tmp_component->IdentifierLength != 0) {
809  store_64bit_word(cpu, a + 0x48, a + 0x50);
810  store_string(cpu, a + 0x50, identifier);
811  if (identifier != NULL)
813  strlen(identifier) + 1;
814  }
815 
817 
818  /* Round up to next 0x8 bytes: */
820  ((machine->md.arc->next_component_address - 1) | 7) + 1;
821 
822  machine->md.arc->n_components ++;
823  return a;
824 }
825 
826 
827 /*
828  * arcbios_addchild_manual():
829  *
830  * Used internally to set up component structures.
831  * Parent may only be NULL for the first (system) component.
832  *
833  * Return value is the virtual (emulated) address of the added component.
834  */
835 uint64_t arcbios_addchild_manual(struct cpu *cpu,
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)
840 {
841  struct machine *machine = cpu->machine;
842  /* This component is only for temporary use: */
843  struct arcbios_component component;
844  struct arcbios_component64 component64;
845 
846  if (config_data != NULL) {
847  unsigned char *p = (unsigned char *) config_data;
848  size_t i;
849 
851  printf("fatal error: you need to increase "
852  "MAX_CONFIG_DATA\n");
853  exit(1);
854  }
855 
856  for (i=0; i<config_len; i++) {
857  unsigned char ch = p[i];
858  cpu->memory_rw(cpu, cpu->mem,
860  &ch, 1, MEM_WRITE, CACHE_NONE);
861  }
862 
864  machine->md.arc->n_configuration_data] = config_len;
868  machine->md.arc->configuration_data_next_addr += config_len;
872  (cpu->machine->md.arc->arc_64bit? 0x18 : 0x0c);
873 
874  /* printf("& ADDING %i: configdata=0x%016" PRIx64" "
875  "component=0x%016" PRIx64"\n",
876  machine->md.arc->n_configuration_data,
877  (uint64_t) machine->md.arc->configuration_data_configdata[
878  machine->md.arc->n_configuration_data],
879  (uint64_t) machine->md.arc->configuration_data_component[
880  machine->md.arc->n_configuration_data]); */
881 
883  }
884 
885  if (!cpu->machine->md.arc->arc_64bit) {
886  component.Class = cclass;
887  component.Type = type;
888  component.Flags = flags;
889  component.Version = version;
890  component.Revision = revision;
891  component.Key = key;
892  component.AffinityMask = affinitymask;
893  component.ConfigurationDataSize = config_len;
894  component.IdentifierLength = 0;
895  component.Identifier = 0;
896  if (identifier != NULL) {
897  component.IdentifierLength = strlen(identifier) + 1;
898  }
899 
900  return arcbios_addchild(cpu, &component, identifier, parent);
901  } else {
902  component64.Class = cclass;
903  component64.Type = type;
904  component64.Flags = flags;
905  component64.Version = version;
906  component64.Revision = revision;
907  component64.Key = key;
908  component64.AffinityMask = affinitymask;
909  component64.ConfigurationDataSize = config_len;
910  component64.IdentifierLength = 0;
911  component64.Identifier = 0;
912  if (identifier != NULL) {
913  component64.IdentifierLength = strlen(identifier) + 1;
914  }
915 
916  return arcbios_addchild64(cpu, &component64, identifier,
917  parent);
918  }
919 }
920 
921 
922 /*
923  * arcbios_get_msdos_partition_size():
924  *
925  * This function tries to parse MSDOS-style partition tables on a disk
926  * image, and return the starting offset (counted in bytes), and the
927  * size, of a specific partition.
928  *
929  * NOTE: partition_nr is 1-based!
930  *
931  * TODO: This is buggy, it doesn't really handle extended partitions.
932  *
933  * See http://www.nondot.org/sabre/os/files/Partitions/Partitions.html
934  * for more info.
935  */
936 static void arcbios_get_msdos_partition_size(struct machine *machine,
937  int disk_id, int disk_type, int partition_nr, uint64_t *start,
938  uint64_t *size)
939 {
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;
944 
945  /* Partition 0 is the entire disk image: */
946  *start = 0;
947  *size = diskimage_getsize(machine, disk_id, disk_type);
948  if (partition_nr == 0)
949  return;
950 
951 ugly_goto:
952  *start = 0; *size = 0;
953 
954  /* printf("reading MSDOS partition from offset 0x%" PRIx64"\n",
955  (uint64_t) offset); */
956 
957  res = diskimage_access(machine, disk_id, disk_type, 0, offset,
958  sector, sizeof(sector));
959  if (!res) {
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);
963  return;
964  }
965 
966  if (sector[510] != 0x55 || sector[511] != 0xaa) {
967  fatal("[ arcbios_get_msdos_partition_size(): not an "
968  "MSDOS partition table ]\n");
969  }
970 
971 #if 0
972  /* Debug dump: */
973  for (i=0; i<4; i++) {
974  int j;
975  printf(" partition %i: ", i+1);
976  for (j=0; j<16; j++)
977  printf(" %02x", sector[446 + i*16 + j]);
978  printf("\n");
979  }
980 #endif
981 
982  for (i=0; i<4; i++) {
983  memmove(buf, sector + 446 + 16*i, 16);
984 
985  partition_type = buf[4];
986 
987  if (partition_type == 0)
988  continue;
989 
990  st = (buf[8] + (buf[9] << 8) + (buf[10] << 16) +
991  (buf[11] << 24)) * 512;
992 
993  if (start != NULL)
994  *start = st;
995  if (size != NULL)
996  *size = (buf[12] + (buf[13] << 8) + (buf[14] << 16) +
997  (buf[15] << 24)) * 512;
998 
999  /* Extended DOS partition: */
1000  if (partition_type == 5) {
1001  offset += st;
1002  goto ugly_goto;
1003  }
1004 
1005  /* Found the right partition? Then return. */
1006  cur_partition ++;
1007  if (cur_partition == partition_nr)
1008  return;
1009  }
1010 
1011  fatal("[ partition(%i) NOT found ]\n", partition_nr);
1012 }
1013 
1014 
1015 /*
1016  * arcbios_handle_to_disk_id_and_type():
1017  */
1018 static int arcbios_handle_to_disk_id_and_type(struct machine *machine,
1019  int handle, int *typep)
1020 {
1021  int id, cdrom;
1022  const char *s;
1023 
1024  if (handle < 0 || handle >= ARC_MAX_HANDLES)
1025  return -1;
1026 
1027  s = machine->md.arc->file_handle_string[handle];
1028  if (s == NULL)
1029  return -1;
1030 
1031  /*
1032  * s is something like "scsi(0)disk(0)rdisk(0)partition(0)".
1033  * TODO: This is really ugly and hardcoded.
1034  */
1035 
1036  if (strncmp(s, "scsi(", 5) != 0 || strlen(s) < 13)
1037  return -1;
1038 
1039  *typep = DISKIMAGE_SCSI;
1040 
1041  cdrom = (s[7] == 'c');
1042  id = cdrom? atoi(s + 13) : atoi(s + 12);
1043 
1044  return id;
1045 }
1046 
1047 
1048 /*
1049  * arcbios_handle_to_start_and_size():
1050  */
1051 static void arcbios_handle_to_start_and_size(struct machine *machine,
1052  int handle, uint64_t *start, uint64_t *size)
1053 {
1054  const char *s = machine->md.arc->file_handle_string[handle];
1055  const char *s2;
1056  int disk_id, disk_type;
1057 
1058  disk_id = arcbios_handle_to_disk_id_and_type(machine,
1059  handle, &disk_type);
1060 
1061  if (disk_id < 0)
1062  return;
1063 
1064  /* This works for "partition(0)": */
1065  *start = 0;
1066  *size = diskimage_getsize(machine, disk_id, disk_type);
1067 
1068  s2 = strstr(s, "partition(");
1069  if (s2 != NULL) {
1070  int partition_nr = atoi(s2 + 10);
1071  /* printf("partition_nr = %i\n", partition_nr); */
1072  if (partition_nr != 0)
1073  arcbios_get_msdos_partition_size(machine,
1074  disk_id, disk_type, partition_nr, start, size);
1075  }
1076 }
1077 
1078 
1079 /*
1080  * arcbios_getfileinformation():
1081  *
1082  * Fill in a GetFileInformation struct in emulated memory,
1083  * for a specific file handle. (This is used to get the size
1084  * and offsets of partitions on disk images.)
1085  */
1086 static int arcbios_getfileinformation(struct cpu *cpu)
1087 {
1088  int handle = cpu->cd.mips.gpr[MIPS_GPR_A0];
1089  uint64_t addr = cpu->cd.mips.gpr[MIPS_GPR_A1];
1090  uint64_t start, size;
1091 
1092  arcbios_handle_to_start_and_size(cpu->machine, handle, &start, &size);
1093 
1094  store_64bit_word(cpu, addr + 0, 0);
1095  store_64bit_word(cpu, addr + 8, size);
1096  store_64bit_word(cpu, addr + 16, 0);
1097  store_32bit_word(cpu, addr + 24, 1);
1098  store_32bit_word(cpu, addr + 28, 0);
1099  store_32bit_word(cpu, addr + 32, 0);
1100 
1101  /* printf("\n!!! size=0x%x start=0x%x\n", (int)size, (int)start); */
1102 
1103  return ARCBIOS_ESUCCESS;
1104 }
1105 
1106 
1107 /*
1108  * arcbios_private_emul():
1109  *
1110  * TODO: This is probably SGI specific. (?)
1111  *
1112  * 0x04 get nvram table
1113  */
1115 {
1116  int vector = cpu->pc & 0xfff;
1117 
1118  switch (vector) {
1119  case 0x04:
1120  debug("[ ARCBIOS PRIVATE get nvram table(): TODO ]\n");
1121  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1122  break;
1123  default:
1124  cpu_register_dump(cpu->machine, cpu, 1, 0x1);
1125  debug("a0 points to: ");
1127  debug("\n");
1128  fatal("ARCBIOS: unimplemented PRIVATE vector 0x%x\n", vector);
1129  cpu->running = 0;
1130  }
1131 }
1132 
1133 
1134 /*
1135  * arcbios_emul(): ARCBIOS emulation
1136  *
1137  * 0x0c Halt()
1138  * 0x10 PowerDown()
1139  * 0x14 Restart()
1140  * 0x18 Reboot()
1141  * 0x1c EnterInteractiveMode()
1142  * 0x20 ReturnFromMain()
1143  * 0x24 GetPeer(node)
1144  * 0x28 GetChild(node)
1145  * 0x2c GetParent(node)
1146  * 0x30 GetConfigurationData(config_data, node)
1147  * 0x3c GetComponent(name)
1148  * 0x44 GetSystemId()
1149  * 0x48 GetMemoryDescriptor(void *)
1150  * 0x50 GetTime()
1151  * 0x54 GetRelativeTime()
1152  * 0x5c Open(path, mode, &fileid)
1153  * 0x60 Close(handle)
1154  * 0x64 Read(handle, &buf, len, &actuallen)
1155  * 0x6c Write(handle, buf, len, &returnlen)
1156  * 0x70 Seek(handle, &offset, len)
1157  * 0x78 GetEnvironmentVariable(char *)
1158  * 0x7c SetEnvironmentVariable(char *, char *)
1159  * 0x80 GetFileInformation(handle, buf)
1160  * 0x88 FlushAllCaches()
1161  * 0x90 GetDisplayStatus(uint32_t handle)
1162  * 0x100 undocumented IRIX (?)
1163  */
1164 int arcbios_emul(struct cpu *cpu)
1165 {
1166  struct machine *machine = cpu->machine;
1167  int vector = cpu->pc & 0xfff;
1168  int i, j, handle;
1169  unsigned char ch2;
1170  unsigned char buf[40];
1171 
1172  if (cpu->pc >= ARC_PRIVATE_ENTRIES &&
1173  cpu->pc < ARC_PRIVATE_ENTRIES + 100*sizeof(uint32_t)) {
1175  return 1;
1176  }
1177 
1178  if (machine->md.arc->arc_64bit)
1179  vector /= 2;
1180 
1181  /* Special case for reboot by jumping to 0xbfc00000: */
1182  if (vector == 0 && (cpu->pc & 0xffffffffULL) == 0xbfc00000ULL)
1183  vector = 0x18;
1184 
1185  switch (vector) {
1186  case 0x0c: /* Halt() */
1187  case 0x10: /* PowerDown() */
1188  case 0x14: /* Restart() */
1189  case 0x18: /* Reboot() */
1190  case 0x1c: /* EnterInteractiveMode() */
1191  case 0x20: /* ReturnFromMain() */
1192  debug("[ ARCBIOS Halt() or similar ]\n");
1193  /* Halt all CPUs. */
1194  for (i=0; i<machine->ncpus; i++) {
1195  machine->cpus[i]->running = 0;
1196  }
1198  break;
1199  case 0x24: /* GetPeer(node) */
1200  if (cpu->cd.mips.gpr[MIPS_GPR_A0] == 0) {
1201  /* NULL ptr argument: return NULL. */
1202  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1203  } else {
1204  uint64_t peer;
1205  cpu->memory_rw(cpu, cpu->mem,
1206  cpu->cd.mips.gpr[MIPS_GPR_A0] - 3 *
1207  machine->md.arc->wordlen, &buf[0],
1209  if (machine->md.arc->arc_64bit) {
1210  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1211  unsigned char tmp; tmp = buf[0];
1212  buf[0] = buf[7]; buf[7] = tmp;
1213  tmp = buf[1]; buf[1] = buf[6];
1214  buf[6] = tmp;
1215  tmp = buf[2]; buf[2] = buf[5];
1216  buf[5] = tmp;
1217  tmp = buf[3]; buf[3] = buf[4];
1218  buf[4] = tmp;
1219  }
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);
1227  } else {
1228  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1229  unsigned char tmp; tmp = buf[0];
1230  buf[0] = buf[3]; buf[3] = tmp;
1231  tmp = buf[1]; buf[1] = buf[2];
1232  buf[2] = tmp;
1233  }
1234  peer = buf[0] + (buf[1]<<8) + (buf[2]<<16)
1235  + (buf[3]<<24);
1236  }
1237 
1238  cpu->cd.mips.gpr[MIPS_GPR_V0] = peer?
1239  (peer + 3 * machine->md.arc->wordlen) : 0;
1240  if (!machine->md.arc->arc_64bit)
1241  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)
1242  (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0];
1243  }
1244  debug("[ ARCBIOS GetPeer(node 0x%016" PRIx64"): 0x%016" PRIx64
1245  " ]\n", (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0],
1246  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_V0]);
1247  break;
1248  case 0x28: /* GetChild(node) */
1249  /* 0 for the root, non-0 for children: */
1250  if (cpu->cd.mips.gpr[MIPS_GPR_A0] == 0)
1252  + machine->md.arc->wordlen * 3;
1253  else {
1254  uint64_t child = 0;
1255  cpu->memory_rw(cpu, cpu->mem,
1256  cpu->cd.mips.gpr[MIPS_GPR_A0] - 2 *
1257  machine->md.arc->wordlen, &buf[0], machine->
1258  md.arc->wordlen, MEM_READ, CACHE_NONE);
1259  if (machine->md.arc->arc_64bit) {
1260  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1261  unsigned char tmp; tmp = buf[0];
1262  buf[0] = buf[7]; buf[7] = tmp;
1263  tmp = buf[1]; buf[1] = buf[6];
1264  buf[6] = tmp;
1265  tmp = buf[2]; buf[2] = buf[5];
1266  buf[5] = tmp;
1267  tmp = buf[3]; buf[3] = buf[4];
1268  buf[4] = tmp;
1269  }
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);
1278  } else {
1279  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1280  unsigned char tmp; tmp = buf[0];
1281  buf[0] = buf[3]; buf[3] = tmp;
1282  tmp = buf[1]; buf[1] = buf[2];
1283  buf[2] = tmp;
1284  }
1285  child = buf[0] + (buf[1]<<8) + (buf[2]<<16) +
1286  (buf[3]<<24);
1287  }
1288 
1289  cpu->cd.mips.gpr[MIPS_GPR_V0] = child?
1290  (child + 3 * machine->md.arc->wordlen) : 0;
1291  if (!machine->md.arc->arc_64bit)
1292  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)
1293  (int32_t)cpu->cd.mips.gpr[MIPS_GPR_V0];
1294  }
1295  debug("[ ARCBIOS GetChild(node 0x%016" PRIx64"): 0x%016"
1296  PRIx64" ]\n", (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0],
1297  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_V0]);
1298  break;
1299  case 0x2c: /* GetParent(node) */
1300  {
1301  uint64_t parent;
1302 
1303  cpu->memory_rw(cpu, cpu->mem,
1304  cpu->cd.mips.gpr[MIPS_GPR_A0] - 1 * machine->
1305  md.arc->wordlen, &buf[0], machine->md.arc->wordlen,
1306  MEM_READ, CACHE_NONE);
1307 
1308  if (machine->md.arc->arc_64bit) {
1309  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1310  unsigned char tmp; tmp = buf[0];
1311  buf[0] = buf[7]; buf[7] = tmp;
1312  tmp = buf[1]; buf[1] = buf[6];
1313  buf[6] = tmp;
1314  tmp = buf[2]; buf[2] = buf[5];
1315  buf[5] = tmp;
1316  tmp = buf[3]; buf[3] = buf[4];
1317  buf[4] = tmp;
1318  }
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);
1327  } else {
1328  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1329  unsigned char tmp; tmp = buf[0];
1330  buf[0] = buf[3]; buf[3] = tmp;
1331  tmp = buf[1]; buf[1] = buf[2];
1332  buf[2] = tmp;
1333  }
1334  parent = buf[0] + (buf[1]<<8) +
1335  (buf[2]<<16) + (buf[3]<<24);
1336  }
1337 
1338  cpu->cd.mips.gpr[MIPS_GPR_V0] = parent?
1339  (parent + 3 * machine->md.arc->wordlen) : 0;
1340  if (!machine->md.arc->arc_64bit)
1341  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)
1342  (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0];
1343  }
1344  debug("[ ARCBIOS GetParent(node 0x%016" PRIx64"): 0x%016"
1345  PRIx64" ]\n", (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0],
1346  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_V0]);
1347  break;
1348  case 0x30: /* GetConfigurationData(void *configdata, void *node) */
1349  /* fatal("[ ARCBIOS GetConfigurationData(0x%016" PRIx64","
1350  "0x%016" PRIx64") ]\n",
1351  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0],
1352  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1]); */
1354  for (i=0; i<machine->md.arc->n_configuration_data; i++) {
1355  /* fatal("configuration_data_component[%i] = "
1356  "0x%016" PRIx64"\n", i, (uint64_t) machine->
1357  md.arc->configuration_data_component[i]); */
1358  if (cpu->cd.mips.gpr[MIPS_GPR_A1] ==
1360  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1361  for (j=0; j<machine->
1362  md.arc->configuration_data_len[i]; j++) {
1363  unsigned char ch;
1364  cpu->memory_rw(cpu, cpu->mem,
1365  machine->md.arc->
1366  configuration_data_configdata[i] +
1367  j, &ch, 1, MEM_READ, CACHE_NONE);
1368  cpu->memory_rw(cpu, cpu->mem,
1369  cpu->cd.mips.gpr[MIPS_GPR_A0] + j,
1370  &ch, 1, MEM_WRITE, CACHE_NONE);
1371  }
1372  break;
1373  }
1374  }
1375  break;
1376  case 0x3c: /* GetComponent(char *name) */
1377  debug("[ ARCBIOS GetComponent(\"");
1379  debug("\") ]\n");
1380 
1381  if (cpu->cd.mips.gpr[MIPS_GPR_A0] == 0) {
1382  fatal("[ ARCBIOS GetComponent: NULL ptr ]\n");
1383  } else {
1384  unsigned char buf2[500];
1385  int match_index = -1;
1386  int match_len = 0;
1387 
1388  memset(buf2, 0, sizeof(buf2));
1389  for (i=0; i<(ssize_t)sizeof(buf2); i++) {
1390  cpu->memory_rw(cpu, cpu->mem,
1391  cpu->cd.mips.gpr[MIPS_GPR_A0] + i,
1392  &buf2[i], 1, MEM_READ, CACHE_NONE);
1393  if (buf2[i] == '\0')
1394  i = sizeof(buf);
1395  }
1396  buf2[sizeof(buf2) - 1] = '\0';
1397 
1398  /* "scsi(0)disk(0)rdisk(0)partition(0)" and such. */
1399  /* printf("GetComponent(\"%s\")\n", buf2); */
1400 
1401  /* Default to NULL return value. */
1402  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1403 
1404  /* Scan the string to component table: */
1405  for (i=0; i<machine->md.arc->n_string_to_components;
1406  i++) {
1407  int m = 0;
1408  while (buf2[m] && machine->md.arc->
1409  string_to_component[i][m] &&
1411  == buf2[m])
1412  m++;
1413  if (m > match_len) {
1414  match_len = m;
1415  match_index = i;
1416  }
1417  }
1418 
1419  if (match_index >= 0) {
1420  /* printf("Longest match: '%s'\n",
1421  machine->md.arc->string_to_component[
1422  match_index]); */
1423  cpu->cd.mips.gpr[MIPS_GPR_V0] =
1425  match_index];
1426  }
1427  }
1428  break;
1429  case 0x44: /* GetSystemId() */
1430  debug("[ ARCBIOS GetSystemId() ]\n");
1432  break;
1433  case 0x48: /* void *GetMemoryDescriptor(void *ptr) */
1434  debug("[ ARCBIOS GetMemoryDescriptor(0x%08x) ]\n",
1435  (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);
1436 
1437  /* If a0=NULL, then return the first descriptor: */
1438  if ((uint32_t)cpu->cd.mips.gpr[MIPS_GPR_A0] == 0)
1439  cpu->cd.mips.gpr[MIPS_GPR_V0] =
1441  else {
1442  int s = machine->md.arc->arc_64bit?
1443  sizeof(struct arcbios_mem64)
1444  : sizeof(struct arcbios_mem);
1445  int nr = cpu->cd.mips.gpr[MIPS_GPR_A0] -
1446  machine->md.arc->memdescriptor_base;
1447  nr /= s;
1448  nr ++;
1449  cpu->cd.mips.gpr[MIPS_GPR_V0] =
1450  machine->md.arc->memdescriptor_base + s * nr;
1451  if (nr >= machine->md.arc->n_memdescriptors)
1452  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1453  }
1454  break;
1455  case 0x50: /* GetTime() */
1456  debug("[ ARCBIOS GetTime() ]\n");
1457  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0xffffffff80001000ULL;
1458  /* TODO! */
1459  break;
1460  case 0x54: /* GetRelativeTime() */
1461  debug("[ ARCBIOS GetRelativeTime() ]\n");
1462  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)(int32_t)time(NULL);
1463  break;
1464  case 0x5c: /* Open(char *path, uint32_t mode, uint32_t *fileID) */
1465  debug("[ ARCBIOS Open(\"");
1466  dump_mem_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0]);
1467  debug("\",0x%x,0x%x)", (int)cpu->cd.mips.gpr[MIPS_GPR_A0],
1468  (int)cpu->cd.mips.gpr[MIPS_GPR_A1],
1469  (int)cpu->cd.mips.gpr[MIPS_GPR_A2]);
1470 
1471  cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_ENOENT;
1472 
1473  handle = 3;
1474  /* TODO: Starting at 0 would require some updates... */
1475  while (machine->md.arc->file_handle_in_use[handle]) {
1476  handle ++;
1477  if (handle >= ARC_MAX_HANDLES) {
1479  break;
1480  }
1481  }
1482 
1483  if (handle >= ARC_MAX_HANDLES) {
1484  fatal("[ ARCBIOS Open: out of file handles ]\n");
1485  } else if (cpu->cd.mips.gpr[MIPS_GPR_A0] == 0) {
1486  fatal("[ ARCBIOS Open: NULL ptr ]\n");
1487  } else {
1488  /*
1489  * TODO: This is hardcoded to successfully open
1490  * anything. It is used by the Windows NT SETUPLDR
1491  * program to load stuff from the boot partition.
1492  */
1493  unsigned char *buf2;
1494  CHECK_ALLOCATION(buf2 = (unsigned char *) malloc(MAX_OPEN_STRINGLEN));
1495  memset(buf2, 0, MAX_OPEN_STRINGLEN);
1496  for (i=0; i<MAX_OPEN_STRINGLEN; i++) {
1497  cpu->memory_rw(cpu, cpu->mem,
1498  cpu->cd.mips.gpr[MIPS_GPR_A0] + i,
1499  &buf2[i], 1, MEM_READ, CACHE_NONE);
1500  if (buf2[i] == '\0')
1501  i = MAX_OPEN_STRINGLEN;
1502  }
1503  buf2[MAX_OPEN_STRINGLEN - 1] = '\0';
1504  machine->md.arc->file_handle_string[handle] =
1505  (char *)buf2;
1506  machine->md.arc->current_seek_offset[handle] = 0;
1508  }
1509 
1511  debug(" = handle %i ]\n", (int)handle);
1513  handle);
1514  machine->md.arc->file_handle_in_use[handle] = 1;
1515  } else
1516  debug(" = ERROR %i ]\n",
1517  (int)cpu->cd.mips.gpr[MIPS_GPR_V0]);
1518  break;
1519  case 0x60: /* Close(uint32_t handle) */
1520  debug("[ ARCBIOS Close(%i) ]\n",
1521  (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);
1523  MIPS_GPR_A0]]) {
1524  fatal("ARCBIOS Close(%i): bad handle\n",
1525  (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);
1527  } else {
1529  cpu->cd.mips.gpr[MIPS_GPR_A0]] = 0;
1530  // TODO: Yes, this is a memory leak. But it will be
1531  // scrapped in favor of real code after the rewrite (I
1532  // hope).
1533  //if (machine->md.arc->file_handle_string[
1534  // cpu->cd.mips.gpr[MIPS_GPR_A0]] != NULL)
1535  // free(machine->md.arc->file_handle_string[
1536  // cpu->cd.mips.gpr[MIPS_GPR_A0]]);
1538  gpr[MIPS_GPR_A0]] = NULL;
1540  }
1541  break;
1542  case 0x64: /* Read(handle, void *buf, length, uint32_t *count) */
1543  if (cpu->cd.mips.gpr[MIPS_GPR_A0] == ARCBIOS_STDIN) {
1544  int j2, nread = 0, a2;
1545 
1546  /*
1547  * Before going into the loop, make sure stdout
1548  * is flushed. If we're using an X11 VGA console,
1549  * then it needs to be flushed as well.
1550  */
1551  fflush(stdin);
1552  fflush(stdout);
1553  /* NOTE/TODO: This gives a tick to _everything_ */
1554  for (j2=0; j2<machine->tick_functions.n_entries; j2++)
1555  machine->tick_functions.f[j2](cpu,
1557 
1558  a2 = cpu->cd.mips.gpr[MIPS_GPR_A2];
1559  for (j2=0; j2<a2; j2++) {
1560  int x;
1561  unsigned char ch;
1562 
1563  /* Read from STDIN is blocking (at least
1564  that seems to be how NetBSD's arcdiag
1565  wants it) */
1566  x = console_readchar(
1568  if (x < 0)
1569  return 0;
1570 
1571  /*
1572  * ESC + '[' should be transformed into 0x9b:
1573  *
1574  * NOTE/TODO: This makes the behaviour of just
1575  * pressing ESC a bit harder to define.
1576  */
1577  if (x == 27) {
1578  x = console_readchar(cpu->
1580  if (x == '[' || x == 'O')
1581  x = 0x9b;
1582  }
1583 
1584  ch = x;
1585  nread ++;
1586  cpu->memory_rw(cpu, cpu->mem,
1587  cpu->cd.mips.gpr[MIPS_GPR_A1] + j2,
1588  &ch, 1, MEM_WRITE, CACHE_NONE);
1589 
1590  /* NOTE: Only one char, from STDIN: */
1591  j2 = cpu->cd.mips.gpr[MIPS_GPR_A2]; /* :-) */
1592  }
1593 
1595  nread);
1596  /* TODO: not EAGAIN? */
1597  cpu->cd.mips.gpr[MIPS_GPR_V0] =
1599  } else {
1600  int handleTmp = cpu->cd.mips.gpr[MIPS_GPR_A0];
1601  int disk_type = 0;
1602  int disk_id = arcbios_handle_to_disk_id_and_type(
1603  machine, handleTmp, &disk_type);
1604  uint64_t partition_offset = 0;
1605  int res;
1606  uint64_t size; /* dummy */
1607  unsigned char *tmp_buf;
1608 
1609  arcbios_handle_to_start_and_size(machine, handleTmp,
1610  &partition_offset, &size);
1611 
1612  debug("[ ARCBIOS Read(%i,0x%08x,0x%08x,0x%08x) ]\n",
1613  (int)cpu->cd.mips.gpr[MIPS_GPR_A0],
1614  (int)cpu->cd.mips.gpr[MIPS_GPR_A1],
1615  (int)cpu->cd.mips.gpr[MIPS_GPR_A2],
1616  (int)cpu->cd.mips.gpr[MIPS_GPR_A3]);
1617 
1618  CHECK_ALLOCATION(tmp_buf = (unsigned char *)
1619  malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]));
1620 
1621  res = diskimage_access(machine, disk_id, disk_type,
1622  0, partition_offset + machine->md.arc->
1623  current_seek_offset[handleTmp], tmp_buf,
1624  cpu->cd.mips.gpr[MIPS_GPR_A2]);
1625 
1626  /* If the transfer was successful, transfer the
1627  data to emulated memory: */
1628  if (res) {
1629  uint64_t dst = cpu->cd.mips.gpr[MIPS_GPR_A1];
1630  store_buf(cpu, dst, (char *)tmp_buf,
1631  cpu->cd.mips.gpr[MIPS_GPR_A2]);
1634  cpu->cd.mips.gpr[MIPS_GPR_A2]);
1635  machine->md.arc->current_seek_offset[handleTmp] +=
1637  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1638  } else
1640  free(tmp_buf);
1641  }
1642  break;
1643  case 0x68: /* GetReadStatus(handle) */
1644  /*
1645  * According to arcbios_tty_getchar() in NetBSD's
1646  * dev/arcbios/arcbios_tty.c, GetReadStatus should
1647  * return 0 if there is something available.
1648  *
1649  * TODO: Error codes are things like ARCBIOS_EAGAIN.
1650  */
1651  if (cpu->cd.mips.gpr[MIPS_GPR_A0] == ARCBIOS_STDIN) {
1653  machine->main_console_handle)? 0 : 1;
1654  } else {
1655  fatal("[ ARCBIOS GetReadStatus(%i) from "
1656  "something other than STDIN: TODO ]\n",
1657  (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);
1658  /* TODO */
1659  cpu->cd.mips.gpr[MIPS_GPR_V0] = 1;
1660  }
1661  break;
1662  case 0x6c: /* Write(handle, buf, len, &returnlen) */
1663  if (cpu->cd.mips.gpr[MIPS_GPR_A0] != ARCBIOS_STDOUT) {
1664  /*
1665  * TODO: this is just a test
1666  */
1667  int handleTmp = cpu->cd.mips.gpr[MIPS_GPR_A0];
1668  int disk_type = 0;
1669  int disk_id = arcbios_handle_to_disk_id_and_type(
1670  machine, handleTmp, &disk_type);
1671  uint64_t partition_offset = 0;
1672  int res, tmpi;
1673  uint64_t size; /* dummy */
1674  unsigned char *tmp_buf;
1675 
1676  arcbios_handle_to_start_and_size(machine,
1677  handleTmp, &partition_offset, &size);
1678 
1679  debug("[ ARCBIOS Write(%i,0x%08" PRIx64",%i,0x%08"
1680  PRIx64") ]\n", (int) cpu->cd.mips.gpr[MIPS_GPR_A0],
1681  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1],
1682  (int) cpu->cd.mips.gpr[MIPS_GPR_A2],
1683  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A3]);
1684 
1685  CHECK_ALLOCATION(tmp_buf = (unsigned char *)
1686  malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]));
1687 
1688  for (tmpi=0; tmpi<(int32_t)cpu->cd.mips.gpr[MIPS_GPR_A2]; tmpi++)
1689  cpu->memory_rw(cpu, cpu->mem,
1690  cpu->cd.mips.gpr[MIPS_GPR_A1] + tmpi,
1691  &tmp_buf[tmpi], sizeof(char), MEM_READ,
1692  CACHE_NONE);
1693 
1694  res = diskimage_access(machine, disk_id, disk_type,
1695  1, partition_offset + machine->md.arc->
1696  current_seek_offset[handleTmp], tmp_buf,
1697  cpu->cd.mips.gpr[MIPS_GPR_A2]);
1698 
1699  if (res) {
1702  cpu->cd.mips.gpr[MIPS_GPR_A2]);
1703  machine->md.arc->current_seek_offset[handleTmp] +=
1705  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1706  } else
1708  free(tmp_buf);
1709  } else {
1710  for (i=0; i<(int32_t)cpu->cd.mips.gpr[MIPS_GPR_A2];
1711  i++) {
1712  unsigned char ch = '\0';
1713  cpu->memory_rw(cpu, cpu->mem,
1714  cpu->cd.mips.gpr[MIPS_GPR_A1] + i,
1715  &ch, sizeof(ch), MEM_READ, CACHE_NONE);
1716 
1717  arcbios_putchar(cpu, ch);
1718  }
1719  }
1721  cpu->cd.mips.gpr[MIPS_GPR_A2]);
1722  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0; /* Success. */
1723  break;
1724  case 0x70: /* Seek(uint32_t handle, int64_t *ofs,
1725  uint32_t whence): uint32_t */
1726  debug("[ ARCBIOS Seek(%i,0x%08" PRIx64",%i): ",
1727  (int) cpu->cd.mips.gpr[MIPS_GPR_A0],
1728  (uint64_t)cpu->cd.mips.gpr[MIPS_GPR_A1],
1729  (int) cpu->cd.mips.gpr[MIPS_GPR_A2]);
1730 
1731  if (cpu->cd.mips.gpr[MIPS_GPR_A2] != 0) {
1732  fatal("[ ARCBIOS Seek(%i,0x%08" PRIx64",%i): "
1733  "UNIMPLEMENTED whence=%i ]\n",
1734  (int) cpu->cd.mips.gpr[MIPS_GPR_A0],
1735  (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1],
1736  (int) cpu->cd.mips.gpr[MIPS_GPR_A2],
1737  (int) cpu->cd.mips.gpr[MIPS_GPR_A2]);
1738  }
1739 
1740  {
1741  unsigned char bufTmp[8];
1742  uint64_t ofs;
1743  cpu->memory_rw(cpu, cpu->mem,
1744  cpu->cd.mips.gpr[MIPS_GPR_A1], &bufTmp[0],
1745  sizeof(bufTmp), MEM_READ, CACHE_NONE);
1746  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1747  unsigned char tmp;
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;
1752  }
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);
1757 
1759  cpu->cd.mips.gpr[MIPS_GPR_A0]] = ofs;
1760  debug("%016" PRIx64" ]\n", (uint64_t) ofs);
1761  }
1762 
1763  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0; /* Success. */
1764 
1765  break;
1766  case 0x78: /* GetEnvironmentVariable(char *) */
1767  /* Find the environment variable given by a0: */
1768  for (i=0; i<(ssize_t)sizeof(buf); i++)
1769  cpu->memory_rw(cpu, cpu->mem,
1770  cpu->cd.mips.gpr[MIPS_GPR_A0] + i,
1771  &buf[i], sizeof(char), MEM_READ, CACHE_NONE);
1772  buf[sizeof(buf)-1] = '\0';
1773  debug("[ ARCBIOS GetEnvironmentVariable(\"%s\") ]\n", buf);
1774  for (i=0; i<0x1000; i++) {
1775  /* Matching string at offset i? */
1776  int nmatches = 0;
1778  for (j=0; j<(ssize_t)strlen((char *)buf); j++) {
1779  cpu->memory_rw(cpu, cpu->mem,
1780  (uint64_t)(envptr + i + j),
1781  &ch2, sizeof(char), MEM_READ, CACHE_NONE);
1782  if (ch2 == buf[j])
1783  nmatches++;
1784  }
1785  cpu->memory_rw(cpu, cpu->mem,
1786  (uint64_t)(envptr + i +
1787  strlen((char *)buf)), &ch2, sizeof(char),
1788  MEM_READ, CACHE_NONE);
1789  if (nmatches == (int)strlen((char *)buf) && ch2=='=') {
1790  cpu->cd.mips.gpr[MIPS_GPR_V0] =
1791  envptr + i +
1792  strlen((char *)buf) + 1;
1793  return 1;
1794  }
1795  }
1796  /* Return NULL if string wasn't found. */
1797  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1798  break;
1799  case 0x7c: /* SetEnvironmentVariable(char *, char *) */
1800  debug("[ ARCBIOS SetEnvironmentVariable(\"");
1802  debug("\",\"");
1804  debug("\") ]\n");
1805  /* TODO: This is a dummy. */
1807  break;
1808  case 0x80: /* GetFileInformation() */
1809  debug("[ ARCBIOS GetFileInformation(%i,0x%x): ",
1810  (int)cpu->cd.mips.gpr[MIPS_GPR_A0],
1811  (int)cpu->cd.mips.gpr[MIPS_GPR_A1]);
1812 
1814  debug("invalid file handle ]\n");
1816  } else if (!machine->md.arc->file_handle_in_use[cpu->cd.
1817  mips.gpr[MIPS_GPR_A0]]) {
1818  debug("file handle not in use! ]\n");
1820  } else {
1821  debug("'%s' ]\n", machine->md.arc->file_handle_string[
1822  cpu->cd.mips.gpr[MIPS_GPR_A0]]);
1823  cpu->cd.mips.gpr[MIPS_GPR_V0] =
1824  arcbios_getfileinformation(cpu);
1825  }
1826  break;
1827  case 0x88: /* FlushAllCaches() */
1828  debug("[ ARCBIOS FlushAllCaches(): TODO ]\n");
1829  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1830  break;
1831  case 0x90: /* void *GetDisplayStatus(handle) */
1832  debug("[ ARCBIOS GetDisplayStatus(%i) ]\n",
1833  (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);
1834  /* TODO: handle different values of 'handle'? */
1836  break;
1837  case 0x100:
1838  /*
1839  * Undocumented, used by IRIX.
1840  */
1841  debug("[ ARCBIOS: IRIX 0x100 (?) ]\n");
1842  /* TODO */
1843  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1844  break;
1845  case 0x888:
1846  /*
1847  * Magical crash if there is no exception handling code.
1848  */
1849  fatal("EXCEPTION, but no exception handler installed yet.\n");
1850  quiet_mode = 0;
1851  cpu_register_dump(machine, cpu, 1, 0x1);
1852  cpu->running = 0;
1853  break;
1854  default:
1855  quiet_mode = 0;
1856  cpu_register_dump(machine, cpu, 1, 0x1);
1857  debug("a0 points to: ");
1859  debug("\n");
1860  fatal("ARCBIOS: unimplemented vector 0x%x\n", vector);
1861  cpu->running = 0;
1862  }
1863 
1864  return 1;
1865 }
1866 
1867 
1868 /*
1869  * arcbios_set_default_exception_handler():
1870  */
1872 {
1873  /*
1874  * The default exception handlers simply jump to 0xbfc88888,
1875  * which is then taken care of in arcbios_emul() above.
1876  *
1877  * 3c1abfc8 lui k0,0xbfc8
1878  * 375a8888 ori k0,k0,0x8888
1879  * 03400008 jr k0
1880  * 00000000 nop
1881  */
1882  store_32bit_word(cpu, 0xffffffff80000000ULL, 0x3c1abfc8);
1883  store_32bit_word(cpu, 0xffffffff80000004ULL, 0x375a8888);
1884  store_32bit_word(cpu, 0xffffffff80000008ULL, 0x03400008);
1885  store_32bit_word(cpu, 0xffffffff8000000cULL, 0x00000000);
1886 
1887  store_32bit_word(cpu, 0xffffffff80000080ULL, 0x3c1abfc8);
1888  store_32bit_word(cpu, 0xffffffff80000084ULL, 0x375a8888);
1889  store_32bit_word(cpu, 0xffffffff80000088ULL, 0x03400008);
1890  store_32bit_word(cpu, 0xffffffff8000008cULL, 0x00000000);
1891 
1892  store_32bit_word(cpu, 0xffffffff80000180ULL, 0x3c1abfc8);
1893  store_32bit_word(cpu, 0xffffffff80000184ULL, 0x375a8888);
1894  store_32bit_word(cpu, 0xffffffff80000188ULL, 0x03400008);
1895  store_32bit_word(cpu, 0xffffffff8000018cULL, 0x00000000);
1896 }
1897 
1898 
1899 /*
1900  * arcbios_add_other_components():
1901  *
1902  * TODO: How should this be synched with the hardware devices
1903  * added in machine.c?
1904  */
1905 static void arcbios_add_other_components(struct machine *machine,
1906  uint64_t system)
1907 {
1908  struct cpu *cpu = machine->cpus[0];
1909 
1910  if (machine->machine_type == MACHINE_ARC &&
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;
1917  /* uint64_t serial1, serial2; */
1918 
1919  jazzbus = arcbios_addchild_manual(cpu,
1922  0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus",
1923  system, NULL, 0);
1924 
1925  /*
1926  * DisplayController, needed by NetBSD:
1927  * TODO: NetBSD still doesn't use it :(
1928  */
1929  switch (machine->machine_subtype) {
1930  case MACHINE_ARC_JAZZ_PICA:
1931  /* Default TLB entries on PICA-61: */
1932 
1933  /* 7: 256K, asid: 0x0, v: 0xe1000000,
1934  p0: 0xfff00000(2.VG), p1: 0x0(0..G) */
1935  mips_coproc_tlb_set_entry(cpu, 7, 262144,
1936  0xffffffffe1000000ULL,
1937  0x0fff00000ULL, 0, 1, 0, 0, 0, 1, 0, 2, 0);
1938 
1939  /* 8: 64K, asid: 0x0, v: 0xe0000000,
1940  p0: 0x80000000(2DVG), p1: 0x0(0..G) */
1941  mips_coproc_tlb_set_entry(cpu, 8, 65536,
1942  0xffffffffe0000000ULL,
1943  0x080000000ULL, 0, 1, 0, 1, 0, 1, 0, 2, 0);
1944 
1945  /* 9: 64K, asid: 0x0, v: 0xe00e0000,
1946  p0: 0x800e0000(2DVG), p1: 0x800f0000(2DVG) */
1947  mips_coproc_tlb_set_entry(cpu, 9, 65536,
1948  (uint64_t)0xffffffffe00e0000ULL,
1949  (uint64_t)0x0800e0000ULL,
1950  (uint64_t)0x0800f0000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1951 
1952  /* 10: 4K, asid: 0x0, v: 0xe0100000,
1953  p0: 0xf0000000(2DVG), p1: 0x0(0..G) */
1954  mips_coproc_tlb_set_entry(cpu, 10, 4096,
1955  (uint64_t)0xffffffffe0100000ULL,
1956  (uint64_t)0x0f0000000ULL, 0,1, 0, 1, 0, 1, 0, 2, 0);
1957 
1958  /* 11: 1M, asid: 0x0, v: 0xe0200000,
1959  p0: 0x60000000(2DVG), p1: 0x60100000(2DVG) */
1960  mips_coproc_tlb_set_entry(cpu, 11, 1048576,
1961  0xffffffffe0200000ULL,
1962  0x060000000ULL, 0x060100000ULL,1,1,1,1,1, 0, 2, 2);
1963 
1964  /* 12: 1M, asid: 0x0, v: 0xe0400000,
1965  p0: 0x60200000(2DVG), p1: 0x60300000(2DVG) */
1966  mips_coproc_tlb_set_entry(cpu, 12, 1048576,
1967  0xffffffffe0400000ULL, 0x060200000ULL,
1968  0x060300000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1969 
1970  /* 13: 4M, asid: 0x0, v: 0xe0800000,
1971  p0: 0x40000000(2DVG), p1: 0x40400000(2DVG) */
1972  mips_coproc_tlb_set_entry(cpu, 13, 1048576*4,
1973  0xffffffffe0800000ULL, 0x040000000ULL,
1974  0x040400000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1975 
1976  /* 14: 16M, asid: 0x0, v: 0xe2000000,
1977  p0: 0x90000000(2DVG), p1: 0x91000000(2DVG) */
1978  mips_coproc_tlb_set_entry(cpu, 14, 1048576*16,
1979  0xffffffffe2000000ULL, 0x090000000ULL,
1980  0x091000000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1981 
1982  if (machine->x11_md.in_use) {
1983  ali_s3 = arcbios_addchild_manual(cpu,
1988  1, 2, 0, 0xffffffff, "ALI_S3",
1989  jazzbus, NULL, 0);
1990 
1996  1, 2, 0, 0xffffffff, "1024x768",
1997  ali_s3, NULL, 0);
1998  }
1999  break;
2001  if (machine->x11_md.in_use) {
2007  1, 2, 0, 0xffffffff, "VXL",
2008  jazzbus, NULL, 0);
2009 
2015  1, 2, 0, 0xffffffff, "1024x768",
2016  vxl, NULL, 0);
2017  }
2018  break;
2019  }
2020 
2021  diskcontroller = arcbios_addchild_manual(cpu,
2025  1, 2, 0, 0xffffffff, "I82077", jazzbus, NULL, 0);
2026 
2027  floppy = arcbios_addchild_manual(cpu,
2032  1, 2, 0, 0xffffffff, NULL, diskcontroller, NULL, 0);
2033 
2034  kbdctl = arcbios_addchild_manual(cpu,
2038  1, 2, 0, 0xffffffff, "I8742", jazzbus, NULL, 0);
2039 
2044  1, 2, 0, 0xffffffff, "PCAT_ENHANCED", kbdctl, NULL, 0);
2045 
2046  ptrctl = arcbios_addchild_manual(cpu,
2049  1, 2, 0, 0xffffffff, "I8742", jazzbus, NULL, 0);
2050 
2054  1, 2, 0, 0xffffffff, "PS2 MOUSE", ptrctl, NULL, 0);
2055 
2056 /* These cause Windows NT to bug out. */
2057 #if 0
2058  serial1 = arcbios_addchild_manual(cpu,
2062  1, 2, 0, 0xffffffff, "COM1", jazzbus, NULL, 0);
2063 
2064  serial2 = arcbios_addchild_manual(cpu,
2068  1, 2, 0, 0xffffffff, "COM1", jazzbus, NULL, 0);
2069 #endif
2070 
2071  paral = arcbios_addchild_manual(cpu,
2075  1, 2, 0, 0xffffffff, "LPT1", jazzbus, NULL, 0);
2076 
2077  audio = arcbios_addchild_manual(cpu,
2081  1, 2, 0, 0xffffffff, "MAGNUM", jazzbus, NULL, 0);
2082 
2085  0, 1, 2, 0, 0xffffffff, "EISA", system, NULL, 0);
2086 
2087  {
2088  unsigned char config[78];
2089  memset(config, 0, sizeof(config));
2090 
2091 /* config data version: 1, revision: 2, count: 4 */
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;
2095 
2096 /*
2097  type: Interrupt
2098  share_disposition: DeviceExclusive, flags: LevelSensitive
2099  level: 4, vector: 22, reserved1: 0
2100 */
2101  config[8] = arc_CmResourceTypeInterrupt;
2104  config[12] = 4;
2105  config[16] = 22;
2106  config[20] = 0;
2107 
2108 /*
2109  type: Memory
2110  share_disposition: DeviceExclusive, flags: ReadWrite
2111  start: 0x 0 80002000, length: 0x1000
2112 */
2113  config[24] = arc_CmResourceTypeMemory;
2115  config[26] = arc_CmResourceMemoryReadWrite;
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;
2119 
2120 /*
2121  type: DMA
2122  share_disposition: DeviceExclusive, flags: 0x0
2123  channel: 0, port: 0, reserved1: 0
2124 */
2125  config[40] = arc_CmResourceTypeDMA;
2127 /* 42..43 = flags, 44,45,46,47 = channel, 48,49,50,51 = port, 52,53,54,55
2128  = reserved */
2129 
2130 /* type: DeviceSpecific
2131  share_disposition: DeviceExclusive, flags: 0x0
2132  datasize: 6, reserved1: 0, reserved2: 0
2133  data: [0x1:0x0:0x2:0x0:0x7:0x30]
2134 */
2135  config[56] = arc_CmResourceTypeDeviceSpecific;
2137 /* 58,59 = flags 60,61,62,63 = data size, 64..71 = reserved */
2138  config[60] = 6;
2139 /* 72..77 = the data */
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));
2147 
2149  }
2150  }
2151 }
2152 
2153 
2154 /*
2155  * arcbios_console_init():
2156  *
2157  * Called from machine.c whenever an ARC-based machine is running with
2158  * a graphical VGA-style framebuffer, which can be used as console.
2159  */
2161  uint64_t vram, uint64_t ctrlregs)
2162 {
2163  if (machine->md.arc == NULL) {
2165  malloc(sizeof(struct machine_arcbios)));
2166  memset(machine->md.arc, 0, sizeof(struct machine_arcbios));
2167  }
2168 
2169  machine->md.arc->vgaconsole = 1;
2170 
2171  machine->md.arc->console_vram = vram;
2172  machine->md.arc->console_ctrlregs = ctrlregs;
2176  machine->md.arc->escape_sequence[0] = '\0';
2177 }
2178 
2179 
2180 /*
2181  * arc_environment_setup():
2182  *
2183  * Initialize the emulated environment variables.
2184  */
2185 static void arc_environment_setup(struct machine *machine, int is64bit,
2186  const char *primary_ether_addr)
2187 {
2188  size_t bootpath_len = 500;
2189  char *init_bootpath;
2190  uint64_t addr, addr2;
2191  struct cpu *cpu = machine->cpus[0];
2192 
2193  /*
2194  * Boot string in ARC format:
2195  *
2196  * TODO: How about floppies? multi()disk()fdisk()
2197  * Is tftp() good for netbooting?
2198  */
2199  CHECK_ALLOCATION(init_bootpath = (char *) malloc(bootpath_len));
2200  init_bootpath[0] = '\0';
2201 
2202  if (machine->bootdev_id < 0 || machine->force_netboot) {
2203  snprintf(init_bootpath, bootpath_len, "tftp()");
2204  } else {
2205  /* TODO: Make this nicer. */
2206  if (machine->machine_type == MACHINE_SGI) {
2207  if (machine->machine_subtype == 30)
2208  strlcat(init_bootpath, "xio(0)pci(15)",
2209  bootpath_len);
2210  if (machine->machine_subtype == 32)
2211  strlcat(init_bootpath, "pci(0)",
2212  bootpath_len);
2213  }
2214 
2217  snprintf(init_bootpath + strlen(init_bootpath),
2218  bootpath_len - strlen(init_bootpath),
2219  "scsi(0)cdrom(%i)fdisk(0)", machine->bootdev_id);
2220  else
2221  snprintf(init_bootpath + strlen(init_bootpath),
2222  bootpath_len - strlen(init_bootpath),
2223  "scsi(0)disk(%i)rdisk(0)partition(1)",
2224  machine->bootdev_id);
2225  }
2226 
2228  strlcat(init_bootpath, "\\", bootpath_len);
2229 
2230  CHECK_ALLOCATION(machine->bootstr = (char *) malloc(ARC_BOOTSTR_BUFLEN));
2231 
2232  strlcpy(machine->bootstr, init_bootpath, ARC_BOOTSTR_BUFLEN);
2235  fprintf(stderr, "boot string too long?\n");
2236  exit(1);
2237  }
2238 
2239  /* Boot args., eg "-a" */
2241 
2242  /* argc, argv, envp in a0, a1, a2: */
2243  cpu->cd.mips.gpr[MIPS_GPR_A0] = 0; /* note: argc is increased later */
2244 
2245  /* TODO: not needed? */
2246  cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
2247  (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
2248 
2249  /* Set up argc/argv: */
2251  addr2 = ARC_ARGV_START;
2252  cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
2253 
2254  /* bootstr: */
2255  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2257  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
2258 
2259  /* bootarg: */
2260  if (machine->bootarg[0] != '\0') {
2261  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2263  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
2264  }
2265 
2266  store_pointer_and_advance(cpu, &addr2, 0, is64bit);
2267 
2268  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
2269 
2270  if (machine->machine_type == MACHINE_SGI) {
2271  /*
2272  * The SGI O2 PROM contains an "env" section header like this:
2273  *
2274  * 00004000 00 00 00 00 00 00 00 00 53 48 44 52 00 00 04 00 |........SHDR....|
2275  * 00004010 03 03 00 00 65 6e 76 00 00 00 00 00 00 00 00 00 |....env.........|
2276  * 00004020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
2277  * 00004030 00 00 00 00 31 2e 30 00 00 00 00 00 13 18 11 ae |....1.0.........|
2278  *
2279  * followed by environment variables at 0x4000. It is not required
2280  * by NetBSD/OpenBSD/Linux, but Irix seems to hardcodedly look into
2281  * the PROM address space for this header.
2282  */
2283  store_32bit_word(cpu, ARC_ENV_SGI + 0x08, 0x53484452);
2284  store_32bit_word(cpu, ARC_ENV_SGI + 0x0c, 0x00000400);
2285  store_32bit_word(cpu, ARC_ENV_SGI + 0x10, 0x03030000);
2286  store_32bit_word(cpu, ARC_ENV_SGI + 0x14, 0x656e7600);
2287  store_32bit_word(cpu, ARC_ENV_SGI + 0x34, 0x312e3000);
2288  store_32bit_word(cpu, ARC_ENV_SGI + 0x3c, 0x131811ae);
2290  }
2291 
2292  /*
2293  * Add environment variables. For each variable, add it
2294  * as a string using add_environment_string(), and add a
2295  * pointer to it to the ARC_ENV_POINTERS array.
2296  */
2297  if (machine->machine_type == MACHINE_SGI) {
2298  if (machine->x11_md.in_use) {
2299  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2300  add_environment_string(cpu, "ConsoleIn=keyboard()",
2301  &addr);
2302  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2303  add_environment_string(cpu, "ConsoleOut=video()",
2304  &addr);
2305 
2306  /* g for graphical mode. G for graphical mode
2307  with SGI logo visible on Irix? */
2308  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2309  add_environment_string(cpu, "console=g", &addr);
2310 
2311  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2312  add_environment_string(cpu, "gfx=alive", &addr);
2313  } else {
2314  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2315  add_environment_string(cpu, "ConsoleIn=serial(0)",
2316  &addr);
2317  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2318  add_environment_string(cpu, "ConsoleOut=serial(0)",
2319  &addr);
2320 
2321  /* 'd' or 'd2' in Irix, 'ttyS0' in Linux? */
2322  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2323  add_environment_string(cpu, "console=d", &addr);
2324 
2325  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2326  add_environment_string(cpu, "gfx=dead", &addr);
2327  }
2328 
2329  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2330  add_environment_string(cpu, "AutoLoad=No", &addr);
2331 
2332  if (machine->bootdev_id < 0 || machine->force_netboot) {
2333  /*
2334  * diskless=1 means boot from network disk? (nfs?)
2335  * diskless=2 means boot from network tape?
2336  */
2337  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2338  add_environment_string(cpu, "diskless=1", &addr);
2339 
2340  // store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2341  // add_environment_string(cpu, "tapedevice=bootp()10.0.0.2:/dev/tape", &addr);
2342 
2343  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2344  add_environment_string(cpu, "bootfile=bootp()10.0.0.2:/var/boot/client/unix", &addr);
2345 
2346  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2348  "SystemPartition=bootp()10.0.0.2:/var/boot/client",
2349  &addr);
2350  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2352  "root=xyz",
2353  &addr);
2354  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2356  "OSLoadPartition=bootp()10.0.0.2:/var/boot/client",
2357  &addr);
2358  } else {
2359  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2360  add_environment_string(cpu, "diskless=0", &addr);
2361 
2362  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2364  "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)",
2365  &addr);
2366  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2368  "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)",
2369  &addr);
2370  }
2371 
2372  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2373  add_environment_string(cpu, "volume=80", &addr);
2374  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2375  add_environment_string(cpu, "sgilogo=y", &addr);
2376 
2377  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2378  add_environment_string(cpu, "monitor=h", &addr);
2379  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2380  add_environment_string(cpu, "TimeZone=GMT", &addr);
2381  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2382  add_environment_string(cpu, "nogfxkbd=1", &addr);
2383 
2384  /* TODO IP30: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' */
2385 
2386  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2387  add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
2388  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2389  add_environment_string(cpu, "OSLoader=sash", &addr);
2390  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2391  add_environment_string(cpu, "kernname=unix", &addr);
2392 
2393  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2394  add_environment_string(cpu, "rbaud=9600", &addr);
2395  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2396  add_environment_string(cpu, "rebound=y", &addr);
2397  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2398  add_environment_string(cpu, "crt_option=1", &addr);
2399  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2400  add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
2401  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2402  add_environment_string(cpu, "netmask=255.0.0.0", &addr);
2403  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2404  add_environment_string(cpu, "dlserver=10.0.0.2", &addr);
2405  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2406  add_environment_string(cpu, "srvaddr=10.0.0.2", &addr);
2407 
2408  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2409  add_environment_string(cpu, "keybd=US", &addr);
2410 
2411  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2412  add_environment_string(cpu, "cpufreq=3", &addr);
2413  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2414  add_environment_string(cpu, "dbaud=9600", &addr);
2415  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2416  add_environment_string(cpu, primary_ether_addr, &addr);
2417 
2418  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2419  add_environment_string(cpu, "verbose=1", &addr);
2420  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2421  // showconfig 0 means don't show. 1 means show some.
2422  // 2 means show more. TODO: higher values?
2423  add_environment_string(cpu, "showconfig=255", &addr);
2424  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2425  add_environment_string(cpu, "diagmode=v", &addr);
2426  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2427  add_environment_string(cpu, "debug_bigmem=1", &addr);
2428  } else {
2429  char *tmp;
2430  size_t mlen = ARC_BOOTSTR_BUFLEN;
2431  CHECK_ALLOCATION(tmp = (char *) malloc(mlen));
2432  snprintf(tmp, mlen, "OSLOADOPTIONS=%s", machine->bootarg);
2433 
2434  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2436 
2437  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2438  snprintf(tmp, mlen,
2439  "OSLOADPARTITION=scsi(0)disk(%d)rdisk(0)partition(1)",
2440  machine->bootdev_id);
2442  free(tmp);
2443 
2444  if (machine->x11_md.in_use) {
2445  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2447  "CONSOLEIN=multi()key()keyboard()console()", &addr);
2448  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2450  "CONSOLEOUT=multi()video()monitor()console()",
2451  &addr);
2452  } else {
2453  /* TODO: serial console for ARC? */
2454  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2456  "CONSOLEIN=multi()serial(0)", &addr);
2457  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2459  "CONSOLEOUT=multi()serial(0)", &addr);
2460  }
2461  }
2462 
2463  /* End the environment strings with an empty zero-terminated
2464  string, and the envp array with a NULL pointer. */
2465  add_environment_string(cpu, "", &addr); /* the end */
2466  store_pointer_and_advance(cpu, &addr2, 0, is64bit);
2467 
2468  /* Return address: (0x20 = ReturnFromMain()) */
2470 }
2471 
2472 
2473 /*
2474  * arcbios_init():
2475  *
2476  * Should be called before any other arcbios function is used. An exception
2477  * is arcbios_console_init(), which may be called before this function.
2478  *
2479  * TODO: Refactor; this is too long.
2480  */
2481 void arcbios_init(struct machine *machine, int is64bit, uint64_t sgi_ram_offset,
2482  const char *primary_ether_addr, uint8_t *primary_ether_macaddr)
2483 {
2484  int i, alloclen = 20;
2485  char *name;
2486  uint64_t arc_reserved, mem_base;
2487  struct cpu *cpu = machine->cpus[0];
2490  uint64_t system = 0;
2491  struct arcbios_spb arcbios_spb;
2493 
2494  if (machine->md.arc == NULL) {
2496  malloc(sizeof(struct machine_arcbios)));
2497  memset(machine->md.arc, 0, sizeof(struct machine_arcbios));
2498  }
2499 
2500  machine->md.arc->arc_64bit = is64bit;
2501  machine->md.arc->wordlen = is64bit? sizeof(uint64_t) : sizeof(uint32_t);
2502 
2505 
2506  if (machine->physical_ram_in_mb < 16)
2507  fprintf(stderr, "WARNING! The ARC platform specification "
2508  "doesn't allow less than 16 MB of RAM. Continuing "
2509  "anyway.\n");
2510 
2511  /* File handles 0, 1, and 2 are stdin, stdout, and stderr. */
2512  for (i=0; i<ARC_MAX_HANDLES; i++) {
2513  machine->md.arc->file_handle_in_use[i] = i<3? 1 : 0;
2514  machine->md.arc->file_handle_string[i] = i>=3? NULL :
2515  (i==0? "(stdin)" : (i==1? "(stdout)" : "(stderr)"));
2516  machine->md.arc->current_seek_offset[i] = 0;
2517  }
2518 
2519  if (!machine->x11_md.in_use)
2520  machine->md.arc->vgaconsole = 0;
2521 
2522  if (machine->md.arc->vgaconsole) {
2523  char tmpstr[100];
2524  int x, y;
2525 
2526  machine->md.arc->console_curcolor = 0x1f;
2527  for (y=0; y<machine->md.arc->console_maxy; y++)
2528  for (x=0; x<machine->md.arc->console_maxx; x++)
2529  arcbios_putcell(cpu, ' ', x, y);
2530 
2531  machine->md.arc->console_curx = 0;
2532  machine->md.arc->console_cury = 0;
2533 
2534  arcbios_putstring(cpu, "GXemul " VERSION" ARCBIOS emulation\n");
2535 
2536  snprintf(tmpstr, sizeof(tmpstr), "%i cpu%s (%s), %i MB "
2537  "memory\n\n", machine->ncpus, machine->ncpus > 1? "s" : "",
2538  cpu->cd.mips.cpu_type.name,
2540  arcbios_putstring(cpu, tmpstr);
2541  }
2542 
2544 
2545  memset(&arcbios_sysid, 0, sizeof(arcbios_sysid));
2546  if (machine->machine_type == MACHINE_SGI) {
2547  /* Vendor ID, max 8 chars: */
2548  strncpy(arcbios_sysid.VendorId, "SGI", 3);
2549  switch (machine->machine_subtype) {
2550  case 22:
2551  strncpy(arcbios_sysid.ProductId,
2552  "87654321", 8); /* some kind of ID? */
2553  break;
2554  case 32:
2555  strncpy(arcbios_sysid.ProductId, "8", 1);
2556  /* 6 or 8 (?) */
2557  break;
2558  default:
2559  snprintf(arcbios_sysid.ProductId, 8, "IP%i",
2561  }
2562  } else {
2563  switch (machine->machine_subtype) {
2564  case MACHINE_ARC_JAZZ_PICA:
2565  strncpy(arcbios_sysid.VendorId, "MIPS MAG", 8);
2566  strncpy(arcbios_sysid.ProductId, "ijkl", 4);
2567  break;
2569  strncpy(arcbios_sysid.VendorId, "MIPS MAG", 8);
2570  strncpy(arcbios_sysid.ProductId, "ijkl", 4);
2571  break;
2572  default:
2573  fatal("error in machine.c sysid\n");
2574  exit(1);
2575  }
2576  }
2577 
2579  sizeof(arcbios_sysid));
2580 
2581  arcbios_get_dsp_stat(cpu, &arcbios_dsp_stat);
2583  sizeof(arcbios_dsp_stat));
2584 
2585  /*
2586  * The first 12 MBs of RAM are simply reserved... this simplifies
2587  * things a lot. If there's more than 512MB of RAM, it has to be
2588  * split in two, according to the ARC spec.
2589  *
2590  * However, the region of physical address space between 0x10000000
2591  * and 0x1fffffff (256 - 512 MB) is sometimes occupied by memory
2592  * mapped devices, for example in the SGI O2, so that portion can not
2593  * be used.
2594  *
2595  * Instead, any high memory needs to be added using a machine-specific
2596  * high address.
2597  */
2598  int reserved_bottom_mem_in_mb = 12;
2599  int free_type = ARCBIOS_MEM_FreeMemory;
2600 
2602 
2603  arc_reserved = 0x2000;
2605  arc_reserved = 0x4000;
2606 
2607  arcbios_add_memory_descriptor(cpu, 0, arc_reserved,
2609  arcbios_add_memory_descriptor(cpu, sgi_ram_offset + arc_reserved,
2610  0x60000-arc_reserved, ARCBIOS_MEM_FirmwareTemporary);
2611 
2612  uint64_t ram = 0;
2613 
2614  // Default is to use a physical memory base around zero (0).
2615  mem_base = sgi_ram_offset / 1048576;
2616 
2617  while (ram < machine->physical_ram_in_mb) {
2618  uint64_t to_add = machine->physical_ram_in_mb - ram;
2619 
2620  if (to_add > 256)
2621  to_add = 256;
2622 
2623  if (ram == 0) {
2624  // Skip first few MB of RAM, for reserved structures.
2625  ram += reserved_bottom_mem_in_mb;
2626  mem_base += reserved_bottom_mem_in_mb;
2627  to_add -= reserved_bottom_mem_in_mb;
2628  }
2629 
2630  arcbios_add_memory_descriptor(cpu, mem_base * 1048576,
2631  to_add * 1048576, free_type);
2632 
2633  ram += to_add;
2634  mem_base += to_add;
2635 
2636  if (mem_base == 256) {
2637  if (machine->machine_type == MACHINE_SGI &&
2638  machine->machine_subtype == 32) {
2639  // mem_base = 0x50000000 / 1048576;
2640  // Actually, the above does not seem to work.
2641  // Perhaps the ARCS in the O2 simply says
2642  // 256 MB regardless of how much more there
2643  // is in the machine?
2644  break;
2645  } else {
2646  fatal("Ignoring RAM above 256 MB! (Not yet "
2647  "implemented for this machine type.)\n");
2648  break;
2649  }
2650  }
2651  }
2652 
2653  /*
2654  * Components: (this is an example of what a system could look like)
2655  *
2656  * [System]
2657  * [CPU] (one for each cpu)
2658  * [FPU] (one for each cpu)
2659  * [CPU Caches]
2660  * [Memory]
2661  * [Ethernet]
2662  * [Serial]
2663  * [SCSI]
2664  * [Disk]
2665  *
2666  * Here's a good list of what hardware is in different IP-models:
2667  * http://www.linux-mips.org/archives/linux-mips/2001-03/msg00101.html
2668  */
2669 
2670  if (machine->machine_name == NULL)
2671  fatal("ERROR: machine_name == NULL\n");
2672 
2673  /* Add the root node: */
2674  switch (machine->machine_type) {
2675  case MACHINE_SGI:
2676  CHECK_ALLOCATION(name = (char *) malloc(alloclen));
2677  snprintf(name, alloclen, "SGI-IP%i",
2679 
2680  /* A very special case for IP24 (which identifies itself
2681  as an IP22): */
2682  if (machine->machine_subtype == 24)
2683  snprintf(name, alloclen, "SGI-IP22");
2684  break;
2685  case MACHINE_ARC:
2686  /* ARC: */
2687  switch (machine->machine_subtype) {
2688  case MACHINE_ARC_JAZZ_PICA:
2689  name = strdup("PICA-61");
2690  break;
2692  name = strdup("Microsoft-Jazz");
2693  break;
2694  default:
2695  fatal("Unimplemented ARC machine type %i\n",
2697  exit(1);
2698  }
2699  break;
2700  default:
2701  fatal("ERROR: non-SGI and non-ARC?\n");
2702  exit(1);
2703  }
2704 
2706  COMPONENT_TYPE_ARC, 0,1,2,0, 0xffffffff, name, 0/*ROOT*/, NULL, 0);
2707  debug("ARC system @ 0x%" PRIx64" (\"%s\")\n", (uint64_t) system, name);
2708 
2709 
2710  /*
2711  * Add tree nodes for CPUs and their caches:
2712  */
2713 
2714  for (i=0; i<machine->ncpus; i++) {
2715  uint64_t cpuaddr, fpu=0, picache, pdcache, sdcache=0;
2716  int cache_size, cache_line_size;
2717  unsigned int jj;
2718  char arc_cpu_name[100];
2719  char arc_fpc_name[105];
2720 
2721  snprintf(arc_cpu_name, sizeof(arc_cpu_name),
2722  "MIPS-%s", machine->cpu_name);
2723 
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');
2728 
2729  strlcpy(arc_fpc_name, arc_cpu_name, sizeof(arc_fpc_name));
2730  strlcat(arc_fpc_name, "FPC", sizeof(arc_fpc_name));
2731 
2732  cpuaddr = arcbios_addchild_manual(cpu,
2734  0, 1, 2, i, 0xffffffff, arc_cpu_name, system, NULL, 0);
2735 
2736  /*
2737  * TODO: This was in the ARC specs, but it isn't really used
2738  * by ARC implementations? At least SGI-IP32 uses it.
2739  */
2743  0, 1, 2, 0, 0xffffffff, arc_fpc_name, cpuaddr,
2744  NULL, 0);
2745 
2746  cache_size = DEFAULT_PCACHE_SIZE - 12;
2747  if (cpu->cd.mips.cache_picache)
2748  cache_size = cpu->cd.mips.cache_picache - 12;
2749  if (cache_size < 0)
2750  cache_size = 0;
2751 
2752  cache_line_size = DEFAULT_PCACHE_LINESIZE;
2754  cache_line_size = cpu->cd.mips.cache_picache_linesize;
2755  if (cache_line_size < 0)
2756  cache_line_size = 0;
2757 
2758  picache = arcbios_addchild_manual(cpu,
2760  0, 1, 2,
2761  /*
2762  * Key bits: 0xXXYYZZZZ
2763  * XX is refill-size.
2764  * Cache line size is 1 << YY,
2765  * Cache size is 4KB << ZZZZ.
2766  */
2767  0x01000000 + (cache_line_size << 16) + cache_size,
2768  /* 32 bytes per line, default = 32 KB total */
2769  0xffffffff, NULL, cpuaddr, NULL, 0);
2770 
2771  cache_size = DEFAULT_PCACHE_SIZE - 12;
2772  if (cpu->cd.mips.cache_pdcache)
2773  cache_size = cpu->cd.mips.cache_pdcache - 12;
2774  if (cache_size < 0)
2775  cache_size = 0;
2776 
2777  cache_line_size = DEFAULT_PCACHE_LINESIZE;
2779  cache_line_size = cpu->cd.mips.cache_pdcache_linesize;
2780  if (cache_line_size < 0)
2781  cache_line_size = 0;
2782 
2783  pdcache = arcbios_addchild_manual(cpu,
2786  /*
2787  * Key bits: 0xYYZZZZ
2788  * Cache line size is 1 << YY,
2789  * Cache size is 4KB << ZZZZ.
2790  */
2791  0x01000000 + (cache_line_size << 16) + cache_size,
2792  /* 32 bytes per line, default = 32 KB total */
2793  0xffffffff, NULL, cpuaddr, NULL, 0);
2794 
2795  if (cpu->cd.mips.cache_secondary >= 12) {
2796  cache_size = cpu->cd.mips.cache_secondary - 12;
2797 
2798  cache_line_size = 6; /* 64 bytes default */
2800  cache_line_size = cpu->cd.mips.
2801  cache_secondary_linesize;
2802  if (cache_line_size < 0)
2803  cache_line_size = 0;
2804 
2805  sdcache = arcbios_addchild_manual(cpu,
2808  /*
2809  * Key bits: 0xYYZZZZ
2810  * Cache line size is 1 << YY,
2811  * Cache size is 4KB << ZZZZ.
2812  */
2813  0x01000000 + (cache_line_size << 16) + cache_size,
2814  /* 64 bytes per line, default = 1 MB total */
2815  0xffffffff, NULL, cpuaddr, NULL, 0);
2816  }
2817 
2818  debug("ARC cpu%i @ 0x%" PRIx64, i, (uint64_t) cpuaddr);
2819 
2820  if (fpu != 0)
2821  debug(" (fpu @ 0x%" PRIx64")\n", (uint64_t) fpu);
2822  else
2823  debug("\n");
2824 
2825  debug(" picache @ 0x%" PRIx64", pdcache @ 0x%" PRIx64"\n",
2826  (uint64_t) picache, (uint64_t) pdcache);
2827 
2828  if (cpu->cd.mips.cache_secondary >= 12)
2829  debug(" sdcache @ 0x%" PRIx64"\n",
2830  (uint64_t) sdcache);
2831 
2832  if (machine->machine_type == MACHINE_SGI) {
2833  /* TODO: Memory amount (and base address?)! */
2834  uint64_t memory = arcbios_addchild_manual(cpu,
2836  COMPONENT_TYPE_MemoryUnit, 0, 1, 2, 0,
2837  0xffffffff, "memory", cpuaddr, NULL, 0);
2838  debug("ARC memory @ 0x%" PRIx64"\n", (uint64_t) memory);
2839  }
2840  }
2841 
2842 
2843  /*
2844  * Add other components:
2845  *
2846  * TODO: How should this be synched with the hardware devices
2847  * added in machine.c?
2848  */
2849 
2850  arcbios_add_other_components(machine, system);
2851 
2852 
2853  /*
2854  * Defalt TLB entry for 64-bit SGI machines:
2855  */
2856  if (machine->machine_type == MACHINE_SGI) {
2857  switch (machine->machine_subtype) {
2858  case 12:
2859  /* TODO: Not on 12? */
2860  break;
2861  case 32:
2862  /* Not needed for SGI O2? */
2863  break;
2864  default:
2865  mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,
2866  0xc000000000000000ULL, 0, 1048576*16, 1,1,1,1,1, 0, 2, 2);
2867  }
2868  }
2869 
2870 
2871  /*
2872  * Set up Firmware Vectors:
2873  */
2875  ARC_FIRMWARE_ENTRIES, 0x10000, "[ARCBIOS entry]", 0, 1);
2876 
2877  for (i=0; i<100; i++) {
2878  if (is64bit) {
2880  ARC_FIRMWARE_ENTRIES + i*8);
2882  ARC_PRIVATE_ENTRIES + i*8);
2883 
2884  /* "Magic trap" instruction: */
2886  0x00c0de0c);
2888  0x00c0de0c);
2889  } else {
2891  ARC_FIRMWARE_ENTRIES + i*4);
2893  ARC_PRIVATE_ENTRIES + i*4);
2894 
2895  /* "Magic trap" instruction: */
2897  0x00c0de0c);
2899  0x00c0de0c);
2900  }
2901  }
2902 
2903 
2904  /*
2905  * Set up the ARC SPD:
2906  */
2907  if (is64bit) {
2908  /* ARCS64 SPD (TODO: This is just a guess) */
2909  memset(&arcbios_spb_64, 0, sizeof(arcbios_spb_64));
2910  store_64bit_word_in_host(cpu, (unsigned char *)
2912  store_16bit_word_in_host(cpu, (unsigned char *)
2913  &arcbios_spb_64.Version, 64);
2914  store_16bit_word_in_host(cpu, (unsigned char *)
2915  &arcbios_spb_64.Revision, 0);
2916  store_64bit_word_in_host(cpu, (unsigned char *)
2919  sizeof(arcbios_spb_64));
2920  } else {
2921  /* ARCBIOS SPB: (For ARC and 32-bit SGI modes) */
2922  memset(&arcbios_spb, 0, sizeof(arcbios_spb));
2923  store_32bit_word_in_host(cpu, (unsigned char *)
2925  store_32bit_word_in_host(cpu, (unsigned char *)
2926  &arcbios_spb.SPBLength, sizeof(arcbios_spb));
2927  store_16bit_word_in_host(cpu, (unsigned char *)
2928  &arcbios_spb.Version, 1);
2929  store_16bit_word_in_host(cpu, (unsigned char *)
2931  MACHINE_SGI? 10 : 2);
2932  store_32bit_word_in_host(cpu, (unsigned char *)
2934  store_32bit_word_in_host(cpu, (unsigned char *)
2935  &arcbios_spb.FirmwareVectorLength, 100 * 4); /* ? */
2936  store_32bit_word_in_host(cpu, (unsigned char *)
2938  store_32bit_word_in_host(cpu, (unsigned char *)
2939  &arcbios_spb.PrivateVectorLength, 100 * 4); /* ? */
2941  sizeof(arcbios_spb));
2942  }
2943 
2944 
2945  /*
2946  * TODO: How to build the component tree intermixed with
2947  * the rest of device initialization?
2948  */
2949 
2950  arc_environment_setup(machine, is64bit, primary_ether_addr);
2951 }
2952 
machine_arcbios::string_to_component_value
uint64_t string_to_component_value[MAX_STRING_TO_COMPONENT]
Definition: machine_arc.h:80
arcbios_component64::AffinityMask
uint64_t AffinityMask
Definition: sgi_arcbios.h:176
mips_cpu::cpu_type
struct mips_cpu_type_def cpu_type
Definition: cpu_mips.h:206
arcbios_spb_64::FirmwareVector
uint64_t FirmwareVector
Definition: sgi_arcbios.h:140
machine::bootdev_type
int bootdev_type
Definition: machine.h:153
COMPONENT_CLASS_PeripheralClass
#define COMPONENT_CLASS_PeripheralClass
Definition: sgi_arcbios.h:202
mips_cpu::cache_pdcache
int cache_pdcache
Definition: cpu_mips.h:261
cpu_register_dump
void cpu_register_dump(struct machine *m, struct cpu *cpu, int gprs, int coprocs)
Definition: cpu.cc:212
machine::machine_subtype
int machine_subtype
Definition: machine.h:112
MIPS_GPR_A0
#define MIPS_GPR_A0
Definition: cpu_mips.h:138
arcbios_spb::Version
uint16_t Version
Definition: sgi_arcbios.h:106
tick_functions::extra
void ** extra
Definition: machine.h:77
arcbios_component64::Identifier
uint64_t Identifier
Definition: sgi_arcbios.h:179
machine_arcbios::in_escape_sequence
int in_escape_sequence
Definition: machine_arc.h:58
machine::bootarg
char * bootarg
Definition: machine.h:156
arcbios_console_init
void arcbios_console_init(struct machine *machine, uint64_t vram, uint64_t ctrlregs)
Definition: arcbios.cc:2160
console_putchar
void console_putchar(int handle, int ch)
Definition: console.cc:410
arcbios_spb::Revision
uint16_t Revision
Definition: sgi_arcbios.h:107
arc_CmResourceTypeMemory
@ arc_CmResourceTypeMemory
Definition: arcbios_other.h:127
COMPONENT_TYPE_KeyboardPeripheral
#define COMPONENT_TYPE_KeyboardPeripheral
Definition: sgi_arcbios.h:303
ARCBIOS_EBADF
#define ARCBIOS_EBADF
Definition: sgi_arcbios.h:75
arcbios_component::Type
uint32_t Type
Definition: sgi_arcbios.h:157
cpu::running
uint8_t running
Definition: cpu.h:353
arc_CmResourceMemoryReadWrite
@ arc_CmResourceMemoryReadWrite
Definition: arcbios_other.h:205
MAX_CONFIG_DATA
#define MAX_CONFIG_DATA
Definition: machine_arc.h:46
machine::symbol_context
struct symbol_context symbol_context
Definition: machine.h:144
store_buf
void store_buf(struct cpu *cpu, uint64_t addr, const char *s, size_t len)
Definition: memory.cc:826
arcbios_mem64::BasePage
uint64_t BasePage
Definition: sgi_arcbios.h:352
diskimage.h
ARC_PRIVATE_VECTORS
#define ARC_PRIVATE_VECTORS
Definition: arcbios.h:106
MIPS_GPR_SP
#define MIPS_GPR_SP
Definition: cpu_mips.h:163
mips_cpu::cache_secondary_linesize
int cache_secondary_linesize
Definition: cpu_mips.h:265
memory
Definition: memory.h:75
COMPONENT_TYPE_PrimaryDCache
#define COMPONENT_TYPE_PrimaryDCache
Definition: sgi_arcbios.h:269
debug
#define debug
Definition: dev_adb.cc:57
ARC_CONFIG_DATA_ADDR
#define ARC_CONFIG_DATA_ADDR
Definition: arcbios.h:104
mips_cpu::cache_secondary
int cache_secondary
Definition: cpu_mips.h:262
arcbios_spb
Definition: sgi_arcbios.h:103
COMPONENT_TYPE_DisplayController
#define COMPONENT_TYPE_DisplayController
Definition: sgi_arcbios.h:288
arcbios_private_emul
void arcbios_private_emul(struct cpu *cpu)
Definition: arcbios.cc:1114
MACHINE_ARC_JAZZ_PICA
#define MACHINE_ARC_JAZZ_PICA
Definition: machine.h:301
machine::cpus
struct cpu ** cpus
Definition: machine.h:140
ARC_ENV_SGI
#define ARC_ENV_SGI
Definition: arcbios.h:98
machine_arcbios::console_ctrlregs
uint64_t console_ctrlregs
Definition: machine_arc.h:56
machine_arcbios::file_handle_in_use
int file_handle_in_use[ARC_MAX_HANDLES]
Definition: machine_arc.h:67
arcbios_spb::FirmwareVectorLength
uint32_t FirmwareVectorLength
Definition: sgi_arcbios.h:112
COMPONENT_TYPE_MonitorPeripheral
#define COMPONENT_TYPE_MonitorPeripheral
Definition: sgi_arcbios.h:300
store_64bit_word
int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64)
Definition: memory.cc:752
COMPONENT_FLAG_Removable
#define COMPONENT_FLAG_Removable
Definition: sgi_arcbios.h:316
if
addr & if(addr >=0x24 &&page !=NULL)
Definition: tmp_arm_multi.cc:56
mips_cpu_type_def::name
const char * name
Definition: cpu_mips.h:47
add_environment_string
void add_environment_string(struct cpu *cpu, const char *s, uint64_t *addr)
Definition: memory.cc:710
arcbios_component::Key
uint32_t Key
Definition: sgi_arcbios.h:161
arcbios_sysid::VendorId
char VendorId[ARCBIOS_SYSID_FIELDLEN]
Definition: sgi_arcbios.h:335
ARC_PRIVATE_ENTRIES
#define ARC_PRIVATE_ENTRIES
Definition: arcbios.h:107
ARCBIOS_EIO
#define ARCBIOS_EIO
Definition: sgi_arcbios.h:79
MIPS_GPR_V0
#define MIPS_GPR_V0
Definition: cpu_mips.h:136
MIPS_GPR_A1
#define MIPS_GPR_A1
Definition: cpu_mips.h:139
COMPONENT_CLASS_SystemClass
#define COMPONENT_CLASS_SystemClass
Definition: sgi_arcbios.h:197
arcbios_component64::Revision
uint16_t Revision
Definition: sgi_arcbios.h:174
arcbios_sysid::ProductId
char ProductId[ARCBIOS_SYSID_FIELDLEN]
Definition: sgi_arcbios.h:336
COMPONENT_CLASS_MemoryClass
#define COMPONENT_CLASS_MemoryClass
Definition: sgi_arcbios.h:203
machine_arcbios::memdescriptor_base
uint64_t memdescriptor_base
Definition: machine_arc.h:73
arcbios_dsp_stat
Definition: sgi_arcbios.h:379
MEM_READ
#define MEM_READ
Definition: memory.h:116
arcbios_spb_64
Definition: sgi_arcbios.h:129
cpu::byte_order
uint8_t byte_order
Definition: cpu.h:347
COMPONENT_TYPE_SCSIAdapter
#define COMPONENT_TYPE_SCSIAdapter
Definition: sgi_arcbios.h:277
mips_cpu::cache_picache_linesize
int cache_picache_linesize
Definition: cpu_mips.h:263
EMUL_BIG_ENDIAN
#define EMUL_BIG_ENDIAN
Definition: misc.h:165
arcbios_addchild_manual
uint64_t arcbios_addchild_manual(struct cpu *cpu, uint64_t cclass, uint64_t type, uint64_t flags, uint64_t version, uint64_t revision, uint64_t key, uint64_t affinitymask, const char *identifier, uint64_t parent, void *config_data, size_t config_len)
Definition: arcbios.cc:835
diskimage_access
int diskimage_access(struct machine *machine, int id, int type, int writeflag, off_t offset, unsigned char *buf, size_t len)
Definition: diskimage.cc:617
arcbios_component::AffinityMask
uint32_t AffinityMask
Definition: sgi_arcbios.h:162
machine::arc
struct machine_arcbios * arc
Definition: machine.h:183
ARC_CONSOLE_MAX_Y
#define ARC_CONSOLE_MAX_Y
Definition: machine_arc.h:38
MIPS_GPR_RA
#define MIPS_GPR_RA
Definition: cpu_mips.h:165
console.h
ARC_MAX_HANDLES
#define ARC_MAX_HANDLES
Definition: machine_arc.h:43
addr
uint32_t addr
Definition: tmp_arm_multi.cc:52
console_charavail
int console_charavail(int handle)
Definition: console.cc:347
id
u_short id
Definition: siireg.h:71
MAX_OPEN_STRINGLEN
#define MAX_OPEN_STRINGLEN
Definition: machine_arc.h:42
MAX_STRING_TO_COMPONENT
#define MAX_STRING_TO_COMPONENT
Definition: machine_arc.h:45
cpu::mips
struct mips_cpu mips
Definition: cpu.h:446
arc_CmResourceInterruptLevelSensitive
@ arc_CmResourceInterruptLevelSensitive
Definition: arcbios_other.h:199
arcbios_spb::PrivateVectorLength
uint32_t PrivateVectorLength
Definition: sgi_arcbios.h:114
diskimage_is_a_cdrom
int diskimage_is_a_cdrom(struct machine *machine, int id, int type)
Definition: diskimage.cc:1060
COMPONENT_TYPE_SecondaryDCache
#define COMPONENT_TYPE_SecondaryDCache
Definition: sgi_arcbios.h:271
machine::tick_functions
struct tick_functions tick_functions
Definition: machine.h:131
cpu_mips.h
machine_arcbios::configuration_data_len
int configuration_data_len[MAX_CONFIG_DATA]
Definition: machine_arc.h:87
machine::boot_string_argument
char * boot_string_argument
Definition: machine.h:171
ARCBIOS_EINVAL
#define ARCBIOS_EINVAL
Definition: sgi_arcbios.h:78
arcbios_init
void arcbios_init(struct machine *machine, int is64bit, uint64_t sgi_ram_offset, const char *primary_ether_addr, uint8_t *primary_ether_macaddr)
Definition: arcbios.cc:2481
arcbios_component64::Class
uint32_t Class
Definition: sgi_arcbios.h:170
MEM_WRITE
#define MEM_WRITE
Definition: memory.h:117
DEFAULT_PCACHE_SIZE
#define DEFAULT_PCACHE_SIZE
Definition: cpu_mips.h:175
machine_arcbios::configuration_data_configdata
uint64_t configuration_data_configdata[MAX_CONFIG_DATA]
Definition: machine_arc.h:88
arcbios_mem64
Definition: sgi_arcbios.h:349
ARC_BOOTSTR_BUFLEN
#define ARC_BOOTSTR_BUFLEN
Definition: arcbios.h:82
arcbios_dsp_stat::HighIntensity
uint8_t HighIntensity
Definition: sgi_arcbios.h:386
arc_CmResourceShareDeviceExclusive
@ arc_CmResourceShareDeviceExclusive
Definition: arcbios_other.h:192
SGI_SPB_ADDR
#define SGI_SPB_ADDR
Definition: arcbios.h:92
machine_arcbios::console_curx
int console_curx
Definition: machine_arc.h:61
COMPONENT_TYPE_DiskController
#define COMPONENT_TYPE_DiskController
Definition: sgi_arcbios.h:282
FIRST_ARC_COMPONENT
#define FIRST_ARC_COMPONENT
Definition: arcbios.h:105
arcbios_other.h
arcbios_mem
Definition: sgi_arcbios.h:342
arcbios_component64::Key
uint64_t Key
Definition: sgi_arcbios.h:175
ARC_DSPSTAT_ADDR
#define ARC_DSPSTAT_ADDR
Definition: arcbios.h:102
COMPONENT_TYPE_ARC
#define COMPONENT_TYPE_ARC
Definition: sgi_arcbios.h:261
COMPONENT_TYPE_PrimaryICache
#define COMPONENT_TYPE_PrimaryICache
Definition: sgi_arcbios.h:268
ARCBIOS_STDOUT
#define ARCBIOS_STDOUT
Definition: sgi_arcbios.h:66
arcbios_component64
Definition: sgi_arcbios.h:169
machine_arcbios::console_vram
uint64_t console_vram
Definition: machine_arc.h:55
strlen
void COMBINE() strlen(struct cpu *cpu, struct arm_instr_call *ic, int low_addr)
Definition: cpu_arm_instr.cc:2686
PHYSICAL
#define PHYSICAL
Definition: memory.h:126
fatal
void fatal(const char *fmt,...)
Definition: main.cc:152
machine_arcbios::escape_sequence
char escape_sequence[ARC_MAX_ESC+1]
Definition: machine_arc.h:57
DISKIMAGE_SCSI
#define DISKIMAGE_SCSI
Definition: diskimage.h:40
machine::cpu_name
char * cpu_name
Definition: machine.h:133
x11_md::in_use
int in_use
Definition: machine.h:82
arcbios_emul
int arcbios_emul(struct cpu *cpu)
Definition: arcbios.cc:1164
arcbios_component
Definition: sgi_arcbios.h:155
machine_arc.h
misc.h
machine_arcbios::console_curcolor
int console_curcolor
Definition: machine_arc.h:64
mips_coproc_tlb_set_entry
void mips_coproc_tlb_set_entry(struct cpu *cpu, int entrynr, int size, uint64_t vaddr, uint64_t paddr0, uint64_t paddr1, int valid0, int valid1, int dirty0, int dirty1, int global, int asid, int cachealgo0, int cachealgo1)
Definition: cpu_mips_coproc.cc:438
arc_CmResourceTypeInterrupt
@ arc_CmResourceTypeInterrupt
Definition: arcbios_other.h:126
ARC_ARGV_START
#define ARC_ARGV_START
Definition: arcbios.h:96
MIPS_GPR_A3
#define MIPS_GPR_A3
Definition: cpu_mips.h:141
COMPONENT_TYPE_MemoryUnit
#define COMPONENT_TYPE_MemoryUnit
Definition: sgi_arcbios.h:310
CACHE_NONE
#define CACHE_NONE
Definition: memory.h:123
cpu::cd
union cpu::@1 cd
machine.h
machine_arcbios::scsicontroller
uint64_t scsicontroller
Definition: machine_arc.h:91
machine
Definition: machine.h:97
machine::main_console_handle
int main_console_handle
Definition: machine.h:128
cpu::name
char * name
Definition: cpu.h:334
console_readchar
int console_readchar(int handle)
Definition: console.cc:390
arcbios_spb_64::Version
uint16_t Version
Definition: sgi_arcbios.h:132
COMPONENT_TYPE_FPU
#define COMPONENT_TYPE_FPU
Definition: sgi_arcbios.h:265
arcbios_mem::BasePage
uint32_t BasePage
Definition: sgi_arcbios.h:344
COMPONENT_CLASS_AdapterClass
#define COMPONENT_CLASS_AdapterClass
Definition: sgi_arcbios.h:200
arcbios_mem64::PageCount
uint64_t PageCount
Definition: sgi_arcbios.h:353
arcbios_spb::PrivateVector
uint32_t PrivateVector
Definition: sgi_arcbios.h:115
machine::force_netboot
int force_netboot
Definition: machine.h:167
arcbios_component::ConfigurationDataSize
uint32_t ConfigurationDataSize
Definition: sgi_arcbios.h:163
ARCBIOS_STDIN
#define ARCBIOS_STDIN
Definition: sgi_arcbios.h:65
arc_CmResourceTypeDMA
@ arc_CmResourceTypeDMA
Definition: arcbios_other.h:128
ARCBIOS_MEM_FirmwarePermanent
#define ARCBIOS_MEM_FirmwarePermanent
Definition: sgi_arcbios.h:372
store_string
void store_string(struct cpu *cpu, uint64_t addr, const char *s)
Definition: memory.cc:695
arcbios_dsp_stat::ForegroundColor
uint8_t ForegroundColor
Definition: sgi_arcbios.h:384
COMPONENT_TYPE_SerialController
#define COMPONENT_TYPE_SerialController
Definition: sgi_arcbios.h:286
COMPONENT_TYPE_ParallelController
#define COMPONENT_TYPE_ParallelController
Definition: sgi_arcbios.h:289
store_16bit_word_in_host
void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data, uint16_t data16)
Definition: memory.cc:992
arcbios_mem64::Type
uint32_t Type
Definition: sgi_arcbios.h:350
ARCBIOS_MEM_FreeMemory
#define ARCBIOS_MEM_FreeMemory
Definition: sgi_arcbios.h:368
machine_arcbios::configuration_data_next_addr
uint64_t configuration_data_next_addr
Definition: machine_arc.h:85
ARCBIOS_EAGAIN
#define ARCBIOS_EAGAIN
Definition: sgi_arcbios.h:74
arcbios_component::Version
uint16_t Version
Definition: sgi_arcbios.h:159
COMPONENT_CLASS_ControllerClass
#define COMPONENT_CLASS_ControllerClass
Definition: sgi_arcbios.h:201
COMPONENT_TYPE_EISAAdapter
#define COMPONENT_TYPE_EISAAdapter
Definition: sgi_arcbios.h:275
machine::x11_md
struct x11_md x11_md
Definition: machine.h:179
MACHINE_SGI
#define MACHINE_SGI
Definition: machine.h:217
machine_arcbios::arc_64bit
int arc_64bit
Definition: machine_arc.h:50
COMPONENT_TYPE_PointerPeripheral
#define COMPONENT_TYPE_PointerPeripheral
Definition: sgi_arcbios.h:302
arcbios_add_memory_descriptor
void arcbios_add_memory_descriptor(struct cpu *cpu, uint64_t base, uint64_t len, int arctype)
Definition: arcbios.cc:437
cpu.h
arcbios_component::Revision
uint16_t Revision
Definition: sgi_arcbios.h:160
COMPONENT_CLASS_CacheClass
#define COMPONENT_CLASS_CacheClass
Definition: sgi_arcbios.h:199
quiet_mode
int quiet_mode
Definition: main.cc:78
ARCBIOS_SPB_SIGNATURE
#define ARCBIOS_SPB_SIGNATURE
Definition: sgi_arcbios.h:149
SGI_SYSID_ADDR
#define SGI_SYSID_ADDR
Definition: arcbios.h:101
machine::bootdev_id
int bootdev_id
Definition: machine.h:154
COMPONENT_TYPE_AudioController
#define COMPONENT_TYPE_AudioController
Definition: sgi_arcbios.h:292
arcbios_spb_64::Revision
uint16_t Revision
Definition: sgi_arcbios.h:133
dump_mem_string
void dump_mem_string(struct cpu *cpu, uint64_t addr)
Definition: memory.cc:656
cpu::mem
struct memory * mem
Definition: cpu.h:362
machine::physical_ram_in_mb
uint32_t physical_ram_in_mb
Definition: machine.h:147
ARC_ENV_STRINGS_SGI
#define ARC_ENV_STRINGS_SGI
Definition: arcbios.h:99
cpu::machine
struct machine * machine
Definition: cpu.h:328
arcbios_component::IdentifierLength
uint32_t IdentifierLength
Definition: sgi_arcbios.h:164
machine::boot_kernel_filename
char * boot_kernel_filename
Definition: machine.h:170
machine_arcbios::wordlen
int wordlen
Definition: machine_arc.h:51
COMPONENT_CLASS_ProcessorClass
#define COMPONENT_CLASS_ProcessorClass
Definition: sgi_arcbios.h:198
COMPONENT_TYPE_PointerController
#define COMPONENT_TYPE_PointerController
Definition: sgi_arcbios.h:290
machine_arcbios::n_configuration_data
int n_configuration_data
Definition: machine_arc.h:84
arcbios_spb::SPBLength
uint32_t SPBLength
Definition: sgi_arcbios.h:105
mips_cpu::cache_pdcache_linesize
int cache_pdcache_linesize
Definition: cpu_mips.h:264
machine_arcbios::configuration_data_component
uint64_t configuration_data_component[MAX_CONFIG_DATA]
Definition: machine_arc.h:86
mips_cpu::cache_picache
int cache_picache
Definition: cpu_mips.h:260
ARCBIOS_ENOENT
#define ARCBIOS_ENOENT
Definition: sgi_arcbios.h:85
ARC_FIRMWARE_VECTORS
#define ARC_FIRMWARE_VECTORS
Definition: arcbios.h:94
machine_arcbios::current_seek_offset
uint64_t current_seek_offset[ARC_MAX_HANDLES]
Definition: machine_arc.h:69
machine_arcbios::console_maxy
int console_maxy
Definition: machine_arc.h:60
COMPONENT_FLAG_ConsoleOut
#define COMPONENT_FLAG_ConsoleOut
Definition: sgi_arcbios.h:318
verbose
int verbose
Definition: main.cc:77
arcbios_component64::Flags
uint32_t Flags
Definition: sgi_arcbios.h:172
ARCBIOS_EMFILE
#define ARCBIOS_EMFILE
Definition: sgi_arcbios.h:81
store_32bit_word
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
store_pointer_and_advance
void store_pointer_and_advance(struct cpu *cpu, uint64_t *addrp, uint64_t data, int flag64)
Definition: memory.cc:855
ARC_FIRMWARE_ENTRIES
#define ARC_FIRMWARE_ENTRIES
Definition: arcbios.h:95
machine_arcbios::console_reverse
int console_reverse
Definition: machine_arc.h:63
arcbios_set_default_exception_handler
void arcbios_set_default_exception_handler(struct cpu *cpu)
Definition: arcbios.cc:1871
mips_cpu::gpr
uint64_t gpr[N_MIPS_GPRS]
Definition: cpu_mips.h:209
store_32bit_word_in_host
void store_32bit_word_in_host(struct cpu *cpu, unsigned char *data, uint64_t data32)
Definition: memory.cc:973
COMPONENT_FLAG_Input
#define COMPONENT_FLAG_Input
Definition: sgi_arcbios.h:319
COMPONENT_TYPE_MultiFunctionAdapter
#define COMPONENT_TYPE_MultiFunctionAdapter
Definition: sgi_arcbios.h:279
ARC_CONSOLE_MAX_X
#define ARC_CONSOLE_MAX_X
Definition: machine_arc.h:37
MIPS_GPR_A2
#define MIPS_GPR_A2
Definition: cpu_mips.h:140
machine_arcbios::n_memdescriptors
int n_memdescriptors
Definition: machine_arc.h:72
machine::machine_type
int machine_type
Definition: machine.h:111
COMPONENT_FLAG_Output
#define COMPONENT_FLAG_Output
Definition: sgi_arcbios.h:320
arcbios_component64::Version
uint16_t Version
Definition: sgi_arcbios.h:173
add_symbol_name
void add_symbol_name(struct symbol_context *, uint64_t addr, uint64_t len, const char *name, int type, int n_args)
Definition: symbol.cc:199
store_64bit_word_in_host
void store_64bit_word_in_host(struct cpu *cpu, unsigned char *data, uint64_t data32)
Definition: memory.cc:945
ARC_MAX_ESC
#define ARC_MAX_ESC
Definition: machine_arc.h:40
machine_arcbios::console_cury
int console_cury
Definition: machine_arc.h:62
machine_arcbios::vgaconsole
int vgaconsole
Definition: machine_arc.h:54
arcbios_component64::ConfigurationDataSize
uint64_t ConfigurationDataSize
Definition: sgi_arcbios.h:177
tick_functions::n_entries
int n_entries
Definition: machine.h:71
COMPONENT_TYPE_FloppyDiskPeripheral
#define COMPONENT_TYPE_FloppyDiskPeripheral
Definition: sgi_arcbios.h:297
ARC_ENV_STRINGS
#define ARC_ENV_STRINGS
Definition: arcbios.h:97
machine_arcbios::console_maxx
int console_maxx
Definition: machine_arc.h:59
machine::bootstr
char * bootstr
Definition: machine.h:155
arcbios.h
arcbios_spb_64::SPBSignature
uint64_t SPBSignature
Definition: sgi_arcbios.h:130
arcbios_mem::Type
uint32_t Type
Definition: sgi_arcbios.h:343
arcbios_add_string_to_component
void arcbios_add_string_to_component(struct machine *machine, char *str, uint64_t component)
Definition: arcbios.cc:60
arcbios_sysid
Definition: sgi_arcbios.h:334
arcbios_mem::PageCount
uint32_t PageCount
Definition: sgi_arcbios.h:345
machine::machine_name
const char * machine_name
Definition: machine.h:115
cpu
Definition: cpu.h:326
machine::exit_without_entering_debugger
int exit_without_entering_debugger
Definition: machine.h:172
arcbios_get_scsicontroller
uint64_t arcbios_get_scsicontroller(struct machine *machine)
Definition: arcbios.cc:425
machine::md
union machine::@2 md
arcbios_component::Identifier
uint32_t Identifier
Definition: sgi_arcbios.h:165
arcbios_spb::FirmwareVector
uint32_t FirmwareVector
Definition: sgi_arcbios.h:113
machine_arcbios::n_components
int n_components
Definition: machine_arc.h:77
diskimage_getsize
int64_t diskimage_getsize(struct machine *machine, int id, int type)
Definition: diskimage.cc:203
ARCBIOS_ESUCCESS
#define ARCBIOS_ESUCCESS
Definition: sgi_arcbios.h:71
machine_arcbios
Definition: machine_arc.h:48
COMPONENT_FLAG_ConsoleIn
#define COMPONENT_FLAG_ConsoleIn
Definition: sgi_arcbios.h:317
ARCBIOS_MEM_FirmwareTemporary
#define ARCBIOS_MEM_FirmwareTemporary
Definition: sgi_arcbios.h:371
MACHINE_ARC
#define MACHINE_ARC
Definition: machine.h:218
ARC_MEMDESC_ADDR
#define ARC_MEMDESC_ADDR
Definition: arcbios.h:103
arcbios_spb::SPBSignature
uint32_t SPBSignature
Definition: sgi_arcbios.h:104
COMPONENT_TYPE_KeyboardController
#define COMPONENT_TYPE_KeyboardController
Definition: sgi_arcbios.h:291
cpu::memory_rw
int(* memory_rw)(struct cpu *cpu, struct memory *mem, uint64_t vaddr, unsigned char *data, size_t len, int writeflag, int cache_flags)
Definition: cpu.h:368
COMPONENT_TYPE_CPU
#define COMPONENT_TYPE_CPU
Definition: sgi_arcbios.h:264
tick_functions::f
void(** f)(struct cpu *, void *)
Definition: machine.h:76
machine_arcbios::string_to_component
char * string_to_component[MAX_STRING_TO_COMPONENT]
Definition: machine_arc.h:79
arc_CmResourceTypeDeviceSpecific
@ arc_CmResourceTypeDeviceSpecific
Definition: arcbios_other.h:129
DEFAULT_PCACHE_LINESIZE
#define DEFAULT_PCACHE_LINESIZE
Definition: cpu_mips.h:176
cpu::pc
uint64_t pc
Definition: cpu.h:386
arcbios_register_scsicontroller
void arcbios_register_scsicontroller(struct machine *machine, uint64_t scsicontroller_component)
Definition: arcbios.cc:415
MACHINE_ARC_JAZZ_MAGNUM
#define MACHINE_ARC_JAZZ_MAGNUM
Definition: machine.h:302
memory.h
arcbios_component::Class
uint32_t Class
Definition: sgi_arcbios.h:156
machine_arcbios::next_component_address
uint64_t next_component_address
Definition: machine_arc.h:76
arcbios_component::Flags
uint32_t Flags
Definition: sgi_arcbios.h:158
arcbios_component64::IdentifierLength
uint64_t IdentifierLength
Definition: sgi_arcbios.h:178
machine_arcbios::file_handle_string
const char * file_handle_string[ARC_MAX_HANDLES]
Definition: machine_arc.h:68
machine::ncpus
int ncpus
Definition: machine.h:139
machine_arcbios::n_string_to_components
int n_string_to_components
Definition: machine_arc.h:81
arcbios_component64::Type
uint32_t Type
Definition: sgi_arcbios.h:171
CHECK_ALLOCATION
#define CHECK_ALLOCATION(ptr)
Definition: misc.h:239

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18