freebsd compat. layer: some initial glue code
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21013 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1ba4119dda
commit
336ce7039c
@ -11,6 +11,7 @@ SubDirCcFlags [ FDefines _KERNEL=1 ] ;
|
|||||||
|
|
||||||
KernelAddon fxp :
|
KernelAddon fxp :
|
||||||
if_fxp.c
|
if_fxp.c
|
||||||
|
glue.c
|
||||||
: libfreebsd_network.a
|
: libfreebsd_network.a
|
||||||
;
|
;
|
||||||
|
|
||||||
|
3
src/add-ons/kernel/drivers/network/fxp/dev/fxp/glue.c
Normal file
3
src/add-ons/kernel/drivers/network/fxp/dev/fxp/glue.c
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include <sys/bus.h>
|
||||||
|
|
||||||
|
HAIKU_FBSD_DRIVER_GLUE(fxp, pci)
|
@ -133,9 +133,21 @@ int bus_setup_intr(device_t dev, struct resource *r, int flags,
|
|||||||
driver_intr_t handler, void *arg, void **cookiep);
|
driver_intr_t handler, void *arg, void **cookiep);
|
||||||
int bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
|
int bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
|
||||||
|
|
||||||
#define BUS_PROBE_DEFAULT -20
|
#define BUS_PROBE_DEFAULT 20
|
||||||
|
|
||||||
#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg)
|
#define DRIVER_MODULE_NAME(name, busname) \
|
||||||
|
__fbsd_##name##busname
|
||||||
|
|
||||||
|
driver_t *__fbsd_driver(void);
|
||||||
|
|
||||||
|
#define HAIKU_FBSD_DRIVER_GLUE(name, busname) \
|
||||||
|
driver_t *__fbsd_driver() { \
|
||||||
|
extern driver_t *DRIVER_MODULE_NAME(name, busname); \
|
||||||
|
return DRIVER_MODULE_NAME(name, busname); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \
|
||||||
|
driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver)
|
||||||
|
|
||||||
const char *device_get_name(device_t dev);
|
const char *device_get_name(device_t dev);
|
||||||
const char *device_get_nameunit(device_t dev);
|
const char *device_get_nameunit(device_t dev);
|
||||||
|
@ -11,11 +11,21 @@
|
|||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <Drivers.h>
|
||||||
|
|
||||||
#include <compat/sys/bus.h>
|
#include <compat/sys/bus.h>
|
||||||
#include <compat/sys/mbuf.h>
|
#include <compat/sys/mbuf.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_DEVICES 8
|
||||||
|
|
||||||
|
|
||||||
|
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||||
|
|
||||||
|
|
||||||
|
static char *sDevNameList[MAX_DEVICES + 1];
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
compat_open(const char *name, uint32 flags, void **cookie)
|
compat_open(const char *name, uint32 flags, void **cookie)
|
||||||
{
|
{
|
||||||
@ -70,7 +80,7 @@ compat_read(void *cookie, off_t position, void *buf, size_t *numBytes)
|
|||||||
IF_DEQUEUE(&dev->receive_queue, mb);
|
IF_DEQUEUE(&dev->receive_queue, mb);
|
||||||
} while (mb == NULL);
|
} while (mb == NULL);
|
||||||
|
|
||||||
len = min_c(max_c(mb->m_len, 0), *numBytes);
|
len = min_c(max_c((size_t)mb->m_len, 0), *numBytes);
|
||||||
|
|
||||||
// TODO we need something that cna join various chunks
|
// TODO we need something that cna join various chunks
|
||||||
memcpy(buf, mtod(mb, const void *), len);
|
memcpy(buf, mtod(mb, const void *), len);
|
||||||
@ -94,3 +104,75 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len)
|
|||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static device_hooks sDeviceHooks = {
|
||||||
|
compat_open,
|
||||||
|
compat_close,
|
||||||
|
compat_free,
|
||||||
|
compat_control,
|
||||||
|
compat_read,
|
||||||
|
compat_write,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
_device_probe(device_t dev)
|
||||||
|
{
|
||||||
|
device_method_t *methods = __fbsd_driver()->methods;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; methods[i].name != NULL; i++) {
|
||||||
|
if (!strcmp(methods[i].name, "device_probe"))
|
||||||
|
return methods[i].method(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("fsbd compat layer: method missing, device_probe");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
init_hardware()
|
||||||
|
{
|
||||||
|
struct device fakeDevice;
|
||||||
|
pci_info info;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
memset(&fakeDevice, 0, sizeof(struct device));
|
||||||
|
fakeDevice.pciInfo = &info;
|
||||||
|
|
||||||
|
for (i = 0; gPci->get_nth_pci_info(i, &info) == B_OK; i++) {
|
||||||
|
if (_device_probe(&fakeDevice) >= 0)
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
init_driver()
|
||||||
|
{
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
uninit_driver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char **
|
||||||
|
publish_devices()
|
||||||
|
{
|
||||||
|
return (const char **)sDevNameList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
device_hooks *
|
||||||
|
find_device(const char *name)
|
||||||
|
{
|
||||||
|
return &sDeviceHooks;
|
||||||
|
}
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
#include <compat/dev/mii/miivar.h>
|
#include <compat/dev/mii/miivar.h>
|
||||||
|
|
||||||
|
|
||||||
|
driver_t miibus_driver = {
|
||||||
|
"mii",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mii_phy_probe(device_t dev, device_t *miiDev, ifm_change_cb_t change,
|
mii_phy_probe(device_t dev, device_t *miiDev, ifm_change_cb_t change,
|
||||||
ifm_stat_cb_t stat)
|
ifm_stat_cb_t stat)
|
||||||
|
Loading…
Reference in New Issue
Block a user