forked from ReKernel/ReKernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpic.h
More file actions
executable file
·29 lines (24 loc) · 744 Bytes
/
pic.h
File metadata and controls
executable file
·29 lines (24 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef PIC_H
#define PIC_H
#include "kernel.h"
#define PIC1_CMD 0x20
#define PIC1_DATA 0x21
#define PIC2_CMD 0xA0
#define PIC2_DATA 0xA1
#define PIC_EOI 0x20 /* End-Of-Interrupt command */
/* Remap PIC so IRQ0–15 map to interrupts 32–47 (avoiding CPU exceptions) */
void pic_remap(void);
void pic_send_eoi(uint8_t irq);
void pic_mask_irq(uint8_t irq);
void pic_unmask_irq(uint8_t irq);
/* Low-level port I/O */
static inline void outb(uint16_t port, uint8_t val) {
__asm__ volatile ("outb %0, %1" :: "a"(val), "Nd"(port));
}
static inline uint8_t inb(uint16_t port) {
uint8_t val;
__asm__ volatile ("inb %1, %0" : "=a"(val) : "Nd"(port));
return val;
}
static inline void io_wait(void) { outb(0x80, 0); }
#endif