]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/platform/drvAppleIntelClassicPIC/AppleIntelClassicPIC.h
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
29 #ifndef _IOKIT_APPLEINTELCLASSICPIC_H
30 #define _IOKIT_APPLEINTELCLASSICPIC_H
32 #include <IOKit/IOInterrupts.h>
33 #include <IOKit/IOInterruptController.h>
35 #define kClockIRQ 0 // FIXME for SMP systems.
37 #define kPIC1BasePort 0x20
38 #define kPIC2BasePort 0xa0
40 #define kPIC1TriggerTypePort 0x4d0
41 #define kPIC2TriggerTypePort 0x4d1
43 #define kPICCmdPortOffset 0
44 #define kPICDataPortOffset 1
46 #define kEOICommand 0x20
48 #define kPICSlaveID 2 // Slave ID for second PIC
50 #define kNumVectors 16
52 #define IS_SLAVE_VECTOR(x) ((x) & 8)
56 #define kPIC_ICW1(x) ((x) + kPICCmdPortOffset)
57 #define kPIC_ICW1_MBO 0x10 // must be one
58 #define kPIC_ICW1_LTIM 0x08 // level/edge triggered mode
59 #define kPIC_ICW1_ADI 0x04 // 4/8 byte call address interval
60 #define kPIC_ICW1_SNGL 0x02 // single/cascade mode
61 #define kPIC_ICW1_IC4 0x01 // ICW4 needed/not needed
63 // ICW2 - Interrupt vector address (bits 7 - 3).
65 #define kPIC_ICW2(x) ((x) + kPICDataPortOffset)
67 // ICW3 - Slave device.
69 #define kPIC_ICW3(x) ((x) + kPICDataPortOffset)
73 #define kPIC_ICW4(x) ((x) + kPICDataPortOffset)
74 #define kPIC_ICW4_SFNM 0x10 // special fully nested mode
75 #define kPIC_ICW4_BUF 0x08 // buffered mode
76 #define kPIC_ICW4_MS 0x04 // master/slave
77 #define kPIC_ICW4_AEOI 0x02 // automatic end of interrupt mode
78 #define kPIC_ICW4_uPM 0x01 // 8088 (vs. 8085) operation
80 // OCW1 - Interrupt mask.
82 #define kPIC_OCW1(x) ((x) + kPICDataPortOffset)
84 // OCW2 - Bit 4 must be zero.
86 #define kPIC_OCW2(x) ((x) + kPICCmdPortOffset)
87 #define kPIC_OCW2_R 0x80 // rotation
88 #define kPIC_OCW2_SL 0x40 // specific
89 #define kPIC_OCW2_EOI 0x20
90 #define kPIC_OCW2_LEVEL(x) ((x) & 0x07)
92 // OCW3 - Bit 4 must be zero.
94 #define kPIC_OCW3(x) ((x) + kPICCmdPortOffset)
95 #define kPIC_OCW3_ESMM 0x40 // special mask mode
96 #define kPIC_OCW3_SMM 0x20
97 #define kPIC_OCW3_MBO 0x08 // must be one
98 #define kPIC_OCW3_P 0x04 // poll
99 #define kPIC_OCW3_RR 0x02
100 #define kPIC_OCW3_RIS 0x01
103 class AppleIntelClassicPIC
: public IOInterruptController
105 OSDeclareDefaultStructors( AppleIntelClassicPIC
);
108 volatile UInt16 maskInterrupts
; /* Which interrupts are masked out */
109 UInt16 triggerTypes
; /* Interrupt trigger type mask */
111 inline int getTriggerType(long irq
)
113 return ( triggerTypes
& (1 << irq
) ) ?
114 kIOInterruptTypeLevel
: kIOInterruptTypeEdge
;
117 inline void updateMask(long irq
)
119 if ( IS_SLAVE_VECTOR(irq
) )
120 outb( kPIC_OCW1(kPIC2BasePort
), maskInterrupts
>> 8 );
122 outb( kPIC_OCW1(kPIC1BasePort
), maskInterrupts
& 0xff );
125 inline void disableInterrupt(long irq
)
127 maskInterrupts
|= (1 << irq
);
131 inline void enableInterrupt(long irq
)
133 maskInterrupts
&= ~(1 << irq
);
137 inline void ackInterrupt(long irq
)
139 if ( IS_SLAVE_VECTOR(irq
) )
140 outb( kPIC_OCW2(kPIC2BasePort
), kEOICommand
);
141 outb( kPIC_OCW2(kPIC1BasePort
), kEOICommand
);
144 virtual void initializePIC(UInt16 port
,
145 UInt8 icw1
, UInt8 icw2
,
146 UInt8 icw3
, UInt8 icw4
);
149 virtual bool start(IOService
* provider
);
150 virtual void free(void);
152 // Methods that must be implemented by simplifed interrupt controllers.
154 virtual int getVectorType(long vectorNumber
, IOInterruptVector
* vector
);
155 virtual IOInterruptAction
getInterruptHandlerAddress(void);
156 virtual IOReturn
handleInterrupt(void * refCon
, IOService
* nub
, int source
);
157 virtual bool vectorCanBeShared(long vectorNumber
, IOInterruptVector
* vector
);
158 virtual void initVector(long vectorNumber
, IOInterruptVector
* vector
);
159 virtual void disableVectorHard(long vectorNumber
, IOInterruptVector
* vector
);
160 virtual void enableVector(long vectorNumber
, IOInterruptVector
* vector
);
163 #endif /* ! _IOKIT_APPLEINTELCLASSICPIC_H */