Author: zguo
Date: Fri Apr 12 15:06:11 2013
New Revision: 58733
URL:
http://svn.reactos.org/svn/reactos?rev=58733&view=rev
Log:
[RTL8139]
Add header files for RTL8139 drivers holding function definitions and register addresses.
Still incomplete/some holdovers from old ne2000 driver which will get pruned as more of
the driver is rewritten. Not committing the actual driver code yet due to the need to
massively clean it up. Not yet added to compilation.
CORE-7081
Added:
trunk/reactos/drivers/network/dd/rtl8139/ (with props)
trunk/reactos/drivers/network/dd/rtl8139/include/ (with props)
trunk/reactos/drivers/network/dd/rtl8139/include/8139.h (with props)
trunk/reactos/drivers/network/dd/rtl8139/include/debug.h (with props)
trunk/reactos/drivers/network/dd/rtl8139/include/nic.h (with props)
Propchange: trunk/reactos/drivers/network/dd/rtl8139/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Fri Apr 12 15:06:11 2013
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/reactos/drivers/network/dd/rtl8139/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/reactos/drivers/network/dd/rtl8139/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/drivers/network/dd/rtl8139/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Propchange: trunk/reactos/drivers/network/dd/rtl8139/include/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Fri Apr 12 15:06:11 2013
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/reactos/drivers/network/dd/rtl8139/include/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/reactos/drivers/network/dd/rtl8139/include/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/drivers/network/dd/rtl8139/include/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Added: trunk/reactos/drivers/network/dd/rtl8139/include/8139.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
==============================================================================
--- trunk/reactos/drivers/network/dd/rtl8139/include/8139.h (added)
+++ trunk/reactos/drivers/network/dd/rtl8139/include/8139.h [iso-8859-1] Fri Apr 12
15:06:11 2013
@@ -1,0 +1,146 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS RTL8139 Driver
+ * FILE: include/8139.h
+ * PURPOSE: 8139 NIC definitions
+ */
+
+#pragma once
+//Register addresses
+#define R_MAC 0x00 //MAC address uses bytes 0-5, 6 and 7 are reserved
+#define R_MCAST0 0x08 //Multicast registers
+#define R_MCAST1 0x09 //Multicast registers
+#define R_MCAST2 0x0A
+#define R_MCAST3 0x0B
+#define R_MCAST4 0x0C
+#define R_MCAST5 0x0D
+#define R_MCAST6 0x0E
+#define R_MCAST7 0x0F
+#define R_TXSTS0 0x10 //TX status, 0x10-0x13, 4 bytes
+#define R_TXSTS1 0x14
+#define R_TXSTS2 0x18
+#define R_TXSTS3 0x1C
+#define R_TXSAD0 0x20 //TX start address of descriptor 0
+#define R_TXSAD1 0x24
+#define R_TXSAD2 0x28
+#define R_TXSAD3 0x2C
+#define R_RXSA 0x30 //RX buffer start address
+#define R_ERXBC 0x34 //Early RX byte count register
+#define R_ERXSTS 0x36 //Early RX status register
+
+#define R_CMD 0x37 //Command register
+#define B_CMD_TXE 0x04 //Enable TX
+#define B_CMD_RXE 0x08 //Enable RX
+#define B_CMD_RST 0x10 //Reset bit
+
+#define R_CAPR 0x38 //Current address of packet read
+#define R_CBA 0x3A //Current buffer address
+#define R_IM 0x3C //Interrupt mask register
+#define R_IS 0x3E //Interrupt status register
+#define R_TC 0x40 //Transmit configuration register
+
+#define R_RC 0x44 //Receive configuration register
+#define B_RC_AAP 0x01 //Accept all packets
+#define B_RC_APM 0x02 //Accept packets sent to device MAC
+#define B_RC_AM 0x04 //Accept multicast packets
+#define B_RC_AB 0x08 //Accept broadcast packets
+#define B_RC_AR 0x10 //Accept runt (smaller than 64bytes) packets
+
+#define R_TCTR 0x48 //Timer counter register
+#define R_MPC 0x4C //Missed packet counter
+#define R_9346CR 0x50 //93C46 command register
+#define R_CFG0 0x51 //Configuration register 0
+#define R_CFG1 0x52
+#define R_TINTR 0x54 //Timer interrupt register
+#define R_MS 0x58 //Media status register
+#define R_CFG3 0x59 //Configuration register 3
+#define R_CFG4 0x5A //Configuration register 4
+#define R_MINTS 0x5C //Multiple interrupt select
+#define R_PCIID 0x5E //PCI Revision ID = 0x10
+#define R_DTSTS 0x60 //TX status of all descriptors
+#define R_BMC 0x62 //Basic mode control register
+#define R_BMSTS 0x64 //Basic mode status register
+#define R_ANA 0x66 //Auto-negotiation advertisement
+#define R_ANLP 0x68 //Auto-negotiation link partner
+#define R_ANEX 0x6A //Auto-negotiation expansion
+#define R_DCTR 0x6C //Disconnect counter
+#define R_FCSCTR 0x6E //False carrier sense counter
+#define R_NWT 0x70 //N-way test register
+#define R_RXERRCTR 0x72 //RX error counter
+#define R_CSCFG 0x74 //CS configuration register
+#define R_PHYP1 0x78 //PHY parameter 1
+#define R_TWP 0x7C //Twister parameter
+#define R_PHYP2 0x80 //PHY parameter 2
+#define R_PCRC0 0x84 //Power management CRC for wakeup frame 0
+#define R_PCRC1 0x85
+#define R_PCRC2 0x86
+#define R_PCRC3 0x87
+#define R_PCRC4 0x88
+#define R_PCRC5 0x89
+#define R_PCRC6 0x8A
+#define R_PCRC7 0x8B
+#define R_WAKE0 0x8C //Power management wakeup frame 0
+#define R_WAKE1 0x94
+#define R_WAKE2 0x9C
+#define R_WAKE3 0xA4
+#define R_WAKE4 0xAC
+#define R_WAKE5 0xB4
+#define R_WAKE6 0xBC
+#define R_WAKE7 0xC4
+#define R_LSBCRC0 0xCC //LSB of the mask byte of wakeup frame 0 within offset 12
to 75
+#define R_LSBCRC0 0xCD
+#define R_LSBCRC0 0xCE
+#define R_LSBCRC0 0xCF
+#define R_LSBCRC0 0xD0
+#define R_LSBCRC0 0xD1
+#define R_LSBCRC0 0xD2
+#define R_LSBCRC0 0xD3
+#define R_CFG5 0xD8 //Configuration register 5
+
+//EEPROM Control Bytes
+#define EE_DATA_READ 0x01 //Chip data out
+#define EE_DATA_WRITE 0x02 //Chip data in
+#define EE_SHIFT_CLK 0x04 //Chip shift clock
+#define EE_CS 0x08 //Chip select
+#define EE_ENB 0x88 //Chip enable
+
+
+//EEPROM Commands
+#define EE_READ_CMD 0x06
+
+
+/* NIC prepended structure to a received packet */
+typedef struct _PACKET_HEADER {
+ UCHAR Status; /* See RSR_* constants */
+ UCHAR NextPacket; /* Pointer to next packet in chain */
+ USHORT PacketLength; /* Length of packet including this header */
+} PACKET_HEADER, *PPACKET_HEADER;
+
+#define IEEE_802_ADDR_LENGTH 6
+
+/* Ethernet frame header */
+typedef struct _ETH_HEADER {
+ UCHAR Destination[IEEE_802_ADDR_LENGTH];
+ UCHAR Source[IEEE_802_ADDR_LENGTH];
+ USHORT PayloadType;
+} ETH_HEADER, *PETH_HEADER;
+
+typedef struct _DISCARD_HEADER {
+ PACKET_HEADER HWHeader;
+ ETH_HEADER EthernetHeader;
+} DISCARD_HEADER, *PDISCARD_HEADER;
+
+#define NICDisableInterrupts(Adapter) { \
+ NDIS_DbgPrint(MAX_TRACE, ("NICDisableInterrupts()\n")); \
+ NdisRawWritePortUchar((Adapter)->IOBase + PG0_IMR, 0x00); \
+}
+
+#define NICEnableInterrupts(Adapter) { \
+ NDIS_DbgPrint(MAX_TRACE, ("NICEnableInterrupts() Mask (0x%X)\n",
(Adapter)->InterruptMask)); \
+ NdisRawWritePortUchar((Adapter)->IOBase + PG0_IMR, (Adapter)->InterruptMask);
\
+}
+
+VOID NTAPI MiniportHandleInterrupt(
+ IN NDIS_HANDLE MiniportAdapterContext);
+
+/* EOF */
Propchange: trunk/reactos/drivers/network/dd/rtl8139/include/8139.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/drivers/network/dd/rtl8139/include/debug.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
==============================================================================
--- trunk/reactos/drivers/network/dd/rtl8139/include/debug.h (added)
+++ trunk/reactos/drivers/network/dd/rtl8139/include/debug.h [iso-8859-1] Fri Apr 12
15:06:11 2013
@@ -1,0 +1,82 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Novell Eagle 2000 driver
+ * FILE: include/debug.h
+ * PURPOSE: Debugging support macros
+ * DEFINES: DBG - Enable debug output
+ * NASSERT - Disable assertions
+ */
+
+#pragma once
+
+#define NORMAL_MASK 0x000000FF
+#define SPECIAL_MASK 0xFFFFFF00
+#define MIN_TRACE 0x00000001
+#define MID_TRACE 0x00000002
+#define MAX_TRACE 0x00000003
+
+#define DEBUG_MEMORY 0x00000100
+#define DEBUG_ULTRA 0xFFFFFFFF
+
+#if DBG
+
+extern ULONG DebugTraceLevel;
+
+#ifdef _MSC_VER
+
+#define NDIS_DbgPrint(_t_, _x_) \
+ if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
+ ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
+ DbgPrint("(%s:%d) ", __FILE__, __LINE__); \
+ DbgPrint _x_ ; \
+ }
+
+#else /* _MSC_VER */
+
+#define NDIS_DbgPrint(_t_, _x_) \
+ if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
+ ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
+ DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
+ DbgPrint _x_ ; \
+ }
+
+#endif /* _MSC_VER */
+
+
+#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
+#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql() == (x))
+
+#else /* DBG */
+
+#define NDIS_DbgPrint(_t_, _x_)
+
+#define ASSERT_IRQL(x)
+#define ASSERT_IRQL_EQUAL(x)
+/* #define ASSERT(x) */ /* ndis.h */
+
+#endif /* DBG */
+
+
+#define assert(x) ASSERT(x)
+#define assert_irql(x) ASSERT_IRQL(x)
+
+
+#ifdef _MSC_VER
+
+#define UNIMPLEMENTED \
+ NDIS_DbgPrint(MIN_TRACE, ("The function at %s:%d is unimplemented, \
+ but come back another day.\n", __FILE__, __LINE__));
+
+#else /* _MSC_VER */
+
+#define UNIMPLEMENTED \
+ NDIS_DbgPrint(MIN_TRACE, ("%s at %s:%d is unimplemented, \
+ but come back another day.\n", __FUNCTION__, __FILE__, __LINE__));
+
+#endif /* _MSC_VER */
+
+
+#define CHECKPOINT \
+ do { NDIS_DbgPrint(MIN_TRACE, ("%s:%d\n", __FILE__, __LINE__)); }
while(0);
+
+/* EOF */
Propchange: trunk/reactos/drivers/network/dd/rtl8139/include/debug.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/drivers/network/dd/rtl8139/include/nic.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
==============================================================================
--- trunk/reactos/drivers/network/dd/rtl8139/include/nic.h (added)
+++ trunk/reactos/drivers/network/dd/rtl8139/include/nic.h [iso-8859-1] Fri Apr 12
15:06:11 2013
@@ -1,0 +1,247 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Novell Eagle 2000 driver
+ * FILE: include/ne2000.h
+ * PURPOSE: NE2000 driver definitions
+ */
+
+#define NDIS_MINIPORT_DRIVER 1
+#define NDIS_LEGACY_MINIPORT 1
+#define NDIS51_MINIPORT 1
+#include <ndis.h>
+#include <8139.h>
+#include <debug.h>
+
+/* Define NOCARD to test NDIS without a card */
+//#define NOCARD
+
+/* NE2000 sepcific constants */
+#define NIC_DATA 0x10 /* Data register */
+#define NIC_RESET 0x1F /* Reset register */
+
+
+/* Global constants */
+
+#define DRIVER_NDIS_MAJOR_VERSION 0x05
+#define DRIVER_NDIS_MINOR_VERSION 0
+
+#define DRIVER_DEFAULT_IO_BASE_ADDRESS 0x280 /* bochs default */
+#define DRIVER_DEFAULT_INTERRUPT_NUMBER 9 /* bochs default */
+#define DRIVER_DEFAULT_INTERRUPT_SHARED FALSE
+#define DRIVER_DEFAULT_INTERRUPT_MODE NdisInterruptLatched
+
+#define DRIVER_MAX_MULTICAST_LIST_SIZE 8
+
+#define DRIVER_VENDOR_DESCRIPTION "RTL 8139 Adapter."
+#define DRIVER_VENDOR_DRIVER_VERSION 0x0100 /* 1.0 */
+
+#define DRIVER_FRAME_SIZE 1514 /* Size of an ethernet frame */
+#define DRIVER_HEADER_SIZE 14 /* Size of an ethernet header */
+#define DRIVER_LENGTH_OF_ADDRESS 6 /* Size of an ethernet address */
+
+/* Maximum lookahead buffer size */
+#define DRIVER_MAXIMUM_LOOKAHEAD (252 - DRIVER_HEADER_SIZE)
+
+/* Size of a block in a buffer ring */
+#define DRIVER_BLOCK_SIZE 256
+
+
+/* Default number of transmit buffers */
+#define DRIVER_DEFAULT_TX_BUFFER_COUNT 12
+#define BUFFERS_PER_TX_BUF 1
+
+/* Interrupt Mask Register value */
+#define DRIVER_INTERRUPT_MASK IMR_ALLE - IMR_RDCE
+
+/* Maximum number of interrupts handled per call to MiniportHandleInterrupt */
+#define INTERRUPT_LIMIT 10
+
+/* Global structures */
+
+typedef struct _MINIPORT_RESERVED
+{
+ PNDIS_PACKET Next;
+} MINIPORT_RESERVED, *PMINIPORT_RESERVED;
+
+#define RESERVED(Packet) ((PMINIPORT_RESERVED)((Packet)->MiniportReserved))
+
+typedef UCHAR DRIVER_HARDWARE_ADDRESS[DRIVER_LENGTH_OF_ADDRESS];
+
+/* Information about an adapter */
+typedef struct _NIC_ADAPTER
+{
+ /* Entry on global adapter list */
+ LIST_ENTRY ListEntry;
+ /* Adapter handle */
+ NDIS_HANDLE MiniportAdapterHandle;
+ /* NDIS interrupt object */
+ NDIS_MINIPORT_INTERRUPT Interrupt;
+
+ /* I/O base address and interrupt number of adapter */
+ ULONG_PTR IoBaseAddress;
+ ULONG InterruptLevel;
+ ULONG InterruptVector;
+ BOOLEAN InterruptShared;
+ KINTERRUPT_MODE InterruptMode;
+
+ /* Mapped address of the I/O base port */
+ PUCHAR IOBase;
+
+ /* TRUE if the NIC can transfer in word mode */
+ BOOLEAN WordMode;
+
+ /* Base address and size of the onboard memory window */
+ PUCHAR RamBase;
+ UINT RamSize;
+
+ /* Station Address PROM (SAPROM) */
+ UCHAR SAPROM[16];
+
+ /* Onboard ethernet address from the manufacturer */
+ DRIVER_HARDWARE_ADDRESS PermanentAddress;
+
+ /* Ethernet address currently in use */
+ DRIVER_HARDWARE_ADDRESS StationAddress;
+
+ /* Maximum number of multicast addresses this adapter supports */
+ ULONG MaxMulticastListSize;
+
+ /* List of multicast addresses in use */
+ DRIVER_HARDWARE_ADDRESS Addresses[DRIVER_MAX_MULTICAST_LIST_SIZE];
+
+ /* Current multicast address mask */
+ UCHAR MulticastAddressMask[8];
+
+ /* Masked interrupts (IMR value) */
+ ULONG InterruptMask;
+
+ /* Interrupts that have occurred */
+ UCHAR InterruptStatus;
+
+ /* Current packet filter */
+ ULONG PacketFilter;
+
+ /* Lookahead buffer */
+ UINT LookaheadSize;
+ UCHAR Lookahead[DRIVER_MAXIMUM_LOOKAHEAD + DRIVER_HEADER_SIZE];
+
+ /* Receive buffer ring */
+ UINT PageStart;
+ UINT PageStop;
+ UINT CurrentPage;
+ UINT NextPacket;
+
+ /* TRUE if there was a buffer overflow */
+ BOOLEAN BufferOverflow;
+
+ /* TRUE if an error occurred during reception of a packet */
+ BOOLEAN ReceiveError;
+
+ /* TRUE if an error occurred during transmission of a packet */
+ BOOLEAN TransmitError;
+
+ /* TRUE if a transmit interrupt is pending */
+ BOOLEAN TransmitPending;
+
+ /* Received packet header */
+ PACKET_HEADER PacketHeader;
+
+ /* Offset in onboard RAM of received packet */
+ ULONG PacketOffset;
+
+ /* TRUE if receive indications are done and should be completed */
+ BOOLEAN DoneIndicating;
+
+ /* Transmit buffers */
+ UINT TXStart; /* Start block of transmit buffer ring */
+ UINT TXCount; /* Number of blocks in transmit buffer ring */
+ UINT TXFree; /* Number of free transmit buffers */
+ UINT TXNext; /* Next buffer to use */
+ /* Length of packet. 0 means buffer is unused */
+ UINT TXSize[DRIVER_DEFAULT_TX_BUFFER_COUNT];
+ INT TXCurrent; /* Current buffer beeing transmitted. -1 means none */
+
+ /* Head of transmit queue */
+ PNDIS_PACKET TXQueueHead;
+ /* Tail of transmit queue */
+ PNDIS_PACKET TXQueueTail;
+
+ /* Statistics */
+ ULONG FrameAlignmentErrors;
+ ULONG CrcErrors;
+ ULONG MissedPackets;
+
+ /* Flags used for driver cleanup */
+ BOOLEAN IOPortRangeRegistered;
+ BOOLEAN InterruptRegistered;
+ BOOLEAN ShutdownHandlerRegistered;
+} NIC_ADAPTER, *PNIC_ADAPTER;
+
+/* Global driver information */
+typedef struct _DRIVER_INFORMATION
+{
+ NDIS_HANDLE NdisWrapperHandle; /* Returned from NdisInitializeWrapper */
+ NDIS_HANDLE NdisMacHandle; /* Returned from NdisRegisterMac */
+ LIST_ENTRY AdapterListHead; /* Adapters this driver control */
+} DRIVER_INFORMATION, *PDRIVER_INFORMATION;
+
+
+
+/* Global variable */
+
+extern DRIVER_INFORMATION DriverInfo;
+extern NDIS_PHYSICAL_ADDRESS HighestAcceptableMax;
+
+
+
+/* Prototypes */
+
+BOOLEAN NICCheck(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICInitialize(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICSetup(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICStart(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICStop(
+ PNIC_ADAPTER Adapter);
+
+NDIS_STATUS NICReset(
+ PNIC_ADAPTER Adapter);
+
+VOID NICUpdateCounters(
+ PNIC_ADAPTER Adapter);
+
+VOID NICReadDataAlign(
+ PNIC_ADAPTER Adapter,
+ PUSHORT Target,
+ ULONG_PTR Source,
+ USHORT Length);
+
+VOID NICWriteDataAlign(
+ PNIC_ADAPTER Adapter,
+ ULONG_PTR Target,
+ PUSHORT Source,
+ USHORT Length);
+
+VOID NICReadData(
+ PNIC_ADAPTER Adapter,
+ PUCHAR Target,
+ ULONG_PTR Source,
+ USHORT Length);
+
+VOID NICWriteData(
+ PNIC_ADAPTER Adapter,
+ ULONG_PTR Target,
+ PUCHAR Source,
+ USHORT Length);
+
+VOID NICTransmit(
+ PNIC_ADAPTER Adapter);
+
+/* EOF */
Propchange: trunk/reactos/drivers/network/dd/rtl8139/include/nic.h
------------------------------------------------------------------------------
svn:eol-style = native