UEFIStarter
a simple UEFI framework
Macros | Typedefs | Functions | Variables
gop.c File Reference

This application showcases a few ways to use the graphics output. More...

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/ShellCEntryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <UEFIStarter/core.h>
#include <UEFIStarter/graphics.h>

Macros

#define ARG_SKIP_BARS   _argument_list[0].value.uint64
 helper macro to access the "-skip-bars" command-line argument
 
#define ARG_SKIP_IMAGES   _argument_list[1].value.uint64
 helper macro to access the "-skip-images" command-line argument
 
#define ARG_SKIP_FONT   _argument_list[2].value.uint64
 helper macro to access the "-skip-font" command-line argument
 
#define ARG_SKIP_OBJECTS   _argument_list[3].value.uint64
 helper macro to access the "-skip-objects" command-line argument
 
#define ARG_SKIP_ANIM   _argument_list[4].value.uint64
 helper macro to access the "-skip-anim" command-line argument
 
#define REG(NAME)   register long NAME asm (#NAME);
 shortcut macro to access a CPU register
 

Typedefs

typedef image_timage_parser_f(file_contents_t *)
 data type for image parser function pointers
 

Functions

UINT8 ramp (UINTN val)
 Produces a triangular waveform going from 0 to 255 and back to 0 again. More...
 
void draw_progress_bar (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, unsigned int screen_w, unsigned int screen_h, float value)
 Draws a single frame of the progress bar. More...
 
void draw_moving_objects (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
 Draws an animation with objects moving across the screen. More...
 
void draw_prepared_fs_anim (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
 Draws an animated progress bar, then a full-screen animation. More...
 
void draw_image (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, CHAR16 *filename, image_parser_f parser)
 Loads an image and then draws it to the screen. More...
 
void draw_bars (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
 Draws a few vertical bars onto the screen. More...
 
void draw_font (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
 Draws white text on a blue background. More...
 
void do_graphics_stuff ()
 Performs all the enabled graphics demonstrations.
 
INTN EFIAPI ShellAppMain (UINTN argc, CHAR16 **argv)
 Main function, gets invoked by UEFI shell. More...
 

Variables

static cmdline_argument_t _argument_list []
 list of command-line arguments More...
 
static cmdline_argument_group_t _arguments ={ L"Application-specific options" ,sizeof( _argument_list )/sizeof(cmdline_argument_t), _argument_list }
 command-line arguments group
 

Detailed Description

This application showcases a few ways to use the graphics output.

There are a few command-line options you can use to skip individual demos or change graphics settings.

You'll need to run this application in a graphics-capable UEFI environment. Virtual machines created with the Vagrantfile included in this repository don't support graphics: the application will still run and expect a few keystrokes but you'll just see a text hint on the console.

If you have QEMU installed on a system with e.g. the X11 server (or are using it on Windows) you can execute the target image (target/*.img) there - see the Makefile's "run" target on how to do that.

If you're using VirtualBox the easiest way to run this application is probably by creating a new VM (no harddisk required), enabling EFI (Machine Settings / System / Enable EFI) and mounting the generated ISO image (target/*.iso). Booting this VM should take you to the UEFI shell as usual.

Author
Richard Nusser
License
GPLv3 (see http://www.gnu.org/licenses/)
See also
https://github.com/rinusser/UEFIStarter

Function Documentation

◆ ramp()

UINT8 ramp ( UINTN  val)

Produces a triangular waveform going from 0 to 255 and back to 0 again.

Parameters
valthe position in the triangle function
Returns
the sample at the given position

◆ draw_progress_bar()

void draw_progress_bar ( EFI_GRAPHICS_OUTPUT_PROTOCOL *  gop,
unsigned int  screen_w,
unsigned int  screen_h,
float  value 
)

Draws a single frame of the progress bar.

Parameters
gopthe UEFI graphics output protocol to draw with
screen_wthe screen's width
screen_hthe screen's height
valuethe progress to draw, within [0..1]

◆ draw_moving_objects()

void draw_moving_objects ( EFI_GRAPHICS_OUTPUT_PROTOCOL *  gop)

Draws an animation with objects moving across the screen.

This also limits the frame rate (and waits for vsync if enabled in the command line) to reduce flickering.

Parameters
gopthe UEFI graphics protocol to draw with

◆ draw_prepared_fs_anim()

void draw_prepared_fs_anim ( EFI_GRAPHICS_OUTPUT_PROTOCOL *  gop)

Draws an animated progress bar, then a full-screen animation.

This actually prepares a background buffer that's twice the screen height and then scrolls down to simulate movement.

Parameters
gopthe UEFI graphics protocol to draw with

◆ draw_image()

void draw_image ( EFI_GRAPHICS_OUTPUT_PROTOCOL *  gop,
CHAR16 *  filename,
image_parser_f  parser 
)

Loads an image and then draws it to the screen.

Todo:
remove parser function pointer and use newer load_netpbm_file() instead
Parameters
gopthe UEFI graphics protocol to draw with
filenamethe image's filename
parserthe image parser function

◆ draw_bars()

void draw_bars ( EFI_GRAPHICS_OUTPUT_PROTOCOL *  gop)

Draws a few vertical bars onto the screen.

Parameters
gopthe UEFI graphics protocol to draw with

◆ draw_font()

void draw_font ( EFI_GRAPHICS_OUTPUT_PROTOCOL *  gop)

Draws white text on a blue background.

Parameters
gopthe UEFI graphics protocol to draw with

◆ ShellAppMain()

INTN EFIAPI ShellAppMain ( UINTN  argc,
CHAR16 **  argv 
)

Main function, gets invoked by UEFI shell.

Parameters
argcthe number of command-line arguments passed
argvthe command-line arguments passed
Returns
an EFI status code for the shell

Variable Documentation

◆ _argument_list

cmdline_argument_t _argument_list[]
static
Initial value:
= {
{{uint64:0},ARG_BOOL,NULL,L"-skip-bars", L"Skip bars test"},
{{uint64:0},ARG_BOOL,NULL,L"-skip-images", L"Skip images test"},
{{uint64:0},ARG_BOOL,NULL,L"-skip-font", L"Skip font test"},
{{uint64:0},ARG_BOOL,NULL,L"-skip-objects",L"Skip moving objects test"},
{{uint64:0},ARG_BOOL,NULL,L"-skip-anim", L"Skip animation test"},
}
boolean
Definition: cmdline.h:22

list of command-line arguments