|
1 | 1 | ;;============================================================================== |
2 | 2 | ;; Real mode swich to protected mode | @file /asm/bios/start16.asm |
| 3 | +;; |
| 4 | +;; Para bios boot primero real mode a protected mode. Uefi saltea esta parte, ya |
| 5 | +;; bootea en 64. |
| 6 | +;; |
| 7 | +;; https://wiki.osdev.org/Detecting_Memory_(x86)#BIOS_Function:_INT_0x15,_EAX_=_0xE820 |
| 8 | +;; https://wiki.osdev.org/Detecting_Memory_(x86)#Getting_an_E820_Memory_Map |
3 | 9 | ;;============================================================================== |
4 | 10 |
|
5 | 11 |
|
|
11 | 17 | ;;extern print_bios |
12 | 18 | ;;extern failure |
13 | 19 | print_bios equ 0x00de + 0x7c00 ;; print_bios en 0x7cde |
14 | | -;;failure equ 0x0067 + 0x7c00 |
15 | | -;;vesa equ 0x0111 + 0x7c00 |
16 | 20 |
|
| 21 | +;; tsl.asm |
| 22 | +extern start64 |
17 | 23 |
|
18 | 24 | ;; tsl_ap.asm |
19 | 25 | extern GDTR32 |
20 | 26 | extern tmpGDTR64 ;; Only for bios boot. See tsl.asm 1178 TO-DO. |
21 | 27 | extern SYS64_CODE_SEL |
22 | 28 |
|
23 | | -extern start64 |
24 | | - |
25 | | - |
26 | | -;; Primera parte: pasa real mode a protected mode. |
27 | 29 |
|
28 | 30 | BITS 16 |
| 31 | + |
29 | 32 | start16: |
30 | 33 | mov ax, print_bios |
31 | 34 | mov si, msg_e820 |
32 | | - call ax |
33 | | - |
34 | | -; Get the BIOS E820 Memory Map |
35 | | -; https://wiki.osdev.org/Detecting_Memory_(x86)#BIOS_Function:_INT_0x15,_EAX_=_0xE820 |
36 | | -; The code below is from https://wiki.osdev.org/Detecting_Memory_(x86)#Getting_an_E820_Memory_Map |
37 | | -; inputs: es:di -> destination buffer for 24 byte entries |
38 | | -; outputs: bp = entry count, trashes all registers except esi |
39 | | -; The function below creates a memory map at address 0x6000 and the records are: |
40 | | -; 64-bit Base |
41 | | -; 64-bit Length |
42 | | -; 32-bit Type (1 = normal, 2 reserved, ACPI reclaimable) |
43 | | -; 32-bit ACPI |
44 | | -; 64-bit Padding |
45 | | -do_e820: |
46 | | - mov edi, 0x00006000 ; location that memory map will be stored to |
47 | | - xor ebx, ebx ; ebx must be 0 to start |
48 | | - xor bp, bp ; keep an entry count in bp |
49 | | - mov edx, 0x0534D4150 ; Place "SMAP" into edx |
| 35 | + call ax ;; Calling using pointer works with directly defining functio addr. |
| 36 | + |
| 37 | + |
| 38 | +;;============================================================================== |
| 39 | +;;e820 | builds memmap |
| 40 | +;; Arguments: |
| 41 | +;; -- {es:di} = destination buffer for 24 byte entries. |
| 42 | +;; Returns: |
| 43 | +;; -- bp = entry count |
| 44 | +;; |
| 45 | +;; trashes all registers except esi |
| 46 | +;; Creates memory map at 0x6000. |
| 47 | +;; and the records are: |
| 48 | +;; 64 bit Base |
| 49 | +;; 64 bit Length |
| 50 | +;; 32 bit Type (1 = normal, 2 reserved, ACPI reclaimable) |
| 51 | +;; 32 bit ACPI |
| 52 | +;; 64 bit Padding |
| 53 | +;;============================================================================== |
| 54 | + |
| 55 | +e820: |
| 56 | + mov edi, 0x00006000 ;; Addrr to place memmap. |
| 57 | + xor ebx, ebx |
| 58 | + xor bp, bp ;; Entry count. |
| 59 | + mov edx, 0x0534D4150 ;; SMAP. |
50 | 60 | mov eax, 0xe820 |
51 | | - mov [es:di + 20], dword 1 ; force a valid ACPI 3.X entry |
| 61 | + mov dword [es:di + 20], 1 ;; force a valid ACPI 3.X entry |
52 | 62 | mov ecx, 24 ; ask for 24 bytes |
53 | 63 | int 0x15 |
54 | 64 | jc nomemmap ; carry set on first call means "unsupported function" |
@@ -103,7 +113,6 @@ memmapend: |
103 | 113 | mov eax, cr0 |
104 | 114 | or al, 0x01 ; Set protected mode bit |
105 | 115 | mov cr0, eax |
106 | | - ;;jmp 8:0x8000 ; Jump to 32-bit protected mode |
107 | 116 |
|
108 | 117 | ;;;;;;;;;;;;;; esto tiene que ser a start32 |
109 | 118 | ;;jmp 8:0x8000 |
|
0 commit comments