]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Tools / Source / ProcessDsc / FWVolume.c
index 3e60b0344b4b6d627c72de456934996829fe8987..5181373a54037235ba4d3c869d3e23376a82b11a 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -35,18 +35,7 @@ Abstract:
 #define EFI_BASE_ADDRESS    "EFI_BASE_ADDRESS"\r
 #define DEFAULT_FV_INF_DIR  "FV"            // default dir for where we create the FV INF file\r
 #define DEFAULT_FV_DIR      "$(BUILD_DIR)"  // where the FV file comes from\r
-#define MALLOC(size)        malloc (size)\r
-#define FREE(ptr)           free (ptr)\r
 \r
-//\r
-// Disable warning for unused function arguments\r
-//\r
-#pragma warning(disable : 4100)\r
-//\r
-// Disable warning for while(1) code\r
-//\r
-// #pragma warning (disable : 4127)\r
-//\r
 typedef struct {\r
   char  *ComponentType;\r
   char  *Extension;\r
@@ -196,8 +185,7 @@ static
 void\r
 AddFirmwareVolumes (\r
   char          *FVs,\r
-  int           ComponentsInstance,\r
-  FILE_LIST     *FileListPtr\r
+  int           ComponentsInstance\r
   );\r
 \r
 static\r
@@ -503,7 +491,7 @@ Returns:
   // Add these firmware volumes to the list of known firmware\r
   // volume names.\r
   //\r
-  AddFirmwareVolumes (FVs, ComponentsInstance, Ptr);\r
+  AddFirmwareVolumes (FVs, ComponentsInstance);\r
 \r
   return STATUS_SUCCESS;\r
 }\r
@@ -528,7 +516,7 @@ CFVDestructor (
   //\r
   while (mFVList != NULL) {\r
     mFVListLast = mFVList->Next;\r
-    FREE (mFVList);\r
+    free (mFVList);\r
     mFVList = mFVListLast;\r
   }\r
 }\r
@@ -957,10 +945,10 @@ Returns:
   //\r
   // Now go through the list of all NonFFS FVs they specified and search for\r
   // a [build.fv.$(FV)] or [build.fv] command and emit the commands to the\r
-  // output makefile. Add them to the "fvs" target as well.\r
+  // output makefile. Add them to the "fvs_0" target as well.\r
   //\r
   if (mNonFfsFVList != NULL) {\r
-    fprintf (MakeFptr, "fvs ::");\r
+    fprintf (MakeFptr, "fvs_0 ::");\r
     FVPtr = mNonFfsFVList;\r
     while (FVPtr != NULL) {\r
       fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);\r
@@ -1022,43 +1010,40 @@ Returns:
       DSCFileRestorePosition (DSC);\r
     }\r
   }\r
+\r
   //\r
-  // Go through our list of firmware volumes and create an "fvs" target that\r
-  // builds everything. It has to be a mix of components and FV's in order.\r
-  // For example:  fvs : components_0 fv\fv001.fv fv\fv002.fv components_1 fv\fv003.fv\r
+  // Get the components count\r
   //\r
-  ComponentsInstance  = 0;\r
-  ComponentCount      = 0;\r
-  fprintf (MakeFptr, "fvs ::");\r
-  for (;;) {\r
-    //\r
-    // First see if we have any components for this section. If we don't,\r
-    // then we're done\r
-    //\r
-    for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
-      if (FileListPtr->ComponentsInstance == ComponentsInstance) {\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (FileListPtr == NULL) {\r
-      break;\r
+  ComponentCount = -1;\r
+  for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
+    if (FileListPtr->ComponentsInstance > ComponentCount) {\r
+      ComponentCount = FileListPtr->ComponentsInstance;\r
     }\r
+  }\r
+  ComponentCount++;\r
 \r
-    fprintf (MakeFptr, " components_%d", ComponentsInstance);\r
-    ComponentCount++;\r
-    //\r
-    // Now print any firmware volumes that match this components instance\r
-    //\r
+  //\r
+  // Now print firmware volumes build targets fvs_0, fvs_1 etc.\r
+  //\r
+  for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {\r
+    fprintf (MakeFptr, "fvs_%d ::", ComponentsInstance);\r
     for (FVPtr = mFVList; FVPtr != NULL; FVPtr = FVPtr->Next) {\r
       if (FVPtr->ComponentsInstance == ComponentsInstance) {\r
         fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);\r
       }\r
     }\r
-\r
-    ComponentsInstance++;\r
+    fprintf (MakeFptr, "\n\n");\r
+  }\r
+      \r
+  //\r
+  // Create an "fvs" target that builds everything. It has to be a mix of \r
+  // components and FV's in order. For example:\r
+  // fvs :: components_0 fvs_0 components_1 fvs_1\r
+  //\r
+  fprintf (MakeFptr, "fvs ::");\r
+  for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {\r
+    fprintf (MakeFptr, " components_%d fvs_%d", ComponentsInstance, ComponentsInstance);\r
   }\r
-\r
   fprintf (MakeFptr, "\n\n");\r
 \r
   //\r
@@ -1351,8 +1336,7 @@ static
 void\r
 AddFirmwareVolumes (\r
   char          *FVs,\r
-  int           ComponentsInstance,\r
-  FILE_LIST     *FileListPtr\r
+  int           ComponentsInstance\r
   )\r
 {\r
   FV_LIST *FvPtr;\r
@@ -1386,7 +1370,7 @@ AddFirmwareVolumes (
       // If we didn't find a match, then create a new one\r
       //\r
       if (FvPtr == NULL) {\r
-        FvPtr = MALLOC (sizeof (FV_LIST));\r
+        FvPtr = malloc (sizeof (FV_LIST));\r
         if (FvPtr == NULL) {\r
           Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed");\r
           return ;\r