@@ -34,16 +34,16 @@ HEADER:
3434
3535;; Header DOS, 128 bytes.
3636DOS_SIGNATURE: db "MZ" , 0x00 , 0x00
37- DOS_HDRS: times 60 - ($ - HEADER) db 0
37+ DOS_HDRS: times 60 - ($ - HEADER) db 0
3838PE_SIGNATURE_OFFSET: dd PE_SIGNATURE - START ;; File offset.
3939DOS_STUB: times 64 db 0 ;; No program, zero fill.
4040
4141;; Encabezado PE.
4242PE_SIGNATURE: db "PE" , 0x00 , 0x00
4343
4444;; COFF File Header, 20 bytes.
45- MACHINE_TYPE: dw 0x8664 ;; x86-64 machine.
46- N_SECTIONS: dw 2 ;; Number of entries in section table. Secti
45+ MACHINE_TYPE: dw 0x8664 ;; x86-64 machine.
46+ N_SECTIONS: dw 2 ;; Number of entries in section table. Secti
4747 ;; on table immediately follows the headers.
4848TIMESTAMP: dd 1745097600 ;; File creation, seconds since 1970.
4949SYM_TAB_P2: dd 0 ;; File offset of the COFF symbol table, zer
@@ -68,9 +68,9 @@ CHARACTERISTICS: dw 0x222E ;; Attributes of the file.
6868
6969;; Optional Header Standard Fields
7070OPT_HDR:
71- MAGIC_NUMBER: dw 0x020B ;; PE32+ (64-bit address space) PE format.
72- MAJOR_LINKER_VERSION: db 0
73- MINOR_LINKER_VERSION: db 0
71+ MAGIC_NUMBER: dw 0x020B ;; PE32+ (64-bit address space) PE format.
72+ MAJOR_LINKER_VERSION: db 0
73+ MINOR_LINKER_VERSION: db 0
7474CODE_SIZE: dd CODE_END - CODE ;; Text.
7575INITIALIZED_DATA_SIZE: dd DATA_END - DATA ;; Data.
7676UNINITIALIZED_DATA_SIZE: dd 0x00 ;; Bss.
@@ -115,10 +115,10 @@ OPT_HDR_END:
115115;; Section Table (Section Headers)
116116SECTION_HDRS:
117117SECTION_CODE:
118- .name db ".text" , 0x00 , 0x00 , 0x00
119- .virtual_size dd CODE_END - CODE
120- .virtual_address dd CODE - START
121- .size_of_raw_data dd CODE_END - CODE
118+ .name db ".text" , 0x00 , 0x00 , 0x00
119+ .virtual_size dd CODE_END - CODE
120+ .virtual_address dd CODE - START
121+ .size_of_raw_data dd CODE_END - CODE
122122.pointer_to_raw_data dd CODE - START
123123.pointer_to_relocations dd 0
124124.pointer_to_line_numbers dd 0
@@ -447,9 +447,9 @@ locate_gop_protocol:
447447 ;; 32 UINTN - FrameBufferSize
448448 mov rax , [ VIDEO_INTERFACE ]
449449 add rcx , EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
450- mov rcx , [ rcx ] ;; RCX holds the address of the Mode structure
451- mov eax , [ rcx ] ;; EAX holds UINT32 MaxMode
452- mov [ vid_max ], rax ;; The maximum video modes we can check
450+ mov rcx , [ rcx ] ;; RCX holds the address of the Mode structure.
451+ mov eax , [ rcx ] ;; EAX holds UINT32 MaxMode
452+ mov [ vid_max ], rax ;; The maximum video modes we can check
453453 jmp .video_mode_busca
454454
455455.next:
@@ -487,7 +487,13 @@ locate_gop_protocol:
487487 mov rdx , msg_graphics_mode_info_match
488488 call efi_print
489489
490- call prompt_step_mode ;; Ultima parada antes de que se borre pantalla.
490+ call prompt_step_mode ;; Ultima parada antes de que se borre pantalla.
491+
492+
493+ ;; Buscar info pantalla actual (modo 0), de modo de ya tener config video falle
494+ ;; o no el intento de cambio.
495+
496+ ;; Borrar pantalla.
491497
492498.video_mode_set:
493499 mov rcx , [ VIDEO_INTERFACE ] ;; IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This
@@ -522,7 +528,7 @@ skip_set_video:
522528;; a video, se tiene que poder continuar viendo salida.
523529get_video:
524530
525- ;; Gather video mode details.
531+ ;; Get video mode details.
526532 mov rcx , [ VIDEO_INTERFACE ]
527533 add rcx , EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
528534 mov rcx , [ rcx ]
@@ -551,8 +557,8 @@ get_video:
551557 mov eax , [ rcx + 32 ] ;; PixelsPerScanLine
552558 mov [ PPSL ], rax
553559
554- ;; Info en pantalla de el modo seleccionado y valores que quedaron. Estos so
555- ;; n los seteos que le va a pasar al siguiente bootloader y SO.
560+ ;; Info en pantalla del modo seleccionado y valores que quedaron. Estos son
561+ ;; los seteos que le va a pasar al siguiente bootloader y SO.
556562 mov rsi , [ HR ]
557563 mov rdx , fmt_resolution_horizontal
558564 call efi_print
@@ -641,10 +647,19 @@ get_memmap:
641647
642648exit_uefi_services:
643649
644- ;; TODO: notificar a punto de salir, pero aqui no la puedo hacer ya que lueg
650+ ;; Empiezo a imprimir.
651+ mov rdi , [ FB ]
652+ mov eax , 0x00000000 ; 0x00RRGGBB
653+ mov rcx , [ FB_SIZE ] ;;;;;;;;;; frame buffer size
654+ shr rcx , 2 ; Quick divide by 4 (32-bit colour)
655+ ;;rep stosd
656+
657+ ;; Notificar a punto de salir, pero aqui no la puedo hacer ya que lueg
645658 ;; o de obtener mapa de mem, inmediatamente debo hacer el exit.
646- ;;mov rdx, msg_will_exit_uefi_services
647- ;;call print
659+ mov rax , [ FB ]
660+ mov [ print_cursor ], rax ;; Inicializacion del cursor.
661+ mov r9 , msg_boot_services_exit
662+ call print
648663 ;;call prompt_step_mode ;; Ultima parada step usando boot services.
649664
650665 mov rcx , [ EFI_IMAGE_HANDLE ] ;; IN EFI_HANDLE ImageHandle
@@ -655,10 +670,6 @@ exit_uefi_services:
655670 jne get_memmap ;; Get mem map, then try to exit again.
656671 cli ;; Ya afuera.
657672
658- ;; TODO: notificar salida oka, pero aqui no la puedo hacer ya que luego de o
659- ;; btener mapa de mem, inmediatamente debo hacer el exit.
660-
661-
662673 ;; Payload al destino. Maximo tamano 256KiB y por eso cuando armamos imagen
663674 ;; se deberia revisar que no sea mayor. Un posible payload es:
664675 ;; uefiBootloader.sys + kernel.bin + modulosUserland.bin
@@ -708,18 +719,8 @@ exit_uefi_services:
708719 rep stosq
709720
710721
711- ;; Hacer un clear del screen.
712- mov rdi , [ FB ]
713- mov eax , 0x00000000 ; 0x00RRGGBB
714- mov rcx , [ FB_SIZE ] ;;;;;;;;;; frame buffer size
715- shr rcx , 2 ; Quick divide by 4 (32-bit colour)
716- rep stosd
717- ;;;;;;; verificado que el tamano de pantalla correcto
718722
719- mov rax , [ FB ]
720- mov [ print_cursor ], rax ;; Inicializacion del cursor.
721723mov r9 , msg_boot_services_exit_ok
722- mov rsi , msg_test8
723724call print
724725
725726
@@ -1055,61 +1056,6 @@ division_init:
10551056 ret
10561057
10571058
1058-
1059- ;;==============================================================================
1060- ;; num2strWord - convierte un entero en un string null terminated
1061- ;;==============================================================================
1062- ;; Argumentos:
1063- ;; -- placeholder por stack, 1er push.
1064- ;; -- el numero entero de 64 bit a convertir, pasado por stack (2do push)
1065- ;; Retorno:
1066- ;; -- los caracteres ASCII (1 char = word) en rbx puntero al comienzo dentro del
1067- ;; placeholder
1068- ;;==============================================================================
1069-
1070- num2strWord:
1071- push rbp
1072- mov rbp , rsp
1073-
1074- push rax
1075- push rcx
1076- push rdx
1077-
1078- mov rcx , 10
1079- mov rdx , 0 ;; En cero la parte mas significativa.
1080- mov rax , [ rbp + 8 * 2 ] ;; Cargo el numero a convertir.
1081- mov rbx , [ rbp + 8 * 3 ]
1082- push word 0
1083-
1084- .calcular:
1085- div ecx
1086- or dl , 0x30 ;; Convierto el resto menor a 10 a ASCII.
1087- push dx
1088- cmp al , 0
1089- jz .write
1090- mov rdx , 0
1091- jmp .calcular
1092-
1093- .write:
1094- pop word [ rbx ]
1095- cmp word [ rbx ], 0
1096- jne .avanza
1097- jmp .end
1098-
1099- .avanza:
1100- add rbx , 2
1101- jmp .write
1102-
1103- .end:
1104- pop rdx
1105- pop rcx
1106- pop rax
1107-
1108- mov rsp , rbp
1109- pop rbp
1110- ret
1111-
1112-
11131059;;==============================================================================
11141060;; print - impresion utf8 a buffer de video luego de ExitBootSerivces()
11151061;;==============================================================================
@@ -1341,7 +1287,6 @@ msg_efi_success: dw utf16("EFI success"), 13, 0xA, 0
13411287msg_efi_not_ready: dw utf16( "EFI not ready" ) , 13 , 0xA , 0
13421288msg_notify_memmap_change: dw utf16( "Memory map buffer size change: will request again." ) , 13 , 0xA , 0
13431289txt_err_memmap: dw utf16( "get memmap feilure" ) , 0
1344- msg_will_exit_uefi_services: dw utf16( "A continuacion hara exit de uefi services" ) , 13 , 0xA , 0
13451290
13461291msg_test16: dw utf16( "Test" ) , 13 , 0xA , 0
13471292msg_test8: db "Test" , 0
@@ -1367,8 +1312,8 @@ fmt_edid_protocol_located: dw utf16("EDID protocol found = %s"), 13, 0xA, 0
13671312str_gop_protocol_fatal_err: dw utf16( "GOP protocol no localizado" ) , 0
13681313
13691314;; UTF8 strings para bootloader.
1370- ____msg_boot_services_exit_ok : db "Exit from UEFI services exitoso." , 0
1371- msg_boot_services_exit_ok: db "Exit from UE%FI se" , 0x0A , "rvices exit%soso_1234567890." , 0
1315+ msg_boot_services_exit : db "ExitBootSerivces()..." , 0x0A , 0
1316+ msg_boot_services_exit_ok: db "Exit from UEFI services OK (ret val = EFI_SUCCESS)." , 0x0A , 0
13721317
13731318
13741319
@@ -1477,7 +1422,7 @@ font_data:
14771422 dd 0x01010000 , 0x04040202 , 0x10100808 , 0x40402020 ;; 0x5c backslash
14781423 dd 0x101C0000 , 0x10101010 , 0x10101010 , 0x1C101010 ;; 0x5d bracketright
14791424 dd 0x24180000 , 0x00008142 , 0x00000000 , 0x00000000 ;; 0x5e asciicircum
1480- dd 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 ;; 0x5f underscore
1425+ dd 0x00000000 , 0x00000000 , 0x00000000 , 0xFF000000 ;; 0x5f underscore
14811426 dd 0x10080400 , 0x00000000 , 0x00000000 , 0x00000000 ;; 0x60 grave
14821427 dd 0x00000000 , 0x40423C00 , 0x4141417E , 0x00005E61 ;; 0x61 a
14831428 dd 0x01010000 , 0x41231D01 , 0x41414141 , 0x00001D23 ;; 0x62 b
0 commit comments