putch + broken interrupt handlers
int handlers only break when ran
This commit is contained in:
parent
677c53165d
commit
c4bae42dd9
22
interrupts.c
22
interrupts.c
@ -79,11 +79,10 @@ void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs) {
|
||||
|
||||
void int_keyboard(struct cpu_reg_state* cpu) {
|
||||
// Get the keycode from the serial buffer
|
||||
u8 buf[5];
|
||||
memset(buf, 0x00, 5);
|
||||
u8 scancode = serial_read_buffer(0x60);
|
||||
buf[0] = scancode;
|
||||
printf((char*)buf);
|
||||
char code = serial_read_buffer(0x60);
|
||||
if((u8)code < 0x80 || (u8)code > 0x1f) {
|
||||
putch(code);
|
||||
}
|
||||
serial_pic_ack(cpu->int_no);
|
||||
}
|
||||
|
||||
@ -91,11 +90,12 @@ void int_keyboard(struct cpu_reg_state* cpu) {
|
||||
void interrupt_handler(struct cpu_reg_state cpu) {
|
||||
// treating things on the stack like it were a cpu_reg_state
|
||||
// NOTE: dummy stuff to stop gcc from complaining atm
|
||||
switch(cpu.int_no) {
|
||||
case(i_Keyboard): {
|
||||
// keyboard interrupt handler gets the stuff now
|
||||
int_keyboard(&cpu);
|
||||
}
|
||||
if(cpu.int_no < 32) {
|
||||
printf("int response is:\n");
|
||||
printf(err_msg[cpu.int_no]);
|
||||
}
|
||||
else {
|
||||
printf("Unhandled exception");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -120,7 +120,7 @@ void init_idt() {
|
||||
setup_idt_entry(8,(u32)no_err_handler_9,0x08, 0x8e);
|
||||
|
||||
setup_idt_entry(9,(u32)err_code_handler_10,0x08, 0x8e);
|
||||
setup_idt_entry(0,(u32)err_code_handler_11,0x08, 0x8e);
|
||||
setup_idt_entry(10,(u32)err_code_handler_11,0x08, 0x8e);
|
||||
setup_idt_entry(11,(u32)err_code_handler_12,0x08, 0x8e);
|
||||
setup_idt_entry(12,(u32)err_code_handler_13,0x08, 0x8e);
|
||||
setup_idt_entry(13,(u32)err_code_handler_14,0x08, 0x8e);
|
||||
|
3
kernel.c
3
kernel.c
@ -2,10 +2,13 @@
|
||||
#include "types.h"
|
||||
#include "tests.h"
|
||||
#include "interrupts.h"
|
||||
#include "stlio.h"
|
||||
#include "gdt.h"
|
||||
|
||||
void kinit() {
|
||||
printf("setting up gdt\n");
|
||||
gdt_configure();
|
||||
printf("setting idt\n");
|
||||
init_idt();
|
||||
test_dispatcher();
|
||||
}
|
||||
|
3
stlio.c
3
stlio.c
@ -49,3 +49,6 @@ void printf(const char* fmt) {
|
||||
}
|
||||
}
|
||||
|
||||
void putch(const char c) {
|
||||
write_char(c);
|
||||
}
|
1
stlio.h
1
stlio.h
@ -11,3 +11,4 @@ u32 read(const u32);
|
||||
|
||||
void printf(const char*);
|
||||
|
||||
void putch(const char);
|
26
tests.c
26
tests.c
@ -3,17 +3,29 @@
|
||||
#include "tests.h"
|
||||
#include "serial.h"
|
||||
|
||||
void test_write() {
|
||||
clear_fb();
|
||||
char* msg1 = "Writing this to fbout\n";
|
||||
char* serial1 = "0123456789abcdef0123456789abcdef";
|
||||
char* msg2 = "serial write has finished";
|
||||
void divide_by_zero() {
|
||||
// here we can test the divide by zero without gcc noticing
|
||||
int x = 0;
|
||||
int y = 5;
|
||||
int z = y/x;
|
||||
if(z) {
|
||||
printf("hmm\n");
|
||||
}
|
||||
}
|
||||
|
||||
printf(msg1);
|
||||
void test_serial_write() {
|
||||
char* serial1 = "0123456789abcdef0123456789abcdef";
|
||||
serial_write(serial1, strlen(serial1));
|
||||
printf(msg2);
|
||||
printf("serial test write finished\n");
|
||||
}
|
||||
|
||||
void test_write() {
|
||||
char* msg1 = "Writing to fbout\n";
|
||||
printf(msg1);
|
||||
}
|
||||
|
||||
void test_dispatcher() {
|
||||
clear_fb();
|
||||
test_write();
|
||||
divide_by_zero();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user