Basic Printf & Text Mode Info | UEFI Dev (in C)

Channel:
Subscribers:
5,840
Published on ● Video Link: https://www.youtube.com/watch?v=e8rR9PekdkQ



Duration: 1:19:42
527 views
24


Changing text colors, starting printf for strings and numbers, and printing current text mode information.

Notes:
- The -target flag in clang's LDFLAGS could be removed, it's wholly redundant.
Also, ifeq() and co. in gnumake work off of environment variables, and aren't ran at runtime. That plus not being able to detect cmd.exe easily is why I've gone with the comment/uncomment layout for the makefile, but there's probably better ways to do it.
Could maybe use ifeq($(OS), Windows_NT) or ifdef OS or similar to not need as much manual commenting.

- I lied, the text mode on my laptop on boot is set to 80x25. I think either the text mode can change after setting a GOP graphics mode, or the GOP mode changes when you change text modes, but my laptop starts off in the lowest or baseline supported mode of 80x25 characters.

- If you want to know how to write a small stdarg.h (and other libc system headers), take a look at "The Standard C Library" by P.J. Plauger, 1992. Chapter 10 goes over stdarg.h with only a couple macros to implement va_list et al. If it's not in print, you can sail the high seas to find it.

- In printf(), result is always set to true before it returns. That's a bug and will be fixed later on.

Links:
https://uefi.org/specifications (uefi & other specifications)

UEFI Programming playlist:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqZYHNLtOZ1MNxOt8myP5K0p

Git Repo:
https://github.com/queso-fuego/uefi-dev

Repo state at the start of this video:
git clone --recurse-submodules https://github.com/queso-fuego/uefi-dev
cd uefi-dev
git checkout a8e6966f77aed1794d05e7c1be4aa67af57d3483

Repo state at the end of this video:
git checkout 4ff04037ba5b54b7c7f101ecee789e7342c38730

Next video:
- Reading in keystrokes for user input, printing available text modes, and choosing/setting a new text mode.

Join the Community Discord: https://discord.gg/yKm4T89QFn

Contact:
https://queso_fuego.srht.site/contact.html

- Let me know if there's anything specific you'd like to see!

Questions about setup/software/etc.?
Check the FAQ: https://queso_fuego.srht.site/about.html

Outline:
0:00:00 initial set up for linux
0:01:47 fix linker warnings with LDFLAGS
0:06:14 separate file names in makefile for windows vs. linux
0:08:06 add text attributes for text colors
0:19:12 EFI_TEXT_QUERY_MODE & EFI_TEXT_SET_MODE
0:24:24 SIMPLE_TEXT_OUTPUT_MODE
0:26:14 set up global variables for less typing
0:30:46 start printf() to print formatted strings
0:47:19 add %d to printf for ints
1:05:26 get text mode columns & rows with QueryMode()
1:09:58 add print_hex() function and %x in printf
1:14:51 show text mode info
1:16:17 one more thing, fix negative numbers
1:18:04 show final output, coming up & outro

Music credits:
Winter Night by Sakura Girl | https://soundcloud.com/sakuragirl_official
Music promoted by https://www.chosic.com/free-music/all/
Creative Commons CC BY 3.0
https://creativecommons.org/licenses/by/3.0/

#uefidev #cprogramming #printf







Tags:
queso fuego
c programming
programming
uefi
efi
uefi dev
printf
custom printf
in c
text modes
text mode information
not bios
stdarg
varargs