The Pedigree Project  0.1
Rtl8139.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 RTL8139_H
21 #define RTL8139_H
22 
23 #include "pedigree/kernel/machine/Device.h"
24 #include "pedigree/kernel/machine/IrqHandler.h"
25 #include "pedigree/kernel/machine/Network.h"
26 #include "pedigree/kernel/process/Semaphore.h"
27 #include "pedigree/kernel/process/Thread.h"
28 #include "pedigree/kernel/processor/IoBase.h"
29 #include "pedigree/kernel/processor/IoPort.h"
30 #include "pedigree/kernel/processor/MemoryRegion.h"
31 #include "pedigree/kernel/processor/PhysicalMemoryManager.h"
32 #include "pedigree/kernel/processor/types.h"
33 
34 #define RTL8139_VENDOR_ID 0x10ec
35 #define RTL8139_DEVICE_ID 0x8139
36 
38 class Rtl8139 : public Network, public IrqHandler
39 {
40  public:
41  Rtl8139(Network *pDev);
42  ~Rtl8139();
43 
44  virtual void getName(String &str)
45  {
46  str = "rtl8139";
47  }
48 
49  virtual bool send(size_t nBytes, uintptr_t buffer);
50 
51  virtual bool setStationInfo(StationInfo info);
52 
53  virtual StationInfo getStationInfo();
54 
55  virtual bool isConnected();
56 
57  // IRQ handler callback.
58  virtual bool irq(irq_id_t number, InterruptState &state);
59 
60  IoBase *m_pBase;
61 
62  private:
63  void recv();
64 
65  void reset();
66 
67  struct packet
68  {
69  uintptr_t ptr;
70  size_t len;
71  };
72 
73  StationInfo m_StationInfo;
74 
75  uint32_t m_RxCurr;
76  uint8_t m_TxCurr;
77 
78  volatile bool m_RxLock;
79  Spinlock m_TxLock;
80 
81  uint8_t *m_pRxBuffVirt;
82  uint8_t *m_pTxBuffVirt;
83 
84  uintptr_t m_pRxBuffPhys;
85  uintptr_t m_pTxBuffPhys;
86 
87  MemoryRegion m_RxBuffMR;
88  MemoryRegion m_TxBuffMR;
89 
90  Rtl8139(const Rtl8139 &);
91  void operator=(const Rtl8139 &);
92 };
93 
94 #endif
virtual bool isConnected()
Definition: Rtl8139.cc:271
virtual bool irq(irq_id_t number, InterruptState &state)
Definition: Rtl8139.cc:276
virtual void getName(String &str)
Definition: Rtl8139.h:44
Definition: String.h:49
Abstrace base class for hardware I/O capabilities.
Definition: IoBase.h:31
virtual StationInfo getStationInfo()
Definition: Rtl8139.cc:266
Special memory entity in the kernel's virtual address space.
Definition: MemoryRegion.h:35
virtual bool send(size_t nBytes, uintptr_t buffer)
Definition: Rtl8139.cc:149