/[gxemul]/trunk/src/devices/dev_sgi_ip30.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/devices/dev_sgi_ip30.c

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

revision 24 by dpavlin, Mon Oct 8 16:19:56 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2004-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_sgi_ip30.c,v 1.21 2006/03/04 12:38:48 debug Exp $   *  $Id: dev_sgi_ip30.c,v 1.26 2007/06/15 19:57:34 debug Exp $
29   *     *  
30   *  SGI IP30 stuff.   *  COMMENT: SGI IP30 stuff
31   *   *
32   *  This is just comprised of hardcoded guesses so far. (Ugly.)   *  NOTE/TODO: This is just comprised of hardcoded guesses so far. (Ugly.)
33   */   */
34    
35  #include <stdio.h>  #include <stdio.h>
# Line 37  Line 37 
37  #include <string.h>  #include <string.h>
38    
39  #include "cpu.h"  #include "cpu.h"
40  #include "devices.h"  #include "device.h"
41  #include "machine.h"  #include "machine.h"
42  #include "memory.h"  #include "memory.h"
43  #include "misc.h"  #include "misc.h"
44    
45    
46  void dev_sgi_ip30_tick(struct cpu *cpu, void *extra)  #define DEV_SGI_IP30_LENGTH             0x80000
47    
48    struct sgi_ip30_data {
49            /*  ip30:  */
50            uint64_t                imask0;         /*  0x10000  */
51            uint64_t                reg_0x10018;
52            uint64_t                isr;            /*  0x10030  */
53            uint64_t                reg_0x20000;
54            uint64_t                reg_0x30000;
55    
56            /*  ip30_2:  */
57            uint64_t                reg_0x0029c;
58    
59            /*  ip30_3:  */
60            uint64_t                reg_0x00284;
61    
62            /*  ip30_4:  */
63            uint64_t                reg_0x000b0;
64    
65            /*  ip30_5:  */
66            uint64_t                reg_0x00000;
67    };
68    
69    
70    DEVICE_TICK(sgi_ip30)
71  {  {
72          struct sgi_ip30_data *d = extra;          struct sgi_ip30_data *d = extra;
73    
# Line 52  void dev_sgi_ip30_tick(struct cpu *cpu, Line 76  void dev_sgi_ip30_tick(struct cpu *cpu,
76          if (d->imask0 & ((int64_t)1<<50)) {          if (d->imask0 & ((int64_t)1<<50)) {
77                  /*  TODO: Only interrupt if reg 0x20000 (the counter)                  /*  TODO: Only interrupt if reg 0x20000 (the counter)
78                          has passed the compare (0x30000).  */                          has passed the compare (0x30000).  */
79                  cpu_interrupt(cpu, 8+1 + 50);  fatal("IP30 legacy interrupt rewrite: TODO\n");
80    abort();
81    //              cpu_interrupt(cpu, 8+1 + 50);
82          }          }
83  }  }
84    
85    
 /*  
  *  dev_sgi_ip30_access():  
  */  
86  DEVICE_ACCESS(sgi_ip30)  DEVICE_ACCESS(sgi_ip30)
87  {  {
88          struct sgi_ip30_data *d = (struct sgi_ip30_data *) extra;          struct sgi_ip30_data *d = extra;
89          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
90    
91          if (writeflag == MEM_WRITE)          if (writeflag == MEM_WRITE)
92                  idata = memory_readmax64(cpu, data, len);                  idata = memory_readmax64(cpu, data, len);
93    
94          switch (relative_addr) {          switch (relative_addr) {
95    
96          case 0x20:          case 0x20:
97                  /*  Memory bank configuration:  */                  /*  Memory bank configuration:  */
98                  odata = 0x80010000ULL;                  odata = 0x80010000ULL;
99                  break;                  break;
100    
101          case 0x10000:   /*  Interrupt mask register 0:  */          case 0x10000:   /*  Interrupt mask register 0:  */
102                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
103                          d->imask0 = idata;                          d->imask0 = idata;
# Line 80  DEVICE_ACCESS(sgi_ip30) Line 105  DEVICE_ACCESS(sgi_ip30)
105                          odata = d->imask0;                          odata = d->imask0;
106                  }                  }
107                  break;                  break;
108    
109          case 0x10018:          case 0x10018:
110                  /*                  /*
111                   *  If this is not implemented, the IP30 PROM complains during                   *  If this is not implemented, the IP30 PROM complains during
# Line 95  DEVICE_ACCESS(sgi_ip30) Line 121  DEVICE_ACCESS(sgi_ip30)
121                          odata = d->reg_0x10018;                          odata = d->reg_0x10018;
122                  }                  }
123                  break;                  break;
124    
125          case 0x10020:   /*  Set ISR, according to Linux/IP30  */          case 0x10020:   /*  Set ISR, according to Linux/IP30  */
126                  d->isr = idata;                  d->isr = idata;
127                  /*  Recalculate CPU interrupt assertions:  */                  /*  Recalculate CPU interrupt assertions:  */
128                  cpu_interrupt(cpu, 8);  fatal("IP30 legacy interrupt rewrite: TODO\n");
129    abort();
130    //              cpu_interrupt(cpu, 8);
131                  break;                  break;
132    
133          case 0x10028:   /*  Clear ISR, according to Linux/IP30  */          case 0x10028:   /*  Clear ISR, according to Linux/IP30  */
134                  d->isr &= ~idata;                  d->isr &= ~idata;
135                  /*  Recalculate CPU interrupt assertions:  */                  /*  Recalculate CPU interrupt assertions:  */
136                  cpu_interrupt(cpu, 8);  fatal("IP30 legacy interrupt rewrite: TODO\n");
137    abort();
138    //              cpu_interrupt(cpu, 8);
139                  break;                  break;
140    
141          case 0x10030:   /*  Interrupt Status Register  */          case 0x10030:   /*  Interrupt Status Register  */
142                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
143                          /*  Clear-on-write  (TODO: is this correct?)  */                          /*  Clear-on-write  (TODO: is this correct?)  */
144                          d->isr &= ~idata;                          d->isr &= ~idata;
145                          /*  Recalculate CPU interrupt assertions:  */                          /*  Recalculate CPU interrupt assertions:  */
146                          cpu_interrupt(cpu, 8);  fatal("IP30 legacy interrupt rewrite: TODO\n");
147    abort();
148    //                      cpu_interrupt(cpu, 8);
149                  } else {                  } else {
150                          odata = d->isr;                          odata = d->isr;
151                  }                  }
152                  break;                  break;
153    
154          case 0x20000:          case 0x20000:
155                  /*  A counter  */                  /*  A counter  */
156                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
# Line 123  DEVICE_ACCESS(sgi_ip30) Line 159  DEVICE_ACCESS(sgi_ip30)
159                          odata = d->reg_0x20000;                          odata = d->reg_0x20000;
160                  }                  }
161                  break;                  break;
162    
163          case 0x30000:          case 0x30000:
164                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
165                          d->reg_0x30000 = idata;                          d->reg_0x30000 = idata;
# Line 130  DEVICE_ACCESS(sgi_ip30) Line 167  DEVICE_ACCESS(sgi_ip30)
167                          odata = d->reg_0x30000;                          odata = d->reg_0x30000;
168                  }                  }
169                  break;                  break;
170    
171          default:          default:
172                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
173                          debug("[ sgi_ip30: unimplemented write to address "                          debug("[ sgi_ip30: unimplemented write to address "
# Line 148  DEVICE_ACCESS(sgi_ip30) Line 186  DEVICE_ACCESS(sgi_ip30)
186  }  }
187    
188    
 /*  
  *  dev_sgi_ip30_2_access():  
  */  
189  DEVICE_ACCESS(sgi_ip30_2)  DEVICE_ACCESS(sgi_ip30_2)
190  {  {
191          struct sgi_ip30_data *d = (struct sgi_ip30_data *) extra;          struct sgi_ip30_data *d = extra;
192          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
193    
194          idata = memory_readmax64(cpu, data, len);          idata = memory_readmax64(cpu, data, len);
# Line 201  DEVICE_ACCESS(sgi_ip30_2) Line 236  DEVICE_ACCESS(sgi_ip30_2)
236  }  }
237    
238    
 /*  
  *  dev_sgi_ip30_3_access():  
  */  
239  DEVICE_ACCESS(sgi_ip30_3)  DEVICE_ACCESS(sgi_ip30_3)
240  {  {
241          struct sgi_ip30_data *d = (struct sgi_ip30_data *) extra;          struct sgi_ip30_data *d = extra;
242          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
243    
244          idata = memory_readmax64(cpu, data, len);          idata = memory_readmax64(cpu, data, len);
245    
246          switch (relative_addr) {          switch (relative_addr) {
247    
248          case 0xb4:          case 0xb4:
249                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
250                          debug("[ sgi_ip30_3: unimplemented write to "                          debug("[ sgi_ip30_3: unimplemented write to "
# Line 221  DEVICE_ACCESS(sgi_ip30_3) Line 254  DEVICE_ACCESS(sgi_ip30_3)
254                          odata = 2;      /*  should be 2, or Irix loops  */                          odata = 2;      /*  should be 2, or Irix loops  */
255                  }                  }
256                  break;                  break;
257    
258          case 0x00104:          case 0x00104:
259                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
260                          debug("[ sgi_ip30_3: unimplemented write to address "                          debug("[ sgi_ip30_3: unimplemented write to address "
# Line 231  DEVICE_ACCESS(sgi_ip30_3) Line 265  DEVICE_ACCESS(sgi_ip30_3)
265                                              complains  */                                              complains  */
266                  }                  }
267                  break;                  break;
268    
269          case 0x00284:          case 0x00284:
270                  /*                  /*
271                   *  If this is not implemented, the IP30 PROM complains during                   *  If this is not implemented, the IP30 PROM complains during
# Line 246  DEVICE_ACCESS(sgi_ip30_3) Line 281  DEVICE_ACCESS(sgi_ip30_3)
281                          odata = d->reg_0x00284;                          odata = d->reg_0x00284;
282                  }                  }
283                  break;                  break;
284    
285          default:          default:
286                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
287                          debug("[ sgi_ip30_3: unimplemented write to address "                          debug("[ sgi_ip30_3: unimplemented write to address "
# Line 264  DEVICE_ACCESS(sgi_ip30_3) Line 300  DEVICE_ACCESS(sgi_ip30_3)
300  }  }
301    
302    
 /*  
  *  dev_sgi_ip30_4_access():  
  */  
303  DEVICE_ACCESS(sgi_ip30_4)  DEVICE_ACCESS(sgi_ip30_4)
304  {  {
305          struct sgi_ip30_data *d = (struct sgi_ip30_data *) extra;          struct sgi_ip30_data *d = extra;
306          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
307    
308          idata = memory_readmax64(cpu, data, len);          idata = memory_readmax64(cpu, data, len);
309    
310          switch (relative_addr) {          switch (relative_addr) {
311    
312          case 0x000b0:          case 0x000b0:
313                  /*                  /*
314                   *  If this is not implemented, the IP30 PROM complains during                   *  If this is not implemented, the IP30 PROM complains during
# Line 290  DEVICE_ACCESS(sgi_ip30_4) Line 324  DEVICE_ACCESS(sgi_ip30_4)
324                          odata = d->reg_0x000b0;                          odata = d->reg_0x000b0;
325                  }                  }
326                  break;                  break;
327    
328          default:          default:
329                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
330                          debug("[ sgi_ip30_4: unimplemented write to address"                          debug("[ sgi_ip30_4: unimplemented write to address"
# Line 308  DEVICE_ACCESS(sgi_ip30_4) Line 343  DEVICE_ACCESS(sgi_ip30_4)
343  }  }
344    
345    
 /*  
  *  dev_sgi_ip30_5_access():  
  */  
346  DEVICE_ACCESS(sgi_ip30_5)  DEVICE_ACCESS(sgi_ip30_5)
347  {  {
348          struct sgi_ip30_data *d = (struct sgi_ip30_data *) extra;          struct sgi_ip30_data *d = extra;
349          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
350    
351          idata = memory_readmax64(cpu, data, len);          idata = memory_readmax64(cpu, data, len);
352    
353          switch (relative_addr) {          switch (relative_addr) {
354    
355          case 0x00000:          case 0x00000:
356                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
357                          d->reg_0x00000 = idata;                          d->reg_0x00000 = idata;
# Line 326  DEVICE_ACCESS(sgi_ip30_5) Line 359  DEVICE_ACCESS(sgi_ip30_5)
359                          odata = d->reg_0x00000;                          odata = d->reg_0x00000;
360                  }                  }
361                  break;                  break;
362    
363          default:          default:
364                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
365                          debug("[ sgi_ip30_5: unimplemented write to address "                          debug("[ sgi_ip30_5: unimplemented write to address "
# Line 344  DEVICE_ACCESS(sgi_ip30_5) Line 378  DEVICE_ACCESS(sgi_ip30_5)
378  }  }
379    
380    
381  /*  DEVINIT(sgi_ip30)
  *  dev_sgi_ip30_init():  
  */  
 struct sgi_ip30_data *dev_sgi_ip30_init(struct machine *machine,  
         struct memory *mem, uint64_t baseaddr)  
382  {  {
383          struct sgi_ip30_data *d = malloc(sizeof(struct sgi_ip30_data));          struct sgi_ip30_data *d;
384          if (d == NULL) {  
385                  fprintf(stderr, "out of memory\n");          CHECK_ALLOCATION(d = malloc(sizeof(struct sgi_ip30_data)));
                 exit(1);  
         }  
386          memset(d, 0, sizeof(struct sgi_ip30_data));          memset(d, 0, sizeof(struct sgi_ip30_data));
387    
388          memory_device_register(mem, "sgi_ip30_1", baseaddr,          memory_device_register(devinit->machine->memory, "sgi_ip30_1",
389              DEV_SGI_IP30_LENGTH, dev_sgi_ip30_access, (void *)d,              devinit->addr, DEV_SGI_IP30_LENGTH, dev_sgi_ip30_access, (void *)d,
390              DM_DEFAULT, NULL);              DM_DEFAULT, NULL);
391          memory_device_register(mem, "sgi_ip30_2", 0x10000000,          memory_device_register(devinit->machine->memory, "sgi_ip30_2",
392              0x10000, dev_sgi_ip30_2_access, (void *)d, DM_DEFAULT, NULL);              0x10000000, 0x10000, dev_sgi_ip30_2_access, (void *)d, DM_DEFAULT,
393          memory_device_register(mem, "sgi_ip30_3", 0x1f000000,              NULL);
394              0x10000, dev_sgi_ip30_3_access, (void *)d, DM_DEFAULT, NULL);          memory_device_register(devinit->machine->memory, "sgi_ip30_3",
395          memory_device_register(mem, "sgi_ip30_4", 0x1f600000,              0x1f000000, 0x10000, dev_sgi_ip30_3_access, (void *)d, DM_DEFAULT,
396              0x10000, dev_sgi_ip30_4_access, (void *)d, DM_DEFAULT, NULL);              NULL);
397          memory_device_register(mem, "sgi_ip30_5", 0x1f6c0000,          memory_device_register(devinit->machine->memory, "sgi_ip30_4",
398              0x10000, dev_sgi_ip30_5_access, (void *)d, DM_DEFAULT, NULL);              0x1f600000, 0x10000, dev_sgi_ip30_4_access, (void *)d, DM_DEFAULT,
399                NULL);
400            memory_device_register(devinit->machine->memory, "sgi_ip30_5",
401                0x1f6c0000, 0x10000, dev_sgi_ip30_5_access, (void *)d, DM_DEFAULT,
402                NULL);
403    
404          machine_add_tickfunction(machine, dev_sgi_ip30_tick, d, 16, 0.0);          machine_add_tickfunction(devinit->machine,
405                dev_sgi_ip30_tick, d, 16);
406    
407          return d;          return 1;
408  }  }
409    

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

  ViewVC Help
Powered by ViewVC 1.1.26