diff options
| author | Miguel <m.i@gmx.at> | 2018-08-21 01:24:14 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-08-21 01:24:14 +0200 |
| commit | 8a5fbdabb24250a76feed770bce64d7e3e4f61de (patch) | |
| tree | 4e2aa197e160357a68dbf1d7b3853963b7f1caac /asm/pit.s | |
| parent | 690403fc51ecb51689cb72f224fccc0d301b7f7d (diff) | |
adding new pit code
Diffstat (limited to 'asm/pit.s')
| -rw-r--r-- | asm/pit.s | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/asm/pit.s b/asm/pit.s new file mode 100644 index 0000000..ab8dcdb --- /dev/null +++ b/asm/pit.s @@ -0,0 +1,59 @@ +.global pit_init +.global pit_interrupt_handler +.global pit_get_ticks + +ticks: +.int 0 + +pit_get_ticks: + + mov (ticks),%eax + ret + +pit_interrupt_handler: + + // increase tick counter + push %eax + mov $ticks, %eax + incl (%eax) + pop %eax + + //// + + pusha //Push all standard registers + + mov %esp, %eax //save current stack pointer (pointing to registers!) + + movl $stack_top, %esp //use stack from multiboot.s(16Kb) + + // call our scheduler passing it the old stack addres (pointing to pushed registers (pusha)) + push %eax + call task_switch_next + + // the scheduler returned the new stack pointer (after taskswitch) + mov %eax, %esp //Replace the stack with what the C code gave us + + // acknowlege irq + mov $0x20,%al + out %al,$0x20 + + popa //Put the standard registers back + + iret + +pit_init: + + // configure ticking 25 times a second + // 1193180 / 25 = 47727.2 + mov $47727, %dx + + mov $0b00110100, %al + outb %al,$0x43 + + mov %dx,%ax + + out %al, $0x40 + xchg %ah,%al + out %al, $0x40 + + ret |
