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
  • 相关阅读:
    asp.net 奇淫技巧
    生成缩略图不清晰
    NPOI相关
    Dapper
    Newtonsoft.Json高级用法(转载)
    swfobject2.2
    如何把SQLServer数据库从高版本降级到低版本? (转载)
    Smallpdf 轻松玩转PDF。我们爱它。
    Simple Data
    在HTML中优雅的生成PDF
  • 原文地址:https://www.cnblogs.com/qintangtao/p/3303034.html
Copyright © 2011-2022 走看看