]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenPage/GenPage.c
BaseTools: align ERROR/WARNING/RETURN macros with MdePkg versions
[mirror_edk2.git] / BaseTools / Source / C / GenPage / GenPage.c
index cb34a0719c11fefdb5e9f9e57db457a7d747e704..3bb05efa36cd06b86c31f4b6eb08ee8144d83058 100644 (file)
@@ -1,18 +1,4 @@
 /** @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
@@ -28,6 +14,16 @@ Abstract:
                         (\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
@@ -150,6 +146,10 @@ Return:
   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
@@ -405,7 +405,7 @@ main (
     }\r
     \r
     //\r
-    // Don't recognize the paramter.\r
+    // Don't recognize the parameter.\r
     //\r
     InputFile = argv[0];\r
     argc--;\r
@@ -421,15 +421,21 @@ main (
   // 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