diff --git a/.clang-format b/.clang-format index fd3032c..353a103 100644 --- a/.clang-format +++ b/.clang-format @@ -1,8 +1,8 @@ AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: AcrossComments -AlignConsecutiveDeclarations: AcrossComments -AlignConsecutiveBitFields: AcrossComments -AlignConsecutiveMacros: AcrossComments +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: false +AlignConsecutiveBitFields: true +AlignConsecutiveMacros: true AlignArrayOfStructures: Right AlignEscapedNewlines: Left AlignOperands: AlignAfterOperator @@ -30,7 +30,7 @@ BreakBeforeTernaryOperators: false BreakAfterJavaFieldAnnotations: true BreakStringLiterals: false -ColumnLimit: 120 +ColumnLimit: 100 ContinuationIndentWidth: 4 IncludeBlocks: Regroup diff --git a/arch/aarch64/fb.c b/arch/aarch64/fb.c index 98f631d..755adb0 100644 --- a/arch/aarch64/fb.c +++ b/arch/aarch64/fb.c @@ -28,7 +28,7 @@ * can be passed via the mailbox */ volatile unsigned int __attribute__((aligned(16))) mbox[36]; -unsigned int width, height, pitch, bpp, rgb; +unsigned int width, height, pitch, bpp, rgb; unsigned char *fb; void pixel_draw(int x, int y, int r, int g, int b) { @@ -38,7 +38,8 @@ void pixel_draw(int x, int y, int r, int g, int b) { } unsigned int mbox_call(unsigned char ch) { - unsigned int m = ((unsigned int)((long)&mbox) & ~0xF) | (ch & 0xF); /* 28-bit address (MSB), 4-bit value (LSB) */ + unsigned int m = ((unsigned int)((long)&mbox) & ~0xF) + | (ch & 0xF); /* 28-bit address (MSB), 4-bit value (LSB) */ while (1) if (!(mmio_read(MBOX_STATUS) & MBOX_FULL)) diff --git a/arch/aarch64/fdt.c b/arch/aarch64/fdt.c index 6535fee..748b7eb 100644 --- a/arch/aarch64/fdt.c +++ b/arch/aarch64/fdt.c @@ -32,15 +32,15 @@ fdt_prop fdt_get_prop(uint32_t *addr) { } uint32_t *fdt_get_addr(const char *path) { - const char *fdt_strings = (char *)fdt + SWAP_UINT32(fdt->off_dt_strings); - uint32_t *fdt_struct = (uint32_t *)fdt + SWAP_UINT32(fdt->off_dt_struct); + const char *fdt_strings = (char *)fdt + SWAP_UINT32(fdt->off_dt_strings); + uint32_t *fdt_struct = (uint32_t *)fdt + SWAP_UINT32(fdt->off_dt_struct); const uint32_t struct_size = SWAP_UINT32(fdt->size_dt_struct); - uint32_t *struct_ptr = fdt_struct; - uint32_t name_length = 0; - uint32_t prop_length = 0; - uint32_t prop_name_off = 0; - uint32_t *lastaddr = 0; + uint32_t *struct_ptr = fdt_struct; + uint32_t name_length = 0; + uint32_t prop_length = 0; + uint32_t prop_name_off = 0; + uint32_t *lastaddr = 0; char path_copy[strlen(path) + 1]; strcpy(path_copy, path); @@ -98,17 +98,17 @@ uint32_t *fdt_get_addr(const char *path) { } void print_fdt() { - const char *fdt_strings = (char *)fdt + SWAP_UINT32(fdt->off_dt_strings); - uint32_t *fdt_struct = (uint32_t *)fdt + SWAP_UINT32(fdt->off_dt_struct); + const char *fdt_strings = (char *)fdt + SWAP_UINT32(fdt->off_dt_strings); + uint32_t *fdt_struct = (uint32_t *)fdt + SWAP_UINT32(fdt->off_dt_struct); const uint32_t struct_size = SWAP_UINT32(fdt->size_dt_struct); - uint32_t *struct_ptr = fdt_struct; - uint32_t name_length = 0; - uint32_t prop_length = 0; - uint32_t prop_name_off = 0; - char intstr[10]; - uint8_t tab_count = 0; - uint8_t first_elem = 0; + uint32_t *struct_ptr = fdt_struct; + uint32_t name_length = 0; + uint32_t prop_length = 0; + uint32_t prop_name_off = 0; + char intstr[10]; + uint8_t tab_count = 0; + uint8_t first_elem = 0; while (struct_ptr < fdt_struct + struct_size) { /* Read token */ diff --git a/arch/aarch64/hal.c b/arch/aarch64/hal.c index 0f06f5f..6873bef 100644 --- a/arch/aarch64/hal.c +++ b/arch/aarch64/hal.c @@ -23,7 +23,10 @@ void hcf() { } void delay(int32_t count) { - asm("__delay_%=: subs %[count], %[count], #1; bne __delay_%=\n" : "=r"(count) : [count] "0"(count) : "cc"); + asm("__delay_%=: subs %[count], %[count], #1; bne __delay_%=\n" + : "=r"(count) + : [count] "0"(count) + : "cc"); } uint32_t mmio_read(uint64_t reg) { diff --git a/arch/aarch64/include/bits/alltypes.h b/arch/aarch64/include/bits/alltypes.h index 3a1f1a1..214b6a8 100644 --- a/arch/aarch64/include/bits/alltypes.h +++ b/arch/aarch64/include/bits/alltypes.h @@ -34,22 +34,22 @@ #define __LLONG_MAX 0x7fffffffffffffffLL #define __ULLONG_MAX 0xffffffffffffffffULL -typedef unsigned wint_t; -typedef int blksize_t; +typedef unsigned wint_t; +typedef int blksize_t; typedef unsigned int nlink_t; -typedef float float_t; -typedef double double_t; -typedef int size_t; +typedef float float_t; +typedef double double_t; +typedef int size_t; -typedef char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; +typedef char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned int uint32_t; -typedef long int64_t; -typedef unsigned long uint64_t; -typedef long intptr_t; -typedef unsigned long uintptr_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef long int64_t; +typedef unsigned long uint64_t; +typedef long intptr_t; +typedef unsigned long uintptr_t; #endif diff --git a/arch/aarch64/include/fdt.h b/arch/aarch64/include/fdt.h index 583ebd1..7038d17 100644 --- a/arch/aarch64/include/fdt.h +++ b/arch/aarch64/include/fdt.h @@ -19,7 +19,8 @@ #ifndef _ASAGIRI_FDT_H #define _ASAGIRI_FDT_H -#define SWAP_UINT32(x) (((x) >> 24) | (((x)&0x00FF0000) >> 8) | (((x)&0x0000FF00) << 8) | ((x) << 24)) +#define SWAP_UINT32(x) \ + (((x) >> 24) | (((x)&0x00FF0000) >> 8) | (((x)&0x0000FF00) << 8) | ((x) << 24)) #include @@ -37,16 +38,16 @@ typedef struct fdt_header { } fdt_header; typedef struct fdt_prop { - uint32_t nameoff; - uint32_t len; + uint32_t nameoff; + uint32_t len; uint32_t *data; } fdt_prop; enum { FDT_BEGIN_NODE = 0x1, FDT_END_NODE = 0x2, FDT_PROP = 0x3, FDT_NOP = 0x4, FDT_END = 0x9 }; -fdt_prop fdt_get_prop(uint32_t *); +fdt_prop fdt_get_prop(uint32_t *); uint32_t *fdt_get_addr(const char *); -void fdt_init(); -void print_fdt(); +void fdt_init(); +void print_fdt(); #endif diff --git a/arch/aarch64/include/hal.h b/arch/aarch64/include/hal.h index 694b0f3..e23975a 100644 --- a/arch/aarch64/include/hal.h +++ b/arch/aarch64/include/hal.h @@ -23,9 +23,9 @@ #define asm __asm__ __volatile__ -void hcf(); -void delay(int32_t); +void hcf(); +void delay(int32_t); uint32_t mmio_read(uint64_t); -void mmio_write(uint64_t, uint32_t); +void mmio_write(uint64_t, uint32_t); #endif diff --git a/arch/aarch64/include/uart.h b/arch/aarch64/include/uart.h index 7be6ade..429ab4e 100644 --- a/arch/aarch64/include/uart.h +++ b/arch/aarch64/include/uart.h @@ -19,9 +19,9 @@ #ifndef _ASAGIRI_UART_H #define _ASAGIRI_UART_H -void uart_init(); -void uart_putc(unsigned char); +void uart_init(); +void uart_putc(unsigned char); unsigned char uart_getc(); -void uart_puts(const char *); +void uart_puts(const char *); #endif diff --git a/arch/aarch64/uart.c b/arch/aarch64/uart.c index 504cfed..673c353 100644 --- a/arch/aarch64/uart.c +++ b/arch/aarch64/uart.c @@ -69,7 +69,9 @@ void uart_init() { /* Enable FIFO & 8 bit data transmission (1 stop bit, no parity). */ mmio_write(UART_LCRH, (1 << 4) | (1 << 5) | (1 << 6)); /* Mask all interrupts. */ - mmio_write(UART_IMSC, (1 << 1) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)); + mmio_write(UART_IMSC, + (1 << 1) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) + | (1 << 10)); /* Enable UART0, receive & transfer part of UART. */ mmio_write(UART_CR, 1 | (1 << 8) | (1 << 9)); } diff --git a/arch/x86_64/include/bits/alltypes.h b/arch/x86_64/include/bits/alltypes.h index 3ede9cd..214b6a8 100644 --- a/arch/x86_64/include/bits/alltypes.h +++ b/arch/x86_64/include/bits/alltypes.h @@ -6,7 +6,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -19,19 +19,19 @@ #ifndef _ASAGIRI_ALLTYPES_H #define _ASAGIRI_ALLTYPES_H -#define _Addr long +#define _Addr long #define _Int64 long -#define _Reg long +#define _Reg long -#define __CHAR_MAX 0x7f -#define __UCHAR_MAX 0xff -#define __SHRT_MAX 0x7fff -#define __USHRT_MAX 0xffff -#define __INT_MAX 0x7fffffff -#define __UINT_MAX 0xffffffff -#define __LONG_MAX 0x7fffffffffffffffL -#define __ULONG_MAX 0xffffffffffffffffUL -#define __LLONG_MAX 0x7fffffffffffffffLL +#define __CHAR_MAX 0x7f +#define __UCHAR_MAX 0xff +#define __SHRT_MAX 0x7fff +#define __USHRT_MAX 0xffff +#define __INT_MAX 0x7fffffff +#define __UINT_MAX 0xffffffff +#define __LONG_MAX 0x7fffffffffffffffL +#define __ULONG_MAX 0xffffffffffffffffUL +#define __LLONG_MAX 0x7fffffffffffffffLL #define __ULLONG_MAX 0xffffffffffffffffULL typedef unsigned wint_t; diff --git a/arch/x86_64/include/bits/stdarg.h b/arch/x86_64/include/bits/stdarg.h index 3d4e61b..4f86862 100644 --- a/arch/x86_64/include/bits/stdarg.h +++ b/arch/x86_64/include/bits/stdarg.h @@ -6,7 +6,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -#define va_start(v,l) __builtin_va_start(v,l) -#define va_end(v) __builtin_va_end(v) -#define va_arg(v,l) __builtin_va_arg(v,l) -#define va_copy(d,s) __builtin_va_copy(d,s) +#define va_start(v, l) __builtin_va_start(v, l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v, l) __builtin_va_arg(v, l) +#define va_copy(d, s) __builtin_va_copy(d, s) typedef __builtin_va_list va_list; typedef __builtin_va_list __isoc_va_list; \ No newline at end of file diff --git a/arch/x86_64/include/hal.h b/arch/x86_64/include/hal.h index f86180a..f4fd188 100644 --- a/arch/x86_64/include/hal.h +++ b/arch/x86_64/include/hal.h @@ -23,8 +23,8 @@ #define asm __asm__ __volatile__ -void hcf(); -void outb(uint16_t, uint8_t); +void hcf(); +void outb(uint16_t, uint8_t); uint8_t inb(uint16_t); #endif diff --git a/hanekawa/include/assert.h b/hanekawa/include/assert.h index 2a20a7b..d161b57 100644 --- a/hanekawa/include/assert.h +++ b/hanekawa/include/assert.h @@ -21,6 +21,7 @@ #include -#define assert(val) ((val) ? (void)0 : (printf("ASSERTION FAILED, " __FILE__ ":%d: " #val "\n", __LINE__), abort())) +#define assert(val) \ + ((val) ? (void)0 : (printf("ASSERTION FAILED, " __FILE__ ":%d: " #val "\n", __LINE__), abort())) #endif \ No newline at end of file diff --git a/hanekawa/include/ctype.h b/hanekawa/include/ctype.h index d4e3278..7de1142 100644 --- a/hanekawa/include/ctype.h +++ b/hanekawa/include/ctype.h @@ -6,7 +6,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the diff --git a/hanekawa/include/math.h b/hanekawa/include/math.h index 6bf2c23..9accc33 100644 --- a/hanekawa/include/math.h +++ b/hanekawa/include/math.h @@ -23,6 +23,6 @@ #include double pow(double x, double y); -int abs(int x); +int abs(int x); #endif diff --git a/hanekawa/include/stdlib.h b/hanekawa/include/stdlib.h index f06381e..1960145 100644 --- a/hanekawa/include/stdlib.h +++ b/hanekawa/include/stdlib.h @@ -24,6 +24,6 @@ char *itoa(int value, char *buffer, int base); char *uitoa(uint32_t value, char *buffer, int base); -void abort(); +void abort(); #endif diff --git a/hanekawa/math/pow.c b/hanekawa/math/pow.c index e4ad77f..ddab23e 100644 --- a/hanekawa/math/pow.c +++ b/hanekawa/math/pow.c @@ -21,8 +21,8 @@ double pow(double x, double y) { return 1; } - int count = 0; - double out = 1; + int count = 0; + double out = 1; while (count < y) { out = out * x; count++; diff --git a/hanekawa/stdio/printf.c b/hanekawa/stdio/printf.c index 4f69393..2732c0e 100644 --- a/hanekawa/stdio/printf.c +++ b/hanekawa/stdio/printf.c @@ -64,7 +64,7 @@ int printf(const char *restrict format, ...) { const char *format_begun_at = format++; size_t len = 0; - char buf[11]; + char buf[11]; switch (*format) { case 'c': diff --git a/hanekawa/stdlib/itoa.c b/hanekawa/stdlib/itoa.c index 7f9c51a..bb43e9c 100644 --- a/hanekawa/stdlib/itoa.c +++ b/hanekawa/stdlib/itoa.c @@ -53,8 +53,8 @@ char *itoa(int value, char *buffer, int base) { buffer[index] = 0; /* Reverse the buffer */ - uint8_t len = index; - char temp = 0; + uint8_t len = index; + char temp = 0; for (uint8_t i = 0; i < len >> 1; ++i) { temp = buffer[i]; buffer[i] = buffer[len - i - 1]; diff --git a/hanekawa/stdlib/uitoa.c b/hanekawa/stdlib/uitoa.c index bb5b3db..bde721b 100644 --- a/hanekawa/stdlib/uitoa.c +++ b/hanekawa/stdlib/uitoa.c @@ -41,8 +41,8 @@ char *uitoa(uint32_t value, char *buffer, int base) { buffer[index] = 0; /* Reverse the buffer */ - uint8_t len = index; - char temp = 0; + uint8_t len = index; + char temp = 0; for (uint8_t i = 0; i < len >> 1; ++i) { temp = buffer[i]; buffer[i] = buffer[len - i - 1]; diff --git a/hanekawa/string/memcpy.c b/hanekawa/string/memcpy.c index 5e7d0a6..30ef9ad 100644 --- a/hanekawa/string/memcpy.c +++ b/hanekawa/string/memcpy.c @@ -19,7 +19,7 @@ #include void *memcpy(void *restrict dstptr, const void *srcptr, size_t size) { - unsigned char *dst = (unsigned char *)dstptr; + unsigned char *dst = (unsigned char *)dstptr; const unsigned char *src = (const unsigned char *)srcptr; for (size_t i = 0; i < size; i++) { dst[i] = src[i]; diff --git a/hanekawa/string/memmove.c b/hanekawa/string/memmove.c index e0efe11..ce55dc7 100644 --- a/hanekawa/string/memmove.c +++ b/hanekawa/string/memmove.c @@ -19,7 +19,7 @@ #include void *memmove(void *dstptr, const void *srcptr, size_t size) { - unsigned char *dst = (unsigned char *)dstptr; + unsigned char *dst = (unsigned char *)dstptr; const unsigned char *src = (const unsigned char *)srcptr; if (dst < src) { diff --git a/shinobu/file.c b/shinobu/file.c index 0cfbe0d..bb14a90 100644 --- a/shinobu/file.c +++ b/shinobu/file.c @@ -23,17 +23,24 @@ EFI_FILE_PROTOCOL *EFIAPI OpenFile(CHAR16 *path) { /* Locate handle supporting SFSP */ EFI_HANDLE *handles; - UINTN handleCnt; - EFI_GUID sfspGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; + UINTN handleCnt; + EFI_GUID sfspGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; - status = uefi_call_wrapper(*(void **)&BS->LocateHandleBuffer, 5, ByProtocol, &sfspGuid, NULL, &handleCnt, &handles); + status = uefi_call_wrapper(*(void **)&BS->LocateHandleBuffer, + 5, + ByProtocol, + &sfspGuid, + NULL, + &handleCnt, + &handles); PRINT_ERR(status); /* TODO: Might need to iterate on all handles if * multiple FAT32 images are connected * Open Filesystem */ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs = NULL; - status = uefi_call_wrapper(*(void **)&BS->HandleProtocol, 3, handles[0], &sfspGuid, (VOID **)&fs); + status = + uefi_call_wrapper(*(void **)&BS->HandleProtocol, 3, handles[0], &sfspGuid, (VOID **)&fs); PRINT_ERR(status); /* Open ROOTDIR */ @@ -42,7 +49,13 @@ EFI_FILE_PROTOCOL *EFIAPI OpenFile(CHAR16 *path) { PRINT_ERR(status); /* Open file */ - status = uefi_call_wrapper(*(void **)&root->Open, 5, root, &root, path, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY); + status = uefi_call_wrapper(*(void **)&root->Open, + 5, + root, + &root, + path, + EFI_FILE_MODE_READ, + EFI_FILE_READ_ONLY); PRINT_ERR(status); return root; diff --git a/shinobu/include/shinobu.h b/shinobu/include/shinobu.h index afb9101..64a80b8 100644 --- a/shinobu/include/shinobu.h +++ b/shinobu/include/shinobu.h @@ -27,18 +27,18 @@ Print(L"%a:%d error: %r\n", __FILE__, __LINE__, status); typedef struct { - UINTN memoryMapSize; + UINTN memoryMapSize; EFI_MEMORY_DESCRIPTOR *memoryMap; - UINTN mapKey; - UINTN descriptorSize; - UINT32 descriptorVersion; + UINTN mapKey; + UINTN descriptorSize; + UINT32 descriptorVersion; } UEFIMemoryMap; -EFI_STATUS EFIAPI SetMemoryMap(UEFIMemoryMap *); +EFI_STATUS EFIAPI SetMemoryMap(UEFIMemoryMap *); EFI_FILE_PROTOCOL *EFIAPI OpenFile(CHAR16 *path); -EFI_STATUS EFIAPI SetPos(EFI_FILE_PROTOCOL *, UINTN); -EFI_STATUS EFIAPI Read(EFI_FILE_PROTOCOL *, UINTN *, VOID *); -EFI_STATUS EFIAPI Close(EFI_FILE_PROTOCOL *); +EFI_STATUS EFIAPI SetPos(EFI_FILE_PROTOCOL *, UINTN); +EFI_STATUS EFIAPI Read(EFI_FILE_PROTOCOL *, UINTN *, VOID *); +EFI_STATUS EFIAPI Close(EFI_FILE_PROTOCOL *); /* elf.h */ #define EI_NIDENT (16) @@ -50,27 +50,27 @@ typedef uint64_t Elf64_Xword; typedef struct { unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf64_Half e_type; /* Object file type */ - Elf64_Half e_machine; /* Architecture */ - Elf64_Word e_version; /* Object file version */ - Elf64_Addr e_entry; /* Entry point virtual address */ - Elf64_Off e_phoff; /* Program header table file offset */ - Elf64_Off e_shoff; /* Section header table file offset */ - Elf64_Word e_flags; /* Processor-specific flags */ - Elf64_Half e_ehsize; /* ELF header size in bytes */ - Elf64_Half e_phentsize; /* Program header table entry size */ - Elf64_Half e_phnum; /* Program header table entry count */ - Elf64_Half e_shentsize; /* Section header table entry size */ - Elf64_Half e_shnum; /* Section header table entry count */ - Elf64_Half e_shstrndx; /* Section header string table index */ + Elf64_Half e_type; /* Object file type */ + Elf64_Half e_machine; /* Architecture */ + Elf64_Word e_version; /* Object file version */ + Elf64_Addr e_entry; /* Entry point virtual address */ + Elf64_Off e_phoff; /* Program header table file offset */ + Elf64_Off e_shoff; /* Section header table file offset */ + Elf64_Word e_flags; /* Processor-specific flags */ + Elf64_Half e_ehsize; /* ELF header size in bytes */ + Elf64_Half e_phentsize; /* Program header table entry size */ + Elf64_Half e_phnum; /* Program header table entry count */ + Elf64_Half e_shentsize; /* Section header table entry size */ + Elf64_Half e_shnum; /* Section header table entry count */ + Elf64_Half e_shstrndx; /* Section header string table index */ } Elf64_Ehdr; typedef struct { - Elf64_Word p_type; /* Segment type */ - Elf64_Word p_flags; /* Segment flags */ - Elf64_Off p_offset; /* Segment file offset */ - Elf64_Addr p_vaddr; /* Segment virtual address */ - Elf64_Addr p_paddr; /* Segment physical address */ + Elf64_Word p_type; /* Segment type */ + Elf64_Word p_flags; /* Segment flags */ + Elf64_Off p_offset; /* Segment file offset */ + Elf64_Addr p_vaddr; /* Segment virtual address */ + Elf64_Addr p_paddr; /* Segment physical address */ Elf64_Xword p_filesz; /* Segment size in file */ Elf64_Xword p_memsz; /* Segment size in memory */ Elf64_Xword p_align; /* Segment alignment */ diff --git a/shinobu/shinobu.c b/shinobu/shinobu.c index 720a308..c589eb9 100644 --- a/shinobu/shinobu.c +++ b/shinobu/shinobu.c @@ -36,7 +36,7 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable EFI_FILE_PROTOCOL *kernelFile = OpenFile(L"yukari"); /* Read ELF Header */ - UINTN EHeaderSize = sizeof(Elf64_Ehdr); + UINTN EHeaderSize = sizeof(Elf64_Ehdr); Elf64_Ehdr *kernelElfHeader = AllocatePool(EHeaderSize); SetPos(kernelFile, 0); @@ -45,7 +45,7 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable Print(L"ELF Header Loc: 0x%x\n", kernelElfHeader); /* Read ELF Prog Header */ - UINTN PHeaderSize = kernelElfHeader->e_phnum * kernelElfHeader->e_phentsize; + UINTN PHeaderSize = kernelElfHeader->e_phnum * kernelElfHeader->e_phentsize; Elf64_Phdr *kernelProgHeader = AllocatePool(PHeaderSize); SetPos(kernelFile, kernelElfHeader->e_phoff); @@ -57,12 +57,16 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable for (UINT16 i = 0; i < kernelElfHeader->e_phnum; ++i) { if (kernelProgHeader[i].p_type == 1) { /* Get count of pages needed */ - int pages = (kernelProgHeader[i].p_memsz + EFI_PAGE_SIZE - 1) / EFI_PAGE_SIZE; + int pages = (kernelProgHeader[i].p_memsz + EFI_PAGE_SIZE - 1) / EFI_PAGE_SIZE; /* Get segment address */ Elf64_Addr segment = kernelProgHeader[i].p_paddr; /* Allocate pages to the segment address */ - status = - uefi_call_wrapper(*(void **)&BS->AllocatePages, 4, AllocateAddress, EfiLoaderData, pages, &segment); + status = uefi_call_wrapper(*(void **)&BS->AllocatePages, + 4, + AllocateAddress, + EfiLoaderData, + pages, + &segment); PRINT_ERR(status); /* Write program segment to the allocated address */ UINTN fileSize = kernelProgHeader[i].p_filesz;