PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
pic.c
Go to the documentation of this file.
1#include <kernel/cpu/irq.h>
3
5#include <kernel/cpu/io.h>
6#include <kernel/log/log.h>
7
8static void pic_wait(void)
9{
10 io_out8(0x80, 0);
11}
12
13void pic_disable(void)
14{
15 // We initialize the PIC before we then mask all interrupts.
16 // Probably not needed but it ensures that the PIC is in a known state before we disable it.
17
19 pic_wait();
21 pic_wait();
22
24 pic_wait();
26 pic_wait();
27
29 pic_wait();
31 pic_wait();
32
34 pic_wait();
36 pic_wait();
37
39 pic_wait();
41 pic_wait();
42
43 io_out8(PIC1_DATA, a1);
44 pic_wait();
45 io_out8(PIC2_DATA, a2);
46 pic_wait();
47
48 // Mask all interrupts.
49 io_out8(PIC1_DATA, 0xFF);
50 io_out8(PIC2_DATA, 0xFF);
51
52 LOG_INFO("pic disabled\n");
53}
@ VECTOR_EXTERNAL_START
Inclusive start of external interrupts (handled by the IRQ system).
Definition interrupt.h:123
static void io_out8(port_t port, uint8_t val)
Write an 8-bit value to an I/O port.
Definition io.h:71
static uint8_t io_in8(port_t port)
Read an 8-bit value from an I/O port.
Definition io.h:82
#define PIC2_COMMAND
Definition pic.h:19
#define ICW1_INIT
Initialization - required!
Definition pic.h:28
#define ICW4_8086
8086/88 (MCS-80/85) mode
Definition pic.h:30
void pic_disable(void)
Definition pic.c:13
#define ICW1_ICW4
Indicates that ICW4 will be present.
Definition pic.h:24
#define PIC2_DATA
Definition pic.h:20
#define PIC1_COMMAND
Definition pic.h:17
#define PIC1_DATA
Definition pic.h:18
#define LOG_INFO(format,...)
Definition log.h:106
static void pic_wait(void)
Definition pic.c:8
__UINT8_TYPE__ uint8_t
Definition stdint.h:11