~ubuntu-branches/ubuntu/hardy/kvm/hardy-backports

« back to all changes in this revision

Viewing changes to user/test/irq.S

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-11-15 02:21:55 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20071115022155-pxoxb8kfcrkn72mi
Tags: 1:52+dfsg-0ubuntu1
* New upstream release.
* 08_default_tdf.patch
  - Make -tdf the default and add a -no-tdf option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// irq test program.  assumes outb $irq, $0xff generates an interrupt $irq.
2
 
 
3
 
#include "print.h"
4
 
        
5
 
.text
6
 
        PRINT "irq test"
7
 
        mov $stack_top, %rsp
8
 
 
9
 
        call setup_gdt
10
 
        
11
 
        mov %ds, %ax
12
 
        mov %ax, %ds  // check ds descriptor is okay
13
 
 
14
 
        mov $irq_handler, %rdx
15
 
        mov $0x20, %eax
16
 
        call setup_idt_entry
17
 
 
18
 
        lidt idt_descriptor
19
 
 
20
 
        PRINT "software interrupt"
21
 
        int $0x20
22
 
 
23
 
        sti
24
 
        nop
25
 
 
26
 
        PRINT "injecting interrupt with interrupts enabled"
27
 
        
28
 
        mov $0x20, %al
29
 
        outb %al, $0xff // inject interrupt
30
 
 
31
 
        nop
32
 
        nop
33
 
        nop
34
 
        PRINT "after injection"
35
 
 
36
 
        cli
37
 
 
38
 
        PRINT "injecting interrupt with interrupts disabled"
39
 
        
40
 
        mov $0x20, %al
41
 
        outb %al, $0xff // inject interrupt
42
 
 
43
 
        // no interrupt here (disabled)
44
 
        nop
45
 
        nop
46
 
        PRINT "enabling interrupts"
47
 
        nop
48
 
        nop
49
 
        sti
50
 
        out %al, $0x80 // blocked by sti
51
 
        // interrupt here
52
 
        out %al, $0x80 
53
 
 
54
 
        PRINT "after injection"
55
 
        nop
56
 
        nop
57
 
        
58
 
        hlt
59
 
        
60
 
irq_handler:
61
 
        PRINT "interrupt handler"
62
 
        iretq
63
 
        
64
 
setup_idt_entry:        // %rax: irq %rdx: handler
65
 
        shl $4, %rax
66
 
        mov %dx, idt(%rax)
67
 
        shr $16, %rdx
68
 
        mov %cs, 2+idt(%rax)
69
 
        mov %dx, 6+idt(%rax)
70
 
        shr $16, %rdx
71
 
        mov %edx, 8+idt(%rax)
72
 
        movw $0x8e00, 4+idt(%rax)
73
 
        ret
74
 
 
75
 
setup_gdt:
76
 
        mov $0, %eax
77
 
        mov %cs, %ax
78
 
        andl $~7, %eax
79
 
        movl $0xffff, gdt(%rax)
80
 
        movl $0xaf9b00, 4+gdt(%rax)
81
 
 
82
 
        mov $0, %eax
83
 
        mov %ds, %ax
84
 
        andl $~7, %eax
85
 
        movl $0xffff, gdt(%rax)
86
 
        movl $0x8f9300, 4+gdt(%rax)
87
 
 
88
 
        lgdt gdt_descriptor
89
 
        ret
90
 
        
91
 
.data
92
 
        
93
 
.align 16
94
 
 
95
 
idt:    
96
 
        . = . + 256 * 16
97
 
 
98
 
idt_descriptor:
99
 
        .word . - idt - 1
100
 
        .quad idt
101
 
 
102
 
.align 8
103
 
        
104
 
gdt:
105
 
        . = . + 256 * 8
106
 
 
107
 
gdt_descriptor:
108
 
        .word . - gdt - 1
109
 
        .quad gdt 
110
 
 
111
 
        
112
 
.align 4096
113
 
stack_base:
114
 
        . = . + 4096
115
 
stack_top:
116
 
        
117
 
 
118