comparison gnu-efi-3.0.12/apps/bootloader.c @ 6:117ef669f2ce

...
author kono
date Fri, 19 Jan 2024 11:25:58 +0900
parents 209a1a162228
children f422d46482db
comparison
equal deleted inserted replaced
5:209a1a162228 6:117ef669f2ce
52 } 52 }
53 53
54 // Now open a file 54 // Now open a file
55 Status = uefi_call_wrapper(Root->Open, 5, Root, &File,FileName , EFI_FILE_MODE_READ, 0); 55 Status = uefi_call_wrapper(Root->Open, 5, Root, &File,FileName , EFI_FILE_MODE_READ, 0);
56 if (EFI_ERROR(Status)) { 56 if (EFI_ERROR(Status)) {
57 Print(L"Failed to open file: %r\n", Status); 57 // Print(L"Failed to open file: %r\n", Status);
58 uefi_call_wrapper(Root->Close, 1, Root); 58 uefi_call_wrapper(Root->Close, 1, Root);
59 continue; 59 continue;
60 } 60 }
61 61
62 EFI_FILE_INFO *FileInfo; 62 EFI_FILE_INFO *FileInfo;
114 114
115 Status = LoadFile(KernelFileName, &KernelBaseAddr, &BufferPageSize); 115 Status = LoadFile(KernelFileName, &KernelBaseAddr, &BufferPageSize);
116 if (EFI_ERROR(Status)) { 116 if (EFI_ERROR(Status)) {
117 return Status; 117 return Status;
118 } 118 }
119 Print(L"Boot 1\n");
119 120
120 struct BootParam boot_param; 121 struct BootParam boot_param;
121 boot_param.kernel_addr = KernelBaseAddr; 122 boot_param.kernel_addr = KernelBaseAddr;
122 boot_param.kernel_entry = KernelBaseAddr; 123 boot_param.kernel_entry = KernelBaseAddr;
123 // GetGraphicMode(ImageHandle, &(boot_param.graphic_config)); 124 // GetGraphicMode(ImageHandle, &(boot_param.graphic_config));
130 // if (EFI_ERROR(Status)) { 131 // if (EFI_ERROR(Status)) {
131 // Print(L"Failed to get system configuration table.\n"); 132 // Print(L"Failed to get system configuration table.\n");
132 // return Status; 133 // return Status;
133 // } 134 // }
134 // boot_param.rsdp_addr = (UINT64)vendor_table; 135 // boot_param.rsdp_addr = (UINT64)vendor_table;
136 Print(L"Boot 2\n");
135 137
136 struct MemoryMap MemoryMap = {4096, NULL, 4096, 0, 0, 0}; 138 struct MemoryMap MemoryMap = {4096, NULL, 4096, 0, 0, 0};
137 Status = uefi_call_wrapper(SystemTable->BootServices->AllocatePool, 3, EfiLoaderData, MemoryMap.BufferSize, &MemoryMap.Buffer); 139 Status = uefi_call_wrapper(SystemTable->BootServices->AllocatePool, 3, EfiLoaderData, MemoryMap.BufferSize, &MemoryMap.Buffer);
138 if (EFI_ERROR(Status)) { 140 if (EFI_ERROR(Status)) {
139 Print(L"Failed to allocate memory to get memory map\n"); 141 Print(L"Failed to allocate memory to get memory map\n");
143 Status = uefi_call_wrapper(SystemTable->BootServices->GetMemoryMap, 5, &MemoryMap.MapSize, (EFI_MEMORY_DESCRIPTOR*)MemoryMap.Buffer, &MemoryMap.MapKey, &MemoryMap.DescriptorSize, &MemoryMap.DescriptorVersion); 145 Status = uefi_call_wrapper(SystemTable->BootServices->GetMemoryMap, 5, &MemoryMap.MapSize, (EFI_MEMORY_DESCRIPTOR*)MemoryMap.Buffer, &MemoryMap.MapKey, &MemoryMap.DescriptorSize, &MemoryMap.DescriptorVersion);
144 if (EFI_ERROR(Status)) { 146 if (EFI_ERROR(Status)) {
145 Print(L"Failed to get memory map.\n"); 147 Print(L"Failed to get memory map.\n");
146 return Status; 148 return Status;
147 } 149 }
150 Print(L"Boot 3\n");
148 151
149 Status = uefi_call_wrapper(SystemTable->BootServices->ExitBootServices, 2, ImageHandle, MemoryMap.MapKey); 152 Status = uefi_call_wrapper(SystemTable->BootServices->ExitBootServices, 2, ImageHandle, MemoryMap.MapKey);
150 if (EFI_ERROR(Status)) { 153 if (EFI_ERROR(Status)) {
151 Print(L"Failed to exit boot services\n"); 154 Print(L"Failed to exit boot services\n");
152 return Status; 155 return Status;
153 } 156 }
154 157
158 Print(L"Start Entry\n");
155 Entry(&boot_param); 159 Entry(&boot_param);
156 160
157 return Status; 161 return Status;
158 } 162 }
159 163