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

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

revision 28 by dpavlin, Mon Oct 8 16:20:26 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-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_8259.c,v 1.25 2006/07/21 16:55:41 debug Exp $   *  $Id: dev_8259.c,v 1.30 2007/06/15 18:13:04 debug Exp $
29   *     *  
30   *  8259 Programmable Interrupt Controller.   *  COMMENT: Intel 8259 Programmable Interrupt Controller
31   *   *
32   *  See the following URL for more details:   *  See the following URL for more details:
33   *      http://www.nondot.org/sabre/os/files/MiscHW/8259pic.txt   *      http://www.nondot.org/sabre/os/files/MiscHW/8259pic.txt
# Line 53  Line 53 
53    
54  DEVICE_ACCESS(8259)  DEVICE_ACCESS(8259)
55  {  {
56          struct pic8259_data *d = (struct pic8259_data *) extra;          struct pic8259_data *d = extra;
57          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
58          int i;          int i;
59    
# Line 110  DEVICE_ACCESS(8259) Line 110  DEVICE_ACCESS(8259)
110                                  d->isr = 0;                                  d->isr = 0;
111                                  /*  Recalculate interrupt assertions,                                  /*  Recalculate interrupt assertions,
112                                      if necessary:  */                                      if necessary:  */
113                                  if ((old_irr & ~d->ier) != (d->irr & ~d->ier))                                  if ((old_irr & ~d->ier) != (d->irr & ~d->ier)) {
114                                          cpu_interrupt(cpu, d->irq_nr);                                          if (d->irr & ~d->ier)
115                                                    INTERRUPT_ASSERT(d->irq);
116                                            else
117                                                    INTERRUPT_DEASSERT(d->irq);
118                                    }
119                          } else if ((idata >= 0x21 && idata <= 0x27) ||                          } else if ((idata >= 0x21 && idata <= 0x27) ||
120                              (idata >= 0x60 && idata <= 0x67) ||                              (idata >= 0x60 && idata <= 0x67) ||
121                              (idata >= 0xe0 && idata <= 0xe7)) {                              (idata >= 0xe0 && idata <= 0xe7)) {
# Line 120  DEVICE_ACCESS(8259) Line 124  DEVICE_ACCESS(8259)
124                                  d->irr &= ~(1 << (idata & 7));                                  d->irr &= ~(1 << (idata & 7));
125                                  d->isr &= ~(1 << (idata & 7));                                  d->isr &= ~(1 << (idata & 7));
126                                  /*  Recalc. int assertions, if necessary:  */                                  /*  Recalc. int assertions, if necessary:  */
127                                  if ((old_irr & ~d->ier) != (d->irr & ~d->ier))                                  if ((old_irr & ~d->ier) != (d->irr & ~d->ier)) {
128                                          cpu_interrupt(cpu, d->irq_nr);                                          if (d->irr & ~d->ier)
129                                                    INTERRUPT_ASSERT(d->irq);
130                                            else
131                                                    INTERRUPT_DEASSERT(d->irq);
132                                    }
133                          } else if (idata == 0x68) {                          } else if (idata == 0x68) {
134                                  /*  Set Special Mask Mode  */                                  /*  Set Special Mask Mode  */
135                                  /*  TODO  */                                  /*  TODO  */
# Line 208  DEVICE_ACCESS(8259) Line 216  DEVICE_ACCESS(8259)
216    
217                          /*  Recalculate interrupt assertions,                          /*  Recalculate interrupt assertions,
218                              if necessary:  */                              if necessary:  */
219                          if ((d->irr & ~old_ier) != (d->irr & ~d->ier))                          if ((d->irr & ~old_ier) != (d->irr & ~d->ier)) {
220                                  cpu_interrupt(cpu, d->irq_nr);                                  if (d->irr & ~d->ier)
221                                            INTERRUPT_ASSERT(d->irq);
222                                    else
223                                            INTERRUPT_DEASSERT(d->irq);
224                            }
225                  } else {                  } else {
226                          odata = d->ier;                          odata = d->ier;
227                  }                  }
# Line 248  DEVICE_ACCESS(8259) Line 260  DEVICE_ACCESS(8259)
260   */   */
261  DEVINIT(8259)  DEVINIT(8259)
262  {  {
263          struct pic8259_data *d = malloc(sizeof(struct pic8259_data));          struct pic8259_data *d;
264          char *name2;          char *name2;
265          size_t nlen = strlen(devinit->name) + 20;          size_t nlen = strlen(devinit->name) + 20;
266    
267          if (d == NULL) {          CHECK_ALLOCATION(d = malloc(sizeof(struct pic8259_data)));
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
268          memset(d, 0, sizeof(struct pic8259_data));          memset(d, 0, sizeof(struct pic8259_data));
         d->irq_nr = devinit->irq_nr;  
269    
270          name2 = malloc(nlen);          INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
271    
272            CHECK_ALLOCATION(name2 = malloc(nlen));
273          snprintf(name2, nlen, "%s", devinit->name);          snprintf(name2, nlen, "%s", devinit->name);
274          if ((devinit->addr & 0xfff) == 0xa0) {          if ((devinit->addr & 0xfff) == 0xa0) {
275                  strlcat(name2, " [secondary]", nlen);                  strlcat(name2, " [secondary]", nlen);

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

  ViewVC Help
Powered by ViewVC 1.1.26