flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Use UEFI Graphics Output Protocol

Goto page Previous  1, 2, 3, 4, 5, 6
Author
Thread Post new topic Reply to topic
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Thanks you Smile

But no, don't work ... Crying or Very sad
..It's terrible ...
Post 21 Apr 2020, 14:13
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Please if somebody can help me. I'm desperate ...

I have uploaded all of my code to test UEFI fonction: https://www.mediafire.com/file/4l9ado1e39813p2/UEFITest.tar.gz/file
Post 22 Apr 2020, 14:41
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
you can upload your code here, then no need to use this shitty mediafire site.

i suggest you to first feel comfortable with legacy bootloading, then, you'll see better what you miss for uefi.

i'll have a look at your code, bur please use the add attachement form below the post editor.


Description: for example, you can upload anything here
Download
Filename: hexchars3x5.inc
Filesize: 1.58 KB
Downloaded: 87 Time(s)

Post 22 Apr 2020, 21:50
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 707
Location: Adelaide
sinsi
There is an error in EFIBootServices
Code:
    .HandleProtocol                         EFIInteger64
    .void                                   EFIInteger64 ;<<<<<missing
    .RegisterProtocolNotify                 EFIInteger64
    

This code snippet returns RAX=0 (no error)
Code:
        mov     rax,[SystemTable]
        mov     rax,[rax+EFISystemTable.BootServices]
        lea     rcx,[GUID.EFIGraphicsOutputProtocol]
        sub     edx,edx
        lea     r8,[Interface.EFIGraphicsOutputProtocol]
        call    [rax+EFIBootServices.LocateProtocol]
    
Post 23 Apr 2020, 04:56
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
No Surprised Omg, finally it's very simple error omg ...
I understand better what nothing work xD

Just question, what is exactly LEA instruction ?

And why with this function, when i do CALL RAX, this don't work? I think i need understand something...
Post 23 Apr 2020, 09:47
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 365
Ali.Z
Fulgurance wrote:
Just question, what is exactly LEA instruction ?


Load Effective Address, computes a complex address and store it in a register.
example:
- lea eax,[eax+edi*8+86868686h]

read it this way:
86868686h + (8*edi) + eax = result stored in eax.

you can refer to intel's/amd's manual to learn new instructions or learn what is X instruction or how it work.

_________________
Asm For Wise Humans
Post 23 Apr 2020, 10:42
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
In one word, thanks ! End of desesperate Surprised

FInally work !

Code:
format pe64 efi
entry Main

section '.text' code readable writeable executable

Main:
mov [Handle],rcx
mov [SystemTable],rdx

push rbp
sub rsp,0x20

mov rcx,[rdx+EFISystemTable.ConOut]
mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString]
mov rdx,Text
call rax

add rsp,0x20
mov rdx,[SystemTable]

sub rsp,0x20

mov rax,[SystemTable]
mov rax,[rax+EFISystemTable.BootServices]
mov rcx,GUID.EFIGraphicsOutputProtocol
xor edx,edx
mov r8,Interface.EFIGraphicsOutputProtocol
call [rax+EFIBootServices.LocateProtocol]

add rsp,0x20
mov rdx,[SystemTable]

sub rsp,0x50

mov rcx,[Interface.EFIGraphicsOutputProtocol]
mov rdx,RectangleColor
mov r8,[EFIGraphicsOutputBltOperation.BufferToVideo]
mov r9,0x0
mov qword[rsp + 8*4],0x0
mov qword[rsp + 8*5],0x64
mov qword[rsp + 8*6],0x64
mov qword[rsp + 8*7],0xF
mov qword[rsp + 8*8],0xF
mov qword[rsp + 8*9],0x0
call [rcx+EFIGraphicsOutputProtocol.Blt]

add rsp,0x50
mov rdx,[SystemTable]

cmp rax,0x0
jne .Exit

sub rsp,0x20

mov rcx,[rdx+EFISystemTable.ConOut]
mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString]
mov rdx,Text
call rax

add rsp,0x20

.Exit:

jmp $

include "EFIBase/GUID.fasm"
include "EFIBase/Interface.fasm"
include "EFIBase/EFIDataTypes.fasm"
include "EFITableHeader/EFITableHeader.fasm"
include "EFISystemTable/EFISystemTable.fasm"
include "EFIBootServices/EFIBootServices.fasm"
include "EFIBootServices/IndexTables/EFILocateSearchType.fasm"
include "EFISimpleTextOutputProtocol/EFISimpleTextOutputProtocol.fasm"
include "EFIGraphicsOutputProtocol/EFIGraphicsOutputProtocol.fasm"
include "EFIGraphicsOutputProtocol/IndexTables/EFIGraphicsOutputBltOperation.fasm"

Handle:         dq ?
SystemTable:    dq ?
Text:           du 'Texte',0x0
RectangleColor: db 0xFF,0xFF,0xFF,?
    
Post 23 Apr 2020, 11:47
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Just little question. Is it normal when i do ClearScreen before my rect drawing, my rect isn't visible. It's only visible if i don't do clear screen
Post 23 Apr 2020, 11:52
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
I have doing that (look comments)

Code:
format pe64 efi
entry Main

section '.text' code readable writeable executable

Main:
mov [Handle],rcx
mov [SystemTable],rdx

push rbp
;sub rsp,0x20

;mov rcx,[rdx+EFISystemTable.ConOut]
;mov rax,[rcx+EFISimpleTextOutputProtocol.ClearScreen]
;call rax

;add rsp,0x20
;mov rdx,[SystemTable]

sub rsp,0x20

mov rcx,[rdx+EFISystemTable.ConOut]
mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString]
mov rdx,Text
call rax

add rsp,0x20
mov rdx,[SystemTable]

sub rsp,0x20

mov rax,[SystemTable]
mov rax,[rax+EFISystemTable.BootServices]
mov rcx,GUID.EFIGraphicsOutputProtocol
xor edx,edx
mov r8,Interface.EFIGraphicsOutputProtocol
call [rax+EFIBootServices.LocateProtocol]

add rsp,0x20
mov rdx,[SystemTable]

sub rsp,0x50

mov rcx,[Interface.EFIGraphicsOutputProtocol]
mov rdx,RectangleColor
mov r8,[EFIGraphicsOutputBltOperation.BufferToVideo]
mov r9,0x0
mov qword[rsp + 8*4],0x0
mov qword[rsp + 8*5],0x64
mov qword[rsp + 8*6],0x64
mov qword[rsp + 8*7],0xF
mov qword[rsp + 8*8],0xF
mov qword[rsp + 8*9],0x0
call [rcx+EFIGraphicsOutputProtocol.Blt]

add rsp,0x50
mov rdx,[SystemTable]

cmp rax,0x0
jne .Exit

sub rsp,0x20

mov rcx,[rdx+EFISystemTable.ConOut]
mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString]
mov rdx,Text
call rax

add rsp,0x20

.Exit:

jmp $

include "EFIBase/GUID.fasm"
include "EFIBase/Interface.fasm"
include "EFIBase/EFIDataTypes.fasm"
include "EFITableHeader/EFITableHeader.fasm"
include "EFISystemTable/EFISystemTable.fasm"
include "EFIBootServices/EFIBootServices.fasm"
include "EFIBootServices/IndexTables/EFILocateSearchType.fasm"
include "EFISimpleTextOutputProtocol/EFISimpleTextOutputProtocol.fasm"
include "EFIGraphicsOutputProtocol/EFIGraphicsOutputProtocol.fasm"
include "EFIGraphicsOutputProtocol/IndexTables/EFIGraphicsOutputBltOperation.fasm"

Handle:         dq ?
SystemTable:    dq ?
Text:           du 'Texte',0x0
RectangleColor: db 0xFF,0xFF,0xFF,?
    
Post 23 Apr 2020, 11:59
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
I have found the problem. I need to do mov rdx,[SystemTable]. But why ...
Post 23 Apr 2020, 12:08
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
It's very strange, because, when i put comment into the part when i test result of EFIGraphicsOutputSource.Blt, Blt function don't work ... why ???

Code:
format pe64 efi
entry Main

section '.text' code readable writeable executable

Main:
mov [Handle],rcx
mov [SystemTable],rdx

mov rdx,[SystemTable]

push rbp
sub rsp,0x20

mov rcx,[rdx+EFISystemTable.ConOut]
mov rax,[rcx+EFISimpleTextOutputProtocol.ClearScreen]
call rax

add rsp,0x20
mov rdx,[SystemTable]

sub rsp,0x20

mov rcx,[rdx+EFISystemTable.ConOut]
mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString]
mov rdx,Text
call rax

add rsp,0x20
mov rdx,[SystemTable]

sub rsp,0x20

mov rax,[SystemTable]
mov rax,[rax+EFISystemTable.BootServices]
mov rcx,GUID.EFIGraphicsOutputProtocol
xor edx,edx
mov r8,Interface.EFIGraphicsOutputProtocol
call [rax+EFIBootServices.LocateProtocol]

add rsp,0x20
mov rdx,[SystemTable]

sub rsp,0x50

mov rcx,[Interface.EFIGraphicsOutputProtocol]
mov rdx,RectangleColor
mov r8,[EFIGraphicsOutputBltOperation.BufferToVideo]
mov r9,0x0
mov qword[rsp + 8*4],0x0
mov qword[rsp + 8*5],0x64
mov qword[rsp + 8*6],0x64
mov qword[rsp + 8*7],0xF
mov qword[rsp + 8*8],0xF
mov qword[rsp + 8*9],0x0
call [rcx+EFIGraphicsOutputProtocol.Blt]

add rsp,0x50
mov rdx,[SystemTable]

;cmp rax,0x0
;jne .Exit

;sub rsp,0x20

;mov rcx,[rdx+EFISystemTable.ConOut]
;mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString]
;mov rdx,Text
;call rax

;add rsp,0x20

;.Exit:

jmp $

include "EFIBase/GUID.fasm"
include "EFIBase/Interface.fasm"
include "EFIBase/EFIDataTypes.fasm"
include "EFITableHeader/EFITableHeader.fasm"
include "EFISystemTable/EFISystemTable.fasm"
include "EFIBootServices/EFIBootServices.fasm"
include "EFIBootServices/IndexTables/EFILocateSearchType.fasm"
include "EFISimpleTextOutputProtocol/EFISimpleTextOutputProtocol.fasm"
include "EFIGraphicsOutputProtocol/EFIGraphicsOutputProtocol.fasm"
include "EFIGraphicsOutputProtocol/IndexTables/EFIGraphicsOutputBltOperation.fasm"

Handle:         dq ?
SystemTable:    dq ?
Text:           du 'Texte',0x0
RectangleColor: db 0xFF,0xFF,0xFF,?
SystemMessage:  du '* ',0x0
Message:        du 'EFI Boot: Test OK',0xD,0xA,0x0
    
Post 23 Apr 2020, 12:56
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
I have understand something ! It's always needed to restore rcx and rdx ???
Post 23 Apr 2020, 13:20
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 807
Location: Belarus
DimonSoft
Let me insist again that general-purpose instructions, addressing, calling conventions and stuff like that are things to be learnt far before one gets to writing something for UEFI or legacy BIOS (though real mode world is a lot easier to deal with). There’re six pages for now but the questions are still basic. Writing an OS requires one to know even much more stuff than that.

Nothing personal, I just feel you’re wasting your time relying on other people’s help all the way along instead of developing your own skills by learning things in order.
Post 23 Apr 2020, 16:49
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 365
Ali.Z
I agree with DimonSoft on that one should learn all the basics before even attempting to write a kernel mode OS or even a simple bootloader.

many (if not most) assembly programmers made their tiny OS for fun, including me; and yes what DimonSoft said is true one need to know a lot more than basic stuff.

when programming at hardware level, assembly instructions are very thin layer or lets say its level 1; there are a lot of things one need to consider and understand, in other words assembly is the key to the hardware level by mean it removes many abstractions.

but I dont agree on the part he (DimonSoft) said that you are relying on other people's help; because I believe we humans must co-op and help each other, and not helping others is wrong and no good; however this is off-topic.

refer to your processor manual for the complete instruction set and their uses, its good to learn intel's efi and do some uefi programming if you have an intel chip and you want your software to run on future processors; as intel stated there is no CSM.

but if you are on amd's side, then its okay AFAIK amd wont drop the CSM.

good luck with your project.

_________________
Asm For Wise Humans
Post 23 Apr 2020, 17:55
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
c'est pas faux (ce qu'ils disent plus haut), il faut d'abord bien maitriser et connaitre les bases. je ne sais pas quel est ton background en developpement, mais l'asm est un domaine bien different des autres langages. il est plus proche de la logique et de la mecanique que de l'informatique. ça demande de comprendre les fonctions de base de n'importe quel processeur.

les processeurs x86 sont relativement simples a utiliser, mais très complexes à comprendre.

le fonctionnement du mode uefi des pc est un fragment de ce que tu dois comprendre pour coder ce que tu veux coder.

un os, ou une appli embarquée, ça demande de maitriser l'outil.

n'hesite pas à tester les codes des autres, et à les lire pour les comprendre. ça va rentrer.
Post 24 Apr 2020, 18:04
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 807
Location: Belarus
DimonSoft
Fulgurance wrote:
I have understand something ! It's always needed to restore rcx and rdx ???

Et la réponse à cette question est liée à les conventions d’appel des fonctions utilisé par UEFI, l’une des conventions. Mais ayant de l’expérience dans la programmation pour Windows tout ça serait assez évident. C’est pour ça que je dis qu’il ne faut pas se plonger dans UEFI sans avoir assez d’expérience plus basique: beaucoup des choses assez simples va prendre trop de temps.
Post 24 Apr 2020, 19:50
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6

< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.