module: Append '/' to PATH strings if missing
[syslinux.git] / modules / ver.asm
blob600def02ec8b56f0bff6bb93bd27e0ea8c5f86e8
1 ; ****************************************************************************
3 ; ver.asm
5 ; A COMBOOT/DOS COM program to display the version of the system
6 ; (Syslinux, DOS, or DRMK)
8 ; Copyright (C) 2009-2010 Gene Cumm
10 ; This program is free software; you can redistribute it and/or modify
11 ; it under the terms of the GNU General Public License as published by
12 ; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
13 ; Boston MA 02111-1307, USA; either version 2 of the License, or
14 ; (at your option) any later version; incorporated herein by reference.
16 ; ****************************************************************************
18 ; %define DEBUG
20 section .text
21 org 0x100
23 _start:
24 call crlf
25 mov si,info_str
26 call writestr
27 call getdosver
28 call chkprn_dosver
29 jnz .end
30 call chkprn_syslinux
31 call crlf
32 .end:
33 ; pop ds
34 ret
37 ; chkprn_syslinux
38 chkprn_syslinux:
39 %ifdef DEBUG
40 mov si,may_sysl_str
41 call writestr
42 %endif
43 cmp eax,59530000h
44 jne .end
45 cmp ebx,4C530000h
46 jne .end
47 cmp ecx,4E490000h
48 jne .end
49 cmp edx,58550000h
50 jne .end
51 .is_syslinux:
52 pushad
53 %ifdef DEBUG
54 mov si,is_sysl_str
55 call writestr
56 %endif
57 .get_sysl_ver:
58 mov ax,0001h
59 int 22h
60 ; AX=0001h [2.00] Get Version
62 ; Input: AX 0001h
63 ; Output: AX number of INT 22h API functions available
64 ; CH Syslinux major version number
65 ; CL Syslinux minor version number
66 ; DL Syslinux derivative ID (e.g. 32h = PXELINUX)
67 ; ES:SI Syslinux version string
68 ; ES:DI Syslinux copyright string
69 %ifdef DEBUG
70 push si
71 push cs
72 pop ds
73 mov si,gotver_str
74 call writestr
75 pop si
76 %endif
78 .prn_ver_str:
79 mov si,syslban_str
80 call writestr
81 push ds
82 push es
83 pop ds
84 call writestr
85 call crlf
86 pop ds
87 .prn_var:
88 cmp dl,31h
89 je .var_sysl
90 cmp dl,32h
91 je .var_pxel
92 cmp dl,33h
93 je .var_isol
94 cmp dl,34h
95 je .var_extl
96 jmp .var_unk
97 .var_sysl:
98 mov si,sysl_str
99 call writestr
100 jmp .prn_lnxsp
101 .var_pxel:
102 mov si,pxel_str
103 call writestr
104 jmp .prn_lnxsp
105 .var_isol:
106 mov si,isol_str
107 call writestr
108 jmp .prn_lnxsp
109 .var_extl:
110 mov si,extl_str
111 call writestr
112 ; jmp .prn_lnxsp
113 .prn_lnxsp:
114 mov si,linsp_str
115 call writestr
116 jmp .prn_ver
117 .var_unk:
118 mov si,unkvar_str
119 call writestr
120 .prn_ver:
121 %ifdef DEBUG
122 push si
123 push cs
124 pop ds
125 mov si,prn_ver_str
126 call writestr
127 pop si
128 %endif
129 .prn_ver_maj:
130 mov al,ch
131 call writedecb
132 mov dl,'.'
133 call writechr_dl
134 .prn_ver_min:
135 mov al,cl
136 ; cmp al,10
137 ; jae .min_wri
138 ; mov al,'0'
139 ; call writechr
140 ; mov al,cl
141 ; .min_wri:
142 ; call writedecb
143 call writedecb2
145 .end_prn:
146 popad
147 .end:
150 ; chkprn_dosver Check and print DOS version;
151 ; Input Data from INT21 AH=30h
152 ; AH Major version of DOS or 0
153 ; AL Minor Version
154 ; BH DOS type
155 ; BL:CX 24-bit OEM serial number
156 ; Return
157 ; ZF Unset if DOS, Set if not DOS (AX=0)
158 chkprn_dosver:
159 and ax,ax ; cmp ax,0
160 jz .end
161 .is_dos:
162 push eax
163 push edx
164 push si
165 %ifdef DEBUG
166 mov si,is_dos_str
167 call writestr
168 call crlf
169 call prnreg_gp_l
170 call crlf
171 %endif
172 .var_prn:
173 cmp bh,0
174 je .var_pcdos
175 cmp bh,0FFh
176 je .var_msdos
177 cmp bh,0FDh
178 je .var_freedos
179 cmp bh,0DEh
180 je .var_drmk
181 jmp .var_unk
182 .var_pcdos:
183 mov si,pcdos_str
184 call writestr
185 jmp .var_end
186 .var_msdos:
187 mov si,msdos_str
188 call writestr
189 jmp .var_end
190 .var_freedos:
191 mov si,freedos_str
192 call writestr
193 jmp .var_end
194 .var_drmk:
195 mov si,drmk_str
196 call writestr
197 jmp .var_end
198 .var_unk:
199 mov si,unkdos_str
200 call writestr
201 mov si,spparen_str
202 call writestr
203 push eax
204 mov al,bh
205 call writehex2
206 pop eax
207 mov si,parensp_str
208 call writestr
209 ; jmp .var_end
210 .var_end:
211 call prn_dosver_num
212 call crlf
213 .subver:
214 pop si
215 pop edx
216 pop eax
217 cmp bh,0FFh
218 je .msdos_ver
219 cmp bh,0DEh
220 jne .end_ver
221 .drmk_ver:
222 call getprn_drmkver
223 ; jmp .end_ver ; DRMK returns Extended/True DOS
224 .msdos_ver:
225 cmp al,5
226 jb .end_ver
227 call getprn_msdosver
228 .end_ver:
229 and ax,ax ; Unset ZF
230 .end:
233 ; prn_dosver_num Print the numerical DOS version
234 ; Input Data from INT21 AH=30h
235 ; AH Major version of DOS or 0
236 ; AL Minor Version
237 ; BH DOS type
238 ; BL:CX 24-bit OEM serial number
239 prn_dosver_num:
240 push eax
241 push edx
242 push si
243 pushfd
244 .vmaj_prn:
245 call writedecb
246 ; call writehex2
247 mov dl,'.'
248 call writechr_dl
249 .vmin_prn:
250 mov al,ah
251 call writedecb
252 ; call writehex2
253 .serial: ; Skip if 0
254 cmp bl,0
255 jne .ser_start
256 cmp cx,0
257 je .end
258 .ser_start:
259 mov si,spparen_str
260 call writestr
261 mov si,zerox_str
262 call writestr
263 .ser_bl:
264 mov al,bl
265 call writehex2
266 .ser_cx:
267 mov ax,cx
268 call writehex4
269 .serial_end:
270 mov si,parensp_str
271 call writestr
272 .end:
273 popfd
274 pop si
275 pop edx
276 pop eax
279 ; getdosver Get the DOS version
280 ; Return Version or 0 + SYSLINUX message
281 ; EAX Part 1
282 ; EBX Part 2
283 ; ECX Part 3
284 ; EDX Part 4
285 getdosver:
286 mov ecx,0
287 mov edx,0
288 mov ebx,0
289 mov eax,3000h
290 int 21h
293 ; getmsdosver Get the Extended MS-DOS version
294 ; Returns Version
295 ; EAX Part 1
296 ; EBX Part 2
297 ; ECX Part 3
298 ; EDX Part 4
299 getmsdosver:
300 mov ecx,0
301 mov edx,0
302 mov ebx,0
303 mov eax,3306h
304 int 21h
307 ; getprn_msdosver
308 getprn_msdosver:
309 pushad
310 pushfd
311 call getmsdosver
312 %ifdef DEBUG
313 call prnreg_gp_l
314 call crlf
315 %endif
316 mov si,dosext_str
317 call writestr
318 mov eax,ebx
319 mov ebx,0
320 mov ecx,edx
321 call prn_dosver_num
322 .end:
323 popfd
324 popad
327 ; getdrmkver: Get the DRMK-specifc OS version
328 ; Returns Version
329 ; AX OS Version
330 ; DX Patch Version
331 getdrmkver:
332 mov ax,4452h
333 int 21h
336 ; getdrmkver: Get the DRMK-specifc Kernel build info
337 ; Returns Kernel build info
338 ; AX Kernel build date in DOS 16-bit format
339 ; [ES:BX] Kernel private data
340 getdrmkbld:
341 mov ax,4458h
342 int 21h
345 ; getprn_drmkver: Get/Print DRMK-specific Version info
346 getprn_drmkver:
347 pushad
348 pushfd
349 .getver:
350 call getdrmkver
351 .prnosver: ; "OS Version"
352 mov si,osver_str
353 call writestr
354 mov si,zerox_str
355 call writestr
356 ; mov ax,0
357 call writehex4
358 call crlf
359 .prnpatchver: ; "Patch Version"
360 mov si,patchver_str
361 call writestr
362 mov si,zerox_str
363 call writestr
364 mov ax,dx
365 call writehex4
366 call crlf
367 .getbld:
368 call getdrmkbld
369 .prnkernbld: ; "Kernel Build Date"
370 mov si,kernbld_str
371 call writestr
372 call writedate_ax
373 call crlf
374 .prnkernprvaddr:
375 mov si,prvdat_str
376 call writestr
377 mov ax,es
378 call writehex4
379 mov dl,':'
380 call writechr_dl
381 mov ax,bx
382 call writehex4
383 call crlf
384 %ifdef DEBUG
385 .prnkernprv:
386 mov di,[es:bx]
387 mov ax,di
388 call writehex4
389 call crlf
390 mov si,2
391 mov cx,8
392 .prnkernprv2:
393 push cx
394 mov cx,8
395 .prnkernprv1:
396 mov eax,[es:bx+si]
397 call writehex8
398 cmp cx,1
399 jbe .prnkern0dash
400 mov ax,'-'
401 call writechr
402 .prnkern0dash:
403 add si,4
404 sub di,4
405 cmp di,0
406 jbe .prnkernprvend
407 loop .prnkernprv1
408 call crlf
409 pop cx
410 loop .prnkernprv2
411 jmp .end
412 .prnkernprvend:
413 pop cx
414 %endif
415 .end:
416 popfd
417 popad
420 ;writedate_ax Write a date in AX in ISO8601 big endian format
421 ; Input
422 ; AX Date in 16-bit DOS format
423 ; 2006-01-11
424 ; 0011010 0001 01011
425 writedate_ax:
426 pushad
427 pushfd
428 mov dx,ax
429 %ifdef DEBUG
430 call writehex4
431 call crlf
432 %endif
433 .year:
434 shr ax,9
435 add ax,1980
436 call writedecw
437 mov al,'-'
438 call writechr
439 mov ax,dx
440 .month:
441 shr ax,5
442 and ax,0Fh
443 ; cmp ax,10
444 ; jae .month_wri
445 ; mov cx,ax
446 ; mov ax,'0'
447 ; call writechr
448 ; mov ax,cx
449 ; .month_wri:
450 ; call writedecb
451 call writedecb2
452 mov al,'-'
453 call writechr
454 mov ax,dx
455 .day:
456 and ax,1Fh
457 ; cmp ax,10
458 ; jae .day_wri
459 ; mov cx,ax
460 ; mov ax,'0'
461 ; call writechr
462 ; mov ax,cx
463 ; .day_wri:
464 ; call writedecb
465 call writedecb2
466 .end:
467 popfd
468 popad
471 ; writechr_dl Write a character to the console saving AX
472 ; Input
473 ; DL character to write
474 writechr_dl:
475 push ax
476 mov ah,02h
477 int 21h
478 .end:
479 pop ax
482 ; writechr_al Write a character to the console saving AX
483 ; Input
484 ; AL character to write
485 writechr:
486 writechr_al:
487 push dx
488 mov dl,al
489 call writechr_dl
490 .end: pop dx
493 ; writedecb[23] Print byte as fixed width
494 ; Input
495 ; AL number to write
496 writedecb3:
497 pushfd
498 cmp al,100
499 jae .skip
500 push ax
501 mov ax,'0'
502 call writechr
503 pop ax
504 .skip: popfd
505 writedecb2:
506 pushfd
507 cmp al,10
508 jae .skip
509 push ax
510 mov ax,'0'
511 call writechr
512 pop ax
513 .skip: popfd
514 call writedecb
518 ; prnreg_gp_l Dump GP registers (Long)
519 prnreg_gp_l:
520 push eax
521 push si
522 call crlf
523 mov si,sp2_str
524 call writestr
525 mov si,eax_str
526 call writestr
527 call writehex8
528 mov si,sp2_str
529 call writestr
530 mov si,ecx_str
531 call writestr
532 mov eax,ecx
533 call writehex8
534 mov si,sp2_str
535 call writestr
536 mov si,edx_str
537 call writestr
538 mov eax,edx
539 call writehex8
540 mov si,sp2_str
541 call writestr
542 mov si,ebx_str
543 call writestr
544 mov eax,ebx
545 call writehex8
546 call crlf
547 pop si
548 pop eax
549 .end:
552 ; is_zf
553 is_zf:
554 push si
555 jz .true
556 .false:
557 mov si,zero_not_str
558 call writestr
559 jmp .end
560 .true:
561 mov si,zero_is_str
562 call writestr
563 .end:
564 pop si
567 %include "../core/macros.inc" ; CR/LF
568 %include "writestr.inc" ; String output
569 %include "../core/writehex.inc" ; Hexadecimal output
570 %include "../core/writedec.inc" ; Decimal output
572 section .data
573 info_str db 'Ver.com b026', CR, LF, 0
574 is_dos_str db 'Found DOS', CR, LF, 0
575 is_sysl_str db 'Found a Syslinux variant', CR, LF, 0
576 is_drmk_str db 'Found DRMK', CR, LF, 0
577 may_sysl_str db 'Maybe Syslinux variant', CR, LF, 0
578 gotver_str db 'Got the version back', CR, LF, 0
579 prn_ver_str db 'Printing version number', CR, LF, 0
580 syslban_str db 'Syslinux banner: ',0
581 sysl_str db 'SYS', 0
582 pxel_str db 'PXE', 0
583 isol_str db 'ISO', 0
584 extl_str db 'EXT', 0
585 linsp_str db 'LINUX ', 0
586 unkvar_str db 'Unkown-Variant ', 0
587 pcdos_str db 'PC-DOS ', 0
588 msdos_str db 'MS-DOS ', 0
589 freedos_str db 'FreeDOS ', 0
590 unkdos_str db 'Unknown-DOS ', 0
591 drmk_str db 'DRMK ', 0
592 dosext_str db ' Extended DOS version: ', 0
593 osver_str db ' OS Version: ', 0
594 patchver_str db ' Patch Version: ', 0
595 kernbld_str db ' Kernel Build Date: ', 0
596 prvdat_str db ' Private Data Ptr: ', 0
597 spparen_str db ' (', 0
598 zerox_str db '0x', 0
599 parensp_str db ') ', 0
600 eax_str db 'EAX=', 0
601 ebx_str db 'EBX=', 0
602 ecx_str db 'ECX=', 0
603 edx_str db 'EDX=', 0
604 sp2_str db ' ', 0
605 zero_not_str db ' NOT_Zero ',0
606 zero_is_str db ' IS_Zero ',0