Fully synchronize sys/boot from FreeBSD-5.x, but add / to the module path
[dragonfly.git] / sys / boot / pc98 / boot0.5 / syscons.s
CommitLineData
984263bc
MD
1# Copyright (c) KATO Takenori, 1999, 2000.
2#
3# All rights reserved. Unpublished rights reserved under the copyright
4# laws of Japan.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# 1. Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer as
12# the first lines of this file unmodified.
13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
5ee58eed
MD
28# $FreeBSD: src/sys/boot/pc98/boot0.5/syscons.s,v 1.1 2000/08/02 08:46:08 kato Exp $
29# $DragonFly: src/sys/boot/pc98/boot0.5/Attic/syscons.s,v 1.3 2003/11/10 06:08:38 dillon Exp $
984263bc
MD
30#
31
32 .code16
33
34 .text
35#
36# %al character code
37# destroyed: %al, %bx
38#
39put_character:
40 movw $0xe000, %bx
41 movb ishireso, %ah
42 orb %ah, %ah
43 jne hireso_ch
44 movw $0xa000, %bx
45hireso_ch:
46 movw %bx, %es
47 xorb %ah, %ah
48 movw curpos, %bx
49 movw %ax, %es:(%bx)
50 xorw %ax, %ax
51 movw %ax, %es
52 ret
53
54#
55# %al attribute
56# destroyed: %ah, %cx
57#
58set_attribute:
59 movw $0xe200, %bx
60 movb ishireso, %ah
61 orb %ah, %ah
62 jne hireso_ch
63 movw $0xa200, %bx
64hireso_attr:
65 movw %bx, %es
66 xorb %ah, %ah
67 movw curpos, %bx
68 movw %ax, %es:(%bx)
69 xorw %bx, %bx
70 movw %bx, %es
71 ret
72
73#
74# Put a character
75# %al: character code
76# destroyed: %ah, %bx, %cx
77#
78 .global sc_putc
79sc_putc:
80 call put_character
81 incw curpos
82 incw curpos
83 cmpw $4000, curpos
84 jng putc_end
85 movw $0, curpos
86putc_end:
87 ret
88
89#
90# Put a null terminated string
91# %di: pointer to string
92# destroyed: %ah, %cx, %di
93#
94 .global sc_puts
95sc_puts:
96 movb (%di), %al
97 orb %al, %al
98 jz puts_end
99 call sc_putc
100 incw %di
101 jmp sc_puts
102puts_end:
103 ret
104
105#
106# Change the current cursor position
107# %cx: X
108# %dx: Y
109# destroyed: %ax, %bx
110#
111 .global sc_goto
112sc_goto:
113 movw %dx, %ax # AX=Y
114 shlw %ax # AX=Y*64
115 shlw %ax
116 shlw %ax
117 shlw %ax
118 shlw %ax
119 shlw %ax
120 movw %dx, %bx # BX=Y
121 shlw %bx # BX=Y*16
122 shlw %bx
123 shlw %bx
124 shlw %bx
125 addw %bx, %ax # AX=Y*64+Y*16=Y*80
126 addw %cx, %ax
127 shlw %ax
128 movw %ax, curpos
129 ret
130
131#
132# Clear screen
133# destroyed: %ax, %bx
134#
135 .global sc_clean
136sc_clean:
137 movb $0x16, %ah
138 movw $0xe120, %dx
139 int $0x18 # KBD/CRT BIOS
140 movw $0, curpos
141 ret
142
143#
144# Set sttribute code
145# %al: attribute
146# %cx: count
147# destroyed: %ax, %bx, %cx
148#
149 .global sc_setattr
150sc_setattr:
151 call set_attribute
152 incw curpos
153 incw curpos
154 loop sc_setattr
155
156#
157# Sense the state of shift key
158# destroyed: %ax
159#
160 .global sc_getshiftkey
161sc_getshiftkey:
162 movb $2, %ah # Sense KB_SHIFT_COD
163 int $0x18 # KBD/CRT BIOS
164 xorb %ah, %ah
165 ret
166
167#
168# Check KBD buffer
169#
170 .global sc_iskeypress
171sc_iskeypress:
172 mov $1, %ah
173 int $0x18 # KBD/CRT BIOS
174 testb $1, %bh
175 jz no_key
176 movw $1, %ax
177 ret
178no_key:
179 xorw %ax, %ax
180 ret
181
182#
183# Read from KBD
184#
185 .global sc_getc
186sc_getc:
187 xorb %ah, %ah
188 int $0x18
189 ret
190
191#
192# Initialize CRT (normal mode)
193#
194init_screen_normal:
195 # Disable graphic screen
196 movb $0x41, %ah
197 int $0x18
198 # Init graphic screen
199 movb $0x42, %al
200 movb $0xc0, %ch
201 int $0x18
202 # 80x25 mode
203 movw $0x0a00, %ax
204 int $0x18
205 ret
206
207#
208# Initialize CRT (hireso mode)
209#
210init_screen_hireso:
211 # Init RAM window
212 movb $8, %al
213 outb %al, $0x91
214 movb $0x0a, %al
215 outb %al, $0x93
216 # 80x31 mode
217 movw $0x0a00, %ax
218 int $0x18
219 ret
220
221#
222# Initialize screen (internal)
223#
224init_screen:
225 movb ishireso, %ah
226 orb %ah, %ah
227 jne hireso_ini
228 call init_screen_normal
229 jmp init_next
230hireso_ini:
231 call init_screen_hireso
232init_next:
233 movb $0x0c, %ah
234 int $0x18
235 # cursor home and off
236 xorw %dx, %dx
237 movb $0x13, %ah
238 int $0x18
239 movb $0x12, %ah
240 int $0x18
241 ret
242
243#
244# Initialize screeen
245#
246 .global sc_init
247sc_init:
248 call init_screen
249 call sc_clean
250 movw $0, curpos
251 ret
252
253 .data
254curpos: .word 0 # Current cursor position