/** @file\r
-\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
- GenPage.c\r
- \r
-Abstract:\r
Pre-Create a 4G page table (2M pages).\r
It's used in DUET x64 build needed to enter LongMode.\r
\r
(\r
Directory-Ptr Directory {512}\r
) {4}\r
+\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
**/\r
\r
#include <stdio.h>\r
X64_PAGE_TABLE_ENTRY_2M *PageDirectoryEntry2MB;\r
\r
PageTable = (void *)malloc (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE);\r
+ if (PageTable == NULL) {\r
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+ return NULL;\r
+ }\r
memset (PageTable, 0, (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE));\r
PageTablePtr = PageTable;\r
\r
}\r
\r
//\r
- // Don't recognize the paramter.\r
+ // Don't recognize the parameter.\r
//\r
InputFile = argv[0];\r
argc--;\r
// Create X64 page table\r
//\r
BaseMemory = CreateIdentityMappingPageTables ();\r
+ if (BaseMemory == NULL) {\r
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+ return STATUS_ERROR;\r
+ }\r
\r
//\r
// Add page table to binary file\r
//\r
result = GenBinPage (BaseMemory, InputFile, OutputFile);\r
if (result < 0) {\r
+ free (BaseMemory);\r
return STATUS_ERROR;\r
}\r
\r
+ free (BaseMemory);\r
return 0;\r
}\r
\r