1 #include <efi.h> 2 #include <efilib.h> 3 #include <dragonstub/printk.h> 4 #include <dragonstub/dragonstub.h> 5 6 void print_dragonstub_banner(void); 7 8 EFI_STATUS 9 efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab) 10 { 11 EFI_STATUS status; 12 EFI_LOADED_IMAGE *loaded_image = NULL; 13 /* addr/point and size pairs for memory management*/ 14 char *cmdline_ptr = NULL; 15 16 InitializeLib(image_handle, systab); 17 18 print_dragonstub_banner(); 19 20 efi_info("EFI env initialized\n"); 21 22 /* 23 * Get a handle to the loaded image protocol. This is used to get 24 * information about the running image, such as size and the command 25 * line. 26 */ 27 status = uefi_call_wrapper(BS->OpenProtocol, 6, image_handle, 28 &LoadedImageProtocol, (void **)&loaded_image, 29 image_handle, NULL, 30 EFI_OPEN_PROTOCOL_GET_PROTOCOL); 31 if (EFI_ERROR(status)) { 32 efi_err("Could not open loaded image protocol: %d\n", status); 33 return status; 34 } 35 36 efi_info("Loaded image protocol opened\n"); 37 38 status = efi_handle_cmdline(loaded_image, &cmdline_ptr); 39 40 if (EFI_ERROR(status)) { 41 efi_err("Could not get command line: %d\n", status); 42 return status; 43 } 44 if (cmdline_ptr == NULL) 45 efi_warn("Command line is NULL\n"); 46 else 47 efi_info("Command line: %s\n", cmdline_ptr); 48 49 efi_info("Booting DragonOS kernel...\n"); 50 51 efi_todo("Boot DragonOS kernel"); 52 53 return EFI_SUCCESS; 54 } 55 56 /// @brief Print thr DragonStub banner 57 void print_dragonstub_banner(void) 58 { 59 efi_printk( 60 " ____ ____ _ _ \n"); 61 efi_printk( 62 "| _ \\ _ __ __ _ __ _ ___ _ __ / ___|| |_ _ _| |__ \n"); 63 efi_printk( 64 "| | | | '__/ _` |/ _` |/ _ \\| '_ \\\\___ \\| __| | | | '_ \\ \n"); 65 efi_printk( 66 "| |_| | | | (_| | (_| | (_) | | | |___) | |_| |_| | |_) |\n"); 67 efi_printk( 68 "|____/|_| \\__,_|\\__, |\\___/|_| |_|____/ \\__|\\__,_|_.__/ \n"); 69 efi_printk( 70 " |___/ \n"); 71 } 72