-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
67 lines (43 loc) · 1.95 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <efi.h>
#include <efilib.h>
#include "modes.h"
#include "foo.h"
extern EFI_GUID GraphicsOutputProtocol;
EFI_STATUS
EFIAPI
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_INPUT_KEY efi_input_key;
int a = 10, b = 20;
InitializeLib(ImageHandle, SystemTable);
//Print(L"Hello, world!\n");
terra_main(L"Hello, Terra from C!\n");
Print(L"%d + %d = %d\n", a, b, terra_add(a,b));
Print(L"%s\n", SystemTable->FirmwareVendor);
EFI_STATUS status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
status = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&gop);
if(EFI_ERROR(status))
return status;
status = uefi_call_wrapper(SystemTable->BootServices->LocateProtocol, 3, &GraphicsOutputProtocol, NULL, &gop);
Print(L"Framebuffer base is at %lx\n", gop->Mode->FrameBufferBase);
print_modes(gop);
Print(L"\n\n\nHit any key\n");
WaitForSingleEvent(SystemTable->ConIn->WaitForKey, 0);
status = uefi_call_wrapper(SystemTable->ConIn->ReadKeyStroke, 2, SystemTable->ConIn, &efi_input_key);
paint_screen(gop, (UINT32)0x00FF0000);
uefi_call_wrapper(BS->Stall, 1, 2 * 1000 * 1000);
paint_screen(gop, (UINT32)0x0000FF00);
uefi_call_wrapper(BS->Stall, 1, 2 * 1000 * 1000);
paint_screen(gop, (UINT32)0x000000FF0);
uefi_call_wrapper(BS->Stall, 1, 2 * 1000 * 1000);
// FROM: https://github.com/vathpela/gnu-efi/blob/master/apps/t7.c
Print(L"\n\n\nHit any key to exit this image\n");
WaitForSingleEvent(SystemTable->ConIn->WaitForKey, 0);
uefi_call_wrapper(SystemTable->ConOut->OutputString, 2, SystemTable->ConOut, L"\n\n");
status = uefi_call_wrapper(SystemTable->ConIn->ReadKeyStroke, 2, SystemTable->ConIn, &efi_input_key);
Print(L"ScanCode: %xh UnicodeChar: %xh\n", efi_input_key.ScanCode, efi_input_key.UnicodeChar);
WaitForSingleEvent(SystemTable->ConIn->WaitForKey, 0);
status = uefi_call_wrapper(SystemTable->ConIn->ReadKeyStroke, 2, SystemTable->ConIn, &efi_input_key);
return EFI_SUCCESS;
}