Compare commits
2 Commits
595a7d5163
...
59bcc17668
Author | SHA1 | Date | |
---|---|---|---|
59bcc17668 | |||
5f50f8c013 |
@ -273,116 +273,140 @@ irs31:
|
|||||||
irq0:
|
irq0:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $32
|
push $0
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq1
|
.globl irq1
|
||||||
irq1:
|
irq1:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $33
|
push $1
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq2
|
.globl irq2
|
||||||
irq2:
|
irq2:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $34
|
push $2
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq3
|
.globl irq3
|
||||||
irq3:
|
irq3:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $35
|
push $3
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq4
|
.globl irq4
|
||||||
irq4:
|
irq4:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $36
|
push $4
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq5
|
.globl irq5
|
||||||
irq5:
|
irq5:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $37
|
push $5
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq6
|
.globl irq6
|
||||||
irq6:
|
irq6:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $38
|
push $6
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq7
|
.globl irq7
|
||||||
irq7:
|
irq7:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $39
|
push $7
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq8
|
.globl irq8
|
||||||
irq8:
|
irq8:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $40
|
push $8
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq9
|
.globl irq9
|
||||||
irq9:
|
irq9:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $41
|
push $9
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq10
|
.globl irq10
|
||||||
irq10:
|
irq10:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $42
|
push $10
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq11
|
.globl irq11
|
||||||
irq11:
|
irq11:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $43
|
push $11
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
|
|
||||||
.globl irq12
|
.globl irq12
|
||||||
irq12:
|
irq12:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $44
|
push $12
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq13
|
.globl irq13
|
||||||
irq13:
|
irq13:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $45
|
push $13
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq14
|
.globl irq14
|
||||||
irq14:
|
irq14:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $46
|
push $14
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
.globl irq15
|
.globl irq15
|
||||||
irq15:
|
irq15:
|
||||||
cli
|
cli
|
||||||
push $0
|
push $0
|
||||||
push $47
|
push $15
|
||||||
jmp irs_common
|
jmp irq_common
|
||||||
|
|
||||||
|
irq_common:
|
||||||
|
pusha
|
||||||
|
|
||||||
|
mov %ds, %ax
|
||||||
|
push %eax
|
||||||
|
|
||||||
|
mov $0x10, %ax
|
||||||
|
mov %ax, %ds
|
||||||
|
mov %ax, %es
|
||||||
|
mov %ax, %fs
|
||||||
|
mov %ax, %gs
|
||||||
|
|
||||||
|
call irq_handler
|
||||||
|
|
||||||
|
pop %eax
|
||||||
|
|
||||||
|
mov %ax, %ds
|
||||||
|
mov %ax, %es
|
||||||
|
mov %ax, %fs
|
||||||
|
mov %ax, %gs
|
||||||
|
|
||||||
|
popa
|
||||||
|
add $8, %esp # cleans push error and irs code
|
||||||
|
sti
|
||||||
|
iret # pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP
|
||||||
|
|
||||||
|
|
||||||
irs_common:
|
irs_common:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "idt.h"
|
#include "idt.h"
|
||||||
|
#include "Scancodes.h"
|
||||||
|
|
||||||
IDT_entry idt_table[256];
|
IDT_entry idt_table[256];
|
||||||
IDT_ptr idt_ptr;
|
IDT_ptr idt_ptr;
|
||||||
@ -17,7 +17,7 @@ void set_id_entry (uint8_t num , uint32_t base, uint16_t sel, uint8_t flags){
|
|||||||
void irs_handler (registers regs) {
|
void irs_handler (registers regs) {
|
||||||
kterm_writestring("received interrupt!\n");
|
kterm_writestring("received interrupt!\n");
|
||||||
|
|
||||||
printf(" Interrupt number: %d \n", regs.int_no);
|
printf("(IRS) Interrupt number: %d \n", regs.int_no);
|
||||||
|
|
||||||
if( regs.int_no == 13){
|
if( regs.int_no == 13){
|
||||||
printf(" Error code: %d \n", regs.err_code);
|
printf(" Error code: %d \n", regs.err_code);
|
||||||
@ -28,6 +28,52 @@ void irs_handler (registers regs) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void irq_handler (registers regs) {
|
||||||
|
|
||||||
|
|
||||||
|
if ( regs.int_no != 0) {
|
||||||
|
kterm_writestring("received interrupt!\n");
|
||||||
|
printf("(IRQ) Interrupt number: %d \n", regs.int_no);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( regs.int_no == 1 ){
|
||||||
|
// Keyboard interrupt !!
|
||||||
|
|
||||||
|
int scan;
|
||||||
|
register int i;
|
||||||
|
|
||||||
|
// Read scancode
|
||||||
|
|
||||||
|
scan = inb(0x60);
|
||||||
|
|
||||||
|
// Send ack message!
|
||||||
|
i = inb(0x61);
|
||||||
|
outb(0x61, i|0x80);
|
||||||
|
outb(0x61, i);
|
||||||
|
kterm_writestring("A key was pressed/released\n");
|
||||||
|
printf( "Scancode: %x\n", scan);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
outb(0x20, 0x20); // send end of interrupt to master
|
||||||
|
|
||||||
|
if ( regs.int_no > 8 && regs.int_no <= 15) {
|
||||||
|
outb(0xA0, 0x20); // send end of interrupt to slave
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( regs.int_no == 13){
|
||||||
|
printf(" Error code: %d \n", regs.err_code);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +85,7 @@ void init_idt(){
|
|||||||
|
|
||||||
// TODO: Set everything to zero first
|
// TODO: Set everything to zero first
|
||||||
|
|
||||||
set_id_entry(0, (uint32_t) irs0 , 0x08, 0x8E);
|
set_id_entry(0, (uint32_t) irs0 , 0x08, 0x8F);
|
||||||
set_id_entry(1, (uint32_t) irs1 , 0x08, 0x8E);
|
set_id_entry(1, (uint32_t) irs1 , 0x08, 0x8E);
|
||||||
set_id_entry(2, (uint32_t) irs2 , 0x08, 0x8E);
|
set_id_entry(2, (uint32_t) irs2 , 0x08, 0x8E);
|
||||||
set_id_entry(3, (uint32_t) irs3 , 0x08, 0x8E);
|
set_id_entry(3, (uint32_t) irs3 , 0x08, 0x8E);
|
||||||
|
@ -140,18 +140,17 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
/** test interrupt handlers **/
|
/** test interrupt handlers **/
|
||||||
asm volatile ("int $0x03");
|
//asm volatile ("int $0x03");
|
||||||
|
|
||||||
asm volatile ("int $4");
|
//asm volatile ("int $0x04");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (true){
|
while (true){
|
||||||
// Read time indefinetely
|
//Read time indefinetely
|
||||||
read_rtc();
|
read_rtc();
|
||||||
printf( "UTC time: %2d-%2d-%2d %2d:%2d:%2d : (YY-MM-DD h:mm:ss)\r" ,year, month, day, hour, minute, second);
|
printf( "UTC time: %2d-%2d-%2d %2d:%2d:%2d : (YY-MM-DD h:mm:ss)\r" ,year, month, day, hour, minute, second);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Lets start using the serial port for debugging .. **/
|
/** Lets start using the serial port for debugging .. **/
|
||||||
// Hopefully once we go into realmode or do something that
|
// Hopefully once we go into realmode or do something that
|
||||||
|
Loading…
x
Reference in New Issue
Block a user