⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 undi_nii.c

📁 网卡 BOOT ROM 的 64 住源程序。模块有:核心代码、H文件、网卡驱动程序、头代码文件。
💻 C
📖 第 1 页 / 共 3 页
字号:
#include "efi/efi.h"#include "etherboot.h"#include "isa.h"#include "dev.h"#include "nic.h"#include "timer.h"#warning "Place the declaraction of __call someplace more appropriate\n"extern EFI_STATUS __call(void *,...);#warning "Place a declaration of lookup_efi_nic somewhere useful"EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE *lookup_efi_nic(int index);struct sw_undi {	uint8_t  signature[4];	uint8_t  len;	uint8_t  fudge;	uint8_t  rev;	uint8_t  ifcnt;	uint8_t  major;	uint8_t  minor;	uint16_t reserved1;	uint32_t implementation;#define UNDI_IMP_CMD_COMPLETE_INT_SUPPORTED		0x00000001#define UNDI_IMP_PACKET_RX_INT_SUPPORTED		0x00000002#define UNDI_IMP_TX_COMPLETE_INT_SUPPORTED		0x00000004#define UNDI_IMP_SOFTWARE_INT_SUPPORTED			0x00000008#define UNDI_IMP_FILTERED_MULTICAST_RX_SUPPORTED	0x00000010#define UNDI_IMP_BROADCAST_RX_SUPPORTED			0x00000020#define UNDI_IMP_PROMISCUOUS_RX_SUPPORTED		0x00000040#define UNDI_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED	0x00000080#define UNDI_IMP_STATION_ADDR_SETTABLE			0x00000100#define UNDI_IMP_STATISTICS_SUPPORTED			0x00000200#define UNDI_IMP_NVDATA_SUPPORT_MASK			0x00000C00#define UNDI_IMP_NVDATA_NOT_AVAILABLE			0x00000000#define UNDI_IMP_NVDATA_READ_ONLY			0x00000400#define UNDI_IMP_NVDATA_SPARSE_WRITEABLE		0x00000800#define UNDI_IMP_NVDATA_BULK_WRITEABLE			0x00000C00#define UNDI_IMP_MULTI_FRAME_SUPPORTED			0x00001000#define UNDI_IMP_CMD_QUEUE_SUPPORTED			0x00002000#define UNDI_IMP_CMD_LINK_SUPPORTED			0x00004000#define UNDI_IMP_FRAG_SUPPORTED				0x00008000#define UNDI_IMP_64BIT_DEVICE				0x00010000#define UNDI_IMP_SW_VIRT_ADDR				0x40000000#define UNDI_IMP_HW_UNDI				0x80000000	uint64_t entry_point;	uint8_t  reserved2[3];	uint8_t  bus_type_cnt;	uint32_t bus_type[0];};struct cdb {	uint16_t op_code;#define CDB_OP_GET_STATE		0x0000#define CDB_OP_START			0x0001#define CDB_OP_STOP			0x0002#define CDB_OP_GET_INIT_INFO		0x0003#define CDB_OP_GET_CONFIG_INFO		0x0004#define CDB_OP_INITIALIZE		0x0005#define CDB_OP_RESET			0x0006#define CDB_OP_SHUTDOWN			0x0007#define CDB_OP_INTERRUPT_ENABLES	0x0008#define CDB_OP_RECEIVE_FILTERS		0x0009#define CDB_OP_STATION_ADDRESS		0x000a#define CDB_OP_STATISTICS		0x000b#define CDB_OP_MCAST_IP_TO_MAC		0x000c#define CDB_OP_NVDATA			0x000d#define CDB_OP_GET_STATUS		0x000e#define CDB_OP_FILL_HEADER		0x000f#define CDB_OP_TRANSMIT			0x0010#define CDB_OP_RECEIVE			0x0011	uint16_t op_flags;#define CDB_OPFLAGS_NOT_USED			0x0000/* Initialize */#define CDB_OPFLAGS_INIT_CABLE_DETECT_MASK	0x0001#define CDB_OPFLAGS_INIT_DETECT_CABLE		0x0000#define CDB_OPFLAGS_INIT_DO_NOT_DETECT_CABLE	0x0001/* Reset */#define CDB_OPFLAGS_RESET_DISABLE_INTERRUPTS	0x0001#define CDB_OPFLAGS_RESET_DISABLE_FILTERS	0x0002/* Interrupt Enables */#define CDB_OPFLAGS_INTERRUPT_OPMASK		0xc000#define CDB_OPFLAGS_INTERRUPT_ENABLE		0x8000#define CDB_OPFLAGS_INTERRUPT_DISABLE		0x4000#define CDB_OPFLAGS_INTERRUPT_READ		0x0000#define CDB_OPFLAGS_INTERRUPT_RECEIVE		0x0001#define CDB_OPFLAGS_INTERRUPT_TRANSMIT		0x0002#define CDB_OPFLAGS_INTERRUPT_COMMAND		0x0004#define CDB_OPFLAGS_INTERRUPT_SOFTWARE		0x0008/* Receive Filters */#define CDB_OPFLAGS_RECEIVE_FILTER_OPMASK		0xc000#define CDB_OPFLAGS_RECEIVE_FILTER_ENABLE		0x8000#define CDB_OPFLAGS_RECEIVE_FILTER_DISABLE		0x4000#define CDB_OPFLAGS_RECEIVE_FILTER_READ			0x0000#define CDB_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST	0x2000#define CDB_OPFLAGS_RECEIVE_FILTER_UNICAST		0x0001#define CDB_OPFLAGS_RECEIVE_FILTER_BROADCAST		0x0002#define CDB_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST	0x0004#define CDB_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS		0x0008#define CDB_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST	0x0010/* Station Address */#define CDB_OPFLAGS_STATION_ADDRESS_READ	0x0000#define CDB_OPFLAGS_STATION_ADDRESS_WRITE	0x0000#define CDB_OPFLAGS_STATION_ADDRESS_RESET	0x0001/* Statistics */#define CDB_OPFLAGS_STATISTICS_READ		0x0000#define CDB_OPFLAGS_STATISTICS_RESET		0x0001/* MCast IP to MAC */#define CDB_OPFLAGS_MCAST_IP_TO_MAC_OPMASK	0x0003#define CDB_OPFLAGS_MCAST_IPV4_TO_MAC		0x0000#define CDB_OPFLAGS_MCAST_IPV6_TO_MAC		0x0001/* NvData */#define CDB_OPFLAGS_NVDATA_OPMASK		0x0001#define CDB_OPFLAGS_NVDATA_READ			0x0000#define CDB_OPFLAGS_NVDATA_WRITE		0x0001/* Get Status */#define CDB_OPFLAGS_GET_INTERRUPT_STATUS	0x0001#define CDB_OPFLAGS_GET_TRANSMITTED_BUFFERS	0x0002/* Fill Header */#define CDB_OPFLAGS_FILL_HEADER_OPMASK		0x0001#define CDB_OPFLAGS_FILL_HEADER_FRAGMENTED	0x0001#define CDB_OPFLAGS_FILL_HEADER_WHOLE		0x0000/* Transmit */#define CDB_OPFLAGS_SWUNDI_TRANSMIT_OPMASK	0x0001#define CDB_OPFLAGS_TRANSMIT_BLOCK		0x0001#define CDB_OPFLAGS_TRANSMIT_DONT_BLOCK		0x0000#define CDB_OPFLAGS_TRANSMIT_OPMASK		0x0002#define CDB_OPFLAGS_TRANSMIT_FRAGMENTED		0x0002#define CDB_OPFLAGS_TRANSMIT_WHOLE		0x0000/* Receive */	uint16_t cpb_size;	uint16_t db_size;	uint64_t cpb_addr;	uint64_t db_addr;	uint16_t stat_code;#define CDB_STATCODE_INITIALIZE			0x0000/* Common stat_code values */#define CDB_STATCODE_SUCCESS			0x0000#define CDB_STATCODE_INVALID_CDB		0x0001#define CDB_STATCODE_INVALID_CPB		0x0002#define CDB_STATCODE_BUSY			0x0003#define CDB_STATCODE_QUEUE_FULL			0x0004#define CDB_STATCODE_ALREADY_STARTED		0x0005#define CDB_STATCODE_NOT_STARTED		0x0006#define CDB_STATCODE_NOT_SHUTDOWN		0x0007#define CDB_STATCODE_ALREADY_INITIALIZED	0x0008#define CDB_STATCODE_NOT_INITIALIZED		0x0009#define CDB_STATCODE_DEVICE_FAILURE		0x000A#define CDB_STATCODE_NVDATA_FAILURE		0x000B#define CDB_STATCODE_UNSUPPORTED		0x000C#define CDB_STATCODE_BUFFER_FULL		0x000D#define CDB_STATCODE_INVALID_PARAMETER		0x000E#define CDB_STATCODE_INVALID_UNDI		0x000F#define CDB_STATCODE_IPV4_NOT_SUPPORTED		0x0010#define CDB_STATCODE_IPV6_NOT_SUPPORTED		0x0011#define CDB_STATCODE_NOT_ENOUGH_MEMORY		0x0012#define CDB_STATCODE_NO_DATA			0x0013	uint16_t stat_flags;#define CDB_STATFLAGS_INITIALIZE		0x0000/* Common stat_flags */#define CDB_STATFLAGS_STATUS_MASK		0xc000#define CDB_STATFLAGS_COMMAND_COMPLETE		0xc000#define CDB_STATFLAGS_COMMAND_FAILED		0x8000#define CDB_STATFLAGS_COMMAND_QUEUED		0x4000/* Get State */#define CDB_STATFLAGS_GET_STATE_MASK		0x0003#define CDB_STATFLAGS_GET_STATE_INITIALIZED	0x0002#define CDB_STATFLAGS_GET_STATE_STARTED		0x0001#define CDB_STATFLAGS_GET_STATE_STOPPED		0x0000/* Start *//* Get Init Info */#define CDB_STATFLAGS_CABLE_DETECT_MASK			0x0001#define CDB_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED	0x0000#define CDB_STATFLAGS_CABLE_DETECT_SUPPORTED		0x0001/* Initialize */#define CDB_STATFLAGS_INITIALIZED_NO_MEDIA	0x0001/* Reset */#define CDB_STATFLAGS_RESET_NO_MEDIA		0x0001/* Shutdown *//* Interrupt Enables */#define CDB_STATFLAGS_INTERRUPT_RECEIVE		0x0001#define CDB_STATFLAGS_INTERRUPT_TRANSMIT	0x0002#define CDB_STATFLAGS_INTERRUPT_COMMAND		0x0004/* Receive Filters */#define CDB_STATFLAGS_RECEIVE_FILTER_UNICAST		0x0001#define CDB_STATFLAGS_RECEIVE_FILTER_BROADCAST		0x0002#define CDB_STATFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST	0x0004#define CDB_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS	0x0008#define CDB_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST	0x0010/* Statistics *//* MCast IP to MAC *//* NvData *//* Get Status */#define CDB_STATFLAGS_GET_STATUS_INTERRUPT_MASK		0x000F#define CDB_STATFLAGS_GET_STATUS_NO_INTERRUPTS		0x0000#define CDB_STATFLAGS_GET_STATUS_RECEIVE		0x0001#define CDB_STATFLAGS_GET_STATUS_TRANSMIT		0x0002#define CDB_STATFLAGS_GET_STATUS_COMMAND		0x0004#define CDB_STATFLAGS_GET_STATUS_SOFTWARE		0x0008#define CDB_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY	0x0010#define CDB_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN	0x0020/* Fill Header *//* Transmit *//* Receive */	uint16_t ifnum;#define CDB_IFNUM_START				0x0000#define CDB_IFNUM_INVALID			0x0000	uint16_t control;#define CDB_CONTROL_QUEUE_IF_BUSY		0x0002#define CDB_CONTROL_LINK			0x0001#define CDB_CONTROL_LAST_CDB_IN_LIST		0x0000};#define UNDI_MAC_LENGTH 32typedef uint8_t undi_mac_addr[UNDI_MAC_LENGTH];typedef uint16_t undi_media_protocol;typedef uint8_t undi_frame_type;#define UNDI_FRAME_TYPE_NONE		0x00#define UNDI_FRAME_TYPE_UNICAST		0x01#define UNDI_FRAME_TYPE_BROADCAST	0x02#define UNDI_FRAME_TYPE_MULTICAST	0x03#define UNDI_FRAME_TYPE_PROMISCUOUS	0x04#define UNDI_MAX_XMIT_BUFFERS 32#define UNDI_MAX_MCAST_ADDRESS_CNT 8#define UNDI_BUS_TYPE(a,b,c,d) \	((((d) & 0xff) << 24) | \	 (((c) & 0xff) << 16) | \	 (((b) & 0xff) <<  8) | \	 (((a) & 0xff) <<  0))#define UNDI_BUS_TYPE_PCI	UNDI_BUS_TYPE('P','C','I','R')#define UNDI_BUS_TYPE_PCC	UNDI_BUS_TYPE('P','C','C','R')#define UNDI_BUS_TYPE_USB	UNDI_BUS_TYPE('U','S','B','R')#define UNDI_BUS_TYPE_1394	UNDI_BUS_TYPE('1','3','9','4')struct cpb_start {	void *delay;	void *block;	void *virt2phys;	void *mem_io;} PACKED;struct db_init_info {	uint32_t memory_required;	uint32_t frame_data_len;	uint32_t link_speeds[4];	uint32_t nv_count;	uint16_t nv_width;	uint16_t media_header_len;	uint16_t hw_addr_len;	uint16_t mcast_filter_cnt;	uint16_t tx_buf_cnt;	uint16_t tx_buf_size;	uint16_t rx_buf_cnt;	uint16_t rx_buf_size;	uint8_t  if_type;	uint8_t  duplex;#define UNDI_DUPLEX_ENABLE_FULL_SUPPORTED	1#define UNDI_DUPLEX_FORCE_FULL_SUPPORTED	2	uint8_t  loopback;#define UNDI_LOOPBACK_INTERNAL_SUPPORTED	1#define UNDI_LOOPBACK_EXTERNAL_SUPPORTED	2} PACKED;struct db_pci_config_info {	uint32_t bus_type;	uint16_t bus;	uint8_t  device;	uint8_t  function;	uint8_t  config[256];};struct db_pcc_config_info {	uint32_t bus_type;	uint16_t bus;	uint8_t  device;	uint8_t  function;	uint8_t  config[256];};struct db_usb_config_info {	uint32_t bus_type;};struct db_iee1394_config_info {	uint32_t bus_type;};struct db_config_info {	union {		struct db_pci_config_info pci;		struct db_pcc_config_info pcc;		struct db_usb_config_info usb;		struct db_iee1394_config_info iee1394;	};};struct cpb_initialize {	uint64_t memory_addr;	uint32_t memory_length;	uint32_t link_speed;	uint16_t tx_buf_cnt;	uint16_t tx_buf_size;	uint16_t rx_buf_cnt;	uint16_t rx_buf_size;	uint8_t  duplex;	uint8_t  loopback;} PACKED;struct db_initialize {	uint32_t memory_used;	uint16_t tx_buf_cnt;	uint16_t tx_buf_size;	uint16_t rx_buf_cnt;	uint16_t rx_buf_size;} PACKED;struct cpb_station_address {	undi_mac_addr station_addr;} PACKED;struct db_station_address {	undi_mac_addr station_address;	undi_mac_addr broadcast_address;	undi_mac_addr permanent_address;} PACKED;struct cpb_receive_filters {	undi_mac_addr mcast_list[UNDI_MAX_MCAST_ADDRESS_CNT];} PACKED;struct db_receive_filters {	undi_mac_addr mcast_list[UNDI_MAX_MCAST_ADDRESS_CNT];} PACKED;struct db_get_status {	uint32_t rx_frame_len;	uint32_t reserved;	uint64_t tx_buffer[UNDI_MAX_XMIT_BUFFERS];} PACKED;struct cpb_transmit {	uint64_t frame_addr;	uint32_t data_len;	uint16_t media_header_len;	uint16_t reserved;} PACKED;struct cpb_receive {	uint64_t buffer_addr;	uint32_t buffer_len;	uint32_t reserved;} PACKED;struct db_receive {	undi_mac_addr src_addr;	undi_mac_addr dest_addr;	uint32_t frame_len;	undi_media_protocol protocol;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -