Skip to content

Commit 2e39592

Browse files
apuntar bien a mem
1 parent 15a8b39 commit 2e39592

18 files changed

Lines changed: 143 additions & 47 deletions

File tree

.gdb_history

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
quit
2-
b *0x8000
3-
continue
4-
quit
5-
b *0x8000
6-
continue
7-
quit
81
b *0x8000
92
continue
103
quit
@@ -254,3 +247,10 @@ b *0x7e00
254247
continue
255248
si
256249
quit
250+
b *0x7e00
251+
continue
252+
si
253+
si
254+
b *0x8000
255+
continue
256+
quit

TO-DO.rm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Integracion uefi + bios
2+
-- no le estoy apuntando vien a pasar el flag de step mode al inicio de uefi.
23

34
-- corregir que start16 se carga en 0x7e00 y no en 8000 (ver tsl.ld).
45

asm/include/efi.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,6 @@ EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE equ 24
113113
EFI_RUNTIME_SERVICES_RESETSYSTEM equ 104
114114

115115

116-
DATA_HI_START_LOAD equ 0x406400 ;; Image load + offsetPayload + tsl.sys off
117-
;; set = 0x400000 + 0x4000 + 0x2400.
116+
DATA_HI_START_LOAD equ 0x406A00 ;; Image load + start16 + offsetPayload + tsl.sys (sec
117+
;; tion .data offset) = 0x400000 + 0x4000 +
118+
;; 0x200 + 0x2800.

asm/tsl.asm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ section .text
5151

5252
TSL_BASE_ADDRESS equ 0x8000
5353

54+
db "inifede"
5455

5556
start64:
5657
mov al, [STEP_MODE_FLAG]
@@ -1145,7 +1146,7 @@ clear_regs:
11451146
section .data
11461147

11471148
;; Some additional system vars.
1148-
1149+
db "probando"
11491150
STEP_MODE_FLAG: db 1 ;; Lo activa presionar 's' al booteo. Este byte es f
11501151
;; orwardeado desde uefi.asm hacia aqui porque se ut
11511152
;; iliza en ambos lugares y la inicializacion se hac

asm/tsl_ap.asm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,19 @@ bootmode_branch:
283283

284284
section .data
285285

286+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;extern data_lo_start_load
287+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;extern data_lo_start_reloc_aligned
288+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;extern code_hi_start_load
289+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;extern data_lo_start_load
290+
286291
align 16
292+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;pepe:
293+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; dq data_lo_start_load
294+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; dq data_lo_start_reloc_aligned
295+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;dq code_hi_size_aligned
296+
297+
298+
;;db "hello"
287299

288300
GDTR32: ;; Global Descriptor Table Register.
289301
dw gdt32_end - gdt32 - 1 ;; Size.

asm/uefi.asm

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@
1212
;; La salida de NASM se guarda en /EFI/BOOT/BOOTX64.EFI y se le inyecta el paylo
1313
;; ad (UEFI bootloader + packedKernel.bin) que se requiera. Archivo BOOTX64.EFI,
1414
;; luego de agregado el payload queda:
15-
;; +--------------------------+-------------------------+------------+
16-
;; | binario uefi.sys | payload | padeo de |
17-
;; | | | | transient | packed | 0x00 hasta |
18-
;; | Encabez | Codigo | Datos | system | Kernel.bin | el fin |
19-
;; | | | | low | hi | | |
20-
;; +---------+--------+-------+-----+------+------------+------------+
21-
;; |^ |^ |^ |^ |^ |^ |^ ^|
22-
;; 0x0 0x200 0x1000 0x4000 0x4400 0x7000 0x40000 0xFFFFF
23-
;; 0 512B 4KiB 16KiB 17KiB 28KiB 256KiB 1MiB-1
15+
;; +--------------------------+-------------------------------+--------+
16+
;; | binario uefi.sys | payload | padeo |
17+
;; | | | | | transient | packed | 0x00 |
18+
;; | Encabez | Codigo | Datos | start16 | system | Kernel | hasta |
19+
;; | | | | | low | hi | .bin | el fin |
20+
;; +---------+--------+-------+---------+------------+--------+--------+
21+
;; |^ |^ |^ |^ |^ |^ |^ ^| ^|
22+
;; 0x0 0x200 0x1000 0x4000 0x4200 0x4400 0x7000 0x40000 0xFFFFF
23+
;; 0 512B 4KiB 16KiB 16.5KiB 17KiB 28KiB 256KiB 1MiB-1
2424
;;==============================================================================
2525

2626

27+
START16_SIZE equ 0x200
2728
TSL_BASE_ADDRESS equ 0x800000
2829
TSL_BASE_ADDRESS_LOW equ 0x8000
29-
TSL_LO_SIZE equ 0x400
30+
TSL_LO_SIZE equ 0x800 ;; Puede hacerse 0x400 pero dado que se le s
31+
;; uma START16_SIZE quedan 0x600 y prefiero
32+
;; alinear a 0x800 que a 0x200.
33+
3034

3135
%include "./asm/include/efi.inc"
3236
%define utf16(x) __utf16__(x)
@@ -307,8 +311,15 @@ entryPoint:
307311
;; Ventana en la que se puede activar modo step presionando 's'.
308312
call ventana_modo_step
309313

310-
;; Copio a la section data de la payload el flag cuyo valor es seteado en linked
311-
;; icion para que este disponible cuando se pase a tsl.sys
314+
;;jmp $
315+
;;nop
316+
;;nop
317+
;;nop
318+
319+
320+
321+
;; Copio en la section data de la payload el flag cuyo valor es seteado en linke
322+
;; dicion para que este disponible cuando se pase a tsl.sys
312323
mov al, [STEP_MODE_FLAG]
313324
mov [DATA_HI_START_LOAD], al
314325

@@ -613,12 +624,15 @@ print_video_information:
613624
mov r9, fmt_fb_address
614625
call print
615626

627+
;; TO-DO: estos 512 ver si lo dejo asi o si lo pongo simbolicamente.
616628
verifica_payload:
617-
mov rsi, PAYLOAD + 6
629+
mov rsi, PAYLOAD + 6 + 512 ;; The additional 512 bytes are to skip start16,
630+
;; which is placed to completely fill the 1st 51
631+
;; 2 bytes of the payload.
618632
mov rax, [rsi]
619633
mov rbx, "BOOTLOAD" ;; Chequeo simple de payload en lugar.
620634
cmp rax, rbx ;; No se puede hacer cmp con operando inmediato de 64...
621-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;jne payloadSignatureFail
635+
jne payloadSignatureFail
622636

623637
get_memmap:
624638
mov rdx, [memmap] ;; OUT EFI_MEMORY_DESCRIPTOR *MemoryMap
@@ -764,29 +778,32 @@ exit_uefi_services:
764778

765779
;; Payload al destino. Maximo tamano 240KiB y por eso cuando armamos imagen
766780
;; se deberia revisar que no sea mayor. Posible payload (previo copia):
767-
;; +-----------------------------------+--------------------+
768-
;; | tsl.sys | packedKernel.bin |
769-
;; | code | data | 00..0 | code | data | kernel | mods user |
770-
;; | low | low | 00..0 | hi | hi | .bin | land.bin |
771-
;; +-----------------------------------+--------------------+
772-
;; |<-- 0x2400 ---------------->|
773-
;; |<-- 240KiB -------------------------------------------->|
774-
;; |<-- 0x300 -->| |<----------- 239KiB ------------->|
775-
;; |<-- 0x400 ---------->| |
776-
;; |^ |^ |^
777-
;; 0x404000 0x404400 0x440000
781+
;; +---------------------------------------------+--------------------+
782+
;; | tsl.sys | packedKernel.bin |
783+
;; | start16 | code | data | 00..0 | code | data | kernel | mods user |
784+
;; | | low | low | 00..0 | hi | hi | .bin | land.bin |
785+
;; +---------------------------------------------+--------------------+
786+
;; | 0x2800 --------------------->|0x2000|
787+
;; |< 240KiB -------------------------------------------------------->|
788+
;; |< 0x200 >|0x200 |0x100 | |<----------- 238KiB ------------->|
789+
;; |< 0x800 ---------------------->| |
790+
;; |^ |^ |^
791+
;; 0x404000 0x404800 0x440000
778792
;; PAYLOAD
779793

780794
;; Low primeros TSL_LO_SIZE bytes de los 240 del payload.
781-
mov rsi, PAYLOAD
795+
mov rsi, PAYLOAD + START16_SIZE ;; The additional bytes are to skip start16, whi
796+
;; ch is placed to completely fill the 1st 512 bytes
797+
;; of the payload.
798+
782799
mov rdi, TSL_BASE_ADDRESS_LOW
783800
mov rcx, TSL_LO_SIZE ;; Bytes a partir de TSL_BASE_ADDRESS_LOW.
784801
rep movsb
785802

786803
;; Hi tsl. Los restantes 239K. Se encuentran alineados a 1K.
787-
mov rsi, PAYLOAD + TSL_LO_SIZE
804+
mov rsi, PAYLOAD + START16_SIZE + TSL_LO_SIZE
788805
mov rdi, TSL_BASE_ADDRESS
789-
mov rcx, (239 * 1024) ;; 239KiB.
806+
mov rcx, (238 * 1024) ;; 238KiB.
790807
rep movsb
791808
792809
;; Datos de video pasamos a siguiente etapa de bootloader. Movemos y queda:
@@ -1115,7 +1132,7 @@ fmt_test_uefi: dw utf16("test uefi"), 13, 0x0A, 0
11151132
fmt_test_reg: db "test reg = %r", 0x0A, 0
11161133

11171134
;;==============================================================================
1118-
;; Here goes the payload
1135+
;; Space reservation for the payload
11191136
;; =============================================================================
11201137

11211138
section .payload

build/tsl.sys

528 Bytes
Binary file not shown.

build/uefi.sys

0 Bytes
Binary file not shown.

elf/tsl_hi.elf

32 Bytes
Binary file not shown.

elf/tsl_lo.elf

368 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)