flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Use UEFI Graphics Output Protocol Goto page 1, 2, 3, 4, 5, 6, 7 Next |
Author |
|
bitRAKE 10 Apr 2020, 15:39
If the handle (ImageHandle for an application) can access the protocol, it's GUID can be used to return a pointer to the interface through EFI_BOOT_SERVICES.OpenProtocol. This is slightly analogous to the way COM works.
|
|||
10 Apr 2020, 15:39 |
|
Fulgurance 10 Apr 2020, 16:40
Hum, okay. But there aren't any information how can i use this fonction into UEFI documentation. Can you give me an example please. I don't understand how can i do that. What is GUID ?
And sorry, but i have never coding COM files... |
|||
10 Apr 2020, 16:40 |
|
DimonSoft 10 Apr 2020, 18:18
It’s not about COM files, it’s about COM interfaces, a completely unrelated thing.
|
|||
10 Apr 2020, 18:18 |
|
Fulgurance 10 Apr 2020, 19:22
Ohokay. I don't know COM interface.Have you got some example please ?
|
|||
10 Apr 2020, 19:22 |
|
revolution 10 Apr 2020, 19:26
|
|||
10 Apr 2020, 19:26 |
|
bitRAKE 10 Apr 2020, 19:27
If you don't know what a GUID is then you've hardly read enough of the spec, IMHO. I'm sorry that the learning curve is so steep. There are examples:
https://github.com/fabianishere/boot2flappy - cool graphic game for UEFI (see https://github.com/fabianishere/boot2flappy/blob/9b1aced88a33e31f95c1a61614f4b53dc2147458/src/efi-x86_64/graphics.s#L51) Ferno has converted his debugger FDBG to work on EFI, but it's not gfx, but is a larger example of EFI use. It's on the board if you search. Some other references: https://en.wikipedia.org/wiki/Component_Object_Model https://docs.microsoft.com/en-us/windows/win32/com/com-objects-and-interfaces UEFI differs from COM in that interfaces do not inherit from IUnknown, and the firmware restricts interface use by handle. But a lot of cool additional features exist as well. Creating your own protocols for the hardware you have. These can stay resident after the OS takes over. Replacing firmware UEFI protocols with your own implementations, etc. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 Apr 2020, 19:27 |
|
ProMiNick 10 Apr 2020, 19:36
https://yadi.sk/d/HTs1wxZvp6BmYw see subfolder "\DEMOS\EXECS\WINDOWS\WIN32\COM_TECH" there 2 folders "CLIENTS" & "SERVERS" (COM is client-server technology).
sources are compilable with includes path like in file fasmw.ini in subfolder "\BIN". example of using COM(as client) in EasyCode package (package is crossassembler IDE) of forum member EasyCode. all rest about COM exist only in HLL. [EDITED]because UEFI differs from COM, beter read what suggested bitRAKE. |
|||
10 Apr 2020, 19:36 |
|
bitRAKE 10 Apr 2020, 22:59
If you are on windows, this example works well:
https://github.com/nebulaeonline/nebulae This is a project to keep an eye on. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 Apr 2020, 22:59 |
|
Fulgurance 11 Apr 2020, 09:48
bitRAKE wrote: If you are on windows, this example works well: I'm Gentoo Linux user |
|||
11 Apr 2020, 09:48 |
|
Fulgurance 11 Apr 2020, 09:53
Oh yes, i'm stupid, GUID ... simply GUID partition table (GPT) Yes i see.
But i don't understand how GUID can help me to call Graphical function. I'm going to read yours links, and i come again if i have some questions But... hey ! Now i think i have understand something. First install protocol with boot service and pass Graphics Output Protocol at argument with him GUID ? And after call it ? Is it something else ? |
|||
11 Apr 2020, 09:53 |
|
Fulgurance 11 Apr 2020, 13:20
Okay, i have read all, and i have coded that. But i'm not sure about my way to pass GUID arguments.Is it two 64 bits parameters ? i'm not sure about BltOperation, is it bolean or the same as efi offset ?
And how can i pass the last arguments ? With stack ? Look: Code: format pe64 efi entry Main section '.text' code readable executable Main: mov [SystemTable],rdx mov rcx,[rdx+EFISystemTable.BootServices] mov rax,[rcx+EFIBootServices.OpenProtocol] mov rdx,0x9042a9de23dc4a38 mov r8,0x96fb7aded080516a mov r9,[rax+EFIGraphicsOutputProtocol.Blt] mov r10,RectangleColor mov r11,EFIGraphicsOutputBltOperation.BufferToVideo mov r12,0x0 mov r13,0x0 mov r14,0x64 mov rsi,0x64 mov rdi,0xF sub rsp,0x20 call rax add rsp,0x20 mov rdx,[SystemTable] jmp $ section '.data' data readable writable include "UEFIDataTypes.fasm" include "EFITableHeader.fasm" include "EFISystemTable.fasm" include "EFIBootServices.fasm" include "EFIGraphicsOutputProtocol.fasm" include "EFIGraphicsOutputBltOperation.fasm" SystemTable: dq ? SystemMessage: du '* EFI Boot: ',0x0 Message: du 'Test OK',0xD,0xA,0x0 RectangleColor: db 0xFF,0xFF,0xFF,? Last edited by Fulgurance on 11 Apr 2020, 13:26; edited 2 times in total |
|||
11 Apr 2020, 13:20 |
|
Fulgurance 11 Apr 2020, 13:21
Code: struc EFIInteger8 { . db ? } struc EFIInteger16 { align 2 . dw ? } struc EFIInteger32 { align 4 . dd ? } struc EFIInteger64 { align 8 . dq ? } macro EFITable name { virtual at 0 name name end virtual } |
|||
11 Apr 2020, 13:21 |
|
Fulgurance 11 Apr 2020, 13:21
Code: struc EFITableHeader { .Signature EFIInteger64 .Revision EFIInteger32 .HeaderSize EFIInteger32 .CRC32 EFIInteger32 .Reserved EFIInteger32 } EFITable EFITableHeader |
|||
11 Apr 2020, 13:21 |
|
Fulgurance 11 Apr 2020, 13:22
Code: struc EFISystemTable { .Hdr EFITableHeader .FirmwareVendor EFIInteger64 .FirmwareRevision EFIInteger32 .ConsoleInHandle EFIInteger64 .ConIn EFIInteger64 .ConsoleOutHandle EFIInteger64 .ConOut EFIInteger64 .StandardErrorHandle EFIInteger64 .StdErr EFIInteger64 .RuntimeServices EFIInteger64 .BootServices EFIInteger64 .NumberOfTableEntries EFIInteger64 .ConfigurationTable EFIInteger64 } EFITable EFISystemTable |
|||
11 Apr 2020, 13:22 |
|
Fulgurance 11 Apr 2020, 13:22
Code: struc EFIBootServices { .Hdr EFITableHeader .RaiseTPL EFIInteger64 .RestoreTPL EFIInteger64 .AllocatePages EFIInteger64 .FreePages EFIInteger64 .GetMemoryMap EFIInteger64 .AllocatePool EFIInteger64 .FreePool EFIInteger64 .CreateEvent EFIInteger64 .SetTimer EFIInteger64 .WaitForEvent EFIInteger64 .SignalEvent EFIInteger64 .CloseEvent EFIInteger64 .CheckEvent EFIInteger64 .InstallProtocolInterface EFIInteger64 .ReinstallProtocolInterface EFIInteger64 .UninstallProtocolInterface EFIInteger64 .HandleProtocol EFIInteger64 .RegisterProtocolNotify EFIInteger64 .LocateHandle EFIInteger64 .LocateDevicePath EFIInteger64 .InstallConfigurationTable EFIInteger64 .LoadImage EFIInteger64 .StartImage EFIInteger64 .Exit EFIInteger64 .UnloadImage EFIInteger64 .ExitBootServices EFIInteger64 .GetNextMonoticCount EFIInteger64 .Stall EFIInteger64 .SetWatchdogTimer EFIInteger64 .ConnectController EFIInteger64 .DisconnectController EFIInteger64 .OpenProtocol EFIInteger64 .CloseProtocol EFIInteger64 .OpenProtocolInformation EFIInteger64 .ProcotocolsPerHandle EFIInteger64 .LocateHandleBuffer EFIInteger64 .LocateProtocol EFIInteger64 .InstallMultipleProtocolInterfaces EFIInteger64 .UninstallMultipleProtocolInterfaces EFIInteger64 .CalculateCrc32 EFIInteger64 .CopyMem EFIInteger64 .SetMem EFIInteger64 .CreateEventEx EFIInteger64 } EFITable EFIBootServices |
|||
11 Apr 2020, 13:22 |
|
Fulgurance 11 Apr 2020, 13:22
Code: struc EFIGraphicsOutputProtocol { .QueryMode EFIInteger64 .SetMode EFIInteger64 .Blt EFIInteger64 .Mode EFIInteger64 } EFITable EFIGraphicsOutputProtocol |
|||
11 Apr 2020, 13:22 |
|
Fulgurance 11 Apr 2020, 13:23
Code: struc EFIGraphicsOutputBltOperation { .VideoFill EFIInteger64 .VideoToBltBuffer EFIInteger64 .BufferToVideo EFIInteger64 .VideoToVideo EFIInteger64 .OperationMax EFIInteger64 } EFITable EFIGraphicsOutputBltOperation |
|||
11 Apr 2020, 13:23 |
|
bitRAKE 11 Apr 2020, 18:20
Each protocol is a pointer to an interface. Get pointer to EFI_GRAPHICS_OUTPUT_PROTCOL and then the third pointer is Blt function. There are many separate function calls - each with their own parameters.
Okay, so let us work backward, assuming we are going to fill a 16x16 area with the color red: Code: ; our pixel (somewhere in a data section) Red_Pixel db 0,0,-1,0 ; EFI_GRAPHICS_OUTPUT_BLT_PIXEL array of one item ; ... after other setup ... mov rcx,[gop] ; EFI_GRAPHICS_OUTPUT_PROTOCOL mov rdx,Red_Pixel mov r8,0 ; EfiBltVideoFill mov r9,0 ; source X mov qword[rsp + 8*4],0 ; source Y mov qword[rsp + 8*5],0 ; destination X mov qword[rsp + 8*6],0 ; destination Y mov qword[rsp + 8*7],16 ; width mov qword[rsp + 8*8],16 ; height mov qword[rsp + 8*8],0 ; delta call [rcx + EFI_GRAPHICS_OUTPUT_PROTOCOL.Blt] *BltBuffer - the asterisks means a pointer to the data is needed. enum are just integer constants, so EfiBltVideoFill = 0. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
11 Apr 2020, 18:20 |
|
revolution 11 Apr 2020, 18:58
Something doesn't look right:
Code: mov qword[rsp + 8*8],16 ; height mov qword[rsp + 8*8],0 ; delta |
|||
11 Apr 2020, 18:58 |
|
Goto page 1, 2, 3, 4, 5, 6, 7 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.