MOS Source Code
Loading...
Searching...
No Matches
pic.c
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
#include <
mos/types.h
>
4
#include <
mos/x86/devices/port.h
>
5
#include <
mos/x86/x86_platform.h
>
6
7
// Reinitialize the PIC controllers.
8
// Giving them specified vector offsets rather than 8h and 70h, as configured by default
9
// ICW: Initialization command words
10
#define ICW1_ICW4 0x01
/* ICW4 (not) needed */
11
#define ICW1_INIT 0x10
/* Initialization - required! */
12
#define ICW4_8086 0x01
/* 8086/88 (MCS-80/85) mode */
13
14
#define PIC1 0x20
// IO base address for master PIC
15
#define PIC2 0xA0
// IO base address for slave PIC
16
#define PIC1_COMMAND (PIC1)
17
#define PIC1_DATA (PIC1 + 1)
18
#define PIC2_COMMAND (PIC2)
19
#define PIC2_DATA (PIC2 + 1)
20
21
#define PIC1_OFFSET 0x20
22
#define PIC2_OFFSET 0x28
23
24
// We now have APIC, so PIC is not used anymore, but the above initialization code is still used
25
void
pic_remap_irq
(
void
)
26
{
27
port_outb
(
PIC1_COMMAND
,
ICW1_INIT
|
ICW1_ICW4
);
// starts the initialization sequence (in cascade mode)
28
port_outb
(
PIC2_COMMAND
,
ICW1_INIT
|
ICW1_ICW4
);
29
30
port_outb
(
PIC1_DATA
,
PIC1_OFFSET
);
// ICW2: Master PIC vector offset
31
port_outb
(
PIC2_DATA
,
PIC2_OFFSET
);
// ICW2: Slave PIC vector offset
32
33
port_outb
(
PIC1_DATA
, 4);
// ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100)
34
port_outb
(
PIC2_DATA
, 2);
// ICW3: tell Slave PIC its cascade identity (0000 0010)
35
36
port_outb
(
PIC1_DATA
,
ICW4_8086
);
37
port_outb
(
PIC2_DATA
,
ICW4_8086
);
38
39
port_outb
(
PIC2_DATA
, 0xFF);
// mask all interrupts on slave PIC
40
port_outb
(
PIC1_DATA
, 0xFF);
// mask all interrupts on master PIC
41
}
PIC1_OFFSET
#define PIC1_OFFSET
Definition
pic.c:21
PIC2_COMMAND
#define PIC2_COMMAND
Definition
pic.c:18
ICW1_INIT
#define ICW1_INIT
Definition
pic.c:11
ICW4_8086
#define ICW4_8086
Definition
pic.c:12
PIC2_OFFSET
#define PIC2_OFFSET
Definition
pic.c:22
ICW1_ICW4
#define ICW1_ICW4
Definition
pic.c:10
PIC2_DATA
#define PIC2_DATA
Definition
pic.c:19
PIC1_COMMAND
#define PIC1_COMMAND
Definition
pic.c:16
pic_remap_irq
void pic_remap_irq(void)
Definition
pic.c:25
PIC1_DATA
#define PIC1_DATA
Definition
pic.c:17
port.h
port_outb
should_inline void port_outb(u16 port, u8 value)
Definition
port.h:31
types.h
x86_platform.h
kernel
arch
x86_64
interrupt
pic.c
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0