From e2e1558a02e410c6c54b62014b2df6096a6f7949 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Thu, 21 Apr 2016 12:37:24 +1200 Subject: [PATCH] EFI: stub functions so we can call loader's main() function. --- build/jam/ArchitectureRules | 2 +- src/system/boot/platform/efi/Jamfile | 15 ++++++-- src/system/boot/platform/efi/console.cpp | 15 +++++--- src/system/boot/platform/efi/debug.cpp | 44 ++++++++++++++++++++++++ src/system/boot/platform/efi/devices.cpp | 39 +++++++++++++++++++++ src/system/boot/platform/efi/heap.cpp | 22 ++++++++++++ src/system/boot/platform/efi/menu.cpp | 40 +++++++++++++++++++++ src/system/boot/platform/efi/mmu.cpp | 25 ++++++++++++++ src/system/boot/platform/efi/start.cpp | 32 +++++++++++++++-- src/system/boot/platform/efi/video.cpp | 41 ++++++++++++++++++++++ 10 files changed, 263 insertions(+), 12 deletions(-) create mode 100644 src/system/boot/platform/efi/debug.cpp create mode 100644 src/system/boot/platform/efi/devices.cpp create mode 100644 src/system/boot/platform/efi/heap.cpp create mode 100644 src/system/boot/platform/efi/menu.cpp create mode 100644 src/system/boot/platform/efi/mmu.cpp create mode 100644 src/system/boot/platform/efi/video.cpp diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index c0c35a1375..6e8564dc18 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -419,7 +419,7 @@ rule KernelArchitectureSetup architecture -maccumulate-outgoing-args -Wno-error=unused-variable ; HAIKU_BOOT_C++FLAGS += -fpic -fno-stack-protector -fPIC -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -Wno-error=unused-variable ; - HAIKU_BOOT_LDFLAGS = -Bstatic -Bsymbolic -shared -nostdlib -znocombreloc -nostartfiles ; + HAIKU_BOOT_LDFLAGS = -Bstatic -Bsymbolic -shared -nostdlib -znocombreloc -nostartfiles -no-undefined ; } else { HAIKU_BOOT_CCFLAGS += -fno-pic ; HAIKU_BOOT_C++FLAGS += -fno-pic ; diff --git a/src/system/boot/platform/efi/Jamfile b/src/system/boot/platform/efi/Jamfile index c125fab3a9..38ee97d6bc 100644 --- a/src/system/boot/platform/efi/Jamfile +++ b/src/system/boot/platform/efi/Jamfile @@ -20,6 +20,12 @@ local platform_src = relocation_func.cpp start.cpp console.cpp + video.cpp + debug.cpp + mmu.cpp + heap.cpp + menu.cpp + devices.cpp ; Includes [ FGristFiles $(efi_glue_src) $(platform_src) ] @@ -36,6 +42,9 @@ BootMergeObject boot_platform_efi.o : : boot_platform_generic.a ; -SEARCH on [ FGristFiles relocation_func.cpp ] = [ FDirName $(SUBDIR) arch $(TARGET_ARCH) ] ; -LOCATE on [ FGristFiles $(efi_glue_src) ] = [ BuildFeatureAttribute gnuefi : libdir : path ] ; -Depends [ FGristFiles $(efi_glue_src) ] : [ BuildFeatureAttribute gnuefi : libdir ] ; +SEARCH on [ FGristFiles relocation_func.cpp ] + = [ FDirName $(SUBDIR) arch $(TARGET_ARCH) ] ; +LOCATE on [ FGristFiles $(efi_glue_src) ] + = [ BuildFeatureAttribute gnuefi : libdir : path ] ; +Depends [ FGristFiles $(efi_glue_src) ] + : [ BuildFeatureAttribute gnuefi : libdir ] ; diff --git a/src/system/boot/platform/efi/console.cpp b/src/system/boot/platform/efi/console.cpp index 47f1cd449d..c3a12138d0 100644 --- a/src/system/boot/platform/efi/console.cpp +++ b/src/system/boot/platform/efi/console.cpp @@ -1,6 +1,7 @@ /* * Copyright 2014-2016 Haiku, Inc. All rights reserved. - * Copyright 2013 Fredrik Holmqvist, fredrik.holmqvist@gmail.com. All rights reserved. + * Copyright 2013 Fredrik Holmqvist, fredrik.holmqvist@gmail.com. All rights + * reserved. * Distributed under the terms of the MIT License. */ @@ -22,8 +23,10 @@ class Console : public ConsoleNode { public: Console(); - virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize); - virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize); + virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, + size_t bufferSize); + virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, + size_t bufferSize); }; @@ -51,7 +54,8 @@ Console::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) ssize_t -Console::WriteAt(void *cookie, off_t /*pos*/, const void *buffer, size_t bufferSize) +Console::WriteAt(void *cookie, off_t /*pos*/, const void *buffer, + size_t bufferSize) { const char *string = (const char *)buffer; CHAR16 ucsBuffer[bufferSize + 3]; @@ -67,7 +71,8 @@ Console::WriteAt(void *cookie, off_t /*pos*/, const void *buffer, size_t bufferS //Not sure if we should keep going or abort for 0. //Keep going was easy anyway. ucsBuffer[j] = 0; - kSystemTable->ConOut->OutputString(kSystemTable->ConOut, ucsBuffer); + kSystemTable->ConOut->OutputString(kSystemTable->ConOut, + ucsBuffer); j = 0; continue; } diff --git a/src/system/boot/platform/efi/debug.cpp b/src/system/boot/platform/efi/debug.cpp new file mode 100644 index 0000000000..0a40169b8c --- /dev/null +++ b/src/system/boot/platform/efi/debug.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include +#include + +#include "efi_platform.h" + + +extern "C" void +dprintf(const char *format, ...) +{ +} + + +extern "C" void +panic(const char *format, ...) +{ + va_list args; + + platform_switch_to_text_mode(); + + puts("*** PANIC ***"); + + va_start(args, format); + vprintf(format, args); + va_end(args); + + while (true) + kBootServices->Stall(1000000); +} + + +char* +platform_debug_get_log_buffer(size_t *_size) +{ + return NULL; +} diff --git a/src/system/boot/platform/efi/devices.cpp b/src/system/boot/platform/efi/devices.cpp new file mode 100644 index 0000000000..de151c276c --- /dev/null +++ b/src/system/boot/platform/efi/devices.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + + +status_t +platform_add_boot_device(struct stage2_args *args, NodeList *devicesList) +{ + return B_ERROR; +} + + +status_t +platform_add_block_devices(struct stage2_args *args, NodeList *devicesList) +{ + return B_ERROR; +} + + +status_t +platform_get_boot_partition(struct stage2_args *args, Node *bootDevice, + NodeList *partitions, boot::Partition **_partition) +{ + panic("platform_get_boot_partition not implemented"); + return B_ERROR; +} + + +status_t +platform_register_boot_device(Node *device) +{ + panic("platform_register_boot_device not implemented"); + return B_ERROR; +} diff --git a/src/system/boot/platform/efi/heap.cpp b/src/system/boot/platform/efi/heap.cpp new file mode 100644 index 0000000000..282dab2d3d --- /dev/null +++ b/src/system/boot/platform/efi/heap.cpp @@ -0,0 +1,22 @@ +/* + * Copyright 2016 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + + +extern "C" void +platform_release_heap(struct stage2_args *args, void *base) +{ + return; +} + + +extern "C" status_t +platform_init_heap(struct stage2_args *args, void **_base, void **_top) +{ + return B_ERROR; +} diff --git a/src/system/boot/platform/efi/menu.cpp b/src/system/boot/platform/efi/menu.cpp new file mode 100644 index 0000000000..0b13b2dcc0 --- /dev/null +++ b/src/system/boot/platform/efi/menu.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2016 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + +#include "efi_platform.h" + + +void +platform_add_menus(Menu *menu) +{ + // No platform specific menus +} + + +void +platform_update_menu_item(Menu *menu, MenuItem *item) +{ + platform_generic_update_text_menu_item(menu, item); +} + + +void +platform_run_menu(Menu *menu) +{ + platform_generic_run_text_menu(menu); +} + + +size_t +platform_get_user_input_text(Menu *menu, MenuItem *item, char *buffer, + size_t bufferSize) +{ + return platform_generic_get_user_input_text(menu, item, buffer, + bufferSize); +} diff --git a/src/system/boot/platform/efi/mmu.cpp b/src/system/boot/platform/efi/mmu.cpp new file mode 100644 index 0000000000..28140d71fc --- /dev/null +++ b/src/system/boot/platform/efi/mmu.cpp @@ -0,0 +1,25 @@ +/* + * Copyright 2016 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + + +extern "C" status_t +platform_allocate_region(void **_virtualAddress, size_t size, uint8 protection, + bool exactAddress) +{ + panic("platform_allocate_region not implemented"); + return B_ERROR; +} + + +extern "C" status_t +platform_free_region(void *address, size_t size) +{ + panic("platform_free_region not implemented"); + return B_ERROR; +} diff --git a/src/system/boot/platform/efi/start.cpp b/src/system/boot/platform/efi/start.cpp index 09ddbf0b84..468baa1b0a 100644 --- a/src/system/boot/platform/efi/start.cpp +++ b/src/system/boot/platform/efi/start.cpp @@ -5,7 +5,9 @@ */ -#include +#include +#include +#include #include "console.h" #include "efi_platform.h" @@ -30,6 +32,27 @@ call_ctors(void) } +extern "C" uint32 +platform_boot_options() +{ + return 0; +} + + +extern "C" void +platform_start_kernel(void) +{ + panic("platform_start_kernel not implemented"); +} + + +extern "C" void +platform_exit(void) +{ + return; +} + + /** * efi_main - The entry point for the EFI application * @image: firmware-allocated handle that identifies the image @@ -38,16 +61,19 @@ call_ctors(void) extern "C" EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable) { + stage2_args args; + kSystemTable = systemTable; kBootServices = systemTable->BootServices; kRuntimeServices = systemTable->RuntimeServices; + memset(&args, 0, sizeof(stage2_args)); + call_ctors(); console_init(); - printf("Hello from EFI Loader for Haiku!\nPress any key to continue...\n"); - console_wait_for_key(); + main(&args); return EFI_SUCCESS; } diff --git a/src/system/boot/platform/efi/video.cpp b/src/system/boot/platform/efi/video.cpp new file mode 100644 index 0000000000..4523bd5749 --- /dev/null +++ b/src/system/boot/platform/efi/video.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2016, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + +#include "efi_platform.h" + + +extern "C" status_t +platform_init_video(void) +{ + return B_ERROR; +} + + +extern "C" void +platform_switch_to_logo(void) +{ +} + + +extern "C" void +platform_blit4(addr_t frameBuffer, const uint8 *data, + uint16 width, uint16 height, uint16 imageWidth, + uint16 left, uint16 top) +{ + panic("platform_blit4 unsupported"); + return; +} + + +extern "C" void +platform_set_palette(const uint8 *palette) +{ + panic("platform_set_palette unsupported"); + return; +}