MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / GetDebugLogFile

Function GetDebugLogFile

rEFIt_UEFI/Platform/BootLog.cpp:62–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60
61
62EFI_FILE_PROTOCOL* GetDebugLogFile()
63{
64 EFI_STATUS Status;
65 EFI_LOADED_IMAGE *LoadedImage;
66 EFI_FILE_PROTOCOL *RootDir;
67 EFI_FILE_PROTOCOL *LogFile;
68
69 // get RootDir from device we are loaded from
70 Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
71 if (EFI_ERROR(Status)) {
72 return NULL;
73 }
74 RootDir = EfiLibOpenRoot(LoadedImage->DeviceHandle);
75 if (RootDir == NULL) {
76 return NULL;
77 }
78
79 // Open log file from current root
80 Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG,
81 EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
82
83 // If the log file is not found try to create it
84 if (Status == EFI_NOT_FOUND) {
85 Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG,
86 EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
87 }
88 RootDir->Close(RootDir);
89 RootDir = NULL;
90
91 if (EFI_ERROR(Status)) {
92 // try on first EFI partition
93 Status = egFindESP(&RootDir);
94 if (!EFI_ERROR(Status)) {
95 Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG,
96 EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
97 // If the log file is not found try to create it
98 if (Status == EFI_NOT_FOUND) {
99 Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG,
100 EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
101 }
102 RootDir->Close(RootDir);
103 RootDir = NULL;
104 }
105 }
106
107 if (EFI_ERROR(Status)) {
108 LogFile = NULL;
109 }
110
111 return LogFile;
112}
113
114
115VOID SaveMessageToDebugLogFile(IN CHAR8 *LastMessage)

Callers 1

Calls 4

egFindESPFunction · 0.85
EfiLibOpenRootFunction · 0.50
OpenMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected