UEFIStarter
a simple UEFI framework
Functions
timer.c File Reference

This application shows how to wait for events and register a timer. More...

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

Functions

void callback (EFI_EVENT event, void *context)
 Callback function for the timer. More...
 
void do_gettime_tests ()
 Prints the current date/time info and timing capabilities of the UEFI runtime service's GetTime(). More...
 
void do_timestamp_tests ()
 Compares the internal get_timestamp() against the UEFI service's timer functions. More...
 
void do_event_tests ()
 Registers events to wait for. More...
 
INTN EFIAPI ShellAppMain (UINTN argc, CHAR16 **argv)
 Main function, gets invoked by UEFI shell. More...
 

Detailed Description

This application shows how to wait for events and register a timer.

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

Function Documentation

◆ callback()

void callback ( EFI_EVENT  event,
void *  context 
)

Callback function for the timer.

Contains a Print() call that may crash a Virtualbox VM. In current builds it does not, but it used to for some reason. Calling Print() in a timer callback is just for demonstration anyway.

Parameters
event(unused) the triggered timer event
context(unused) the triggered timer event's context data

◆ do_gettime_tests()

void do_gettime_tests ( )

Prints the current date/time info and timing capabilities of the UEFI runtime service's GetTime().

This shows resolutions of 1Hz on all tested systems, the nanosecond field seems to be always empty. This makes GetTime() useless for timing e.g. animation frames.

◆ do_timestamp_tests()

void do_timestamp_tests ( )

Compares the internal get_timestamp() against the UEFI service's timer functions.

The timer interval is 1s, so the internal timestamp should increase by 1 for each Hz of CPU frequency.

◆ do_event_tests()

void do_event_tests ( )

Registers events to wait for.

One of the events is a callback function, it will get called asynchronously whenever the event is fired. The called handler currently prints to the console - this used to hang when executed inside a VirtualBox VM.

◆ 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