The Pedigree Project  0.1
3Com90x.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef NIC_3C90X_H
21 #define NIC_3C90X_H
22 
23 #include "pedigree/kernel/machine/IrqHandler.h"
24 #include "pedigree/kernel/machine/Network.h"
25 #include "pedigree/kernel/machine/types.h"
26 #include "pedigree/kernel/process/Semaphore.h"
27 #include "pedigree/kernel/processor/MemoryRegion.h"
28 #include "pedigree/kernel/processor/state_forward.h"
29 #include "pedigree/kernel/processor/types.h"
30 #include "pedigree/kernel/utilities/List.h"
31 #include "pedigree/kernel/utilities/String.h"
32 
33 class IoBase;
34 
36 class Nic3C90x : public Network, public IrqHandler
37 {
38  public:
39  Nic3C90x(Network *pDev);
40  ~Nic3C90x();
41 
42  virtual void getName(String &str)
43  {
44  str = "3C90x";
45  }
46 
47  virtual bool send(size_t nBytes, uintptr_t buffer);
48 
49  virtual bool setStationInfo(const StationInfo &info);
50 
51  virtual const StationInfo &getStationInfo();
52 
53  // IRQ handler callback.
54  virtual bool irq(irq_id_t number, InterruptState &state);
55 
56  IoBase *m_pBase;
57 
58  private:
59  int issueCommand(int cmd, int param);
60 
61  int setWindow(int window);
62 
63  uint16_t readEeprom(int address);
64 
65  int writeEepromWord(int address, uint16_t value);
66  int writeEeprom(int address, uint16_t value);
67 
68  static int trampoline(void *p);
69 
70  void receiveThread();
71 
72  void reset();
73 
75  uint8_t m_isBrev;
76  uint8_t m_CurrentWindow;
77 
78  uint8_t *m_pRxBuffVirt;
79  uint8_t *m_pTxBuffVirt;
80  uintptr_t m_pRxBuffPhys;
81  uintptr_t m_pTxBuffPhys;
82  MemoryRegion m_RxBuffMR;
83  MemoryRegion m_TxBuffMR;
84 
85  uintptr_t m_pDPD;
86  MemoryRegion m_DPDMR;
87 
88  uintptr_t m_pUPD;
89  MemoryRegion m_UPDMR;
90 
92  struct TXD
93  {
94  uint32_t DnNextPtr;
95  uint32_t FrameStartHeader;
96  // uint32_t HdrAddr;
97  // uint32_t HdrLength;
98  uint32_t DataAddr;
99  uint32_t DataLength;
100  } __attribute__((aligned(8)));
101 
103  struct RXD
104  {
105  uint32_t UpNextPtr;
106  uint32_t UpPktStatus;
107  uint32_t DataAddr;
108  uint32_t DataLength;
109  } __attribute__((aligned(8)));
110 
111  TXD *m_TransmitDPD;
112  RXD *m_ReceiveUPD;
113 
114  Nic3C90x(const Nic3C90x &);
115  void operator=(const Nic3C90x &);
116 
117  Semaphore m_RxMutex;
118  Semaphore m_TxMutex;
119 
120  List<void *> m_PendingPackets;
121 };
122 
123 #endif
virtual bool irq(irq_id_t number, InterruptState &state)
Definition: 3Com90x.cc:667
int setWindow(int window)
Definition: 3Com90x.cc:102
Definition: cmd.h:30
int issueCommand(int cmd, int param)
Definition: 3Com90x.cc:83
void reset()
Definition: 3Com90x.cc:204
uint8_t m_isBrev
Definition: 3Com90x.h:75
Definition: String.h:49
virtual const StationInfo & getStationInfo()
Definition: 3Com90x.cc:795
Abstrace base class for hardware I/O capabilities.
Definition: IoBase.h:31
virtual void getName(String &str)
Definition: 3Com90x.h:42
Nic3C90x(Network *pDev)
Definition: 3Com90x.cc:315
Special memory entity in the kernel&#39;s virtual address space.
Definition: MemoryRegion.h:35
uint16_t readEeprom(int address)
Definition: 3Com90x.cc:115
int writeEeprom(int address, uint16_t value)
Definition: 3Com90x.cc:168
int writeEepromWord(int address, uint16_t value)
Definition: 3Com90x.cc:135
virtual bool send(size_t nBytes, uintptr_t buffer)
Definition: 3Com90x.cc:267
virtual bool setStationInfo(const StationInfo &info)
Definition: 3Com90x.cc:761