UEFI基础——测试用例Hello Word

12 篇文章 4 订阅 ¥59.90 ¥99.00

Hello 测试用例

硬件环境:龙芯ls3a6000平台
软件环境:龙芯uefi固件

GUID获取网址:https://guidgen.com

一、创建工程

  • mkdir TextPkg/
  • 三个文件 Hello.c 、 Hello.inf 、HelloPkg.dsc

1.1 Hello.c

/** @file
  The application to print hello word.

Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是在UEFI下使用SLT存储测试用例的代码示例: ```c #include <Library/UefiBootServicesTableLib.h> #include <Library/UefiLib.h> #include <Library/MemoryAllocationLib.h> #include <Protocol/SharedLargeMemoryProtocol.h> // 定义测试数据的大小 #define DATA_SIZE 1024 EFI_STATUS EFIAPI SLTTestEntryPoint( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS status; VOID *data; EFI_PHYSICAL_ADDRESS slt_address; UINTN slt_size; EFI_SHARED_LARGE_MEMORY_PROTOCOL *slt_protocol; // 获取SLT协议 status = gBS->LocateProtocol(&gEfiSharedLargeMemoryProtocolGuid, NULL, (VOID **)&slt_protocol); if (EFI_ERROR(status)) { Print(L"Failed to locate SLT protocol: %r\n", status); return status; } // 分配测试数据的内存 data = AllocatePool(DATA_SIZE); if (data == NULL) { Print(L"Failed to allocate memory for test data\n"); return EFI_OUT_OF_RESOURCES; } // 将测试数据复制到SLT存储中 slt_size = DATA_SIZE; status = slt_protocol->AllocateSharedMemory(&slt_size, &slt_address); if (EFI_ERROR(status)) { Print(L"Failed to allocate SLT memory: %r\n", status); return status; } CopyMem((VOID *)slt_address, data, DATA_SIZE); // 从SLT存储中读取数据 VOID *read_data = AllocatePool(DATA_SIZE); if (read_data == NULL) { Print(L"Failed to allocate memory for read data\n"); return EFI_OUT_OF_RESOURCES; } CopyMem(read_data, (VOID *)slt_address, DATA_SIZE); // 检查读取的数据与原始数据是否相等 if (CompareMem(data, read_data, DATA_SIZE) != 0) { Print(L"SLT storage test failed: read data does not match original data\n"); return EFI_DEVICE_ERROR; } // 释放SLT存储 status = slt_protocol->FreeSharedMemory(slt_address); if (EFI_ERROR(status)) { Print(L"Failed to free SLT memory: %r\n", status); return status; } // 释放内存 FreePool(data); FreePool(read_data); // 测试通过 Print(L"SLT storage test passed!\n"); return EFI_SUCCESS; } ``` 这个示例代码在UEFI环境下使用SLT存储测试数据。首先,它通过SLT协议分配了一个SLT存储,然后将测试数据复制到这个存储中。接着从SLT存储中读取数据,并检查读取的数据与原始数据是否相等。最后,它释放了SLT存储,并释放了内存。这个测试用例可以帮助验证UEFI下的SLT存储是否正常工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大、猫

感谢支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值