source: trunk/bootcode/regular/auxio.asm@ 87

Last change on this file since 87 was 57, checked in by Ben Rietbroek, 10 years ago

All source-files lowercased [v1.1.1-testing]

Some standard files like 'COPYING', 'LICENSE', etc. have not been
converted to lower case because they are usually distributed uppercased.

File size: 13.2 KB
Line 
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
31IFDEF MODULE_NAMES
32DB 'AUXIO',0
33ENDIF
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
38AuxIO_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 dec dl ; adjust port-number
49 and dl,03h ; 3 is max value
50
51 ; Initialization message
52 mov si,offset AuxInitMsg
53 call MBR_Teletype
54
55 ; Port number
56 call VideoIO_SyncPos
57 mov al,dl
58 inc al
59 call VideoIO_PrintByteDynamicNumber
60 xor si,si
61 call MBR_TeletypeNL
62
63 ; Do the initialization
64 mov al,dh ; initialization parameters to al
65 mov dh,0 ; DX now contains port-number
66 mov ah,0
67 int 14h ; intialize com-port
68 AuxIO_Init_NoLogging:
69 ret
70AuxIO_Init EndP
71
72
73;
74; Send the Build Information to the COM-port.
75;
76AuxIO_PrintBuildInfo Proc Near Uses ax cx si di
77 ; Print header.
78 mov si, offset build_info
79 call AuxIO_Print
80
81 ; Prepare info in temorary buffer.
82 mov si,offset bld_level_date_start
83 mov cx,offset bld_level_date_end
84 sub cx,si
85 mov di,offset Scratch
86 cld
87 rep movsb
88
89 ; Fill spaces until assembler specification.
90 mov al,' '
91 mov cx,37
92 rep stosb
93
94 ; Copy assembler specification.
95 IFDEF JWASM
96 mov al,'['
97 stosb
98 mov si,offset jwasm_txt
99 ELSEIFDEF TASM
100 mov al,' '
101 stosb
102 mov al,'['
103 stosb
104 mov si,offset tasm_txt
105
106 ELSEIFDEF WASM
107 mov al,' '
108 stosb
109 mov al,'['
110 stosb
111 mov si,offset wasm_txt
112 ELSEIFDEF MASM
113 mov al,' '
114 stosb
115 mov al,'['
116 stosb
117 mov si,offset masm_txt
118 ELSE
119 mov al,' '
120 stosb
121 mov al,'['
122 stosb
123 mov si,offset unknown_txt
124 ENDIF
125
126 AuxIO_PrintBuildInfo_a1:
127 lodsb
128 test al,al
129 jz AuxIO_PrintBuildInfo_e1
130 stosb
131 jmp AuxIO_PrintBuildInfo_a1
132 AuxIO_PrintBuildInfo_e1:
133 mov al,']'
134 stosb
135
136 ; Insert NULL Terminator.
137 xor al,al
138 stosb
139
140 ; Print Info.
141 mov si, offset Scratch
142 call AuxIO_Print
143 call AuxIO_TeletypeNL
144
145 ; OS/2 BLDLEVEL information.
146 mov si, offset bld_level
147 call AuxIO_Print
148 call AuxIO_TeletypeNL
149
150 ret
151AuxIO_PrintBuildInfo EndP
152
153
154; Print char to com-port (teletype style)
155AuxIO_Teletype Proc Near Uses ax dx
156
157
158 ;~ pusha
159 ;~ xor dx,dx
160 ;~ mov ah,03h
161 ;~ mov al,00h
162 ;~ int 14h
163 ;~ mov ah,al
164 ;~ shr al,4
165 ;~ and al,0fh
166 ;~ add al,'0'
167 ;~ cmp al,'9'
168 ;~ jbe @F
169 ;~ add al,7
170;~ @@: push ax
171 ;~ xor dx,dx
172 ;~ mov ah,01h
173 ;~ int 14h
174 ;~ pop ax
175 ;~ mov al,ah
176 ;~ and al,0fh
177 ;~ add al,'0'
178 ;~ cmp al,'9'
179 ;~ jbe @F
180 ;~ add al,7
181;~ @@: xor dx,dx
182 ;~ mov ah,01h
183 ;~ int 14h
184 ;~ popa
185
186 ;~ pusha
187;~ @@:
188 ;~ xor dx,dx
189 ;~ mov ah,03h
190 ;~ mov al,00h
191 ;~ int 14h
192 ;~ and al,20h
193 ;~ cmp al,20h
194 ;~ jnz @B
195 ;~ popa
196
197
198 mov dx,[BIOS_AuxParms] ; get port and parameters
199 xor dh,dh ; we don't need the parameters
200 test dl,dl ; test if logging is enabled
201 jz AuxIO_Teletype_NoLogging ; nope, return immediately
202 dec dl ; adjust port-number
203 and dl,03h ; 3 is max value
204 mov ah,01h
205 int 14h ; send char to com-port
206 AuxIO_Teletype_NoLogging:
207 ret
208AuxIO_Teletype EndP
209
210
211; Print newline char (unix) to com-port (teletype style)
212AuxIO_TeletypeNL Proc Near Uses ax
213 mov al,10
214 call AuxIO_Teletype
215 ret
216AuxIO_TeletypeNL EndP
217
218
219; Print Bin-byte to com-port (teletype style)
220; This outputs 8 characters ('0' or '1' for each bit)
221; In: AL - byte to send
222; Out: AL - byte sent
223; Destroyed: None
224AuxIO_TeletypeBinByte Proc Near Uses ax cx
225 mov ah,al
226 mov cx,8
227 AuxIO_TeletypeBinByte_nextchar:
228 xor al,al
229 rcl ah,1
230 rcl al,1
231 add al,'0'
232 call AuxIO_Teletype
233 loop AuxIO_TeletypeBinByte_nextchar
234 ret
235AuxIO_TeletypeBinByte EndP
236
237; Print Bin-word to com-port (teletype style)
238; This outputs 16 characters ('0' or '1' for each bit)
239; In: AX - byte to send
240; Out: AX - byte sent
241; Destroyed: None
242AuxIO_TeletypeBinWord Proc
243 xchg al,ah ; High byte first
244 call AuxIO_TeletypeBinByte ; Output to com-port
245 xchg al,ah ; low byte next
246 call AuxIO_TeletypeBinByte ; Output to com-port
247 ret
248AuxIO_TeletypeBinWord EndP
249
250; Print Bin-dword to com-port (teletype style)
251; This outputs 32 characters ('0' or '1' for each bit)
252; In: DX:AX - dword to send
253; Out: DX:AX - dword sent
254; Destroyed: None
255AuxIO_TeletypeBinDWord Proc Near
256 xchg ax,dx
257 call AuxIO_TeletypeBinWord ; High word first
258 xchg ax,dx
259 call AuxIO_TeletypeBinWord ; Low word next
260 ret
261AuxIO_TeletypeBinDWord EndP
262
263; Print Bin-qword to com-port (teletype style)
264; This outputs 64 characters ('0' or '1' for each bit)
265; In: BX:CX:DX:AX - qword to send
266; Out: BX:CX:DX:AX - qword sent
267; Destroyed: None
268AuxIO_TeletypeBinQWord Proc Near
269 xchg dx,bx
270 xchg ax,cx
271 call AuxIO_TeletypeBinDWord ; High dword first
272 xchg dx,bx
273 xchg ax,cx
274 call AuxIO_TeletypeBinDWord ; Low dword next
275 ret
276AuxIO_TeletypeBinQWord EndP
277
278
279; Print hex-byte to com-port (teletype style)
280; This outputs two characters
281; In: AL - byte to send
282; Out: AL - byte sent
283; Destroyed: None
284AuxIO_TeletypeHexByte Proc Near Uses ax
285 call CONV_BinToAsc ; Returns high hex-nibble in AH, low hex-nibble in AL
286 xchg al,ah ; High hex-nibble first
287 call AuxIO_Teletype ; Output to com-port
288 xchg al,ah ; Low hex-nibble next
289 call AuxIO_Teletype ; Output to com-port
290 ret
291AuxIO_TeletypeHexByte EndP
292
293; Print hex-word to com-port (teletype style)
294; This outputs four characters
295; In: AX - word to send
296; Out: AX - word sent
297; Destroyed: None
298AuxIO_TeletypeHexWord Proc Near
299 xchg al,ah ; High byte first
300 call AuxIO_TeletypeHexByte ; Output to com-port
301 xchg al,ah ; low byte next
302 call AuxIO_TeletypeHexByte ; Output to com-port
303 ret
304AuxIO_TeletypeHexWord EndP
305
306
307; Print hex-dword to com-port (teletype style)
308; This outputs eight characters
309; In: DX:AX - dword to send
310; Out: DX:AX - dword sent
311; Destroyed: None
312AuxIO_TeletypeHexDWord Proc Near
313 xchg ax,dx
314 call AuxIO_TeletypeHexWord ; High word first
315 xchg ax,dx
316 call AuxIO_TeletypeHexWord ; Low word next
317 ret
318AuxIO_TeletypeHexDWord EndP
319
320
321; Print hex-qword to com-port (teletype style)
322; This outputs sixteen characters
323; In: BX:CX:DX:AX - qword to send
324; Out: BX:CX:DX:AX - qword sent
325; Destroyed: None
326AuxIO_TeletypeHexQWord Proc Near
327 xchg dx,bx
328 xchg ax,cx
329 call AuxIO_TeletypeHexDWord ; High dword first
330 xchg dx,bx
331 xchg ax,cx
332 call AuxIO_TeletypeHexDWord ; Low dword next
333 ret
334AuxIO_TeletypeHexQWord EndP
335
336
337
338; Print 0-terminated string to com-port
339AuxIO_Print Proc Near Uses ax bx cx dx
340 AuxIO_PrintNext:
341 lodsb
342 test al,al
343 jz AuxIO_PrintEOS
344 call AuxIO_Teletype
345 jmp AuxIO_PrintNext
346 AuxIO_PrintEOS:
347 ret
348AuxIO_Print EndP
349
350
351; Dump a 16-byte block of memory to the com-port in debug-format (hex-bytes and ascii-bytes)
352; In: DS:SI - pointer to memory to dump
353;
354AuxIO_DumpParagraph Proc Near Uses ax cx dx si
355
356 ; Dump the index dword
357 xor dx,dx
358 mov ax,si
359 call AuxIO_TeletypeHexDWord
360
361 ; Separate it from the dump
362 mov al,' '
363 call AuxIO_Teletype
364 mov al,' '
365 call AuxIO_Teletype
366 mov al,'|'
367 call AuxIO_Teletype
368 mov al,' '
369 call AuxIO_Teletype
370
371 ; Save si for later
372 push si
373
374 ; Four groups of 4 bytes
375 mov cx,4
376
377
378 AuxIO_DumpParagraph_Next_1:
379
380 ; byte at offset 0
381 lodsb
382 call AuxIO_TeletypeHexByte
383
384 ; space separator
385 mov al,' '
386 call AuxIO_Teletype
387
388 ; byte at offset 1
389 lodsb
390 call AuxIO_TeletypeHexByte
391
392 ; space separator
393 mov al,' '
394 call AuxIO_Teletype
395
396 ; byte at offset 2
397 lodsb
398 call AuxIO_TeletypeHexByte
399
400 ; space separator
401 mov al,' '
402 call AuxIO_Teletype
403
404 ; byte at offset 3
405 lodsb
406 call AuxIO_TeletypeHexByte
407
408 ; space separator
409 mov al,' '
410 call AuxIO_Teletype
411
412 ; separator
413 mov al,'|'
414 call AuxIO_Teletype
415
416 ; space separator
417 mov al,' '
418 call AuxIO_Teletype
419
420 loop AuxIO_DumpParagraph_Next_1
421
422 ; space separator
423 mov al,' '
424 call AuxIO_Teletype
425
426 ; recall pointer
427 pop si
428
429 ; 16 ascii bytes to print
430 mov cx,16
431
432 AuxIO_DumpParagraph_Next_2:
433 mov ah,'.' ; char to use ufnot printable
434 lodsb ; load byte
435 call CONV_ConvertToPrintable ; use dot's if not printable
436 call AuxIO_Teletype ; print it
437 loop AuxIO_DumpParagraph_Next_2
438 ret
439AuxIO_DumpParagraph EndP
440
441
442
443AuxIO_DumpSector Proc Near Uses cx si
444 mov cx,32 ; Number of paragraphs in a sector
445 AuxIO_DumpSector_Next:
446 call AuxIO_DumpParagraph ; Dump the paragraph
447 add si,16 ; Advance pointer
448 call AuxIO_TeletypeNL
449 loop AuxIO_DumpSector_Next
450 ret
451AuxIO_DumpSector EndP
452
453
454AuxIOHello db 10,10,10,10,10,'AiR-BOOT com-port debugging',10,0
455
456
Note: See TracBrowser for help on using the repository browser.