问题描述
我需要编写驱动程序(DXE),该驱动程序可以将字节对"从虚拟机(QEMU)传输到主机系统(OS-Ubuntu).我已经阅读了《 UEFI_Spec和开发人员指南》,但是我仍然不明白,如何编写代码以及应该使用哪种协议(试图使用TCPv4,但是甚至不能使用LocateHandleBuffer).
I need to write driver (DXE), that can transmit "couple of bytes" from virtual machine (QEMU) to the host system (OS - Ubuntu). I've read the UEFI_Spec and Guide for developers, but I still don't understand, how to write the code and what protocol should I use (tried to use TCPv4 but can't even LocateHandleBuffer).
EFI_STATUS Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiTcp4ProtocolGuid, NULL, &HandleCount, &HandleBuffer);
我得到:
EFI_UNSUPPORTED
如果有人可以解释我或可以显示代码示例,我将不胜感激.谢谢.
If somebody can explain me or can show examples of the code, I'll be very grateful. Thanks.
推荐答案
对于大多数与网络相关的协议,您首先必须使用相应的服务绑定协议"来获取包含要查找的协议的句柄.
For most network related protocols you first have to use the corresponding "Service Binding Protocol" to get a handle which contains the protocol you are looking for.
使用以下步骤访问Tcp4Protocol:
Use this steps to access the Tcp4Protocol:
gBS->LocateHandleBuffer(ByProtovol,gEfiTcp4ServiceBindingProtocolGuid, NULL, &HandleCount, &HandleBuffer);
// Loop over the HandleBuffer Array and pick the one you need
gBS->HandleProtocol(HandleBuffer[YourIndex], &gEfiTcp4ServiceBindingProtocolGuid, &Tcp4SBProtocol);
Tcp4SBProtocol->CreateChild(Tcp4SBProtocol, &Tcp4Handle);
gBS->HandleProtocol(Tcp4Handle, &gEfiTcp4ProtocolGuid, &Tcp4Protocol);
要检查NIC是否可用,可以使用:
To check if a NIC is available you can use:
// This should return EFI_SUCCESS
gBS->LocateProtocol(&gEfiSimpleNetworkProtocolGuid, NULL, &SimpleNetworkProtocol);
在 Uefi规范中,有一个完整的HttpProtocol代码示例. a>(从第1548页开始),Tcp4Protocol差别不大.
There is a complete code sample for the HttpProtocol inside the Uefi specification (starting at page 1548), the Tcp4Protocol is not very different.
这篇关于如何发送至少一个“字节对"?在本地网络(UEFI DXE)上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!