zoukankan      html  css  js  c++  java
  • Parse how to write flash in uefi shell.

    Step:

    1.     Enable

    2.     Read

    3.     Write

    4.     Disable

    FI_GUID gEfiSFlashProtocolGuid = FLASH_PROTOCOL_GUID;
    FLASH_PROTOCOL*  pFlashProtocol;
    EFI_PHYSICAL_ADDRESS        Flash4GBMapStart;
    EFI_STATUS   Status;
    UINT8        *StrBuffer;
     
    Status = pBootServices->LocateProtocol( &gEfiSFlashProtocolGuid, NULL, &pFlashProtocol);
     
    Status = pBootServices->AllocatePool(//start: allocate mem  check point hear
                 EfiBootServicesData,
                 sizeof(UINT8) * FLASH_BLOCK_SIZE,
                 (VOID*)&StrBuffer);
    if (EFI_ERROR(Status) || StrBuffer == NULL) {
            error code here…..
          }
     
    MemSet(StrBuffer, (sizeof(UINT8) * FLASH_BLOCK_SIZE), 0);
    Flash4GBMapStart = 0xFFFFFFFF - FLASH_SIZE + 1;
          
    //Enable DeviceWrite to read real Flash address, not memory mapping.
    Status = pFlashProtocol->DeviceWriteEnable();//step1. enable
     if (EFI_ERROR(Status)) {
                   error code here…..
     } 
     Status = pFlashProtocol->Read(//step2. Read
                       (VOID*)Flash4GBMapStart,
                       FLASH_BLOCK_SIZE,
                       (VOID*)StrBuffer);
                    
     *(StrBuffer+PcieLaneSettingAddr) = PcieLaneSetting;          
    Status = pFlashProtocol->Write(//step3. Update or write
     (VOID*)Flash4GBMapStart,
    FLASH_BLOCK_SIZE,
     (VOID*)StrBuffer);       
    
     pFlashProtocol->DeviceWriteDisable();  //step4. Disable
    pBootServices->FreePool(StrBuffer);//end: free memory
  • 相关阅读:
    【python】装饰器详解推荐
    【React + flask】跨域服务及访问
    【LInux】统计某文件夹下目录的个数
    【NPM】设置代理
    【Mac】jupyter
    【Mac brew】代理安装brew insall
    【医学】超声波成像原理
    【Nginx】配置及使用
    音视频处理ffmpeg使用
    【DL】梯度下降小结
  • 原文地址:https://www.cnblogs.com/qintangtao/p/3303034.html
Copyright © 2011-2022 走看看