TianoCore EDK2 master
Loading...
Searching...
No Matches
Snp.h
Go to the documentation of this file.
1
9#ifndef _SNP_H_
10#define _SNP_H_
11
12#include <Uefi.h>
13
15#include <Protocol/PciIo.h>
17#include <Protocol/DevicePath.h>
18
19#include <Guid/EventGroup.h>
20
21#include <Library/DebugLib.h>
25#include <Library/BaseLib.h>
26#include <Library/UefiLib.h>
28#include <Library/PrintLib.h>
29#include <Library/PcdLib.h>
30
33
34#define FOUR_GIGABYTES (UINT64) 0x100000000ULL
35
36#define SNP_DRIVER_SIGNATURE SIGNATURE_32 ('s', 'n', 'd', 's')
37#define MAX_MAP_LENGTH 100
38
39#define PCI_BAR_IO_MASK 0x00000003
40#define PCI_BAR_IO_MODE 0x00000001
41
42#define PCI_BAR_MEM_MASK 0x0000000F
43#define PCI_BAR_MEM_MODE 0x00000000
44#define PCI_BAR_MEM_64BIT 0x00000004
45
46#define SNP_TX_BUFFER_INCREASEMENT MAX_XMIT_BUFFERS
47#define SNP_MAX_TX_BUFFER_NUM 65536
48
49typedef
51(EFIAPI *ISSUE_UNDI32_COMMAND)(
52 UINT64 Cdb
53 );
54
55typedef struct {
56 UINT32 Signature;
58
61
62 EFI_HANDLE DeviceHandle;
63 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
64
65 //
66 // Local instance data needed by SNP driver
67 //
68 // Pointer to S/W UNDI API entry point
69 // This will be NULL for H/W UNDI
70 //
71 ISSUE_UNDI32_COMMAND IssueUndi32Command;
72
73 BOOLEAN IsSwUndi;
74
75 //
76 // undi interface number, if one undi manages more nics
77 //
78 PXE_IFNUM IfNum;
79
80 //
81 // Allocated tx/rx buffer that was passed to UNDI Initialize.
82 //
83 UINT32 TxRxBufferSize;
84 VOID *TxRxBuffer;
85 //
86 // mappable buffers for receive and fill header for undi3.0
87 // these will be used if the user buffers are above 4GB limit (instead of
88 // mapping the user buffers)
89 //
90 UINT8 *ReceiveBufffer;
91 VOID *ReceiveBufferUnmap;
92 UINT8 *FillHeaderBuffer;
93 VOID *FillHeaderBufferUnmap;
94
96 UINT8 IoBarIndex;
97 UINT8 MemoryBarIndex;
98
99 //
100 // Buffers for command descriptor block, command parameter block
101 // and data block.
102 //
103 PXE_CDB Cdb;
104 VOID *Cpb;
105 VOID *CpbUnmap;
106 VOID *Db;
107
108 //
109 // UNDI structure, we need to remember the init info for a long time!
110 //
111 PXE_DB_GET_INIT_INFO InitInfo;
112
113 VOID *SnpDriverUnmap;
114 //
115 // when ever we map an address, we must remember it's address and the un-map
116 // cookie so that we can unmap later
117 //
118 struct MAP_LIST {
119 EFI_PHYSICAL_ADDRESS VirtualAddress;
120 VOID *MapCookie;
121 } MapList[MAX_MAP_LENGTH];
122
124
125 //
126 // Whether UNDI support reporting media status from GET_STATUS command,
127 // i.e. PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED or
128 // PXE_STATFLAGS_GET_STATUS_NO_MEDIA_NOT_SUPPORTED
129 //
130 BOOLEAN MediaStatusSupported;
131
132 //
133 // Whether UNDI support cable detect for INITIALIZE command,
134 // i.e. PXE_STATFLAGS_CABLE_DETECT_SUPPORTED or
135 // PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED
136 //
137 BOOLEAN CableDetectSupported;
138
139 //
140 // Array of the recycled transmit buffer address from UNDI.
141 //
142 UINT64 *RecycledTxBuf;
143 //
144 // The maximum number of recycled buffer pointers in RecycledTxBuf.
145 //
146 UINT32 MaxRecycledTxBuf;
147 //
148 // Current number of recycled buffer pointers in RecycledTxBuf.
149 //
150 UINT32 RecycledTxBufCount;
151} SNP_DRIVER;
152
153#define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, Snp, SNP_DRIVER_SIGNATURE)
154
155//
156// Global Variables
157//
158extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding;
159extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName;
160extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2;
161
172PxeStart (
173 IN SNP_DRIVER *Snp
174 );
175
188PxeStop (
189 SNP_DRIVER *Snp
190 );
191
204PxeInit (
205 SNP_DRIVER *Snp,
206 UINT16 CableDetectFlag
207 );
208
220 IN SNP_DRIVER *Snp
221 );
222
235 SNP_DRIVER *Snp
236 );
237
257 IN SNP_DRIVER *Snp,
258 OUT UINT32 *InterruptStatusPtr,
259 IN BOOLEAN GetTransmittedBuf
260 );
261
276VOID
277EFIAPI
279 IN UINT64 UniqueId,
280 IN UINT32 Enable
281 );
282
293VOID
294EFIAPI
296 IN UINT64 UniqueId,
297 IN UINT64 MicroSeconds
298 );
299
313VOID
314EFIAPI
316 IN UINT64 UniqueId,
317 IN UINT8 ReadOrWrite,
318 IN UINT8 NumBytes,
319 IN UINT64 MemOrPortAddr,
320 IN OUT UINT64 BufferPtr
321 );
322
337VOID
338EFIAPI
340 IN UINT64 UniqueId,
341 IN UINT64 CpuAddr,
342 IN UINT32 NumBytes,
343 IN UINT32 Direction,
344 IN OUT UINT64 DeviceAddrPtr
345 );
346
361VOID
362EFIAPI
364 IN UINT64 UniqueId,
365 IN UINT64 CpuAddr,
366 IN UINT32 NumBytes,
367 IN UINT32 Direction,
368 IN UINT64 DeviceAddr
369 );
370
392VOID
393EFIAPI
395 IN UINT64 UniqueId,
396 IN UINT64 CpuAddr,
397 IN UINT32 NumBytes,
398 IN UINT32 Direction,
399 IN UINT64 DeviceAddr
400 );
401
419EFIAPI
422 );
423
443EFIAPI
446 );
447
482EFIAPI
485 IN UINTN ExtraRxBufferSize OPTIONAL,
486 IN UINTN ExtraTxBufferSize OPTIONAL
487 );
488
514EFIAPI
517 IN BOOLEAN ExtendedVerification
518 );
519
540EFIAPI
543 );
544
640EFIAPI
643 IN UINT32 Enable,
644 IN UINT32 Disable,
645 IN BOOLEAN ResetMCastFilter,
646 IN UINTN MCastFilterCnt OPTIONAL,
647 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
648 );
649
683EFIAPI
686 IN BOOLEAN Reset,
687 IN EFI_MAC_ADDRESS *New OPTIONAL
688 );
689
738EFIAPI
741 IN BOOLEAN Reset,
742 IN OUT UINTN *StatisticsSize OPTIONAL,
743 IN OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
744 );
745
775EFIAPI
778 IN BOOLEAN IPv6,
779 IN EFI_IP_ADDRESS *IP,
781 );
782
835EFIAPI
838 IN BOOLEAN ReadWrite,
839 IN UINTN Offset,
840 IN UINTN BufferSize,
841 IN OUT VOID *Buffer
842 );
843
883EFIAPI
886 OUT UINT32 *InterruptStatus OPTIONAL,
887 OUT VOID **TxBuf OPTIONAL
888 );
889
945EFIAPI
948 IN UINTN HeaderSize,
949 IN UINTN BufferSize,
950 IN VOID *Buffer,
951 IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
952 IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
953 IN UINT16 *Protocol OPTIONAL
954 );
955
1005EFIAPI
1008 OUT UINTN *HeaderSize OPTIONAL,
1009 IN OUT UINTN *BufferSize,
1010 OUT VOID *Buffer,
1011 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
1012 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
1013 OUT UINT16 *Protocol OPTIONAL
1014 );
1015
1023VOID
1024EFIAPI
1026 EFI_EVENT Event,
1027 VOID *SnpPtr
1028 );
1029
1030#define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)
1031
1032#endif /* _SNP_H_ */
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS EFIAPI Lock(IN EFI_SMM_ACCESS2_PROTOCOL *This)
Definition: SmmAccessDxe.c:133
EFI_STATUS PxeStop(SNP_DRIVER *Snp)
Definition: Stop.c:21
EFI_STATUS EFIAPI SnpUndi32NvData(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN BOOLEAN ReadWrite, IN UINTN Offset, IN UINTN BufferSize, IN OUT VOID *Buffer)
Definition: Nvdata.c:144
EFI_STATUS PxeGetStnAddr(SNP_DRIVER *Snp)
VOID EFIAPI SnpUndi32CallbackMap(IN UINT64 UniqueId, IN UINT64 CpuAddr, IN UINT32 NumBytes, IN UINT32 Direction, IN OUT UINT64 DeviceAddrPtr)
Definition: Callback.c:199
EFI_STATUS PxeStart(IN SNP_DRIVER *Snp)
Definition: Start.c:21
EFI_STATUS PxeInit(SNP_DRIVER *Snp, UINT16 CableDetectFlag)
Definition: Initialize.c:24
VOID EFIAPI SnpUndi32CallbackUnmap(IN UINT64 UniqueId, IN UINT64 CpuAddr, IN UINT32 NumBytes, IN UINT32 Direction, IN UINT64 DeviceAddr)
Definition: Callback.c:294
EFI_STATUS EFIAPI SnpUndi32Stop(IN EFI_SIMPLE_NETWORK_PROTOCOL *This)
Definition: Stop.c:84
EFI_STATUS EFIAPI SnpUndi32Statistics(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN BOOLEAN Reset, IN OUT UINTN *StatisticsSize OPTIONAL, IN OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL)
Definition: Statistics.c:60
EFI_STATUS EFIAPI SnpUndi32Initialize(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN UINTN ExtraRxBufferSize OPTIONAL, IN UINTN ExtraTxBufferSize OPTIONAL)
Definition: Initialize.c:181
VOID EFIAPI SnpUndi32CallbackBlock(IN UINT64 UniqueId, IN UINT32 Enable)
Definition: Callback.c:30
EFI_STATUS EFIAPI SnpUndi32Transmit(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)
Definition: Transmit.c:270
EFI_STATUS EFIAPI SnpUndi32McastIpToMac(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN BOOLEAN IPv6, IN EFI_IP_ADDRESS *IP, OUT EFI_MAC_ADDRESS *MAC)
EFI_STATUS EFIAPI SnpUndi32Shutdown(IN EFI_SIMPLE_NETWORK_PROTOCOL *This)
Definition: Shutdown.c:90
EFI_STATUS EFIAPI SnpUndi32ReceiveFilters(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN UINT32 Enable, IN UINT32 Disable, IN BOOLEAN ResetMCastFilter, IN UINTN MCastFilterCnt OPTIONAL, IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL)
VOID EFIAPI SnpUndi32CallbackMemio(IN UINT64 UniqueId, IN UINT8 ReadOrWrite, IN UINT8 NumBytes, IN UINT64 MemOrPortAddr, IN OUT UINT64 BufferPtr)
Definition: Callback.c:89
VOID EFIAPI SnpUndi32CallbackDelay(IN UINT64 UniqueId, IN UINT64 MicroSeconds)
Definition: Callback.c:62
EFI_STATUS PxeShutdown(IN SNP_DRIVER *Snp)
Definition: Shutdown.c:21
VOID EFIAPI SnpUndi32CallbackSync(IN UINT64 UniqueId, IN UINT64 CpuAddr, IN UINT32 NumBytes, IN UINT32 Direction, IN UINT64 DeviceAddr)
Definition: Callback.c:348
EFI_STATUS PxeGetStatus(IN SNP_DRIVER *Snp, OUT UINT32 *InterruptStatusPtr, IN BOOLEAN GetTransmittedBuf)
Definition: Get_status.c:30
EFI_STATUS EFIAPI SnpUndi32Receive(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, OUT UINTN *HeaderSize OPTIONAL, IN OUT UINTN *BufferSize, OUT VOID *Buffer, OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, OUT UINT16 *Protocol OPTIONAL)
Definition: Receive.c:191
EFI_STATUS EFIAPI SnpUndi32GetStatus(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, OUT UINT32 *InterruptStatus OPTIONAL, OUT VOID **TxBuf OPTIONAL)
Definition: Get_status.c:199
EFI_STATUS EFIAPI SnpUndi32Reset(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Definition: Reset.c:87
EFI_STATUS EFIAPI SnpUndi32StationAddress(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN BOOLEAN Reset, IN EFI_MAC_ADDRESS *New OPTIONAL)
EFI_STATUS EFIAPI SnpUndi32Start(IN EFI_SIMPLE_NETWORK_PROTOCOL *This)
Definition: Start.c:113
VOID EFIAPI SnpWaitForPacketNotify(EFI_EVENT Event, VOID *SnpPtr)
Definition: WaitForPacket.c:20
VOID EFIAPI ExitBootServicesEvent(IN EFI_EVENT Event, IN VOID *Context)
Definition: TimerDxe.c:92
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
Definition: Snp.h:55