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