Skip to content

Commit 4023e3a

Browse files
Fix shadow mem en efi_print.
1 parent 8f5036a commit 4023e3a

File tree

3 files changed

+70
-20
lines changed

3 files changed

+70
-20
lines changed

asm/boot/uefi.asm

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ get_memmap:
642642

643643
;; TODO: print_memmpap_info, pero aqui no la puedo hacer ya que luego de obtener
644644
;; mapa de mem, inmediatamente debo hacer el exit.
645-
.print_info_memmap
645+
.print_info_memmap:
646646
mov rdx, 0
647647
mov rax, [memmapsize]
648648
mov rcx, [memmapdescsize]
@@ -715,14 +715,15 @@ exit_uefi_services:
715715
rep stosq
716716

717717

718-
;; TODO: poleo para poder promptear ahora que hemos salido de bootservices.
719-
mov r9, msg_boot_services_exit_ok
720-
call print
721-
;;call prompt_step_mode ;; Ultima parada antes de ir al bootloader.
722-
call emptyKbBuffer
723-
call getKey
718+
;;mov rax, 0x00000000000101F0
719+
;;call keyboard_command
724720

725721

722+
;; Poleo para poder promptear ahora que hemos salido de bootservices.
723+
mov r9, msg_boot_services_exit_ok
724+
call print
725+
call emptyKbBuffer
726+
call keyboard_get_key
726727

727728
; Clear registers
728729
xor eax, eax
@@ -765,7 +766,6 @@ error_fatal8:
765766
hlt
766767
jmp .halt
767768

768-
769769
payloadSignatureFail:
770770
mov r9, msg_badPayloadSignature
771771
call print
@@ -788,6 +788,9 @@ halt:
788788
;; unico que recibe en rsi).
789789
;;==============================================================================
790790

791+
;; TODO: revisar si EFI_OUT_OUTPUTSTRING retorna alterando el rsp porque veo que
792+
;; sin stack frame resulta falla.
793+
791794
efi_print:
792795
push rbp
793796
mov rbp, rsp
@@ -865,8 +868,11 @@ efi_print:
865868
.end_placeholder:
866869
mov word [volatile_placeholder + 2 * rdi], 0x0000
867870
mov rdx, volatile_placeholder
868-
mov rcx, [TXT_OUT_INTERFACE]
871+
mov rcx, [TXT_OUT_INTERFACE]
872+
873+
sub rsp, 8 * 4
869874
call [rcx + EFI_OUT_OUTPUTSTRING]
875+
add rsp, 8 * 2
870876

871877
mov rsp, rbp
872878
pop rbp
@@ -1026,7 +1032,9 @@ prompt_step_mode:
10261032
.pedir_tecla:
10271033
mov rcx, [TXT_IN_INTERFACE]
10281034
mov rdx, EFI_INPUT_KEY
1035+
sub rsp, 8 * 4
10291036
call [rcx + EFI_INPUT_READ_KEY] ;; SIMPLE_INPUT.ReadKeyStroke()
1037+
add rsp, 8 * 4
10301038
cmp eax, EFI_NOT_READY ;; No hubo ingreso, me quedo poleando.
10311039
je .pedir_tecla
10321040

@@ -1035,9 +1043,14 @@ prompt_step_mode:
10351043

10361044
mov rcx, [TXT_OUT_INTERFACE]
10371045
mov rdx, msg_efi_input_device_err ;; Notificar, rax = EFI_DEVICE_ERROR
1046+
sub rsp, 8 * 4
10381047
call [rcx + EFI_OUT_OUTPUTSTRING]
1048+
add rsp, 8 * 4
10391049
jmp .pedir_tecla
1040-
1050+
1051+
;; EFI_INPUT_KEY
1052+
;; UINT16 ScanCode;
1053+
;; CHAR16 UnicodeChar;
10411054
.get_key:
10421055
mov dx, [EFI_INPUT_KEY + 2]
10431056
cmp dx, utf16('n')
@@ -1335,30 +1348,72 @@ memsetFramebuffer:
13351348
ret
13361349

13371350

1351+
1352+
;;==============================================================================
1353+
;;
1354+
;;==============================================================================
1355+
;; Argumentos:
1356+
;; -- al = command
1357+
;; -- ah = byte requerido por el comando (de ser necesario)
1358+
;; -- bit 16 de rax = 0 si comando no requiere ah, 1 si comando requiere enviar
1359+
;; ah a continuacion de al.
1360+
;;==============================================================================
1361+
1362+
keyboard_command:
1363+
push rbp
1364+
mov rbp, rsp
1365+
1366+
out 0x64, al
1367+
bt rax, 16
1368+
jnc .fin
1369+
mov al, ah
1370+
out 0x60, al
1371+
1372+
.fin:
1373+
mov rsp, rbp
1374+
pop rbp
1375+
ret
1376+
1377+
13381378
;;==============================================================================
13391379
;;
13401380
;;==============================================================================
13411381
;; Argumentos:
13421382
;;
13431383
;;==============================================================================
13441384

1345-
getKey:
1385+
1386+
1387+
1388+
1389+
keyboard_get_key:
13461390
push rbp
13471391
mov rbp, rsp
1392+
1393+
cmp byte [STEP_MODE_FLAG], 0
1394+
je .fin
1395+
13481396
mov rax, 0
13491397
.loop:
13501398
in al, 0x64
1351-
mov cl, al
13521399
and al, 0x01
13531400
cmp al, 0
13541401
je .loop
13551402
in al, 0x60
13561403

1404+
;; TODO: revisar por que en pc fgr escritorio, llega a bootloader y cualga o se queda aleatoriamente.
1405+
;; Sin estas dos, pasa oka.
1406+
cmp al, 0x31 ;; Scancode tecla 'n'.
1407+
jne .loop
1408+
1409+
.fin:
13571410
mov rsp, rbp
13581411
pop rbp
13591412
ret
13601413

13611414

1415+
1416+
13621417
;;==============================================================================
13631418
;;
13641419
;;==============================================================================
@@ -1430,7 +1485,7 @@ vid_info: dq 0
14301485
;; UINT16 ScanCode;
14311486
;; CHAR16 UnicodeChar;
14321487
;; } EFI_INPUT_KEY;
1433-
EFI_INPUT_KEY dd 0
1488+
EFI_INPUT_KEY dw 0, 0
14341489

14351490
STEP_MODE_FLAG db 1 ;; Lo activa presionar 's' al booteo.
14361491

@@ -1484,7 +1539,7 @@ fmt_edid_validation_fail: dw utf16("EDID validation failure = %s"), 13, 0xA, 0
14841539
str_edid_size_err: dw utf16("error de tamano"), 0
14851540
str_edid_hdr_err: dw utf16("error en el encabezado"), 0
14861541

1487-
fmt_resolution_horizontal: db "Resolution = %d", 0
1542+
fmt_resolution_horizontal: db "Video resolution = %d", 0
14881543
fmt_resolution_vertical: db " x %d", 13, 0xA, 0
14891544
fmt_ppsl: db "PPSL = %d", 0
14901545
fmt_fb_size: db " | Framebuffer = %d bytes", 0
@@ -1513,11 +1568,6 @@ msg_test8: db "Test", 0
15131568

15141569
fmt_memmap_cant_descriptors: db "Uefi returned a memory map | Cant descriptors = %d", 13, 0xA, 0
15151570

1516-
1517-
1518-
1519-
1520-
15211571
msg_acpi_err: dw utf16("ACPI no encontrado."), 0
15221572

15231573
fmt_err_fatal: dw utf16("Error fatal: %s"), 0
@@ -1574,7 +1624,7 @@ font_data:
15741624
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x13 uni0013
15751625
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x14 uni0014
15761626
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x15 uni0015
1577-
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x16 uni0016
1627+
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x16 uni001memmap6
15781628
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x17 uni0017
15791629
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x18 uni0018
15801630
dd 0x00000000, 0x00000000, 0x00000000, 0x00000000 ;; 0x19 uni0019

build/uefi.elf

0 Bytes
Binary file not shown.

build/uefi.sys

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)