POK(kernelpart)
Main Page
Data Structures
Files
File List
Globals
pic.c
Go to the documentation of this file.
1
/*
2
* POK header
3
*
4
* The following file is a part of the POK project. Any modification should
5
* made according to the POK licence. You CANNOT use this file or a part of
6
* this file is this part of a file for your own project
7
*
8
* For more information on the POK licence, please see our LICENCE FILE
9
*
10
* Please follow the coding guidelines described in doc/CODING_GUIDELINES
11
*
12
* Copyright (c) 2007-2009 POK team
13
*
14
* Created by julien on Thu Jan 15 23:34:13 2009
15
*/
16
17
18
#include <types.h>
19
#include <
errno.h
>
20
21
#include <
arch/x86/ioports.h
>
22
23
#include "
pic.h
"
24
25
int
pok_pic_init
()
26
{
27
outb
(
PIC_MASTER_BASE
,
PIC_MASTER_ICW1
);
28
outb
(
PIC_SLAVE_BASE
,
PIC_SLAVE_ICW1
);
29
30
outb
(
PIC_MASTER_BASE
+ 1,
PIC_MASTER_ICW2
);
31
outb
(
PIC_SLAVE_BASE
+ 1,
PIC_SLAVE_ICW2
);
32
33
outb
(
PIC_MASTER_BASE
+ 1,
PIC_MASTER_ICW3
);
34
outb
(
PIC_SLAVE_BASE
+ 1,
PIC_SLAVE_ICW3
);
35
36
outb
(
PIC_MASTER_BASE
+ 1,
PIC_MASTER_ICW4
);
37
outb
(
PIC_SLAVE_BASE
+ 1,
PIC_SLAVE_ICW4
);
38
39
/* Mask everything */
40
outb
(
PIC_MASTER_BASE
+ 1, 0xfb);
41
outb
(
PIC_SLAVE_BASE
+ 1, 0xff);
42
43
return
(
POK_ERRNO_OK
);
44
}
45
46
int
pok_pic_mask
(
uint8_t
irq)
47
{
48
uint8_t
mask;
49
50
if
(irq > 15)
51
{
52
return
(
POK_ERRNO_EINVAL
);
53
}
54
55
if
(irq < 8)
56
{
57
mask =
inb
(
PIC_MASTER_BASE
+ 1);
58
outb
(
PIC_MASTER_BASE
+ 1, mask | (1 << irq));
59
}
60
else
61
{
62
mask =
inb
(
PIC_SLAVE_BASE
+ 1);
63
outb
(
PIC_SLAVE_BASE
+ 1, mask | (1 << (irq - 8)));
64
}
65
66
return
(
POK_ERRNO_OK
);
67
}
68
69
int
pok_pic_unmask
(
uint8_t
irq)
70
{
71
uint8_t
mask;
72
73
if
(irq > 15)
74
return
(
POK_ERRNO_EINVAL
);
75
76
if
(irq < 8)
77
{
78
mask =
inb
(
PIC_MASTER_BASE
+ 1);
79
outb
(
PIC_MASTER_BASE
+ 1, mask & ~(1 << irq));
80
}
81
else
82
{
83
mask =
inb
(
PIC_SLAVE_BASE
+ 1);
84
outb
(
PIC_SLAVE_BASE
+ 1, mask & ~(1 << (irq - 8)));
85
}
86
87
return
(
POK_ERRNO_OK
);
88
}
89
90
void
pok_pic_eoi
(
uint8_t
irq)
91
{
92
if
(irq >= 8)
93
{
94
outb
(
PIC_SLAVE_BASE
, 0x20);
95
}
96
97
outb
(
PIC_MASTER_BASE
, 0x20);
98
}
99
kernel
arch
x86
x86-qemu
pic.c
Generated on Fri Jun 1 2012 19:07:12 for POK(kernelpart) by
1.8.1