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

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

revision 29 by dpavlin, Mon Oct 8 16:19:56 2007 UTC revision 30 by dpavlin, Mon Oct 8 16:20:40 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: dev_algor.c,v 1.2 2006/03/31 23:20:25 debug Exp $   *  $Id: dev_algor.c,v 1.3 2006/08/14 17:45:47 debug Exp $
29   *   *
30   *  Algor misc. stuff.   *  Algor misc. stuff.
31   *   *
32   *  TODO: This is hardcoded for P5064 right now. Generalize it to P40xx etc.   *  TODO: This is hardcoded for P5064 right now. Generalize it to P40xx etc.
33     *
34     *  CPU irq 2 = ISA, 3 = PCI, 4 = Local.
35   */   */
36    
37  #include <stdio.h>  #include <stdio.h>
# Line 59  DEVICE_ACCESS(algor) Line 61  DEVICE_ACCESS(algor)
61    
62          switch (relative_addr) {          switch (relative_addr) {
63    
64            case P5064_LED1 + 0x0:
65            case P5064_LED1 + 0x4:
66            case P5064_LED1 + 0x8:
67            case P5064_LED1 + 0xc:
68                    break;
69    
70          case P5064_LOCINT:          case P5064_LOCINT:
71                  {                  /*
72                     *  TODO: See how ISAINT is implemented.
73                     *
74                     *  Implemented so far: COM1 only.
75                     */
76                    n = "P5064_LOCINT";
77                    if (writeflag == MEM_READ) {
78                            /*  Ugly hack for NetBSD startup.  TODO: fix  */
79                          static int x = 0;                          static int x = 0;
80                          x ++;                          if (((++ x) & 0xffff) == 0)
                         odata = LOCINT_PCIBR;  
                         if ((x & 0xffff) == 0)  
81                                  odata |= LOCINT_RTC;                                  odata |= LOCINT_RTC;
82    
83                            if (cpu->machine->isa_pic_data.pic1->irr &
84                                ~cpu->machine->isa_pic_data.pic1->ier & 0x10)
85                                    odata |= LOCINT_COM1;
86                            if (cpu->machine->isa_pic_data.pic1->irr &
87                                ~cpu->machine->isa_pic_data.pic1->ier & 0x08)
88                                    odata |= LOCINT_COM2;
89    
90                            /*  Read => ack:  */
91                            cpu->machine->isa_pic_data.pic1->irr &= ~0x18;
92                            cpu_interrupt_ack(cpu, 4);
93                    } else {
94                            if (idata & LOCINT_COM1)
95                                    cpu->machine->isa_pic_data.pic1->ier &= ~0x10;
96                            else
97                                    cpu->machine->isa_pic_data.pic1->ier |= 0x10;
98                            if (idata & LOCINT_COM2)
99                                    cpu->machine->isa_pic_data.pic1->ier &= ~0x08;
100                            else
101                                    cpu->machine->isa_pic_data.pic1->ier |= 0x08;
102                    }
103                    break;
104    
105            case P5064_PANIC:
106                    n = "P5064_PANIC";
107                    if (writeflag == MEM_READ)
108                            odata = 0;
109                    break;
110    
111            case P5064_PCIINT:
112                    /*
113                     *  TODO: See how ISAINT is implemented.
114                     */
115                    n = "P5064_PCIINT";
116                    if (writeflag == MEM_READ) {
117                            odata = 0;
118                            cpu_interrupt_ack(cpu, 3);
119                  }                  }
120                  break;                  break;
121    
122            case P5064_ISAINT:
123                    /*
124                     *  ISA interrupts:
125                     *
126                     *      Bit:  IRQ Source:
127                     *      0     ISAINT_ISABR
128                     *      1     ISAINT_IDE0
129                     *      2     ISAINT_IDE1
130                     *
131                     *  NOTE/TODO: Ugly redirection to the ISA controller.
132                     */
133                    n = "P5064_ISAINT";
134                    if (writeflag == MEM_WRITE) {
135                            if (idata & ISAINT_IDE0)
136                                    cpu->machine->isa_pic_data.pic2->ier &= ~0x40;
137                            else
138                                    cpu->machine->isa_pic_data.pic2->ier |= 0x40;
139                            if (idata & ISAINT_IDE1)
140                                    cpu->machine->isa_pic_data.pic2->ier &= ~0x80;
141                            else
142                                    cpu->machine->isa_pic_data.pic2->ier |= 0x80;
143                            cpu->machine->isa_pic_data.pic1->ier &= ~0x04;
144                    } else {
145                            if (cpu->machine->isa_pic_data.pic2->irr &
146                                ~cpu->machine->isa_pic_data.pic2->ier & 0x40)
147                                    odata |= ISAINT_IDE0;
148                            if (cpu->machine->isa_pic_data.pic2->irr &
149                                ~cpu->machine->isa_pic_data.pic2->ier & 0x80)
150                                    odata |= ISAINT_IDE1;
151    
152                            /*  Read => ack:  */
153                            cpu->machine->isa_pic_data.pic2->irr &= ~0xc0;
154                            cpu_interrupt_ack(cpu, 2);
155                    }
156                    break;
157    
158            case P5064_KBDINT:
159                    /*
160                     *  TODO: See how ISAINT is implemented.
161                     */
162                    n = "P5064_KBDINT";
163                    if (writeflag == MEM_READ)
164                            odata = 0;
165                    break;
166    
167          default:if (writeflag == MEM_READ) {          default:if (writeflag == MEM_READ) {
168                          fatal("[ algor: read from 0x%x ]\n",                          fatal("[ algor: read from 0x%x ]\n",
169                              (int)relative_addr);                              (int)relative_addr);
# Line 80  DEVICE_ACCESS(algor) Line 175  DEVICE_ACCESS(algor)
175    
176          if (n != NULL) {          if (n != NULL) {
177                  if (writeflag == MEM_READ) {                  if (writeflag == MEM_READ) {
178                          debug("[ algor: read from %s ]\n", n);                          debug("[ algor: read from %s: 0x%"PRIx64" ]\n",
179                                n, (uint64_t) odata);
180                  } else {                  } else {
181                          debug("[ algor: write to %s: 0x%"PRIx64" ]\n",                          debug("[ algor: write to %s: 0x%"PRIx64" ]\n",
182                              n, (uint64_t) idata);                              n, (uint64_t) idata);

Legend:
Removed from v.29  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26