Skip to content

Commit acd0d0c

Browse files
pdpt unified entre pags de 1Mib o de 1GiB
1 parent 83234d0 commit acd0d0c

File tree

4 files changed

+54
-34
lines changed

4 files changed

+54
-34
lines changed

asm/tsl.asm

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,40 @@ set_pit_initial_freq:
164164

165165
;; Aqui se comienzan a armar tablas de sistema. Breve resumen de lo que finalmen
166166
;; te va a quedar:
167-
;; | table(s) total
168-
;; | initilized
169-
;; | mem mapping
170-
;; -------------------------------------------------------------+---------------
171-
;; [0x00000000 - 0x00000FFF] 1 * 4KiB | idt |
172-
;; [0x00001000 - 0x00001FFF] 1 * 4KiB | gdt |
173-
;; [0x00002000 - 0x00002FFF] 1 * 4KiB | pml4 |
174-
;; [0x00003000 - 0x00003FFF] 1 * 4KiB | pdpt canonical low | 1st 512GiB
175-
;; [0x00004000 - 0x00004FFF] 1 * 4KiB | pdpt canonical high |
176-
;; [0x00005000 - 0x00007FFF] 3 * 4KiB | system data |
177-
;; [0x00008000 - 0x0000FFFF] 8 * 4KiB | disponible |
178-
;; [0x00010000 - 0x0001FFFF] 16 * 4KiB | pd low | 1st 16GiB
179-
;; [0x00020000 - 0x0005FFFF] 64 * 4KiB | pd high
180-
;; [0x00060000 - 0x0009FFFF] 64 * 4KiB | disponible
181-
167+
;; | | | if |if |mapped| | table(s) total
168+
;; |4KiB | | 1Mib |1GiB |per | | initilized
169+
;; |blocks| | pages |pages|entry | | mem mapping
170+
;; -----------+------+-----------+--------+-------+--------------+---------------
171+
;; 0x00000000 | 1 | idt | | | |
172+
;; 0x00000FFF | | | | | |
173+
;; -----------------------------------------------------------------------------
174+
;; 0x00001000 | 1 | gdt | | | |
175+
;; 0x00001FFF | | | | | |
176+
;; -----------------------------------------------------------------------------
177+
;; 0x00002000 | 1 | pml4 | | | |
178+
;; 0x00002FFF | | | | | | | |
179+
;; -----------------------------------------------------------------------------
180+
;; 0x00003000 | 1 | pdpt cano | 16 |512 | 1GiB |
181+
;; 0x00003FFF | | nical low | entr. |entr.| |
182+
;; -----------------------------------------------------------------------------
183+
;; 0x00004000 | 1 | pdpt cano | | | |
184+
;; 0x00004FFF | | nical hig | | | |
185+
;; ----------------------------------------------------------------------------
186+
;; 0x00005000 | 3 | system | | | | |
187+
;; 0x00007FFF | | data | | | |
188+
;; -----------------------------------------------------------------------------
189+
;; 0x00008000 | 8 | dispo | | | |
190+
;; 0x0000FFFF | | nible | | | |
191+
;; -----------------------------------------------------------------------------
192+
;; 0x00010000 | 16 | pd low |16 pag *| sin |2MiB |
193+
;; 0x0001FFFF | | |512 entr| uso | |
194+
;; -----------------------------------------------------------------------------
195+
;; 0x00020000 | 64 | pd high | | sin | |
196+
;; 0x0005FFFF | | | | uso | |
197+
;; ----------------------------------------------------------------------------
198+
;; 0x00060000 | 64 | dispo | | | | |
199+
;; 0x0009FFFF | | nible | | | | |
200+
;; -----------------------------------------------------------------------------
182201
mov r9, msg_gdt
183202
call print
184203

@@ -191,7 +210,7 @@ set_pit_initial_freq:
191210
call print
192211

193212
;; PML4. Starts at 0x0000000000002000. Each entry maps 512GiB.
194-
pml4_2mb:
213+
pml4:
195214
mov edi, 0x00002000 ;; PML4 entry for physical mem, canonical low.
196215
mov eax, 0x00003003 ;; #1 (R/W) | #0 (P) | *PDP low (4KiB aligned).
197216
stosq ;; 1 | 1 |
@@ -257,7 +276,7 @@ pag_1gb_support:
257276
mov r9, msg_support_1g_pages_no ;; Completa: no soporta pags 1GB.
258277
call print
259278

260-
;; 2MiB pages.
279+
;; 2MiB pages.
261280
mov r9, msg_pages_will_be_2mib
262281
call print
263282

@@ -350,7 +369,7 @@ pd_low_2mb:
350369
mov r9, msg_ready
351370
call print
352371

353-
jmp skip_1gb
372+
jmp load_gdt
354373

355374
;; 1GiB Pages. Create the Low Page-Directory-Pointer Table Entries (PDPTE). PDPT
356375
;; E starts at 0x0000000000010000, create the first entry there. A single PDPTE
@@ -366,31 +385,32 @@ support_1gb_pages:
366385
mov byte [p_1gb_pages], 1
367386

368387
;; Overwrite the original PML4 entry for physical memory.
369-
pml4_1g:
370-
mov ecx, 16
371-
mov edi, 0x00002000 ;; Create a PML4 entry for physical memory
372-
mov eax, 0x00010003 ;; #1 (R/W) | #0 (P) | *PDP low (4KiB aligned).
388+
;;pml4_1g:
389+
;; mov ecx, 16
390+
;; mov edi, 0x00002000 ;; Create a PML4 entry for physical memory
391+
;; mov eax, 0x00010003 ;; #1 (R/W) | #0 (P) | *PDP low (4KiB aligned).
373392
;; 1 | 1 |
374-
pml4_low_entry_1gb:
375-
stosq
376-
add rax, 0x00001000 ;; Next pdpt 4KiB later.
377-
dec ecx
378-
jnz pml4_low_entry_1gb
393+
;;pml4_low_entry_1gb:
394+
;; stosq
395+
;; add rax, 0x00001000 ;; Next pdpt 4KiB later.
396+
;; dec ecx
397+
;; jnz pml4_low_entry_1gb
379398

380399
pdpt_low_1gb:
381-
mov ecx, 8191 ;; Number of PDPE's to make.. each PDPE maps 1GiB of physical memory.
382-
mov edi, 0x00010000 ;; location of low PDPE
400+
mov ecx, 512 ;; Number of PDPE's to make.. each PDPE maps 1GiB of physical memory.
401+
mov edi, 0x00003000 ;; location of low PDPE
383402
mov eax, 0x00000083 ;; #7 (PS) | #1 (R/W) | #0 (P) |
384403
;; 1 | 1 | 1 |
385404

386405
pdpt_entry_low_1gb: ;; Create a 1GiB page.
406+
dec ecx
407+
jz pdpt_entry_low_1gb
387408
stosq
388409
add rax, 0x40000000 ;; Increment by 1GiB.
389-
dec ecx
390-
jnz pdpt_entry_low_1gb
410+
jmp pdpt_entry_low_1gb
391411

392-
skip_1gb:
393412

413+
load_gdt:
394414
mov r9, msg_load_gdt
395415
call print
396416
lgdt [GDTR64]
@@ -731,8 +751,8 @@ patch_ap_code:
731751
call print
732752

733753

734-
cli
735-
hlt
754+
;;cli
755+
;;hlt
736756

737757
mov r9, msg_setting_memmap
738758
call print

build/tsl.sys

0 Bytes
Binary file not shown.

out/BOOTX64.EFI

0 Bytes
Binary file not shown.

out/payload.sys

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)