1 | ; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
|
---|
2 | ;
|
---|
3 | ; This file is part of AiR-BOOT
|
---|
4 | ;
|
---|
5 | ; AiR-BOOT is free software: you can redistribute it and/or modify it under
|
---|
6 | ; the terms of the GNU General Public License as published by the Free
|
---|
7 | ; Software Foundation, either version 3 of the License, or (at your option)
|
---|
8 | ; any later version.
|
---|
9 | ;
|
---|
10 | ; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
11 | ; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
---|
13 | ; details.
|
---|
14 | ;
|
---|
15 | ; You should have received a copy of the GNU General Public License along with
|
---|
16 | ; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | ;
|
---|
18 | ;---------------------------------------------------------------------------
|
---|
19 | ; AiR-BOOT / AUXILARY I/O
|
---|
20 | ;---------------------------------------------------------------------------
|
---|
21 |
|
---|
22 |
|
---|
23 | ; -----------------------
|
---|
24 | ; Rousseau: # AUXIO.ASM #
|
---|
25 | ; -----------------------
|
---|
26 | ; Output some stuff to the serial port.
|
---|
27 | ; The aux parameters in the MBR must be initialized for this.
|
---|
28 | ; Lower byte is com-port, 0=disabled, 1=com1, etc.
|
---|
29 | ; High byte is initialization; see below. (0e3h)
|
---|
30 |
|
---|
31 | IFDEF MODULE_NAMES
|
---|
32 | DB 'AUXIO',0
|
---|
33 | ENDIF
|
---|
34 |
|
---|
35 | ; Initialize the com-port, but only when logging is enabled.
|
---|
36 | ; It get's it's parameters from the value in the MBR.
|
---|
37 | ; Out: AX - line status
|
---|
38 | AuxIO_Init Proc Near Uses dx si
|
---|
39 | ; bits 7-5 = datarate (000=110,001=150,010=300,011=600,100=1200,101=2400,110=4800,111=9600 bps)
|
---|
40 | ; bits 4-3 = parity (00 or 10 = none, 01 = odd, 11 = even)
|
---|
41 | ; bit 2 = stop-bits (set = 2 stop-bits, clear = 1 stop-bit)
|
---|
42 | ; bits 1-0 = data-bits (00 = 5, 01 = 6, 10 = 7, 11 = 8)
|
---|
43 | ; mov [BIOS_AuxParms],ax ; save initialization and port
|
---|
44 | mov dx,[BIOS_AuxParms] ; DL=port, 0=disabled, 1=com1; DH=config-parms
|
---|
45 | test dl,dl ; see if logging is enabled, if not, skip initialization
|
---|
46 | jz AuxIO_Init_NoLogging
|
---|
47 |
|
---|
48 | ; Adjust to valid port range
|
---|
49 | dec dl ; adjust port-number
|
---|
50 | and dl,03h ; 3 is max value
|
---|
51 |
|
---|
52 | ; Do the initialization
|
---|
53 | mov al,dh ; initialization parameters to al
|
---|
54 | mov dh,0 ; DX now contains port-number
|
---|
55 | mov ah,0
|
---|
56 | int 14h ; intialize com-port
|
---|
57 | AuxIO_Init_NoLogging:
|
---|
58 | ret
|
---|
59 | AuxIO_Init EndP
|
---|
60 |
|
---|
61 |
|
---|
62 | ;
|
---|
63 | ; Send the Build Information to the COM-port.
|
---|
64 | ;
|
---|
65 | AuxIO_PrintBuildInfo Proc Near Uses ax cx si di
|
---|
66 |
|
---|
67 | ; OS/2 BLDLEVEL information.
|
---|
68 | mov si, offset bld_level
|
---|
69 | call AuxIO_Print
|
---|
70 | call AuxIO_TeletypeNL
|
---|
71 |
|
---|
72 | ret
|
---|
73 | AuxIO_PrintBuildInfo EndP
|
---|
74 |
|
---|
75 |
|
---|
76 | ; Print char to com-port (teletype style)
|
---|
77 | AuxIO_Teletype Proc Near Uses ax dx
|
---|
78 | mov dx,[BIOS_AuxParms] ; get port and parameters
|
---|
79 | xor dh,dh ; we don't need the parameters
|
---|
80 | test dl,dl ; test if logging is enabled
|
---|
81 | jz AuxIO_Teletype_NoLogging ; nope, return immediately
|
---|
82 | dec dl ; adjust port-number
|
---|
83 | and dl,03h ; 3 is max value
|
---|
84 | mov ah,01h
|
---|
85 | int 14h ; send char to com-port
|
---|
86 | AuxIO_Teletype_NoLogging:
|
---|
87 | ret
|
---|
88 | AuxIO_Teletype EndP
|
---|
89 |
|
---|
90 |
|
---|
91 | ; Print newline char (unix) to com-port (teletype style)
|
---|
92 | AuxIO_TeletypeNL Proc Near Uses ax
|
---|
93 | mov al,10
|
---|
94 | call AuxIO_Teletype
|
---|
95 | ret
|
---|
96 | AuxIO_TeletypeNL EndP
|
---|
97 |
|
---|
98 |
|
---|
99 | ; Print byte as decimal to com-port (teletype style)
|
---|
100 | AuxIO_TeletypeDecByte Proc Near Uses ax dx
|
---|
101 | call CONV_BinToPBCD ; Convert to PBCD
|
---|
102 | mov dx, ax ; Save PBCD value
|
---|
103 | shr ah, 4 ; Move digit count to low nibble
|
---|
104 | cmp ah, 3 ; Less than 3 digits ?
|
---|
105 | jb @F ; Yep, skip digit with index 2
|
---|
106 | mov al, dh ; Get byte with digit
|
---|
107 | and al, 0fh ; Mask it out
|
---|
108 | add al, '0' ; To ASCII
|
---|
109 | call AuxIO_Teletype
|
---|
110 | @@:
|
---|
111 | shr dh, 4 ; Move digit count to low nibble
|
---|
112 | cmp dh, 2 ; Less that 2 digits ?
|
---|
113 | jb @F ; Yep, skip digit with index 1
|
---|
114 | mov al, dl ; Get byte with digit
|
---|
115 | shr al, 4 ; Move to lower nibble
|
---|
116 | add al, '0' ; To ASCII
|
---|
117 | call AuxIO_Teletype
|
---|
118 | @@:
|
---|
119 | mov al, dl ; Get byte with digit
|
---|
120 | and al, 0fh ; Mask it out
|
---|
121 | add al, '0' ; To ASCII
|
---|
122 | call AuxIO_Teletype
|
---|
123 | ret
|
---|
124 | AuxIO_TeletypeDecByte EndP
|
---|
125 |
|
---|
126 |
|
---|
127 | ; Print Bin-byte to com-port (teletype style)
|
---|
128 | ; This outputs 8 characters ('0' or '1' for each bit)
|
---|
129 | ; In: AL - byte to send
|
---|
130 | ; Out: AL - byte sent
|
---|
131 | ; Destroyed: None
|
---|
132 | AuxIO_TeletypeBinByte Proc Near Uses ax cx
|
---|
133 | mov ah,al
|
---|
134 | mov cx,8
|
---|
135 | AuxIO_TeletypeBinByte_nextchar:
|
---|
136 | xor al,al
|
---|
137 | rcl ah,1
|
---|
138 | rcl al,1
|
---|
139 | add al,'0'
|
---|
140 | call AuxIO_Teletype
|
---|
141 | loop AuxIO_TeletypeBinByte_nextchar
|
---|
142 | ret
|
---|
143 | AuxIO_TeletypeBinByte EndP
|
---|
144 |
|
---|
145 | ; Print Bin-word to com-port (teletype style)
|
---|
146 | ; This outputs 16 characters ('0' or '1' for each bit)
|
---|
147 | ; In: AX - byte to send
|
---|
148 | ; Out: AX - byte sent
|
---|
149 | ; Destroyed: None
|
---|
150 | AuxIO_TeletypeBinWord Proc
|
---|
151 | xchg al,ah ; High byte first
|
---|
152 | call AuxIO_TeletypeBinByte ; Output to com-port
|
---|
153 | xchg al,ah ; low byte next
|
---|
154 | call AuxIO_TeletypeBinByte ; Output to com-port
|
---|
155 | ret
|
---|
156 | AuxIO_TeletypeBinWord EndP
|
---|
157 |
|
---|
158 | ; Print Bin-dword to com-port (teletype style)
|
---|
159 | ; This outputs 32 characters ('0' or '1' for each bit)
|
---|
160 | ; In: DX:AX - dword to send
|
---|
161 | ; Out: DX:AX - dword sent
|
---|
162 | ; Destroyed: None
|
---|
163 | AuxIO_TeletypeBinDWord Proc Near
|
---|
164 | xchg ax,dx
|
---|
165 | call AuxIO_TeletypeBinWord ; High word first
|
---|
166 | xchg ax,dx
|
---|
167 | call AuxIO_TeletypeBinWord ; Low word next
|
---|
168 | ret
|
---|
169 | AuxIO_TeletypeBinDWord EndP
|
---|
170 |
|
---|
171 | ; Print Bin-qword to com-port (teletype style)
|
---|
172 | ; This outputs 64 characters ('0' or '1' for each bit)
|
---|
173 | ; In: BX:CX:DX:AX - qword to send
|
---|
174 | ; Out: BX:CX:DX:AX - qword sent
|
---|
175 | ; Destroyed: None
|
---|
176 | AuxIO_TeletypeBinQWord Proc Near
|
---|
177 | xchg dx,bx
|
---|
178 | xchg ax,cx
|
---|
179 | call AuxIO_TeletypeBinDWord ; High dword first
|
---|
180 | xchg dx,bx
|
---|
181 | xchg ax,cx
|
---|
182 | call AuxIO_TeletypeBinDWord ; Low dword next
|
---|
183 | ret
|
---|
184 | AuxIO_TeletypeBinQWord EndP
|
---|
185 |
|
---|
186 |
|
---|
187 | ; Print hex-byte to com-port (teletype style)
|
---|
188 | ; This outputs two characters
|
---|
189 | ; In: AL - byte to send
|
---|
190 | ; Out: AL - byte sent
|
---|
191 | ; Destroyed: None
|
---|
192 | AuxIO_TeletypeHexByte Proc Near Uses ax
|
---|
193 | call CONV_BinToAsc ; Returns high hex-nibble in AH, low hex-nibble in AL
|
---|
194 | xchg al,ah ; High hex-nibble first
|
---|
195 | call AuxIO_Teletype ; Output to com-port
|
---|
196 | xchg al,ah ; Low hex-nibble next
|
---|
197 | call AuxIO_Teletype ; Output to com-port
|
---|
198 | ret
|
---|
199 | AuxIO_TeletypeHexByte EndP
|
---|
200 |
|
---|
201 | ; Print hex-word to com-port (teletype style)
|
---|
202 | ; This outputs four characters
|
---|
203 | ; In: AX - word to send
|
---|
204 | ; Out: AX - word sent
|
---|
205 | ; Destroyed: None
|
---|
206 | AuxIO_TeletypeHexWord Proc Near
|
---|
207 | xchg al,ah ; High byte first
|
---|
208 | call AuxIO_TeletypeHexByte ; Output to com-port
|
---|
209 | xchg al,ah ; low byte next
|
---|
210 | call AuxIO_TeletypeHexByte ; Output to com-port
|
---|
211 | ret
|
---|
212 | AuxIO_TeletypeHexWord EndP
|
---|
213 |
|
---|
214 |
|
---|
215 | ; Print hex-dword to com-port (teletype style)
|
---|
216 | ; This outputs eight characters
|
---|
217 | ; In: DX:AX - dword to send
|
---|
218 | ; Out: DX:AX - dword sent
|
---|
219 | ; Destroyed: None
|
---|
220 | AuxIO_TeletypeHexDWord Proc Near
|
---|
221 | xchg ax,dx
|
---|
222 | call AuxIO_TeletypeHexWord ; High word first
|
---|
223 | xchg ax,dx
|
---|
224 | call AuxIO_TeletypeHexWord ; Low word next
|
---|
225 | ret
|
---|
226 | AuxIO_TeletypeHexDWord EndP
|
---|
227 |
|
---|
228 |
|
---|
229 | ; Print hex-qword to com-port (teletype style)
|
---|
230 | ; This outputs sixteen characters
|
---|
231 | ; In: BX:CX:DX:AX - qword to send
|
---|
232 | ; Out: BX:CX:DX:AX - qword sent
|
---|
233 | ; Destroyed: None
|
---|
234 | AuxIO_TeletypeHexQWord Proc Near
|
---|
235 | xchg dx,bx
|
---|
236 | xchg ax,cx
|
---|
237 | call AuxIO_TeletypeHexDWord ; High dword first
|
---|
238 | xchg dx,bx
|
---|
239 | xchg ax,cx
|
---|
240 | call AuxIO_TeletypeHexDWord ; Low dword next
|
---|
241 | ret
|
---|
242 | AuxIO_TeletypeHexQWord EndP
|
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 | ; Print 0-terminated string to com-port
|
---|
247 | AuxIO_Print Proc Near Uses ax bx cx dx
|
---|
248 | AuxIO_PrintNext:
|
---|
249 | lodsb
|
---|
250 | test al,al
|
---|
251 | jz AuxIO_PrintEOS
|
---|
252 | call AuxIO_Teletype
|
---|
253 | jmp AuxIO_PrintNext
|
---|
254 | AuxIO_PrintEOS:
|
---|
255 | ret
|
---|
256 | AuxIO_Print EndP
|
---|
257 |
|
---|
258 |
|
---|
259 | ; Dump a 16-byte block of memory to the com-port in debug-format (hex-bytes and ascii-bytes)
|
---|
260 | ; In: DS:SI - pointer to memory to dump
|
---|
261 | ;
|
---|
262 | AuxIO_DumpParagraph Proc Near Uses ax cx dx si
|
---|
263 |
|
---|
264 | ; Dump the index dword
|
---|
265 | mov dx, ds
|
---|
266 | mov ax,si
|
---|
267 | call AuxIO_TeletypeHexDWord
|
---|
268 | ;~ call AuxIO_TeletypeHexWord
|
---|
269 |
|
---|
270 | ; Separate it from the dump
|
---|
271 | mov al,' '
|
---|
272 | ;~ call AuxIO_Teletype
|
---|
273 | ;~ mov al,'|'
|
---|
274 | mov al,' '
|
---|
275 | call AuxIO_Teletype
|
---|
276 | mov al,' '
|
---|
277 | ;~ call AuxIO_Teletype
|
---|
278 |
|
---|
279 | ; Save si for later
|
---|
280 | push si
|
---|
281 |
|
---|
282 | ; Four groups of 4 bytes
|
---|
283 | mov cx,4
|
---|
284 |
|
---|
285 |
|
---|
286 | AuxIO_DumpParagraph_Next_1:
|
---|
287 |
|
---|
288 | ; byte at offset 0
|
---|
289 | lodsb
|
---|
290 | call AuxIO_TeletypeHexByte
|
---|
291 |
|
---|
292 | ; space separator
|
---|
293 | mov al,' '
|
---|
294 | call AuxIO_Teletype
|
---|
295 |
|
---|
296 | ; byte at offset 1
|
---|
297 | lodsb
|
---|
298 | call AuxIO_TeletypeHexByte
|
---|
299 |
|
---|
300 | ; space separator
|
---|
301 | mov al,' '
|
---|
302 | call AuxIO_Teletype
|
---|
303 |
|
---|
304 | ; byte at offset 2
|
---|
305 | lodsb
|
---|
306 | call AuxIO_TeletypeHexByte
|
---|
307 |
|
---|
308 | ; space separator
|
---|
309 | mov al,' '
|
---|
310 | call AuxIO_Teletype
|
---|
311 |
|
---|
312 | ; byte at offset 3
|
---|
313 | lodsb
|
---|
314 | call AuxIO_TeletypeHexByte
|
---|
315 |
|
---|
316 | ; space separator
|
---|
317 | mov al,' '
|
---|
318 | ;~ call AuxIO_Teletype
|
---|
319 |
|
---|
320 | ; separator
|
---|
321 | ;~ mov al,'|'
|
---|
322 | mov al,' '
|
---|
323 | call AuxIO_Teletype
|
---|
324 |
|
---|
325 | ; space separator
|
---|
326 | mov al,' '
|
---|
327 | ;~ call AuxIO_Teletype
|
---|
328 |
|
---|
329 | loop AuxIO_DumpParagraph_Next_1
|
---|
330 |
|
---|
331 | ; recall pointer
|
---|
332 | pop si
|
---|
333 |
|
---|
334 | ; 16 ascii bytes to print
|
---|
335 | mov cx,16
|
---|
336 |
|
---|
337 | AuxIO_DumpParagraph_Next_2:
|
---|
338 | mov ah,'.' ; char to use ufnot printable
|
---|
339 | lodsb ; load byte
|
---|
340 | call CONV_ConvertToPrintable ; use dot's if not printable
|
---|
341 | call AuxIO_Teletype ; print it
|
---|
342 | loop AuxIO_DumpParagraph_Next_2
|
---|
343 | ret
|
---|
344 | AuxIO_DumpParagraph EndP
|
---|
345 |
|
---|
346 |
|
---|
347 |
|
---|
348 | AuxIO_DumpSector Proc Near Uses cx si
|
---|
349 | mov cx,32 ; Number of paragraphs in a sector
|
---|
350 | AuxIO_DumpSector_Next:
|
---|
351 | call AuxIO_DumpParagraph ; Dump the paragraph
|
---|
352 | add si,16 ; Advance pointer
|
---|
353 | call AuxIO_TeletypeNL
|
---|
354 | loop AuxIO_DumpSector_Next
|
---|
355 | ret
|
---|
356 | AuxIO_DumpSector EndP
|
---|
357 |
|
---|
358 |
|
---|
359 | AuxInitMsg db 'Serial Communications active on COM',0
|
---|
360 | AuxIOHello db 10,10,10,'<<<<< AiR-BOOT SERIAL DEBUGGER ACTIVE >>>>>',10,0
|
---|