]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/boot/pc98/boot0.5/syscons.s
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / boot / pc98 / boot0.5 / syscons.s
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 #
28 # $FreeBSD$
29 #
30
31         .code16
32
33         .text
34 #
35 #       %al     character code
36 #       destroyed: %al, %bx
37 #
38 put_character:
39         movw    $0xe000, %bx
40         movb    ishireso, %ah
41         orb     %ah, %ah
42         jne     hireso_ch
43         movw    $0xa000, %bx
44 hireso_ch:
45         movw    %bx, %es
46         xorb    %ah, %ah
47         movw    curpos, %bx
48         movw    %ax, %es:(%bx)
49         xorw    %ax, %ax
50         movw    %ax, %es
51         ret
52
53 #
54 #       %al     attribute
55 #       destroyed: %ah, %cx
56 #
57 set_attribute:
58         movw    $0xe200, %bx
59         movb    ishireso, %ah
60         orb     %ah, %ah
61         jne     hireso_ch
62         movw    $0xa200, %bx
63 hireso_attr:
64         movw    %bx, %es
65         xorb    %ah, %ah
66         movw    curpos, %bx
67         movw    %ax, %es:(%bx)
68         xorw    %bx, %bx
69         movw    %bx, %es
70         ret
71
72 #
73 # Put a character
74 #       %al:    character code
75 #       destroyed: %ah, %bx, %cx
76 #
77         .global sc_putc
78 sc_putc:
79         call    put_character
80         incw    curpos
81         incw    curpos
82         cmpw    $4000, curpos
83         jng     putc_end
84         movw    $0, curpos
85 putc_end:
86         ret
87
88 #
89 # Put a null terminated string
90 #       %di:    pointer to string
91 #       destroyed: %ah, %cx, %di
92 #
93         .global sc_puts
94 sc_puts:
95         movb    (%di), %al
96         orb     %al, %al
97         jz      puts_end
98         call    sc_putc
99         incw    %di
100         jmp     sc_puts
101 puts_end:
102         ret
103
104 #
105 # Change the current cursor position
106 #       %cx:    X
107 #       %dx:    Y
108 #       destroyed: %ax,  %bx
109 #
110         .global sc_goto
111 sc_goto:
112         movw    %dx, %ax                # AX=Y
113         shlw    %ax                     # AX=Y*64
114         shlw    %ax
115         shlw    %ax
116         shlw    %ax
117         shlw    %ax
118         shlw    %ax
119         movw    %dx, %bx                # BX=Y
120         shlw    %bx                     # BX=Y*16
121         shlw    %bx
122         shlw    %bx
123         shlw    %bx
124         addw    %bx, %ax                # AX=Y*64+Y*16=Y*80
125         addw    %cx, %ax
126         shlw    %ax
127         movw    %ax, curpos
128         ret
129
130 #
131 # Clear screen
132 #       destroyed: %ax, %bx
133 #
134         .global sc_clean
135 sc_clean:
136         movb    $0x16, %ah
137         movw    $0xe120, %dx
138         int     $0x18                   # KBD/CRT BIOS
139         movw    $0, curpos
140         ret
141
142 #
143 # Set sttribute code
144 #       %al:    attribute
145 #       %cx:    count
146 #       destroyed: %ax, %bx, %cx
147 #
148         .global sc_setattr
149 sc_setattr:
150         call    set_attribute
151         incw    curpos
152         incw    curpos
153         loop    sc_setattr
154
155 #
156 # Sense the state of shift key
157 #       destroyed: %ax
158 #
159         .global sc_getshiftkey
160 sc_getshiftkey:
161         movb    $2, %ah                 # Sense KB_SHIFT_COD
162         int     $0x18                   # KBD/CRT BIOS
163         xorb    %ah, %ah
164         ret
165
166 #
167 # Check KBD buffer
168 #
169         .global sc_iskeypress
170 sc_iskeypress:
171         mov     $1, %ah
172         int     $0x18                   # KBD/CRT BIOS
173         testb   $1, %bh
174         jz      no_key
175         movw    $1, %ax
176         ret
177 no_key:
178         xorw    %ax, %ax
179         ret
180
181 #
182 # Read from KBD
183 #
184         .global sc_getc
185 sc_getc:
186         xorb    %ah, %ah
187         int     $0x18
188         ret
189
190 #
191 # Initialize CRT (normal mode)
192 #
193 init_screen_normal:
194         # Disable graphic screen
195         movb    $0x41, %ah
196         int     $0x18
197         # Init graphic screen
198         movb    $0x42, %al
199         movb    $0xc0, %ch
200         int     $0x18
201         # 80x25 mode
202         movw    $0x0a00, %ax
203         int     $0x18
204         ret
205
206 #
207 # Initialize CRT (hireso mode)
208 #
209 init_screen_hireso:
210         # Init RAM window
211         movb    $8, %al
212         outb    %al, $0x91
213         movb    $0x0a, %al
214         outb    %al, $0x93
215         # 80x31 mode
216         movw    $0x0a00, %ax
217         int     $0x18
218         ret
219
220 #
221 # Initialize screen (internal)
222 #
223 init_screen:
224         movb    ishireso, %ah
225         orb     %ah, %ah
226         jne     hireso_ini
227         call    init_screen_normal
228         jmp     init_next
229 hireso_ini:
230         call    init_screen_hireso
231 init_next:
232         movb    $0x0c, %ah
233         int     $0x18
234         # cursor home and off
235         xorw    %dx, %dx
236         movb    $0x13, %ah
237         int     $0x18
238         movb    $0x12, %ah
239         int     $0x18
240         ret
241
242 #
243 # Initialize screeen
244 #
245         .global sc_init
246 sc_init:
247         call    init_screen
248         call    sc_clean
249         movw    $0, curpos
250         ret
251
252         .data
253 curpos:         .word   0               # Current cursor position