]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Added CWD to EfiFileLib. Fix some X64 warnings.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 7 Feb 2010 22:04:03 +0000 (22:04 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 7 Feb 2010 22:04:03 +0000 (22:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9942 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
EmbeddedPkg/Ebl/Command.c
EmbeddedPkg/Include/Library/EfiFileLib.h
EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c

index 75d0f1c687a9e483e3e3a7eec895043aa835f916..8b3132cc99e965ae5b1df0a130010f7281f9f30f 100644 (file)
@@ -1057,7 +1057,7 @@ DisassembleInstruction (
   )\r
 {\r
   if (Thumb) {\r
-    DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size, &ItBlock, Extended);\r
+    DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size, ItBlock, Extended);\r
   } else {\r
     DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size, Extended);\r
   }\r
index 7899a0f442c53816a956bb408b58d7e41a9fb7bb..a525e3a4faa5df2d682954b72ccecab6f2501bae 100644 (file)
@@ -282,13 +282,13 @@ EblExitCmd (
   IN CHAR8  **Argv\r
   )\r
 {\r
-  EFI_STATUS              Status;
-  UINTN                   MemoryMapSize;
-  EFI_MEMORY_DESCRIPTOR   *MemoryMap;
-  UINTN                   MapKey;
-  UINTN                   DescriptorSize;
-  UINTN                   DescriptorVersion;
-  UINTN                   Pages;
+  EFI_STATUS              Status;\r
+  UINTN                   MemoryMapSize;\r
+  EFI_MEMORY_DESCRIPTOR   *MemoryMap;\r
+  UINTN                   MapKey;\r
+  UINTN                   DescriptorSize;\r
+  UINT32                  DescriptorVersion;\r
+  UINTN                   Pages;\r
 \r
   if (Argc > 1) { \r
     if (AsciiStriCmp (Argv[1], "efi") != 0) {\r
@@ -298,42 +298,42 @@ EblExitCmd (
     return EFI_ABORTED;\r
   }\r
   \r
-  MemoryMap = NULL;
-  MemoryMapSize = 0;
-  do {
-    Status = gBS->GetMemoryMap (
-                    &MemoryMapSize,
-                    MemoryMap,
-                    &MapKey,
-                    &DescriptorSize,
-                    &DescriptorVersion
-                    );
-    if (Status == EFI_BUFFER_TOO_SMALL) {
-
-      Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
-      MemoryMap = AllocatePages (Pages);
-    
-      //
-      // Get System MemoryMap
-      //
-      Status = gBS->GetMemoryMap (
-                      &MemoryMapSize,
-                      MemoryMap,
-                      &MapKey,
-                      &DescriptorSize,
-                      &DescriptorVersion
-                      );
-      // Don't do anything between the GetMemoryMap() and ExitBootServices()
-      if (!EFI_ERROR (Status)) {
-        Status = gBS->ExitBootServices (gImageHandle, MapKey);
-        if (EFI_ERROR (Status)) {
-          FreePages (MemoryMap, Pages);
-          MemoryMap = NULL;
-          MemoryMapSize = 0;
-        }
-      }
-    }
-  } while (EFI_ERROR (Status));
+  MemoryMap = NULL;\r
+  MemoryMapSize = 0;\r
+  do {\r
+    Status = gBS->GetMemoryMap (\r
+                    &MemoryMapSize,\r
+                    MemoryMap,\r
+                    &MapKey,\r
+                    &DescriptorSize,\r
+                    &DescriptorVersion\r
+                    );\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+\r
+      Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;\r
+      MemoryMap = AllocatePages (Pages);\r
+    \r
+      //\r
+      // Get System MemoryMap\r
+      //\r
+      Status = gBS->GetMemoryMap (\r
+                      &MemoryMapSize,\r
+                      MemoryMap,\r
+                      &MapKey,\r
+                      &DescriptorSize,\r
+                      &DescriptorVersion\r
+                      );\r
+      // Don't do anything between the GetMemoryMap() and ExitBootServices()\r
+      if (!EFI_ERROR (Status)) {\r
+        Status = gBS->ExitBootServices (gImageHandle, MapKey);\r
+        if (EFI_ERROR (Status)) {\r
+          FreePages (MemoryMap, Pages);\r
+          MemoryMap = NULL;\r
+          MemoryMapSize = 0;\r
+        }\r
+      }\r
+    }\r
+  } while (EFI_ERROR (Status));\r
 \r
   //\r
   // At this point it is very dangerous to do things EFI as most of EFI is now gone.\r
index 992d326997648929fcedad6a2f51ec550bae9b3c..4e3c80d7ecbdd5e216931c587f74d58f6a6aa65d 100644 (file)
@@ -311,5 +311,38 @@ UINTN
 EfiGetDeviceCounts (\r
   IN  EFI_OPEN_FILE_TYPE     Type\r
   );\r
+  \r
+\r
+/**\r
+  Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and \r
+  the path does not contain a device name, The CWD is prepended to the path.\r
+  \r
+  @param  Cwd     Current Working Directory to set\r
+\r
+\r
+  @return EFI_SUCCESS           CWD is set\r
+  @return EFI_INVALID_PARAMETER Cwd is not a valid device:path\r
+\r
+**/\r
+EFI_STATUS\r
+EfiSetCwd (\r
+  IN  CHAR8   *Cwd\r
+  );  \r
+\r
+/**\r
+  Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and \r
+  the path does not contain a device name, The CWD is prepended to the path.\r
+  \r
+  @param  Cwd     Current Working Directory \r
+\r
+\r
+  @return NULL    No CWD set\r
+  @return 'other' malloc'ed buffer contains CWD.\r
+  \r
+**/\r
+CHAR8 *\r
+EfiGettCwd (\r
+  VOID\r
+  );  \r
 \r
 #endif\r
index 5effe7fcb99d8d5b495f033e200ba96e52724cae..cbe2aeecebddb626ab2eb547d6dcaef4b2105be0 100644 (file)
@@ -55,6 +55,9 @@
 #include <Library/EblNetworkLib.h>
 
 
+CHAR8 *gCwd = NULL;
+
+
 #define EFI_OPEN_FILE_GUARD_HEADER  0x4B4D4641
 #define EFI_OPEN_FILE_GUARD_FOOTER  0x444D5A56
 
@@ -635,6 +638,7 @@ EfiOpen (
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
   UINTN                     Size;
   EFI_IP_ADDRESS            Ip;
+  CHAR8                     *CwdPlusPathName;
 
   EblUpdateDeviceLists ();
  
@@ -656,8 +660,22 @@ EfiOpen (
   }
 
   if (FileStart == 0) {
+    if (gCwd == NULL) {
+      // No CWD
+      return NULL;
+    }
+    
     // We could add a current working diretory concept 
-    return NULL;
+    CwdPlusPathName = AllocatePool (AsciiStrSize (gCwd) + AsciiStrSize (PathName));
+    if (CwdPlusPathName == NULL) {
+      return NULL;
+    }
+    
+    AsciiStrCpy (CwdPlusPathName, gCwd);
+    AsciiStrCat (CwdPlusPathName, PathName);
+    File = EfiOpen (CwdPlusPathName, OpenMode, SectionType);
+    FreePool (CwdPlusPathName);
+    return File;
   }
 
   //
@@ -1481,3 +1499,66 @@ EfiWrite (
   return Status;
 }
 
+
+
+/**
+  Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and 
+  the path does not contain a device name, The CWD is prepended to the path.
+  
+  @param  Cwd     Current Working Directory to set
+
+
+  @return EFI_SUCCESS           CWD is set
+  @return EFI_INVALID_PARAMETER Cwd is not a valid device:path
+
+**/
+EFI_STATUS
+EfiSetCwd (
+  IN  CHAR8   *Cwd
+  ) 
+{
+  EFI_OPEN_FILE *File;
+  
+  File = EfiOpen (Cwd, EFI_FILE_MODE_READ, 0);
+  if (File == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  
+  EfiClose (File);
+  
+  if (gCwd != NULL) {
+    FreePool (gCwd);
+  }
+  
+  gCwd = AllocatePool (AsciiStrSize (Cwd));
+  if (gCwd == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  AsciiStrCpy (gCwd, Cwd);
+  return EFI_SUCCESS;
+}
+
+
+/**
+  Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and 
+  the path does not contain a device name, The CWD is prepended to the path.
+  The CWD buffer is only valid until a new call is made to EfiSetCwd(). After
+  a call to EfiSetCwd() it is not legal to use the pointer returned by 
+  this funciton.
+  
+  @param  Cwd     Current Working Directory 
+
+
+  @return NULL    No CWD set
+  @return 'other' Returns buffer that contains CWD.
+  
+**/
+CHAR8 *
+EfiGettCwd (
+  VOID
+  )
+{
+  return gCwd;
+}
+
+