From a5734f22277a0b07799dc05349b626ed8e3736fa Mon Sep 17 00:00:00 2001 From: Todor Minchev Date: Thu, 30 Oct 2014 12:15:48 +0000 Subject: [PATCH] gummiboot: cosmetic fixes in preparation for RFC release Signed-off-by: Todor Minchev --- Makefile.am | 11 +- src/efi/gummiboot.c | 41 ++++--- src/elf/elf.c | 196 +++++++++++++++---------------- src/multiboot2/acpi.h | 12 +- src/multiboot2/multiboot2.c | 76 ++++++------ src/multiboot2/multiboot2.h | 4 +- src/multiboot2/multiboot2_util.h | 79 ++++++------- 7 files changed, 201 insertions(+), 218 deletions(-) diff --git a/Makefile.am b/Makefile.am index aff07ee..69209ec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,13 +40,12 @@ bin_PROGRAMS = gummiboot gummiboot_SOURCES = \ src/setup/setup.c \ src/setup/efivars.c \ - src/setup/efivars.h + src/setup/efivars.h gummiboot_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \ - -DGUMMIBOOTLIBDIR=\"$(gummibootlibdir)\" - + -DGUMMIBOOTLIBDIR=\"$(gummibootlibdir)\" gummiboot_CFLAGS = \ $(AM_CFLAGS) \ @@ -83,7 +82,7 @@ efi_sources = \ src/efi/gummiboot.c \ src/multiboot2/multiboot2.c \ src/elf/elf.c \ - src/elf/memcpy.c + src/elf/memcpy.c efi_headers = \ src/efi/util.h \ @@ -92,7 +91,7 @@ efi_headers = \ src/multiboot2/multiboot2.h \ src/multiboot2/multiboot2_util.h \ src/multiboot2/acpi.h \ - src/elf/elf.h + src/elf/elf.h efi_cppflags = \ $(EFI_CPPFLAGS) \ @@ -101,7 +100,7 @@ efi_cppflags = \ -I$(EFI_INC_DIR)/efi/$(ARCH) \ -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \ -I$(top_builddir)/src/multiboot2 \ - -I$(top_builddir)/src/elf + -I$(top_builddir)/src/elf efi_cflags = \ $(EFI_CFLAGS) \ diff --git a/src/efi/gummiboot.c b/src/efi/gummiboot.c index 5e515ad..00b00a2 100644 --- a/src/efi/gummiboot.c +++ b/src/efi/gummiboot.c @@ -33,7 +33,6 @@ #include "console.h" #include "graphics.h" - #ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL #endif @@ -1093,12 +1092,12 @@ static VOID config_entry_add_from_file(Config *config, EFI_HANDLE *device, CHAR1 } if (strcmpa((CHAR8 *)"multiboot2", key) == 0) { - FreePool(entry->multiboot2); + FreePool(entry->multiboot2); entry->multiboot2 = stra_to_path(value); continue; } if (strcmpa((CHAR8 *)"acm", key) == 0) { - FreePool(entry->acm); + FreePool(entry->acm); entry->acm = stra_to_path(value); continue; } @@ -1637,33 +1636,33 @@ static EFI_STATUS image_start(EFI_HANDLE parent_image, const Config *config, con path = FileDevicePath(entry->device, entry->loader); if (!path) { - Print(L"Error getting device path."); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - return EFI_INVALID_PARAMETER; + Print(L"Error getting device path."); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + return EFI_INVALID_PARAMETER; } if(entry->multiboot2){ - err = copy_file_buf(parent_image, entry->multiboot2, &os_buf, 0) ; - if (EFI_ERROR(err)) - goto out; + err = copy_file_buf(parent_image, entry->multiboot2, &os_buf, 0) ; + if (EFI_ERROR(err)) + goto out; - /*parse multiboot2 header*/ - err = parse_header(os_buf,MULTIBOOT_SEARCH) ; + /*parse multiboot2 header*/ + err = parse_header(os_buf,MULTIBOOT_SEARCH) ; - /*load as elf binary*/ - if(err == EFI_LOAD_ELF){ - err = load_elf(os_buf, &elf_entry) ; - if (EFI_ERROR(err)) - goto out; - }else if (EFI_ERROR(err)) - goto out; + /*load as elf binary*/ + if(err == EFI_LOAD_ELF){ + err = load_elf(os_buf, &elf_entry) ; + if (EFI_ERROR(err)) + goto out; + }else if (EFI_ERROR(err)) + goto out; err = populate_mbi2(parent_image, entry, &mbi2_buf) ; - if (EFI_ERROR(err)) - goto out; + if (EFI_ERROR(err)) + goto out; start_elf(elf_entry, mbi2_buf); - //we should never reach this point + /* we should never reach this point */ } err = uefi_call_wrapper(BS->LoadImage, 6, FALSE, parent_image, path, NULL, 0, &image); diff --git a/src/elf/elf.c b/src/elf/elf.c index 173a31f..c9209a2 100644 --- a/src/elf/elf.c +++ b/src/elf/elf.c @@ -14,76 +14,69 @@ static inline void *memset(void *b, int c, uint32_t len) EFI_STATUS load_elf(CHAR8 *buf, void **entry) { - elf_header_t * elf = NULL ; - int i ; + elf_header_t * elf = NULL ; - if ( buf == NULL ) { - Print(L"elf.c : %d: Buffer is zero.\n", __LINE__); - uefi_call_wrapper(BS->Stall, 1, 1 * 1000 * 1000); - return EFI_LOAD_ERROR; - }else - elf = (elf_header_t *) buf ; - - /* validate the ELF header */ - if (elf->e_ident[EI_MAG0] != ELFMAG0 - || elf->e_ident[EI_MAG1] != ELFMAG1 - || elf->e_ident[EI_MAG2] != ELFMAG2 - || elf->e_ident[EI_MAG3] != ELFMAG3 - || elf->e_ident[EI_DATA] != ELFDATA2LSB){ - Print(L"elf.c : %d: Invalid ELF magic.\n", __LINE__); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - return EFI_LOAD_ERROR; - } - - if (elf->e_ident[EI_CLASS] != ELFCLASS32 || elf->e_machine != EM_386 - || elf->e_version != EV_CURRENT){ - Print(L"elf.c : %d: Invalid ELF class.\n", __LINE__); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - return EFI_LOAD_ERROR; - } - - if (elf->e_type != ET_EXEC && elf->e_type != ET_DYN){ - Print(L"elf.c : %d: Invalid ELF type.\n", __LINE__); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - return EFI_LOAD_ERROR; - } - - /* load loadable segments into memory */ - for ( i = 0; i < elf->e_phnum; i++ ) { - elf_program_header_t *ph = (elf_program_header_t *) - ((void *)elf + elf->e_phoff + i*elf->e_phentsize); - - if ( ph->p_type == PT_LOAD ) { - - memcpy((void *)(uint64_t)ph->p_paddr, (void *)elf + ph->p_offset, - ph->p_filesz); - - memset((void *)(uint64_t)(ph->p_paddr + ph->p_filesz), 0, - ph->p_memsz - ph->p_filesz); - } - } - - *entry = (void*)(uint64_t)elf->e_entry; - - return EFI_SUCCESS; + if ( buf == NULL ) { + Print(L"elf.c : %d: Buffer is zero.\n", __LINE__); + uefi_call_wrapper(BS->Stall, 1, 1 * 1000 * 1000); + return EFI_LOAD_ERROR; + }else + elf = (elf_header_t *) buf ; + + /* validate the ELF header */ + if (elf->e_ident[EI_MAG0] != ELFMAG0 + || elf->e_ident[EI_MAG1] != ELFMAG1 + || elf->e_ident[EI_MAG2] != ELFMAG2 + || elf->e_ident[EI_MAG3] != ELFMAG3 + || elf->e_ident[EI_DATA] != ELFDATA2LSB){ + Print(L"elf.c : %d: Invalid ELF magic.\n", __LINE__); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + return EFI_LOAD_ERROR; + } + + if (elf->e_ident[EI_CLASS] != ELFCLASS32 || elf->e_machine != EM_386 + || elf->e_version != EV_CURRENT){ + Print(L"elf.c : %d: Invalid ELF class.\n", __LINE__); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + return EFI_LOAD_ERROR; + } + + if (elf->e_type != ET_EXEC && elf->e_type != ET_DYN){ + Print(L"elf.c : %d: Invalid ELF type.\n", __LINE__); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + return EFI_LOAD_ERROR; + } + + /* load loadable segments into memory */ + for ( i = 0; i < elf->e_phnum; i++ ) { + elf_program_header_t *ph = (elf_program_header_t *) + ((void *)elf + elf->e_phoff + i*elf->e_phentsize); + + if ( ph->p_type == PT_LOAD ) { + memcpy((void *)(uint64_t)ph->p_paddr, (void *)elf + ph->p_offset, + ph->p_filesz); + + memset((void *)(uint64_t)(ph->p_paddr + ph->p_filesz), 0, + ph->p_memsz - ph->p_filesz); + } + } + + *entry = (void*)(uint64_t)elf->e_entry; + return EFI_SUCCESS; } void start_elf(void *buf, void* mbi2_buf){ struct seg_desc global_desc_table[] = { - /* NULL descriptor 0x0*/ { 0, }, - /* Code32 segment descriptor 0x08*/ populate_4k_seg_descriptor(0, 0xffffffff, 0x1, gdt_cs_flags_limit), - /* Data32 segment descriptor 0x10*/ populate_4k_seg_descriptor(0, 0xffffffff, 0x1, gdt_ds_flags_limit), /* Task state segment descriptor 0x18*/ { 0, }, - /* Code16 segment descriptor 0x20*/ populate_4k_seg_descriptor(0, 0xffffffff, 0x0, gdt_cs_flags_limit), @@ -101,57 +94,56 @@ void start_elf(void *buf, void* mbi2_buf){ gdt_desc.sz = sizeof(global_desc_table) - 1; gdt_desc.addr = (uint64_t) global_desc_table; - if(!buf){ - Print(L"elf.c : %d : Missing ELF entry point. Resetting.\n", __LINE__); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS,0,0); - } - - if(!mbi2_buf){ - Print(L"elf.c : %d : Missing MBI2 buffer. Resetting.\n", __LINE__); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS,0,0); - - } - - __asm__ __volatile__( - "lgdt %0 ;" /* load GDT into GDTR*/ - "pushq %1 ;" /* push code segment selector on the stack*/ - "leaq 1f(%%rip), %%rax ;" /* address to jump into*/ - "pushq %%rax ;" /* push jump address on the stack */ - "retfq ;" - - "1:mov %2, %%ax ;" /* we are in compatibility mode*/ - "mov %%ax, %%ds ;" /* reset the data segments */ - "mov %%ax, %%es ;" - "mov %%ax, %%fs ;" - "mov %%ax, %%gs ;" - "mov %%ax, %%ss ;" - - "mov %%cr0, %%rax ;" - "btcl $31, %%eax ;" /* disable paging*/ - "mov %%rax, %%cr0 ;" - "movl $0x0c0000080, %%ecx ;" /* EFER MSR number */ - "rdmsr ;" /* Read EFER. */ - "btcl $8, %%eax ;" /* Set LME=0. */ - "wrmsr ;" /* Write EFER. */ - :: "m" (gdt_desc), - "i" (cs_sel), - "i" (ds_sel)); /* Goodbye long mode, we are back to protected mode */ - - /* hand over to tboot */ + if(!buf){ + Print(L"elf.c : %d : Missing ELF entry point. Resetting.\n", __LINE__); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS,0,0); + } + + if(!mbi2_buf){ + Print(L"elf.c : %d : Missing MBI2 buffer. Resetting.\n", __LINE__); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS,0,0); + } + + __asm__ __volatile__( + "lgdt %0 ;" /* load GDT into GDTR*/ + "pushq %1 ;" /* push code segment selector on the stack*/ + "leaq 1f(%%rip), %%rax ;" /* address to jump into*/ + "pushq %%rax ;" /* push jump address on the stack */ + "retfq ;" + + "1:mov %2, %%ax ;" /* we are in compatibility mode*/ + "mov %%ax, %%ds ;" /* reset the data segments */ + "mov %%ax, %%es ;" + "mov %%ax, %%fs ;" + "mov %%ax, %%gs ;" + "mov %%ax, %%ss ;" + + "mov %%cr0, %%rax ;" + "btcl $31, %%eax ;" /* disable paging*/ + "mov %%rax, %%cr0 ;" + "movl $0x0c0000080, %%ecx ;" /* EFER MSR number */ + "rdmsr ;" /* Read EFER. */ + "btcl $8, %%eax ;" /* Set LME=0. */ + "wrmsr ;" /* Write EFER. */ + :: "m" (gdt_desc), + "i" (cs_sel), + "i" (ds_sel)); /* Goodbye long mode, we are back to protected mode */ + + /* hand over to tboot */ /* EAX - multiboot2 magic EBX - MBI2 - ECX - tboot entry point */ + ECX - tboot entry point */ __asm__ __volatile__ ( - "push %2 ;" - "mov $0x36d76289, %%eax ;" /* TODO - Shouldn't be really needed, but EAX gets corrupted ? */ - "ret ;" - :: - "a" (MULTIBOOT2_BOOTLOADER_MAGIC), - "b" (mbi2_buf), - "c" (buf)); + "push %2 ;" + "mov $0x36d76289, %%eax ;" /* Shouldn't be really needed, but EAX gets corrupted ? */ + "ret ;" + :: + "a" (MULTIBOOT2_BOOTLOADER_MAGIC), + "b" (mbi2_buf), + "c" (buf)); /* WE SHOULD NEVER REACH HERE */ } diff --git a/src/multiboot2/acpi.h b/src/multiboot2/acpi.h index 2f52f37..821dcc3 100644 --- a/src/multiboot2/acpi.h +++ b/src/multiboot2/acpi.h @@ -1,11 +1,11 @@ -#define EFI_ACPI_TABLE_GUID \ - { 0xeb9d2d30, 0x2d88, 0x11d3, \ - { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ +#define EFI_ACPI_TABLE_GUID \ + { 0xeb9d2d30, 0x2d88, 0x11d3, \ + { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ } -#define EFI_ACPI_20_TABLE_GUID \ - { 0x8868e871, 0xe4f1, 0x11d3, \ - { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ +#define EFI_ACPI_20_TABLE_GUID \ + { 0x8868e871, 0xe4f1, 0x11d3, \ + { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ } typedef struct { diff --git a/src/multiboot2/multiboot2.c b/src/multiboot2/multiboot2.c index 2c936d2..7cb1f5f 100644 --- a/src/multiboot2/multiboot2.c +++ b/src/multiboot2/multiboot2.c @@ -21,12 +21,12 @@ CHAR8 * char16_to_char8 (IN CHAR16 *src, OUT CHAR8 *dest, IN UINT16 size){ } EFI_STATUS copy_file_buf(EFI_HANDLE parent_image, CHAR16 *file, CHAR8 **buf, UINTN *buf_len ){ - EFI_STATUS err; + EFI_STATUS err; EFI_LOADED_IMAGE *loaded_image; EFI_FILE_HANDLE root_dir ; - EFI_FILE_HANDLE file_handle; - UINTN tmp_sz ; - EFI_FILE_INFO tmp_buf; + EFI_FILE_HANDLE file_handle; + UINTN tmp_sz ; + EFI_FILE_INFO tmp_buf; err = uefi_call_wrapper(BS->OpenProtocol, 6, parent_image, &LoadedImageProtocol, (void **)&loaded_image, parent_image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); @@ -123,8 +123,9 @@ EFI_STATUS parse_header(CHAR8 *buf, UINTN len){ for (tag = (mboot_hdr_tag_p) (hdr + 1); tag->type != MULTIBOOT_TAG_TYPE_END; tag = (mboot_hdr_tag_p) ((uint32_t *) tag - + ALIGN_UP (tag->size, 2))){ + + ALIGN_UP (tag->size, 2))){ + /* none of these are populated by tboot - TODO - not implemented for now */ switch(tag->type){ case MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST: { @@ -135,35 +136,33 @@ EFI_STATUS parse_header(CHAR8 *buf, UINTN len){ break; for (i = 0; i < (req_tag->size - sizeof (req_tag)) / sizeof (req_tag->requests[0]); i++) - - switch (req_tag->requests[i]) - { - case MULTIBOOT_TAG_TYPE_END: - case MULTIBOOT_TAG_TYPE_CMDLINE: - case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: - case MULTIBOOT_TAG_TYPE_MODULE: - case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: - case MULTIBOOT_TAG_TYPE_BOOTDEV: - case MULTIBOOT_TAG_TYPE_MMAP: - case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: - case MULTIBOOT_TAG_TYPE_VBE: - case MULTIBOOT_TAG_TYPE_ELF_SECTIONS: - case MULTIBOOT_TAG_TYPE_APM: - case MULTIBOOT_TAG_TYPE_EFI32: - case MULTIBOOT_TAG_TYPE_EFI64: - case MULTIBOOT_TAG_TYPE_ACPI_OLD: - case MULTIBOOT_TAG_TYPE_ACPI_NEW: - case MULTIBOOT_TAG_TYPE_NETWORK: - case MULTIBOOT_TAG_TYPE_EFI_MMAP: - case MULTIBOOT_TAG_TYPE_EFI_BS: - break; - - default: - Print(L"multiboot2.c : %d Unsupported information tag: 0x%x", - __LINE__, req_tag->requests[i]); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - return EFI_LOAD_ERROR; - } + switch (req_tag->requests[i]){ + case MULTIBOOT_TAG_TYPE_END: + case MULTIBOOT_TAG_TYPE_CMDLINE: + case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: + case MULTIBOOT_TAG_TYPE_MODULE: + case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: + case MULTIBOOT_TAG_TYPE_BOOTDEV: + case MULTIBOOT_TAG_TYPE_MMAP: + case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: + case MULTIBOOT_TAG_TYPE_VBE: + case MULTIBOOT_TAG_TYPE_ELF_SECTIONS: + case MULTIBOOT_TAG_TYPE_APM: + case MULTIBOOT_TAG_TYPE_EFI32: + case MULTIBOOT_TAG_TYPE_EFI64: + case MULTIBOOT_TAG_TYPE_ACPI_OLD: + case MULTIBOOT_TAG_TYPE_ACPI_NEW: + case MULTIBOOT_TAG_TYPE_NETWORK: + case MULTIBOOT_TAG_TYPE_EFI_MMAP: + case MULTIBOOT_TAG_TYPE_EFI_BS: + break; + + default: + Print(L"multiboot2.c : %d Unsupported information tag: 0x%x", + __LINE__, req_tag->requests[i]); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + return EFI_LOAD_ERROR; + } break; } @@ -173,7 +172,6 @@ EFI_STATUS parse_header(CHAR8 *buf, UINTN len){ case MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS: has_entry_addr_tag = true ; - //entry_addr_tag = ((mboot_hdr_tag_entry_addr_p) tag)->entry_addr; break; case MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS: @@ -182,12 +180,10 @@ EFI_STATUS parse_header(CHAR8 *buf, UINTN len){ supported_consoles &= ~MULTIBOOT_OS_CONSOLE_EGA_TEXT; if (((struct multiboot_header_tag_console_flags *) tag)->console_flags & MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED) - //console_required = true; break; case MULTIBOOT_HEADER_TAG_FRAMEBUFFER: - //fbtag = (mboot_hdr_tag_fbuf_p) tag; supported_consoles |= MULTIBOOT_CONSOLE_FRAMEBUFFER; break; @@ -200,9 +196,9 @@ EFI_STATUS parse_header(CHAR8 *buf, UINTN len){ default: if (! (tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL)){ - Print(L"multiboot2.c : %d Unsupported tag: 0x%x",__LINE__, tag->type); - uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - return EFI_LOAD_ERROR; + Print(L"multiboot2.c : %d Unsupported tag: 0x%x",__LINE__, tag->type); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + return EFI_LOAD_ERROR; } break ; } diff --git a/src/multiboot2/multiboot2.h b/src/multiboot2/multiboot2.h index 3ccff15..2ccef1d 100644 --- a/src/multiboot2/multiboot2.h +++ b/src/multiboot2/multiboot2.h @@ -227,7 +227,7 @@ struct multiboot_tag_mmap multiboot_uint32_t size; multiboot_uint32_t entry_size; multiboot_uint32_t entry_version; - struct multiboot_mmap_entry entries[0]; + struct multiboot_mmap_entry entries[0]; }; struct multiboot_vbe_info_block @@ -371,7 +371,7 @@ struct multiboot_tag_efi_mmap multiboot_uint32_t descr_size; multiboot_uint32_t descr_vers; multiboot_uint8_t efi_mmap[0]; -}; +}; #endif /* ! ASM_FILE */ diff --git a/src/multiboot2/multiboot2_util.h b/src/multiboot2/multiboot2_util.h index 4f4ae17..860507a 100644 --- a/src/multiboot2/multiboot2_util.h +++ b/src/multiboot2/multiboot2_util.h @@ -7,20 +7,20 @@ #define EFI_LOAD_ELF 50 #define E820_MAX_ENTRIES 128 -#define E820_RAM 1 -#define E820_RESERVED 2 -#define E820_ACPI 3 -#define E820_NVS 4 -#define E820_EXEC_CODE 5 +#define E820_RAM 1 +#define E820_RESERVED 2 +#define E820_ACPI 3 +#define E820_NVS 4 +#define E820_EXEC_CODE 5 -#define MULTIBOOT_OS_CONSOLE_EGA_TEXT 1 -#define MULTIBOOT_CONSOLE_FRAMEBUFFER 2 +#define MULTIBOOT_OS_CONSOLE_EGA_TEXT 1 +#define MULTIBOOT_CONSOLE_FRAMEBUFFER 2 -#define cs_sel 1<<3 -#define ds_sel 2<<3 -#define gdt_cs_flags_limit 0x9a /* present, system, DPL-0, execute/read */ -#define gdt_ds_flags_limit 0x92 /* present, system, DPL-0, read/write */ +#define cs_sel 1<<3 +#define ds_sel 2<<3 +#define gdt_cs_flags_limit 0x9a /* present, system, DPL-0, execute/read */ +#define gdt_ds_flags_limit 0x92 /* present, system, DPL-0, read/write */ #define ALIGN_UP(addr, align) \ ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1)) @@ -69,11 +69,11 @@ typedef struct { } Config; typedef struct { - UINTN mmap_size; - EFI_MEMORY_DESCRIPTOR *mmap; - UINTN mapkey; - UINTN desc_size; - UINT32 desc_ver; + UINTN mmap_size; + EFI_MEMORY_DESCRIPTOR *mmap; + UINTN mapkey; + UINTN desc_size; + UINT32 desc_ver; }efi_mmap_t; typedef struct{ @@ -83,38 +83,35 @@ typedef struct{ } __attribute__((packed)) e820_entry_t; typedef struct{ - unsigned int r_mask_sz; - unsigned int r_fld_pos; - unsigned int g_mask_sz; - unsigned int g_fld_pos; - unsigned int b_mask_sz; - unsigned int b_fld_pos; - unsigned int res_mask_sz; - unsigned int res_fld_pos; - + unsigned int r_mask_sz; + unsigned int r_fld_pos; + unsigned int g_mask_sz; + unsigned int g_fld_pos; + unsigned int b_mask_sz; + unsigned int b_fld_pos; + unsigned int res_mask_sz; + unsigned int res_fld_pos; }fb_rgbr_mask_field_t ; struct seg_desc { + uint16_t limit_15_0; + uint16_t base_addr_15_0; + uint8_t base_addr_23_16; - uint16_t limit_15_0; - uint16_t base_addr_15_0; - uint8_t base_addr_23_16; - - /* 4 bits flags + 4 bits limit*/ - uint8_t flags_lim; - - /* Bits 16-19 in the segment limiter. */ - uint8_t limit_19_16:4; + /* 4 bits flags + 4 bits limit*/ + uint8_t flags_lim; - uint8_t u:1; - uint8_t x:1; + /* Bits 16-19 in the segment limiter. */ + uint8_t limit_19_16:4; - /* D=0 16-bit segment, D=1, 32-bit */ - uint8_t d:1; + uint8_t u:1; + uint8_t x:1; + /* D=0 16-bit segment, D=1, 32-bit */ + uint8_t d:1; - /* Granularity G=0 1 byte, G=1 4KB */ - uint8_t g:1; - uint8_t base_addr_31_24; + /* Granularity G=0 1 byte, G=1 4KB */ + uint8_t g:1; + uint8_t base_addr_31_24; } __attribute__((__packed__)); /* Build a 4KB granular segment descriptor. */