Herunterladen Inhalt Inhalt Diese Seite drucken

Shell-Beispielskripts - HP UEFI Shell Benutzerhandbuch

Inhaltsverzeichnis

Werbung

Shell-Beispielskripts

Beispiele
Die folgenden Beispielskripts illustrieren das Erfassen einer Konfiguration (Export) und deren
Replikation (Import) mit der auf einem virtuellen iLO Medium bereitgestellten Datei startup.nsh.
Beispiel
fs0:\>
/** @file
This is an example Shell Application. Note that there are
other ways to add a command to the shell. This example
demonstrates just one.
Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
This software contains information confidential and proprietary to
Hewlett-Packard Company. It shall not be reproduced in whole or in part,
or transferred to other documents, or disclosed to third parties, or used
for any purpose other than that for which it was obtained without the prior
written consent of Hewlett-Packard Company.
**/
#include <Protocol/EfiShell.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
/**
Implements simple shell HelloWorld Application that prints out
the string "Hello World" to the screen and then display UEFI
Shell revision and registered environment variables in system.
This example demonstrates how a new UEFI Shell Application can
be created to run at UEFI Shell Prompt.
@param ImageHandle
@param SystemTable
@retval EFI_SUCCESS
**/
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE
IN EFI_SYSTEM_TABLE
)
\{
EFI_SHELL_PROTOCOL
CONST CHAR16
CONST CHAR16
EFI_STATUS
Print (L"Hello World!\n");
//
// Locate UEFI Shell Protocol
//
Status = gBS->OpenProtocol (
if (EFI_ERROR(Status)) {
//
// Search for the shell protocol
//
Status = gBS->LocateProtocol (
if (EFI_ERROR(Status)) {
UefiShellProtocol = NULL;
return EFI_SUCCESS;
\}
\}
if (UefiShellProtocol != NULL) {
//
// Sample to read UEFI Shell Major and Minor Version Variables
//
Print (L"UEFI Shell Revision: %d.%d\n", UefiShellProtocol->MajorVersion, UefiShellProtocol->MinorVersion);
72
Das UEFI-Programmiermodell
Handle to the Image
Pointer to the System Table
In all cases
ImageHandle,
*SystemTable
*UefiShellProtocol;
*ConstEnvNameList;
*Value;
Status;
ImageHandle,
&gEfiShellProtocolGuid,
(VOID **)&UefiShellProtocol,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
&gEfiShellProtocolGuid,
NULL,
(VOID **)&UefiShellProtocol
);

Quicklinks ausblenden:

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis