Skip to content

Conversation

@philipanda
Copy link
Contributor

@philipanda philipanda commented Jul 3, 2025

Description

Extracting hardcoded colors from setup menu into PCDs allowing for easy customisation.
Added a Dasharo theme as a bonus and PoC.

image
  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

qemu-system-x86_64 -machine q35 -serial telnet:localhost:1345,server,nowait -drive if=pflash,format=raw,unit=0,file=build/coreboot.rom

Integration Instructions

@philipanda philipanda changed the title WIP Make most color values into PCDs Setup menu color customization Jul 3, 2025
@miczyg1
Copy link
Contributor

miczyg1 commented Jul 3, 2025

I just wondered recently when someone will dare to touch CustomizedDisplayLib and play with it :)

We would have to somehow match the Dasharo green colour (on dasharo.com page the hex color for green is #38d430). Of course white and black should also be present.

If I color pick the green from the picture you posted, it gives me #009800 which is not the right one.

@philipanda
Copy link
Contributor Author

I just wondered recently when someone will dare to touch CustomizedDisplayLib and play with it :)

We would have to somehow match the Dasharo green colour (on dasharo.com page the hex color for green is #38d430). Of course white and black should also be present.

If I color pick the green from the picture you posted, it gives me #009800 which is not the right one.

CustomizedDisplayLib only supports a small color palette which looks similar to VGA color palette. There are a total of 8 possible background colors and 16 text colors, so sadly there is little possibilities to play with.

There are only two green shades possible for text - green and light green, for backgrounds its only the green you see.

I can't tell if it would be feasible to extend the color palette. It might be more challenging than just exposing the colors as PSDs.

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 3, 2025

I think it will be inevitable to change mGraphicsEfiColors table in MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c

Also we have to take care of serial terminal colors in TerminalConOutSetAttribute (MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c)

Also you may try to change the font to something more close to what we use on dasharo.com (I believe it is oswald font regular-400 or a Font Awesome 6 regular-400)

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 3, 2025

Colors taken from dasharo.com that I suggest that may be suitable:

DARKGRAY - #29363b
LIGHTGRAY - #808080
LIGHTGREEN - #38d430

@philipanda
Copy link
Contributor Author

philipanda commented Jul 5, 2025

I've exposed the hex color palette as PCDs too and come up with this color scheme in graphics mode using the hex values you've given:
image

There are only 8 possible background colors, so I had to do some non-obvious "reshades":

  • EFI_LIGHTCYAN -> #FFFFFF
  • EFI_LIGHTGREEN -> #38d430
  • EFI_BROWN -> #29363b
  • EFI_LIGHTGRAY -> #808080

For now it doesn't look that great via serial though ;)
image

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 7, 2025

For now it doesn't look that great via serial though ;)

Of course it doesn't :) Check out this: https://gist.github.com/viniciusdaniel/53a98cbb1d8cac1bb473da23f5708836
Maybe the 88/256 colors are supported. If not, then it would have to be implemented in TerminalConOutSetAttribute
Currently I believe we use 8/16 colors only as they are widely supported. The 88/256 palette seem to be supported by just a handful of terminals. There is also 24bit color: https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit (then maybe the same graphics RGB notations could be used in serial terminal)

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 7, 2025

Couple more suggestions to the color selection:

  1. Option text (Intel ME mode) and simple text (Press ESC to exit) colors maybe should be reversed? Options green and text gray. Help text is good though.
  2. Originally the hotkey help section had a black foreground to stand out a bit differently. Can it stay black? It would probably look good with green hotkey help strings.
  3. Help section should be darker. It barely stands out from the foreground:

image

@philipanda
Copy link
Contributor Author

I think it will be inevitable to change mGraphicsEfiColors table in MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c

Also we have to take care of serial terminal colors in TerminalConOutSetAttribute (MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c)

Also you may try to change the font to something more close to what we use on dasharo.com (I believe it is oswald font regular-400 or a Font Awesome 6 regular-400)

That might be more troublesome than expected 😆
It seems that the font used by GraphicsConsole.c is defined at /MdeModulePkg/Universal/Console/GraphicsConsoleDxe/LaffStd.c. That is a huge array that maps Unicode glyphs to bitmaps made of hex bytes.

Adding a support for vector fonts might be a little too much for now, but maybe it could be feasible to create a tool that could convert vector fonts into bitmaps like the one defined in LaffStd.c.

@philipanda
Copy link
Contributor Author

philipanda commented Jul 12, 2025

I've been fiddling around with converting the Oswald font to bitmaps. The results seemed promising, but in the end I think it will not be possible to properly display a proper vector font in 19x8 resolution.

That's the best results I was able to achieve. While it's possible to do some postprocessing to fix jagged edges, losing detail is inevitable. Creating such a small font requires working with pixel art.

image

The scripts for the conversion are on a separate branch as I will scrap that idea for now.

@macpijan
Copy link
Contributor

macpijan commented Jul 14, 2025

Yeah the font does not look great and would require more work.

The colors look interesting, though.

@philipanda philipanda force-pushed the setup-menu-color-customization branch 2 times, most recently from cb616c6 to 145ff2b Compare September 16, 2025 07:44
@philipanda
Copy link
Contributor Author

Looks like the 256 colors mode might work easily on terminals that support it.
It's enough to modify the escape codes produced by the TerminalConOutSetAttribute. I don't think there would be a simple way of knowing what color modes the client terminal understands though, so the compatibility with simple terminals might get worse.

I've tried hardcoding this pinkish color for every printed character. I think I've messed something up with the escape codes, but the color definitely looks like the one I've requested (213).
image

@philipanda
Copy link
Contributor Author

philipanda commented Sep 21, 2025

And the 24 bit mode works perfectly too, at least on Gnome terminal.
The amount of work that would be needed to implement any of them seem to be similarly low. It would require only modifying how TerminalConOutSetAttribute encodes the 16 color EFI color palette into escape codes.

The color used here is the Dasharo green #38d430.
The only little issue is that the color needs to be convered from hex to decimal to use in an escape code.
image

When accessing the serial without the 24b truecolor support using xterm:

xterm -cm

Nothing is broken, just that there are no colors:
image

I think 24b color would be the best solution. I had a hard time trying to stop my terminal from interpreting them, so that makes me believe that most potential users won't have issues with that and it won't break tests via serial in OSFV.

@philipanda
Copy link
Contributor Author

Using the 24b escape codes the colors work great via on a serial console via telnet on Qemu:
image

Some of the colors, like most of the gray/white text, don't exactly match. I suspect it's an issue with mapping the RGB colors into the 16 EFI colors along the way. Maybe the bright bit is not interpreted correctly when mapping the colors.

@philipanda philipanda force-pushed the setup-menu-color-customization branch 2 times, most recently from 4483433 to 2473d00 Compare September 21, 2025 12:17
@miczyg1
Copy link
Contributor

miczyg1 commented Sep 24, 2025

The only little issue is that the color needs to be convered from hex to decimal to use in an escape code.

Should be easy with %02u formatter for printf.

Some of the colors, like most of the gray/white text, don't exactly match. I suspect it's an issue with mapping the RGB colors into the 16 EFI colors along the way. Maybe the bright bit is not interpreted correctly when mapping the colors.

Yeah, the letters in the top section are far from being white... But hey, it looks neat already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philipanda another mistakenly added change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out. I've commited some random files before too. I think that I'm commiting some artifacts from the build process that I am unaware of. I certainly did not search&replaced something in a binary file 😆. I'll check twice before adding a whole directory next time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philipanda
Copy link
Contributor Author

philipanda commented Dec 17, 2025

It looks like whatever exact code prints the graphical version of setup menu correctly uses the code 0x0F for white foreground, but the serial console uses 0x07 instead (no bright bit). It only affects this single color. Every other shade is correct in both the graphical and text (serial) modes. I guess the value 0x07 has to be hardcoded somewhere and I don't yet know where, or it is not updated witht the DasharoColorTheme.dsc.inc as 0x07 would be the default value from EDK2

@philipanda
Copy link
Contributor Author

philipanda commented Dec 18, 2025

It looks like whatever exact code prints the graphical version of setup menu correctly uses the code 0x0F for white foreground, but the serial console uses 0x07 instead (no bright bit). It only affects this single color. Every other shade is correct in both the graphical and text (serial) modes. I guess the value 0x07 has to be hardcoded somewhere and I don't yet know where, or it is not updated witht the DasharoColorTheme.dsc.inc as 0x07 would be the default value from EDK2

The issue was the line MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c:564 where the bright bit was being cleared: ForegroundControl = mTerminalEfiColors[Attribute & 0x07];. Not sure why it was like that before as the foreground supports the bright bit, unlike the background. Anding with 0x0F is the way to go and fixes the issues with invalid colors on the serial console.

With that out of the way I think all issues with this PR are fixed?

@philipanda philipanda marked this pull request as ready for review December 18, 2025 07:38
@philipanda philipanda force-pushed the setup-menu-color-customization branch 3 times, most recently from 899a8df to e86d004 Compare December 18, 2025 07:44
@philipanda philipanda requested a review from miczyg1 December 18, 2025 07:45
@philipanda
Copy link
Contributor Author

philipanda commented Dec 20, 2025

The exact pick of the colors is due to subjective feel. I'd suggest first considering only the implementation without defining custom color palette and adding the custom colors later if the one defined in this PR would need some adjustments.

I'd very much like to try and get that color customization into the upstream EDK2 next and would be grateful for any tips to improve the chances of that happening. From me, I'm afraid it is not a complete feature if only the setup menu can be colored. I've never checked how other places like the popups behave. Maybe that should be worked on first.

Another thing is that this change will make all the terminals that only support the classic 4 bit VGA color escape codes show no colors, like in the xterm example. I can't come up with a realistic scenario where someone would use EDK2 via serial using a terminal that does not support 24b RGB colors escape codes, but maybe some switch or a key combination for restoring the 4b mode would be reasonable.

Summing up how this looks like:

  • graphical with serial ON:
    Screenshot From 2025-12-20 20-56-57

  • serial with rgb support:
    Screenshot From 2025-12-20 20-58-25

  • serial with no colors support:
    Screenshot From 2025-12-20 20-57-11

  • graphical with serial redirection OFF:
    Screenshot From 2025-12-20 20-58-53

@philipanda philipanda force-pushed the setup-menu-color-customization branch from e86d004 to 7cf7c41 Compare December 20, 2025 20:39
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
@philipanda philipanda force-pushed the setup-menu-color-customization branch from 7cf7c41 to c426ae7 Compare December 20, 2025 20:44
@philipanda
Copy link
Contributor Author

philipanda commented Dec 20, 2025

*rebased onto the dasharo branch and cleared up the commits a bit

@pietrushnic
Copy link
Contributor

Looks cool. I will not judge the implementation, but definitely having our theme is a nice direction. It gives us some branding alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants