home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / bsd / 11916 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  5.0 KB

  1. Xref: sparky comp.unix.bsd:11916 comp.sys.ibm.pc.hardware:37378
  2. Newsgroups: comp.unix.bsd,comp.sys.ibm.pc.hardware
  3. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!paladin.american.edu!howland.reston.ans.net!usc!sdd.hp.com!caen!batcomputer!cornell!uw-beaver!cs.ubc.ca!newsserver.sfu.ca!sfu.ca!vanepp
  4. From: vanepp@fraser.sfu.ca (Peter Van Epp)
  5. Subject: Re: Programming the 8259 (and a possible 386bsd bug)
  6. Message-ID: <vanepp.728105387@sfu.ca>
  7. Sender: news@sfu.ca
  8. Organization: Simon Fraser University, Burnaby, B.C., Canada
  9. References: <1993Jan26.170934.5461@zip.eecs.umich.edu>
  10. Date: Wed, 27 Jan 1993 03:29:47 GMT
  11. Lines: 118
  12.  
  13. dmuntz@quip.eecs.umich.edu (Dan Muntz) writes:
  14.  
  15. >I'd like to know what people have found to be good (accurate/complete) sources
  16. >of information about programming the 8259 as it is used in 386/486 machines.
  17.  
  18. The chip data sheet while less than readable, and not necessarily complete 
  19. (nor accurate) at least gives the meaning of all the bits and registers
  20. and what they in theory do.
  21.  
  22. >In isa.c in 386bsd the following sequence is used to initialize the "lower"
  23. >8259:
  24.  
  25. From the data sheet on the 8259a:
  26.  
  27. >    /* initialize 8259's */
  28. >    outb(IO_ICU1, 0x11);            /* reset; program device, four bytes */
  29.  
  30. Icw1:  (address line is 0)
  31.  
  32. bits d7 - d5 Interrupt vector address (bits 7 - 3, bits 2 - 0 are set to the  
  33.             level of the interrupt) (0)
  34. bit  d4      1 (always)
  35. bit  d3      edge trigger mode (0), a 1 would be level trigger mode
  36. bit  d2         call interval of 8 (0), a 1 would be call interval of 4
  37.         but it is ignored in 8086 mode (which this is, see later)
  38. bit  d1      cascade mode (0), a 1 would be single mode (no icw3)
  39. bit  d0         Icw4 needed (1) no Icw4 needed would be 0. 
  40.  
  41. >    outb(IO_ICU1+1, NRSVIDT);       /* starting at this vector index */
  42.  
  43. Icw2:  (address line is one)
  44.  
  45. Interrupt vector address (the bits are probably not important).
  46.  
  47. >    outb(IO_ICU1+1, 1<<2);          /* slave on line 2 */
  48.  
  49. Icw3:  (address line is one)
  50.  
  51. bits d7 - d3  0 (always)
  52.  
  53. bits d2 - d0  binary address of slave id (2 in this case).
  54.  
  55. >    outb(IO_ICU1+1, 1);             /* 8086 mode */
  56.  
  57. Icw4:  (address line is 1)
  58.  
  59. bits d7 - d5  0 (always)
  60. bit d4        not fully special nested mode (0) 1 is fully special nested mode
  61. bit d3 - d2   0x non buffered mode 
  62.           10 buffered mode slave
  63.           11 buffered mode master
  64. bit d1        normal EOI (0) 1 auto EOI (EOI = End Of Interrupt)
  65. bit d0          8086 mode (1) 0 8080 mode (my first micro, the CPU chip was $350,
  66.             and 4k of static ram was $500, add wire wrap sockets,
  67.             ttl, an lh0026 MOS clock driver and 8 toggle switches
  68.             and voila heaven!).
  69.  
  70. This completes the initialization sequence, now for the interrupt masks.
  71.  
  72. >    outb(IO_ICU1+1, 0xff);        /* leave interrupts masked */
  73.  
  74. Ocw1: (address line is 1)
  75.  
  76. bits d7 - d0   corresponding interrupt is masked (1) or not masked (0)
  77.  
  78. >    outb(IO_ICU1, 2);        /* default to ISR on read */
  79.  
  80. Ocw2: (address line is 0)
  81.  
  82. bit  d7       non rotating priority (0), 1 is rotating priority
  83. bit  d6       no action (0), 1 is specific EOI (selected by bits 2 - 0)
  84. bit  d5          no action (0), 1 is reset highest active interrupt
  85. bits d4 - d3  0 (always)
  86. bit  d2 - d0  interrupt level to reset (level 2 in this case, but probably 
  87.         don't care?).
  88.  
  89. I expect that you are correct, the comment is wrong. When something needs
  90. doing, Ocw3 will get written to do whatever wants to be done (and then
  91. indeed, writing 3 not 2 will get you the ISR register). 
  92.  
  93. It is now sitting waiting for an OCW3 command whose format is
  94.  
  95. Ocw3: (address line is 0)
  96.  
  97. bit d7         don't care
  98. bit d6 - d5    00 no action
  99.            01 no action
  100.            10 read special mask          
  101.            11 set special mask
  102. bit d4           0 (always)
  103. bit d3         1 (always)
  104. bit d2         0 no action, 1 read code of highest int on next read. 
  105. bits d1 - d0   00 no action
  106.            01 no action
  107.            10 read IR reg on next read pulse (IR = Interrupt Request reg)
  108.             (bit map of incoming interrupts, not masked)
  109.            11 read IS reg on next rd pulse (IS = In Service reg) 
  110.             (shows the priority of the levels being serviced).
  111.  
  112. A quick grep for IO_ICU finds hits in icu.h, a look at that finds a bunch of
  113. inline assembler in macros, at least some of which deals with doing EOIs to
  114. interrupt controllers. I expect that you will find the missing Ocw3 hidden
  115. away in there somewhere.
  116.  
  117. >According to the meager amount of information I've found, the last line
  118. >should be outb(IO_ICU1, 3); to select ISR on read (or the comment should
  119. >say IRR instead of ISR).  From other points in the code, it appears that
  120. >ISR is expected.  If this line is wrong, the other 8259 is also being
  121. >initialized incorrectly.  Can anyone shed some light on this?
  122.  
  123. Hopefully the above helps some, if you need more info just ask and I'll
  124. see what else I can dig up (or maybe someone more knowledgable will comment),
  125. I seem to remember some comments on $%$#$%^ interrupt controllers in one
  126. of the early DDJ articles on BSD386 as well, so that may be another source
  127. of info (straight from the horse's mouth as it were!).
  128.  
  129. Peter Van Epp / Operations and Technical Support 
  130. Simon Fraser University, Burnaby, B.C. Canada
  131.