hex0.S: implement open_protocol function.
This commit is contained in:
parent
9cb1d5b7f0
commit
d0e6bdb758
|
@ -2,25 +2,46 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
# Calling convention:
|
||||||
|
# First four arguments are passed via registers but we need to leave stack space
|
||||||
|
|
||||||
.global _start
|
.global _start
|
||||||
.text
|
.text
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
mov [ImageHandle], rcx # ImageHandle *image
|
sub rsp, 64
|
||||||
mov [SystemTable], rdx # SystemTable *system
|
mov [ImageHandle], rcx # ImageHandle *image_handle
|
||||||
|
mov rax, [rdx+96] # system->boot
|
||||||
|
mov [SystemBoot], rax # save system->boot
|
||||||
|
|
||||||
lea rdx, [hello] # arg2 = "Hello World"
|
# Open Loaded Image protocol
|
||||||
mov rcx, [SystemTable] # system
|
# arg1 = ImageHandle
|
||||||
mov rcx, [rcx+64] # arg1 = system->out
|
mov rdx, [LOADED_IMAGE_PROTOCOL] # EFI_LOADED_IMAGE_PROTOCOL_GUID (first 64 bits)
|
||||||
call [rcx+8]
|
mov [rsp+48], rdx # save onto stack
|
||||||
|
mov rdx, [LOADED_IMAGE_PROTOCOL+8]# EFI_LOADED_IMAGE_PROTOCOL_GUID (last 64 bits)
|
||||||
|
mov [rsp+56], rdx # save onto stack
|
||||||
|
lea rdx, [rsp+48] # arg2 = &EFI_LOADED_IMAGE_PROTOCOL_GUID
|
||||||
|
# arg3 = &image
|
||||||
|
mov r9, rcx # arg4 = image_handle
|
||||||
|
mov qword ptr [rsp+32], 0 # arg5 = NULL
|
||||||
|
mov qword ptr [rsp+40], 1 # arg6 = EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
|
||||||
|
|
||||||
|
call [rax+280] # system->boot->open_protocol();
|
||||||
|
add rsp, 64
|
||||||
|
|
||||||
|
# Command line args
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
mov rax, 0 # rax = 0
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
||||||
hello: .asciz "H\0e\0l\0l\0o\0 \0w\0o\0r\0l\0d\0!\0\n\0\r\0\0"
|
|
||||||
|
|
||||||
ImageHandle: .quad 0
|
ImageHandle: .quad 0
|
||||||
SystemTable: .quad 0
|
SystemBoot: .quad 0
|
||||||
|
|
||||||
|
# Protocol GUIDs
|
||||||
|
LOADED_IMAGE_PROTOCOL:
|
||||||
|
.long 0x5b1b31a1
|
||||||
|
.short 0x9562
|
||||||
|
.short 0x11d2
|
||||||
|
.byte 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b
|
||||||
|
|
Loading…
Reference in New Issue