PatchworkOS
Loading...
Searching...
No Matches
pic.c
Go to the documentation of this file.
1
#include <
kernel/drivers/pic.h
>
2
3
#include <
kernel/cpu/interrupt.h
>
4
#include <
kernel/cpu/port.h
>
5
#include <
kernel/log/log.h
>
6
7
void
pic_disable
(
void
)
8
{
9
// We initialize the PIC before we then mask all interrupts.
10
// Probably not needed but it ensures that the PIC is in a known state before we disable it.
11
12
uint8_t
a1 =
port_inb
(
PIC1_DATA
);
13
port_wait
();
14
uint8_t
a2 =
port_inb
(
PIC2_DATA
);
15
port_wait
();
16
17
port_outb
(
PIC1_COMMAND
,
ICW1_INIT
|
ICW1_ICW4
);
18
port_wait
();
19
port_outb
(
PIC2_COMMAND
,
ICW1_INIT
|
ICW1_ICW4
);
20
port_wait
();
21
22
port_outb
(
PIC1_DATA
,
EXTERNAL_INTERRUPT_BASE
);
23
port_wait
();
24
port_outb
(
PIC2_DATA
,
EXTERNAL_INTERRUPT_BASE
+ 0x8);
25
port_wait
();
26
27
port_outb
(
PIC1_DATA
, 4);
28
port_wait
();
29
port_outb
(
PIC2_DATA
, 2);
30
port_wait
();
31
32
port_outb
(
PIC1_DATA
,
ICW4_8086
);
33
port_wait
();
34
port_outb
(
PIC2_DATA
,
ICW4_8086
);
35
port_wait
();
36
37
port_outb
(
PIC1_DATA
, a1);
38
port_wait
();
39
port_outb
(
PIC2_DATA
, a2);
40
port_wait
();
41
42
// Mask all interrupts.
43
port_outb
(
PIC1_DATA
, 0xFF);
44
port_outb
(
PIC2_DATA
, 0xFF);
45
46
LOG_INFO
(
"pic disabled\n"
);
47
}
EXTERNAL_INTERRUPT_BASE
@ EXTERNAL_INTERRUPT_BASE
Definition
interrupt.h:132
ICW1_INIT
#define ICW1_INIT
Definition
port.h:19
port_inb
static uint8_t port_inb(uint16_t port)
Definition
port.h:34
ICW4_8086
#define ICW4_8086
Definition
port.h:21
port_wait
static void port_wait(void)
Definition
port.h:65
port_outb
static void port_outb(uint16_t port, uint8_t val)
Definition
port.h:29
ICW1_ICW4
#define ICW1_ICW4
Definition
port.h:15
LOG_INFO
#define LOG_INFO(format,...)
Definition
log.h:87
interrupt.h
log.h
pic_disable
void pic_disable(void)
Definition
pic.c:7
pic.h
PIC2_COMMAND
#define PIC2_COMMAND
Definition
pic.h:7
PIC2_DATA
#define PIC2_DATA
Definition
pic.h:8
PIC1_COMMAND
#define PIC1_COMMAND
Definition
pic.h:5
PIC1_DATA
#define PIC1_DATA
Definition
pic.h:6
port.h
uint8_t
__UINT8_TYPE__ uint8_t
Definition
stdint.h:11
src
kernel
drivers
pic.c
Generated by
1.9.8