-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
1280 lines (1137 loc) · 54.3 KB
/
main.c
File metadata and controls
1280 lines (1137 loc) · 54.3 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <efi.h>
#include <efilib.h>
#include <libsmbios.h>
#include <stdbool.h>
#include <stdlib.h>
#include "INCLUDE/CryptoAndModuleSigEnforcement/crypto.c"
#include "acpi.h"
#include "Devices/_devices.c"
#include "bugcheck/bugcheck.c"
char* strcpy(char* dest, const char* src) // I suppose VFS needs it
{
char* orig = dest;
while ((*dest++ = *src++));
return orig;
}
#include "VirtualFileSystem/vfs.c"
#include "Memory/memory.c"
UINT32* GOP_public_framebuffer;
UINT32* GOP_public_pitch, GOP_public_height;
void kmain(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t screen_width, uint32_t screen_height);
// For processes
#define MAX_PROCESSES 256
// For legacy console output
#define cls ST->ConOut->ClearScreen(ST->ConOut)
#define printosver Print(L"PINAUK UEFI KERNEL VERSION ALPHA")
#define bluescrcolor ST->ConOut->SetAttribute(ST->ConOut, EFI_WHITE | (EFI_BLUE << 4))
// For font rendering (couldn't find a less appropriate place for it)
#define GLYPH_WIDTH 8
#define GLYPH_HEIGHT 16
#define GLYPHS_PER_ROW 16
#define GLYPHS_PER_COL 16
// Some shit for architectures, no-one will ever compile this kernel for RISC-V 64-bit, heck not even for ARM
#if defined(_M_X64) || defined(__x86_64__)
static CHAR16* ArchName = L"x86 64-bit";
#elif defined(_M_IX86) || defined(__i386__)
static CHAR16* ArchName = L"x86 32-bit";
#elif defined (_M_ARM64) || defined(__aarch64__)
static CHAR16* ArchName = L"ARM 64-bit";
#elif defined (_M_ARM) || defined(__arm__)
static CHAR16* ArchName = L"ARM 32-bit";
#elif defined (_M_RISCV64) || (defined(__riscv) && (__riscv_xlen == 64))
static CHAR16* ArchName = L"RISC-V 64-bit";
// What on Earth is you fucking architecture?
#else
# error Unsupported architecture
#endif
void printstr(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t screen_height, char c[]);
uint32_t currtextx, currtexty = 0;
void test_sha256();
// Why the fuck is it here and not in a custom libc implementation?
char* strtok(char* str, char delim)
{
static char* next = NULL;
if (str != NULL)
{
next = str;
}
if (next == NULL || *next == '\0')
{
return NULL;
}
char* token_start = next;
// Skip over characters until we find the delimiter or end
while (*next != '\0' && *next != delim)
{
next++;
}
// If we stopped at a delimiter, replace it with '\0' and move past it
if (*next == delim)
{
*next = '\0';
next++;
}
return token_start;
}
// WARNING: A VEEEERY GROSS HACK HACK HACK HACK HACK HACK HACK HACK AHEAD
int CharToGlyph(char c)
{
switch (c)
{
case ' ': return 0x0;
case 'A': return 0x1;
case 'B': return 0x2;
case 'C': return 0x3;
case 'D': return 0x4;
case 'E': return 0x5;
case 'F': return 0x6;
case 'G': return 0x7;
case 'H': return 0x8;
case 'I': return 0x9;
case 'J': return 0xA;
case 'K': return 0xB;
case 'L': return 0xC;
case 'M': return 0xD;
case 'N': return 0xE;
case 'O': return 0xF;
case 'P': return 0x10;
case 'Q': return 0x11;
case 'R': return 0x12;
case 'S': return 0x13;
case 'T': return 0x14;
case 'U': return 0x15;
case 'V': return 0x16;
case 'W': return 0x17;
case 'X': return 0x18;
case 'Y': return 0x19;
case 'Z': return 0x1A;
default: return -1;
}
}
// Now, idk is it used or no neither I give it a shit
/// <summary>
/// Gets a string length
/// </summary>
/// <param name="str">ur string</param>
/// <returns>Length of string **MINUS 4**</returns> (I guess minus 4, didn't really test it)
UINTN strlen(const char* str)
{
UINTN len = 0;
while (*str++) len++;
return len;
}
// Basically a soup of everything that belongs here and what doesn't
UINT32 font_glyphs[256][GLYPH_HEIGHT][GLYPH_WIDTH];
void kernel_panic(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t screen_height, const char* errorcode);
int isNeoTermOutCrash = 0;
void createProcess(const char* path);
//void draw_char(UINT32* framebuffer, UINT32 pitch, UINT32 x, UINT32 y, char c);
//void draw_string(UINT32* framebuffer, UINT32 pitch, UINT32 x, UINT32 y, char c[1024]);
void PutChar(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t x, uint32_t y, char c, uint32_t fg, uint32_t bg);
char char_to_vga_index(char c);
void print(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t x, uint32_t y, char c[], uint32_t fg, uint32_t bg);
void neotermout_cls(UINT32* framebuffer, uint32_t width, uint32_t height, uint32_t fg, uint32_t bg); // Fuck it's mostly unused for anything real anyways
int find_free_slot();
// Tri-state status for Secure Boot: -1 = Setup, 0 = Disabled, 1 = Enabled
INTN SecureBootStatus = 0;
void Console();
void ExecCmd(CHAR16 inpbuf[128]);
void PrintEHCIInfo(uintptr_t bar);
// After ExitBootServices
void kinit(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t screen_width, uint32_t screen_height);
#define MOD_MAGIC 0x4D4F4455
typedef struct {
uint32_t magic;
uint32_t version;
uint64_t entry;
uint8_t reserved[48];
} module_header_t;
typedef void (*module_entry_fn)(void);
EFI_STATUS LoadModule(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable, CHAR16* Path) {
EFI_FILE_PROTOCOL* file;
EFI_FILE_PROTOCOL* root;
EFI_LOADED_IMAGE* loadedImage;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs;
uefi_call_wrapper(SystemTable->BootServices->HandleProtocol,
3, ImageHandle, &gEfiLoadedImageProtocolGuid, (void**)&loadedImage);
uefi_call_wrapper(SystemTable->BootServices->HandleProtocol,
3, loadedImage->DeviceHandle, &gEfiSimpleFileSystemProtocolGuid, (void**)&fs);
uefi_call_wrapper(fs->OpenVolume, 2, fs, &root);
uefi_call_wrapper(root->Open, 5, root, &file, Path, EFI_FILE_MODE_READ, 0);
// Read header
module_header_t header;
UINTN headerSize = sizeof(header);
uefi_call_wrapper(file->Read, 3, file, &headerSize, &header);
if (header.magic != MOD_MAGIC || header.version != 1) {
Print(L"Invalid module format.\n");
kernel_panic(GOP_public_framebuffer, GOP_public_pitch, GOP_public_height, "INVALID_KERNEL_MODULE_FORMAT");
for (;;);
return EFI_LOAD_ERROR;
}
// Load rest of module
UINTN moduleSize = 0;
EFI_FILE_INFO* fileInfo;
UINTN infoSize = sizeof(EFI_FILE_INFO) + 200;
uefi_call_wrapper(SystemTable->BootServices->AllocatePool, 3, EfiLoaderData, infoSize, (void**)&fileInfo);
uefi_call_wrapper(file->GetInfo, 4, file, &gEfiFileInfoGuid, &infoSize, fileInfo);
moduleSize = fileInfo->FileSize - sizeof(header);
void* moduleMemory;
uefi_call_wrapper(SystemTable->BootServices->AllocatePages,
4, AllocateAnyPages, EfiLoaderCode, (moduleSize + 0xFFF) / 0x1000, (EFI_PHYSICAL_ADDRESS*)&moduleMemory);
uefi_call_wrapper(file->Read, 3, file, &moduleSize, moduleMemory);
// Get entry point and call it
module_entry_fn entry = (module_entry_fn)((uint8_t*)moduleMemory + header.entry);
Print(L"Calling module...\n");
entry(); // Boom! Module runs.
return EFI_SUCCESS;
}
/*void draw_pixel(UINT32* framebuffer, UINT32 width, UINT32 x, UINT32 y, UINT32 color)
{
framebuffer[y * width + x] = color;
}*/
void KK()
{
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* InputEx;
EFI_GUID SimpleTextInputExProtocolGuid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
char
Status = uefi_call_wrapper(BS->LocateProtocol, 3,
&SimpleTextInputExProtocolGuid,
NULL,
(VOID**)&InputEx);
if (EFI_ERROR(Status))
{
Print(L"Failed to locate SimpleTextInputEx protocol\n"); // Better to make it kernel_panic, but idrk
return Status;
}
}
void draw_pixel(UINT32* framebuffer, UINT32 pitch, UINT32 x, UINT32 y, UINT32 color)
{
framebuffer[y * pitch + x] = color;
}
EFI_FILE_PROTOCOL* load_file(
EFI_HANDLE ImageHandle,
EFI_SYSTEM_TABLE* SystemTable,
CHAR16* path
) {
EFI_LOADED_IMAGE_PROTOCOL* loaded_image = NULL;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs = NULL;
EFI_FILE_PROTOCOL* root = NULL;
EFI_FILE_PROTOCOL* file = NULL;
// Get Loaded Image Protocol
SystemTable->BootServices->HandleProtocol(
ImageHandle,
&gEfiLoadedImageProtocolGuid,
(void**)&loaded_image
);
// Get the file system
SystemTable->BootServices->HandleProtocol(
loaded_image->DeviceHandle,
&gEfiSimpleFileSystemProtocolGuid,
(void**)&fs
);
// Open volume (root dir)
fs->OpenVolume(fs, &root);
// Actually open the file
EFI_STATUS status = root->Open(
root,
&file,
path,
EFI_FILE_MODE_READ,
0
);
if (EFI_ERROR(status)) {
Print(L"Open file failed: %r\n", status);
for (;;);
//kernel_panic("CRITICAL_FILE_NOT_FOUND");
return NULL;
}
return file;
}
static EFI_STATUS PrintSystemInfo(VOID)
{
EFI_STATUS Status;
SMBIOS_STRUCTURE_POINTER Smbios;
SMBIOS_STRUCTURE_TABLE* SmbiosTable;
SMBIOS3_STRUCTURE_TABLE* Smbios3Table;
UINT8 Found = 0, * Raw, * SecureBoot, * SetupMode;
UINTN MaximumSize, ProcessedSize = 0;
Print(L"UEFI v%d.%d (%s, 0x%08X)\n", gST->Hdr.Revision >> 16, gST->Hdr.Revision & 0xFFFF,
gST->FirmwareVendor, gST->FirmwareRevision);
Status = LibGetSystemConfigurationTable(&SMBIOS3TableGuid, (VOID**)&Smbios3Table);
if (Status == EFI_SUCCESS)
{
Smbios.Hdr = (SMBIOS_HEADER*)Smbios3Table->TableAddress;
MaximumSize = (UINTN)Smbios3Table->TableMaximumSize;
}
else
{
Status = LibGetSystemConfigurationTable(&SMBIOSTableGuid, (VOID**)&SmbiosTable);
if (EFI_ERROR(Status))
return EFI_NOT_FOUND;
Smbios.Hdr = (SMBIOS_HEADER*)(UINTN)SmbiosTable->TableAddress;
MaximumSize = (UINTN)SmbiosTable->TableLength;
}
while ((Smbios.Hdr->Type != 0x7F) && (Found < 2))
{
Raw = Smbios.Raw;
if (Smbios.Hdr->Type == 0)
{
Print(L"%a %a\n", LibGetSmbiosString(&Smbios, Smbios.Type0->Vendor),
LibGetSmbiosString(&Smbios, Smbios.Type0->BiosVersion));
Found++;
}
if (Smbios.Hdr->Type == 1)
{
Print(L"%a %a\n", LibGetSmbiosString(&Smbios, Smbios.Type1->Manufacturer),
LibGetSmbiosString(&Smbios, Smbios.Type1->ProductName));
Found++;
}
LibGetSmbiosString(&Smbios, -1);
ProcessedSize += (UINTN)Smbios.Raw - (UINTN)Raw;
if (ProcessedSize > MaximumSize)
{
Print(L"%EAborting system report due to noncompliant SMBIOS%N\n");
return EFI_ABORTED;
}
}
SecureBoot = LibGetVariable(L"SecureBoot", &EfiGlobalVariable);
SetupMode = LibGetVariable(L"SetupMode", &EfiGlobalVariable);
SecureBootStatus = ((SecureBoot != NULL) && (*SecureBoot != 0)) ? 1 : 0;
// You'd expect UEFI platforms to properly clear SetupMode after they
// installed all the certs... but most of them don't. Hence Secure Boot
// disabled having precedence over SetupMode. Looking at you OVMF!
if ((SetupMode != NULL) && (*SetupMode != 0))
SecureBootStatus *= -1;
// Wasteful, but we can't highlight "Enabled"/"Setup" from a %s argument...
if (SecureBootStatus > 0)
Print(L"Secure Boot status: %HEnabled%N\n");
else if (SecureBootStatus < 0)
Print(L"Secure Boot status: %ESetup%N\n");
else
Print(L"Secure Boot status: Disabled\n");
return EFI_SUCCESS;
}
#pragma pack(push, 1)
typedef struct
{
UINT8 signature[2]; // 'B' 'M'
UINT32 fileSize;
UINT32 reserved;
UINT32 dataOffset;
UINT32 headerSize;
INT32 width;
INT32 height;
UINT16 planes;
UINT16 bpp;
UINT32 compression;
UINT32 imageSize;
INT32 xPelsPerMeter;
INT32 yPelsPerMeter;
UINT32 colorsUsed;
UINT32 importantColors;
} BMPHeader;
#pragma pack(pop)
EFI_SIMPLE_POINTER_PROTOCOL* mouse; // Fuck it's unused as of 15.05.2025 anyways
#define SLP_TYP5 (5 << 10)
#define SLP_EN (1 << 13)
extern void outw(unsigned short port, unsigned short value);
void shutdown_system(EFI_SYSTEM_TABLE* SystemTable) {
// 1. Find RSDP in UEFI ConfigurationTable
RSDPDescriptor20* rsdp = NULL;
EFI_GUID acpi2_guid = ACPI_20_TABLE_GUID;
EFI_GUID acpi1_guid = ACPI_TABLE_GUID;
for (UINTN i = 0; i < SystemTable->NumberOfTableEntries; i++) {
EFI_CONFIGURATION_TABLE* table = &SystemTable->ConfigurationTable[i];
if (CompareGuid(&table->VendorGuid, &acpi2_guid) || CompareGuid(&table->VendorGuid, &acpi1_guid)) {
rsdp = (RSDPDescriptor20*)table->VendorTable;
break;
}
}
if (!rsdp) {
Print(L"RSDP not found.\n");
return;
}
// 2. Get XSDT and parse entries
XSDT* xsdt = (XSDT*)(uintptr_t)(rsdp->XsdtAddress);
UINTN entries = (xsdt->Header.Length - sizeof(ACPISDTHeader)) / sizeof(uint64_t);
FADT* fadt = NULL;
for (UINTN i = 0; i < entries; i++) {
ACPISDTHeader* hdr = (ACPISDTHeader*)(uintptr_t)(xsdt->Entries[i]);
if (hdr->Signature[0] == 'F' && hdr->Signature[1] == 'A' &&
hdr->Signature[2] == 'C' && hdr->Signature[3] == 'P') {
fadt = (FADT*)hdr;
break;
}
}
if (!fadt) {
Print(L"FADT not found.\n");
return;
}
// 3. Write shutdown command
uint16_t pm1a = fadt->PM1a_CNT_BLK;
if (!pm1a) {
Print(L"PM1a_CNT_BLK not defined.\n");
return;
}
// Use inline assembly to write to I/O port
uint16_t shutdown_val = SLP_TYP5 | SLP_EN;
Print(L"Shutting down...");
outw((uint16_t)fadt->PM1a_CNT_BLK, shutdown_val);
Print(L"Shutting down via ACPI didn't work for some reason, resorting to QEMU-specific way");
outw(0x604, 0x2000); // QEMU ACPI shutdown
// Halt fallback
Print(L"Shutting down didn't work, halting...");
for (;;) __halt();
}
// Application entrypoint (must be set to 'efi_main' for gnu-efi crt0 compatibility)
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
UINTN Event;
#if defined(_GNU_EFI)
InitializeLib(ImageHandle, SystemTable);
#endif
cls;
PrintSystemInfo();
bluescrcolor;
ST->ConOut->OutputString(ST->ConOut, L"Hello with new text color!\r\n");
cls;
printosver;
Print(L"\nRunning on a CPU architecture: %s", ArchName);
Print(L"\n");
// Disable the watchdog timer so that the PC doesn't reboot in 5 minutes
gBS->SetWatchdogTimer(0, 0, 0, NULL);
Print(L"Disabled the watchdog timer\n");
// Time to init gfx!
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
EFI_GUID gopGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_STATUS status = uefi_call_wrapper(BS->LocateProtocol, 3, &gopGuid, NULL, (void**)&gop);
if (status == EFI_SUCCESS)
{
Print(L"GOP initialization succeeded!\n");
}
else if (status != EFI_SUCCESS)
{
Print(L"\nGOP initialization failed!\n");
//kernel_panic("GOP_INIT_FAILED");
while (1 == 1) // Why is it here? kernel_panic already loops infinitely
{
}
}
//UINT32* framebuffer = (UINT32*)gop->Mode->FrameBufferBase; // Fucking why commenting it out
UINT32* framebuffer = (UINT32*)gop->Mode->FrameBufferBase; // and writing it on the next line?
GOP_public_framebuffer = framebuffer; // Make it (semi) publically available
Print(L"Set the GOP framebuffer\n");
//UINT32 width = gop->Mode->Info->HorizontalResolution; // ???
UINT32 pitch = gop->Mode->Info->PixelsPerScanLine;
GOP_public_pitch = pitch;
Print(L"Set the GOP width\n"); // ik it's pitch, but i don't really give it a fuck
UINT32 height = gop->Mode->Info->VerticalResolution;
GOP_public_height = height;
Print(L"Set the GOP height\n");
Print(L"Screen resolution is: %d x %d", pitch, height);
Print(L"\n");
EFI_FILE_PROTOCOL* file = load_file(ImageHandle, SystemTable, L"\\syslogo.bmp");
if (file == NULL)
{
Print(L"Failed to open syslogo.bmp\n");
while (1 == 1) // Why not kernel_panic?
{
}
//return EFI_NOT_FOUND;
}
#pragma pack(push, 1)
typedef struct
{
UINT16 signature; // Should be 'BM'
UINT32 file_size;
UINT32 reserved;
UINT32 pixel_array_offset;
} BMPHeader;
typedef struct
{
UINT32 header_size;
INT32 width;
INT32 height;
UINT16 planes;
UINT16 bits_per_pixel;
UINT32 compression;
UINT32 image_size;
// ... we can add more later if we ever need to, but why??????
} DIBHeader;
#pragma pack(pop)
BMPHeader bmp_header;
DIBHeader dib_header;
UINTN size = sizeof(BMPHeader);
file->SetPosition(file, 0);
file->Read(file, &size, &bmp_header);
if (bmp_header.signature != 0x4D42)
{
Print(L"Not a BMP file\n");
return EFI_ABORTED;
}
size = sizeof(DIBHeader);
file->Read(file, &size, &dib_header);
Print(L"BMP Size: %dx%d, %d bpp\n", dib_header.width, dib_header.height, dib_header.bits_per_pixel);
UINT32 pixel_data_offset = bmp_header.pixel_array_offset;
UINT32 image_width = dib_header.width;
UINT32 image_height = dib_header.height;
UINT16 bpp = dib_header.bits_per_pixel;
if (bpp != 24)
{
Print(L"Only 24bpp BMPs are supported.\n");
kernel_panic(framebuffer, pitch, height, "BMP_NOT_24BIT");
return EFI_ABORTED; // Again, why not kernel_panic?
}
// Each row is padded to 4-byte boundary
UINT32 row_size = (image_width * 3 + 3) & ~3;
UINT32 image_data_size = row_size * image_height;
UINT8* pixel_data = AllocatePool(image_data_size);
if (!pixel_data)
{
Print(L"Out of memory\n");
kernel_panic(framebuffer, pitch, height, "BMP_LOAD_OUT_OF_MEMORY");
return EFI_ABORTED; // Why not fucking kernel panic???
}
// Read pixel data
file->SetPosition(file, pixel_data_offset);
UINTN read_size = image_data_size;
file->Read(file, &read_size, pixel_data);
UINT32 scale = 8;
scale = pitch / image_width;
UINT32 scaled_width = image_width * scale;
UINT32 scaled_height = image_height * scale;
UINT32 offset_x = (pitch - scaled_width) / 2;
UINT32 offset_y = (height - scaled_height) / 2;
for (UINT32 y = 0; y < image_height; y++)
{
for (UINT32 x = 0; x < image_width; x++)
{
UINT32 row = image_height - 1 - y; // Turn it upside-down (BMPs are upside-down)
UINT8* pixel = pixel_data + row * row_size + x * 3;
UINT8 blue = pixel[0];
UINT8 green = pixel[1];
UINT8 red = pixel[2];
UINT32 color = (red << 16) | (green << 8) | blue;
// Draw a scale×scale block per source pixel (for integer scaling)
for (UINT32 dy = 0; dy < scale; dy++)
{
for (UINT32 dx = 0; dx < scale; dx++)
{
draw_pixel(framebuffer, pitch, offset_x + x * scale + dx,
offset_y + y * scale + dy,
color);
}
}
}
}
KK();
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* InputEx;
EFI_GUID SimpleTextInputExProtocolGuid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
char
Status = uefi_call_wrapper(BS->LocateProtocol, 3,
&SimpleTextInputExProtocolGuid,
NULL,
(VOID**)&InputEx);
if (EFI_ERROR(Status))
{
Print(L"Failed to locate SimpleTextInputEx protocol\n");
kernel_panic(framebuffer, pitch, height, "SIMPLE_TEXT_INPUT_EX_LOCATION_FAILED");
return Status;
}
gBS->Stall(10);
UINTN memoryMapSize = 0;
UINTN extraPadding = 8192;
EFI_MEMORY_DESCRIPTOR* memoryMap = NULL;
UINTN mapKey;
UINTN descriptorSize;
UINT32 descriptorVersion;
neotermout_cls(framebuffer, pitch, height, 0xFFFFFFFF, 0x00000098);
print(framebuffer, pitch, 0, 0, "NEOTERMOUT(TM)", 0xFFFFFFFF, 0x00000098);
print(framebuffer, pitch, 0, 16, "THIS MESSAGE CONFIRMS THAT THE NEW TERMINAL OUTPUT", 0xFFFFFFFF, 0x00000098);
print(framebuffer, pitch, 0, 32, "IS INDEED WORKING CORRECTLY", 0xFFFFFFFF, 0x00000098);
test_sha256();
Print(L"\n");
// Do the malloc init (yeah, at the last moment possible)
pmm_init_args_t pmm_args;
boot_info_t boot_info;
boot_info.desc_size = sizeof(EFI_MEMORY_DESCRIPTOR);
boot_info.desc_ver = descriptorVersion;
boot_info.fb_pa = (EFI_PHYSICAL_ADDRESS)framebuffer; // Physical address of framebuffer
boot_info.fb_size = pitch * height * sizeof(UINT32); // Size of framebuffer in bytes
boot_info.kernel_start_pa = (EFI_PHYSICAL_ADDRESS)ImageHandle; // Physical address of kernel start
boot_info.kernel_end_pa = (EFI_PHYSICAL_ADDRESS)ImageHandle + 0x100000; // Physical address of kernel end, just a guess
boot_info.mmap = memoryMap; // Memory map pointer
boot_info.mmap_size = sizeof(memoryMap); // Memory map size in bytes
pmm_args.bi = boot_info; // Boot info pointer
pmm_init(&pmm_args); // Initialize the physical memory manager
// Umm... I guess that's it?
Print(L"pmm_init");
// First call to get the required buffer size
gBS->GetMemoryMap(&memoryMapSize, memoryMap, &mapKey, &descriptorSize, &descriptorVersion);
//Print(L"Memory map size: %d bytes\n", memoryMapSize);
// Allocate the memory map buffer (add extra room just in case)
memoryMap = AllocatePool(memoryMapSize + extraPadding);
//Print(L"Allocated memory map buffer at %p\n", memoryMap);
// Call again to actually get the memory map
gBS->GetMemoryMap(&memoryMapSize, memoryMap, &mapKey, &descriptorSize, &descriptorVersion);
//Print(L"Got memory map with %d descriptors\n", memoryMapSize / descriptorSize);
// Finally, exit boot services
status = gBS->ExitBootServices(ImageHandle, mapKey);
//Print(L"ExitBootServices status: %r\n", status); // You won't see me if it was successful, but whatever
if (EFI_ERROR(status)) {
// Memory map likely changed
kernel_panic(GOP_public_framebuffer, GOP_public_pitch, GOP_public_height, "EXITBOOTSERVICES_MEMORYMAP_LIKELY_CHANGED");
}
kinit(framebuffer, pitch, pitch, height);
}
/*#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/PrintLib.h>*/
void PrintEHCIInfo(uintptr_t bar) {
volatile uint8_t* mmio = (volatile uint8_t*)bar;
uint8_t caplength = mmio[0x00];
uint16_t hciversion = *(volatile uint16_t*)(mmio + 0x02);
Print(L"EHCI CAPLENGTH: 0x%02x\n", caplength);
Print(L"EHCI HCIVERSION: 0x%04x\n", hciversion);
// Optional: decode version
UINT8 major = (hciversion >> 8) & 0xFF;
UINT8 minor = hciversion & 0xFF;
Print(L"EHCI Version: %d.%d\n", major, minor);
}
static void print_hash_utf16(const uint8_t* hash)
{
const CHAR16 hex[] = u"0123456789abcdef";
CHAR16 buf[65]; // 64 hex chars + null terminator
for (int i = 0; i < 32; ++i) {
buf[i * 2] = hex[hash[i] >> 4];
buf[i * 2 + 1] = hex[hash[i] & 0xF];
}
buf[64] = 0; // null terminator
Print("\n");
Print(buf); // Or whatever outputs CHAR16*
}
void test_sha256()
{
const char* msg = "abc"; // still ASCII here
uint8_t hash[32];
sha256_compute((const uint8_t*)msg, strlen(msg), hash);
print_hash_utf16(hash); // now prints it as CHAR16 string
}
void shell_echo(char* argv[])
{
int i = 0;
while (argv[i] != NULL) {
Print(L"%c ", argv[i]);
++i;
}
Print(L"\n");
}
void ExecEcho(CHAR16 wholeCommand[])
{
char out[128];
for (int i = 0; i < 127 && wholeCommand[i] != 0; i++) {
out[i] = (char)wholeCommand[i];
out[i + 1] = '\0';
}
// Tokenize out into argv[]
char* argv[10];
int argc = 0;
char* token = strtok(out, " ");
while (token && argc < 10) {
argv[argc++] = token;
token = strtok(NULL, " ");
}
argv[argc] = NULL; // Null-terminate
if (argc > 1) {
shell_echo(&argv[1]); // Skip "echo"
}
}
/*void ExecCmd(CHAR16* input)
{
CHAR16* command = StrDuplicate(input); // Make a mutable copy
CHAR16* token;
CHAR16* next_token;
CHAR16* args[10];
int arg_count = 0;
for (token = strtok(/*command,*//* L" ", & next_token);
token != NULL && arg_count < 10;
token = strtok(/*NULL,*/ /*L" ", & next_token))
{
args[arg_count++] = token;
}
if (/*arg_count >= 1 && StrCmp(args[0], "ECHO"*/
/*args[0] == (short)"echo")
{
ExecEcho(input); // Or pass args
}
else
{
Print(L"\nCommand not found: ", args[0]);
}
FreePool(command); // if StrDuplicate used AllocatePool
// Wait, I may've found the issue now
}*/
#include <intrin.h>
void ClearScreen(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t screen_height, uint32_t clear_color)
{
for (uint32_t y = 0; y < screen_height; ++y)
{
for (uint32_t x = 0; x < pixels_per_scanline; ++x)
{
framebuffer_base[y * pixels_per_scanline + x] = clear_color;
}
}
}
void kernel_panic(UINT32* framebuffer_base, uint32_t pixels_per_scanline, uint32_t screen_height, const char* errorcode)
{
// Clear screen (optional)
//for (uint32_t y = 0; y < screen_height; ++y)
//{
// for (uint32_t x = 0; x < pixels_per_scanline; ++x)
// {
// framebuffer_base[y * pixels_per_scanline + x] = 0xFF0000; // Bright red background
// }
//}
ClearScreen(framebuffer_base, pixels_per_scanline, screen_height, 0x00000098);
currtextx = 0;
currtexty = 0;
// All caps because I think I commented out the small letters glyphs
printstr(framebuffer_base, pixels_per_scanline, screen_height, "*** KERNEL PANIC ***");
currtextx = 0; // Nasty hack to reset the text cursor position
printstr(framebuffer_base, pixels_per_scanline, screen_height, "ERROR: ");
currtextx = 0; // Nasty hack to reset the text cursor position
printstr(framebuffer_base, pixels_per_scanline, screen_height, errorcode);
currtextx = 0; // Nasty hack to reset the text cursor position
printstr(framebuffer_base, pixels_per_scanline, screen_height, "SYSTEM HALTED.");
currtextx = 0; // Nasty hack to reset the text cursor position
printstr(framebuffer_base, pixels_per_scanline, screen_height, "DO NOT TRY TO REPORT THIS TO THE DEV, THEY WON'T FIX IT ANYWAYS");
currtextx = 0; // Nasty hack to reset the text cursor position
printstr(framebuffer_base, pixels_per_scanline, screen_height, "PLUS IT WORKED FINE ON MY MACHINE LMAO");
currtextx = 0; // Nasty hack to reset the text cursor position (if you still didn't get it from the prevoius six comments)
printstr(framebuffer_base, pixels_per_scanline, screen_height, "seriously what'd u do"); // No-one will see it since I commented out the small letters glyphs, but whatever
// Ehh whatever, it works now, and it is not corrupted YAHOOOOOOOOOOOOOOOOO!
// Lol the code is more comments than actual code
// Halt the CPU
while (1)
{
//__halt();
//printstr(framebuffer_base, pixels_per_scanline, screen_height, "If you see me then the CPU isn't halted");
// OK, it's not halted, and the output is also corrupted. Ehh, whatever, the OS is still for stooooooopid users who can't read error codes,
// they will just scream and blame me for "NoT mAkInG mY oS wOrK pRoPeRlY",
}
}
uint8_t vgafont16[256 * 16] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00,
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xdb, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xc3, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc1, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00,
0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00,
0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xff, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00,
0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x3b, 0x1b, 0x7e, 0xd8, 0xdc, 0x77, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00,
0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x18, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0xfc, 0x66, 0x66, 0x7c, 0x62, 0x66, 0x6f, 0x66, 0x66, 0x66, 0xf3, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00,
0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x9b, 0x06, 0x0c, 0x1f, 0x00, 0x00,
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x96, 0x3e, 0x06, 0x06, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44,
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,