public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Andrew Fish" <afish@apple.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>,
	Pedro Falcato <pedro.falcato@gmail.com>
Cc: d.meneses@softi9.pt
Subject: Re: [edk2-devel] How to add a DXE driver to an OVMF image?
Date: Wed, 02 Nov 2022 18:07:56 -0700	[thread overview]
Message-ID: <3519C852-1306-4986-92F2-D5B2C4531D00@apple.com> (raw)
In-Reply-To: <CAKbZUD2_rfZ++fS-FxoaqgEg4j4M8JT0B=+KrcS1xhRvZn4pGw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3521 bytes --]

If you are building with the firmware use the DebugLib in the INF and DEBUG(); macros.

DEBUG((DEBUG_ERROR, “It works\n”));

Also by setting your Depex to TRUE you are basically asking to run before the console is available. If you want to depend on all UEFI Services being present don’t set a dependency expression. The Depex is for ordering the early drivers that don’t follow the UEFI Driver Model. So for example you have to configure your chipset, and SPI driver to get UEFI NVRAM working etc. 

Thanks,

Andrew Fish

> On Nov 2, 2022, at 5:58 PM, Pedro Falcato <pedro.falcato@gmail.com> wrote:
> 
> Hi!
> 
> If I recall correctly, UEFI drivers are not guaranteed to have a valid ConOut and ConIn, and you're not supposed to use those. They are (always?) valid in UEFI apps.
> Can you try to use DebugLib (don't forget to place DebugLib in LibraryClasses) and DEBUG((DEBUG_INFO, "Blah\n")); ? That should pretty much work. Note that OVMF will send those debug messages to a special device, so you can pass "-debugcon file:debug.log -global isa-debugcon.iobase=0x402" to QEMU to keep them. The rest of your procedure looks mostly OK as far as I can tell.
> 
> Crash theory: ConOut was garbage, so you tried to jump into a random address. Random address had random data/instructions in there, which caused you an int 6 -> Invalid opcode.
> 
> Thanks,
> Pedro
> 
> On Wed, Nov 2, 2022 at 2:02 PM d.meneses via groups.io <http://groups.io/> <d.meneses=softi9.pt@groups.io <mailto:softi9.pt@groups.io>> wrote:
>> As detailed on this post on Super User <https://superuser.com/q/1749795/1742482>, I am trying to add a DXE driver to an OVMF image I'm building with edk2. Nobody was able to help me there so I turn here for your help.
>>  
>> I haven't found any proper documentation on exactly what I'm trying to achieve so I am probably missing something.
>>  
>> So far what I have done is:
>> create the simplest DXE driver I managed
>> In folder MdeModulePkg/Application/Hello, I have:
>> Hello.c : 
>> include
>>  
>> ...
>>  
>> while (1)
>>         SystemTable->ConOut->OutputString(SystemTable->ConOut,
>>                                           L"It works!\n");
>> return EFI_SUCCESS;
>> 
>>  
>> Hello.inf : 
>> [Defines]
>>   INF_VERSION                    = 0x00010005
>>   BASE_NAME                      = Hello
>>   FILE_GUID                      = ...
>>   MODULE_TYPE                    = DXE_DRIVER
>>   VERSION_STRING                 = 1.0
>>   ENTRY_POINT                    = UefiMain
>> 
>> 
>> [Sources]
>>   Hello.c
>> 
>> [Packages]
>>   MdePkg/MdePkg.dec
>>   MdeModulePkg/MdeModulePkg.dec
>> 
>> [LibraryClasses]
>>   UefiDriverEntryPoint
>>   UefiLib
>> 
>> [Depex]
>>     TRUE
>> Set OvmfPkg/OvmfPkgX64.dsc as my target platform with GCC5 as the toolchain
>> Add MdeModulePkg/Application/Hello/Hello.inf to the end of the component section (I have tried to add it after other certain drivers) in the .dsc file.
>> Add MdeModulePkg/Application/Hello/Hello.inf to the end of the [FV.DXEFV] section in OvmfPkgX64.fdf (I have also tried to add it after other certain drivers)
>> Run build
>> Run QEMU with the resulting OVMF image: qemu-system-x86_64 -d int -D log.txt  -bios OVMF.fd -net none -drive file=fat:rw:bootdrv,format=raw
>> QEMU hangs with message "Guest has not initialized display (yet)"
>> log.txt has one log: check_exception old: 0xffffffff new 0x6
>>  
>> 
>> 
> 
> 
> -- 
> Pedro Falcato
> 


[-- Attachment #2: Type: text/html, Size: 30481 bytes --]

  reply	other threads:[~2022-11-03  1:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 11:11 How to add a DXE driver to an OVMF image? d.meneses
2022-11-03  0:58 ` [edk2-devel] " Pedro Falcato
2022-11-03  1:07   ` Andrew Fish [this message]
2022-11-03 15:23     ` d.meneses
2022-11-03 16:51       ` Pedro Falcato
2022-11-03 19:11         ` d.meneses
2022-11-03 21:34           ` Andrew Fish
2022-11-03 22:02             ` d.meneses
2022-11-03 22:02               ` Pedro Falcato
2022-11-03 22:12                 ` d.meneses
2022-11-04 13:20                   ` d.meneses
2022-11-09 17:52                     ` Andrew Fish
2022-11-09 18:29                       ` d.meneses
2022-11-09 20:09                         ` Andrew Fish
2022-11-10  7:43                           ` d.meneses

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3519C852-1306-4986-92F2-D5B2C4531D00@apple.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox