comparison gnu-efi-3.0.12/apps/bootloader.c @ 7:f422d46482db

run into the kernel but it crashed
author kono
date Fri, 19 Jan 2024 15:48:18 +0900
parents 117ef669f2ce
children c4198b641a84
comparison
equal deleted inserted replaced
6:117ef669f2ce 7:f422d46482db
19 UINTN MapSize; 19 UINTN MapSize;
20 UINTN MapKey; 20 UINTN MapKey;
21 UINTN DescriptorSize; 21 UINTN DescriptorSize;
22 UINT32 DescriptorVersion; 22 UINT32 DescriptorVersion;
23 }; 23 };
24
25 void HexDump(UINT8 *bytePtr, UINTN size) {
26 for (UINTN i = 0; i < size; i++) {
27 if (i % 16 == 0 && i != 0) {
28 Print(L"\n");
29 }
30 Print(L"%02x ", bytePtr[i]);
31 }
32 Print(L"\n");
33 }
24 34
25 35
26 EFI_STATUS LoadFile(CHAR16 *FileName, EFI_PHYSICAL_ADDRESS *FileAddr, UINTN *FilePageSize) { 36 EFI_STATUS LoadFile(CHAR16 *FileName, EFI_PHYSICAL_ADDRESS *FileAddr, UINTN *FilePageSize) {
27 EFI_STATUS Status; 37 EFI_STATUS Status;
28 EFI_FILE_IO_INTERFACE *IOVolume; 38 EFI_FILE_IO_INTERFACE *IOVolume;
117 return Status; 127 return Status;
118 } 128 }
119 Print(L"Boot 1\n"); 129 Print(L"Boot 1\n");
120 130
121 struct BootParam boot_param; 131 struct BootParam boot_param;
122 boot_param.kernel_addr = KernelBaseAddr; 132 KernelBaseAddr = (EFI_PHYSICAL_ADDRESS ) ((UINT64)KernelBaseAddr + 0x1000);
123 boot_param.kernel_entry = KernelBaseAddr; 133 boot_param.kernel_addr = KernelBaseAddr ;
134 boot_param.kernel_entry = boot_param.kernel_addr ;
124 // GetGraphicMode(ImageHandle, &(boot_param.graphic_config)); 135 // GetGraphicMode(ImageHandle, &(boot_param.graphic_config));
125 136
126 typedef unsigned long (EntryPoint)(struct BootParam*); 137 typedef unsigned long (EntryPoint)(struct BootParam*);
127 EntryPoint *Entry = (EntryPoint*)(KernelBaseAddr); 138 EntryPoint *Entry = (EntryPoint*)(KernelBaseAddr);
128 139
147 Print(L"Failed to get memory map.\n"); 158 Print(L"Failed to get memory map.\n");
148 return Status; 159 return Status;
149 } 160 }
150 Print(L"Boot 3\n"); 161 Print(L"Boot 3\n");
151 162
163 Print(L"Kernel Entry: %llx\n",boot_param.kernel_entry);
164 Print(L"RSDP Address: %llx\n",boot_param.rsdp_addr);
165 Print(L"Kernel Address: %llx\n",boot_param.kernel_addr);
166
167 HexDump((UINT8 *)KernelBaseAddr,0x100);
168
152 Status = uefi_call_wrapper(SystemTable->BootServices->ExitBootServices, 2, ImageHandle, MemoryMap.MapKey); 169 Status = uefi_call_wrapper(SystemTable->BootServices->ExitBootServices, 2, ImageHandle, MemoryMap.MapKey);
153 if (EFI_ERROR(Status)) { 170 if (EFI_ERROR(Status)) {
154 Print(L"Failed to exit boot services\n"); 171 Print(L"Failed to exit boot services\n");
155 return Status; 172 return Status;
156 } 173 }
157 174
158 Print(L"Start Entry\n");
159 Entry(&boot_param); 175 Entry(&boot_param);
160 176
161 return Status; 177 return Status;
162 } 178 }
163 179