#include <uefi.h>
/* this is implemented by the application */
-extern int main(int argc, char_t **argv);
-
-/* definitions for elf relocations */
-typedef uint64_t Elf64_Xword;
-typedef int64_t Elf64_Sxword;
-typedef uint64_t Elf64_Addr;
-typedef struct
-{
- Elf64_Sxword d_tag; /* Dynamic entry type */
- union
- {
- Elf64_Xword d_val; /* Integer value */
- Elf64_Addr d_ptr; /* Address value */
- } d_un;
-} Elf64_Dyn;
-#define DT_NULL 0 /* Marks end of dynamic section */
-#define DT_RELA 7 /* Address of Rela relocs */
-#define DT_RELASZ 8 /* Total size of Rela relocs */
-#define DT_RELAENT 9 /* Size of one Rela reloc */
-typedef struct
-{
- Elf64_Addr r_offset; /* Address */
- Elf64_Xword r_info; /* Relocation type and symbol index */
-} Elf64_Rel;
-#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
-#define R_X86_64_RELATIVE 8 /* Adjust by program base */
+extern int main(void);
/* globals to store system table pointers */
-efi_handle_t IM = NULL;
-efi_system_table_t *ST = NULL;
-efi_boot_services_t *BS = NULL;
-efi_runtime_services_t *RT = NULL;
-efi_loaded_image_protocol_t *LIP = NULL;
+static efi_handle_t IM = NULL;
+static efi_system_table_t *ST = NULL;
+static efi_boot_services_t *BS = NULL;
+static efi_runtime_services_t *RT = NULL;
+static efi_loaded_image_protocol_t *LIP = NULL;
/* platform specific globals */
VideoConfig Video = {0};
*
*/
+/* definitions for elf relocations */
+typedef uint64_t Elf64_Xword;
+typedef int64_t Elf64_Sxword;
+typedef uint64_t Elf64_Addr;
+typedef struct
+{
+ Elf64_Sxword d_tag; /* Dynamic entry type */
+ union
+ {
+ Elf64_Xword d_val; /* Integer value */
+ Elf64_Addr d_ptr; /* Address value */
+ } d_un;
+} Elf64_Dyn;
+#define DT_NULL 0 /* Marks end of dynamic section */
+#define DT_RELA 7 /* Address of Rela relocs */
+#define DT_RELASZ 8 /* Total size of Rela relocs */
+#define DT_RELAENT 9 /* Size of one Rela reloc */
+typedef struct
+{
+ Elf64_Addr r_offset; /* Address */
+ Elf64_Xword r_info; /* Relocation type and symbol index */
+} Elf64_Rel;
+#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
+#define R_X86_64_RELATIVE 8 /* Adjust by program base */
+
int uefi_init(uintptr_t ldbase, Elf64_Dyn *dyn, efi_system_table_t *systab, efi_handle_t image)
{
- efi_guid_t shpGuid = EFI_SHELL_PARAMETERS_PROTOCOL_GUID;
- efi_shell_parameters_protocol_t *shp = NULL;
- efi_guid_t shiGuid = SHELL_INTERFACE_PROTOCOL_GUID;
- efi_shell_interface_protocol_t *shi = NULL;
efi_guid_t lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
- efi_guid_t gopGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
efi_status_t status;
long relsz = 0, relent = 0;
/* perform some initialization for the kernel */
video_init();
- return main(0, 0);
+ /* now jump to kernel main() */
+ return main();
}
/* we only need one .o file, so use inline Assembly here */
efi_query_capsule_capabilities_t QueryCapsuleCapabilities;
efi_query_variable_info_t QueryVariableInfo;
} efi_runtime_services_t;
-extern efi_runtime_services_t *RT;
-#define gRT RT
/** Boot Services ***/
typedef struct {
efi_calculate_crc32_t CalculateCrc32;
} efi_boot_services_t;
-extern efi_boot_services_t *BS;
-#define gBS BS
/*** Loaded Image Protocol ***/
#ifndef EFI_LOADED_IMAGE_PROTOCOL_GUID
efi_memory_type_t ImageCodeType;
efi_memory_type_t ImageDataType;
} efi_loaded_image_protocol_t;
-extern efi_loaded_image_protocol_t *LIP;
-extern efi_handle_t IM;
/*** System Table ***/
typedef struct {
uintn_t NumberOfTableEntries;
efi_configuration_table_t *ConfigurationTable;
} efi_system_table_t;
-extern efi_system_table_t *ST;
-#define gST ST
/*** Simple File System Protocol ***/
#ifndef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
efi_gop_mode_t *Mode;
} efi_gop_t;
-extern efi_gop_t *GOP;
-
/*** Simple Pointer Protocol (not used, but could be useful to have) ***/
#ifndef EFI_SIMPLE_POINTER_PROTOCOL_GUID
#define EFI_SIMPLE_POINTER_PROTOCOL_GUID { 0x31878c87, 0xb75, 0x11d5, { 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }