@@ -260,6 +260,25 @@ start64:
260260 mov ebx , 0
261261 call debug_block
262262
263+ ; Configure serial port @ 0x03F8 as 115200 8N1
264+ call init_serial
265+
266+ mov rsi , msg_pure64 ; Output "[ Pure64 ]"
267+ call debug_msg
268+
269+ ; Output boot method
270+ mov rsi , msg_boot
271+ call debug_msg
272+ cmp byte [ p_BootMode ], 'U'
273+ je boot_uefi
274+ mov rsi , msg_bios
275+ call debug_msg
276+ jmp msg_boot_done
277+ boot_uefi:
278+ mov rsi , msg_uefi
279+ call debug_msg
280+ msg_boot_done:
281+
263282; Clear out the first 20KiB of memory. This will store the 64-bit IDT, GDT, PML4, PDP Low, and PDP High
264283 mov ecx , 5120
265284 xor eax , eax
@@ -716,25 +735,41 @@ pde_end:
716735 mov ebx , 4
717736 call debug_block
718737
738+ mov rsi , msg_acpi
739+ call debug_msg
719740 call init_acpi ; Find and process the ACPI tables
741+ mov rsi , msg_ok
742+ call debug_msg
720743
721744; Visual Debug (4/8)
722745 mov ebx , 6
723746 call debug_block
724747
748+ mov rsi , msg_bsp
749+ call debug_msg
725750 call init_ cpu ; Configure the BSP CPU
751+ mov rsi , msg_ok
752+ call debug_msg
726753
727754; Visual Debug (5/8)
728755 mov ebx , 8
729756 call debug_block
730757
758+ mov rsi , msg_hpet
759+ call debug_msg
731760 call init_hpet ; Configure the HPET
761+ mov rsi , msg_ok
762+ call debug_msg
732763
733764; Visual Debug (6/8)
734765 mov ebx , 10
735766 call debug_block
736767
768+ mov rsi , msg_smp
769+ call debug_msg
737770 call init_smp ; Init of SMP, deactivate interrupts
771+ mov rsi , msg_ok
772+ call debug_msg
738773
739774; Reset the stack to the proper location (was set to 0x8000 previously)
740775 mov rsi , [ p_LocalAPICAddress ] ; We would call p_smp_get_id here but the stack is not ...
@@ -887,6 +922,9 @@ lfb_wc_end:
887922 mov ebx , 14
888923 call debug_block
889924
925+ mov rsi , msg_kernel
926+ call debug_msg
927+
890928%ifdef BIOS
891929 cmp byte [ p_BootDisk ], 'F' ; Check if sys is booted from floppy?
892930 jnz clear_regs
@@ -916,6 +954,7 @@ clear_regs:
916954%include "init/acpi.asm"
917955%include "init/cpu.asm"
918956%include "init/hpet.asm"
957+ %include "init/serial.asm"
919958%include "init/smp.asm"
920959%ifdef BIOS
921960%include "fdc/dma.asm"
@@ -1010,6 +1049,106 @@ debug_progressbar:
10101049%endif
10111050
10121051
1052+ ; -----------------------------------------------------------------------------
1053+ ; debug_msg_char - Send a single char via the serial port
1054+ ; IN: AL = Byte to send
1055+ debug_msg_char:
1056+ pushf
1057+ push rdx
1058+ push rax ; Save the byte
1059+ mov dx , 0x03F8 ; Address of first serial port
1060+ debug_msg_char_wait:
1061+ add dx , 5 ; Offset to Line Status Register
1062+ in al , dx
1063+ sub dx , 5 ; Back to to base
1064+ and al , 0x20
1065+ cmp al , 0
1066+ je debug_msg_char_wait
1067+ pop rax ; Restore the byte
1068+ out dx , al ; Send the char to the serial port
1069+ debug_msg_char_done:
1070+ pop rdx
1071+ popf
1072+ ret
1073+ ; -----------------------------------------------------------------------------
1074+
1075+
1076+ ; -----------------------------------------------------------------------------
1077+ ; debug_msg_char - Send a message via the serial port
1078+ ; IN: RSI = Location of message
1079+ debug_msg:
1080+ pushf
1081+ push rdx
1082+ push rax
1083+ cld ; Clear the direction flag.. we want to increment through the string
1084+ mov dx , 0x03F8 ; Address of first serial port
1085+ debug_msg_next:
1086+ add dx , 5 ; Offset to Line Status Register
1087+ in al , dx
1088+ sub dx , 5 ; Back to to base
1089+ and al , 0x20
1090+ cmp al , 0
1091+ je debug_msg_next
1092+ lodsb ; Get char from string and store in AL
1093+ cmp al , 0
1094+ je debug_msg_done
1095+ out dx , al ; Send the char to the serial port
1096+ jmp debug_msg_next
1097+ debug_msg_done:
1098+ pop rax
1099+ pop rdx
1100+ popf
1101+ ret
1102+ ; -----------------------------------------------------------------------------
1103+
1104+
1105+ ; -----------------------------------------------------------------------------
1106+ ; debug_dump_(rax|eax|ax|al) -- Dump content of RAX, EAX, AX, or AL
1107+ ; IN: RAX/EAX/AX/AL = content to dump
1108+ ; OUT: Nothing, all registers preserved
1109+ debug_dump_rax:
1110+ rol rax , 8
1111+ call debug_dump_al
1112+ rol rax , 8
1113+ call debug_dump_al
1114+ rol rax , 8
1115+ call debug_dump_al
1116+ rol rax , 8
1117+ call debug_dump_al
1118+ rol rax , 32
1119+ debug_dump_eax: ; RAX is used here instead of EAX to preserve the upper 32-bits
1120+ rol rax , 40
1121+ call debug_dump_al
1122+ rol rax , 8
1123+ call debug_dump_al
1124+ rol rax , 16
1125+ debug_dump_ax:
1126+ rol ax , 8
1127+ call debug_dump_al
1128+ rol ax , 8
1129+ debug_dump_al:
1130+ push rax ; Save RAX
1131+ push ax ; Save AX for the low nibble
1132+ shr al , 4 ; Shift the high 4 bits into the low 4, high bits cleared
1133+ or al , '0' ; Add "0"
1134+ cmp al , '9' + 1 ; Digit?
1135+ jl debug_dump_al_h ; Yes, store it
1136+ add al , 7 ; Add offset for character "A"
1137+ debug_dump_al_h:
1138+ call debug_msg_char
1139+ pop ax ; Restore AX
1140+ and al , 0x0F ; Keep only the low 4 bits
1141+ or al , '0' ; Add "0"
1142+ cmp al , '9' + 1 ; Digit?
1143+ jl debug_dump_al_l ; Yes, store it
1144+ add al , 7 ; Add offset for character "A"
1145+ debug_dump_al_l:
1146+ call debug_msg_char
1147+ pop rax ; Restore RAX
1148+ ret
1149+ ; -----------------------------------------------------------------------------
1150+
1151+
10131152EOF:
10141153 db 0xDE , 0xAD , 0xC0 , 0xDE
10151154
0 commit comments