UEFI shell - 脚本文件

UEFI shell下的脚本文件的命名格式为: ****.nsh

脚本的语法和规范参考:

  • 《EFI Shell User’s Guide》
  • 《UEFI原理与编程》

1. 写一个简单的脚本测试下:

脚本名为test.nsh,内容如下:

pci

在这里插入图片描述

2.开机自启动脚本

UEFI shell有一个开机自启动脚本,命名startup.nsh
在这里插入图片描述编辑下startup.nsh,内容为

date

开启虚拟机,不做任何操作,结果如下:
在这里插入图片描述

3.开机自启动脚本的代码实现

参考
edk2/ShellPkg/Application/Shell/Shell.c

...
STATIC CONST CHAR16 mStartupScript[]        = L"startup.nsh";
...

{
  .......
  //
  // Try to find 'Startup.nsh' in the execution path defined by the environment variable PATH.
  //
  if ((StartupScriptPath == NULL) || EFI_ERROR (ShellIsFile (StartupScriptPath))) {
    SHELL_FREE_NON_NULL (StartupScriptPath);
    StartupScriptPath = ShellFindFilePath (mStartupScript);
  }

......




/**
  Find a file by searching the CWD and then the path.

  If FileName is NULL then ASSERT.

  If the return value is not NULL then the memory must be caller freed.

  @param FileName               Filename string.

  @retval NULL                  the file was not found
  @return !NULL                 the full path to the file.
**/
CHAR16 *
EFIAPI
ShellFindFilePath (
  IN CONST CHAR16 *FileName
  );


};

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值