Code: Select all
asm volatile ("int $0x3");
asm volatile ("int $0x4");
My kernel code
Code: Select all
#include "utils/system.h"
#include "utils/print.h"
#include "cpu/gdt.h"
#include "cpu/idt.h"
void kernel_main()
{
init_video();
init_gdt();
init_idt();
/* Test our interrupt handlers */
asm volatile ("int $0x3");
asm volatile ("int $0x4");
puts("Hello World");
for (;;);
}
Code: Select all
void putn(uint32_t n)
{
if (n == 0)
{
putch('0');
return;
}
int32_t acc = n;
char c[32];
int i = 0;
while (acc > 0)
{
c[i] = '0' + acc%10;
acc /= 10;
i++;
}
c[i] = 0;
char c2[32];
c2[i--] = 0;
int j = 0;
while(i >= 0)
{
c2[i--] = c[j++];
}
puts(c2);
}
Code: Select all
typedef struct
{
uint32_t ds;
uint32_t edi, esi, esp, ebx, edx, ecx, eax;
uint32_t int_num, err_code;
uint32_t eip, cs, eflags, useresp, ss;
} __attribute__((packed)) registers_t;
void isr_handler(registers_t regs);
Code: Select all
void isr_handler(registers_t regs)
{
puts("Recieved interrupt: ");
puth(regs.int_num);
putch('\n');
}