]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Ebl/Main.c
EmbeddedPkg/Ebl: Move the flag string %a for the path from the PCD to the function...
[mirror_edk2.git] / EmbeddedPkg / Ebl / Main.c
index 5d1a37916f02d33d8244e030a77702988338e730..1f677bcb041b6ac4a32af994602903bb89447e6f 100644 (file)
@@ -1,10 +1,10 @@
 /** @file\r
   Basic command line parser for EBL (Embedded Boot Loader)\r
 \r
-  Copyright (c) 2007, Intel Corporation<BR>\r
-  Portions copyright (c) 2008-2009, Apple Inc. All rights reserved.\r
+  Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 \r
-  All rights reserved. This program and the accompanying materials\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
@@ -187,7 +187,7 @@ ParseArguments (
       break;\r
     }\r
 \r
-    // Perform any text coversion here\r
+    // Perform any text conversion here\r
     if (*Char == '\t') {\r
       // TAB to space\r
       *Char = ' ';\r
@@ -205,9 +205,14 @@ ParseArguments (
       } \r
     } else {\r
       // Looking for the terminator of an Argv[] entry\r
-      if ((InQuote && (*Char == '"')) || (!InQuote && (*Char == ' '))) {\r
+      if (!InQuote && (*Char == ' ')) {\r
         *Char = '\0';\r
         LookingForArg = TRUE;\r
+      } else if (!InQuote && (*Char == '"') && (*(Char-1) != '\\')) {\r
+        InQuote = TRUE;\r
+      } else if (InQuote && (*Char == '"') && (*(Char-1) != '\\')) {\r
+        *Char = '\0';\r
+        InQuote = FALSE;\r
       }\r
     }    \r
   }\r
@@ -451,10 +456,49 @@ EblPrintStartupBanner (
   EblSetTextColor (0);\r
   AsciiPrint (") prototype. Built at %a on %a\n",__TIME__, __DATE__);\r
   AsciiPrint ("THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN 'AS IS' BASIS,\nWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\n");\r
-  AsciiPrint ("Please send feedback to dev@edk2.tianocore.org\n");\r
+  AsciiPrint ("Please send feedback to edk2-devel@lists.sourceforge.net\n");\r
+}\r
+\r
+\r
+/**\r
+  Send null requests to all removable media block IO devices so the a media add/remove/change\r
+  can be detected in real before we execute a command. \r
+\r
+  This is mainly due to the fact that the FAT driver does not do this today so you can get stale \r
+  dir commands after an SD Card has been removed.\r
+**/\r
+VOID\r
+EblProbeRemovableMedia (\r
+  VOID\r
+  )\r
+{\r
+  UINTN         Index;\r
+  UINTN         Max;\r
+  EFI_OPEN_FILE *File;\r
+\r
+  //\r
+  // Probe for media insertion/removal in removable media devices\r
+  //\r
+  Max = EfiGetDeviceCounts (EfiOpenBlockIo);\r
+  if (Max != 0) {\r
+    for (Index = 0; Index < Max; Index++) {\r
+      File = EfiDeviceOpenByType (EfiOpenBlockIo, Index);\r
+      if (File != NULL) {\r
+        if (File->FsBlockIoMedia->RemovableMedia) {\r
+          // Probe to see if media is present (or not) or media changed\r
+          //  this causes the ReinstallProtocolInterface() to fire in the\r
+          //  block io driver to update the system about media change events\r
+          File->FsBlockIo->ReadBlocks (File->FsBlockIo, File->FsBlockIo->Media->MediaId, (EFI_LBA)0, 0, NULL);\r
+        }\r
+        EfiClose (File);\r
+      }\r
+    }\r
+  }\r
 }\r
 \r
 \r
+\r
+\r
 /**\r
   Print the prompt for the EBL.\r
 **/\r
@@ -464,7 +508,7 @@ EblPrompt (
   )\r
 {\r
   EblSetTextColor (EFI_YELLOW);\r
-  AsciiPrint ((CHAR8 *)PcdGetPtr (PcdEmbeddedPrompt));\r
+  AsciiPrint ("%a %a",(CHAR8 *)PcdGetPtr (PcdEmbeddedPrompt), EfiGetCwd ());\r
   EblSetTextColor (0);\r
   AsciiPrint ("%a", ">");\r
 }\r
@@ -558,7 +602,11 @@ EdkBootLoaderEntry (
   EblInitializeScriptCmd ();\r
   EblInitializeExternalCmd ();\r
   EblInitializeNetworkCmd();\r
+  EblInitializeVariableCmds ();\r
   \r
+  // Disable the 5 minute EFI watchdog time so we don't get automatically reset\r
+  gBS->SetWatchdogTimer (0, 0, 0, NULL);\r
+\r
   if (FeaturePcdGet (PcdEmbeddedMacBoot)) {\r
     // A MAC will boot in graphics mode, so turn it back to text here\r
     // This protocol was removed from edk2. It is only an edk thing. We need to make our own copy.\r
@@ -567,8 +615,6 @@ EdkBootLoaderEntry (
     // Enable the biggest output screen size possible\r
     gST->ConOut->SetMode (gST->ConOut, (UINTN)gST->ConOut->Mode->MaxMode - 1);\r
 \r
-    // Disable the 5 minute EFI watchdog time so we don't get automatically reset\r
-    gBS->SetWatchdogTimer (0, 0, 0, NULL);\r
   }\r
 \r
   // Save current screen mode\r
@@ -610,6 +656,11 @@ EdkBootLoaderEntry (
     EblPrompt ();\r
     GetCmd (CmdLine, MAX_CMD_LINE);\r
     SetCmdHistory (CmdLine);\r
+\r
+    if (FeaturePcdGet (PcdEmbeddedProbeRemovable)) {\r
+      // Probe removable media devices to see if media has been inserted or removed.\r
+      EblProbeRemovableMedia ();\r
+    }\r
   }\r
 }\r
 \r