commit 28f4ea9de7453cc8cb467b90422405bd35fcc269
parent bdd7e90acee1f048946782373b1a2a3df5046d8b
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sat, 30 Mar 2024 09:57:33 +0900
blue gradation
Diffstat:
3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/kernel.c b/kernel.c
@@ -1,12 +1,22 @@
-typedef unsigned char uint8_t;
+#include "uefi.h"
+
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
// Argument order is to interface to the MS-ABI
void
-kernel_main(void *dummy0, void *dummy1, uint64_t fb_size, uint8_t *fb_base)
+kernel_main(void *dummy0, void *dummy1, void *dummy2,
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
{
- for(int i = 0; i < fb_size; i++) {
- fb_base[i] = i % 0xff;
+ uint32_t *fb_base = (uint8_t *)gop->Mode->FrameBufferBase;
+ uint32_t hrez = gop->Mode->Info->HorizontalResolution;
+ uint32_t vrez = gop->Mode->Info->VerticalResolution;
+ uint32_t sl = gop->Mode->Info->PixelsPerScanLine;
+ for (int i = 0; i < vrez; i++) {
+ for (int j = 0; j < hrez; j++) {
+ fb_base[i * sl + j] = j % 0xff;
+ }
}
for(;;);
}
\ No newline at end of file
diff --git a/loader.c b/loader.c
@@ -114,9 +114,8 @@ EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *systab)
return stat;
}
- typedef void (* Kernel) (UINT8 *fb_base, UINT64 fb_size);
- ((Kernel) kernel_ehdr.entry)(
- (UINT8 *)gop->Mode->FrameBufferBase, gop->Mode->FrameBufferSize);
+ typedef void (* Kernel) (EFI_GRAPHICS_OUTPUT_PROTOCOL *);
+ ((Kernel) kernel_ehdr.entry)(gop);
return EFI_SUCCESS;
}
diff --git a/uefi.h b/uefi.h
@@ -116,7 +116,28 @@ typedef struct {
typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;
+typedef enum {
+ PixelRedGreenBlueReserved8BitPerColor,
+ PixelBlueGreenRedReserved8BitPerColor,
+ PixelBitMask,
+ PixelBltOnly,
+ PixelFormatMax,
+} EFI_GRAPHICS_PIXEL_FORMAT;
+
+typedef struct {
+ UINT32 RedMask;
+ UINT32 GreenMask;
+ UINT32 BlueMask;
+ UINT32 ReservedMask;
+} EFI_PIXEL_BITMASK;
+
typedef struct {
+ UINT32 Version;
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFromat; // This is not fixed in size.
+ EFI_PIXEL_BITMASK PixelInformation;
+ UINT32 PixelsPerScanLine;
} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
typedef struct {