OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:08 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: UEFI Print(%s) writes weird characters
PostPosted: Wed Apr 12, 2023 5:40 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
I don't know why suddenly when I tried to add DLL Loading to my bootloader, Some weird stuff started to happen, first when I loaded one function from one DLL it worked fine but as soon as I added another function the bootloader does no longer work (and the loading code is copied from the previous os which was successful in loading relocatable importing and exporting pe images).

Print() prints some weird stuff when adding an ASCII String Argument "%s" even on the serial.log.

The Kernel "/src/nos" imports "syscruntime.lib" which is the kernel mode version of my cruntime library (basicly its exactly the same as cruntime.lib but compiled with /SUBSYSTEM:native

I don't see anything wrong in the loader "/src/boot/efi/amd64/load.c"

However even if I try to print a string at the start of UefiEntry to same weird thing happens, but if I use a unicode string "%ls" it works fine.

Libraries code is at "/lib/"

project NewOS : https://github.com/NXTdevosc1/New-Operating-System

Although the bootloader gets extremely larger each time I add a function, now it is at 183KB, I don't think it needs to be more then 25KB


Top
 Profile  
 
 Post subject: Re: UEFI Print(%s) writes weird characters
PostPosted: Wed Apr 12, 2023 6:12 pm 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
EFI does not have a "Print" function, but gnu-efi's efilib does.

The efilib Print function takes a UTF16 format string, and the "%s" formatter also expects UTF16 arguments. If you want to pass an ASCII string argument, it has a "%a" format specifier.

Here's a reference from someone's mirror of gnu-efi: https://github.com/vathpela/gnu-efi/blo ... nt.c#L1055

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: UEFI Print(%s) writes weird characters
PostPosted: Wed Apr 12, 2023 10:37 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
It looks like this is actually EDK2 and not GNU-EFI, but EDK2 also provides a Print() function, and EDK2's Print() function also requires "%a" for ASCII strings.


Top
 Profile  
 
 Post subject: Re: UEFI Print(%s) writes weird characters
PostPosted: Wed Apr 12, 2023 11:14 pm 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
Octocontrabass wrote:
It looks like this is actually EDK2 and not GNU-EFI, but EDK2 also provides a Print() function, and EDK2's Print() function also requires "%a" for ASCII strings.

Ah, my mistake - though, the UefiLib in EDK2 is a descendent of the efilib in gnu-efi, which is why these work the same way :)

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: UEFI Print(%s) writes weird characters
PostPosted: Fri Apr 14, 2023 5:44 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
Thanks ill try that.


Top
 Profile  
 
 Post subject: Re: UEFI Print(%s) writes weird characters
PostPosted: Fri Apr 14, 2023 4:15 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
It's working !


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

All times are UTC - 6 hours


Who is online

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