Moved interrupt handling to subdir
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,7 +1,7 @@
|
|||||||
bin/*
|
|
||||||
src/*.o
|
|
||||||
quark.iso
|
quark.iso
|
||||||
src/*~
|
src/quark-kernel
|
||||||
|
src/interrupts/libinterrupts.a
|
||||||
|
*.o
|
||||||
*~
|
*~
|
||||||
rootfs
|
rootfs/
|
||||||
test/
|
test/
|
||||||
27
Makefile
27
Makefile
@@ -1,27 +1,14 @@
|
|||||||
objs = src/addressspace.o src/tty.o src/buddyallocator.o src/math.o \
|
|
||||||
src/cstring.o src/pagetableentry.o src/multiboot2header.o \
|
|
||||||
src/systeminfo.o src/memorymap.o src/interruptdescriptor.o \
|
|
||||||
src/inthandlers.o src/pio.o src/entry.o src/quarkkernel.o
|
|
||||||
link_script = src/linker.ld
|
|
||||||
quark_bin = qkernel
|
|
||||||
quark_img = quark.iso
|
|
||||||
|
|
||||||
CXX = i686-elf-g++
|
|
||||||
CC = i686-elf-gcc
|
|
||||||
|
|
||||||
CPPFLAGS = -ffreestanding -mgeneral-regs-only -O0 -Wall -fno-exceptions -fno-rtti -ggdb
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(quark_img)
|
all: quark.iso
|
||||||
|
|
||||||
$(quark_img): bin/$(quark_bin) rootfs/boot/grub/grub.cfg
|
quark.iso: src/quark-kernel
|
||||||
cp bin/$(quark_bin) rootfs/apps
|
cp src/quark-kernel rootfs/apps
|
||||||
grub-mkrescue -o $@ rootfs
|
grub-mkrescue -o $@ rootfs
|
||||||
|
|
||||||
bin/$(quark_bin): $(objs) $(link_script)
|
src/quark-kernel:
|
||||||
mkdir -p bin/
|
make -C src
|
||||||
$(CXX) -o $@ -T $(link_script) -ffreestanding -nostdlib -O0 $(objs) -lgcc
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f $(objs) bin/$(quark_bin) $(quark_img)
|
make -C src clean
|
||||||
|
rm -f quark.iso
|
||||||
|
|||||||
18
src/Makefile
Normal file
18
src/Makefile
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
objs = addressspace.o tty.o buddyallocator.o math.o cstring.o pagetableentry.o multiboot2header.o systeminfo.o memorymap.o pio.o entry.o quarkkernel.o
|
||||||
|
|
||||||
|
CXX = i686-elf-g++
|
||||||
|
CC = i686-elf-gcc
|
||||||
|
|
||||||
|
CXXFLAGS = -ffreestanding -mgeneral-regs-only -O0 -Wall -fno-exceptions -fno-rtti -ggdb
|
||||||
|
LDFLAGS = -T linker.ld -lgcc -nostdlib
|
||||||
|
|
||||||
|
quark-kernel: $(objs) linker.ld interrupts/libinterrupts.a
|
||||||
|
$(CXX) -o $@ $(LDFLAGS) interrupts/libinterrupts.a $(objs)
|
||||||
|
|
||||||
|
interrupts/libinterrupts.a:
|
||||||
|
make -C interrupts CXX="$(CXX)" CC="$(CC)" CXXFLAGS="$(CXXFLAGS)"
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
make -C interrupts clean
|
||||||
|
rm -f $(objs) quark-kernel
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
.section .multiboot
|
.section .multiboot
|
||||||
.include "src/multiboot2header.S"
|
.include "multiboot2header.S"
|
||||||
|
|
||||||
.section .rodata
|
.section .rodata
|
||||||
|
|
||||||
|
|||||||
9
src/interrupts/Makefile
Normal file
9
src/interrupts/Makefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
objs = x86/inthandlers.o x86/interruptdescriptor.o x86/idt.o x86/interrupts.o
|
||||||
|
archive = libinterrupts.a
|
||||||
|
|
||||||
|
$(archive): $(objs)
|
||||||
|
i686-elf-ar rcs $@ $^
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -f $(archive) $(objs)
|
||||||
19
src/interrupts/interrupts.hpp
Normal file
19
src/interrupts/interrupts.hpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef INTERRUPTS_H
|
||||||
|
#define INTERRUPTS_H
|
||||||
|
|
||||||
|
namespace kernel
|
||||||
|
{
|
||||||
|
class Interrupts
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Interrupts();
|
||||||
|
|
||||||
|
void enable();
|
||||||
|
|
||||||
|
void disable();
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
21
src/interrupts/x86/idt.S
Normal file
21
src/interrupts/x86/idt.S
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
.section .bss
|
||||||
|
|
||||||
|
.align 8
|
||||||
|
.global idt
|
||||||
|
idt:
|
||||||
|
.skip 8 * 256
|
||||||
|
idt_end:
|
||||||
|
|
||||||
|
.section .rodata
|
||||||
|
|
||||||
|
.idt_info:
|
||||||
|
.short idt_end - idt - 1
|
||||||
|
.long idt
|
||||||
|
|
||||||
|
.section .text
|
||||||
|
|
||||||
|
.global _lidt
|
||||||
|
.type _lidt, @function
|
||||||
|
_lidt:
|
||||||
|
|
||||||
|
ret
|
||||||
10
src/interrupts/x86/idt.hpp
Normal file
10
src/interrupts/x86/idt.hpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef IDT_H
|
||||||
|
#define IDT_H
|
||||||
|
|
||||||
|
#include "interruptdescriptor.hpp"
|
||||||
|
|
||||||
|
extern kernel::InterruptDescriptor idt[256];
|
||||||
|
|
||||||
|
extern "C" void _lidt();
|
||||||
|
|
||||||
|
#endif
|
||||||
19
src/interrupts/x86/interrupts.cpp
Normal file
19
src/interrupts/x86/interrupts.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "../interrupts.hpp"
|
||||||
|
#include "idt.hpp"
|
||||||
|
|
||||||
|
kernel::Interrupts::Interrupts()
|
||||||
|
{
|
||||||
|
// Load interrupt handlers
|
||||||
|
// Configure PIC
|
||||||
|
_lidt();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void kernel::Interrupts::enable()
|
||||||
|
{
|
||||||
|
asm("sti");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void kernel::Interrupts::disable()
|
||||||
|
{
|
||||||
|
asm("cli");
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ void divisionByZero(void* frame)
|
|||||||
display += 2;
|
display += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
__attribute__ ((interrupt))
|
__attribute__ ((interrupt))
|
||||||
void gpFaultHandler(void* frame, unsigned int error)
|
void gpFaultHandler(void* frame, unsigned int error)
|
||||||
{
|
{
|
||||||
@@ -6,8 +6,6 @@
|
|||||||
#include "memorymap.hpp"
|
#include "memorymap.hpp"
|
||||||
#include "buddyallocator.hpp"
|
#include "buddyallocator.hpp"
|
||||||
#include "addressspace.hpp"
|
#include "addressspace.hpp"
|
||||||
#include "interruptdescriptor.hpp"
|
|
||||||
#include "inthandlers.hpp"
|
|
||||||
#include "pio.hpp"
|
#include "pio.hpp"
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
|
||||||
@@ -15,7 +13,6 @@ using namespace kernel;
|
|||||||
|
|
||||||
extern SystemInfo system_info;
|
extern SystemInfo system_info;
|
||||||
extern MemoryMap::Region memory_map;
|
extern MemoryMap::Region memory_map;
|
||||||
extern InterruptDescriptor idt;
|
|
||||||
|
|
||||||
extern "C" void __cxa_pure_virtual()
|
extern "C" void __cxa_pure_virtual()
|
||||||
{
|
{
|
||||||
@@ -39,14 +36,7 @@ void main(char* cmdline)
|
|||||||
BuddyAllocator alloc(memmap, (char*) 0xC0000000, system_info.getHighMemory() / 4 + 256, 6);
|
BuddyAllocator alloc(memmap, (char*) 0xC0000000, system_info.getHighMemory() / 4 + 256, 6);
|
||||||
AddressSpace vmem(alloc);
|
AddressSpace vmem(alloc);
|
||||||
vmem.mmap((void*) 0x80000000, 0x10000);
|
vmem.mmap((void*) 0x80000000, 0x10000);
|
||||||
InterruptDescriptor* interruptTable = &idt;
|
|
||||||
interruptTable[0] = InterruptDescriptor((void*) &divisionByZero, InterruptDescriptor::INT32, 0);
|
|
||||||
interruptTable[8] = InterruptDescriptor((void*) &doubleFaultHandler, InterruptDescriptor::INT32, 0);
|
|
||||||
interruptTable[14] = InterruptDescriptor((void*) &pageFaultHandler, InterruptDescriptor::INT32, 0);
|
|
||||||
//for(int i = 1; i < 32; i++)
|
|
||||||
// interruptTable[i] = InterruptDescriptor((void*) &pageFaultHandler, InterruptDescriptor::INT32, 0);
|
|
||||||
outb(0xa1, 0xff);
|
outb(0xa1, 0xff);
|
||||||
outb(0x21, 0xff);
|
outb(0x21, 0xff);
|
||||||
asm("sti");
|
|
||||||
tty << "Nothing left to do. Hanging.\n";
|
tty << "Nothing left to do. Hanging.\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user