mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
Prekernel: Split early boot printing into two subroutines
This commit is contained in:
parent
0a54a86a8b
commit
e8808b259a
1 changed files with 46 additions and 17 deletions
|
@ -98,6 +98,46 @@ code64_sel:
|
||||||
start:
|
start:
|
||||||
jmp real_start
|
jmp real_start
|
||||||
|
|
||||||
|
/*
|
||||||
|
param 1: pointer to C string
|
||||||
|
returns: Length of string (including null byte)
|
||||||
|
*/
|
||||||
|
print_no_halt:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp, %ebp
|
||||||
|
|
||||||
|
pushl %esi
|
||||||
|
pushl %ecx
|
||||||
|
|
||||||
|
movl 8(%ebp), %esi
|
||||||
|
|
||||||
|
mov $0xb8000, %ecx /* VRAM address. */
|
||||||
|
mov $0x07, %ah /* grey-on-black text. */
|
||||||
|
|
||||||
|
.Lprint_str_loop:
|
||||||
|
lodsb /* Loads a byte from address at %esi into %al and increments %esi. */
|
||||||
|
|
||||||
|
test %al, %al
|
||||||
|
jz .Lprint_str_end
|
||||||
|
|
||||||
|
movw %ax, (%ecx)
|
||||||
|
add $2, %ecx
|
||||||
|
|
||||||
|
jmp .Lprint_str_loop
|
||||||
|
.Lprint_str_end:
|
||||||
|
|
||||||
|
mov %esi, %eax
|
||||||
|
sub 8(%ebp), %eax
|
||||||
|
|
||||||
|
popl %ecx
|
||||||
|
popl %esi
|
||||||
|
|
||||||
|
movl %ebp, %esp
|
||||||
|
popl %ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this function assumes that paging is disabled (or everything is mapped 1:1)
|
this function assumes that paging is disabled (or everything is mapped 1:1)
|
||||||
param 1: pointer to string ended with null terminator (C string)
|
param 1: pointer to string ended with null terminator (C string)
|
||||||
|
@ -122,24 +162,13 @@ print_and_halt:
|
||||||
movl %esp, %ebp
|
movl %esp, %ebp
|
||||||
movl 4(%ebp), %esi
|
movl 4(%ebp), %esi
|
||||||
|
|
||||||
mov $0xb8000, %ecx /* VRAM address. */
|
/* Print string using non-destructive methods */
|
||||||
mov $0x07, %ah /* grey-on-black text. */
|
pushl %esi
|
||||||
|
call print_no_halt
|
||||||
|
addl $4, %esp
|
||||||
|
|
||||||
.print_str_loop:
|
/* print_no_halt returns the string length (including null byte) in eax. */
|
||||||
lodsb /* Loads a byte from address at %esi into %al and increments %esi. */
|
mov %eax, %ecx
|
||||||
|
|
||||||
test %al, %al
|
|
||||||
jz .print_str_end
|
|
||||||
|
|
||||||
movw %ax, (%ecx)
|
|
||||||
add $2, %ecx
|
|
||||||
|
|
||||||
jmp .print_str_loop
|
|
||||||
.print_str_end:
|
|
||||||
|
|
||||||
/* Calculate string length into %ecx */
|
|
||||||
mov %esi, %ecx
|
|
||||||
sub 4(%ebp), %ecx
|
|
||||||
movw %cx, (COPIED_STRING_LOCATION) /* Store string length for later use. */
|
movw %cx, (COPIED_STRING_LOCATION) /* Store string length for later use. */
|
||||||
|
|
||||||
/* Copy string into lower memory */
|
/* Copy string into lower memory */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue