source: rtems/c/src/lib/libbsp/powerpc/mcp750/irq/i8259.c @ fcee56c0

4.104.114.84.95
Last change on this file since fcee56c0 was fcee56c0, checked in by Joel Sherrill <joel.sherrill@…>, on 07/01/99 at 23:39:13

Patch from Eric Valette <valette@…> to clean up the
previous submission.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1
2/*
3 *  This file contains the implementation of the function described in irq.h
4 *  related to Intel 8259 Programmable Interrupt controller.
5 *
6 *  Copyright (C) 1998, 1999 valette@crf.canon.fr
7 *
8 *  The license and distribution terms for this file may be
9 *  found in found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14 
15#include <bsp.h>
16#include <bsp/irq.h>
17
18/*-------------------------------------------------------------------------+
19| Cache for 1st and 2nd PIC IRQ line's status (enabled or disabled) register.
20+--------------------------------------------------------------------------*/
21/*
22 * lower byte is interrupt mask on the master PIC.
23 * while upper bits are interrupt on the slave PIC.
24 * This cache is initialized in ldseg.s
25 */
26volatile rtems_i8259_masks i8259s_cache;
27
28/*-------------------------------------------------------------------------+
29|         Function:  BSP_irq_disable_at_i8259s
30|      Description: Mask IRQ line in appropriate PIC chip.
31| Global Variables: i8259s_cache
32|        Arguments: vector_offset - number of IRQ line to mask.
33|          Returns: Nothing.
34+--------------------------------------------------------------------------*/
35int BSP_irq_disable_at_i8259s    (const rtems_irq_symbolic_name irqLine)
36{
37  unsigned short mask;
38  unsigned int  level;
39
40  if ( ((int)irqLine < BSP_ISA_IRQ_LOWEST_OFFSET) ||
41       ((int)irqLine > BSP_ISA_IRQ_MAX_OFFSET)
42       )
43    return 1;
44 
45  _CPU_ISR_Disable(level);
46 
47  mask = 1 << irqLine;
48  i8259s_cache |= mask;
49 
50  if (irqLine < 8)
51  {
52    outport_byte(PIC_MASTER_IMR_IO_PORT, i8259s_cache & 0xff);
53  }
54  else
55  {
56    outport_byte(PIC_SLAVE_IMR_IO_PORT, ((i8259s_cache & 0xff00) > 8));
57  }
58  _CPU_ISR_Enable (level);
59
60  return 0;
61}
62
63/*-------------------------------------------------------------------------+
64|         Function:  BSP_irq_enable_at_i8259s
65|      Description: Unmask IRQ line in appropriate PIC chip.
66| Global Variables: i8259s_cache
67|        Arguments: irqLine - number of IRQ line to mask.
68|          Returns: Nothing.
69+--------------------------------------------------------------------------*/
70int BSP_irq_enable_at_i8259s    (const rtems_irq_symbolic_name irqLine)
71{
72  unsigned short mask;
73  unsigned int  level;
74
75  if ( ((int)irqLine < BSP_ISA_IRQ_LOWEST_OFFSET) ||
76       ((int)irqLine > BSP_ISA_IRQ_MAX_OFFSET )
77       )
78    return 1;
79
80  _CPU_ISR_Disable(level);
81 
82  mask = ~(1 << irqLine);
83  i8259s_cache &= mask;
84 
85  if (irqLine < 8)
86  {
87    outport_byte(PIC_MASTER_IMR_IO_PORT, i8259s_cache & 0xff);
88  }
89  else
90  {
91    outport_byte(PIC_SLAVE_IMR_IO_PORT, ((i8259s_cache & 0xff00) > 8));
92  }
93  _CPU_ISR_Enable (level);
94
95  return 0;
96} /* mask_irq */
97
98int BSP_irq_enabled_at_i8259s           (const rtems_irq_symbolic_name irqLine)
99{
100  unsigned short mask;
101
102  if ( ((int)irqLine < BSP_ISA_IRQ_LOWEST_OFFSET) ||
103       ((int)irqLine > BSP_ISA_IRQ_MAX_OFFSET)
104     )
105    return 1;
106
107  mask = (1 << irqLine);
108  return  (~(i8259s_cache & mask));
109}
110 
111
112/*-------------------------------------------------------------------------+
113|         Function: BSP_irq_ack_at_i8259s
114|      Description: Signal generic End Of Interrupt (EOI) to appropriate PIC.
115| Global Variables: None.
116|        Arguments: irqLine - number of IRQ line to acknowledge.
117|          Returns: Nothing.
118+--------------------------------------------------------------------------*/
119int BSP_irq_ack_at_i8259s       (const rtems_irq_symbolic_name irqLine)
120{
121  if (irqLine >= 8) {
122   outport_byte(PIC_SLAVE_COMMAND_IO_PORT, PIC_EOI);
123  }
124  outport_byte(PIC_MASTER_COMMAND_IO_PORT, PIC_EOI);
125
126  return 0;
127
128} /* ackIRQ */
129
130void BSP_i8259s_init(void)
131{
132  /*
133   * init master 8259 interrupt controller
134   */
135  outport_byte(PIC_MASTER_COMMAND_IO_PORT, 0x11); /* Start init sequence */
136  outport_byte(PIC_MASTER_IMR_IO_PORT, 0x00);/* Vector base  = 0 */
137  outport_byte(PIC_MASTER_IMR_IO_PORT, 0x04);/* edge tiggered, Cascade (slave) on IRQ2 */
138  outport_byte(PIC_MASTER_IMR_IO_PORT, 0x01);/* Select 8086 mode */
139  outport_byte(PIC_MASTER_IMR_IO_PORT, 0xFB); /* Mask all except cascade */
140  /*
141   * init slave  interrupt controller
142   */
143  outport_byte(PIC_SLAVE_COMMAND_IO_PORT, 0x11); /* Start init sequence */
144  outport_byte(PIC_SLAVE_IMR_IO_PORT, 0x08);/* Vector base  = 8 */
145  outport_byte(PIC_SLAVE_IMR_IO_PORT, 0x02);/* edge triggered, Cascade (slave) on IRQ2 */
146  outport_byte(PIC_SLAVE_IMR_IO_PORT, 0x01); /* Select 8086 mode */
147  outport_byte(PIC_SLAVE_IMR_IO_PORT, 0xFF); /* Mask all */
148 
149  i8259s_cache = 0xFFFB;
150}
151
Note: See TracBrowser for help on using the repository browser.