2121#include < stdio.h>
2222#include < string.h>
2323#include < uefi/boot_service.h>
24+ #include < uefi/protocols/device_path_protocol.h>
2425#include < uefi/protocols/loaded_image_protocol.h>
2526#include < uefi/types.h>
2627
27- #include " boot_service_provider.h"
2828#include " uefi_platform.h"
2929
3030struct EFI_DEVICE_PATH_FILE_PATH_PROTOCOL {
31- struct EFI_DEVICE_PATH_PROTOCOL dp;
31+ EfiDevicePathProtocol dp;
3232 uint16_t str[];
3333};
3434
@@ -79,7 +79,7 @@ static uint32_t efi_m_max_table_entries;
7979static constexpr size_t EFI_DEBUG_TABLE_ENTRY_SIZE = (sizeof (union EfiDebugImageInfo));
8080
8181EfiStatus efi_core_new_debug_image_info_entry (uint32_t image_info_type,
82- struct EFI_LOADED_IMAGE_PROTOCOL *loaded_image,
82+ EfiLoadedImageProtocol *loaded_image,
8383 EfiHandle image_handle) {
8484 /* Set the flag indicating that we're in the process of updating
8585 * the table.
@@ -198,38 +198,38 @@ EfiStatus setup_debug_support(EfiSystemTable &table,
198198 char *image_base,
199199 size_t virtual_size,
200200 bdev_t *dev) {
201- struct EFI_LOADED_IMAGE_PROTOCOL *efiLoadedImageProtocol = nullptr ;
201+ EfiLoadedImageProtocol *efiLoadedImageProtocol = nullptr ;
202202
203203 allocate_pool (EFI_MEMORY_TYPE_BOOT_SERVICES_DATA,
204- sizeof (struct EFI_LOADED_IMAGE_PROTOCOL ),
204+ sizeof (EfiLoadedImageProtocol ),
205205 reinterpret_cast <void **>(&efiLoadedImageProtocol));
206- memset (efiLoadedImageProtocol, 0 , sizeof (struct EFI_LOADED_IMAGE_PROTOCOL ));
206+ memset (efiLoadedImageProtocol, 0 , sizeof (EfiLoadedImageProtocol ));
207207
208- efiLoadedImageProtocol->Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
209- efiLoadedImageProtocol->SystemTable = &table;
210- efiLoadedImageProtocol->ImageBase = reinterpret_cast <void *>(image_base);
211- efiLoadedImageProtocol->ImageSize = virtual_size;
208+ efiLoadedImageProtocol->revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
209+ efiLoadedImageProtocol->system_table = &table;
210+ efiLoadedImageProtocol->image_base = reinterpret_cast <void *>(image_base);
211+ efiLoadedImageProtocol->image_size = virtual_size;
212212 char *device_buf = nullptr ;
213- size_t fpsize = sizeof (struct EFI_DEVICE_PATH_PROTOCOL ) + 2 * (strlen (dev->name ) + 2 );
213+ size_t fpsize = sizeof (EfiDevicePathProtocol ) + 2 * (strlen (dev->name ) + 2 );
214214 allocate_pool (EFI_MEMORY_TYPE_BOOT_SERVICES_DATA,
215- fpsize + sizeof (struct EFI_DEVICE_PATH_PROTOCOL ),
215+ fpsize + sizeof (EfiDevicePathProtocol ),
216216 reinterpret_cast <void **>(&device_buf));
217- memset (device_buf, 0 , fpsize + sizeof (struct EFI_DEVICE_PATH_PROTOCOL ));
217+ memset (device_buf, 0 , fpsize + sizeof (EfiDevicePathProtocol ));
218218 struct EFI_DEVICE_PATH_FILE_PATH_PROTOCOL *fp = reinterpret_cast <struct EFI_DEVICE_PATH_FILE_PATH_PROTOCOL *>(device_buf);
219- struct EFI_DEVICE_PATH_PROTOCOL *dp_end = reinterpret_cast <struct EFI_DEVICE_PATH_PROTOCOL *>(device_buf + fpsize);
220- fp->dp .Type = EFI_DEVICE_PATH_TYPE_MEDIA_DEVICE;
221- fp->dp .SubType = EFI_DEVICE_PATH_SUB_TYPE_FILE_PATH;
222- fp->dp .Length [0 ] = fpsize % 256 ;
223- fp->dp .Length [1 ] = fpsize / 256 ;
219+ struct EfiDevicePathProtocol *dp_end = reinterpret_cast <EfiDevicePathProtocol *>(device_buf + fpsize);
220+ fp->dp .type = EFI_DEVICE_PATH_TYPE_MEDIA_DEVICE;
221+ fp->dp .sub_type = EFI_DEVICE_PATH_SUB_TYPE_FILE_PATH;
222+ fp->dp .length [0 ] = fpsize % 256 ;
223+ fp->dp .length [1 ] = fpsize / 256 ;
224224 fp->str [0 ] = ' \\ ' ;
225225 for (size_t i = 0 ; i < strlen (dev->name ); i++) {
226226 fp->str [i+1 ] = dev->name [i];
227227 }
228- dp_end->Type = EFI_DEVICE_PATH_TYPE_END;
229- dp_end->SubType = EFI_DEVICE_PATH_SUB_TYPE_END;
230- dp_end->Length [0 ] = sizeof (struct EFI_DEVICE_PATH_PROTOCOL ) % 256 ;
231- dp_end->Length [1 ] = sizeof (struct EFI_DEVICE_PATH_PROTOCOL ) / 256 ;
232- efiLoadedImageProtocol->FilePath = reinterpret_cast <struct EFI_DEVICE_PATH_PROTOCOL *>(device_buf);
228+ dp_end->type = EFI_DEVICE_PATH_TYPE_END;
229+ dp_end->sub_type = EFI_DEVICE_PATH_SUB_TYPE_END;
230+ dp_end->length [0 ] = sizeof (EfiDevicePathProtocol ) % 256 ;
231+ dp_end->length [1 ] = sizeof (EfiDevicePathProtocol ) / 256 ;
232+ efiLoadedImageProtocol->file_path = reinterpret_cast <EfiDevicePathProtocol *>(device_buf);
233233 return efi_core_new_debug_image_info_entry (EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
234234 efiLoadedImageProtocol,
235235 image_base);
@@ -242,8 +242,8 @@ void teardown_debug_support(char *image_base) {
242242 if (table[index].normal_image &&
243243 table[index].normal_image ->image_handle == image_base) {
244244 /* Found a match. Get device_buf and efiLoadedImageProtocol. */
245- struct EFI_LOADED_IMAGE_PROTOCOL *efiLoadedImageProtocol = table[index].normal_image ->loaded_image_protocol_instance ;
246- char *device_buf = reinterpret_cast <char *>(efiLoadedImageProtocol->FilePath );
245+ EfiLoadedImageProtocol *efiLoadedImageProtocol = table[index].normal_image ->loaded_image_protocol_instance ;
246+ char *device_buf = reinterpret_cast <char *>(efiLoadedImageProtocol->file_path );
247247 /* Free resources */
248248 efi_core_remove_debug_image_info_entry (image_base);
249249 free_pool (device_buf);
0 commit comments