WKern
Loading...
Searching...
No Matches
masker.c
Go to the documentation of this file.
1/*
2WKern - A Bare Metal OS / Kernel I am maKing (For Fun)
3Copyright (C) 2025 Wdboyes13
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along 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
26void 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
34void 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}
void Outb(u16 port, u8 val)
Write a byte to the specified I/O port.
Definition asm.c:30
u8 Inb(u16 port)
Read a byte from the specified I/O port.
Definition asm.c:40
void Kprintf(const char *fmt,...)
Formatted output to the screen.
Definition printer.c:152
#define PIC2_DATA
Definition masker.c:23
void UnmaskIrq(u8 irq)
Unmask an IRQ.
Definition masker.c:34
#define PIC1_DATA
Definition masker.c:22
void MaskAllIrqs(void)
Mask all IRQs.
Definition masker.c:26
unsigned short u16
16-Bit Unsigned Int
Definition nums.h:36
unsigned char u8
8-Bit Unsigned Int
Definition nums.h:32