Firmware Image Download 命令(UEFI EDKII)

Firmware Image Download 命令

在 NVMe 规范中,Firmware Image Download 命令用于从主机向 NVMe 控制器下载固件镜像。该命令是 NVMe 管理命令集的一部分,通常用于更新或安装新的固件。

1. 目的:

从主机传输固件镜像到 NVMe 控制器。

2. 流程:

通常在该命令之后跟随一个 Firmware Commit 命令,指示控制器验证并激活新下载的固件。

3.命令结构:

操作码:0x11(Firmware Image Download 命令)。
CDW10:包含要传输的 dword(4 字节单位)的数量。
CDW11:包含在固件镜像中的偏移量(以 dword 为单位),从这个偏移量开始传输。

4.数据传输:

固件镜像分块传输,每个块的大小在命令中指定。
可能需要多个 Firmware Image Download 命令才能传输整个镜像。

5.Firmware Commit 命令:

操作码:0x10(Firmware Commit 命令)。
在完整的固件镜像下载后发出此命令。
指示控制器验证并可选地激活新的固件镜像。

流程示例

1. 准备工作:

  • 确保固件镜像在主机上可用,并准备传输。
  • 确定块大小和传输整个镜像所需的块数量。

2. 下载块:

  • 发出多个 Firmware Image Download 命令,每个命令传输固件镜像的一块。
  • 每个命令指定块大小和固件镜像中的偏移量。

3. 提交固件:

在所有块下载完成后,发出 Firmware Commit 命令以验证并激活新的固件。

示例代码

以下是一个简化的伪代码示例,用于说明这一过程:

EFI_STATUS
FirmwareImageDownload(
  IN EFI_PCI_IO_PROTOCOL *PciIo,
  IN VOID *Buffer,
  IN UINTN BufferSize
  )
{
  EFI_STATUS Status;
  NVME_COMMAND Command;
  UINT64 Data;
  UINTN Offset = 0;
  UINTN ChunkSize = 4096;  // 每次传输的块大小
  UINT8 QueueEntrySize = sizeof(NVME_COMMAND);

  // 准备命令
  ZeroMem(&Command, sizeof(NVME_COMMAND));
  Command.Opcode = FIRMWARE_IMAGE_DOWNLOAD_OPCODE;
  Command.Prp1 = (UINT64)(UINTN)Buffer; // 指向要下载的固件数据缓冲区

  while (Offset < BufferSize) {
    UINTN BytesToTransfer = MIN(ChunkSize, BufferSize - Offset);
    Command.Cdword10 = (UINT32)(BytesToTransfer / 4);  // 传输的 dword 数量
    Command.Cdword11 = (UINT32)(Offset / 4);  // 偏移量

    // 写入命令到 NVMe 控制器
    Status = PciIo->Mem.Write(
      PciIo,
      EfiPciIoWidthUint32,
      NVME_BAR,
      NVME_ASQ,
      QueueEntrySize,
      &Command
    );
    if (EFI_ERROR(Status)) {
      return Status;
    }

    // 轮询完成队列
    // 在这里添加等待完成的代码

    Offset += BytesToTransfer;
  }

  // 提交固件
  ZeroMem(&Command, sizeof(NVME_COMMAND));
  Command.Opcode = FIRMWARE_COMMIT_OPCODE;

  Status = PciIo->Mem.Write(
    PciIo,
    EfiPciIoWidthUint32,
    NVME_BAR,
    NVME_ASQ,
    QueueEntrySize,
    &Command
  );

  return Status;
}
  • 读写命令:
    使用 PciIo->Mem.Write 方法向 NVMe 控制器的命令队列写入命令。
  • 地址转换:
    将固件缓冲区的虚拟地址转换为物理地址,写入命令结构中的 Prp1 字段。
  • 轮询完成:
    在写入命令后,轮询或等待完成队列以确保命令成功执行。
  • 提交固件:
    完成固件镜像下载后,发送固件提交命令以激活新的固件。

总结

通过 Firmware Image Download 命令,可以从主机向 NVMe 控制器下载固件镜像,通常在下载完成后,需要发出 Firmware Commit 命令以验证并激活新固件。该过程包括准备工作、分块下载固件镜像、提交固件等步骤。

### Ubuntu 24.04 Installation Guide #### Preparation Before Installation Before starting the installation of Ubuntu 24.04, ensure that all necessary hardware is compatible with this version of Ubuntu and prepare an installation medium such as a USB drive or DVD containing the latest ISO image file of Ubuntu 24.04. #### System Requirements To install Ubuntu 24.04 smoothly, it's recommended to have at least the following system specifications: - Processor: 2 GHz dual-core processor or better. - Memory (RAM): At least 4 GB, but more memory will provide better performance especially for graphical applications and development environments. - Hard Drive Space: Minimum 25 GB free space; however, considering additional software installations, having much larger storage like described in one case study where there was up to 18T available would be beneficial[^1]. #### Creating Bootable Media Use tools like Rufus on Windows or Startup Disk Creator on another Linux machine to create bootable media from the downloaded ISO file. #### BIOS/UEFI Settings Adjustment Adjusting settings within your computer’s BIOS/UEFI might be required before proceeding with the installation process. This includes setting the correct date/time, enabling UEFI mode over legacy BIOS support when applicable, ensuring Secure Boot is either disabled or set appropriately depending upon whether you plan to use secure boot features during OS operation, adjusting boot order so that external devices are prioritized higher than internal drives allowing selection of the live session directly after powering on without needing manual intervention each time. #### Starting Live Session And Installing The Operating System Boot into the live environment provided by the created bootable disk. Choose "Try Ubuntu" first if unsure about committing changes immediately until satisfied everything works correctly under trial conditions. Once ready, select “Install Ubuntu”. Follow prompts through language preferences, keyboard layout configuration, updates/download third-party drivers options while installing, partition setup including choosing between guided full-disk usage or custom layouts based on personal needs/preferences, then finally confirm actions which begin copying files onto target partitions preparing them accordingly for initial startup post-installation completion. #### Post-Installation Configuration After finishing the base operating system deployment, further configurations may include updating package lists using `sudo apt update`, upgrading installed packages via `sudo apt upgrade`. For specific setups requiring particular services running automatically upon reboots, commands similar to those used for configuring service management could apply, e.g., enabling GitLab CE to start at boot time can involve executing `sudo systemctl enable gitlab-runsvdir.service`[^2]. Additionally, users looking to modify display languages' priorities or configure sudo permissions should refer to relevant sections addressing these topics specifically[^3]. --related questions-- 1. What steps need attention regarding compatibility checks prior to attempting any new major release installation? 2. How does changing certain parameters inside BIOS affect my ability to successfully complete an Ubuntu installation? 3. Can I perform tasks simultaneously alongside trying out Ubuntu from a live CD/DVD/USB stick? 4. Why choose between different types of boot modes offered within modern computers’ firmware interfaces? 5. In what scenarios would someone opt for advanced partition schemes rather than letting the installer handle everything automatically?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值