The Pedigree Project  0.1
modules/drivers/common/rtl8139/main.cc
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 #include "Rtl8139.h"
21 #include "modules/Module.h"
22 #include "pedigree/kernel/Log.h"
23 #include "pedigree/kernel/machine/Device.h"
24 #include "pedigree/kernel/machine/Network.h"
25 #include "pedigree/kernel/processor/Processor.h"
26 #include "pedigree/kernel/processor/types.h"
27 
28 void probeDevice(Device *pDev)
29 {
30  NOTICE("RTL8139 found");
31 
32  // Create a new RTL8139 node
33  Rtl8139 *pRtl8139 = new Rtl8139(reinterpret_cast<Network *>(pDev));
34 
35  // Replace pDev with pRtl8139.
36  pRtl8139->setParent(pDev->getParent());
37  pDev->getParent()->replaceChild(pDev, pRtl8139);
38 }
39 
40 void entry()
41 {
43  Device::searchByVendorIdAndDeviceId(
44  RTL8139_VENDOR_ID, RTL8139_DEVICE_ID, probeDevice);
45 }
46 
47 void exit()
48 {
49 }
50 
51 MODULE_INFO("rtl8139", &entry, &exit, "network-stack");
void replaceChild(Device *src, Device *dest)
Definition: Device.cc:168
Definition: Device.h:43
#define NOTICE(text)
Definition: Log.h:74
void setParent(Device *p)
Definition: Device.h:154
Device * getParent() const
Definition: Device.h:149