PERFORCE change 149163 for review
Rui Paulo
rpaulo at FreeBSD.org
Wed Sep 3 22:11:13 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=149163
Change 149163 by rpaulo at rpaulo_phi on 2008/09/03 22:10:13
Change the command name from 'col' to 'mode'. This is the actual name
of the EFI shell command.
When printing ImageBase, we can use 32 bit.
Print a couple more interesting information when booting up.
Add initial version of the nvram command.
Affected files ...
.. //depot/projects/efi/boot/i386/efi/main.c#4 edit
Differences ...
==== //depot/projects/efi/boot/i386/efi/main.c#4 (text+ko) ====
@@ -57,6 +57,7 @@
EFI_STATUS
main(int argc, CHAR16 *argv[])
{
+ char vendor[128];
EFI_LOADED_IMAGE *img;
int i;
@@ -78,7 +79,14 @@
/* Get our loaded image protocol interface structure. */
BS->HandleProtocol(IH, &imgid, (VOID**)&img);
- printf("Image base: 0x%016lx\n", (u_long)img->ImageBase);
+ printf("Image base: 0x%lx\n", (u_long)img->ImageBase);
+ printf("EFI version: %d.%02d\n", ST->Hdr.Revision >> 16,
+ ST->Hdr.Revision & 0xffff);
+ printf("EFI Firmware: ");
+ /* printf doesn't understand EFI Unicode */
+ ST->ConOut->OutputString(ST->ConOut, ST->FirmwareVendor);
+ printf(" (rev %d.%02d)\n", ST->FirmwareRevision >> 16,
+ ST->FirmwareRevision & 0xffff);
printf("\n");
printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
@@ -129,7 +137,9 @@
RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 23,
(CHAR16 *)"Reboot from the loader");
- exit(0);
+
+ /* NOTREACHED */
+ return (CMD_ERROR);
}
COMMAND_SET(quit, "quit", "exit the loader", command_quit);
@@ -258,15 +268,16 @@
}
-COMMAND_SET(col, "col", "change or display text modes", command_col);
+COMMAND_SET(mode, "mode", "change or display text modes", command_mode);
static int
-command_col(int argc, char *argv[])
+command_mode(int argc, char *argv[])
{
unsigned int cols, rows, mode;
- int i, status;
+ int i;
char *cp;
char rowenv[8];
+ EFI_STATUS status;
SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
conout = ST->ConOut;
@@ -305,3 +316,56 @@
return (CMD_OK);
}
+
+
+COMMAND_SET(nvram, "nvram", "get or set NVRAM variables", command_nvram);
+
+static int
+command_nvram(int argc, char *argv[])
+{
+ CHAR16 var[128];
+ CHAR16 *data;
+ EFI_STATUS status;
+ EFI_GUID varguid = { 0,0,0,{0,0,0,0,0,0,0,0} };
+ unsigned int varsz;
+ unsigned int datasz;
+ SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
+ int i;
+
+ conout = ST->ConOut;
+
+ /* Initiate the search */
+ status = RS->GetNextVariableName(&varsz, NULL, NULL);
+
+ for (; status != EFI_NOT_FOUND; ) {
+ status = RS->GetNextVariableName(&varsz, var,
+ &varguid);
+ //if (EFI_ERROR(status))
+ //break;
+
+ conout->OutputString(conout, var);
+ printf("=");
+ datasz = 0;
+ status = RS->GetVariable(var, &varguid, NULL, &datasz,
+ NULL);
+ /* XXX: check status */
+ data = malloc(datasz);
+ status = RS->GetVariable(var, &varguid, NULL, &datasz,
+ data);
+ if (EFI_ERROR(status))
+ printf("<error retrieving variable>");
+ else {
+ for (i = 0; i < datasz; i++) {
+ if (isalnum(data[i]) || isspace(data[i]))
+ printf("%c", data[i]);
+ else
+ printf("\\x%02x", data[i]);
+ }
+ }
+ /* XXX */
+ pager_output("\n");
+ free(data);
+ }
+
+ return (CMD_OK);
+}
More information about the p4-projects
mailing list