From ed16fe92e0ad5d56b528165e3c93bb3bc69e7056 Mon Sep 17 00:00:00 2001 From: Asias He Date: Tue, 8 Jun 2010 20:46:50 +0800 Subject: [PATCH] kvm, test: add PIT 8254 and PIC 8259 test code 8254 ticks at 100HZ. Signed-off-by: Asias He Signed-off-by: Pekka Enberg --- tools/kvm/tests/kernel/tick.S | 79 +++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tools/kvm/tests/kernel/tick.S diff --git a/tools/kvm/tests/kernel/tick.S b/tools/kvm/tests/kernel/tick.S new file mode 100644 index 000000000000..33be9e205660 --- /dev/null +++ b/tools/kvm/tests/kernel/tick.S @@ -0,0 +1,79 @@ +#define IO_PIC 0x20 +#define IRQ_OFFSET 32 +#define IO_PIT 0x40 +#define TIMER_FREQ 1193182 +#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x)) + + .code16gcc + .text + .globl _start + .type _start, @function +_start: + mov $0x3f8,%dx + cs lea msg, %si + mov $(msg_end-msg), %cx + cs rep/outsb + +set_idt: + xor %ax, %ax + movw %ax, %es + movw $timer_isr, %es:(IRQ_OFFSET*4) + movw %cs, %es:(IRQ_OFFSET*4+2) + +set_pic: + # ICW1 + mov $0x11, %al + mov $(IO_PIC), %dx + out %al,%dx + # ICW2 + mov $(IRQ_OFFSET), %al + mov $(IO_PIC+1), %dx + out %al, %dx + # ICW3 + mov $0x00, %al + mov $(IO_PIC+1), %dx + out %al, %dx + # ICW4 + mov $0x3, %al + mov $(IO_PIC+1), %dx + out %al, %dx + +set_pit: + # set 8254 mode + mov $(IO_PIT+3), %dx + mov $0x34, %al + outb %al, %dx + # set 8254 freq 100Hz + mov $(IO_PIT), %dx + movb $(TIMER_DIV(100) % 256), %al + outb %al, %dx + movb $(TIMER_DIV(100) / 256), %al + outb %al, %dx + +enable_irq0: + mov $0xfe, %al + mov $(IO_PIC+1), %dx + out %al, %dx + sti +loop: + 1: + jmp 1b + +timer_isr: + pushaw + mov $0x3f8,%dx + mov $0x49, %al # I + out %al,%dx + mov $0x53, %al # S + out %al,%dx + mov $0x52, %al # R + out %al,%dx + mov $0x0a, %al # \n + out %al, %dx + popaw + iretw + +msg: + .ascii "This is PVM.\nPIC 8259 and PIT 8254 test.\n" + .asciz "---------------------------------------------------\n" +msg_end: -- 2.39.5