OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:45 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: UEFI Stack Order
PostPosted: Sun Jan 01, 2023 4:45 pm 
Offline
Member
Member

Joined: Fri May 04, 2012 8:04 am
Posts: 35
I am learning UEFI (in assembly language). I have been able to clear the screen, print some stuff and exit successfully. However, I have issues with calling LocateHandle. I suspect the problem is with the way I am handling the stack and so I want to use this opportunity to understand how the stack should be.

What order should things be in when calling UEFI functions? Should I have the 5th, 6th, and 7th parameters on the stack before the shadow space or vice versa? For example should I have this
Code:
; UEFI parameters go on the stack in reverse order

push PARAM_7         ; Push parameter 7
push PARAM_6         ; Push parameter 6
push PARAM_5         ; Push parameter 5
sub rsp, 32              ; Required shadow space
call UEFI_function    ; Call the function


Or should I have this
Code:
sub rsp, 32              ; Make shadow space

; Remaining parameters go on the stack in reverse order
push PARAM_7        ; Push parameter 7
push PARAM_6        ; Push parameter 6
push PARAM_5        ; Push parameter 5
call UEFI_function    ; Call the function


If neither of these is correct, then what is the correct way to do it?


Top
 Profile  
 
 Post subject: Re: UEFI Stack Order
PostPosted: Sun Jan 01, 2023 5:48 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
writing this from the phone, so hardly will be helpful. but, first, the calling convention is specified in the spec the latter is described on the Microsoft site, see the link and second, personally, I believe they go before shadow space, since the shadow space is for the first parameters, (I was wrong, they go after the shadow space) third, why you just don't check, crashing UEFI in VM is not that scary, I did that a hundred of times. :lol: fourth, read the article below, it describes it fully. in conclusion, your second variant is correct.

here read, there are answers there.

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group