aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-03-01 14:20:47 -0500
committerFranklin Wei <frankhwei536@gmail.com>2015-03-01 14:20:47 -0500
commitc7252588ebb95f97631e9470778c69afa00c35b5 (patch)
tree06d760878e18f6cddbe4305cddd4d5dfa74529f8 /kernel
parentb8f54e63d2b8f8007c580adf2a6034c98a0f2eaa (diff)
downloadkappa-c7252588ebb95f97631e9470778c69afa00c35b5.zip
kappa-c7252588ebb95f97631e9470778c69afa00c35b5.tar.gz
kappa-c7252588ebb95f97631e9470778c69afa00c35b5.tar.bz2
kappa-c7252588ebb95f97631e9470778c69afa00c35b5.tar.xz
Huge restructure
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fpu.c25
-rw-r--r--kernel/gdt-as.S14
-rw-r--r--kernel/gdt.c34
-rw-r--r--kernel/idt-as.S6
-rw-r--r--kernel/idt.c24
-rw-r--r--kernel/include/fpu.h2
-rw-r--r--kernel/include/gdt.h23
-rw-r--r--kernel/include/heap.h5
-rw-r--r--kernel/include/idt.h23
-rw-r--r--kernel/include/io.h5
-rw-r--r--kernel/include/irq.h19
-rw-r--r--kernel/include/isr.h51
-rw-r--r--kernel/include/log.h3
-rw-r--r--kernel/include/multiboot.h90
-rw-r--r--kernel/include/paging.h8
-rw-r--r--kernel/include/panic.h1
-rw-r--r--kernel/include/timer.h13
-rw-r--r--kernel/include/version.h2
-rw-r--r--kernel/irq-as.S146
-rw-r--r--kernel/irq.c73
-rw-r--r--kernel/isr-as.S214
-rw-r--r--kernel/isr.c60
-rw-r--r--kernel/linker.ld45
-rw-r--r--kernel/main.c2
-rw-r--r--kernel/paging-as.S9
-rw-r--r--kernel/paging.c64
-rw-r--r--kernel/ssp.c19
27 files changed, 2 insertions, 978 deletions
diff --git a/kernel/fpu.c b/kernel/fpu.c
deleted file mode 100644
index f5512d6..0000000
--- a/kernel/fpu.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2011-2013 Kevin Lange */
-/* this code from toaruos */
-#include <stddef.h>
-#include "fpu.h"
-
-/**
- * Enable the FPU and SSE
- */
-void fpu_enable(void) {
- asm volatile ("clts");
- size_t t;
- asm volatile ("mov %%cr4, %0" : "=r"(t));
- t |= 3 << 9;
- asm volatile ("mov %0, %%cr4" :: "r"(t));
-}
-
-/**
- * Disable FPU and SSE so it traps to the kernel
- */
-void fpu_disable(void) {
- size_t t;
- asm volatile ("mov %%cr0, %0" : "=r"(t));
- t |= 1 << 3;
- asm volatile ("mov %0, %%cr0" :: "r"(t));
-}
diff --git a/kernel/gdt-as.S b/kernel/gdt-as.S
deleted file mode 100644
index 5a481e3..0000000
--- a/kernel/gdt-as.S
+++ /dev/null
@@ -1,14 +0,0 @@
- .global gdt_flush
-gdt_flush: # prototype: void gdt_flush(uint32)
- movl 4(%esp), %eax
- lgdt (%eax)
- # 0x8 is the code segment selector
- jmp $0x8, $.flush
-.flush:
- mov $0x10, %ax # 0x10 is the data segment selector
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %gs
- mov %ax, %ss
- ret
diff --git a/kernel/gdt.c b/kernel/gdt.c
deleted file mode 100644
index 36a0cda..0000000
--- a/kernel/gdt.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "gdt.h"
-
-static void gdt_set_gate(int idx, uint32_t base, uint32_t limit, uint8_t access, uint8_t gran)
-{
- /* Setup the descriptor base address */
- gdt[idx].base_low = (base & 0xFFFF);
- gdt[idx].base_middle = (base >> 16) & 0xFF;
- gdt[idx].base_high = (base >> 24) & 0xFF;
-
- /* Setup the descriptor limits */
- gdt[idx].limit_low = (limit & 0xFFFF);
- gdt[idx].granularity = ((limit >> 16) & 0x0F);
-
- /* Finally, set up the granularity and access flags */
- gdt[idx].granularity |= (gran & 0xF0);
- gdt[idx].access = access;
-}
-
-void gdt_init(void)
-{
- gp.limit = sizeof(gdt) - 1;
- gp.base = (uint32_t)&gdt;
-
- /* null segment */
- gdt_set_gate(0, 0, 0, 0, 0);
-
- /* code segment */
- gdt_set_gate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
-
- /* data segment */
- gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
-
- gdt_flush((uint32_t)&gp);
-}
diff --git a/kernel/idt-as.S b/kernel/idt-as.S
deleted file mode 100644
index d1ab7e2..0000000
--- a/kernel/idt-as.S
+++ /dev/null
@@ -1,6 +0,0 @@
- .global idt_flush
- .type idt_flush, @function
-idt_flush: # prototype: void idt_flush(uint32)
- movl 4(%esp), %eax
- lidt (%eax)
- ret
diff --git a/kernel/idt.c b/kernel/idt.c
deleted file mode 100644
index 0108991..0000000
--- a/kernel/idt.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <stdint.h>
-#include <string.h>
-#include "idt.h"
-#include "isr.h"
-#include "irq.h"
-
-void idt_set_gate(uint8_t idx, uint32_t base, uint16_t sel, uint8_t flags)
-{
- idt[idx].base_lo = base & 0xFFFF;
- idt[idx].base_hi = base >> 16;
- idt[idx].sel = sel;
- idt[idx].zero = 0;
- idt[idx].flags = flags;
-}
-
-void idt_init(void)
-{
- idt_pt.limit = sizeof(idt) - 1;
- idt_pt.base = (uint32_t)&idt;
-
- memset(&idt, 0, sizeof(idt));
-
- idt_flush((uint32_t)&idt_pt);
-}
diff --git a/kernel/include/fpu.h b/kernel/include/fpu.h
deleted file mode 100644
index 0eb448a..0000000
--- a/kernel/include/fpu.h
+++ /dev/null
@@ -1,2 +0,0 @@
-void fpu_enable(void);
-void fpu_disable(void);
diff --git a/kernel/include/gdt.h b/kernel/include/gdt.h
deleted file mode 100644
index 4cf7c4f..0000000
--- a/kernel/include/gdt.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <stdint.h>
-
-struct gdt_entry {
- 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 gdt_ptr {
- uint16_t limit;
- uint32_t base;
-} __attribute__((packed));
-
-struct gdt_entry gdt[3];
-struct gdt_ptr gp;
-
-/* assembly */
-extern void gdt_flush(uint32_t);
-
-void gdt_init(void);
diff --git a/kernel/include/heap.h b/kernel/include/heap.h
deleted file mode 100644
index dfadf36..0000000
--- a/kernel/include/heap.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stddef.h>
-void *kmalloc(size_t);
-void *kmalloc_a(size_t);
-void *kmalloc_p(size_t, void**);
-void *kmalloc_ap(size_t, void**);
diff --git a/kernel/include/idt.h b/kernel/include/idt.h
deleted file mode 100644
index 250ab82..0000000
--- a/kernel/include/idt.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <stdint.h>
-
-struct idt_entry {
- uint16_t base_lo;
- uint16_t sel;
- uint8_t zero;
- uint8_t flags;
- uint16_t base_hi;
-} __attribute__((packed));
-
-struct idt_ptr {
- uint16_t limit;
- uint32_t base;
-} __attribute__((packed));
-
-struct idt_entry idt[0x100];
-struct idt_ptr idt_pt;
-
-void idt_init(void);
-
-extern void idt_flush(uint32_t);
-
-void idt_set_gate(uint8_t idx, uint32_t base, uint16_t sel, uint8_t flags);
diff --git a/kernel/include/io.h b/kernel/include/io.h
deleted file mode 100644
index d1177ac..0000000
--- a/kernel/include/io.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdint.h>
-void outb(uint16_t port, uint8_t val);
-void outw(uint16_t port, uint16_t val);
-uint8_t inb(uint16_t port);
-uint16_t inw(uint16_t port);
diff --git a/kernel/include/irq.h b/kernel/include/irq.h
deleted file mode 100644
index 13461e9..0000000
--- a/kernel/include/irq.h
+++ /dev/null
@@ -1,19 +0,0 @@
-extern void _irq0(void);
-extern void _irq1(void);
-extern void _irq2(void);
-extern void _irq3(void);
-extern void _irq4(void);
-extern void _irq5(void);
-extern void _irq6(void);
-extern void _irq7(void);
-extern void _irq8(void);
-extern void _irq9(void);
-extern void _irq10(void);
-extern void _irq11(void);
-extern void _irq12(void);
-extern void _irq13(void);
-extern void _irq14(void);
-extern void _irq15(void);
-extern void _int0x80(void);
-
-void irq_init(void);
diff --git a/kernel/include/isr.h b/kernel/include/isr.h
deleted file mode 100644
index 4cc7f1b..0000000
--- a/kernel/include/isr.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stdint.h>
-
-/* these are all implemented in isr-as.S */
-extern void _isr0(void);
-extern void _isr1(void);
-extern void _isr2(void);
-extern void _isr3(void);
-extern void _isr4(void);
-extern void _isr5(void);
-extern void _isr6(void);
-extern void _isr7(void);
-extern void _isr8(void);
-extern void _isr9(void);
-extern void _isr10(void);
-extern void _isr11(void);
-extern void _isr12(void);
-extern void _isr13(void);
-extern void _isr14(void);
-extern void _isr15(void);
-extern void _isr16(void);
-extern void _isr17(void);
-extern void _isr18(void);
-extern void _isr19(void);
-extern void _isr20(void);
-extern void _isr21(void);
-extern void _isr22(void);
-extern void _isr23(void);
-extern void _isr24(void);
-extern void _isr25(void);
-extern void _isr26(void);
-extern void _isr27(void);
-extern void _isr28(void);
-extern void _isr29(void);
-extern void _isr30(void);
-extern void _isr31(void);
-
-/* installs ISR's 0-31 */
-void isr_init(void);
-
-/* This defines what the stack looks like after an ISR was running */
-struct regs_t {
- uint32_t gs, fs, es, ds; /* pushed the segs last */
- uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
- uint32_t int_no; /* interrupt stubs do this */
- uint32_t err_code; /* exceptions push this */
- uint32_t eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
-} __attribute__((packed));
-
-#define IRQ(x) (32+x)
-
-void set_interrupt_handler(uint8_t interrupt, void (*func)(struct regs_t*));
diff --git a/kernel/include/log.h b/kernel/include/log.h
deleted file mode 100644
index 1a28c0d..0000000
--- a/kernel/include/log.h
+++ /dev/null
@@ -1,3 +0,0 @@
-void log_putchar(int);
-void log_puts(const char*);
-void log(const char*, ...);
diff --git a/kernel/include/multiboot.h b/kernel/include/multiboot.h
deleted file mode 100644
index e1f7cf0..0000000
--- a/kernel/include/multiboot.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#include <stdint.h>
-
-struct multiboot_aout_symbol_table_t
-{
- uint32_t tabsize;
- uint32_t strsize;
- uint32_t addr;
- uint32_t reserved;
-} __attribute__((packed));
-
-struct multiboot_elf_section_header_table_t
-{
- uint32_t num;
- uint32_t size;
- uint32_t addr;
- uint32_t shndx;
-} __attribute__((packed));
-
-struct vbe_info_t {
- uint16_t attributes;
- uint8_t winA, winB;
- uint16_t granularity;
- uint16_t winsize;
- uint16_t segmentA, segmentB;
- uint32_t realFctPtr;
- uint16_t pitch;
- uint16_t Xres, Yres;
- uint8_t Wchar, Ychar, planes, bpp, banks;
- uint8_t memory_model, bank_size, image_pages;
- uint8_t reserved0;
- uint8_t red_mask, red_position;
- uint8_t green_mask, green_position;
- uint8_t blue_mask, blue_position;
- uint8_t rsv_mask, rsv_position;
- uint8_t directcolor_attributes;
- uint32_t physbase;
- uint32_t reserved1;
- uint16_t reserved2;
-} __attribute__((packed));
-
-struct multiboot_info_t
-{
- /* Multiboot info version number */
- uint32_t flags;
-
- /* Available memory from BIOS */
- uint32_t mem_lower;
- uint32_t mem_upper;
-
- /* "root" partition */
- uint32_t boot_device;
-
- /* Kernel command line */
- uint32_t cmdline;
-
- /* Boot-Module list */
- uint32_t mods_count;
- uint32_t mods_addr;
-
- union
- {
- struct multiboot_aout_symbol_table_t aout_sym;
- struct multiboot_elf_section_header_table_t elf_sec;
- } u;
-
- /* Memory Mapping buffer */
- uint32_t mmap_length;
- uint32_t mmap_addr;
-
- /* Drive Info buffer */
- uint32_t drives_length;
- uint32_t drives_addr;
-
- /* ROM configuration table */
- uint32_t config_table;
-
- /* Boot Loader Name */
- uint32_t boot_loader_name;
-
- /* APM table */
- uint32_t apm_table;
-
- /* Video */
- uint32_t vbe_control_info;
- uint32_t vbe_mode_info;
- uint16_t vbe_mode;
- uint16_t vbe_interface_seg;
- uint16_t vbe_interface_off;
- uint16_t vbe_interface_len;
-} __attribute__((packed));
diff --git a/kernel/include/paging.h b/kernel/include/paging.h
deleted file mode 100644
index 0481069..0000000
--- a/kernel/include/paging.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#define PAGE_PRESENT (1<<0)
-#define PAGE_RW (1<<1)
-#define PAGE_USER (1<<2)
-
-#define PAGE_MASK 0xFFFFF000
-#define PAGE_SIZE 0x1000
-
-void paging_init(void);
diff --git a/kernel/include/panic.h b/kernel/include/panic.h
deleted file mode 100644
index db53e8e..0000000
--- a/kernel/include/panic.h
+++ /dev/null
@@ -1 +0,0 @@
-void panic(const char*, ...);
diff --git a/kernel/include/timer.h b/kernel/include/timer.h
deleted file mode 100644
index 7a15949..0000000
--- a/kernel/include/timer.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <stdint.h>
-
-#define HZ 100
-#define PIT_FREQ 1193182
-
-extern volatile const uint64_t *current_tick;
-
-struct regs_t;
-
-void timer_init(uint32_t freq);
-
-/* NOTE: enables interrupts by default */
-void timer_delay(uint64_t ticks);
diff --git a/kernel/include/version.h b/kernel/include/version.h
deleted file mode 100644
index 8fff367..0000000
--- a/kernel/include/version.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#define KAPPA_KERNEL_VERSION "0.0.1-alpha"
-#define KAPPA_KERNEL_CODENAME "Ayatollah's Buybacks"
diff --git a/kernel/irq-as.S b/kernel/irq-as.S
deleted file mode 100644
index 1d16392..0000000
--- a/kernel/irq-as.S
+++ /dev/null
@@ -1,146 +0,0 @@
- .extern irq_handler
-
-irq_stub:
-
- pusha
- push %ds
- push %es
- push %fs
- push %gs
- mov $0x10, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %gs
- mov %esp, %eax # push the stack
- push %eax
- mov $irq_handler, %eax
- call *%eax
- pop %eax
- pop %gs
- pop %fs
- pop %es
- pop %ds
- popa
- addl $8, %esp
- iret
-
- .global _irq0
- .global _irq1
- .global _irq2
- .global _irq3
- .global _irq4
- .global _irq5
- .global _irq6
- .global _irq7
- .global _irq8
- .global _irq9
- .global _irq10
- .global _irq11
- .global _irq12
- .global _irq13
- .global _irq14
- .global _irq15
- .global _int0x80
-
-_irq0:
- cli
- pushl $0
- pushl $32
- jmp irq_stub
-
-_irq1:
- cli
- pushl $0
- pushl $33
- jmp irq_stub
-
-_irq2:
- cli
- pushl $0
- pushl $34
- jmp irq_stub
-
-_irq3:
- cli
- pushl $0
- pushl $35
- jmp irq_stub
-
-_irq4:
- cli
- pushl $0
- pushl $36
- jmp irq_stub
-
-_irq5:
- cli
- pushl $0
- pushl $37
- jmp irq_stub
-
-_irq6:
- cli
- pushl $0
- pushl $38
- jmp irq_stub
-
-_irq7:
- cli
- pushl $0
- pushl $39
- jmp irq_stub
-
-_irq8:
- cli
- pushl $0
- pushl $40
- jmp irq_stub
-
-_irq9:
- cli
- pushl $0
- pushl $41
- jmp irq_stub
-
-_irq10:
- cli
- pushl $0
- pushl $42
- jmp irq_stub
-
-_irq11:
- cli
- pushl $0
- pushl $43
- jmp irq_stub
-
-_irq12:
- cli
- pushl $0
- pushl $44
- jmp irq_stub
-
-_irq13:
- cli
- pushl $0
- pushl $45
- jmp irq_stub
-
-_irq14:
- cli
- pushl $0
- pushl $46
- jmp irq_stub
-
-_irq15:
- cli
- pushl $0
- pushl $47
- jmp irq_stub
-
-_int0x80:
- cli
- pushl $0
- pushl $0x80
- jmp irq_stub
diff --git a/kernel/irq.c b/kernel/irq.c
deleted file mode 100644
index c6dbf4c..0000000
--- a/kernel/irq.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <stdint.h>
-#include <stddef.h>
-#include <stdio.h>
-#include "idt.h"
-#include "io.h"
-#include "irq.h"
-#include "isr.h"
-#include "panic.h"
-
-/* in isr.c */
-extern void *int_callbacks[256];
-
-void irq_remap(void)
-{
- outb(0x20, 0x11);
- outb(0xA0, 0x11);
- outb(0x21, 0x20);
- outb(0xA1, 0x28);
- outb(0x21, 0x04);
- outb(0xA1, 0x02);
- outb(0x21, 0x01);
- outb(0xA1, 0x01);
- outb(0x21, 0x0);
- outb(0xA1, 0x0);
-}
-
-void irq_init(void)
-{
- irq_remap();
- idt_set_gate(32, (uint32_t)_irq0, 0x08, 0x8E);
- idt_set_gate(33, (uint32_t)_irq1, 0x08, 0x8E);
- idt_set_gate(34, (uint32_t)_irq2, 0x08, 0x8E);
- idt_set_gate(35, (uint32_t)_irq3, 0x08, 0x8E);
- idt_set_gate(36, (uint32_t)_irq4, 0x08, 0x8E);
- idt_set_gate(37, (uint32_t)_irq5, 0x08, 0x8E);
- idt_set_gate(38, (uint32_t)_irq6, 0x08, 0x8E);
- idt_set_gate(39, (uint32_t)_irq7, 0x08, 0x8E);
- idt_set_gate(40, (uint32_t)_irq8, 0x08, 0x8E);
- idt_set_gate(41, (uint32_t)_irq9, 0x08, 0x8E);
- idt_set_gate(42, (uint32_t)_irq10, 0x08, 0x8E);
- idt_set_gate(43, (uint32_t)_irq11, 0x08, 0x8E);
- idt_set_gate(44, (uint32_t)_irq12, 0x08, 0x8E);
- idt_set_gate(45, (uint32_t)_irq13, 0x08, 0x8E);
- idt_set_gate(46, (uint32_t)_irq14, 0x08, 0x8E);
- idt_set_gate(47, (uint32_t)_irq15, 0x08, 0x8E);
- idt_set_gate(128,(uint32_t)_int0x80, 0x08, 0x8E);
-}
-
-void irq_handler(struct regs_t *regs)
-{
- void (*handler)(struct regs_t *r);
-
- handler = int_callbacks[regs->int_no];
-
- if(handler)
- {
- handler(regs);
- }
- else
- {
- }
-
- /* If the IDT entry that was invoked was greater than 40
- * (meaning IRQ8 - 15), then we need to send an EOI to
- * the slave controller */
- if (regs->int_no >= 40)
- {
- outb(0xA0, 0x20);
- }
-
- /* send an EOI to the master controller */
- outb(0x20, 0x20);
-}
diff --git a/kernel/isr-as.S b/kernel/isr-as.S
deleted file mode 100644
index 858ce47..0000000
--- a/kernel/isr-as.S
+++ /dev/null
@@ -1,214 +0,0 @@
- .extern isr_handler
-isr_stub:
- pusha
- push %ds
- push %es
- push %fs
- push %gs
- mov $0x10, %ax # Load the Kernel Data Segment descriptor!
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %gs
- mov %esp, %eax # Push us the stack
- push %eax
- call isr_handler
- pop %eax
- pop %gs
- pop %fs
- pop %es
- pop %ds
- popa
- add $8, %esp
- iret
-
- # stub ISR's:
- .global _isr0
- .global _isr1
- .global _isr2
- .global _isr3
- .global _isr4
- .global _isr5
- .global _isr6
- .global _isr7
- .global _isr8
- .global _isr9
- .global _isr10
- .global _isr11
- .global _isr12
- .global _isr13
- .global _isr14
- .global _isr15
- .global _isr16
- .global _isr17
- .global _isr18
- .global _isr19
- .global _isr20
- .global _isr21
- .global _isr22
- .global _isr23
- .global _isr24
- .global _isr25
- .global _isr26
- .global _isr27
- .global _isr28
- .global _isr29
- .global _isr30
- .global _isr31
-
- # Interrupts 8, 10, 11, 12, 13, and 14 push error codes onto the stack
-
-_isr0:
- cli
- pushl $0
- pushl $0
- jmp isr_stub
-_isr1:
- cli
- pushl $0
- pushl $1
- jmp isr_stub
-_isr2:
- cli
- pushl $0
- pushl $2
- jmp isr_stub
-_isr3:
- cli
- pushl $0
- pushl $3
- jmp isr_stub
-_isr4:
- cli
- pushl $0
- pushl $4
- jmp isr_stub
-_isr5:
- cli
- pushl $0
- pushl $5
- jmp isr_stub
-_isr6:
- cli
- pushl $0
- pushl $6
- jmp isr_stub
-_isr7:
- cli
- pushl $0
- pushl $7
- jmp isr_stub
-_isr8:
- cli
- pushl $8
- jmp isr_stub
-_isr9:
- cli
- pushl $0
- pushl $9
- jmp isr_stub
-_isr10:
- cli
- pushl $10
- jmp isr_stub
-_isr11:
- cli
- pushl $11
- jmp isr_stub
-_isr12:
- cli
- pushl $12
- jmp isr_stub
-_isr13:
- cli
- pushl $13
- jmp isr_stub
-_isr14:
- cli
- pushl $14
- jmp isr_stub
-_isr15:
- cli
- pushl $0
- pushl $15
- jmp isr_stub
-_isr16:
- cli
- pushl $0
- pushl $16
- jmp isr_stub
-_isr17:
- cli
- pushl $0
- pushl $17
- jmp isr_stub
-_isr18:
- cli
- pushl $0
- pushl $18
- jmp isr_stub
-_isr19:
- cli
- pushl $0
- pushl $19
- jmp isr_stub
-_isr20:
- cli
- pushl $0
- pushl $20
- jmp isr_stub
-_isr21:
- cli
- pushl $0
- pushl $21
- jmp isr_stub
-_isr22:
- cli
- pushl $0
- pushl $22
- jmp isr_stub
-_isr23:
- cli
- pushl $0
- pushl $23
- jmp isr_stub
-_isr24:
- cli
- pushl $0
- pushl $24
- jmp isr_stub
-_isr25:
- cli
- pushl $0
- pushl $25
- jmp isr_stub
-_isr26:
- cli
- pushl $0
- pushl $26
- jmp isr_stub
-_isr27:
- cli
- pushl $0
- pushl $27
- jmp isr_stub
-_isr28:
- cli
- pushl $0
- pushl $28
- jmp isr_stub
-_isr29:
- cli
- pushl $0
- pushl $29
- jmp isr_stub
-_isr30:
- cli
- pushl $0
- pushl $30
- jmp isr_stub
-_isr31:
- cli
- pushl $0
- pushl $31
- jmp isr_stub
diff --git a/kernel/isr.c b/kernel/isr.c
deleted file mode 100644
index e6887c6..0000000
--- a/kernel/isr.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <stddef.h>
-#include <stdio.h>
-#include "isr.h"
-#include "idt.h"
-#include "panic.h"
-
-void (*int_callbacks[256])(struct regs_t*) = { NULL };
-
-void set_interrupt_handler(uint8_t n, void (*callback)(struct regs_t*))
-{
- int_callbacks[n] = callback;
-}
-
-void isr_handler(struct regs_t *regs)
-{
- if(int_callbacks[regs->int_no])
- {
- int_callbacks[regs->int_no](regs);
- }
- else
- {
- printf("WARNING: unhandled ISR 0x%x!\n", regs->int_no);
- }
-}
-
-void isr_init(void)
-{
- idt_set_gate(0, (uint32_t)_isr0, 0x08, 0x8E);
- idt_set_gate(1, (uint32_t)_isr1, 0x08, 0x8E);
- idt_set_gate(2, (uint32_t)_isr2, 0x08, 0x8E);
- idt_set_gate(3, (uint32_t)_isr3, 0x08, 0x8E);
- idt_set_gate(4, (uint32_t)_isr4, 0x08, 0x8E);
- idt_set_gate(5, (uint32_t)_isr5, 0x08, 0x8E);
- idt_set_gate(6, (uint32_t)_isr6, 0x08, 0x8E);
- idt_set_gate(7, (uint32_t)_isr7, 0x08, 0x8E);
- idt_set_gate(8, (uint32_t)_isr8, 0x08, 0x8E);
- idt_set_gate(9, (uint32_t)_isr9, 0x08, 0x8E);
- idt_set_gate(10, (uint32_t)_isr10, 0x08, 0x8E);
- idt_set_gate(11, (uint32_t)_isr11, 0x08, 0x8E);
- idt_set_gate(12, (uint32_t)_isr12, 0x08, 0x8E);
- idt_set_gate(13, (uint32_t)_isr13, 0x08, 0x8E);
- idt_set_gate(14, (uint32_t)_isr14, 0x08, 0x8E);
- idt_set_gate(15, (uint32_t)_isr15, 0x08, 0x8E);
- idt_set_gate(16, (uint32_t)_isr16, 0x08, 0x8E);
- idt_set_gate(17, (uint32_t)_isr17, 0x08, 0x8E);
- idt_set_gate(18, (uint32_t)_isr18, 0x08, 0x8E);
- idt_set_gate(19, (uint32_t)_isr19, 0x08, 0x8E);
- idt_set_gate(20, (uint32_t)_isr20, 0x08, 0x8E);
- idt_set_gate(21, (uint32_t)_isr21, 0x08, 0x8E);
- idt_set_gate(22, (uint32_t)_isr22, 0x08, 0x8E);
- idt_set_gate(23, (uint32_t)_isr23, 0x08, 0x8E);
- idt_set_gate(24, (uint32_t)_isr24, 0x08, 0x8E);
- idt_set_gate(25, (uint32_t)_isr25, 0x08, 0x8E);
- idt_set_gate(26, (uint32_t)_isr26, 0x08, 0x8E);
- idt_set_gate(27, (uint32_t)_isr27, 0x08, 0x8E);
- idt_set_gate(28, (uint32_t)_isr28, 0x08, 0x8E);
- idt_set_gate(29, (uint32_t)_isr29, 0x08, 0x8E);
- idt_set_gate(30, (uint32_t)_isr30, 0x08, 0x8E);
- idt_set_gate(31, (uint32_t)_isr31, 0x08, 0x8E);
-}
diff --git a/kernel/linker.ld b/kernel/linker.ld
deleted file mode 100644
index c032991..0000000
--- a/kernel/linker.ld
+++ /dev/null
@@ -1,45 +0,0 @@
-/* The bootloader will look at this image and start execution at the symbol
- designated as the entry point. */
-ENTRY(_start)
-
-/* Tell where the various sections of the object files will be put in the final
- kernel image. */
-SECTIONS
-{
- /* Begin putting sections at 1 MiB, a conventional place for kernels to be
- loaded at by the bootloader. */
- . = 1M;
-
- /* First put the multiboot header, as it is required to be put very early
- early in the image or the bootloader won't recognize the file format.
- Next we'll put the .text section. */
- .text BLOCK(4K) : ALIGN(4K)
- {
- *(.multiboot)
- *(.text)
- }
-
- /* Read-only data. */
- .rodata BLOCK(4K) : ALIGN(4K)
- {
- *(.rodata)
- }
-
- /* Read-write data (initialized) */
- .data BLOCK(4K) : ALIGN(4K)
- {
- *(.data)
- }
-
- /* Read-write data (uninitialized) and stack */
- .bss BLOCK(4K) : ALIGN(4K)
- {
- *(COMMON)
- *(.bss)
- *(.bootstrap_stack)
- }
-
- /* The compiler may produce other sections, by default it will put them in
- a segment with the same name. Simply add stuff here as needed. */
- link_mem_end = .;
-}
diff --git a/kernel/main.c b/kernel/main.c
index 76c62f8..540bdcc 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -266,7 +266,9 @@ static void keyhandler(const struct ps2_keyevent *ev)
putchar(toupper(ev->ascii));
}
else
+ {
putchar(ev->ascii);
+ }
}
}
diff --git a/kernel/paging-as.S b/kernel/paging-as.S
deleted file mode 100644
index cafaab4..0000000
--- a/kernel/paging-as.S
+++ /dev/null
@@ -1,9 +0,0 @@
- .global do_paging_enable
-do_paging_enable:
- movl 4(%esp), %eax # loads page directory address
- mov %eax, %cr3
- mov %cr0, %eax
- orl $0x80000000, %eax # set PG bit
- sti
- mov %eax, %cr0
- ret
diff --git a/kernel/paging.c b/kernel/paging.c
deleted file mode 100644
index 9d748ab..0000000
--- a/kernel/paging.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include "heap.h"
-#include "isr.h"
-#include "paging.h"
-#include "panic.h"
-
-uint32_t *current_directory;
-
-static void page_fault(struct regs_t *regs)
-{
- volatile uint32_t fault_addr;
- asm("mov %%cr2, %0" : "=r"(fault_addr));
- printf("=== Page Fault ===\n");
- printf("Faulting address: 0x%x\n", fault_addr);
- /* dump the regs */
- printf("EAX: 0x%x EBX: 0x%x\n", regs->eax, regs->ebx);
- printf("ECX: 0x%x EDX: 0x%x\n", regs->ecx, regs->edx);
- printf("ESP: 0x%x EBP: 0x%x\n", regs->esp, regs->ebp);
- printf("ESI: 0x%x EDI: 0x%x\n", regs->esi, regs->edi);
- printf("EIP: 0x%x\n", regs->eip);
- panic("Page fault!\n");
-}
-
- void paging_switch_directory(uint32_t *dir)
-{
- current_directory = dir;
- extern void do_paging_enable(uint32_t);
- do_paging_enable((uint32_t)current_directory);
-}
-
-static uint32_t *identity_map_table(uint32_t start, int flags)
-{
- /* make a page table */
- uint32_t *table = kmalloc_a(0x1000);
- /* identity map 4MB */
- for(uint32_t i = start; i < start + 1024; ++i)
- {
- table[i - start] = (i * PAGE_SIZE) | flags;
- }
- return table;
-}
-
-void paging_init(void)
-{
- uint32_t *kernel_directory = kmalloc_a(0x1000);
- memset(kernel_directory, 0, 0x1000);
- /* blank the kernel directory */
- for(int i = 0; i < 1024; ++i)
- {
- kernel_directory[i] = PAGE_RW;
- }
-
- /* identity map all 4GB (and allocate all page tables) */
- for(int i = 0; i < 1024; ++i)
- kernel_directory[i] = (uint32_t)identity_map_table(i * 1024, PAGE_PRESENT | PAGE_RW) |
- PAGE_PRESENT | PAGE_RW;
-
- set_interrupt_handler(14, page_fault);
-
- paging_switch_directory(kernel_directory);
-}
diff --git a/kernel/ssp.c b/kernel/ssp.c
deleted file mode 100644
index ad47bb4..0000000
--- a/kernel/ssp.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdint.h>
-#include "panic.h"
-
-#if UINT32_MAX == UINTPTR_MAX
-#define STACK_CHK_GUARD 0xdeadbeef
-#else
-#define STACK_CHK_GUARD 0x0ddc0ffeebadf00d
-#endif
-
-uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
-
-__attribute__((noreturn)) void __stack_chk_fail(void)
-{
-#if __STDC_HOSTED__
- abort();
-#else
- panic("Stack smashing detected");
-#endif
-}