WKern
Loading...
Searching...
No Matches
masker.c
Go to the documentation of this file.
1
/*
2
WKern - A Bare Metal OS / Kernel I am maKing (For Fun)
3
Copyright (C) 2025 Wdboyes13
4
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
any later version.
9
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.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <https://www.gnu.org/licenses/>.
17
*/
18
19
#include <
idt/idtirq.h
>
20
#include <
io/kio.h
>
21
#include <
types/nums.h
>
22
#define PIC1_DATA 0x21
23
#define PIC2_DATA 0xA1
24
26
void
MaskAllIrqs
(
void
) {
27
Kprintf
(
"MasKing all IRQs\n"
);
28
Outb
(
PIC1_DATA
, 0xFF);
// MasK all IRQs on master PIC
29
Outb
(
PIC2_DATA
, 0xFF);
// MasK all IRQs on slave PIC
30
}
31
34
void
UnmaskIrq
(
u8
irq) {
35
Kprintf
(
"UnmasKing IRQ\n"
);
36
u16
port;
37
u8
value;
38
39
if
(irq < 8) {
40
port = 0x21;
41
}
else
{
42
port = 0xA1;
43
irq -= 8;
44
}
45
46
value =
Inb
(port) & ~(1 << irq);
47
Outb
(port, value);
48
}
Outb
void Outb(u16 port, u8 val)
Write a byte to the specified I/O port.
Definition
asm.c:30
Inb
u8 Inb(u16 port)
Read a byte from the specified I/O port.
Definition
asm.c:40
idtirq.h
kio.h
Kprintf
void Kprintf(const char *fmt,...)
Formatted output to the screen.
Definition
printer.c:152
PIC2_DATA
#define PIC2_DATA
Definition
masker.c:23
UnmaskIrq
void UnmaskIrq(u8 irq)
Unmask an IRQ.
Definition
masker.c:34
PIC1_DATA
#define PIC1_DATA
Definition
masker.c:22
MaskAllIrqs
void MaskAllIrqs(void)
Mask all IRQs.
Definition
masker.c:26
nums.h
u16
unsigned short u16
16-Bit Unsigned Int
Definition
nums.h:36
u8
unsigned char u8
8-Bit Unsigned Int
Definition
nums.h:32
src
idt
masker.c
Generated on
for WKern by
1.14.0