snpnt32.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 1,155 行 · 第 1/2 页
C
1,155 行
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. 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.
Module Name:
SnpNt32.c
Abstract:
---*/
#include "SnpNt32.h"
EFI_DRIVER_BINDING_PROTOCOL gSnpNt32DriverBinding = {
SnpNt32DriverBindingSupported,
SnpNt32DriverBindingStart,
SnpNt32DriverBindingStop,
0x10,
NULL,
NULL
};
SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = {
SNP_NT32_DRIVER_SIGNATURE, // Signature
{
NULL,
NULL
}, // InstanceList
NULL, // WinNtThunk
NULL, // NetworkLibraryHandle
{
0
}, // NtNetUtilityTable
{
0,
0,
0
}, // Lock
//
// Private functions
//
SnpNt32InitializeGlobalData, // InitializeGlobalData
SnpNt32InitializeInstanceData, // InitializeInstanceData
SnpNt32CloseInstance // CloseInstance
};
EFI_STATUS
EFIAPI
SnpNt32DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
)
/*++
Routine Description:
Test to see if this driver supports ControllerHandle.
Arguments:
This - Protocol instance pointer.
ControllerHandle - Handle of device to test.
RemainingDevicePath - Optional parameter use to pick a specific child device to start.
Returns:
EFI_SUCCES - This driver supports this device.
other - This driver does not support this device.
--*/
{
SNPNT32_GLOBAL_DATA *GlobalData;
NET_LIST_ENTRY *Entry;
SNPNT32_INSTANCE_DATA *Instance;
GlobalData = &gSnpNt32GlobalData;
NET_LIST_FOR_EACH (Entry, &GlobalData->InstanceList) {
Instance = NET_LIST_USER_STRUCT_S (Entry, SNPNT32_INSTANCE_DATA, Entry, SNP_NT32_INSTANCE_SIGNATURE);
if (Instance->DeviceHandle == ControllerHandle) {
return EFI_SUCCESS;
}
}
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
SnpNt32DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
)
/*++
Routine Description:
Start this driver on ControllerHandle.
Arguments:
This - Protocol instance pointer.
ControllerHandle - Handle of device to bind driver to.
RemainingDevicePath - Optional parameter use to pick a specific child device to start.
Returns:
EFI_SUCCES - This driver is added to ControllerHandle.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
SnpNt32DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
Stop this driver on ControllerHandle.
Arguments:
This - Protocol instance pointer.
ControllerHandle - Handle of device to stop driver on.
NumberOfChildren - Number of Handles in ChildHandleBuffer. If number of children is
zero stop the entire bus driver.
ChildHandleBuffer - List of Child Handles to Stop.
Returns:
EFI_SUCCES - This driver is removed ControllerHandle.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32Start (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
/*++
Routine Description:
Start the SnpNt32 interface.
Arguments:
This - Context pointer.
Returns:
EFI_SUCCESS - The interface is started.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32Stop (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
/*++
Routine Description:
Stop the SnpNt32 interface.
Arguments:
This - Context pointer.
Returns:
EFI_SUCCESS - The interface is stopped.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32Initialize (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN UINTN ExtraRxBufferSize OPTIONAL,
IN UINTN ExtraTxBufferSize OPTIONAL
)
/*++
Routine Description:
Initialize the SnpNt32 interface.
Arguments:
This - Context pointer.
ExtraRxBufferSize - Number of extra receive buffer.
ExtraTxBufferSize - Number of extra transmit buffer.
Returns:
EFI_SUCCESS - The interface is initialized.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32Reset (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
/*++
Routine Description:
Reset the snpnt32 interface.
Arguments:
This - Context pointer.
ExtendedVerification - Not implemented.
Returns:
EFI_SUCCESS - The interface is reseted.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32Shutdown (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
/*++
Routine Description:
Shut down the snpnt32 interface.
Arguments:
This - Context pointer.
Returns:
EFI_SUCCESS - The interface is shut down.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32ReceiveFilters (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN UINT32 EnableBits,
IN UINT32 DisableBits,
IN BOOLEAN ResetMcastFilter,
IN UINTN McastFilterCount OPTIONAL,
IN EFI_MAC_ADDRESS *McastFilter OPTIONAL
)
/*++
Routine Description:
Change the interface's receive filter setting.
Arguments:
This - Context pointer.
EnableBits - The receive filters to enable.
DisableBits - The receive filters to disable
ResetMcastFilter - Reset the multicast filters or not.
McastFilterCount - The count of multicast filter to set.
McastFilter - Pointer to the arrya of multicast addresses to set.
Returns:
EFI_SUCCESS - The receive filter is updated.
EFI_ACCESS_DENIED - The snpnt32 lock is already owned by another routine.
EFI_DEVICE_ERROR - Failed to update the receive filter.
--*/
{
SNPNT32_INSTANCE_DATA *Instance;
SNPNT32_GLOBAL_DATA *GlobalData;
INT32 ReturnValue;
Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
GlobalData = Instance->GlobalData;
if (EFI_ERROR (NET_TRYLOCK (&GlobalData->Lock))) {
return EFI_ACCESS_DENIED;
}
ReturnValue = GlobalData->NtNetUtilityTable.SetReceiveFilter (
Instance->InterfaceInfo.InterfaceIndex,
EnableBits,
McastFilterCount,
McastFilter
);
NET_UNLOCK (&GlobalData->Lock);
if (ReturnValue <= 0) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32StationAddress (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN Reset,
IN EFI_MAC_ADDRESS *NewMacAddr OPTIONAL
)
/*++
Routine Description:
Change or reset the mac address of the interface.
Arguments:
This - Context pointer.
reset - Reset the mac address to the original one or not.
NewMacAddr - Pointer to the new mac address to set.
Returns:
EFI_UNSUPPORTED - Not supported yet.
--*/
{
return EFI_UNSUPPORTED;
}
EFI_STATUS
SnpNt32Statistics (
IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
IN BOOLEAN Reset,
IN OUT UINTN *StatisticsSize OPTIONAL,
IN OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
)
/*++
Routine Description:
Get or reset the statistics data.
Arguments:
This - Context pointer.
Reset - Reset the statistics or not.
StatisticsSize - The size of the buffer used to receive the statistics data.
StatisticsTable - Pointer to the table used to receive the statistics data.
Returns:
EFI_UNSUPPORTED - Not supported yet.
--*/
{
return EFI_UNSUPPORTED;
}
EFI_STATUS
SnpNt32McastIptoMac (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN Ipv6,
IN EFI_IP_ADDRESS *Ip,
OUT EFI_MAC_ADDRESS *Mac
)
/*++
Routine Description:
Convert a multicast ip address to the multicast mac address.
Arguments:
This - Context pointer.
Ipv6 - The Ip is an Ipv6 address or not.
Ip - Pointer to the Ip address to convert.
Mac - Pointer to the buffer used to hold the converted mac address.
Returns:
EFI_UNSUPPORTED - Not supported yet.
--*/
{
return EFI_UNSUPPORTED;
}
EFI_STATUS
SnpNt32Nvdata (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN BOOLEAN ReadOrWrite,
IN UINTN Offset,
IN UINTN BufferSize,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Read or write the nv data.
Arguments:
This - Context pinter.
ReadOrWrite - Read or write the nv data.
Offset - The offset to the start of the nv data.
BufferSize - Size of the buffer.
Buffer - Pointer to the buffer containing the data to write or used to
receive the data read.
Returns:
EFI_UNSUPPORTED - Not supported yet.
--*/
{
return EFI_UNSUPPORTED;
}
EFI_STATUS
SnpNt32GetStatus (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
OUT UINT32 *InterruptStatus,
OUT VOID **TxBuffer
)
/*++
Routine Description:
Get the status information of the interface.
Arguments:
This - Context pointer.
InterruptStatus - The storage to hold the interrupt status.
TxBuffer - Pointer to get the list of pointers of previously transmitted
buffers whose transmission was completed asynchrnously.
Returns:
EFI_SUCCESS - The status is got.
--*/
{
if (TxBuffer != NULL) {
*((UINT8 **) TxBuffer) = (UINT8 *) 1;
}
if (InterruptStatus != NULL) {
*InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
}
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32Transmit (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
IN UINTN HeaderSize,
IN UINTN BufferSize,
IN VOID *Buffer,
IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
IN UINT16 *Protocol OPTIONAL
)
/*++
Routine Description:
Transmit a packet.
Arguments:
This - Context pointer.
HeaderSize - The media header size contained in the packet buffer.
BufferSize - The size of the packet buffer.
Buffer - Pointer to the buffer containing the packet data.
SrcAddr - If non null, points to the source address of this packet.
DestAddr - If non null, points to the destination address of this packet.
Protocol - The protocol type of this packet.
Returns:
EFI_SUCCESS - The packet is transmitted or put into the transmit queue.
other - Some error occurs.
--*/
{
SNPNT32_INSTANCE_DATA *Instance;
SNPNT32_GLOBAL_DATA *GlobalData;
INT32 ReturnValue;
Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
GlobalData = Instance->GlobalData;
if ((HeaderSize != 0) && (SrcAddr == NULL)) {
SrcAddr = &Instance->Mode.CurrentAddress;
}
if (EFI_ERROR (NET_TRYLOCK (&GlobalData->Lock))) {
return EFI_ACCESS_DENIED;
}
ReturnValue = GlobalData->NtNetUtilityTable.Transmit (
Instance->InterfaceInfo.InterfaceIndex,
HeaderSize,
BufferSize,
Buffer,
SrcAddr,
DestAddr,
Protocol
);
NET_UNLOCK (&GlobalData->Lock);
if (ReturnValue < 0) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
EFI_STATUS
SnpNt32Receive (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
OUT UINTN *HeaderSize,
IN OUT UINTN *BuffSize,
OUT VOID *Buffer,
OUT EFI_MAC_ADDRESS *SourceAddr,
OUT EFI_MAC_ADDRESS *DestinationAddr,
OUT UINT16 *Protocol
)
/*++
Routine Description:
Receive network data.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?