ExitBootServicesWorksNow
This commit is contained in:
parent
951ee15924
commit
871845f7c1
2 changed files with 66 additions and 31 deletions
86
bootefi.asm
86
bootefi.asm
|
@ -60,21 +60,21 @@ main:
|
|||
mov rdx, BootMsg
|
||||
call print
|
||||
|
||||
;.GetGOP:
|
||||
; mov rcx, EFI_GRAPHICS_OUTPUT_UUID
|
||||
; mov rdx, 3
|
||||
; mov r8, Video
|
||||
;
|
||||
; mov rax, [BootSrvc]
|
||||
; call_safe [rax + EFI_BOOT_SERVICES_TABLE.LocateProtocol]
|
||||
;
|
||||
; cmp rax, EFI_SUCCES
|
||||
; jne .error
|
||||
;
|
||||
; mov rax, [Video]
|
||||
; mov rbx, [rax + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode]
|
||||
.GetGOP:
|
||||
mov rcx, EFI_GRAPHICS_OUTPUT_UUID
|
||||
mov rdx, 3
|
||||
mov r8, Video
|
||||
|
||||
mov rax, [BootSrvc]
|
||||
call_safe [rax + EFI_BOOT_SERVICES_TABLE.LocateProtocol]
|
||||
|
||||
cmp rax, EFI_SUCCES
|
||||
jne .error
|
||||
|
||||
; jmp .
|
||||
mov rax, [Video]
|
||||
mov rbx, [rax + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode]
|
||||
|
||||
jmp .
|
||||
; TODO: Get and store framebuffer
|
||||
|
||||
; Getting the memory map is kind of harder (not in this case), normally
|
||||
|
@ -92,13 +92,13 @@ main:
|
|||
.GetMemMap:
|
||||
mov rax, [BootSrvc]
|
||||
|
||||
lea rcx, [MemMapSize]
|
||||
mov rcx, MemMapSize
|
||||
mov rdx, [MemMapBuff]
|
||||
lea r8, [MemMapKey]
|
||||
lea r9, [MemMapDescSize]
|
||||
mov r8, MemMapKey
|
||||
mov r9, MemMapDescSize
|
||||
; notice the last argument is moved to r10 and then "pushed" to the stack
|
||||
; with 32bit offset
|
||||
lea r10, [MemMapDescVer]
|
||||
mov r10, 0
|
||||
mov [rsp+32], r10
|
||||
|
||||
call [rax + EFI_BOOT_SERVICES_TABLE.GetMemoryMap]
|
||||
|
@ -106,16 +106,7 @@ main:
|
|||
; if it returns buffer too small run the function again as it filled out
|
||||
; the needed buffer length
|
||||
cmp al, EFI_BUFFER_TOO_SMALL
|
||||
je .GetMemMap
|
||||
|
||||
; if it returned something else it maybe a problem possible TODO: proper
|
||||
; error handling for now it just puts out error and exits with non-zero code
|
||||
cmp rax, EFI_SUCCESS
|
||||
jne .error
|
||||
|
||||
; print a message saying that we didn't f**k up yet...
|
||||
mov rdx, OKMsg
|
||||
call print
|
||||
pushf
|
||||
|
||||
; preparing args and calling
|
||||
; BootServices.ExitBootServices(*ImegeHandle, *MemMapKey)
|
||||
|
@ -126,11 +117,44 @@ main:
|
|||
call_safe [rax + EFI_BOOT_SERVICES_TABLE.ExitBootServices]
|
||||
|
||||
cmp rax, EFI_SUCCESS
|
||||
jne .error
|
||||
je .after
|
||||
|
||||
mov rdx, ErrMsg
|
||||
call print
|
||||
|
||||
popf
|
||||
je .GetMemMap
|
||||
|
||||
.after:
|
||||
mov rdx, OKMsg
|
||||
call print
|
||||
|
||||
mov eax, EFI_SUCCESS
|
||||
jmp .exit
|
||||
|
||||
; if it returned something else it maybe a problem possible TODO: proper
|
||||
; error handling for now it just puts out error and exits with non-zero code
|
||||
; cmp rax, EFI_SUCCESS
|
||||
; jne .error
|
||||
|
||||
; print a message saying that we didn't f**k up yet...
|
||||
;mov rdx, OKMsg
|
||||
;call print
|
||||
|
||||
; preparing args and calling
|
||||
; BootServices.ExitBootServices(*ImegeHandle, *MemMapKey)
|
||||
; mov rcx, [ImgHdl]
|
||||
; mov rdx, [MemMapKey]
|
||||
|
||||
; mov rax, [BootSrvc]
|
||||
; call_safe [rax + EFI_BOOT_SERVICES_TABLE.ExitBootServices]
|
||||
|
||||
; cmp rax, EFI_SUCCESS
|
||||
; jne .error
|
||||
|
||||
; mov eax, EFI_SUCCESS
|
||||
; jmp .exit
|
||||
|
||||
.error:
|
||||
mov rdx, ErrMsg
|
||||
call print
|
||||
|
@ -164,7 +188,7 @@ MemMapDescVer dq ?
|
|||
MemMapBuff dq 0x220000
|
||||
|
||||
BootMsg du '[BOOT]: Booting the system...',13,10,0
|
||||
ErrMsg du '[BOOT]: There was an error :(',13,10,0
|
||||
OKMsg du '[BOOT]: Everything is OK :), for now...',13,10,0
|
||||
ErrMsg du '[BOOT]: There was an error :(',13,10,0
|
||||
OKMsg du '[BOOT]: Everything is OK :), for now...',13,10,0
|
||||
|
||||
section '.reloc' fixups data discardable
|
||||
|
|
11
uefi.inc
11
uefi.inc
|
@ -299,6 +299,17 @@ struc EFI_GRAPHICS_OUTPUT_MODE_INFORMATION {
|
|||
.PixelsPerScanline int32
|
||||
}
|
||||
struct EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
|
||||
|
||||
struc EFI_MEMORY_DESCRIPTOR {
|
||||
.Type int32
|
||||
.Pad int32
|
||||
.PhysicalStart int64
|
||||
.VirtualStart int64
|
||||
.NumberOfPages int64
|
||||
.Attribute int64
|
||||
}
|
||||
struct EFI_MEMORY_DESCRIPTOR
|
||||
|
||||
;---macros to make life easier---
|
||||
;call it early, after entry point is the best
|
||||
macro InitializeLib
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue