Assignment 3 (only src and notes)
This commit is contained in:
@@ -8,19 +8,19 @@
|
||||
#define GDT_DATA_SELECTOR 0x10
|
||||
|
||||
struct GdtEntry {
|
||||
uint16_t limit_low;
|
||||
uint16_t base_low;
|
||||
uint8_t base_middle;
|
||||
uint8_t access;
|
||||
uint8_t granularity;
|
||||
uint8_t base_high;
|
||||
uint16_t limit_low;
|
||||
uint16_t base_low;
|
||||
uint8_t base_middle;
|
||||
uint8_t access;
|
||||
uint8_t granularity;
|
||||
uint8_t base_high;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct GdtDescriptor {
|
||||
uint16_t size;
|
||||
uint32_t offset;
|
||||
uint16_t size;
|
||||
uint32_t offset;
|
||||
} __attribute__((packed));
|
||||
|
||||
void gdtInitialize(void);
|
||||
void GdtInitialize(void);
|
||||
|
||||
#endif
|
||||
24
src/OSDev_18/include/kernel/idt.h
Normal file
24
src/OSDev_18/include/kernel/idt.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef KERNEL_IDT_H
|
||||
#define KERNEL_IDT_H
|
||||
|
||||
#include <libc/stdint.h>
|
||||
|
||||
#define IDT_ENTRIES 256
|
||||
|
||||
struct IdtEntry{
|
||||
uint16_t interrupt_low;
|
||||
uint16_t kernel_cs;
|
||||
uint8_t reserved;
|
||||
uint8_t attributes;
|
||||
uint16_t interrupt_high;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct Idtr {
|
||||
uint16_t limit;
|
||||
uint32_t base;
|
||||
} __attribute__((packed));
|
||||
|
||||
void IdtInitialize(void);
|
||||
void IdtSetDescriptor(uint8_t vector, uint32_t interrupt, uint8_t flags);
|
||||
|
||||
#endif
|
||||
54
src/OSDev_18/include/kernel/interrupt.h
Normal file
54
src/OSDev_18/include/kernel/interrupt.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef KERNEL_INTERRUPT_H
|
||||
#define KERNEL_INTERRUPT_H
|
||||
|
||||
#include <libc/stdint.h>
|
||||
|
||||
#define IRQ0 32
|
||||
#define IRQ1 33
|
||||
#define IRQ2 34
|
||||
#define IRQ3 35
|
||||
#define IRQ4 36
|
||||
#define IRQ5 37
|
||||
#define IRQ6 38
|
||||
#define IRQ7 39
|
||||
#define IRQ8 40
|
||||
#define IRQ9 41
|
||||
#define IRQ10 42
|
||||
#define IRQ11 43
|
||||
#define IRQ12 44
|
||||
#define IRQ13 45
|
||||
#define IRQ14 46
|
||||
#define IRQ15 47
|
||||
|
||||
struct Registers {
|
||||
uint32_t ds;
|
||||
|
||||
uint32_t edi;
|
||||
uint32_t esi;
|
||||
uint32_t ebp;
|
||||
uint32_t esp;
|
||||
uint32_t ebx;
|
||||
uint32_t edx;
|
||||
uint32_t ecx;
|
||||
uint32_t eax;
|
||||
|
||||
uint32_t int_no;
|
||||
uint32_t err_code;
|
||||
|
||||
uint32_t eip;
|
||||
uint32_t cs;
|
||||
uint32_t eflags;
|
||||
uint32_t useresp;
|
||||
uint32_t ss;
|
||||
};
|
||||
|
||||
void PicSendEoi(uint8_t irqNum);
|
||||
void PicRemap(void);
|
||||
|
||||
void IsrHandler(struct Registers* registers);
|
||||
void IrqHandler(struct Registers* registers);
|
||||
|
||||
typedef void (*InterruptHandler)(struct Registers* registers);
|
||||
void RegisterInterruptHandler(uint8_t iNum, InterruptHandler handler);
|
||||
|
||||
#endif
|
||||
20
src/OSDev_18/include/kernel/io.h
Normal file
20
src/OSDev_18/include/kernel/io.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef KERNEL_IO_H
|
||||
#define KERNEL_IO_H
|
||||
|
||||
#include <libc/stdint.h>
|
||||
|
||||
static inline void OutPortByte(uint16_t port, uint8_t val) {
|
||||
__asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline uint8_t InPortByte(uint16_t port) {
|
||||
uint8_t ret;
|
||||
__asm__ volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void IoWait(void) {
|
||||
__asm__ volatile ("outb %%al, $0x80" : : "a"(0));
|
||||
}
|
||||
|
||||
#endif
|
||||
11
src/OSDev_18/include/kernel/keyboard.h
Normal file
11
src/OSDev_18/include/kernel/keyboard.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef KERNEL_KEYBOARD_H
|
||||
#define KERNEL_KEYBOARD_H
|
||||
|
||||
#include <kernel/interrupt.h>
|
||||
|
||||
#define KEYBOARD_DATA_PORT 0x60
|
||||
#define KEYBOARD_BUFFER_SIZE 256
|
||||
|
||||
void KeyboardHandler(struct Registers* registers);
|
||||
|
||||
#endif
|
||||
@@ -23,14 +23,16 @@ enum vga_colour{
|
||||
VGA_COLOR_WHITE = 15,
|
||||
};
|
||||
|
||||
uint8_t vgaEntryColour(enum vga_colour fg, enum vga_colour bg);
|
||||
uint16_t vgaEntry(unsigned char uc, uint8_t color);
|
||||
uint8_t VgaEntryColour(enum vga_colour fg, enum vga_colour bg);
|
||||
uint16_t VgaEntry(unsigned char uc, uint8_t color);
|
||||
|
||||
void terminalEntryAt(char c, uint8_t colour, size_t x, size_t y);
|
||||
void terminalInitialize(void);
|
||||
void terminalSetColour(uint8_t colour);
|
||||
void terminalPutChar(char c);
|
||||
void terminalWrite(const char* data, size_t size);
|
||||
void terminalWriteString(const char* data);
|
||||
void TerminalEntryAt(char c, uint8_t colour, size_t x, size_t y);
|
||||
void TerminalInitialize(void);
|
||||
void TerminalSetColour(uint8_t colour);
|
||||
void TerminalUpdateCursor(void);
|
||||
void TerminalPutChar(char c);
|
||||
void TerminalWrite(const char* data, size_t size);
|
||||
void TerminalWriteString(const char* data);
|
||||
void TerminalWriteUInt(uint32_t num);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user