summaryrefslogtreecommitdiff
path: root/src/kernel/idt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/idt.c')
-rw-r--r--src/kernel/idt.c55
1 files changed, 37 insertions, 18 deletions
diff --git a/src/kernel/idt.c b/src/kernel/idt.c
index 3d23797..4dc8a36 100644
--- a/src/kernel/idt.c
+++ b/src/kernel/idt.c
@@ -7,12 +7,11 @@
#include "task.h"
#include "paging.h"
#include "pmap.h"
+#include "kbd.h"
enum {
IDT_PRESENT = 0x80,
-
IDT_INT = 0x0e,
- IDT_TRAP = 0x0f
};
struct idt_entry {
@@ -55,21 +54,13 @@ static uint32_t sc_file_read(uint32_t handle, uint32_t file_offset, uint32_t cou
return count;
}
-static bool sc_start_task(uint32_t drive_number, char *path) {
+static bool sc_start_task(uint32_t drive_number, char *path, const char *pass) {
switch_to_kernel_cr3();
- bool result = try_elf_run(drives + drive_number, path);
+ bool result = try_elf_run(drives + drive_number, vma_to_pma(active_task->page_directory, path), pass);
switch_to_task_cr3();
return result;
}
-static void sc_log_string(char *sz) {
- logsz(sz);
-}
-
-static char sc_get_key() {
- panic("TODO: get key system call");
-}
-
static void *sc_allocate_ram(uint32_t pages) {
return pd_user_allocate_anywhere_writable(active_task->page_directory, pages);
}
@@ -94,7 +85,7 @@ static uint32_t sc_memory_info(enum mi_arg arg) {
case MI_USER_LEFT:
return user_pages_left;
case MI_TASK_LEFT:
- panic("TODO: this process memory left");
+ PANIC("TODO: memory info task left");
default:
return -1;
}
@@ -106,18 +97,21 @@ void const *syscall_table[] = {
&sc_file_read,
&sc_file_get_size,
&sc_start_task,
- &sc_log_string,
- &sc_get_key,
+ &logsz,
+ &get_key_code,
&sc_allocate_ram,
&sc_memory_info
};
-typedef void isr_t;
+//these aren't really void (*)()'s, but gcc complains if we take an address of a void, so we give it a type
+typedef void (*isr_t)();
extern isr_t syscall_isr;
extern isr_t quit_isr;
extern isr_t yield_isr;
+extern isr_t kbd_isr;
+
static void register_int(uint8_t n, isr_t *isr, uint8_t dpl) {
idt[n].addr_low = (uint32_t)isr & 0xffff;
idt[n].addr_high = (uint32_t)isr >> 16;
@@ -125,6 +119,17 @@ static void register_int(uint8_t n, isr_t *isr, uint8_t dpl) {
idt[n].flags = IDT_PRESENT | (dpl << 5) | IDT_INT;
}
+enum {
+ PIC_MCMD = 0x0020,
+ PIC_MDATA = 0x0021,
+ PIC_SCMD = 0x00a0,
+ PIC_SDATA = 0x00a1
+};
+
+enum {
+ PIC_RESET = 0x11
+};
+
void init_idt() {
for (uint16_t i = 0; i < 256; ++i) {
idt[i].flags = 0;
@@ -135,8 +140,22 @@ void init_idt() {
register_int(0x38, &quit_isr, 3);
register_int(0x39, &yield_isr, 3);
- outb(0x0021, 0xff);
- outb(0x00a1, 0xff);
+ register_int(0x21, &kbd_isr, 0);
+
+ outb(PIC_MCMD, PIC_RESET);
+ outb(PIC_SCMD, PIC_RESET);
+
+ outb(PIC_MDATA, 0x20);
+ outb(PIC_SDATA, 0x28);
+
+ outb(PIC_MDATA, 0x04);
+ outb(PIC_SDATA, 0x02);
+
+ outb(PIC_MDATA, 0x01);
+ outb(PIC_SDATA, 0x01);
+
+ outb(PIC_MDATA, 0xfd);
+ outb(PIC_SDATA, 0xff);
asm volatile (
"lidt %0"