diff options
Diffstat (limited to 'asm/asm_pit.s')
| -rw-r--r-- | asm/asm_pit.s | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/asm/asm_pit.s b/asm/asm_pit.s index 8e16d0b..8be29cb 100644 --- a/asm/asm_pit.s +++ b/asm/asm_pit.s @@ -1,7 +1,16 @@ -.global asm_pit_init .global asm_pit_tick .global asm_pit_get_ticks +.global asm_pit_sleep_50ms +.global asm_pit_sleep_40ms +.global asm_pit_sleep_10ms +.global asm_pit_sleep_1ms + +.global asm_pit_rate_50ms +.global asm_pit_rate_40ms +.global asm_pit_rate_10ms +.global asm_pit_rate_1ms + ticks: .int 0 @@ -22,19 +31,62 @@ asm_pit_tick: ret -asm_pit_init: +.macro asm_pit_rate val - // configure ticking 25 times a second - // 1193180 / 25 = 47727.2 - mov $47727, %dx - mov $0b00110100, %al + mov $0b00110100, %al // chan 0 / mode 2 outb %al,$0x43 - mov %dx,%ax + // LSB first + mov \val, %dx + out %al, $0x40 + xchg %ah,%al + out %al, $0x40 + + ret + +.endm + +.macro asm_pit_sleep val + mov $0x00110000, %al // chan 0 / mode 0 + outb %al,$0x43 + + // LSB first + mov \val, %ax out %al, $0x40 xchg %ah,%al out %al, $0x40 + + // check if finished + mov $0xE2, %al + outb %al,$0x43 + + //sleep until finished + //7th bit determines if finished + sleep\val: + inb $0x40, %al + or $0b1000000, %al + cmp $0b1000000, %al + jne sleep\val ret + +.endm + +/* decrements at 1.193182Mhz +0xE90B // 50ms - 20 Hz +0xBA6F // 40ms - 25 Hz +0x2E9C // 10ms - 100 Hz +0x04A9 // 1ms - 1000 Hz +*/ + +asm_pit_sleep_50ms: asm_pit_sleep $0xE90B +asm_pit_sleep_40ms: asm_pit_sleep $0xBA6F +asm_pit_sleep_10ms: asm_pit_sleep $0x2E9C +asm_pit_sleep_1ms: asm_pit_sleep $0x04A9 + +asm_pit_rate_50ms: asm_pit_rate $0xE90B +asm_pit_rate_40ms: asm_pit_rate $0xBA6F +asm_pit_rate_10ms: asm_pit_rate $0x2E9C +asm_pit_rate_1ms: asm_pit_rate $0x04A9 |
