165 if (PageTable == NULL) {
166 Error (NULL, 0, 4001,
"Resource",
"memory cannot be allocated!");
170 PageTablePtr = PageTable;
186 for (PML4Index = 0; PML4Index <
EFI_PML4_ENTRY_NUM; PML4Index++, PageMapLevel4Entry++) {
200 for (PDPTEIndex = 0; PDPTEIndex <
EFI_PDPTE_ENTRY_NUM; PDPTEIndex++, PageDirectoryPointerEntry++) {
214 for (PDEIndex = 0; PDEIndex <
EFI_PDE_ENTRY_NUM; PDEIndex++, PageDirectoryEntry2MB++) {
234 char *NoPageFileName,
257 unsigned long FileSize;
262 PageFile = fopen (PageFileName,
"w+b");
263 if (PageFile == NULL) {
264 Error (NoPageFileName, 0, 0x4002,
"Invalid parameter option",
"Output File %s open failure", PageFileName);
268 NoPageFile = fopen (NoPageFileName,
"r+b");
269 if (NoPageFile == NULL) {
270 Error (NoPageFileName, 0, 0x4002,
"Invalid parameter option",
"Input File %s open failure", NoPageFileName);
278 fseek (NoPageFile, 0, SEEK_END);
279 FileSize = ftell (NoPageFile);
280 fseek (NoPageFile, 0, SEEK_SET);
282 Error (NoPageFileName, 0, 0x4002,
"Invalid parameter option",
"Input file size (0x%lx) exceeds the Page Table Offset (0x%x)", FileSize, (
unsigned)
gPageTableOffsetInFile);
291 while (fread (&Data,
sizeof(
uint8_t), 1, NoPageFile)) {
292 fwrite (&Data,
sizeof(
uint8_t), 1, PageFile);
318 char *OutputFile = NULL;
319 char *InputFile = NULL;
330 if ((strcmp (argv[0],
"-h") == 0) || (strcmp (argv[0],
"--help") == 0)) {
335 if (strcmp (argv[0],
"--version") == 0) {
341 if ((strcmp (argv[0],
"-o") == 0) || (strcmp (argv[0],
"--output") == 0)) {
342 if (argv[1] == NULL || argv[1][0] ==
'-') {
343 Error (NULL, 0, 1003,
"Invalid option value",
"Output file is missing for -o option");
346 OutputFile = argv[1];
352 if ((strcmp (argv[0],
"-b") == 0) || (strcmp (argv[0],
"--baseaddr") == 0)) {
353 if (argv[1] == NULL || argv[1][0] ==
'-') {
354 Error (NULL, 0, 1003,
"Invalid option value",
"Base address is missing for -b option");
357 TempValue = strtoull (argv[1], NULL, 0);
364 if ((strcmp (argv[0],
"-f") == 0) || (strcmp (argv[0],
"--offset") == 0)) {
365 if (argv[1] == NULL || argv[1][0] ==
'-') {
366 Error (NULL, 0, 1003,
"Invalid option value",
"Offset is missing for -f option");
369 TempValue = strtoull (argv[1], NULL, 0);
376 if ((strcmp (argv[0],
"-q") == 0) || (strcmp (argv[0],
"--quiet") == 0)) {
382 if ((strcmp (argv[0],
"-v") ==0) || (strcmp (argv[0],
"--verbose") == 0)) {
388 if ((strcmp (argv[0],
"-d") == 0) || (strcmp (argv[0],
"--debug") == 0)) {
389 if (argv[1] == NULL || argv[1][0] ==
'-') {
390 Error (NULL, 0, 1003,
"Invalid option value",
"Debug Level is not specified.");
393 TempValue = strtoull (argv[1], NULL, 0);
395 Error (NULL, 0, 1003,
"Invalid option value",
"Debug Level range is 0-9, currnt input level is %d", (
int) TempValue);
403 if (argv[0][0] ==
'-') {
404 Error (NULL, 0, 1000,
"Unknown option", argv[0]);
416 if (InputFile == NULL) {
417 Error (NULL, 0, 1003,
"Invalid option value",
"Input file is not specified");
425 if (BaseMemory == NULL) {
426 Error (NULL, 0, 4001,
"Resource",
"memory cannot be allocated!");
433 result =
GenBinPage (BaseMemory, InputFile, OutputFile);
#define EFI_PML4_ENTRY_NUM
void * CreateIdentityMappingPageTables(void)
#define UTILITY_MAJOR_VERSION
int32_t GenBinPage(void *BaseMemory, char *NoPageFileName, char *PageFileName)
uint32_t gPageTableOffsetInFile
#define EFI_PAGE_BASE_ADDRESS
#define EFI_PDPTE_ENTRY_NUM
void Error(char *FileName, uint32_t LineNumber, uint32_t ErrorCode, char *OffendingText, char *MsgFmt,...)
#define CONVERT_BIN_PAGE_ADDRESS(a)
#define EFI_PDE_ENTRY_NUM
uint32_t gPageTableBaseAddress
#define UTILITY_MINOR_VERSION
#define EFI_PAGE_BASE_OFFSET_IN_LDR