The Pedigree Project 0.1
Classes | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Ne2k Class Reference

#include <Ne2k.h>

+ Inheritance diagram for Ne2k:
+ Collaboration diagram for Ne2k:

Classes

struct  packet
 

Public Member Functions

 Ne2k (Network *pDev)
 
virtual void getName (String &str)
 
virtual bool send (size_t nBytes, uintptr_t buffer)
 
virtual bool setStationInfo (const StationInfo &info)
 
virtual const StationInfo & getStationInfo ()
 
virtual IrqDisposition irq (irq_id_t number)
 
bool isConnected ()
 
bool isValid () const
 
- Public Member Functions inherited from Network
 Network (Network *pDev)
 
virtual Type getType ()
 
virtual void dump (String &str)
 
virtual void gotPacket ()
 
virtual void droppedPacket ()
 Called when a packet is dropped by the system.
 
virtual void badPacket ()
 
- Public Member Functions inherited from Device
 Device (Device *p)
 
Device * getParent () const
 
void setParent (Device *p)
 
virtual const String & getSpecificType ()
 
virtual void setSpecificType (String str)
 
void setPciPosition (uint32_t bus, uint32_t device, uint32_t func)
 
void setPciIdentifiers (uint8_t classCode, uint8_t subclassCode, uint16_t vendorId, uint16_t deviceId, uint8_t progIf)
 
void setPciConfigHeader (const PciBus::ConfigSpace &space)
 
PciBus::ConfigSpace getPciConfigHeader () const
 
uint8_t getPciClassCode ()
 
uint8_t getPciSubclassCode ()
 
uint16_t getPciVendorId ()
 
uint16_t getPciDeviceId ()
 
uint8_t getPciProgInterface ()
 
uint32_t getPciBusPosition ()
 
uint32_t getPciDevicePosition ()
 
uint32_t getPciFunctionNumber ()
 
Device * getPhysicalFunction () const
 
size_t getVirtualFunctionIndex () const
 
void setVirtualFunction (Device *physicalFunction, size_t index)
 
virtual Vector< Address * > & addresses ()
 
virtual uintptr_t getInterruptNumber ()
 
virtual void setInterruptNumber (uintptr_t n)
 
void addChild (Device *pDevice)
 
Device * getChild (size_t n)
 
size_t getNumChildren ()
 
void removeChild (size_t n)
 
void removeChild (Device *d)
 
void replaceChild (Device *src, Device *dest)
 
- Public Member Functions inherited from IrqHandler
virtual bool acceptsSpuriousInterrupts () const
 

Public Attributes

IoBase * m_pBase
 

Private Member Functions

bool recv ()
 
bool waitForRemoteDma ()
 
bool resetController ()
 
bool recoverReceiveOverflow (uint8_t irqStatus)
 
void advanceReceiveBoundary (uint8_t nextPacket)
 
void receiveThread ()
 
 Ne2k (const Ne2k &)
 
void operator= (const Ne2k &)
 

Static Private Member Functions

static int trampoline (void *p)
 

Private Attributes

uint8_t m_NextPacket
 
Semaphore m_PacketQueueSize
 
List< packet * > m_PacketQueue
 
Spinlock m_PacketQueueLock
 
Mutex m_DmaLock
 
irq_id_t m_IrqId
 
bool m_Stopping
 
bool m_NetworkRegistered
 
OwnedThread m_ReceiveThread
 

Additional Inherited Members

- Public Types inherited from Device
enum  Type {
  Generic , Root , Disk , Bus ,
  Display , Network , Sound , Console ,
  Mouse , Controller , UsbController , UsbGeneric ,
  UsbContainer
}
 
typedef Device *(* Callback) (Device *)
 
- Static Public Member Functions inherited from Network
static EXPORTED_PUBLIC uint32_t convertToIpv4 (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 
static EXPORTED_PUBLIC IpAddress convertToIpv6 (uint8_t a, uint8_t b=0, uint8_t c=0, uint8_t d=0, uint8_t e=0, uint8_t f=0, uint8_t g=0, uint8_t h=0, uint8_t i=0, uint8_t j=0, uint8_t k=0, uint8_t l=0, uint8_t m=0, uint8_t n=0, uint8_t o=0, uint8_t p=0)
 
static EXPORTED_PUBLIC uint16_t calculateChecksum (uintptr_t buffer, size_t nBytes)
 
- Static Public Member Functions inherited from Device
static bool treeLockHeldByCurrentThread ()
 
static void foreach (Callback callback, Device *root=0)
 
template<class F , class... Args>
static void foreach (pedigree_std::Callable< F > &callback, Device *root, Args... args)
 
static void addToRoot (Device *device)
 
static void searchByVendorId (uint16_t vendorId, void(*callback)(Device *), Device *root=0)
 
static void searchByVendorIdAndDeviceId (uint16_t vendorId, uint16_t deviceId, void(*callback)(Device *), Device *root=0)
 
static void searchByClass (uint16_t classCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassAndSubclass (uint16_t classCode, uint16_t subclassCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassSubclassAndProgInterface (uint16_t classCode, uint16_t subclassCode, uint8_t progInterface, void(*callback)(Device *), Device *root=0)
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 
- Protected Member Functions inherited from IrqHandler
virtual ~IrqHandler ()
 
- Protected Member Functions inherited from IrqHandlerBase
virtual ~IrqHandlerBase ()
 
- Static Protected Member Functions inherited from Device
static Device & root ()
 
- Protected Attributes inherited from Network
StationInfo m_StationInfo
 
- Protected Attributes inherited from Device
Vector< Address * > m_Addresses
 
Vector< Device * > m_Children
 
Device * m_pParent
 
Device * m_PhysicalFunction
 
size_t m_VirtualFunctionIndex
 
uintptr_t m_InterruptNumber
 
String m_SpecificType
 
PciBus::ConfigSpace m_ConfigHeader
 
uint8_t m_ClassCode
 
uint8_t m_SubclassCode
 
uint16_t m_VendorId
 
uint16_t m_DeviceId
 
uint8_t m_ProgInterface
 
uint32_t m_PciBusPos
 
uint32_t m_PciDevicePos
 
uint32_t m_PciFunctionNum
 
- Static Protected Attributes inherited from Device
static Device m_Root
 
static Mutex m_TreeLock
 

Detailed Description

Device driver for the NE2K class of network device

Definition at line 42 of file Ne2k.h.

Constructor & Destructor Documentation

◆ Ne2k()

Ne2k::Ne2k ( Network *  pDev)

◆ ~Ne2k()

Ne2k::~Ne2k ( )
virtual

Definition at line 189 of file Ne2k.cc.

Member Function Documentation

◆ advanceReceiveBoundary()

void Ne2k::advanceReceiveBoundary ( uint8_t  nextPacket)
private

Definition at line 406 of file Ne2k.cc.

◆ getName()

virtual void Ne2k::getName ( String &  str)
inlinevirtual

Stores the device's name in str.

Reimplemented from Network.

Definition at line 47 of file Ne2k.h.

◆ getStationInfo()

const StationInfo & Ne2k::getStationInfo ( )
virtual

Gets station information (such as IP addresses)

Reimplemented from Network.

Definition at line 615 of file Ne2k.cc.

◆ irq()

IrqDisposition Ne2k::irq ( irq_id_t  number)
virtual

Handles a pending IRQ in thread context.

Implements IrqHandler.

Definition at line 619 of file Ne2k.cc.

References IoBase::read8(), and IoBase::write8().

◆ isConnected()

bool Ne2k::isConnected ( )
virtual

Is this device actually connected to a network?

Reimplemented from Network.

Definition at line 663 of file Ne2k.cc.

◆ isValid()

bool Ne2k::isValid ( ) const
inline

Definition at line 63 of file Ne2k.h.

◆ receiveThread()

void Ne2k::receiveThread ( )
private

Definition at line 549 of file Ne2k.cc.

◆ recoverReceiveOverflow()

bool Ne2k::recoverReceiveOverflow ( uint8_t  irqStatus)
private

Definition at line 370 of file Ne2k.cc.

◆ recv()

bool Ne2k::recv ( )
private

Definition at line 411 of file Ne2k.cc.

◆ resetController()

bool Ne2k::resetController ( )
private

Definition at line 313 of file Ne2k.cc.

◆ send()

bool Ne2k::send ( size_t  nBytes,
uintptr_t  buffer 
)
virtual

Sends a given packet through the device.

Parameters
nBytesThe number of bytes to send.
bufferA buffer with the packet to send

Implements Network.

Definition at line 223 of file Ne2k.cc.

References Dec, Hex, ProcessorBase::pause(), IoBase::read8(), IoBase::write16(), and IoBase::write8().

◆ setStationInfo()

bool Ne2k::setStationInfo ( const StationInfo &  info)
virtual

Sets station information (such as IP addresses)

Parameters
infoThe information to set as the station info

Reimplemented from Network.

Definition at line 585 of file Ne2k.cc.

References Dec, StationInfo::gateway, Hex, and StationInfo::nDnsServers.

◆ trampoline()

int Ne2k::trampoline ( void *  p)
staticprivate

Definition at line 543 of file Ne2k.cc.

◆ waitForRemoteDma()

bool Ne2k::waitForRemoteDma ( )
private

Definition at line 303 of file Ne2k.cc.

Member Data Documentation

◆ m_DmaLock

Mutex Ne2k::m_DmaLock
private

Definition at line 88 of file Ne2k.h.

◆ m_IrqId

irq_id_t Ne2k::m_IrqId
private

Definition at line 90 of file Ne2k.h.

◆ m_NetworkRegistered

bool Ne2k::m_NetworkRegistered
private

Definition at line 92 of file Ne2k.h.

◆ m_NextPacket

uint8_t Ne2k::m_NextPacket
private

Definition at line 82 of file Ne2k.h.

◆ m_PacketQueue

List<packet*> Ne2k::m_PacketQueue
private

Definition at line 85 of file Ne2k.h.

◆ m_PacketQueueLock

Spinlock Ne2k::m_PacketQueueLock
private

Definition at line 87 of file Ne2k.h.

◆ m_PacketQueueSize

Semaphore Ne2k::m_PacketQueueSize
private

Definition at line 84 of file Ne2k.h.

◆ m_pBase

IoBase* Ne2k::m_pBase

Definition at line 60 of file Ne2k.h.

◆ m_ReceiveThread

OwnedThread Ne2k::m_ReceiveThread
private

Definition at line 93 of file Ne2k.h.

◆ m_Stopping

bool Ne2k::m_Stopping
private

Definition at line 91 of file Ne2k.h.


The documentation for this class was generated from the following files: