2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 a1
= inb(PIC1_DATA
); // save masks
29 outb(PIC1_COMMAND
,ICW1_INIT
+ICW1_ICW4
); // starts the initialization sequence
30 outb(PIC2_COMMAND
,ICW1_INIT
+ICW1_ICW4
);
31 outb(PIC1_DATA
,offset1
); // define the PIC vectors
32 outb(PIC2_DATA
,offset2
);
33 outb(PIC1_DATA
,4); // continue initialization sequence
35 outb(PIC1_DATA
,ICW4_8086
);
36 outb(PIC2_DATA
,ICW4_8086
);
38 outb(PIC1_DATA
,a1
); // restore saved masks.
49 unsigned int pic_getmask(int irq
) {
50 unsigned int mask
= inb(PIC1_DATA
);
51 mask
|= inb(PIC2_DATA
)<<8;
58 * @param mask IRQ mask
60 void pic_setmask(int irq
,unsigned int mask
) {
62 outb(PIC2_DATA
,mask
>>8);
69 void pic_eoi(int irq
) {
70 if (irq
>=8) outb(PIC2_COMMAND
,PIC_EOI
);
71 outb(PIC1_COMMAND
,PIC_EOI
);
75 * Sets interval of PIT
76 * @param interval Interval
77 * @param channel Channel
78 * @return 0=Success; -1=Failure
80 int pic_pit_setinterval(int channel
,unsigned int interval
) {
81 unsigned int val
= PIT_FREQ
*interval
/1000;
83 outb(PIT_CHANNELS
+channel
,val
);
84 outb(PIT_CHANNELS
+channel
,(val
>>8));