2020-09-28 17:57:50 +02:00
|
|
|
/*
|
|
|
|
* Self.h
|
|
|
|
*
|
|
|
|
* Created on: Sep 28, 2020
|
|
|
|
* Author: jief
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLATFORM_SELF_H_
|
|
|
|
#define PLATFORM_SELF_H_
|
|
|
|
|
2021-02-07 15:39:03 +01:00
|
|
|
#include "../cpp_foundation/XString.h"
|
2023-11-18 11:04:54 +01:00
|
|
|
#include "../cpp_foundation/apd.h"
|
2021-02-06 18:16:46 +01:00
|
|
|
extern "C" {
|
|
|
|
#include <Uefi/UefiSpec.h>
|
|
|
|
#include <Protocol/LoadedImage.h>
|
|
|
|
#include <Protocol/DevicePath.h>
|
2021-02-07 15:39:03 +01:00
|
|
|
#include <Protocol/SimpleFileSystem.h>
|
2021-02-06 18:16:46 +01:00
|
|
|
}
|
2020-09-28 17:57:50 +02:00
|
|
|
|
|
|
|
class Self
|
|
|
|
{
|
2021-05-23 12:20:30 +02:00
|
|
|
// Class method, usable even without any instance of Self.
|
2020-09-28 17:57:50 +02:00
|
|
|
protected:
|
2021-09-28 15:54:31 +02:00
|
|
|
static EFI_STATUS __initialize(XBool debugMsg, EFI_HANDLE m_SelfImageHandle, EFI_LOADED_IMAGE** m_SelfLoadedImage, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL** m_SelfSimpleVolumePtr, EFI_FILE** m_SelfVolumeRootDirPtr, XStringW* m_CloverDirFullPathPtr, XStringW* m_efiFileNamePtr, EFI_FILE** m_CloverDirPtr);
|
2021-05-23 12:20:30 +02:00
|
|
|
public:
|
|
|
|
static const EFI_FILE_PROTOCOL* getCloverDirAndEfiFileName(EFI_HANDLE ImageHandle, XStringW* efiFileName);
|
2020-10-03 19:02:31 +02:00
|
|
|
|
2021-05-23 12:20:30 +02:00
|
|
|
protected:
|
|
|
|
EFI_HANDLE m_SelfImageHandle {}; // this efi.
|
2023-11-18 11:04:54 +01:00
|
|
|
EFI_LOADED_IMAGE* m_SelfLoadedImage = NULL; // this efi.
|
|
|
|
apd<EFI_DEVICE_PATH*> m_SelfDevicePath = NULL; // path to device containing this efi.
|
2021-05-23 12:20:30 +02:00
|
|
|
// XStringW m_SelfDevicePathAsXStringW; // path to device containing this efi.
|
2020-10-03 19:02:31 +02:00
|
|
|
|
2021-05-23 12:20:30 +02:00
|
|
|
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* m_SelfSimpleVolume {}; // Volume containing this efi.
|
|
|
|
EFI_FILE* m_SelfVolumeRootDir {}; // Root dir of the volume containing this efi.
|
2020-10-03 19:02:31 +02:00
|
|
|
|
2021-05-23 12:20:30 +02:00
|
|
|
XStringW m_efiFileName = {};
|
|
|
|
EFI_DEVICE_PATH* m_CloverDirFullDevicePath {}; // full path, including device, of the folder containing this efi.
|
|
|
|
EFI_FILE* m_CloverDir {}; // opened folder containing this efi
|
|
|
|
XStringW m_CloverDirFullPath {}; // full path of folder containing this efi.
|
2021-09-27 08:39:06 +02:00
|
|
|
XStringW m_CloverDirFullPath4Display {}; // prettier for diplay
|
2020-10-03 19:02:31 +02:00
|
|
|
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool m_ThemesDirExists {};
|
2021-05-23 12:20:30 +02:00
|
|
|
EFI_FILE *m_ThemesDir {};
|
2020-10-03 19:02:31 +02:00
|
|
|
|
2021-09-28 15:54:31 +02:00
|
|
|
EFI_STATUS _openDir(const XStringW& path, XBool* b, EFI_FILE** efiDir);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS _initialize();
|
2020-09-28 17:57:50 +02:00
|
|
|
|
|
|
|
public:
|
2021-05-23 12:20:30 +02:00
|
|
|
Self () {};
|
2020-09-28 17:57:50 +02:00
|
|
|
Self(const Self&) = delete;
|
|
|
|
Self& operator = (const Self&) = delete;
|
|
|
|
|
|
|
|
~Self () {};
|
|
|
|
|
|
|
|
EFI_STATUS initialize(EFI_HANDLE ImageHandle);
|
2020-10-03 19:02:31 +02:00
|
|
|
EFI_STATUS reInitialize();
|
|
|
|
void closeHandle();
|
|
|
|
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool isInitialized() const { return m_CloverDir != NULL; }
|
2020-11-24 13:41:47 +01:00
|
|
|
void checkInitialized() const
|
|
|
|
{
|
2022-01-23 13:19:15 +01:00
|
|
|
#ifdef JIEF_DEBUG
|
2020-11-24 13:41:47 +01:00
|
|
|
if ( !isInitialized() ) {
|
|
|
|
panic("Self in not initialized");
|
|
|
|
}
|
2021-02-21 14:49:09 +01:00
|
|
|
#endif
|
2020-11-24 13:41:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
EFI_HANDLE getSelfImageHandle() { checkInitialized(); return m_SelfImageHandle; }
|
|
|
|
const EFI_LOADED_IMAGE& getSelfLoadedImage() { checkInitialized(); return *m_SelfLoadedImage; }
|
|
|
|
EFI_HANDLE getSelfDeviceHandle() { checkInitialized(); return getSelfLoadedImage().DeviceHandle; }
|
|
|
|
const EFI_DEVICE_PATH& getSelfDevicePath() { checkInitialized(); return *m_SelfDevicePath; }
|
|
|
|
|
|
|
|
const EFI_SIMPLE_FILE_SYSTEM_PROTOCOL& getSelfSimpleVolume() { checkInitialized(); return *m_SelfSimpleVolume; }
|
|
|
|
const EFI_FILE& getSelfVolumeRootDir() { checkInitialized(); return *m_SelfVolumeRootDir; }
|
|
|
|
|
|
|
|
const XStringW& getCloverEfiFileName() { checkInitialized(); return m_efiFileName; }
|
|
|
|
const EFI_DEVICE_PATH& getCloverDirFullDevicePath() { checkInitialized(); return *m_CloverDirFullDevicePath; }
|
|
|
|
const EFI_FILE& getCloverDir() { checkInitialized(); return *m_CloverDir; }
|
|
|
|
const XStringW& getCloverDirFullPath() { checkInitialized(); return m_CloverDirFullPath; }
|
2021-09-27 08:39:06 +02:00
|
|
|
const XStringW& getCloverDirFullPath4Display() { checkInitialized(); return m_CloverDirFullPath4Display; }
|
2020-11-24 13:41:47 +01:00
|
|
|
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool themesDirExists() { checkInitialized(); return m_ThemesDirExists; }
|
2020-11-24 13:41:47 +01:00
|
|
|
const EFI_FILE& getThemesDir() { checkInitialized(); return *m_ThemesDir; }
|
2020-10-03 19:02:31 +02:00
|
|
|
|
2020-09-28 17:57:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Self self;
|
|
|
|
|
|
|
|
#endif /* PLATFORM_SELF_H_ */
|