diff --git a/Development/hex0.c b/Development/hex0.c index 5073296..e66173a 100644 --- a/Development/hex0.c +++ b/Development/hex0.c @@ -19,6 +19,13 @@ efi_status_t efi_main(efi_handle_t image_handle, struct efi_system_table *system system->boot->open_protocol(image_handle, &guid1, (void **) &image, image_handle, 0, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + /* Get root file system */ + efi_handle_t root_device = image->device; + system->boot->open_protocol(root_device, &guid2, (void **) &rootfs, image_handle, 0, + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + /* Get root directory */ + rootfs->open_volume(rootfs, &rootdir); + /* Command line args */ uint16_t *options = image->load_options; uint16_t *in; @@ -33,13 +40,6 @@ efi_status_t efi_main(efi_handle_t image_handle, struct efi_system_table *system *options = 0; out = ++options; - /* Get root file system */ - efi_handle_t root_device = image->device; - system->boot->open_protocol(root_device, &guid2, (void **) &rootfs, image_handle, 0, - EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); - /* Get root directory */ - rootfs->open_volume(rootfs, &rootdir); - /* Open file for writing */ struct efi_file_protocol *fout; rootdir->open(rootdir, &fout, out, EFI_FILE_MODE_CREATE| EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0); diff --git a/Development/hex2.c b/Development/hex2.c index dddfa51..b6c97e0 100644 --- a/Development/hex2.c +++ b/Development/hex2.c @@ -356,6 +356,13 @@ efi_status_t efi_main(efi_handle_t image_handle, struct efi_system_table *system boot->open_protocol(image_handle, &guid1, (void **) &image, image_handle, 0, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + /* Get root file system */ + efi_handle_t root_device = image->device; + boot->open_protocol(root_device, &guid2, (void **) &rootfs, image_handle, 0, + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + /* Get root directory */ + rootfs->open_volume(rootfs, &rootdir); + /* Command line args */ uint16_t *options = image->load_options; uint16_t *in; @@ -370,12 +377,6 @@ efi_status_t efi_main(efi_handle_t image_handle, struct efi_system_table *system *options = 0; out = ++options; - /* Get root file system */ - efi_handle_t root_device = image->device; - boot->open_protocol(root_device, &guid2, (void **) &rootfs, image_handle, 0, - EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); - /* Get root directory */ - rootfs->open_volume(rootfs, &rootdir); /* Open file for writing */ struct efi_file_protocol *fout; diff --git a/Development/kaem-minimal.c b/Development/kaem-minimal.c index c744a8b..0e76fa8 100644 --- a/Development/kaem-minimal.c +++ b/Development/kaem-minimal.c @@ -29,6 +29,13 @@ efi_status_t efi_main(efi_handle_t image_handle, struct efi_system_table *system system->boot->open_protocol(image_handle, &guid1, (void **) &image, image_handle, 0, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + /* Get root file system */ + efi_handle_t root_device = image->device; + system->boot->open_protocol(root_device, &guid2, (void **) &rootfs, image_handle, 0, + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + /* Get root directory */ + rootfs->open_volume(rootfs, &rootdir); + /* Command line args */ uint16_t *options = image->load_options; uint16_t default_file[] = L"kaem.amd64"; @@ -44,13 +51,6 @@ efi_status_t efi_main(efi_handle_t image_handle, struct efi_system_table *system script_file = ++options; } - /* Get root file system */ - efi_handle_t root_device = image->device; - system->boot->open_protocol(root_device, &guid2, (void **) &rootfs, image_handle, 0, - EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); - /* Get root directory */ - rootfs->open_volume(rootfs, &rootdir); - /* Open file for reading */ struct efi_file_protocol *fin; efi_status_t status = rootdir->open(rootdir, &fin, script_file, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY);