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

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

revision 18 by dpavlin, Mon Oct 8 16:19:11 2007 UTC revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_bebox.c,v 1.4 2005/10/26 14:37:03 debug Exp $   *  $Id: dev_bebox.c,v 1.7 2005/11/16 21:15:18 debug Exp $
29   *   *
30   *  Emulation of BeBox motherboard registers. See the following URL for more   *  Emulation of BeBox motherboard registers. See the following URL for more
31   *  information:   *  information:
# Line 39  Line 39 
39    
40  #include "cpu.h"  #include "cpu.h"
41  #include "device.h"  #include "device.h"
42    #include "devices.h"
43  #include "machine.h"  #include "machine.h"
44  #include "memory.h"  #include "memory.h"
45  #include "misc.h"  #include "misc.h"
46    
47    
48  struct bebox_data {  /*
49          /*  The 5 motherboard registers:  */   *  check_cpu_masks():
50          uint32_t        cpu0_intmask;   *
51          uint32_t        cpu1_intmask;   *  BeBox interrupt enable bits are not allowed to be present in
52          uint32_t        int_source;   *  both CPUs at the same time.
53          uint32_t        xpi;   */
54          uint32_t        resets;  static void check_cpu_masks(struct cpu *cpu, struct bebox_data *d)
55  };  {
56            d->cpu0_int_mask &= 0x7fffffff;
57            d->cpu1_int_mask &= 0x7fffffff;
58            if ((d->cpu0_int_mask | d->cpu1_int_mask) !=
59                (d->cpu0_int_mask ^ d->cpu1_int_mask))
60                    fatal("check_cpu_masks(): BeBox cpu int masks"
61                        " collide!\n");
62    }
63    
64    
65  /*  /*
# Line 68  int dev_bebox_access(struct cpu *cpu, st Line 76  int dev_bebox_access(struct cpu *cpu, st
76                  idata = memory_readmax64(cpu, data, len);                  idata = memory_readmax64(cpu, data, len);
77    
78          switch (relative_addr) {          switch (relative_addr) {
79    
80            case 0x0f0:
81                    if (writeflag == MEM_READ)
82                            odata = d->cpu0_int_mask;
83                    else {
84                            if (idata & 0x80000000)
85                                    d->cpu0_int_mask |= idata;
86                            else
87                                    d->cpu0_int_mask &= ~idata;
88                            check_cpu_masks(cpu, d);
89                    }
90                    break;
91    
92            case 0x1f0:
93                    if (writeflag == MEM_READ)
94                            odata = d->cpu1_int_mask;
95                    else {
96                            if (idata & 0x80000000)
97                                    d->cpu1_int_mask |= idata;
98                            else
99                                    d->cpu1_int_mask &= ~idata;
100                            check_cpu_masks(cpu, d);
101                    }
102                    break;
103    
104            case 0x2f0:
105                    if (writeflag == MEM_READ)
106                            odata = d->int_status;
107                    else {
108                            if (idata & 0x80000000)
109                                    d->int_status |= idata;
110                            else
111                                    d->int_status &= ~idata;
112                            d->int_status &= 0x7fffffff;
113                    }
114                    break;
115    
116          case 0x3f0:          case 0x3f0:
117                  if (writeflag == MEM_READ) {                  if (writeflag == MEM_READ) {
118                          odata = d->xpi;                          odata = d->xpi;
# Line 113  int devinit_bebox(struct devinit *devini Line 158  int devinit_bebox(struct devinit *devini
158          memset(d, 0, sizeof(struct bebox_data));          memset(d, 0, sizeof(struct bebox_data));
159    
160          memory_device_register(devinit->machine->memory, devinit->name,          memory_device_register(devinit->machine->memory, devinit->name,
161              0x7ffff000, 0x500, dev_bebox_access, d, MEM_DEFAULT, NULL);              0x7ffff000, 0x500, dev_bebox_access, d, DM_DEFAULT, NULL);
162    
163            devinit->return_ptr = d;
164    
165          return 1;          return 1;
166  }  }

Legend:
Removed from v.18  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26