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, 7 Next |
Author |
|
Fulgurance 21 Apr 2020, 14:13
Thanks you
But no, don't work ... ..It's terrible ... |
|||
21 Apr 2020, 14:13 |
|
Fulgurance 22 Apr 2020, 14:41
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 |
|||
22 Apr 2020, 14:41 |
|
edfed 22 Apr 2020, 21:50
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.
|
|||||||||||
22 Apr 2020, 21:50 |
|
Fulgurance 23 Apr 2020, 09:47
No 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... |
|||
23 Apr 2020, 09:47 |
|
Ali.Z 23 Apr 2020, 10:42
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 |
|||
23 Apr 2020, 10:42 |
|
Fulgurance 23 Apr 2020, 11:47
In one word, thanks ! End of desesperate
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,? |
|||
23 Apr 2020, 11:47 |
|
Fulgurance 23 Apr 2020, 11:52
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
|
|||
23 Apr 2020, 11:52 |
|
Fulgurance 23 Apr 2020, 11:59
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,? |
|||
23 Apr 2020, 11:59 |
|
Fulgurance 23 Apr 2020, 12:08
I have found the problem. I need to do mov rdx,[SystemTable]. But why ...
|
|||
23 Apr 2020, 12:08 |
|
Fulgurance 23 Apr 2020, 12:56
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 |
|||
23 Apr 2020, 12:56 |
|
Fulgurance 23 Apr 2020, 13:20
I have understand something ! It's always needed to restore rcx and rdx ???
|
|||
23 Apr 2020, 13:20 |
|
DimonSoft 23 Apr 2020, 16:49
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. |
|||
23 Apr 2020, 16:49 |
|
Ali.Z 23 Apr 2020, 17:55
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 |
|||
23 Apr 2020, 17:55 |
|
edfed 24 Apr 2020, 18:04
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. |
|||
24 Apr 2020, 18:04 |
|
DimonSoft 24 Apr 2020, 19:50
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. |
|||
24 Apr 2020, 19:50 |
|
HSE 02 Apr 2022, 00:22
Apparently is so trivial that I can't find any description:
How you test *.efi files in QEMU? Thanks in advance, HSE |
|||
02 Apr 2022, 00:22 |
|
bitRAKE 02 Apr 2022, 02:38
Check out this repo, https://github.com/bitRAKE/UEFI_playground
,.. it has premade EFI firmware for a few scenarios, and the command files outline what QEMU wants, configuration wise. It was difficult to figure this stuff out as most people use a shell program of some sort to configure QEMU. The examples worked on my hardware and in QEMU. I like to map the working directory as a drive when using QEMU - makes roundtrip debugging really fast: Code: "C:\Program Files\qemu\qemu-system-x86_64w.exe" ^ -nodefaults ^ -cpu qemu64 -vga std -machine q35,smm=on ^ -device qemu-xhci -device usb-mouse -device usb-kbd ^ -L . -drive file=fat:rw:image,index=1,media=disk,if=virtio,format=raw ^ -drive file=firmware\OVMF_amd64\OVMF_CODE_4M.ms.fd,if=pflash,format=raw,unit=0,readonly=on ^ -drive file=firmware\OVMF_amd64\OVMF_VARS_4M.ms.fd,if=pflash,format=raw,unit=1 _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
02 Apr 2022, 02:38 |
|
HSE 02 Apr 2022, 17:48
Nice package!
With yours settings I have "command error status : access denied" But taking one of your lines I maked (is an older UEFI version): Code: qemu-system-x86_64w -bios OVMF.fd -drive file=fat:rw:e:\image,index=1,media=disk,if=virtio,format=raw -net none -serial stdio That allow me to test your efi files. Trying to boot inside qemu is going nowhere, some kind of loop. No problem at all with hardware, red square (bitRAKE1 version) work perfectly. Thanks. |
|||
02 Apr 2022, 17:48 |
|
HSE 04 Apr 2022, 17:46
Still no success with booting in qemu.
But there is a trick (https://www.howtogeek.com/187721/how-to-boot-from-a-usb-drive-in-virtualbox/) to boot the example from USB in VirtualBox. |
|||
04 Apr 2022, 17:46 |
|
Goto page Previous 1, 2, 3, 4, 5, 6, 7 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.