/[gxemul]/trunk/src/promemul/arcbios.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/promemul/arcbios.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: arcbios.c,v 1.11 2006/12/30 13:31:02 debug Exp $   *  $Id: arcbios.c,v 1.16 2007/06/15 17:02:40 debug Exp $
29   *   *
30   *  ARCBIOS emulation.   *  ARCBIOS emulation.
31   */   */
# Line 46  Line 46 
46  #include "cpu_mips.h"  #include "cpu_mips.h"
47  #include "diskimage.h"  #include "diskimage.h"
48  #include "machine.h"  #include "machine.h"
49    #include "machine_arc.h"
50  #include "memory.h"  #include "memory.h"
51  #include "misc.h"  #include "misc.h"
52    
# Line 59  extern int quiet_mode; Line 60  extern int quiet_mode;
60  void arcbios_add_string_to_component(struct machine *machine,  void arcbios_add_string_to_component(struct machine *machine,
61          char *string, uint64_t component)          char *string, uint64_t component)
62  {  {
63          if (machine->md.arc.n_string_to_components >= MAX_STRING_TO_COMPONENT) {          if (machine->md.arc->n_string_to_components
64                >= MAX_STRING_TO_COMPONENT) {
65                  printf("Too many string-to-component mappings.\n");                  printf("Too many string-to-component mappings.\n");
66                  exit(1);                  exit(1);
67          }          }
68    
69          machine->md.arc.string_to_component[machine->          CHECK_ALLOCATION(machine->md.arc->string_to_component[machine->
70              md.arc.n_string_to_components] = strdup(string);              md.arc->n_string_to_components] = strdup(string));
71          if (machine->md.arc.string_to_component[machine->  
             md.arc.n_string_to_components] == NULL) {  
                 fprintf(stderr, "out of memory in "  
                     "arcbios_add_string_to_component()\n");  
                 exit(1);  
         }  
72          debug("adding ARC component mapping: 0x%08x = %s\n",          debug("adding ARC component mapping: 0x%08x = %s\n",
73              (int)component, string);              (int)component, string);
74    
75          machine->md.arc.string_to_component_value[          machine->md.arc->string_to_component_value[
76              machine->md.arc.n_string_to_components] = component;              machine->md.arc->n_string_to_components] = component;
77    
78          machine->md.arc.n_string_to_components ++;          machine->md.arc->n_string_to_components ++;
79  }  }
80    
81    
# Line 93  static void arcbios_get_dsp_stat(struct Line 90  static void arcbios_get_dsp_stat(struct
90          memset(dspstat, 0, sizeof(struct arcbios_dsp_stat));          memset(dspstat, 0, sizeof(struct arcbios_dsp_stat));
91    
92          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
93              CursorXPosition, cpu->machine->md.arc.console_curx + 1);              CursorXPosition, cpu->machine->md.arc->console_curx + 1);
94          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
95              CursorYPosition, cpu->machine->md.arc.console_cury + 1);              CursorYPosition, cpu->machine->md.arc->console_cury + 1);
96          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
97              CursorMaxXPosition, ARC_CONSOLE_MAX_X);              CursorMaxXPosition, ARC_CONSOLE_MAX_X);
98          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->          store_16bit_word_in_host(cpu, (unsigned char *)&dspstat->
99              CursorMaxYPosition, ARC_CONSOLE_MAX_Y);              CursorMaxYPosition, ARC_CONSOLE_MAX_Y);
100          dspstat->ForegroundColor = cpu->machine->md.arc.console_curcolor;          dspstat->ForegroundColor = cpu->machine->md.arc->console_curcolor;
101          dspstat->HighIntensity = cpu->machine->md.arc.console_curcolor ^ 0x08;          dspstat->HighIntensity = cpu->machine->md.arc->console_curcolor ^ 0x08;
102  }  }
103    
104    
# Line 112  static void arcbios_putcell(struct cpu * Line 109  static void arcbios_putcell(struct cpu *
109  {  {
110          unsigned char buf[2];          unsigned char buf[2];
111          buf[0] = ch;          buf[0] = ch;
112          buf[1] = cpu->machine->md.arc.console_curcolor;          buf[1] = cpu->machine->md.arc->console_curcolor;
113          if (cpu->machine->md.arc.console_reverse)          if (cpu->machine->md.arc->console_reverse)
114                  buf[1] = ((buf[1] & 0x70) >> 4) | ((buf[1] & 7) << 4)                  buf[1] = ((buf[1] & 0x70) >> 4) | ((buf[1] & 7) << 4)
115                      | (buf[1] & 0x88);                      | (buf[1] & 0x88);
116          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc.console_vram +          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc->console_vram +
117              2*(x + cpu->machine->md.arc.console_maxx * y),              2*(x + cpu->machine->md.arc->console_maxx * y),
118              &buf[0], sizeof(buf), MEM_WRITE,              &buf[0], sizeof(buf), MEM_WRITE,
119              CACHE_NONE | PHYSICAL);              CACHE_NONE | PHYSICAL);
120  }  }
# Line 130  static void arcbios_putcell(struct cpu * Line 127  static void arcbios_putcell(struct cpu *
127   */   */
128  static void handle_esc_seq(struct cpu *cpu)  static void handle_esc_seq(struct cpu *cpu)
129  {  {
130          int i, len = strlen(cpu->machine->md.arc.escape_sequence);          int i, len = strlen(cpu->machine->md.arc->escape_sequence);
131          int row, col, color, code, start, stop;          int row, col, color, code, start, stop;
132          char *p;          char *p;
133    
134          if (cpu->machine->md.arc.escape_sequence[0] != '[')          if (cpu->machine->md.arc->escape_sequence[0] != '[')
135                  return;                  return;
136    
137          code = cpu->machine->md.arc.escape_sequence[len-1];          code = cpu->machine->md.arc->escape_sequence[len-1];
138          cpu->machine->md.arc.escape_sequence[len-1] = '\0';          cpu->machine->md.arc->escape_sequence[len-1] = '\0';
139    
140          switch (code) {          switch (code) {
141          case 'm':          case 'm':
142                  color = atoi(cpu->machine->md.arc.escape_sequence + 1);                  color = atoi(cpu->machine->md.arc->escape_sequence + 1);
143                  switch (color) {                  switch (color) {
144                  case 0: /*  Default.  */                  case 0: /*  Default.  */
145                          cpu->machine->md.arc.console_curcolor = 0x1f;                          cpu->machine->md.arc->console_curcolor = 0x1f;
146                          cpu->machine->md.arc.console_reverse = 0; break;                          cpu->machine->md.arc->console_reverse = 0; break;
147                  case 1: /*  "Bold".  */                  case 1: /*  "Bold".  */
148                          cpu->machine->md.arc.console_curcolor |= 0x08; break;                          cpu->machine->md.arc->console_curcolor |= 0x08; break;
149                  case 7: /*  "Reverse".  */                  case 7: /*  "Reverse".  */
150                          cpu->machine->md.arc.console_reverse = 1; break;                          cpu->machine->md.arc->console_reverse = 1; break;
151                  case 30: /*  Black foreground.  */                  case 30: /*  Black foreground.  */
152                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
153                          cpu->machine->md.arc.console_curcolor |= 0x00; break;                          cpu->machine->md.arc->console_curcolor |= 0x00; break;
154                  case 31: /*  Red foreground.  */                  case 31: /*  Red foreground.  */
155                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
156                          cpu->machine->md.arc.console_curcolor |= 0x04; break;                          cpu->machine->md.arc->console_curcolor |= 0x04; break;
157                  case 32: /*  Green foreground.  */                  case 32: /*  Green foreground.  */
158                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
159                          cpu->machine->md.arc.console_curcolor |= 0x02; break;                          cpu->machine->md.arc->console_curcolor |= 0x02; break;
160                  case 33: /*  Yellow foreground.  */                  case 33: /*  Yellow foreground.  */
161                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
162                          cpu->machine->md.arc.console_curcolor |= 0x06; break;                          cpu->machine->md.arc->console_curcolor |= 0x06; break;
163                  case 34: /*  Blue foreground.  */                  case 34: /*  Blue foreground.  */
164                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
165                          cpu->machine->md.arc.console_curcolor |= 0x01; break;                          cpu->machine->md.arc->console_curcolor |= 0x01; break;
166                  case 35: /*  Red-blue foreground.  */                  case 35: /*  Red-blue foreground.  */
167                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
168                          cpu->machine->md.arc.console_curcolor |= 0x05; break;                          cpu->machine->md.arc->console_curcolor |= 0x05; break;
169                  case 36: /*  Green-blue foreground.  */                  case 36: /*  Green-blue foreground.  */
170                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
171                          cpu->machine->md.arc.console_curcolor |= 0x03; break;                          cpu->machine->md.arc->console_curcolor |= 0x03; break;
172                  case 37: /*  White foreground.  */                  case 37: /*  White foreground.  */
173                          cpu->machine->md.arc.console_curcolor &= 0xf0;                          cpu->machine->md.arc->console_curcolor &= 0xf0;
174                          cpu->machine->md.arc.console_curcolor |= 0x07; break;                          cpu->machine->md.arc->console_curcolor |= 0x07; break;
175                  case 40: /*  Black background.  */                  case 40: /*  Black background.  */
176                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
177                          cpu->machine->md.arc.console_curcolor |= 0x00; break;                          cpu->machine->md.arc->console_curcolor |= 0x00; break;
178                  case 41: /*  Red background.  */                  case 41: /*  Red background.  */
179                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
180                          cpu->machine->md.arc.console_curcolor |= 0x40; break;                          cpu->machine->md.arc->console_curcolor |= 0x40; break;
181                  case 42: /*  Green background.  */                  case 42: /*  Green background.  */
182                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
183                          cpu->machine->md.arc.console_curcolor |= 0x20; break;                          cpu->machine->md.arc->console_curcolor |= 0x20; break;
184                  case 43: /*  Yellow background.  */                  case 43: /*  Yellow background.  */
185                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
186                          cpu->machine->md.arc.console_curcolor |= 0x60; break;                          cpu->machine->md.arc->console_curcolor |= 0x60; break;
187                  case 44: /*  Blue background.  */                  case 44: /*  Blue background.  */
188                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
189                          cpu->machine->md.arc.console_curcolor |= 0x10; break;                          cpu->machine->md.arc->console_curcolor |= 0x10; break;
190                  case 45: /*  Red-blue background.  */                  case 45: /*  Red-blue background.  */
191                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
192                          cpu->machine->md.arc.console_curcolor |= 0x50; break;                          cpu->machine->md.arc->console_curcolor |= 0x50; break;
193                  case 46: /*  Green-blue background.  */                  case 46: /*  Green-blue background.  */
194                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
195                          cpu->machine->md.arc.console_curcolor |= 0x30; break;                          cpu->machine->md.arc->console_curcolor |= 0x30; break;
196                  case 47: /*  White background.  */                  case 47: /*  White background.  */
197                          cpu->machine->md.arc.console_curcolor &= 0x0f;                          cpu->machine->md.arc->console_curcolor &= 0x0f;
198                          cpu->machine->md.arc.console_curcolor |= 0x70; break;                          cpu->machine->md.arc->console_curcolor |= 0x70; break;
199                  default:fatal("{ handle_esc_seq: color %i }\n", color);                  default:fatal("{ handle_esc_seq: color %i }\n", color);
200                  }                  }
201                  return;                  return;
202          case 'H':          case 'H':
203                  p = strchr(cpu->machine->md.arc.escape_sequence, ';');                  p = strchr(cpu->machine->md.arc->escape_sequence, ';');
204                  if (p == NULL)                  if (p == NULL)
205                          return;         /*  TODO  */                          return;         /*  TODO  */
206                  row = atoi(cpu->machine->md.arc.escape_sequence + 1);                  row = atoi(cpu->machine->md.arc->escape_sequence + 1);
207                  col = atoi(p + 1);                  col = atoi(p + 1);
208                  if (col < 1)                  if (col < 1)
209                          col = 1;                          col = 1;
210                  if (row < 1)                  if (row < 1)
211                          row = 1;                          row = 1;
212                  cpu->machine->md.arc.console_curx = col - 1;                  cpu->machine->md.arc->console_curx = col - 1;
213                  cpu->machine->md.arc.console_cury = row - 1;                  cpu->machine->md.arc->console_cury = row - 1;
214                  return;                  return;
215          case 'J':          case 'J':
216                  /*                  /*
# Line 221  static void handle_esc_seq(struct cpu *c Line 218  static void handle_esc_seq(struct cpu *c
218                   *      current line,                   *      current line,
219                   *  2J = clear whole screen.                   *  2J = clear whole screen.
220                   */                   */
221                  i = atoi(cpu->machine->md.arc.escape_sequence + 1);                  i = atoi(cpu->machine->md.arc->escape_sequence + 1);
222                  if (i != 0 && i != 2)                  if (i != 0 && i != 2)
223                          fatal("{ handle_esc_seq(): %iJ }\n", i);                          fatal("{ handle_esc_seq(): %iJ }\n", i);
224                  if (i == 0)                  if (i == 0)
225                          for (col = cpu->machine->md.arc.console_curx;                          for (col = cpu->machine->md.arc->console_curx;
226                              col < cpu->machine->md.arc.console_maxx; col++)                              col < cpu->machine->md.arc->console_maxx; col++)
227                                  arcbios_putcell(cpu, ' ', col,                                  arcbios_putcell(cpu, ' ', col,
228                                      cpu->machine->md.arc.console_cury);                                      cpu->machine->md.arc->console_cury);
229                  for (col = 0; col < cpu->machine->md.arc.console_maxx; col++)                  for (col = 0; col < cpu->machine->md.arc->console_maxx; col++)
230                          for (row = i? 0 : cpu->machine->md.arc.console_cury+1;                          for (row = i? 0 : cpu->machine->md.arc->console_cury+1;
231                              row < cpu->machine->md.arc.console_maxy; row++)                              row < cpu->machine->md.arc->console_maxy; row++)
232                                  arcbios_putcell(cpu, ' ', col, row);                                  arcbios_putcell(cpu, ' ', col, row);
233                  return;                  return;
234          case 'K':          case 'K':
235                  col = atoi(cpu->machine->md.arc.escape_sequence + 1);                  col = atoi(cpu->machine->md.arc->escape_sequence + 1);
236                  /*  2 = clear line to the right. 1 = to the left (?)  */                  /*  2 = clear line to the right. 1 = to the left (?)  */
237                  start = 0; stop = cpu->machine->md.arc.console_curx;                  start = 0; stop = cpu->machine->md.arc->console_curx;
238                  if (col == 2) {                  if (col == 2) {
239                          start = cpu->machine->md.arc.console_curx;                          start = cpu->machine->md.arc->console_curx;
240                          stop = cpu->machine->md.arc.console_maxx - 1;                          stop = cpu->machine->md.arc->console_maxx - 1;
241                  }                  }
242                  for (i=start; i<=stop; i++)                  for (i=start; i<=stop; i++)
243                          arcbios_putcell(cpu, ' ', i,                          arcbios_putcell(cpu, ' ', i,
244                              cpu->machine->md.arc.console_cury);                              cpu->machine->md.arc->console_cury);
245    
246                  return;                  return;
247          }          }
248    
249          fatal("{ handle_esc_seq(): unimplemented escape sequence: ");          fatal("{ handle_esc_seq(): unimplemented escape sequence: ");
250          for (i=0; i<len; i++) {          for (i=0; i<len; i++) {
251                  int x = cpu->machine->md.arc.escape_sequence[i];                  int x = cpu->machine->md.arc->escape_sequence[i];
252                  if (i == len-1)                  if (i == len-1)
253                          x = code;                          x = code;
254    
# Line 270  static void handle_esc_seq(struct cpu *c Line 267  static void handle_esc_seq(struct cpu *c
267  static void scroll_if_necessary(struct cpu *cpu)  static void scroll_if_necessary(struct cpu *cpu)
268  {  {
269          /*  Scroll?  */          /*  Scroll?  */
270          if (cpu->machine->md.arc.console_cury >=          if (cpu->machine->md.arc->console_cury >=
271              cpu->machine->md.arc.console_maxy) {              cpu->machine->md.arc->console_maxy) {
272                  unsigned char buf[2];                  unsigned char buf[2];
273                  int x, y;                  int x, y;
274                  for (y=0; y<cpu->machine->md.arc.console_maxy-1; y++)                  for (y=0; y<cpu->machine->md.arc->console_maxy-1; y++)
275                          for (x=0; x<cpu->machine->md.arc.console_maxx;                          for (x=0; x<cpu->machine->md.arc->console_maxx;
276                              x++) {                              x++) {
277                                  cpu->memory_rw(cpu, cpu->mem,                                  cpu->memory_rw(cpu, cpu->mem,
278                                      cpu->machine->md.arc.console_vram +                                      cpu->machine->md.arc->console_vram +
279                                      2*(x + cpu->machine->md.arc.                                      2*(x + cpu->machine->md.arc->
280                                          console_maxx * (y+1)),                                          console_maxx * (y+1)),
281                                      &buf[0], sizeof(buf), MEM_READ,                                      &buf[0], sizeof(buf), MEM_READ,
282                                      CACHE_NONE | PHYSICAL);                                      CACHE_NONE | PHYSICAL);
283                                  cpu->memory_rw(cpu, cpu->mem,                                  cpu->memory_rw(cpu, cpu->mem,
284                                      cpu->machine->md.arc.console_vram +                                      cpu->machine->md.arc->console_vram +
285                                      2*(x + cpu->machine->md.arc.                                      2*(x + cpu->machine->md.arc->
286                                          console_maxx * y),                                          console_maxx * y),
287                                      &buf[0], sizeof(buf), MEM_WRITE,                                      &buf[0], sizeof(buf), MEM_WRITE,
288                                      CACHE_NONE | PHYSICAL);                                      CACHE_NONE | PHYSICAL);
289                          }                          }
290    
291                  cpu->machine->md.arc.console_cury =                  cpu->machine->md.arc->console_cury =
292                      cpu->machine->md.arc.console_maxy - 1;                      cpu->machine->md.arc->console_maxy - 1;
293    
294                  for (x=0; x<cpu->machine->md.arc.console_maxx; x++)                  for (x=0; x<cpu->machine->md.arc->console_maxx; x++)
295                          arcbios_putcell(cpu, ' ', x,                          arcbios_putcell(cpu, ' ', x,
296                              cpu->machine->md.arc.console_cury);                              cpu->machine->md.arc->console_cury);
297          }          }
298  }  }
299    
# Line 312  static void arcbios_putchar(struct cpu * Line 309  static void arcbios_putchar(struct cpu *
309          int addr;          int addr;
310          unsigned char byte;          unsigned char byte;
311    
312          if (!cpu->machine->md.arc.vgaconsole) {          if (!cpu->machine->md.arc->vgaconsole) {
313                  /*  Text console output:  */                  /*  Text console output:  */
314    
315                  /*  Hack for Windows NT, which uses 0x9b instead of ESC + [  */                  /*  Hack for Windows NT, which uses 0x9b instead of ESC + [  */
# Line 324  static void arcbios_putchar(struct cpu * Line 321  static void arcbios_putchar(struct cpu *
321                  return;                  return;
322          }          }
323    
324          if (cpu->machine->md.arc.in_escape_sequence) {          if (cpu->machine->md.arc->in_escape_sequence) {
325                  int len = strlen(cpu->machine->md.arc.escape_sequence);                  int len = strlen(cpu->machine->md.arc->escape_sequence);
326                  cpu->machine->md.arc.escape_sequence[len] = ch;                  cpu->machine->md.arc->escape_sequence[len] = ch;
327                  len++;                  len++;
328                  if (len >= ARC_MAX_ESC)                  if (len >= ARC_MAX_ESC)
329                          len = ARC_MAX_ESC;                          len = ARC_MAX_ESC;
330                  cpu->machine->md.arc.escape_sequence[len] = '\0';                  cpu->machine->md.arc->escape_sequence[len] = '\0';
331                  if ((ch >= 'a' && ch <= 'z') ||                  if ((ch >= 'a' && ch <= 'z') ||
332                      (ch >= 'A' && ch <= 'Z') || len >= ARC_MAX_ESC) {                      (ch >= 'A' && ch <= 'Z') || len >= ARC_MAX_ESC) {
333                          handle_esc_seq(cpu);                          handle_esc_seq(cpu);
334                          cpu->machine->md.arc.in_escape_sequence = 0;                          cpu->machine->md.arc->in_escape_sequence = 0;
335                  }                  }
336          } else {          } else {
337                  if (ch == 27) {                  if (ch == 27) {
338                          cpu->machine->md.arc.in_escape_sequence = 1;                          cpu->machine->md.arc->in_escape_sequence = 1;
339                          cpu->machine->md.arc.escape_sequence[0] = '\0';                          cpu->machine->md.arc->escape_sequence[0] = '\0';
340                  } else if (ch == 0x9b) {                  } else if (ch == 0x9b) {
341                          cpu->machine->md.arc.in_escape_sequence = 1;                          cpu->machine->md.arc->in_escape_sequence = 1;
342                          cpu->machine->md.arc.escape_sequence[0] = '[';                          cpu->machine->md.arc->escape_sequence[0] = '[';
343                          cpu->machine->md.arc.escape_sequence[1] = '\0';                          cpu->machine->md.arc->escape_sequence[1] = '\0';
344                  } else if (ch == '\b') {                  } else if (ch == '\b') {
345                          if (cpu->machine->md.arc.console_curx > 0)                          if (cpu->machine->md.arc->console_curx > 0)
346                                  cpu->machine->md.arc.console_curx --;                                  cpu->machine->md.arc->console_curx --;
347                  } else if (ch == '\r') {                  } else if (ch == '\r') {
348                          cpu->machine->md.arc.console_curx = 0;                          cpu->machine->md.arc->console_curx = 0;
349                  } else if (ch == '\n') {                  } else if (ch == '\n') {
350                          cpu->machine->md.arc.console_cury ++;                          cpu->machine->md.arc->console_cury ++;
351                  } else if (ch == '\t') {                  } else if (ch == '\t') {
352                          cpu->machine->md.arc.console_curx =                          cpu->machine->md.arc->console_curx =
353                              ((cpu->machine->md.arc.console_curx - 1)                              ((cpu->machine->md.arc->console_curx - 1)
354                              | 7) + 1;                              | 7) + 1;
355                          /*  TODO: Print spaces?  */                          /*  TODO: Print spaces?  */
356                  } else {                  } else {
357                          /*  Put char:  */                          /*  Put char:  */
358                          if (cpu->machine->md.arc.console_curx >=                          if (cpu->machine->md.arc->console_curx >=
359                              cpu->machine->md.arc.console_maxx) {                              cpu->machine->md.arc->console_maxx) {
360                                  cpu->machine->md.arc.console_curx = 0;                                  cpu->machine->md.arc->console_curx = 0;
361                                  cpu->machine->md.arc.console_cury ++;                                  cpu->machine->md.arc->console_cury ++;
362                                  scroll_if_necessary(cpu);                                  scroll_if_necessary(cpu);
363                          }                          }
364                          arcbios_putcell(cpu, ch,                          arcbios_putcell(cpu, ch,
365                              cpu->machine->md.arc.console_curx,                              cpu->machine->md.arc->console_curx,
366                              cpu->machine->md.arc.console_cury);                              cpu->machine->md.arc->console_cury);
367                          cpu->machine->md.arc.console_curx ++;                          cpu->machine->md.arc->console_curx ++;
368                  }                  }
369          }          }
370    
371          scroll_if_necessary(cpu);          scroll_if_necessary(cpu);
372    
373          /*  Update cursor position:  */          /*  Update cursor position:  */
374          addr = (cpu->machine->md.arc.console_curx >=          addr = (cpu->machine->md.arc->console_curx >=
375              cpu->machine->md.arc.console_maxx?              cpu->machine->md.arc->console_maxx?
376              cpu->machine->md.arc.console_maxx - 1 :              cpu->machine->md.arc->console_maxx - 1 :
377                  cpu->machine->md.arc.console_curx) +                  cpu->machine->md.arc->console_curx) +
378              cpu->machine->md.arc.console_cury *              cpu->machine->md.arc->console_cury *
379              cpu->machine->md.arc.console_maxx;              cpu->machine->md.arc->console_maxx;
380          byte = 0x0e;          byte = 0x0e;
381          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc.          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc->
382              console_ctrlregs + 0x14,              console_ctrlregs + 0x14,
383              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
384          byte = (addr >> 8) & 255;          byte = (addr >> 8) & 255;
385          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc.          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc->
386              console_ctrlregs + 0x15,              console_ctrlregs + 0x15,
387              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
388          byte = 0x0f;          byte = 0x0f;
389          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc.          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc->
390              console_ctrlregs + 0x14,              console_ctrlregs + 0x14,
391              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
392          byte = addr & 255;          byte = addr & 255;
393          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc.          cpu->memory_rw(cpu, cpu->mem, cpu->machine->md.arc->
394              console_ctrlregs + 0x15,              console_ctrlregs + 0x15,
395              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);              &byte, sizeof(byte), MEM_WRITE, CACHE_NONE | PHYSICAL);
396  }  }
# Line 418  static void arcbios_putstring(struct cpu Line 415  static void arcbios_putstring(struct cpu
415  void arcbios_register_scsicontroller(struct machine *machine,  void arcbios_register_scsicontroller(struct machine *machine,
416          uint64_t scsicontroller_component)          uint64_t scsicontroller_component)
417  {  {
418          machine->md.arc.scsicontroller = scsicontroller_component;          machine->md.arc->scsicontroller = scsicontroller_component;
419  }  }
420    
421    
# Line 427  void arcbios_register_scsicontroller(str Line 424  void arcbios_register_scsicontroller(str
424   */   */
425  uint64_t arcbios_get_scsicontroller(struct machine *machine)  uint64_t arcbios_get_scsicontroller(struct machine *machine)
426  {  {
427          return machine->md.arc.scsicontroller;          return machine->md.arc->scsicontroller;
428  }  }
429    
430    
# Line 471  void arcbios_add_memory_descriptor(struc Line 468  void arcbios_add_memory_descriptor(struc
468                  /*  printf("%i\n", arctype);  */                  /*  printf("%i\n", arctype);  */
469          }          }
470  #endif  #endif
471          if (cpu->machine->md.arc.arc_64bit)          if (cpu->machine->md.arc->arc_64bit)
472                  s = sizeof(arcbios_mem64);                  s = sizeof(arcbios_mem64);
473          else          else
474                  s = sizeof(arcbios_mem);                  s = sizeof(arcbios_mem);
475    
476          memdesc_addr = cpu->machine->md.arc.memdescriptor_base +          memdesc_addr = cpu->machine->md.arc->memdescriptor_base +
477              cpu->machine->md.arc.n_memdescriptors * s;              cpu->machine->md.arc->n_memdescriptors * s;
478    
479          if (cpu->machine->md.arc.arc_64bit) {          if (cpu->machine->md.arc->arc_64bit) {
480                  memset(&arcbios_mem64, 0, s);                  memset(&arcbios_mem64, 0, s);
481                  store_32bit_word_in_host(cpu,                  store_32bit_word_in_host(cpu,
482                      (unsigned char *)&arcbios_mem64.Type, arctype);                      (unsigned char *)&arcbios_mem64.Type, arctype);
# Line 499  void arcbios_add_memory_descriptor(struc Line 496  void arcbios_add_memory_descriptor(struc
496                  store_buf(cpu, memdesc_addr, (char *)&arcbios_mem, s);                  store_buf(cpu, memdesc_addr, (char *)&arcbios_mem, s);
497          }          }
498    
499          cpu->machine->md.arc.n_memdescriptors ++;          cpu->machine->md.arc->n_memdescriptors ++;
500  }  }
501    
502    
# Line 520  static uint64_t arcbios_addchild(struct Line 517  static uint64_t arcbios_addchild(struct
517          char *identifier, uint32_t parent)          char *identifier, uint32_t parent)
518  {  {
519          struct machine *machine = cpu->machine;          struct machine *machine = cpu->machine;
520          uint64_t a = machine->md.arc.next_component_address;          uint64_t a = machine->md.arc->next_component_address;
521          uint32_t peer=0;          uint32_t peer=0;
522          uint32_t child=0;          uint32_t child=0;
523          int n_left;          int n_left;
# Line 543  static uint64_t arcbios_addchild(struct Line 540  static uint64_t arcbios_addchild(struct
540           *  TODO:  make this nicer           *  TODO:  make this nicer
541           */           */
542    
543          n_left = machine->md.arc.n_components;          n_left = machine->md.arc->n_components;
544          while (n_left > 0) {          while (n_left > 0) {
545                  /*  Load parent, child, and peer values:  */                  /*  Load parent, child, and peer values:  */
546                  uint32_t eparent, echild, epeer, tmp;                  uint32_t eparent, echild, epeer, tmp;
# Line 553  static uint64_t arcbios_addchild(struct Line 550  static uint64_t arcbios_addchild(struct
550                      (int)peeraddr);  */                      (int)peeraddr);  */
551    
552                  cpu->memory_rw(cpu, cpu->mem,                  cpu->memory_rw(cpu, cpu->mem,
553                      peeraddr + 0 * machine->md.arc.wordlen, &buf[0],                      peeraddr + 0 * machine->md.arc->wordlen, &buf[0],
554                      sizeof(eparent), MEM_READ, CACHE_NONE);                      sizeof(eparent), MEM_READ, CACHE_NONE);
555                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
556                          unsigned char tmp;                          unsigned char tmp;
# Line 563  static uint64_t arcbios_addchild(struct Line 560  static uint64_t arcbios_addchild(struct
560                  epeer   = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);                  epeer   = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
561    
562                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 1 *                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 1 *
563                      machine->md.arc.wordlen,                      machine->md.arc->wordlen,
564                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
565                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
566                          unsigned char tmp; tmp = buf[0];                          unsigned char tmp; tmp = buf[0];
# Line 573  static uint64_t arcbios_addchild(struct Line 570  static uint64_t arcbios_addchild(struct
570                  echild  = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);                  echild  = buf[0] + (buf[1]<<8) + (buf[2]<<16) + (buf[3]<<24);
571    
572                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 2 *                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 2 *
573                      machine->md.arc.wordlen,                      machine->md.arc->wordlen,
574                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
575                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
576                          unsigned char tmp; tmp = buf[0];                          unsigned char tmp; tmp = buf[0];
# Line 631  static uint64_t arcbios_addchild(struct Line 628  static uint64_t arcbios_addchild(struct
628          store_32bit_word(cpu, a+  0x28, host_tmp_component->IdentifierLength);          store_32bit_word(cpu, a+  0x28, host_tmp_component->IdentifierLength);
629          store_32bit_word(cpu, a+  0x2c, host_tmp_component->Identifier);          store_32bit_word(cpu, a+  0x2c, host_tmp_component->Identifier);
630    
631          machine->md.arc.next_component_address += 0x30;          machine->md.arc->next_component_address += 0x30;
632    
633          if (host_tmp_component->IdentifierLength != 0) {          if (host_tmp_component->IdentifierLength != 0) {
634                  store_32bit_word(cpu, a + 0x2c, a + 0x30);                  store_32bit_word(cpu, a + 0x2c, a + 0x30);
635                  store_string(cpu, a + 0x30, identifier);                  store_string(cpu, a + 0x30, identifier);
636                  if (identifier != NULL)                  if (identifier != NULL)
637                          machine->md.arc.next_component_address +=                          machine->md.arc->next_component_address +=
638                              strlen(identifier) + 1;                              strlen(identifier) + 1;
639          }          }
640    
641          machine->md.arc.next_component_address ++;          machine->md.arc->next_component_address ++;
642    
643          /*  Round up to next 0x4 bytes:  */          /*  Round up to next 0x4 bytes:  */
644          machine->md.arc.next_component_address =          machine->md.arc->next_component_address =
645              ((machine->md.arc.next_component_address - 1) | 3) + 1;              ((machine->md.arc->next_component_address - 1) | 3) + 1;
646    
647          machine->md.arc.n_components ++;          machine->md.arc->n_components ++;
648    
649          return a;          return a;
650  }  }
# Line 670  static uint64_t arcbios_addchild64(struc Line 667  static uint64_t arcbios_addchild64(struc
667          char *identifier, uint64_t parent)          char *identifier, uint64_t parent)
668  {  {
669          struct machine *machine = cpu->machine;          struct machine *machine = cpu->machine;
670          uint64_t a = machine->md.arc.next_component_address;          uint64_t a = machine->md.arc->next_component_address;
671          uint64_t peer=0;          uint64_t peer=0;
672          uint64_t child=0;          uint64_t child=0;
673          int n_left;          int n_left;
# Line 693  static uint64_t arcbios_addchild64(struc Line 690  static uint64_t arcbios_addchild64(struc
690           *  TODO:  make this nicer           *  TODO:  make this nicer
691           */           */
692    
693          n_left = machine->md.arc.n_components;          n_left = machine->md.arc->n_components;
694          while (n_left > 0) {          while (n_left > 0) {
695                  /*  Load parent, child, and peer values:  */                  /*  Load parent, child, and peer values:  */
696                  uint64_t eparent, echild, epeer, tmp;                  uint64_t eparent, echild, epeer, tmp;
# Line 703  static uint64_t arcbios_addchild64(struc Line 700  static uint64_t arcbios_addchild64(struc
700                      (uint64_t) peeraddr);  */                      (uint64_t) peeraddr);  */
701    
702                  cpu->memory_rw(cpu, cpu->mem,                  cpu->memory_rw(cpu, cpu->mem,
703                      peeraddr + 0 * machine->md.arc.wordlen, &buf[0],                      peeraddr + 0 * machine->md.arc->wordlen, &buf[0],
704                      sizeof(eparent), MEM_READ, CACHE_NONE);                      sizeof(eparent), MEM_READ, CACHE_NONE);
705                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
706                          unsigned char tmp;                          unsigned char tmp;
# Line 717  static uint64_t arcbios_addchild64(struc Line 714  static uint64_t arcbios_addchild64(struc
714                      + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);                      + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
715    
716                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 1 *                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 1 *
717                      machine->md.arc.wordlen,                      machine->md.arc->wordlen,
718                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
719                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
720                          unsigned char tmp;                          unsigned char tmp;
# Line 731  static uint64_t arcbios_addchild64(struc Line 728  static uint64_t arcbios_addchild64(struc
728                      + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);                      + ((uint64_t)buf[6] << 48) + ((uint64_t)buf[7] << 56);
729    
730                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 2 *                  cpu->memory_rw(cpu, cpu->mem, peeraddr + 2 *
731                      machine->md.arc.wordlen,                      machine->md.arc->wordlen,
732                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);                      &buf[0], sizeof(eparent), MEM_READ, CACHE_NONE);
733                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
734                          unsigned char tmp;                          unsigned char tmp;
# Line 751  static uint64_t arcbios_addchild64(struc Line 748  static uint64_t arcbios_addchild64(struc
748                  if (eparent == parent && epeer == 0) {                  if (eparent == parent && epeer == 0) {
749                          epeer = a;                          epeer = a;
750                          store_64bit_word(cpu, peeraddr + 0 *                          store_64bit_word(cpu, peeraddr + 0 *
751                              machine->md.arc.wordlen, epeer);                              machine->md.arc->wordlen, epeer);
752                          /*  debug("[ addchild: adding 0x%016"PRIx64" as peer "                          /*  debug("[ addchild: adding 0x%016"PRIx64" as peer "
753                              "to 0x%016"PRIx64" ]\n", (uint64_t) a,                              "to 0x%016"PRIx64" ]\n", (uint64_t) a,
754                              (uint64_t) peeraddr);  */                              (uint64_t) peeraddr);  */
# Line 759  static uint64_t arcbios_addchild64(struc Line 756  static uint64_t arcbios_addchild64(struc
756                  if (peeraddr == parent && echild == 0) {                  if (peeraddr == parent && echild == 0) {
757                          echild = a;                          echild = a;
758                          store_64bit_word(cpu, peeraddr + 1 *                          store_64bit_word(cpu, peeraddr + 1 *
759                              machine->md.arc.wordlen, echild);                              machine->md.arc->wordlen, echild);
760                          /*  debug("[ addchild: adding 0x%016"PRIx64" as child "                          /*  debug("[ addchild: adding 0x%016"PRIx64" as child "
761                              "to 0x%016"PRIx64" ]\n", (uint64_t) a,                              "to 0x%016"PRIx64" ]\n", (uint64_t) a,
762                              (uint64_t) peeraddr);  */                              (uint64_t) peeraddr);  */
# Line 801  static uint64_t arcbios_addchild64(struc Line 798  static uint64_t arcbios_addchild64(struc
798    
799          /*  TODO: Find out how a REAL ARCS64 implementation does it.  */          /*  TODO: Find out how a REAL ARCS64 implementation does it.  */
800    
801          machine->md.arc.next_component_address += 0x50;          machine->md.arc->next_component_address += 0x50;
802    
803          if (host_tmp_component->IdentifierLength != 0) {          if (host_tmp_component->IdentifierLength != 0) {
804                  store_64bit_word(cpu, a + 0x48, a + 0x50);                  store_64bit_word(cpu, a + 0x48, a + 0x50);
805                  store_string(cpu, a + 0x50, identifier);                  store_string(cpu, a + 0x50, identifier);
806                  if (identifier != NULL)                  if (identifier != NULL)
807                          machine->md.arc.next_component_address +=                          machine->md.arc->next_component_address +=
808                              strlen(identifier) + 1;                              strlen(identifier) + 1;
809          }          }
810    
811          machine->md.arc.next_component_address ++;          machine->md.arc->next_component_address ++;
812    
813          /*  Round up to next 0x8 bytes:  */          /*  Round up to next 0x8 bytes:  */
814          machine->md.arc.next_component_address =          machine->md.arc->next_component_address =
815              ((machine->md.arc.next_component_address - 1) | 7) + 1;              ((machine->md.arc->next_component_address - 1) | 7) + 1;
816    
817          machine->md.arc.n_components ++;          machine->md.arc->n_components ++;
818          return a;          return a;
819  }  }
820    
# Line 845  uint64_t arcbios_addchild_manual(struct Line 842  uint64_t arcbios_addchild_manual(struct
842                  unsigned char *p = config_data;                  unsigned char *p = config_data;
843                  size_t i;                  size_t i;
844    
845                  if (machine->md.arc.n_configuration_data >= MAX_CONFIG_DATA) {                  if (machine->md.arc->n_configuration_data >= MAX_CONFIG_DATA) {
846                          printf("fatal error: you need to increase "                          printf("fatal error: you need to increase "
847                              "MAX_CONFIG_DATA\n");                              "MAX_CONFIG_DATA\n");
848                          exit(1);                          exit(1);
# Line 854  uint64_t arcbios_addchild_manual(struct Line 851  uint64_t arcbios_addchild_manual(struct
851                  for (i=0; i<config_len; i++) {                  for (i=0; i<config_len; i++) {
852                          unsigned char ch = p[i];                          unsigned char ch = p[i];
853                          cpu->memory_rw(cpu, cpu->mem,                          cpu->memory_rw(cpu, cpu->mem,
854                              machine->md.arc.configuration_data_next_addr + i,                              machine->md.arc->configuration_data_next_addr + i,
855                              &ch, 1, MEM_WRITE, CACHE_NONE);                              &ch, 1, MEM_WRITE, CACHE_NONE);
856                  }                  }
857    
858                  machine->md.arc.configuration_data_len[                  machine->md.arc->configuration_data_len[
859                      machine->md.arc.n_configuration_data] = config_len;                      machine->md.arc->n_configuration_data] = config_len;
860                  machine->md.arc.configuration_data_configdata[                  machine->md.arc->configuration_data_configdata[
861                      machine->md.arc.n_configuration_data] =                      machine->md.arc->n_configuration_data] =
862                      machine->md.arc.configuration_data_next_addr;                      machine->md.arc->configuration_data_next_addr;
863                  machine->md.arc.configuration_data_next_addr += config_len;                  machine->md.arc->configuration_data_next_addr += config_len;
864                  machine->md.arc.configuration_data_component[                  machine->md.arc->configuration_data_component[
865                      machine->md.arc.n_configuration_data] =                      machine->md.arc->n_configuration_data] =
866                      machine->md.arc.next_component_address +                      machine->md.arc->next_component_address +
867                      (cpu->machine->md.arc.arc_64bit? 0x18 : 0x0c);                      (cpu->machine->md.arc->arc_64bit? 0x18 : 0x0c);
868    
869                  /*  printf("& ADDING %i: configdata=0x%016"PRIx64" "                  /*  printf("& ADDING %i: configdata=0x%016"PRIx64" "
870                      "component=0x%016"PRIx64"\n",                      "component=0x%016"PRIx64"\n",
871                       machine->md.arc.n_configuration_data,                       machine->md.arc->n_configuration_data,
872                      (uint64_t) machine->md.arc.configuration_data_configdata[                      (uint64_t) machine->md.arc->configuration_data_configdata[
873                          machine->md.arc.n_configuration_data],                          machine->md.arc->n_configuration_data],
874                      (uint64_t) machine->md.arc.configuration_data_component[                      (uint64_t) machine->md.arc->configuration_data_component[
875                          machine->md.arc.n_configuration_data]);  */                          machine->md.arc->n_configuration_data]);  */
876    
877                  machine->md.arc.n_configuration_data ++;                  machine->md.arc->n_configuration_data ++;
878          }          }
879    
880          if (!cpu->machine->md.arc.arc_64bit) {          if (!cpu->machine->md.arc->arc_64bit) {
881                  component.Class                 = class;                  component.Class                 = class;
882                  component.Type                  = type;                  component.Type                  = type;
883                  component.Flags                 = flags;                  component.Flags                 = flags;
# Line 1020  static int arcbios_handle_to_disk_id_and Line 1017  static int arcbios_handle_to_disk_id_and
1017          if (handle < 0 || handle >= ARC_MAX_HANDLES)          if (handle < 0 || handle >= ARC_MAX_HANDLES)
1018                  return -1;                  return -1;
1019    
1020          s = machine->md.arc.file_handle_string[handle];          s = machine->md.arc->file_handle_string[handle];
1021          if (s == NULL)          if (s == NULL)
1022                  return -1;                  return -1;
1023    
# Line 1047  static int arcbios_handle_to_disk_id_and Line 1044  static int arcbios_handle_to_disk_id_and
1044  static void arcbios_handle_to_start_and_size(struct machine *machine,  static void arcbios_handle_to_start_and_size(struct machine *machine,
1045          int handle, uint64_t *start, uint64_t *size)          int handle, uint64_t *start, uint64_t *size)
1046  {  {
1047          char *s = machine->md.arc.file_handle_string[handle];          char *s = machine->md.arc->file_handle_string[handle];
1048          char *s2;          char *s2;
1049          int disk_id, disk_type;          int disk_id, disk_type;
1050    
# Line 1171  int arcbios_emul(struct cpu *cpu) Line 1168  int arcbios_emul(struct cpu *cpu)
1168                  return 1;                  return 1;
1169          }          }
1170    
1171          if (machine->md.arc.arc_64bit)          if (machine->md.arc->arc_64bit)
1172                  vector /= 2;                  vector /= 2;
1173    
1174          /*  Special case for reboot by jumping to 0xbfc00000:  */          /*  Special case for reboot by jumping to 0xbfc00000:  */
# Line 1200  int arcbios_emul(struct cpu *cpu) Line 1197  int arcbios_emul(struct cpu *cpu)
1197                          uint64_t peer;                          uint64_t peer;
1198                          cpu->memory_rw(cpu, cpu->mem,                          cpu->memory_rw(cpu, cpu->mem,
1199                              cpu->cd.mips.gpr[MIPS_GPR_A0] - 3 *                              cpu->cd.mips.gpr[MIPS_GPR_A0] - 3 *
1200                              machine->md.arc.wordlen, &buf[0],                              machine->md.arc->wordlen, &buf[0],
1201                              machine->md.arc.wordlen, MEM_READ, CACHE_NONE);                              machine->md.arc->wordlen, MEM_READ, CACHE_NONE);
1202                          if (machine->md.arc.arc_64bit) {                          if (machine->md.arc->arc_64bit) {
1203                                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1204                                          unsigned char tmp; tmp = buf[0];                                          unsigned char tmp; tmp = buf[0];
1205                                          buf[0] = buf[7]; buf[7] = tmp;                                          buf[0] = buf[7]; buf[7] = tmp;
# Line 1232  int arcbios_emul(struct cpu *cpu) Line 1229  int arcbios_emul(struct cpu *cpu)
1229                          }                          }
1230    
1231                          cpu->cd.mips.gpr[MIPS_GPR_V0] = peer?                          cpu->cd.mips.gpr[MIPS_GPR_V0] = peer?
1232                              (peer + 3 * machine->md.arc.wordlen) : 0;                              (peer + 3 * machine->md.arc->wordlen) : 0;
1233                          if (!machine->md.arc.arc_64bit)                          if (!machine->md.arc->arc_64bit)
1234                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)
1235                                      (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0];                                      (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0];
1236                  }                  }
# Line 1245  int arcbios_emul(struct cpu *cpu) Line 1242  int arcbios_emul(struct cpu *cpu)
1242                  /*  0 for the root, non-0 for children:  */                  /*  0 for the root, non-0 for children:  */
1243                  if (cpu->cd.mips.gpr[MIPS_GPR_A0] == 0)                  if (cpu->cd.mips.gpr[MIPS_GPR_A0] == 0)
1244                          cpu->cd.mips.gpr[MIPS_GPR_V0] = FIRST_ARC_COMPONENT                          cpu->cd.mips.gpr[MIPS_GPR_V0] = FIRST_ARC_COMPONENT
1245                              + machine->md.arc.wordlen * 3;                              + machine->md.arc->wordlen * 3;
1246                  else {                  else {
1247                          uint64_t child = 0;                          uint64_t child = 0;
1248                          cpu->memory_rw(cpu, cpu->mem,                          cpu->memory_rw(cpu, cpu->mem,
1249                              cpu->cd.mips.gpr[MIPS_GPR_A0] - 2 *                              cpu->cd.mips.gpr[MIPS_GPR_A0] - 2 *
1250                              machine->md.arc.wordlen, &buf[0], machine->                              machine->md.arc->wordlen, &buf[0], machine->
1251                              md.arc.wordlen, MEM_READ, CACHE_NONE);                              md.arc->wordlen, MEM_READ, CACHE_NONE);
1252                          if (machine->md.arc.arc_64bit) {                          if (machine->md.arc->arc_64bit) {
1253                                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1254                                          unsigned char tmp; tmp = buf[0];                                          unsigned char tmp; tmp = buf[0];
1255                                          buf[0] = buf[7]; buf[7] = tmp;                                          buf[0] = buf[7]; buf[7] = tmp;
# Line 1283  int arcbios_emul(struct cpu *cpu) Line 1280  int arcbios_emul(struct cpu *cpu)
1280                          }                          }
1281    
1282                          cpu->cd.mips.gpr[MIPS_GPR_V0] = child?                          cpu->cd.mips.gpr[MIPS_GPR_V0] = child?
1283                              (child + 3 * machine->md.arc.wordlen) : 0;                              (child + 3 * machine->md.arc->wordlen) : 0;
1284                          if (!machine->md.arc.arc_64bit)                          if (!machine->md.arc->arc_64bit)
1285                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)
1286                                      (int32_t)cpu->cd.mips.gpr[MIPS_GPR_V0];                                      (int32_t)cpu->cd.mips.gpr[MIPS_GPR_V0];
1287                  }                  }
# Line 1298  int arcbios_emul(struct cpu *cpu) Line 1295  int arcbios_emul(struct cpu *cpu)
1295    
1296                          cpu->memory_rw(cpu, cpu->mem,                          cpu->memory_rw(cpu, cpu->mem,
1297                              cpu->cd.mips.gpr[MIPS_GPR_A0] - 1 * machine->                              cpu->cd.mips.gpr[MIPS_GPR_A0] - 1 * machine->
1298                              md.arc.wordlen, &buf[0], machine->md.arc.wordlen,                              md.arc->wordlen, &buf[0], machine->md.arc->wordlen,
1299                              MEM_READ, CACHE_NONE);                              MEM_READ, CACHE_NONE);
1300    
1301                          if (machine->md.arc.arc_64bit) {                          if (machine->md.arc->arc_64bit) {
1302                                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {                                  if (cpu->byte_order == EMUL_BIG_ENDIAN) {
1303                                          unsigned char tmp; tmp = buf[0];                                          unsigned char tmp; tmp = buf[0];
1304                                          buf[0] = buf[7]; buf[7] = tmp;                                          buf[0] = buf[7]; buf[7] = tmp;
# Line 1332  int arcbios_emul(struct cpu *cpu) Line 1329  int arcbios_emul(struct cpu *cpu)
1329                          }                          }
1330    
1331                          cpu->cd.mips.gpr[MIPS_GPR_V0] = parent?                          cpu->cd.mips.gpr[MIPS_GPR_V0] = parent?
1332                              (parent + 3 * machine->md.arc.wordlen) : 0;                              (parent + 3 * machine->md.arc->wordlen) : 0;
1333                          if (!machine->md.arc.arc_64bit)                          if (!machine->md.arc->arc_64bit)
1334                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = (int64_t)
1335                                      (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0];                                      (int32_t) cpu->cd.mips.gpr[MIPS_GPR_V0];
1336                  }                  }
# Line 1347  int arcbios_emul(struct cpu *cpu) Line 1344  int arcbios_emul(struct cpu *cpu)
1344                      (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0],                      (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A0],
1345                      (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1]);  */                      (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A1]);  */
1346                  cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EINVAL;                  cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EINVAL;
1347                  for (i=0; i<machine->md.arc.n_configuration_data; i++) {                  for (i=0; i<machine->md.arc->n_configuration_data; i++) {
1348                          /*  fatal("configuration_data_component[%i] = "                          /*  fatal("configuration_data_component[%i] = "
1349                              "0x%016"PRIx64"\n", i, (uint64_t) machine->                              "0x%016"PRIx64"\n", i, (uint64_t) machine->
1350                              md.arc.configuration_data_component[i]);  */                              md.arc->configuration_data_component[i]);  */
1351                          if (cpu->cd.mips.gpr[MIPS_GPR_A1] ==                          if (cpu->cd.mips.gpr[MIPS_GPR_A1] ==
1352                              machine->md.arc.configuration_data_component[i]) {                              machine->md.arc->configuration_data_component[i]) {
1353                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1354                                  for (j=0; j<machine->                                  for (j=0; j<machine->
1355                                      md.arc.configuration_data_len[i]; j++) {                                      md.arc->configuration_data_len[i]; j++) {
1356                                          unsigned char ch;                                          unsigned char ch;
1357                                          cpu->memory_rw(cpu, cpu->mem,                                          cpu->memory_rw(cpu, cpu->mem,
1358                                              machine->md.arc.                                              machine->md.arc->
1359                                              configuration_data_configdata[i] +                                              configuration_data_configdata[i] +
1360                                              j, &ch, 1, MEM_READ, CACHE_NONE);                                              j, &ch, 1, MEM_READ, CACHE_NONE);
1361                                          cpu->memory_rw(cpu, cpu->mem,                                          cpu->memory_rw(cpu, cpu->mem,
# Line 1398  int arcbios_emul(struct cpu *cpu) Line 1395  int arcbios_emul(struct cpu *cpu)
1395                          cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;                          cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1396    
1397                          /*  Scan the string to component table:  */                          /*  Scan the string to component table:  */
1398                          for (i=0; i<machine->md.arc.n_string_to_components;                          for (i=0; i<machine->md.arc->n_string_to_components;
1399                              i++) {                              i++) {
1400                                  int m = 0;                                  int m = 0;
1401                                  while (buf[m] && machine->md.arc.                                  while (buf[m] && machine->md.arc->
1402                                      string_to_component[i][m] &&                                      string_to_component[i][m] &&
1403                                      machine->md.arc.string_to_component[i][m]                                      machine->md.arc->string_to_component[i][m]
1404                                      == buf[m])                                      == buf[m])
1405                                          m++;                                          m++;
1406                                  if (m > match_len) {                                  if (m > match_len) {
# Line 1414  int arcbios_emul(struct cpu *cpu) Line 1411  int arcbios_emul(struct cpu *cpu)
1411    
1412                          if (match_index >= 0) {                          if (match_index >= 0) {
1413                                  /*  printf("Longest match: '%s'\n",                                  /*  printf("Longest match: '%s'\n",
1414                                      machine->md.arc.string_to_component[                                      machine->md.arc->string_to_component[
1415                                      match_index]);  */                                      match_index]);  */
1416                                  cpu->cd.mips.gpr[MIPS_GPR_V0] =                                  cpu->cd.mips.gpr[MIPS_GPR_V0] =
1417                                      machine->md.arc.string_to_component_value[                                      machine->md.arc->string_to_component_value[
1418                                      match_index];                                      match_index];
1419                          }                          }
1420                  }                  }
# Line 1433  int arcbios_emul(struct cpu *cpu) Line 1430  int arcbios_emul(struct cpu *cpu)
1430                  /*  If a0=NULL, then return the first descriptor:  */                  /*  If a0=NULL, then return the first descriptor:  */
1431                  if ((uint32_t)cpu->cd.mips.gpr[MIPS_GPR_A0] == 0)                  if ((uint32_t)cpu->cd.mips.gpr[MIPS_GPR_A0] == 0)
1432                          cpu->cd.mips.gpr[MIPS_GPR_V0] =                          cpu->cd.mips.gpr[MIPS_GPR_V0] =
1433                              machine->md.arc.memdescriptor_base;                              machine->md.arc->memdescriptor_base;
1434                  else {                  else {
1435                          int s = machine->md.arc.arc_64bit?                          int s = machine->md.arc->arc_64bit?
1436                              sizeof(struct arcbios_mem64)                              sizeof(struct arcbios_mem64)
1437                              : sizeof(struct arcbios_mem);                              : sizeof(struct arcbios_mem);
1438                          int nr = cpu->cd.mips.gpr[MIPS_GPR_A0] -                          int nr = cpu->cd.mips.gpr[MIPS_GPR_A0] -
1439                              machine->md.arc.memdescriptor_base;                              machine->md.arc->memdescriptor_base;
1440                          nr /= s;                          nr /= s;
1441                          nr ++;                          nr ++;
1442                          cpu->cd.mips.gpr[MIPS_GPR_V0] =                          cpu->cd.mips.gpr[MIPS_GPR_V0] =
1443                              machine->md.arc.memdescriptor_base + s * nr;                              machine->md.arc->memdescriptor_base + s * nr;
1444                          if (nr >= machine->md.arc.n_memdescriptors)                          if (nr >= machine->md.arc->n_memdescriptors)
1445                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1446                  }                  }
1447                  break;                  break;
# Line 1468  int arcbios_emul(struct cpu *cpu) Line 1465  int arcbios_emul(struct cpu *cpu)
1465    
1466                  handle = 3;                  handle = 3;
1467                  /*  TODO: Starting at 0 would require some updates...  */                  /*  TODO: Starting at 0 would require some updates...  */
1468                  while (machine->md.arc.file_handle_in_use[handle]) {                  while (machine->md.arc->file_handle_in_use[handle]) {
1469                          handle ++;                          handle ++;
1470                          if (handle >= ARC_MAX_HANDLES) {                          if (handle >= ARC_MAX_HANDLES) {
1471                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EMFILE;                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EMFILE;
# Line 1486  int arcbios_emul(struct cpu *cpu) Line 1483  int arcbios_emul(struct cpu *cpu)
1483                           *  anything. It is used by the Windows NT SETUPLDR                           *  anything. It is used by the Windows NT SETUPLDR
1484                           *  program to load stuff from the boot partition.                           *  program to load stuff from the boot partition.
1485                           */                           */
1486                          unsigned char *buf = malloc(MAX_OPEN_STRINGLEN);                          unsigned char *buf;
1487                          if (buf == NULL) {                          CHECK_ALLOCATION(buf = malloc(MAX_OPEN_STRINGLEN));
                                 fprintf(stderr, "out of memory\n");  
                                 exit(1);  
                         }  
1488                          memset(buf, 0, MAX_OPEN_STRINGLEN);                          memset(buf, 0, MAX_OPEN_STRINGLEN);
1489                          for (i=0; i<MAX_OPEN_STRINGLEN; i++) {                          for (i=0; i<MAX_OPEN_STRINGLEN; i++) {
1490                                  cpu->memory_rw(cpu, cpu->mem,                                  cpu->memory_rw(cpu, cpu->mem,
# Line 1500  int arcbios_emul(struct cpu *cpu) Line 1494  int arcbios_emul(struct cpu *cpu)
1494                                          i = MAX_OPEN_STRINGLEN;                                          i = MAX_OPEN_STRINGLEN;
1495                          }                          }
1496                          buf[MAX_OPEN_STRINGLEN - 1] = '\0';                          buf[MAX_OPEN_STRINGLEN - 1] = '\0';
1497                          machine->md.arc.file_handle_string[handle] =                          machine->md.arc->file_handle_string[handle] =
1498                              (char *)buf;                              (char *)buf;
1499                          machine->md.arc.current_seek_offset[handle] = 0;                          machine->md.arc->current_seek_offset[handle] = 0;
1500                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_ESUCCESS;                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_ESUCCESS;
1501                  }                  }
1502    
# Line 1510  int arcbios_emul(struct cpu *cpu) Line 1504  int arcbios_emul(struct cpu *cpu)
1504                          debug(" = handle %i ]\n", (int)handle);                          debug(" = handle %i ]\n", (int)handle);
1505                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A2],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A2],
1506                              handle);                              handle);
1507                          machine->md.arc.file_handle_in_use[handle] = 1;                          machine->md.arc->file_handle_in_use[handle] = 1;
1508                  } else                  } else
1509                          debug(" = ERROR %i ]\n",                          debug(" = ERROR %i ]\n",
1510                              (int)cpu->cd.mips.gpr[MIPS_GPR_V0]);                              (int)cpu->cd.mips.gpr[MIPS_GPR_V0]);
# Line 1518  int arcbios_emul(struct cpu *cpu) Line 1512  int arcbios_emul(struct cpu *cpu)
1512          case 0x60:              /*  Close(uint32_t handle)  */          case 0x60:              /*  Close(uint32_t handle)  */
1513                  debug("[ ARCBIOS Close(%i) ]\n",                  debug("[ ARCBIOS Close(%i) ]\n",
1514                      (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);                      (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);
1515                  if (!machine->md.arc.file_handle_in_use[cpu->cd.mips.gpr[                  if (!machine->md.arc->file_handle_in_use[cpu->cd.mips.gpr[
1516                      MIPS_GPR_A0]]) {                      MIPS_GPR_A0]]) {
1517                          fatal("ARCBIOS Close(%i): bad handle\n",                          fatal("ARCBIOS Close(%i): bad handle\n",
1518                              (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);                              (int)cpu->cd.mips.gpr[MIPS_GPR_A0]);
1519                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EBADF;                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EBADF;
1520                  } else {                  } else {
1521                          machine->md.arc.file_handle_in_use[                          machine->md.arc->file_handle_in_use[
1522                              cpu->cd.mips.gpr[MIPS_GPR_A0]] = 0;                              cpu->cd.mips.gpr[MIPS_GPR_A0]] = 0;
1523                          if (machine->md.arc.file_handle_string[                          if (machine->md.arc->file_handle_string[
1524                              cpu->cd.mips.gpr[MIPS_GPR_A0]] != NULL)                              cpu->cd.mips.gpr[MIPS_GPR_A0]] != NULL)
1525                                  free(machine->md.arc.file_handle_string[                                  free(machine->md.arc->file_handle_string[
1526                                      cpu->cd.mips.gpr[MIPS_GPR_A0]]);                                      cpu->cd.mips.gpr[MIPS_GPR_A0]]);
1527                          machine->md.arc.file_handle_string[cpu->cd.mips.                          machine->md.arc->file_handle_string[cpu->cd.mips.
1528                              gpr[MIPS_GPR_A0]] = NULL;                              gpr[MIPS_GPR_A0]] = NULL;
1529                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_ESUCCESS;                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_ESUCCESS;
1530                  }                  }
# Line 1546  int arcbios_emul(struct cpu *cpu) Line 1540  int arcbios_emul(struct cpu *cpu)
1540                          fflush(stdin);                          fflush(stdin);
1541                          fflush(stdout);                          fflush(stdout);
1542                          /*  NOTE/TODO: This gives a tick to _everything_  */                          /*  NOTE/TODO: This gives a tick to _everything_  */
1543                          for (i=0; i<machine->n_tick_entries; i++)                          for (i=0; i<machine->tick_functions.n_entries; i++)
1544                                  machine->tick_func[i](cpu,                                  machine->tick_functions.f[i](cpu,
1545                                      machine->tick_extra[i]);                                      machine->tick_functions.extra[i]);
1546    
1547                          for (i=0; i<(int32_t)cpu->cd.mips.gpr[MIPS_GPR_A2];                          for (i=0; i<(int32_t)cpu->cd.mips.gpr[MIPS_GPR_A2];
1548                              i++) {                              i++) {
# Line 1609  int arcbios_emul(struct cpu *cpu) Line 1603  int arcbios_emul(struct cpu *cpu)
1603                              (int)cpu->cd.mips.gpr[MIPS_GPR_A2],                              (int)cpu->cd.mips.gpr[MIPS_GPR_A2],
1604                              (int)cpu->cd.mips.gpr[MIPS_GPR_A3]);                              (int)cpu->cd.mips.gpr[MIPS_GPR_A3]);
1605    
1606                          tmp_buf = malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]);                          CHECK_ALLOCATION(tmp_buf =
1607                          if (tmp_buf == NULL) {                              malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]));
                                 fprintf(stderr, "[ ***  Out of memory in "  
                                     "arcbios.c, allocating %i bytes ]\n",  
                                     (int)cpu->cd.mips.gpr[MIPS_GPR_A2]);  
                                 break;  
                         }  
1608    
1609                          res = diskimage_access(machine, disk_id, disk_type,                          res = diskimage_access(machine, disk_id, disk_type,
1610                              0, partition_offset + machine->md.arc.                              0, partition_offset + machine->md.arc->
1611                              current_seek_offset[handle], tmp_buf,                              current_seek_offset[handle], tmp_buf,
1612                              cpu->cd.mips.gpr[MIPS_GPR_A2]);                              cpu->cd.mips.gpr[MIPS_GPR_A2]);
1613    
# Line 1631  int arcbios_emul(struct cpu *cpu) Line 1620  int arcbios_emul(struct cpu *cpu)
1620                                  store_32bit_word(cpu,                                  store_32bit_word(cpu,
1621                                      cpu->cd.mips.gpr[MIPS_GPR_A3],                                      cpu->cd.mips.gpr[MIPS_GPR_A3],
1622                                      cpu->cd.mips.gpr[MIPS_GPR_A2]);                                      cpu->cd.mips.gpr[MIPS_GPR_A2]);
1623                                  machine->md.arc.current_seek_offset[handle] +=                                  machine->md.arc->current_seek_offset[handle] +=
1624                                      cpu->cd.mips.gpr[MIPS_GPR_A2];                                      cpu->cd.mips.gpr[MIPS_GPR_A2];
1625                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1626                          } else                          } else
# Line 1681  int arcbios_emul(struct cpu *cpu) Line 1670  int arcbios_emul(struct cpu *cpu)
1670                              (int) cpu->cd.mips.gpr[MIPS_GPR_A2],                              (int) cpu->cd.mips.gpr[MIPS_GPR_A2],
1671                              (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A3]);                              (uint64_t) cpu->cd.mips.gpr[MIPS_GPR_A3]);
1672    
1673                          tmp_buf = malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]);                          CHECK_ALLOCATION(tmp_buf =
1674                          if (tmp_buf == NULL) {                              malloc(cpu->cd.mips.gpr[MIPS_GPR_A2]));
                                 fprintf(stderr, "[ ***  Out of memory in"  
                                     " arcbios.c, allocating %i bytes ]\n",  
                                     (int)cpu->cd.mips.gpr[MIPS_GPR_A2]);  
                                 break;  
                         }  
1675    
1676                          for (i=0; i<(int32_t)cpu->cd.mips.gpr[MIPS_GPR_A2]; i++)                          for (i=0; i<(int32_t)cpu->cd.mips.gpr[MIPS_GPR_A2]; i++)
1677                                  cpu->memory_rw(cpu, cpu->mem,                                  cpu->memory_rw(cpu, cpu->mem,
# Line 1696  int arcbios_emul(struct cpu *cpu) Line 1680  int arcbios_emul(struct cpu *cpu)
1680                                      CACHE_NONE);                                      CACHE_NONE);
1681    
1682                          res = diskimage_access(machine, disk_id, disk_type,                          res = diskimage_access(machine, disk_id, disk_type,
1683                              1, partition_offset + machine->md.arc.                              1, partition_offset + machine->md.arc->
1684                              current_seek_offset[handle], tmp_buf,                              current_seek_offset[handle], tmp_buf,
1685                              cpu->cd.mips.gpr[MIPS_GPR_A2]);                              cpu->cd.mips.gpr[MIPS_GPR_A2]);
1686    
# Line 1704  int arcbios_emul(struct cpu *cpu) Line 1688  int arcbios_emul(struct cpu *cpu)
1688                                  store_32bit_word(cpu,                                  store_32bit_word(cpu,
1689                                      cpu->cd.mips.gpr[MIPS_GPR_A3],                                      cpu->cd.mips.gpr[MIPS_GPR_A3],
1690                                      cpu->cd.mips.gpr[MIPS_GPR_A2]);                                      cpu->cd.mips.gpr[MIPS_GPR_A2]);
1691                                  machine->md.arc.current_seek_offset[handle] +=                                  machine->md.arc->current_seek_offset[handle] +=
1692                                      cpu->cd.mips.gpr[MIPS_GPR_A2];                                      cpu->cd.mips.gpr[MIPS_GPR_A2];
1693                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;                                  cpu->cd.mips.gpr[MIPS_GPR_V0] = 0;
1694                          } else                          } else
# Line 1758  int arcbios_emul(struct cpu *cpu) Line 1742  int arcbios_emul(struct cpu *cpu)
1742                              (buf[3] << 24) + ((uint64_t)buf[4] << 32) +                              (buf[3] << 24) + ((uint64_t)buf[4] << 32) +
1743                              ((uint64_t)buf[5] << 40) + ((uint64_t)buf[6] << 48)                              ((uint64_t)buf[5] << 40) + ((uint64_t)buf[6] << 48)
1744                              + ((uint64_t)buf[7] << 56);                              + ((uint64_t)buf[7] << 56);
1745                          machine->md.arc.current_seek_offset[                          machine->md.arc->current_seek_offset[
1746                              cpu->cd.mips.gpr[MIPS_GPR_A0]] = ofs;                              cpu->cd.mips.gpr[MIPS_GPR_A0]] = ofs;
1747                          debug("%016"PRIx64" ]\n", (uint64_t) ofs);                          debug("%016"PRIx64" ]\n", (uint64_t) ofs);
1748                  }                  }
# Line 1815  int arcbios_emul(struct cpu *cpu) Line 1799  int arcbios_emul(struct cpu *cpu)
1799                  if (cpu->cd.mips.gpr[MIPS_GPR_A0] >= ARC_MAX_HANDLES) {                  if (cpu->cd.mips.gpr[MIPS_GPR_A0] >= ARC_MAX_HANDLES) {
1800                          debug("invalid file handle ]\n");                          debug("invalid file handle ]\n");
1801                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EINVAL;                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EINVAL;
1802                  } else if (!machine->md.arc.file_handle_in_use[cpu->cd.                  } else if (!machine->md.arc->file_handle_in_use[cpu->cd.
1803                      mips.gpr[MIPS_GPR_A0]]) {                      mips.gpr[MIPS_GPR_A0]]) {
1804                          debug("file handle not in use! ]\n");                          debug("file handle not in use! ]\n");
1805                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EBADF;                          cpu->cd.mips.gpr[MIPS_GPR_V0] = ARCBIOS_EBADF;
1806                  } else {                  } else {
1807                          debug("'%s' ]\n", machine->md.arc.file_handle_string[                          debug("'%s' ]\n", machine->md.arc->file_handle_string[
1808                              cpu->cd.mips.gpr[MIPS_GPR_A0]]);                              cpu->cd.mips.gpr[MIPS_GPR_A0]]);
1809                          cpu->cd.mips.gpr[MIPS_GPR_V0] =                          cpu->cd.mips.gpr[MIPS_GPR_V0] =
1810                              arcbios_getfileinformation(cpu);                              arcbios_getfileinformation(cpu);
# Line 1910  static void arcbios_add_other_components Line 1894  static void arcbios_add_other_components
1894          struct cpu *cpu = machine->cpus[0];          struct cpu *cpu = machine->cpus[0];
1895    
1896          if (machine->machine_type == MACHINE_ARC &&          if (machine->machine_type == MACHINE_ARC &&
             ( machine->machine_subtype == MACHINE_ARC_NEC_RD94 ||  
             machine->machine_subtype == MACHINE_ARC_NEC_R94 ||  
             machine->machine_subtype == MACHINE_ARC_NEC_R96 )) {  
                 uint64_t jazzbus, eisa, other;  
   
                 jazzbus = arcbios_addchild_manual(cpu,  
                     COMPONENT_CLASS_AdapterClass,  
                     COMPONENT_TYPE_MultiFunctionAdapter,  
                     0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus",  
                     system, NULL, 0);  
   
                 switch (machine->machine_subtype) {  
                 case MACHINE_ARC_NEC_RD94:  
                 case MACHINE_ARC_NEC_R94:  
                         if (machine->use_x11)  
                                 arcbios_addchild_manual(cpu,  
                                     COMPONENT_CLASS_ControllerClass,  
                                     COMPONENT_TYPE_DisplayController,  
                     0, 1, 2, 0, 0x0, "10110004",  
                                     system, NULL, 0);  
                         break;  
                 case MACHINE_ARC_NEC_R96:  
                         if (machine->use_x11) {  
                                 uint64_t x;  
                                 x = arcbios_addchild_manual(cpu,  
                                     COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_DisplayController,  
                                     COMPONENT_FLAG_ConsoleOut |  
                                       COMPONENT_FLAG_Output,  
                                     1, 2, 0, 0x0, "necvdfrb",  
                                     jazzbus, NULL, 0);  
                                 arcbios_addchild_manual(cpu,  
                                     COMPONENT_CLASS_PeripheralClass,  
                                     COMPONENT_TYPE_MonitorPeripheral,  
                                     COMPONENT_FLAG_ConsoleOut |  
                                         COMPONENT_FLAG_Output,  
                                     1, 2, 0, 0xffffffff, "640x480",  
                                     x, NULL, 0);  
                         }  
   
                         /*  TODO: R[D]94 too?  */  
                         eisa = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_AdapterClass,  
                             COMPONENT_TYPE_EISAAdapter,  
                             0, 1, 2, 0, 0xffffffff, "EISA",  
                             system, NULL, 0);  
   
                         other = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_OtherController,  
                             0, 1, 2, 0, 0xffffffff, "NEC1C01",  
                             eisa, NULL, 0);  
                         break;  
                 }  
         }  
   
         if (machine->machine_type == MACHINE_ARC &&  
1897              (machine->machine_subtype == MACHINE_ARC_JAZZ_PICA              (machine->machine_subtype == MACHINE_ARC_JAZZ_PICA
1898              || machine->machine_subtype == MACHINE_ARC_JAZZ_MAGNUM)) {              || machine->machine_subtype == MACHINE_ARC_JAZZ_MAGNUM)) {
1899                  uint64_t jazzbus, ali_s3, vxl;                  uint64_t jazzbus, ali_s3, vxl;
# Line 2038  static void arcbios_add_other_components Line 1965  static void arcbios_add_other_components
1965                              0xffffffffe2000000ULL, 0x090000000ULL,                              0xffffffffe2000000ULL, 0x090000000ULL,
1966                              0x091000000ULL, 1, 1, 1, 1, 1, 0, 2, 2);                              0x091000000ULL, 1, 1, 1, 1, 1, 0, 2, 2);
1967    
1968                          if (machine->use_x11) {                          if (machine->x11_md.in_use) {
1969                                  ali_s3 = arcbios_addchild_manual(cpu,                                  ali_s3 = arcbios_addchild_manual(cpu,
1970                                      COMPONENT_CLASS_ControllerClass,                                      COMPONENT_CLASS_ControllerClass,
1971                                      COMPONENT_TYPE_DisplayController,                                      COMPONENT_TYPE_DisplayController,
# Line 2057  static void arcbios_add_other_components Line 1984  static void arcbios_add_other_components
1984                          }                          }
1985                          break;                          break;
1986                  case MACHINE_ARC_JAZZ_MAGNUM:                  case MACHINE_ARC_JAZZ_MAGNUM:
1987                          if (machine->use_x11) {                          if (machine->x11_md.in_use) {
1988                                  vxl = arcbios_addchild_manual(cpu,                                  vxl = arcbios_addchild_manual(cpu,
1989                                      COMPONENT_CLASS_ControllerClass,                                      COMPONENT_CLASS_ControllerClass,
1990                                      COMPONENT_TYPE_DisplayController,                                      COMPONENT_TYPE_DisplayController,
# Line 2219  config[36] = 0x00; config[37] = 0x10; co Line 2146  config[36] = 0x00; config[37] = 0x10; co
2146  void arcbios_console_init(struct machine *machine,  void arcbios_console_init(struct machine *machine,
2147          uint64_t vram, uint64_t ctrlregs)          uint64_t vram, uint64_t ctrlregs)
2148  {  {
2149          machine->md.arc.vgaconsole = 1;          if (machine->md.arc == NULL) {
2150                    CHECK_ALLOCATION(machine->md.arc =
2151                        malloc(sizeof(struct machine_arcbios)));
2152                    memset(machine->md.arc, 0, sizeof(struct machine_arcbios));
2153            }
2154    
2155          machine->md.arc.console_vram = vram;          machine->md.arc->vgaconsole = 1;
2156          machine->md.arc.console_ctrlregs = ctrlregs;  
2157          machine->md.arc.console_maxx = ARC_CONSOLE_MAX_X;          machine->md.arc->console_vram = vram;
2158          machine->md.arc.console_maxy = ARC_CONSOLE_MAX_Y;          machine->md.arc->console_ctrlregs = ctrlregs;
2159          machine->md.arc.in_escape_sequence = 0;          machine->md.arc->console_maxx = ARC_CONSOLE_MAX_X;
2160          machine->md.arc.escape_sequence[0] = '\0';          machine->md.arc->console_maxy = ARC_CONSOLE_MAX_Y;
2161            machine->md.arc->in_escape_sequence = 0;
2162            machine->md.arc->escape_sequence[0] = '\0';
2163  }  }
2164    
2165    
# Line 2249  static void arc_environment_setup(struct Line 2182  static void arc_environment_setup(struct
2182           *  TODO: How about floppies? multi()disk()fdisk()           *  TODO: How about floppies? multi()disk()fdisk()
2183           *        Is tftp() good for netbooting?           *        Is tftp() good for netbooting?
2184           */           */
2185          init_bootpath = malloc(bootpath_len);          CHECK_ALLOCATION(init_bootpath = malloc(bootpath_len));
         if (init_bootpath == NULL) {  
                 fprintf(stderr, "out of mem, bootpath\n");  
                 exit(1);  
         }  
2186          init_bootpath[0] = '\0';          init_bootpath[0] = '\0';
2187    
2188          if (machine->bootdev_id < 0 || machine->force_netboot) {          if (machine->bootdev_id < 0 || machine->force_netboot) {
# Line 2284  static void arc_environment_setup(struct Line 2213  static void arc_environment_setup(struct
2213          if (machine->machine_type == MACHINE_ARC)          if (machine->machine_type == MACHINE_ARC)
2214                  strlcat(init_bootpath, "\\", bootpath_len);                  strlcat(init_bootpath, "\\", bootpath_len);
2215    
2216          machine->bootstr = malloc(ARC_BOOTSTR_BUFLEN);          CHECK_ALLOCATION(machine->bootstr = malloc(ARC_BOOTSTR_BUFLEN));
                 if (machine->bootstr == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
         }  
2217    
2218          strlcpy(machine->bootstr, init_bootpath, ARC_BOOTSTR_BUFLEN);          strlcpy(machine->bootstr, init_bootpath, ARC_BOOTSTR_BUFLEN);
2219          if (strlcat(machine->bootstr, machine->boot_kernel_filename,          if (strlcat(machine->bootstr, machine->boot_kernel_filename,
# Line 2331  static void arc_environment_setup(struct Line 2256  static void arc_environment_setup(struct
2256           *  as a string using add_environment_string(), and add a           *  as a string using add_environment_string(), and add a
2257           *  pointer to it to the ARC_ENV_POINTERS array.           *  pointer to it to the ARC_ENV_POINTERS array.
2258           */           */
2259          if (machine->use_x11) {          if (machine->x11_md.in_use) {
2260                  if (machine->machine_type == MACHINE_ARC) {                  if (machine->machine_type == MACHINE_ARC) {
2261                          store_pointer_and_advance(cpu, &addr2, addr, is64bit);                          store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2262                          add_environment_string(cpu,                          add_environment_string(cpu,
# Line 2439  static void arc_environment_setup(struct Line 2364  static void arc_environment_setup(struct
2364                  char *tmp;                  char *tmp;
2365                  size_t mlen = strlen(machine->bootarg) +                  size_t mlen = strlen(machine->bootarg) +
2366                      strlen("OSLOADOPTIONS=") + 2;                      strlen("OSLOADOPTIONS=") + 2;
2367                  tmp = malloc(mlen);                  CHECK_ALLOCATION(tmp = malloc(mlen));
2368                  snprintf(tmp, mlen, "OSLOADOPTIONS=%s", machine->bootarg);                  snprintf(tmp, mlen, "OSLOADOPTIONS=%s", machine->bootarg);
2369                  store_pointer_and_advance(cpu, &addr2, addr, is64bit);                  store_pointer_and_advance(cpu, &addr2, addr, is64bit);
2370                  add_environment_string(cpu, tmp, &addr);                  add_environment_string(cpu, tmp, &addr);
# Line 2484  void arcbios_init(struct machine *machin Line 2409  void arcbios_init(struct machine *machin
2409          struct arcbios_spb arcbios_spb;          struct arcbios_spb arcbios_spb;
2410          struct arcbios_spb_64 arcbios_spb_64;          struct arcbios_spb_64 arcbios_spb_64;
2411    
2412          machine->md.arc.arc_64bit = is64bit;          if (machine->md.arc == NULL) {
2413          machine->md.arc.wordlen = is64bit? sizeof(uint64_t) : sizeof(uint32_t);                  CHECK_ALLOCATION(machine->md.arc =
2414                        malloc(sizeof(struct machine_arcbios)));
2415                    memset(machine->md.arc, 0, sizeof(struct machine_arcbios));
2416            }
2417    
2418          machine->md.arc.next_component_address = FIRST_ARC_COMPONENT;          machine->md.arc->arc_64bit = is64bit;
2419          machine->md.arc.configuration_data_next_addr = ARC_CONFIG_DATA_ADDR;          machine->md.arc->wordlen = is64bit? sizeof(uint64_t) : sizeof(uint32_t);
2420    
2421            machine->md.arc->next_component_address = FIRST_ARC_COMPONENT;
2422            machine->md.arc->configuration_data_next_addr = ARC_CONFIG_DATA_ADDR;
2423    
2424          if (machine->physical_ram_in_mb < 16)          if (machine->physical_ram_in_mb < 16)
2425                  fprintf(stderr, "WARNING! The ARC platform specification "                  fprintf(stderr, "WARNING! The ARC platform specification "
# Line 2497  void arcbios_init(struct machine *machin Line 2428  void arcbios_init(struct machine *machin
2428    
2429          /*  File handles 0, 1, and 2 are stdin, stdout, and stderr.  */          /*  File handles 0, 1, and 2 are stdin, stdout, and stderr.  */
2430          for (i=0; i<ARC_MAX_HANDLES; i++) {          for (i=0; i<ARC_MAX_HANDLES; i++) {
2431                  machine->md.arc.file_handle_in_use[i] = i<3? 1 : 0;                  machine->md.arc->file_handle_in_use[i] = i<3? 1 : 0;
2432                  machine->md.arc.file_handle_string[i] = i>=3? NULL :                  machine->md.arc->file_handle_string[i] = i>=3? NULL :
2433                      (i==0? "(stdin)" : (i==1? "(stdout)" : "(stderr)"));                      (i==0? "(stdin)" : (i==1? "(stdout)" : "(stderr)"));
2434                  machine->md.arc.current_seek_offset[i] = 0;                  machine->md.arc->current_seek_offset[i] = 0;
2435          }          }
2436    
2437          if (!machine->use_x11)          if (!machine->x11_md.in_use)
2438                  machine->md.arc.vgaconsole = 0;                  machine->md.arc->vgaconsole = 0;
2439    
2440          if (machine->md.arc.vgaconsole) {          if (machine->md.arc->vgaconsole) {
2441                  char tmpstr[100];                  char tmpstr[100];
2442                  int x, y;                  int x, y;
2443    
2444                  machine->md.arc.console_curcolor = 0x1f;                  machine->md.arc->console_curcolor = 0x1f;
2445                  for (y=0; y<machine->md.arc.console_maxy; y++)                  for (y=0; y<machine->md.arc->console_maxy; y++)
2446                          for (x=0; x<machine->md.arc.console_maxx; x++)                          for (x=0; x<machine->md.arc->console_maxx; x++)
2447                                  arcbios_putcell(cpu, ' ', x, y);                                  arcbios_putcell(cpu, ' ', x, y);
2448    
2449                  machine->md.arc.console_curx = 0;                  machine->md.arc->console_curx = 0;
2450                  machine->md.arc.console_cury = 0;                  machine->md.arc->console_cury = 0;
2451    
2452                  arcbios_putstring(cpu, "GXemul");                  arcbios_putstring(cpu, "GXemul");
2453  #ifdef VERSION  #ifdef VERSION
# Line 2552  void arcbios_init(struct machine *machin Line 2483  void arcbios_init(struct machine *machin
2483                  }                  }
2484          } else {          } else {
2485                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
                 case MACHINE_ARC_NEC_RD94:  
                         strncpy(arcbios_sysid.VendorId,  "NEC W&S", 8);  
                         strncpy(arcbios_sysid.ProductId, "RD94", 4);  
                         break;  
                 case MACHINE_ARC_NEC_R94:  
                         strncpy(arcbios_sysid.VendorId,  "NEC W&S", 8);  
                         strncpy(arcbios_sysid.ProductId, "ijkl", 4);  
                         break;  
                 case MACHINE_ARC_NEC_R96:  
                         strncpy(arcbios_sysid.VendorId,  "MIPS DUO", 8);  
                         strncpy(arcbios_sysid.ProductId, "blahblah", 8);  
                         break;  
                 case MACHINE_ARC_NEC_R98:  
                         strncpy(arcbios_sysid.VendorId,  "NEC W&S", 8);  
                         strncpy(arcbios_sysid.ProductId, "R98", 4);  
                         break;  
2486                  case MACHINE_ARC_JAZZ_PICA:                  case MACHINE_ARC_JAZZ_PICA:
2487                          strncpy(arcbios_sysid.VendorId,  "MIPS MAG", 8);                          strncpy(arcbios_sysid.VendorId,  "MIPS MAG", 8);
2488                          strncpy(arcbios_sysid.ProductId, "ijkl", 4);                          strncpy(arcbios_sysid.ProductId, "ijkl", 4);
# Line 2576  void arcbios_init(struct machine *machin Line 2491  void arcbios_init(struct machine *machin
2491                          strncpy(arcbios_sysid.VendorId,  "MIPS MAG", 8);                          strncpy(arcbios_sysid.VendorId,  "MIPS MAG", 8);
2492                          strncpy(arcbios_sysid.ProductId, "ijkl", 4);                          strncpy(arcbios_sysid.ProductId, "ijkl", 4);
2493                          break;                          break;
                 case MACHINE_ARC_JAZZ_M700:  
                         strncpy(arcbios_sysid.VendorId,  "OLI00000", 8);  
                         strncpy(arcbios_sysid.ProductId, "ijkl", 4);  
                         break;  
                 case MACHINE_ARC_DESKTECH_TYNE:  
                         strncpy(arcbios_sysid.VendorId,  "DESKTECH", 8);  
                         strncpy(arcbios_sysid.ProductId, "ijkl", 4);  
                         break;  
2494                  default:                  default:
2495                          fatal("error in machine.c sysid\n");                          fatal("error in machine.c sysid\n");
2496                          exit(1);                          exit(1);
# Line 2607  void arcbios_init(struct machine *machin Line 2514  void arcbios_init(struct machine *machin
2514           *  0x1fffffff (256 - 512 MB) is usually occupied by memory mapped           *  0x1fffffff (256 - 512 MB) is usually occupied by memory mapped
2515           *  devices, so that portion is "lost".           *  devices, so that portion is "lost".
2516           */           */
2517          machine->md.arc.memdescriptor_base = ARC_MEMDESC_ADDR;          machine->md.arc->memdescriptor_base = ARC_MEMDESC_ADDR;
2518    
2519          arc_reserved = 0x2000;          arc_reserved = 0x2000;
2520          if (machine->machine_type == MACHINE_SGI)          if (machine->machine_type == MACHINE_SGI)
# Line 2668  void arcbios_init(struct machine *machin Line 2575  void arcbios_init(struct machine *machin
2575          /*  Add the root node:  */          /*  Add the root node:  */
2576          switch (machine->machine_type) {          switch (machine->machine_type) {
2577          case MACHINE_SGI:          case MACHINE_SGI:
2578                  name = malloc(alloclen);                  CHECK_ALLOCATION(name = malloc(alloclen));
                 if (name == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
2579                  snprintf(name, alloclen, "SGI-IP%i",                  snprintf(name, alloclen, "SGI-IP%i",
2580                      machine->machine_subtype);                      machine->machine_subtype);
2581    
# Line 2684  void arcbios_init(struct machine *machin Line 2587  void arcbios_init(struct machine *machin
2587          case MACHINE_ARC:          case MACHINE_ARC:
2588                  /*  ARC:  */                  /*  ARC:  */
2589                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
                 case MACHINE_ARC_NEC_RD94:  
                         name = "NEC-RD94";  
                         break;  
                 case MACHINE_ARC_NEC_R94:  
                         name = "NEC-R94";  
                         break;  
                 case MACHINE_ARC_NEC_R96:  
                         name = "NEC-R96";  
                         break;  
                 case MACHINE_ARC_NEC_R98:  
                         name = "NEC-R98";  
                         break;  
2590                  case MACHINE_ARC_JAZZ_PICA:                  case MACHINE_ARC_JAZZ_PICA:
2591                          name = "PICA-61";                          name = "PICA-61";
2592                          break;                          break;
2593                  case MACHINE_ARC_JAZZ_MAGNUM:                  case MACHINE_ARC_JAZZ_MAGNUM:
                 case MACHINE_ARC_JAZZ_M700:  
2594                          name = "Microsoft-Jazz";                          name = "Microsoft-Jazz";
2595                          break;                          break;
                 case MACHINE_ARC_DESKTECH_TYNE:  
                         name = "DESKTECH-TYNE";  
                         break;  
2596                  default:                  default:
2597                          fatal("Unimplemented ARC machine type %i\n",                          fatal("Unimplemented ARC machine type %i\n",
2598                              machine->machine_subtype);                              machine->machine_subtype);
# Line 2736  void arcbios_init(struct machine *machin Line 2623  void arcbios_init(struct machine *machin
2623                  snprintf(arc_cpu_name, sizeof(arc_cpu_name),                  snprintf(arc_cpu_name, sizeof(arc_cpu_name),
2624                      "MIPS-%s", machine->cpu_name);                      "MIPS-%s", machine->cpu_name);
2625    
                 if (machine->machine_type == MACHINE_ARC &&  
                     machine->machine_subtype == MACHINE_ARC_NEC_R96)  
                         snprintf(arc_cpu_name, sizeof(arc_cpu_name),  
                             "MIPS-%s - Pr 4/5.0, Fp 5/0", machine->cpu_name);  
   
2626                  arc_cpu_name[sizeof(arc_cpu_name)-1] = 0;                  arc_cpu_name[sizeof(arc_cpu_name)-1] = 0;
2627                  for (jj=0; jj<strlen(arc_cpu_name); jj++)                  for (jj=0; jj<strlen(arc_cpu_name); jj++)
2628                          if (arc_cpu_name[jj] >= 'a' && arc_cpu_name[jj] <= 'z')                          if (arc_cpu_name[jj] >= 'a' && arc_cpu_name[jj] <= 'z')
# Line 2764  void arcbios_init(struct machine *machin Line 2646  void arcbios_init(struct machine *machin
2646                              NULL, 0);                              NULL, 0);
2647    
2648                  cache_size = DEFAULT_PCACHE_SIZE - 12;                  cache_size = DEFAULT_PCACHE_SIZE - 12;
2649                  if (machine->cache_picache)                  if (cpu->cd.mips.cache_picache)
2650                          cache_size = machine->cache_picache - 12;                          cache_size = cpu->cd.mips.cache_picache - 12;
2651                  if (cache_size < 0)                  if (cache_size < 0)
2652                          cache_size = 0;                          cache_size = 0;
2653    
2654                  cache_line_size = DEFAULT_PCACHE_LINESIZE;                  cache_line_size = DEFAULT_PCACHE_LINESIZE;
2655                  if (machine->cache_picache_linesize)                  if (cpu->cd.mips.cache_picache_linesize)
2656                          cache_line_size = machine->cache_picache_linesize;                          cache_line_size = cpu->cd.mips.cache_picache_linesize;
2657                  if (cache_line_size < 0)                  if (cache_line_size < 0)
2658                          cache_line_size = 0;                          cache_line_size = 0;
2659    
# Line 2789  void arcbios_init(struct machine *machin Line 2671  void arcbios_init(struct machine *machin
2671                      0xffffffff, NULL, cpuaddr, NULL, 0);                      0xffffffff, NULL, cpuaddr, NULL, 0);
2672    
2673                  cache_size = DEFAULT_PCACHE_SIZE - 12;                  cache_size = DEFAULT_PCACHE_SIZE - 12;
2674                  if (machine->cache_pdcache)                  if (cpu->cd.mips.cache_pdcache)
2675                          cache_size = machine->cache_pdcache - 12;                          cache_size = cpu->cd.mips.cache_pdcache - 12;
2676                  if (cache_size < 0)                  if (cache_size < 0)
2677                          cache_size = 0;                          cache_size = 0;
2678    
2679                  cache_line_size = DEFAULT_PCACHE_LINESIZE;                  cache_line_size = DEFAULT_PCACHE_LINESIZE;
2680                  if (machine->cache_pdcache_linesize)                  if (cpu->cd.mips.cache_pdcache_linesize)
2681                          cache_line_size = machine->cache_pdcache_linesize;                          cache_line_size = cpu->cd.mips.cache_pdcache_linesize;
2682                  if (cache_line_size < 0)                  if (cache_line_size < 0)
2683                          cache_line_size = 0;                          cache_line_size = 0;
2684    
# Line 2812  void arcbios_init(struct machine *machin Line 2694  void arcbios_init(struct machine *machin
2694                          /*  32 bytes per line, default = 32 KB total  */                          /*  32 bytes per line, default = 32 KB total  */
2695                      0xffffffff, NULL, cpuaddr, NULL, 0);                      0xffffffff, NULL, cpuaddr, NULL, 0);
2696    
2697                  if (machine->cache_secondary >= 12) {                  if (cpu->cd.mips.cache_secondary >= 12) {
2698                          cache_size = machine->cache_secondary - 12;                          cache_size = cpu->cd.mips.cache_secondary - 12;
2699    
2700                          cache_line_size = 6;    /*  64 bytes default  */                          cache_line_size = 6;    /*  64 bytes default  */
2701                          if (machine->cache_secondary_linesize)                          if (cpu->cd.mips.cache_secondary_linesize)
2702                                  cache_line_size = machine->                                  cache_line_size = cpu->cd.mips.
2703                                      cache_secondary_linesize;                                      cache_secondary_linesize;
2704                          if (cache_line_size < 0)                          if (cache_line_size < 0)
2705                                  cache_line_size = 0;                                  cache_line_size = 0;
# Line 2845  void arcbios_init(struct machine *machin Line 2727  void arcbios_init(struct machine *machin
2727                  debug("    picache @ 0x%"PRIx64", pdcache @ 0x%"PRIx64"\n",                  debug("    picache @ 0x%"PRIx64", pdcache @ 0x%"PRIx64"\n",
2728                      (uint64_t) picache, (uint64_t) pdcache);                      (uint64_t) picache, (uint64_t) pdcache);
2729    
2730                  if (machine->cache_secondary >= 12)                  if (cpu->cd.mips.cache_secondary >= 12)
2731                          debug("    sdcache @ 0x%"PRIx64"\n",                          debug("    sdcache @ 0x%"PRIx64"\n",
2732                              (uint64_t) sdcache);                              (uint64_t) sdcache);
2733    

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26