-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_up.s
102 lines (87 loc) · 1.72 KB
/
set_up.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# vim:tabstop=8 shiftwidth=8
#file: set_up.s
#author: bughou@gmail.com
#last modified: 2009.12.17
#function:
# 1. initialise the segment registers and global varibles
# in protected mode.
# 2. rearrange 8259A interrupt vectors.
# 3. initialise 8354 timer.
# 4. enalbe interrupt.
#note:
# 1. this file is loaded at 0x7e00.
# 2. this is the first file starts to run in protected mode.
# 3. the 'ld' prameter '-Ttext' should be 0x7e00.
.include "header.s"
.text
.global _start
_start:
#now,we have got into protected mode!
mov $KERNEL_DATA_SELECTOR,%eax
mov %eax,%ds
mov %eax,%es
mov %eax,%ss
mov %eax,%fs
mov %eax,%gs
mov $0x9fc00,%esp
movl $(0xb8000+(80+40)*2),CURSOR #CGA buffer address.
movl $0x00,TICK
movb $0 ,TICK100
#rearrange default 8259A interrupt vectors to 0x20~0x2f!
mov $0x11,%al #ICW1
outb $0x20
.long DELAY
outb $0xa0
.long DELAY
mov $0x20,%al #ICW2
outb $0x21
.long DELAY
mov $0x28,%al
outb $0xa1
.long DELAY
mov $0x04,%al #ICW3
outb $0x21
.long DELAY
mov $0x02,%al
outb $0xa1
.long DELAY
mov $0x01,%al #ICW4
outb $0x21
.long DELAY
outb $0xa1
.long DELAY
mov $0xff,%al #OCW1 mask interrupt request.
outb $0x21
.long DELAY
outb $0xa1
#initialise 8254 timer0!
mov $0x36,%al
outb $0x43
mov $(1193180*2/HZ)&0xff,%al
outb $0x40
mov $(1193180*2/HZ)>>0x08,%al
outb $0x40
mov $0xf8,%al
outb $0x21
#mov $0xbf,%al
#outb $0xa1
sti
mov $str0,%esi
mov $0xb8000,%edi
int $0x30
mov $str1,%esi
mov $(0xb8000+40*2),%edi
int $0x30
mov $str2,%esi
mov $(0xb8000+80*2),%edi
int $0x30
1: hlt
jmp 1b
########################data######################
str0:
.asciz "timer0 interrupt test:"
str1:
.asciz "00000000:00"
str2:
.asciz "keyboard interrupt test:"
.org 0x600