OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Oct 25, 2021 3:49 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: In EDK2: How to use the real Libraries (MdePkg)
PostPosted: Tue Sep 21, 2021 1:12 am 
Offline

Joined: Wed Sep 08, 2021 8:59 am
Posts: 2
Hi everyone,
I recently started an EDK2 project for a little embedded board. Everything works fine so far, but now I struggle with the serial communication.

What I did:
I used this Introduction (step by step) to create my application: https://wiki.osdev.org/EDK2

Some additional functionality I added works so far:
  • I successfully jumped to 32 Bit mode and can execute stuff there
  • Printing stuff on the screen
  • Accessing files (reading and writing)


Now I wanted to use the serial communication. This is what I tried:
In my .dec file:
Adding following :
Code:
[Packages]
...
PcAtChipsetPkg/PcAtChipsetPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
...
[LibraryClasses]
...
SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf


When calling SerialPortInitialize/...Send/...Receive in my main function, it executes those methods from MdePkg/Library/BaseSerialPortLibNull.c instead. (Obviously not sending anything on the serial bus)

How can I call the "correct" function instead of that stub/null thing? I tried to search in this forum, also in google for several hours now but can't find the answer yet.

Any help would be awesome, thank you for reading!!!


Top
 Profile  
 
 Post subject: Re: In EDK2: How to use the real Libraries (MdePkg)
PostPosted: Wed Sep 22, 2021 2:03 am 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 444
Location: North Dakota, United States
You need to use the EFI Serial IO protocol, not the serial port library. In your [Protocols] section of your .INF file, add:
Code:
gEfiSerialIoProtocolGuid

And then use the Serial IO protocol like you would any other protocol. (For packages/libraries/... you need to create a DXE (for drivers) or application (for EFI applications) with an INF file for each DXE or app, and then include that in a .dsc for your platform. I don't know what the DEC files are for.)


Top
 Profile  
 
 Post subject: Re: In EDK2: How to use the real Libraries (MdePkg)
PostPosted: Wed Sep 22, 2021 5:49 am 
Offline

Joined: Wed Sep 08, 2021 8:59 am
Posts: 2
Okay, that totally makes sense. Somehow I mixed it up completely, thank you for bringing me back on track!


Top
 Profile  
 
 Post subject: Re: In EDK2: How to use the real Libraries (MdePkg)
PostPosted: Wed Sep 22, 2021 4:17 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 444
Location: North Dakota, United States
mattibendewald wrote:
Okay, that totally makes sense. Somehow I mixed it up completely, thank you for bringing me back on track!

Understandable; I've made that mistake with TimerLib. EDK II's build system can be confusing, and what libraries to use and avoid can also be confusing. The rule of thumb, I think, is: if a library is a template-based library (that is, if it contains a *Null implementation), use the underlying protocol only; otherwise, you can use the protocol in conjunction with the library. In the (majority) of cases involving purely non-template-based libraries, the libraries extend the functionality of EFI applications that use their associated protocol(s), or provide simpler interfaces to the (possibly more complicated) interfaces provided by the protocol.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 27 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