source: trunk/bootcode/regular/debug.asm@ 90

Last change on this file since 90 was 90, checked in by Ben Rietbroek, 8 years ago

Added flags to register dump function (debugging) [v1.1.1-testing]

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File size: 28.7 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 / DEBUG
20;---------------------------------------------------------------------------
21
22
23; -----------------------
24; Rousseau: # DEBUG.ASM #
25; -----------------------
26; This module contains functions for debugging AiR-BOOT.
27; It is only included in debug builds and the codesize of AiR-BOOT increases
28; in that case. To compensate for that, the FX code is disabled when debugging
29; is active. Also, most of the debug-routines can selectively be disabled
30; by setting the 'IF' directive to 0 or 1. Setting to 0 does an immediate
31; return, setting to 1 enables the routine.
32
33
34
35IFDEF MODULE_NAMES
36DB 'DEBUG',0
37ENDIF
38
39
40
41;
42; Show help on keys.
43;
44dbh db 10
45 db 'h=HELP, d=DBGSCR-TOGGLE',10
46 db 'l=DRIVE-LETTERS, g=GEO, i=IPT, r=RESTART, v=VOL-LETTERS, x=XREF',10
47 db '0-9=disk 80h-89h info',10
48 db 10,0
49
50DEBUG_ShowHelp Proc
51 pushf
52 pusha
53 mov si, offset dbh
54 call AuxIO_Print
55 popa
56 popf
57 ret
58DEBUG_ShowHelp EndP
59
60
61
62;
63; Dispatch table for debug hot-keys.
64;
65dbg_dispatch:
66 db 't'
67 dw offset DEBUG_Test
68 db 'd'
69 dw offset DEBUG_DebugScreenToggle
70 db 'l'
71 dw offset DEBUG_DumpDriveLetters
72 db 'g'
73 dw offset DEBUG_DumpGeo
74 db 'h'
75 dw offset DEBUG_ShowHelp
76 db 'i'
77 dw offset DEBUG_DumpIPT
78 db 'r'
79 dw offset AirbootRestart
80 db 'v'
81 dw offset DEBUG_DumpVolumeLetters
82 db 'x'
83 dw offset DEBUG_DumpPartitionXref
84 db 'R'
85 dw offset AirbootRestart
86 db 0
87
88
89
90;
91; Show 'not assigned' message.
92;
93dbg_na db 'This key is not assigned, press ''h'' for Help.',10,0
94DEBUG_NotAssigned Proc
95 pushf
96 pusha
97 mov si,offset dbg_na
98 call AuxIO_Print
99 popa
100 popf
101 ret
102DEBUG_NotAssigned Endp
103
104
105; ============================================================== [ dump stuff ]
106
107;
108; Dump the geometry.
109;
110IF 0
111DEBUG_DumpGeo Proc
112 pushf
113 pusha
114
115 ; BIOS cyls
116 mov dx,word ptr [BIOS_Cyls+02]
117 mov ax,word ptr [BIOS_Cyls+00]
118 call AuxIO_TeletypeHexDWord
119 call AuxIO_TeletypeNL
120
121 ; BIOS heads
122 mov dx,word ptr [BIOS_Heads+02]
123 mov ax,word ptr [BIOS_Heads+00]
124 call AuxIO_TeletypeHexDWord
125 call AuxIO_TeletypeNL
126
127 ; BIOS secs
128 mov dx,word ptr [BIOS_Secs+02]
129 mov ax,word ptr [BIOS_Secs+00]
130 call AuxIO_TeletypeHexDWord
131 call AuxIO_TeletypeNL
132
133 ; Bytes per sector
134 mov ax,[BIOS_Bytes]
135 call AuxIO_TeletypeHexWord
136 call AuxIO_TeletypeNL
137
138 ; Total secs
139 mov bx, word ptr [BIOS_TotalSecs+06]
140 mov cx, word ptr [BIOS_TotalSecs+04]
141 mov dx, word ptr [BIOS_TotalSecs+02]
142 mov ax, word ptr [BIOS_TotalSecs+00]
143 call AuxIO_TeletypeHexDWord
144 call AuxIO_TeletypeNL
145
146 ; CHS to LBA
147 mov dx,1
148 mov ax,29e5h
149 mov bx,23h
150 mov cx,9h
151 call CONV_CHS2LBA
152 call AuxIO_TeletypeHexDWord
153 call AuxIO_TeletypeNL
154
155 popa
156 popf
157 ret
158DEBUG_DumpGeo Endp
159ELSE
160DEBUG_DumpGeo Proc
161 ret
162DEBUG_DumpGeo Endp
163ENDIF
164
165
166
167;
168; Dump the internal partition table.
169;
170IF 0
171DEBUG_DumpIPT Proc
172 pushf
173 pusha
174
175 call AuxIO_TeletypeNL
176
177 mov si,offset [BIOScontIPTentry]
178 ;~ mov si,offset [PartitionTable]
179 call AuxIO_DumpSector
180
181 popa
182 popf
183 ret
184DEBUG_DumpIPT EndP
185ELSE
186DEBUG_DumpIPT Proc
187 ret
188DEBUG_DumpIPT EndP
189ENDIF
190
191
192
193;
194; Dump the new partitions table.
195;
196IF 0
197DEBUG_DumpNewPartTable Proc
198 pushf
199 pusha
200
201 call AuxIO_TeletypeNL
202
203 mov si,offset [NewPartTable]
204 call AuxIO_DumpSector
205
206 popa
207 popf
208 ret
209DEBUG_DumpNewPartTable EndP
210DEBUG_DumpNewPartTable Proc
211 ret
212DEBUG_DumpNewPartTable EndP
213ENDIF
214
215
216
217;
218; Dump the partition pointers table.
219;
220IF 0
221DEBUG_DumpPartitionPointers Proc
222 pushf
223 pusha
224
225 call AuxIO_TeletypeNL
226
227 mov si,offset [PartitionPointers]
228 mov cx,7
229
230 DEBUG_DumpPartitionPointers_next:
231 call AuxIO_DumpParagraph
232 add si,16
233 call AuxIO_TeletypeNL
234 loop DEBUG_DumpPartitionPointers_next
235
236 popa
237 popf
238 ret
239DEBUG_DumpPartitionPointers EndP
240ELSE
241DEBUG_DumpPartitionPointers Proc
242 ret
243DEBUG_DumpPartitionPointers EndP
244ENDIF
245
246
247
248;
249; Dump the partition x-ref table.
250;
251IF 0
252xrt db 10,'XrefTable:',10,0
253DEBUG_DumpPartitionXref Proc
254 pushf
255 pusha
256
257 mov si, offset [xrt]
258 call AuxIO_Print
259 ;~ call AuxIO_TeletypeNL
260
261 mov si,offset [PartitionXref]
262 mov cx,3
263
264 DEBUG_DumpPartitionXref_next:
265 call AuxIO_DumpParagraph
266 add si,16
267 call AuxIO_TeletypeNL
268 loop DEBUG_DumpPartitionXref_next
269
270 popa
271 popf
272 ret
273DEBUG_DumpPartitionXref EndP
274ELSE
275DEBUG_DumpPartitionXref Proc
276 ret
277DEBUG_DumpPartitionXref EndP
278ENDIF
279
280
281
282;
283; Dump the dl-feature drive-letters.
284;
285IF 0
286ddl db 10,'Driveletters:',10,0
287DEBUG_DumpDriveLetters Proc
288 pushf
289 pusha
290
291 mov si, offset [ddl]
292 call AuxIO_Print
293
294 ; Dump the old drive-letters as set with the dl-feature.
295 mov si,offset [DriveLetters]
296 mov cx,3
297 DEBUG_DumpDriveLetters_next_1:
298 call AuxIO_DumpParagraph
299 add si,16
300 call AuxIO_TeletypeNL
301 loop DEBUG_DumpDriveLetters_next_1
302
303 ; Dump the new drive-letters as composed when scanning partitions
304 ; and partitions were added or removed.
305 mov si,offset [NewDriveLetters]
306 mov cx,3
307 DEBUG_DumpDriveLetters_next_2:
308 call AuxIO_DumpParagraph
309 add si,16
310 call AuxIO_TeletypeNL
311 loop DEBUG_DumpDriveLetters_next_2
312
313 popa
314 popf
315 ret
316DEBUG_DumpDriveLetters EndP
317ELSE
318DEBUG_DumpDriveLetters Proc
319 ret
320DEBUG_DumpDriveLetters EndP
321ENDIF
322
323
324
325;
326; Dump some disk information.
327;
328IF 0
329ddi db 10,'DumpDiskInfo:',10,0
330DEBUG_DumpDiskInfo Proc
331 pushf
332 pusha
333
334 add al, 50h ; ASCII '0' to BIOS 80h, '1'->81h, etc.
335
336 mov si, offset [ddi]
337 call AuxIO_Print
338
339 call AuxIO_TeletypeHexByte
340 call AuxIO_TeletypeNL
341
342 popa
343 popf
344 ret
345DEBUG_DumpDiskInfo EndP
346ELSE
347DEBUG_DumpDiskInfo Proc
348 ret
349DEBUG_DumpDiskInfo EndP
350ENDIF
351
352
353
354;
355; Dump the lvm volume drive-letters.
356;
357IF 0
358dvl db 10,'VolumeLetters:',10,0
359DEBUG_DumpVolumeLetters Proc
360 pushf
361 pusha
362
363 mov si, offset [dvl]
364 call AuxIO_Print
365
366 mov si,offset [PartitionVolumeLetters]
367 mov cx,3
368
369 DEBUG_DumpVolumeLetters_next:
370 call AuxIO_DumpParagraph
371 add si,16
372 call AuxIO_TeletypeNL
373 loop DEBUG_DumpVolumeLetters_next
374
375 popa
376 popf
377 ret
378DEBUG_DumpVolumeLetters EndP
379ELSE
380DEBUG_DumpVolumeLetters Proc
381 ret
382DEBUG_DumpVolumeLetters EndP
383ENDIF
384
385
386
387;
388; Dump the registers and flags.
389;
390IF 1
391regAX db 'AX:',0
392regBX db ' BX:',0
393regCX db ' CX:',0
394regDX db ' DX:',0
395regSI db ' SI:',0
396regDI db ' DI:',0
397
398regBP db 'CS:',0
399regSP db ' DS:',0
400regCS db ' ES:',0
401regSS db ' SS:',0
402regDS db ' SP:',0
403regES db ' BP:',0
404
405regFS db 'FS:',0
406regGS db ' GS:',0
407
408 db ' '
409
410flagsSF db ' SF:',0
411flagsZF db ' ZF:',0
412flagsAF db ' AF:',0
413flagsPF db ' PF:',0
414flagsCF db ' CF:',0
415
416DEBUG_DumpRegisters Proc
417 pushf
418 pusha
419
420 ; Safe flags so they can be printed later
421 pushf
422
423 ; Save value in SI so it can be printed later
424 push si
425
426 ; Base of registers string
427 mov si, offset [regAX]
428
429 ; AX
430 call AuxIO_Print
431 call AuxIO_TeletypeHexWord
432
433 ; BX
434 call AuxIO_Print
435 mov ax,bx
436 call AuxIO_TeletypeHexWord
437
438 ; CX
439 call AuxIO_Print
440 mov ax,cx
441 call AuxIO_TeletypeHexWord
442
443 ; DX
444 call AuxIO_Print
445 mov ax,dx
446 call AuxIO_TeletypeHexWord
447
448 ; SI
449 call AuxIO_Print
450 pop ax
451 call AuxIO_TeletypeHexWord
452
453 ; DI
454 call AuxIO_Print
455 mov ax,di
456 call AuxIO_TeletypeHexWord
457
458 ; 1st row printed
459 call AuxIO_TeletypeNL
460
461 ; CS
462 call AuxIO_Print
463 mov ax,cs
464 call AuxIO_TeletypeHexWord
465
466 ; DS
467 call AuxIO_Print
468 mov ax,ds
469 call AuxIO_TeletypeHexWord
470
471 ; ES
472 call AuxIO_Print
473 mov ax,es
474 call AuxIO_TeletypeHexWord
475
476 ; SS
477 call AuxIO_Print
478 mov ax,ss
479 call AuxIO_TeletypeHexWord
480
481 ; SP
482 call AuxIO_Print
483 mov ax,sp
484 call AuxIO_TeletypeHexWord
485
486 ; BP
487 call AuxIO_Print
488 mov ax,bp
489 call AuxIO_TeletypeHexWord
490
491 ; 2nd row printed
492 call AuxIO_TeletypeNL
493.386
494 ; FS
495 call AuxIO_Print
496 mov ax,fs
497 call AuxIO_TeletypeHexWord
498
499 ; GS
500 call AuxIO_Print
501 mov ax,gs
502 call AuxIO_TeletypeHexWord
503 ;~ call AuxIO_TeletypeNL
504.286
505 ; Restore the flags
506 popf
507
508 ; Load flags into AH
509 lahf
510
511 ; Base of flags string
512 ;~ mov si, offset [flagsSF]
513
514 ; SF
515 call AuxIO_Print
516 mov al, ah
517 shr al, 7
518 and al, 01h
519 add al, '0'
520 call AuxIO_Teletype
521
522 ; ZF
523 call AuxIO_Print
524 mov al, ah
525 shr al, 6
526 and al, 01h
527 add al, '0'
528 call AuxIO_Teletype
529
530 ; AF
531 call AuxIO_Print
532 mov al, ah
533 shr al, 4
534 and al, 01h
535 add al, '0'
536 call AuxIO_Teletype
537
538 ; PF
539 call AuxIO_Print
540 mov al, ah
541 shr al, 2
542 and al, 01h
543 add al, '0'
544 call AuxIO_Teletype
545
546 ; CF
547 call AuxIO_Print
548 mov al, ah
549 and al, 01h
550 add al, '0'
551 call AuxIO_Teletype
552
553 ; 3rd and last row printed
554 call AuxIO_TeletypeNL
555
556 popa
557 popf
558 ret
559DEBUG_DumpRegisters EndP
560ELSE
561DEBUG_DumpRegisters Proc
562 ret
563DEBUG_DumpRegisters EndP
564ENDIF
565
566
567
568;
569; Dump CHS values.
570;
571IF 0
572DEBUG_DumpCHS Proc Near
573 pushf
574 pusha
575 mov al,'C'
576 call AuxIO_Teletype
577 mov al,':'
578 call AuxIO_Teletype
579 mov ah,cl
580 shr ah,6
581 mov al,ch
582 call AuxIO_TeletypeHexWord
583 mov al,' '
584 call AuxIO_Teletype
585 mov al,'H'
586 call AuxIO_Teletype
587 mov al,':'
588 call AuxIO_Teletype
589 mov al,dh
590 call AuxIO_TeletypeHexByte
591 mov al,' '
592 call AuxIO_Teletype
593 mov al,'S'
594 call AuxIO_Teletype
595 mov al,':'
596 call AuxIO_Teletype
597 mov al,cl
598 and al,00111111b
599 call AuxIO_TeletypeHexByte
600 call AuxIO_TeletypeNL
601 popa
602 popf
603 ret
604DEBUG_DumpCHS EndP
605ELSE
606DEBUG_DumpCHS Proc Near
607 ret
608DEBUG_DumpCHS EndP
609ENDIF
610
611
612
613;
614; Dump BSS.
615;
616IF 0
617DEBUG_DumpBSSSectors Proc Near
618 pushf
619 pusha
620
621 mov si, offset [PartitionSector]
622 call AuxIO_DumpSector
623 call AuxIO_TeletypeNL
624
625 mov si, offset [PBRSector]
626 call AuxIO_DumpSector
627 call AuxIO_TeletypeNL
628
629 mov si, offset [LVMSector]
630 call AuxIO_DumpSector
631 call AuxIO_TeletypeNL
632
633 mov si, offset [TmpSector]
634 call AuxIO_DumpSector
635 call AuxIO_TeletypeNL
636
637 mov si, offset [NewPartTable]
638 call AuxIO_DumpSector
639 call AuxIO_TeletypeNL
640 call AuxIO_TeletypeNL
641
642 popa
643 popf
644 ret
645DEBUG_DumpBSSSectors EndP
646ELSE
647DEBUG_DumpBSSSectors Proc Near
648 ret
649DEBUG_DumpBSSSectors EndP
650ENDIF
651
652
653
654;
655; Dump 6-bit packed hide partition table.
656;
657IF 0
658DEBUG_DumpHidePartTables Proc Near
659 pushf
660 pusha
661
662 mov cx,3
663 mov si, offset [HidePartitionTable]
664 again1:
665 call AuxIO_DumpSector
666 add si,512
667 loop again1
668 call AuxIO_TeletypeNL
669
670 mov cx,3
671 mov si, offset [PartitionXref]
672 again2:
673 call AuxIO_DumpParagraph
674 call AuxIO_TeletypeNL
675 add si,16
676 loop again2
677 call AuxIO_TeletypeNL
678
679 mov cx,3
680 mov si, offset [NewHidePartTable]
681 again3:
682 call AuxIO_DumpSector
683 add si,512
684 loop again3
685 call AuxIO_TeletypeNL
686
687 popa
688 popf
689 ret
690DEBUG_DumpHidePartTables EndP
691ELSE
692DEBUG_DumpHidePartTables Proc Near
693 ret
694DEBUG_DumpHidePartTables EndP
695ENDIF
696
697
698
699; ============================================================== [ test stuff ]
700
701;
702; Activate zero or more test functions.
703; When a call is _not_ commented out, the test-function can still be disabled
704; if its 'IF' directive is 0.
705;
706IF 1
707DEBUG_Test Proc
708 pushf
709 pusha
710 call DEBUG_Test_CONV_BinToPBCD
711 ;~ call DEBUG_Test_MATH_Mul32
712 popa
713 popf
714 ret
715DEBUG_Test EndP
716ELSE
717DEBUG_Test Proc
718 ret
719DEBUG_Test EndP
720ENDIF
721
722
723
724;
725; Test the packed BCD conversion function.
726;
727IF 1
728db_testbin2pbcd db "## TEST BIN2PBCD ##",10,0
729DEBUG_Test_CONV_BinToPBCD Proc
730 pushf
731 pusha
732
733 ; Msg test bin2pbcd
734 mov si,offset [db_testbin2pbcd]
735 call AuxIO_Print
736
737 ; Start with 0
738 xor cx, cx
739
740 ; Print 0 - 255 as BYTE and packed BCD
741 next_value:
742 mov al, cl ; Current value
743 call AuxIO_TeletypeHexByte ; Print as byte
744 mov al, ' '
745 call AuxIO_Teletype
746 mov al, cl ; Current value
747 call CONV_BinToPBCD ; Convert to packed BCD
748 call AuxIO_TeletypeHexWord ; Print as word
749 call AuxIO_TeletypeNL
750
751 inc cx ; Next value
752 cmp cx, 0ffh ; Check for last valid value
753 jbe next_value ; Repeat if still in range
754
755 popa
756 popf
757 ret
758DEBUG_Test_CONV_BinToPBCD EndP
759ELSE
760DEBUG_Test_CONV_BinToPBCD Proc
761 ret
762DEBUG_Test_CONV_BinToPBCD EndP
763ENDIF
764
765
766
767;
768; Test the simple 32-bit math functions.
769;
770IF 0
771db_testmul32 db "## TEST MUL32 ##",10,0
772DEBUG_Test_MATH_Mul32 Proc Near
773 pushf
774 pusha
775
776 ; Msg test math-module
777 mov si,offset [db_testmul32]
778 call AuxIO_Print
779
780 ; Output hex-word
781 mov ax,0BABEh
782 call AuxIO_TeletypeHexWord
783
784 mov al,' '
785 call AuxIO_Teletype
786 mov al,'*'
787 call AuxIO_Teletype
788 mov al,' '
789 call AuxIO_Teletype
790
791 ; Output hex-word
792 mov ax,0BABEh
793 call AuxIO_TeletypeHexWord
794
795 mov al,' '
796 call AuxIO_Teletype
797 mov al,'='
798 call AuxIO_Teletype
799 mov al,' '
800 call AuxIO_Teletype
801
802 mov ax,0BABEh
803 mul ax
804 call AuxIO_TeletypeHexDWord
805
806 ; Start new line
807 call AuxIO_TeletypeNL
808
809 ; Output hex-dword
810 mov dx,0DEADh
811 mov ax,0FACEh
812 call AuxIO_TeletypeHexDWord
813
814 mov al,' '
815 call AuxIO_Teletype
816 mov al,'*'
817 call AuxIO_Teletype
818 mov al,' '
819 call AuxIO_Teletype
820
821 ; Output hex-dword
822 mov dx,0DEADh
823 mov ax,0FACEh
824 call AuxIO_TeletypeHexDWord
825
826 mov al,' '
827 call AuxIO_Teletype
828 mov al,'='
829 call AuxIO_Teletype
830 mov al,' '
831 call AuxIO_Teletype
832
833 mov bx,0DEADh
834 mov cx,0FACEh
835 mov dx,0DEADh
836 mov ax,0FACEh
837 call MATH_Mul32
838 call AuxIO_TeletypeHexQWord
839
840 call AuxIO_TeletypeNL
841 call AuxIO_TeletypeNL
842
843 popa
844 popf
845 ret
846DEBUG_Test_MATH_Mul32 EndP
847ELSE
848DEBUG_Test_MATH_Mul32 Proc Near
849 ret
850DEBUG_Test_MATH_Mul32 EndP
851ENDIF
852
853
854
855;
856; Test the bitfield routines.
857;
858IF 0
859DEBUG_TestBitFieldFunctions Proc
860 pushf
861 pusha
862
863 mov bx,offset [dbg_scratch]
864
865 mov al,0
866 mov dl,0
867 mov dh,6
868 DEBUG_TestBitFieldFunctions_next_write:
869 call CONV_SetBitfieldValue
870 inc al
871 inc dl
872 jnz DEBUG_TestBitFieldFunctions_next_write
873
874 mov dl,0
875 mov dh,6
876 DEBUG_TestBitFieldFunctions_next_read:
877 mov al,dl
878 call AuxIO_TeletypeHexByte
879 mov al,':'
880 call AuxIO_Teletype
881 call CONV_GetBitfieldValue
882 call AuxIO_TeletypeHexWord
883 call AuxIO_TeletypeNL
884 inc dl
885 jnz DEBUG_TestBitFieldFunctions_next_read
886
887 popa
888 popf
889 ret
890DEBUG_TestBitFieldFunctions EndP
891ELSE
892DEBUG_TestBitFieldFunctions Proc
893 ret
894DEBUG_TestBitFieldFunctions EndP
895ENDIF
896
897
898
899;
900; Like the MBR version, but uses video page 3.
901;
902DBG_Teletype Proc Near Uses ax bx cx
903 mov ah, 0Eh
904 mov bh, 03h
905 mov bl, 07h
906 DBGT_Loop:
907 lodsb
908 or al, al
909 jz DBGT_End
910 int 10h
911 jmp DBGT_Loop
912 DBGT_End:
913 ret
914DBG_Teletype EndP
915
916
917
918;
919; Dump information before the menu is displayed.
920;
921DEBUG_Dump1 Proc Near
922 pushf
923 pusha
924
925 ; Hello message
926 mov si, offset AuxIOHello
927 call AuxIO_Print
928
929 ; Build Info
930 ;~ mov si, offset BUILD_DATE
931 ;~ call AuxIO_Print
932 call AuxIO_PrintBuildInfo
933
934 ; Start new line
935 call AuxIO_TeletypeNL
936 ;~ call AuxIO_TeletypeNL
937
938 ;~ call DEBUG_DumpHidePartTables
939 ;~ call DEBUG_CheckMath
940 ;~ call DEBUG_DumpGeo
941 ;~ call DEBUG_CheckBitFields
942
943 popa
944 popf
945 ret
946DEBUG_Dump1 EndP
947
948
949
950;
951; Dump information before the partition is booted.
952;
953IF 0
954DEBUG_Dump2 Proc Near
955 pushf
956 pusha
957
958 call AuxIO_TeletypeNL
959 call AuxIO_TeletypeNL
960
961 mov si,offset db_config
962 call AuxIO_Print
963
964 mov si,offset db_cfgparts
965 call AuxIO_Print
966 mov al,[CFG_Partitions]
967 call AuxIO_TeletypeHexByte
968 call AuxIO_TeletypeNL
969
970 mov si,offset db_cfgpartdef
971 call AuxIO_Print
972 mov al,[CFG_PartDefault]
973 call AuxIO_TeletypeHexByte
974 call AuxIO_TeletypeNL
975
976 mov si,offset db_cfgpartlast
977 call AuxIO_Print
978 mov al,[CFG_PartLast]
979 call AuxIO_TeletypeHexByte
980 call AuxIO_TeletypeNL
981 call AuxIO_TeletypeNL
982
983 mov si,offset db_vars
984 call AuxIO_Print
985
986 mov si,offset db_newpart
987 call AuxIO_Print
988 mov si,offset NewPartTable
989 call AuxIO_DumpSector
990 call AuxIO_TeletypeNL
991 add si,512
992 call AuxIO_DumpSector
993 call AuxIO_TeletypeNL
994 call AuxIO_TeletypeNL
995
996 mov si,offset db_newhide
997 call AuxIO_Print
998 mov si,offset NewHidePartTable
999 call AuxIO_DumpSector
1000 call AuxIO_TeletypeNL
1001 add si,512
1002 call AuxIO_DumpSector
1003 call AuxIO_TeletypeNL
1004 call AuxIO_TeletypeNL
1005
1006 mov si,offset db_dletters
1007 call AuxIO_Print
1008 mov si,offset NewDriveLetters
1009 call AuxIO_DumpParagraph
1010 call AuxIO_TeletypeNL
1011 add si,16
1012 call AuxIO_DumpParagraph
1013 call AuxIO_TeletypeNL
1014 call AuxIO_TeletypeNL
1015
1016 mov si,offset db_tmpec
1017 call AuxIO_Print
1018 mov si,offset TmpSector
1019 call AuxIO_DumpSector
1020 call AuxIO_TeletypeNL
1021 call AuxIO_TeletypeNL
1022
1023 mov si,offset db_partsec
1024 call AuxIO_Print
1025 mov si,offset PartitionSector
1026 call AuxIO_DumpSector
1027 call AuxIO_TeletypeNL
1028 call AuxIO_TeletypeNL
1029
1030 popa
1031 popf
1032 ret
1033DEBUG_Dump2 EndP
1034ELSE
1035DEBUG_Dump2 Proc Near
1036 ret
1037DEBUG_Dump2 EndP
1038ENDIF
1039
1040
1041
1042;
1043; Display a number that was put on the stack.
1044; Used to track code-flow.
1045;
1046dbp db '>---------->> DebugProbe: ',0
1047DEBUG_Probe Proc
1048 push bp
1049 mov bp,sp
1050 pushf
1051 pusha
1052
1053 mov si,offset [dbp] ; Default probe-text.
1054 call AuxIO_Print
1055 mov ax,[bp+04] ; Get probe-number from stack.
1056 call AuxIO_TeletypeHexWord
1057 call AuxIO_TeletypeNL
1058
1059 ; Also display registers.
1060 popa
1061 pusha
1062 call DEBUG_DumpRegisters
1063
1064 popa
1065 popf
1066 pop bp
1067 ret 2
1068DEBUG_Probe Endp
1069
1070
1071
1072;
1073; Toggle display of debug video page.
1074;
1075IF 0
1076DEBUG_DebugScreenToggle Proc
1077 pushf
1078 pusha
1079
1080 mov si, offset $+5
1081 jmp @F
1082 db 10,'DebugScreenToggle:',10,0
1083prvpg db 00h
1084hdr db 10,'[Debug Console]',13,10,0
1085@@: call AuxIO_Print
1086
1087 ; Get current page in BH
1088 mov ah, 0fh
1089 int 10h
1090
1091 ; Already debug page ?
1092 cmp bh, 03h
1093 je DEBUG_DebugScreenToggle_back
1094
1095 ; Remember page
1096 mov [prvpg], bh
1097
1098 ; Switch to debug page
1099 mov al, 03h
1100 mov ah, 05h
1101 int 10h
1102
1103 ; Get cursor position in DX (DH=row, DL=column)
1104 ;~ mov ah, 03h
1105 ;~ mov bh, 03h
1106 ;~ int 10h
1107
1108 ;~ mov al, 01h
1109 ;~ mov bh, 03h
1110 ;~ mov bl, 07h
1111 ;~ mov bp, offset [hdr]
1112 ;~ mov cx, sizeof(hdr)
1113 ;~ mov ah, 13h
1114 ;~ int 10h
1115
1116 ;~ mov bh, 03h
1117 ;~ mov dh, 00h
1118 ;~ mov dl, 00h
1119 ;~ mov ah, 02h
1120 ;~ int 10h
1121
1122 mov si, offset [hdr]
1123 call DBG_Teletype
1124
1125 jmp DEBUG_DebugScreenToggle_end
1126
1127 DEBUG_DebugScreenToggle_back:
1128 ; Switch back to previous page
1129 mov al, [prvpg]
1130 mov ah, 05h
1131 int 10h
1132 jmp DEBUG_DebugScreenToggle_end
1133
1134 DEBUG_DebugScreenToggle_end:
1135 popa
1136 popf
1137 ret
1138DEBUG_DebugScreenToggle EndP
1139ELSE
1140DEBUG_DebugScreenToggle Proc
1141 ret
1142DEBUG_DebugScreenToggle EndP
1143ENDIF
1144
1145
1146
1147;
1148; Handle keypresses when the main menu is active.
1149;
1150DEBUG_HandleKeypress Proc
1151 pushf
1152 pusha
1153
1154 ; Save hot-key
1155 mov dl,al
1156
1157 ; Check for digit.
1158 cmp al,'0'
1159 jb DEBUG_HandleKeypress_exit
1160 cmp al,'9'
1161 ja DEBUG_HandleKeypress_try_alpha
1162 ; It was a digit, dump disk info ('0' for 80h, '1' for 81h, etc)
1163 call DEBUG_DumpDiskInfo
1164 ;~ jmp DEBUG_HandleKeypress_check_it
1165 jmp DEBUG_HandleKeypress_exit
1166
1167 ; Check for alpha.
1168 DEBUG_HandleKeypress_try_alpha:
1169 ; Force upper-case.
1170 and al,11011111b
1171 cmp al,'A'
1172 jb DEBUG_HandleKeypress_exit
1173 cmp al,'Z'
1174 ja DEBUG_HandleKeypress_exit
1175 ; It was an alpha.
1176 jmp DEBUG_HandleKeypress_check_it
1177
1178
1179 ; Check if the key is a hot-key.
1180 DEBUG_HandleKeypress_check_it:
1181 cld
1182 mov si,offset dbg_dispatch
1183
1184 ; Loop over jump-list.
1185 DEBUG_HandleKeypress_next_entry:
1186
1187 ; Load the hot-key.
1188 lodsb
1189 ; No hot-key (not implemented) if end-of-list.
1190 test al,al
1191 jz DEBUG_HandleKeypress_ni
1192
1193 ; Compare hot-key and iterate if not the same.
1194 cmp dl,al
1195 lodsw
1196 jne DEBUG_HandleKeypress_next_entry
1197
1198 ; Entry found, call corresponding routine.
1199 mov bx,ax
1200 call bx
1201
1202 ; Done.
1203 jmp DEBUG_HandleKeypress_exit
1204
1205 ; Call not-assigned routine.
1206 DEBUG_HandleKeypress_ni:
1207 call DEBUG_NotAssigned
1208 jmp DEBUG_HandleKeypress_exit
1209
1210 ; Return to caller.
1211 DEBUG_HandleKeypress_exit:
1212 popa
1213 popf
1214 ret
1215DEBUG_HandleKeypress Endp
1216
1217
1218
1219;
1220; These strings can also be referenced outside the debug module when debugging
1221; is enabled.
1222;
1223dlra db 10,'LVM_DoLetterReassignment: ',0
1224ptetb db 10,'Partition Table Entry to boot',10,0
1225bios_reg db 10,'Registers passed by BIOS:',10,0
1226;~ diopmbr db 10,'DriveIO_ProtectMBR',10,0
1227dioss db 10,'DriveIO_SaveSector',10,0
1228
1229
1230;~ db_mbr db "## MBR ##",10,0
1231;~ db_masterlvm db "## MLVMR ##",10,0
1232
1233
1234;~ db_config db '## CFG (DMP2) ##',10,0
1235;~ db_cfgparts db 'CFG_Partitions:',0
1236;~ db_cfgpartdef db 'CFG_PartDefault:',0
1237;~ db_cfgpartlast db 'CFG_PartLast:',0
1238
1239
1240;~ db_vars db '## VARS ##',10,0
1241;~ db_partsec db 'PartitionSector:',10,0
1242;~ db_lvmsec db 'LVMSector :',10,0
1243;~ db_tmpec db 'TmpSector :',10,0
1244
1245;~ db_newpart db 'NewPartTable :',10,0
1246;~ db_newhide db 'NewHideTable:',10,0
1247;~ db_dletters db 'NewDriveLetters:',10,0
1248
1249;~ db_partsize db 'PartitionSizeTable:',10,0
1250;~ db_partpoint db 'PartitionPointers:',10,0
1251;~ db_partpointcnt db 'PartitionPointerCount:',0
1252;~ db_partxref db 'PartitionXref:',10,0
1253;~ db_partvoldl db 'PartitionVolumeLetters:',10,0
1254
1255;~ db_totaldisks db 'TotalHarddiscs:',0
1256;~ db_lbaswitchtab db 'LBASwitchTable:',10,0
1257;~ db_newparts db 'NewPartitions:',0
1258
1259;~ db_exabspos db 'ExtendedAbsPos:',0
1260;~ db_exabsposset db 'ExtendedAbsPosSet:',0
1261
1262;~ db_curpartloc db 'CurPartition_Location:',0
1263;~ db_curiox db 'CurIO_UseExtension:',0
1264
1265;~ db_curlvmsec db 'Current LVM Sector:',0
1266
1267
1268;~ drive db 'drive : ',0
1269;~ before_lvm_adjust db 'before lvm adjust : ',0
1270;~ after_lvm_adjust db 'after lvm adjust : ',0
1271;~ before_lvm_adjust_log db 'before lvm logical adjust: ',0
1272;~ after_lvm_adjust_log db 'after lvm logical adjust : ',0
1273;~ spt_used db 'spt used : ',0
Note: See TracBrowser for help on using the repository browser.