Merge into main the new state of the operating system/kernel #1
@ -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
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user