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

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

revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2005  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_ip19.c,v 1.13 2005/02/25 06:14:30 debug Exp $   *  $Id: dev_sgi_ip19.c,v 1.19 2007/06/15 19:57:34 debug Exp $
29   *     *  
30   *  SGI IP19 (and IP25) stuff.  The stuff in here is mostly guesswork.   *  COMMENT: SGI IP19 (and IP25) stuff
31     *
32     *  NOTE/TODO: The stuff in here is mostly guesswork.
33   */   */
34    
35  #include <stdio.h>  #include <stdio.h>
# Line 48  struct sgi_ip19_data { Line 50  struct sgi_ip19_data {
50  };  };
51    
52    
53  /*  DEVICE_ACCESS(sgi_ip19)
  *  dev_sgi_ip19_access():  
  */  
 int dev_sgi_ip19_access(struct cpu *cpu, struct memory *mem,  
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
54  {  {
55          struct sgi_ip19_data *d = (struct sgi_ip19_data *) extra;          struct sgi_ip19_data *d = extra;
56          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
57          int regnr;          int regnr;
58    
59          idata = memory_readmax64(cpu, data, len);          if (writeflag == MEM_WRITE)
60                    idata = memory_readmax64(cpu, data, len);
61    
62          regnr = relative_addr / sizeof(uint32_t);          regnr = relative_addr / sizeof(uint32_t);
63    
64          switch (relative_addr) {          switch (relative_addr) {
65    
66          case 0x08:      /*  cpu id  */          case 0x08:      /*  cpu id  */
67                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
68                          debug("[ sgi_ip19: unimplemented write to address "                          debug("[ sgi_ip19: unimplemented write to address "
# Line 72  int dev_sgi_ip19_access(struct cpu *cpu, Line 72  int dev_sgi_ip19_access(struct cpu *cpu,
72                          odata = cpu->cpu_id;    /*  ?  TODO  */                          odata = cpu->cpu_id;    /*  ?  TODO  */
73                  }                  }
74                  break;                  break;
75    
76          case 0x200:     /*  cpu available mask?  */          case 0x200:     /*  cpu available mask?  */
77                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
78                          debug("[ sgi_ip19: unimplemented write to address "                          debug("[ sgi_ip19: unimplemented write to address "
# Line 82  int dev_sgi_ip19_access(struct cpu *cpu, Line 83  int dev_sgi_ip19_access(struct cpu *cpu,
83                          odata = ((1 << cpu->machine->ncpus) - 1) << 16;                          odata = ((1 << cpu->machine->ncpus) - 1) << 16;
84                  }                  }
85                  break;                  break;
86    
87          case 0x20000:   /*  cycle counter or clock  */          case 0x20000:   /*  cycle counter or clock  */
88                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
89                          debug("[ sgi_ip19: unimplemented write to address "                          debug("[ sgi_ip19: unimplemented write to address "
# Line 93  int dev_sgi_ip19_access(struct cpu *cpu, Line 95  int dev_sgi_ip19_access(struct cpu *cpu,
95                  }                  }
96    
97                  break;                  break;
98    
99          default:          default:
100                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
101                          debug("[ sgi_ip19: unimplemented write to address "                          debug("[ sgi_ip19: unimplemented write to address "
# Line 111  int dev_sgi_ip19_access(struct cpu *cpu, Line 114  int dev_sgi_ip19_access(struct cpu *cpu,
114  }  }
115    
116    
117  /*  DEVINIT(sgi_ip19)
  *  devinit__sgi_ip19():  
  */  
 int devinit_sgi_ip19(struct devinit *devinit)  
118  {  {
119          struct sgi_ip19_data *d = malloc(sizeof(struct sgi_ip19_data));          struct sgi_ip19_data *d;
120          if (d == NULL) {  
121                  fprintf(stderr, "out of memory\n");          CHECK_ALLOCATION(d = malloc(sizeof(struct sgi_ip19_data)));
                 exit(1);  
         }  
122          memset(d, 0, sizeof(struct sgi_ip19_data));          memset(d, 0, sizeof(struct sgi_ip19_data));
123    
124          memory_device_register(devinit->machine->memory, devinit->name,          memory_device_register(devinit->machine->memory, devinit->name,
125              devinit->addr, DEV_SGI_IP19_LENGTH,              devinit->addr, DEV_SGI_IP19_LENGTH,
126              dev_sgi_ip19_access, (void *)d, MEM_DEFAULT, NULL);              dev_sgi_ip19_access, (void *)d, DM_DEFAULT, NULL);
127    
128          return 1;          return 1;
129  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26