Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

6 changed files with 13 additions and 238 deletions

View file

@ -23,20 +23,12 @@ steps:
- . edk2/edksetup.sh
- make -C edk2/BaseTools
- echo "Copying EfiClock application files"
- echo "Copying application files"
- mkdir edk2/EfiClock
- cp EfiClock/EfiClock.inf edk2/EfiClock/.
- cp EfiClock/UefiMain.c edk2/EfiClock/.
- rm -rf EfiClock
- cp EfiClock.inf edk2/EfiClock/. && rm EfiClock.inf
- cp UefiMain.c edk2/EfiClock/. && rm UefiMain.c
- sed -i '/\[Components\]/a EfiClock/EfiClock.inf' edk2/MdeModulePkg/MdeModulePkg.dsc
- echo "Copying EfiTicTacToe application files"
- mkdir edk2/EfiTicTacToe
- cp EfiTicTacToe/EfiTicTacToe.inf edk2/EfiTicTacToe/.
- cp EfiTicTacToe/UefiMain.c edk2/EfiTicTacToe/.
- rm -rf EfiTicTacToe
- sed -i '/\[Components\]/a EfiTicTacToe/EfiTicTacToe.inf' edk2/MdeModulePkg/MdeModulePkg.dsc
- echo "Building application"
- build -a X64 -t GCC -p MdeModulePkg/MdeModulePkg.dsc
@ -51,4 +43,3 @@ steps:
target: main
files:
- Build/MdeModule/DEBUG_GCC/X64/EfiClock.efi
- Build/MdeModule/DEBUG_GCC/X64/EfiTicTacToe.efi

View file

@ -1,27 +0,0 @@
[Defines]
INF_VERSION = 1.25
BASE_NAME = EfiTicTacToe
FILE_GUID = e1b1a000-f422-4f61-a6dd-fadc10ae3e28 # Get a GUID from guidgen.com
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = UefiEntry
[Sources]
UefiMain.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
UefiApplicationEntryPoint
UefiLib
[Guids]
[Ppis]
[Protocols]
[FeaturePcd]
[Pcd]

View file

@ -1,181 +0,0 @@
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/AbsolutePointer.h>
EFI_GUID app_guid = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID;
EFI_ABSOLUTE_POINTER_PROTOCOL *App = NULL;
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop = NULL;
UINT64 Gop_FrameBufferBase = 0;
UINT32 Gop_PixelsPerScanLine = 0;
static inline void drawPixel(UINT32 x, UINT32 y, UINT32 pixel)
{
*((UINT32*)(Gop_FrameBufferBase + 4 * Gop_PixelsPerScanLine * y + 4 * x)) = pixel;
}
static inline void drawRectangle(UINT32 x, UINT32 y, UINT32 w, UINT32 h, UINT32 pixel)
{
for(int ix = 0; ix < w; ++ix)
{
for(int iy = 0; iy < h; ++iy)
{
drawPixel(x+ix, y+iy, pixel);
}
}
}
EFI_STATUS EFIAPI UefiEntry(IN EFI_HANDLE imgHandle, IN EFI_SYSTEM_TABLE* sysTable)
{
EFI_STATUS Status;
Status = gBS->LocateProtocol(&gop_guid, NULL, (VOID **)&Gop);
if (EFI_ERROR(Status)) {
Print(u"\r\nERROR: %x; Cannot locate GOP protocol. Return.\r\n", Status);
return Status;
}
Gop_FrameBufferBase = Gop->Mode->FrameBufferBase;
Gop_PixelsPerScanLine = Gop->Mode->Info->PixelsPerScanLine;
UINT32 W = Gop->Mode->Info->HorizontalResolution;
UINT32 H = Gop->Mode->Info->VerticalResolution;
Status = gBS->LocateProtocol(&app_guid, NULL, (VOID **)&App);
if (EFI_ERROR(Status)) {
Print(u"\r\nERROR: %x; Cannot locate APP protocol. Return.\r\n", Status);
return Status;
}
UINT64 aMinX = App->Mode->AbsoluteMinX;
UINT64 aMaxX = App->Mode->AbsoluteMaxX;
UINT64 aMinY = App->Mode->AbsoluteMinY;
UINT64 aMaxY = App->Mode->AbsoluteMaxY;
UINT32 sq_sid = W * 80 / 1000;
UINT32 sq_gap = W * 20 / 1000;
UINT32 col[3] = { W/2 - 3*sq_sid/2 - sq_gap ,
W/2 - sq_sid/2 ,
W/2 + sq_sid/2 + sq_gap };
UINT32 row[3] = { H/2 - 3*sq_sid/2 - sq_gap ,
H/2 - sq_sid/2 ,
H/2 + sq_sid/2 + sq_gap };
UINT32 aRow0 = aMinY + 450*(aMaxY-aMinY)/1000;
UINT32 aRow1 = aMinY + 550*(aMaxY-aMinY)/1000;
UINT32 aCol0 = aMinX + 450*(aMaxX-aMinX)/1000;
UINT32 aCol1 = aMinX + 550*(aMaxX-aMinX)/1000;
const UINT32 accentColor = 0xFFFFFF, idleColor = 0x000000, AColor = 0xCC0000, BColor = 0xFF5500;
drawRectangle(0,0,W,H,idleColor);
drawRectangle(col[1]-4*sq_gap/7,row[0],sq_gap/8,3*sq_sid+2*sq_gap,accentColor);
drawRectangle(col[2]-4*sq_gap/7,row[0],sq_gap/8,3*sq_sid+2*sq_gap,accentColor);
drawRectangle(col[0],row[1]-4*sq_gap/7,3*sq_sid+2*sq_gap,sq_gap/8,accentColor);
drawRectangle(col[0],row[2]-4*sq_gap/7,3*sq_sid+2*sq_gap,sq_gap/8,accentColor);
UINTN EventIndex = 0;
UINT32 turn = AColor;
UINT32 board[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}};
void draw(int c, int r) {
if (board[0][0] != 0 && board[0][0] == board[1][0] && board[1][0] == board[2][0]) return;
if (board[0][1] != 0 && board[0][1] == board[1][1] && board[1][1] == board[2][1]) return;
if (board[0][2] != 0 && board[0][2] == board[1][2] && board[1][2] == board[2][2]) return;
if (board[0][0] != 0 && board[0][0] == board[0][1] && board[0][1] == board[0][2]) return;
if (board[1][0] != 0 && board[1][0] == board[1][1] && board[1][1] == board[1][2]) return;
if (board[2][0] != 0 && board[2][0] == board[2][1] && board[2][1] == board[2][2]) return;
if (board[0][0] != 0 && board[0][0] == board[1][1] && board[1][1] == board[2][2]) return;
if (board[0][2] != 0 && board[0][2] == board[1][1] && board[1][1] == board[2][0]) return;
if (board[c][r] == 0)
{
board[c][r] = turn;
drawRectangle(col[c],row[r],sq_sid,sq_sid,turn);
if (turn == AColor)
{
turn = BColor;
}
else
{
turn = AColor;
}
}
}
while(1) {
Status = gBS->WaitForEvent(1, /*Event*/ &(App->WaitForInput), &EventIndex);
EFI_ABSOLUTE_POINTER_STATE State;
App->GetState(App, &State);
if (State.CurrentX < aCol0)
{
if (State.CurrentY < aRow0)
{
draw(0,0);
}
else if (State.CurrentY < aRow1)
{
if (board[0][1] == 0)
{
draw(0,1);
}
}
else
{
if (board[0][2] == 0)
{
draw(0,2);
}
}
}
else if (State.CurrentX < aCol1)
{
if (State.CurrentY < aRow0)
{
draw(1,0);
}
else if (State.CurrentY < aRow1)
{
draw(1,1);
}
else
{
draw(1,2);
}
}
else
{
if (State.CurrentY < aRow0)
{
draw(2,0);
}
else if (State.CurrentY < aRow1)
{
draw(2,1);
}
else
{
draw(2,2);
}
}
}
return EFI_SUCCESS;
}

View file

@ -11,6 +11,6 @@ The following functionalities are used:
## Pipeline
[![status-badge](https://ci.slowte.ch/api/badges/12/status.svg)](https://ci.slowte.ch/repos/12)
[![status-badge](https://ci.slowte.ch/api/badges/9/status.svg)](https://ci.slowte.ch/repos/9)
A Fedora-based building pipeline provides binariess `.efi` files. It clones and build the toolchain from [TianoCore's toolchain repositories](https://github.com/tianocore). Binaries are released for each tag on the [releases page](https://forge.slowte.ch/uefi/efi-clock/releases).

View file

@ -29,20 +29,21 @@ static inline void drawRectangle(UINT32 x, UINT32 y, UINT32 w, UINT32 h, UINT32
EFI_STATUS EFIAPI UefiEntry(IN EFI_HANDLE imgHandle, IN EFI_SYSTEM_TABLE* sysTable)
{
gST = sysTable;
gBS = gST->BootServices;
gBS = sysTable->BootServices;
gImageHandle = imgHandle;
gBS->SetWatchdogTimer(0, 0, 0, NULL);
EFI_STATUS Status = 0;
EFI_STATUS status = 0;
/**
* GOP Setup
*/
Status = gBS->LocateProtocol(&gop_guid, NULL, (VOID **)&Gop);
if (EFI_ERROR(Status)) {
Print(u"\r\nERROR: %x; Cannot locate GOP protocol. Return.\r\n", Status);
return Status;
status = gBS->LocateProtocol(&gop_guid, NULL, (VOID **)&Gop);
if (EFI_ERROR(status)) {
Print(u"\r\nERROR: %x; Cannot locate GOP protocol. Return.\r\n", status);
return status;
}
Gop_FrameBufferBase = Gop->Mode->FrameBufferBase;
@ -82,15 +83,6 @@ EFI_STATUS EFIAPI UefiEntry(IN EFI_HANDLE imgHandle, IN EFI_SYSTEM_TABLE* sysTab
UINT16 second, minute, hour;
const UINT32 accentColor = 0xFFAB3F, idleColor = 0x555555;
UINTN EventIndex = 0;
EFI_EVENT Event = NULL;
Status = gBS->CreateEvent(EVT_TIMER, TPL_CALLBACK, (EFI_EVENT_NOTIFY)NULL, (VOID*)NULL, &Event);
Status = gBS->SetTimer(Event, TimerPeriodic, 1e6);
if (EFI_ERROR(Status)) {
Print(u"\r\nERROR: %x; Unable to set timer. Return.\r\n", Status);
return Status;
}
while(1)
{
gRT->GetTime(&Time, NULL);
@ -118,7 +110,7 @@ EFI_STATUS EFIAPI UefiEntry(IN EFI_HANDLE imgHandle, IN EFI_SYSTEM_TABLE* sysTab
hour & 0b01000 ? drawRectangle(col0,row2,sq_sid,sq_sid,accentColor) : drawRectangle(col0,row2,sq_sid,sq_sid,idleColor);
hour & 0b10000 ? drawRectangle(col0,row1,sq_sid,sq_sid,accentColor) : drawRectangle(col0,row1,sq_sid,sq_sid,idleColor);
Status = gBS->WaitForEvent(1, Event, &EventIndex);
MicroSecondDelay(1e6);
}
return EFI_SUCCESS;