-
Notifications
You must be signed in to change notification settings - Fork 7
/
head.s
169 lines (140 loc) · 2.8 KB
/
head.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
.equ BOTPAK, 0x00280000
.equ DSKCAC, 0x00100000
.equ DSKCAC0, 0x00008000
.equ VBEMODE, 0x101
.equ CYLS, 0x0ff0
.equ LEDS, 0x0ff1
.equ VMODE, 0x0ff2
.equ SCRNX, 0x0ff4
.equ SCRNY, 0x0ff6
.equ VRAM, 0x0ff8
.text
.code16
head:
# VBE存在確認
movw $0x9000, %ax
movw %ax, %es
movw $0x00, %di
movw $0x4f00, %ax
int $0x10
cmpw $0x004f, %ax
jne scrn320
# VBEのバージョンチェック
movw %es:4(%di), %ax
cmpw $0x0200, %ax
jb scrn320
# 画面モード情報を得る
movw $VBEMODE, %cx
movw $0x4f01, %ax
int $0x10
cmp $0x004f, %ax
jne scrn320
# 画面モード情報の確認
cmpb $0x08, %es:0x19(%di)
jne scrn320
cmpb $0x04, %es:0x1b(%di)
jne scrn320
movw %es:0x00(%di), %ax
andw $0x0080, %ax
jz scrn320
# 画面モードの切り替え
movw $VBEMODE+0x4000, %bx
movw $0x4f02, %ax
int $0x10
movb $0x08, (VMODE)
movw %es:0x12(%di), %ax
movw %ax, (SCRNX)
movw %es:0x14(%di), %ax
movw %ax, (SCRNY)
movl %es:0x28(%edi), %eax
movl %eax, (VRAM)
jmp keystatus
scrn320:
movb $0x13, %al
movb $0x00, %ah
int $0x10
movb $0x08, (VMODE)
movw $320, (SCRNX)
movw $200, (SCRNY)
movl $0x000a0000, (VRAM)
keystatus:
movb $0x02, %ah
int $0x16 # keyboard
movb %al, (LEDS)
movb $0xff, %al
outb %al, $0x21
nop
outb %al, $0xa1
cli
call waitkbdout
movb $0xd1, %al
outb %al, $0x64
call waitkbdout
movb $0xdf, %al
outb %al, $0x60
call waitkbdout
.arch i486
lgdtl (GDTR0)
movl %cr0, %eax
andl $0x7fffffff, %eax
orl $0x00000001, %eax
movl %eax, %cr0
jmp pipelineflush
pipelineflush:
movw $1*8, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movw %ax, %ss
movl $bootpack, %esi
movl $BOTPAK, %edi
movl $512*1024/4, %ecx
call memcpy
movl $0x7c00, %esi
movl $DSKCAC, %edi
movl $512/4, %ecx
call memcpy
movl $DSKCAC0+512, %esi
movl $DSKCAC+512, %edi
movl $0x00, %ecx
movb (CYLS), %cl
imull $512*18*2/4, %ecx
subl $512/4, %ecx
call memcpy
movl $BOTPAK, %ebx
movl $0x11a8, %ebx # !!
addl $3, %ecx
shrl $2, %ecx
jz skip
movl $0x10c8, %edi # !!
addl %ebx, %esi
movl $0x00310000, %edi
call memcpy
skip:
movl $0x00310000, %esp # !!
ljmpl $2*8, $BOTPAK # code segment -> 2 !!
waitkbdout:
inb $0x64, %al
andb $0x02, %al
jnz waitkbdout
ret
memcpy:
movl (%esi), %eax
addl $4, %esi
movl %eax, (%edi)
addl $4, %edi
subl $1, %ecx
jnz memcpy
ret
.align 8
GDT0:
.skip 8, 0x00
.word 0xffff, 0x0000, 0x9200, 0x00cf # data
.word 0xffff, 0x0000, 0x9a00, 0x00cf # code !!
.word 0x0000
GDTR0:
.word 8*3-1
.int GDT0
.align 8
bootpack: