LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
pic.h
Go to the documentation of this file.
1
9
10#ifndef KERNEL_ARCH_X86_64_PIC_H
11#define KERNEL_ARCH_X86_64_PIC_H
12
13#include <stdint.h>
14
15#include "io.h"
16
17#define PIC_MASTER_COMMAND_PORT 0x20
18#define PIC_MASTER_DATA_PORT 0x21
19
20#define PIC_SLAVE_COMMAND_PORT 0xA0
21#define PIC_SLAVE_DATA_PORT 0xA1
22
28void pic_remap(uint8_t master_offset, uint8_t slave_offset);
29
34void pic_set_mask(uint8_t irq);
35
40void pic_clear_mask(uint8_t irq);
41
46void pic_send_eoi(uint8_t irq);
47
48inline uint8_t pic_read_irr(void)
49{
50 outb(PIC_MASTER_COMMAND_PORT, 0x0A);
51 return inb(PIC_MASTER_COMMAND_PORT);
52}
53
54inline uint8_t pic_read_isr(void)
55{
56 outb(PIC_MASTER_COMMAND_PORT, 0x0B);
57 return inb(PIC_MASTER_COMMAND_PORT);
58}
59
60#endif
Provides utilities for IO operations with the hardware.
uint8_t inb(uint16_t port)
Inputs a byte from the specified port.
Definition io.h:31
void outb(uint16_t port, uint8_t value)
Outputs a byte to the specified port.
Definition io.h:22
void pic_send_eoi(uint8_t irq)
Sends an EOI to tell the PIC that the interrupt is over.
Definition pic.c:103
void pic_remap(uint8_t master_offset, uint8_t slave_offset)
Initializes the PIC using ICWs and mask all lines.
Definition pic.c:19
void pic_set_mask(uint8_t irq)
Masks (Disables) a line.
Definition pic.c:54
void pic_clear_mask(uint8_t irq)
Unmasks (Enables) a line.
Definition pic.c:79