Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
f3c0a1dce1 | |||
78d8415c89 | |||
f511cbc772 | |||
4e9b249e4e | |||
09fe36f93d | |||
f7033c98ce | |||
33cab69699 | |||
0153d22634 | |||
88802e6ab6 | |||
93c231bc98 | |||
b9fc55835e | |||
48ce3f1f11 |
6 changed files with 238 additions and 13 deletions
|
@ -23,12 +23,20 @@ steps:
|
||||||
- . edk2/edksetup.sh
|
- . edk2/edksetup.sh
|
||||||
- make -C edk2/BaseTools
|
- make -C edk2/BaseTools
|
||||||
|
|
||||||
- echo "Copying application files"
|
- echo "Copying EfiClock application files"
|
||||||
- mkdir edk2/EfiClock
|
- mkdir edk2/EfiClock
|
||||||
- cp EfiClock.inf edk2/EfiClock/. && rm EfiClock.inf
|
- cp EfiClock/EfiClock.inf edk2/EfiClock/.
|
||||||
- cp UefiMain.c edk2/EfiClock/. && rm UefiMain.c
|
- cp EfiClock/UefiMain.c edk2/EfiClock/.
|
||||||
|
- rm -rf EfiClock
|
||||||
- sed -i '/\[Components\]/a EfiClock/EfiClock.inf' edk2/MdeModulePkg/MdeModulePkg.dsc
|
- 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"
|
- echo "Building application"
|
||||||
- build -a X64 -t GCC -p MdeModulePkg/MdeModulePkg.dsc
|
- build -a X64 -t GCC -p MdeModulePkg/MdeModulePkg.dsc
|
||||||
|
|
||||||
|
@ -43,3 +51,4 @@ steps:
|
||||||
target: main
|
target: main
|
||||||
files:
|
files:
|
||||||
- Build/MdeModule/DEBUG_GCC/X64/EfiClock.efi
|
- Build/MdeModule/DEBUG_GCC/X64/EfiClock.efi
|
||||||
|
- Build/MdeModule/DEBUG_GCC/X64/EfiTicTacToe.efi
|
|
@ -29,21 +29,20 @@ 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)
|
EFI_STATUS EFIAPI UefiEntry(IN EFI_HANDLE imgHandle, IN EFI_SYSTEM_TABLE* sysTable)
|
||||||
{
|
{
|
||||||
gST = sysTable;
|
gST = sysTable;
|
||||||
gBS = sysTable->BootServices;
|
gBS = gST->BootServices;
|
||||||
gImageHandle = imgHandle;
|
|
||||||
|
|
||||||
gBS->SetWatchdogTimer(0, 0, 0, NULL);
|
gBS->SetWatchdogTimer(0, 0, 0, NULL);
|
||||||
|
|
||||||
EFI_STATUS status = 0;
|
EFI_STATUS Status = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GOP Setup
|
* GOP Setup
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status = gBS->LocateProtocol(&gop_guid, NULL, (VOID **)&Gop);
|
Status = gBS->LocateProtocol(&gop_guid, NULL, (VOID **)&Gop);
|
||||||
if (EFI_ERROR(status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
Print(u"\r\nERROR: %x; Cannot locate GOP protocol. Return.\r\n", status);
|
Print(u"\r\nERROR: %x; Cannot locate GOP protocol. Return.\r\n", Status);
|
||||||
return status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gop_FrameBufferBase = Gop->Mode->FrameBufferBase;
|
Gop_FrameBufferBase = Gop->Mode->FrameBufferBase;
|
||||||
|
@ -83,6 +82,15 @@ EFI_STATUS EFIAPI UefiEntry(IN EFI_HANDLE imgHandle, IN EFI_SYSTEM_TABLE* sysTab
|
||||||
UINT16 second, minute, hour;
|
UINT16 second, minute, hour;
|
||||||
const UINT32 accentColor = 0xFFAB3F, idleColor = 0x555555;
|
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)
|
while(1)
|
||||||
{
|
{
|
||||||
gRT->GetTime(&Time, NULL);
|
gRT->GetTime(&Time, NULL);
|
||||||
|
@ -110,7 +118,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 & 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);
|
hour & 0b10000 ? drawRectangle(col0,row1,sq_sid,sq_sid,accentColor) : drawRectangle(col0,row1,sq_sid,sq_sid,idleColor);
|
||||||
|
|
||||||
MicroSecondDelay(1e6);
|
Status = gBS->WaitForEvent(1, Event, &EventIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
27
EfiTicTacToe/EfiTicTacToe.inf
Normal file
27
EfiTicTacToe/EfiTicTacToe.inf
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
[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]
|
181
EfiTicTacToe/UefiMain.c
Normal file
181
EfiTicTacToe/UefiMain.c
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
#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;
|
||||||
|
}
|
|
@ -11,6 +11,6 @@ The following functionalities are used:
|
||||||
|
|
||||||
## Pipeline
|
## Pipeline
|
||||||
|
|
||||||
[![status-badge](https://ci.slowte.ch/api/badges/9/status.svg)](https://ci.slowte.ch/repos/9)
|
[![status-badge](https://ci.slowte.ch/api/badges/12/status.svg)](https://ci.slowte.ch/repos/12)
|
||||||
|
|
||||||
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).
|
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).
|
Loading…
Reference in a new issue