fix on real hardware
This commit is contained in:
parent
24edc2599b
commit
f2ad30047a
@ -24,12 +24,12 @@ RegisterFilterLib|edk2/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNul
|
|||||||
StackCheckLib|edk2/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
|
StackCheckLib|edk2/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
|
||||||
IoLib|edk2/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
IoLib|edk2/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||||
RngLib|edk2/MdePkg/Library/BaseRngLib/BaseRngLib.inf
|
RngLib|edk2/MdePkg/Library/BaseRngLib/BaseRngLib.inf
|
||||||
SerialPortLib|edk2/UefiPayloadPkg/Library/BaseSerialPortLibHob/BaseSerialPortLibHob.inf
|
SerialPortLib|edk2/MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
|
||||||
TimerLib|edk2/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
|
|
||||||
PciLib|edk2/MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
|
|
||||||
HobLib|edk2/MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
|
||||||
PciCf8Lib|edk2/MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
|
|
||||||
DebugPrintErrorLevelLib|edk2/MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
|
DebugPrintErrorLevelLib|edk2/MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
|
||||||
|
LocalApicLib|edk2/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
|
||||||
|
CpuLib|edk2/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
|
||||||
|
UefiRuntimeServicesTableLib|edk2/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
|
||||||
|
TimerLib|edk2/MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
|
||||||
|
|
||||||
[Components]
|
[Components]
|
||||||
src/UEFI_fireworks/UEFI_fireworks.inf
|
src/UEFI_fireworks/UEFI_fireworks.inf
|
||||||
|
3
build.sh
3
build.sh
@ -5,5 +5,6 @@ if [ "$1" == "debug" ]; then
|
|||||||
else
|
else
|
||||||
build -a X64 -t GCC5 -p UEFI_fireworks.dsc
|
build -a X64 -t GCC5 -p UEFI_fireworks.dsc
|
||||||
fi
|
fi
|
||||||
mkdir -p build
|
mkdir -p build/EFI/BOOT/
|
||||||
cp edk2/Build/UEFI_fireworks/DEBUG_GCC5/X64/UEFI_fireworks.efi build/
|
cp edk2/Build/UEFI_fireworks/DEBUG_GCC5/X64/UEFI_fireworks.efi build/
|
||||||
|
cp edk2/Build/UEFI_fireworks/DEBUG_GCC5/X64/UEFI_fireworks.efi build/EFI/BOOT/BOOTX64.EFI
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
UefiMain.c
|
UefiMain.c
|
||||||
drawing.c
|
drawing.c
|
||||||
rng.c
|
rng.c
|
||||||
|
time.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
edk2/MdePkg/MdePkg.dec
|
edk2/MdePkg/MdePkg.dec
|
||||||
@ -28,6 +29,7 @@
|
|||||||
TimerLib
|
TimerLib
|
||||||
RngLib
|
RngLib
|
||||||
SerialPortLib
|
SerialPortLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiRngProtocolGuid
|
gEfiRngProtocolGuid
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
|
#include "time.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
@ -11,9 +12,9 @@
|
|||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/RngLib.h>
|
#include <Library/RngLib.h>
|
||||||
#include <Library/SerialPortLib.h>
|
#include <Library/SerialPortLib.h>
|
||||||
#include <Library/TimerLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
#include <Protocol/GraphicsOutput.h>
|
#include <Protocol/GraphicsOutput.h>
|
||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -24,9 +25,11 @@ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *framebuffer = NULL;
|
|||||||
|
|
||||||
EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
|
EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
|
||||||
IN EFI_SYSTEM_TABLE *sysTable) {
|
IN EFI_SYSTEM_TABLE *sysTable) {
|
||||||
|
Print(L"Starting program\n");
|
||||||
gST = sysTable;
|
gST = sysTable;
|
||||||
gBS = sysTable->BootServices;
|
gBS = sysTable->BootServices;
|
||||||
gImageHandle = imgHandle;
|
gImageHandle = imgHandle;
|
||||||
|
gRT = sysTable->RuntimeServices;
|
||||||
|
|
||||||
// UEFI apps automatically exit after 5 minutes. Stop that here
|
// UEFI apps automatically exit after 5 minutes. Stop that here
|
||||||
gBS->SetWatchdogTimer(0, 0, 0, NULL);
|
gBS->SetWatchdogTimer(0, 0, 0, NULL);
|
||||||
@ -40,6 +43,11 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
|
|||||||
gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL,
|
gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL,
|
||||||
(VOID **)&GraphicsOutput);
|
(VOID **)&GraphicsOutput);
|
||||||
|
|
||||||
|
if (GraphicsOutput == NULL) {
|
||||||
|
Print(L"GraphicsOutput protocol not found!\n");
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
framebuffer =
|
framebuffer =
|
||||||
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GraphicsOutput->Mode->FrameBufferBase;
|
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GraphicsOutput->Mode->FrameBufferBase;
|
||||||
|
|
||||||
@ -58,9 +66,9 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
|
|||||||
gBS->SetMem(firework_array, sizeof(firework_array),
|
gBS->SetMem(firework_array, sizeof(firework_array),
|
||||||
0); // make all pointers null
|
0); // make all pointers null
|
||||||
|
|
||||||
SERIAL_PRINT("DOES it work?");
|
SERIAL_PRINT("DOES it work?\n");
|
||||||
Print(L"If you see this message timer does not work\n");
|
Print(L"If you see this message timer does not work\n");
|
||||||
MicroSecondDelay(1000);
|
milisleep(100);
|
||||||
clear_screen();
|
clear_screen();
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -86,7 +94,7 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
|
|||||||
goto assgned;
|
goto assgned;
|
||||||
} // firework will not be created if if all slots are full
|
} // firework will not be created if if all slots are full
|
||||||
}
|
}
|
||||||
Print(L"NO free slots\n");
|
SERIAL_PRINT("NO free slots\n");
|
||||||
}
|
}
|
||||||
assgned:
|
assgned:
|
||||||
for (UINT8 i = 0; i < ARRAY_SIZE(firework_array); i++) {
|
for (UINT8 i = 0; i < ARRAY_SIZE(firework_array); i++) {
|
||||||
@ -102,7 +110,7 @@ EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imgHandle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MicroSecondDelay(100000);
|
milisleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "Library/UefiBootServicesTableLib.h"
|
#include "Library/UefiBootServicesTableLib.h"
|
||||||
#include "Library/UefiLib.h"
|
#include "Library/UefiLib.h"
|
||||||
#include "ProcessorBind.h"
|
#include "ProcessorBind.h"
|
||||||
|
#include "time.h"
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/RngLib.h>
|
#include <Library/RngLib.h>
|
||||||
#include <Library/TimerLib.h>
|
#include <Library/TimerLib.h>
|
||||||
@ -63,7 +64,7 @@ void init_rng() {
|
|||||||
Print(L"Continuing in ");
|
Print(L"Continuing in ");
|
||||||
for (UINT8 i = 5; i > 0; i--) {
|
for (UINT8 i = 5; i > 0; i--) {
|
||||||
Print(L"\b%d", i);
|
Print(L"\b%d", i);
|
||||||
MicroSecondDelay(1000000);
|
milisleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_random_bytes = fill_random_bytes_LFSR;
|
fill_random_bytes = fill_random_bytes_LFSR;
|
||||||
|
24
src/UEFI_fireworks/time.c
Normal file
24
src/UEFI_fireworks/time.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "Library/UefiLib.h"
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
EFI_STATUS
|
||||||
|
milisleep(UINTN Milliseconds) {
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_EVENT TimerEvent;
|
||||||
|
|
||||||
|
Status =
|
||||||
|
gBS->CreateEvent(EVT_TIMER, TPL_APPLICATION, NULL, NULL, &TimerEvent);
|
||||||
|
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->SetTimer(TimerEvent, TimerRelative,
|
||||||
|
EFI_TIMER_PERIOD_MILLISECONDS(Milliseconds));
|
||||||
|
|
||||||
|
if (!EFI_ERROR(Status)) {
|
||||||
|
gBS->WaitForEvent(1, &TimerEvent, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gBS->CloseEvent(TimerEvent);
|
||||||
|
return Status;
|
||||||
|
}
|
2
src/UEFI_fireworks/time.h
Normal file
2
src/UEFI_fireworks/time.h
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
void milisleep(UINTN Milliseconds);
|
Loading…
x
Reference in New Issue
Block a user