freebsd11_network: Cleanup haiku-module.h.
* init_hardware is unnecessary and mostly a duplicate of init_driver; so just remove it in favor of that. * Deduplify some of the _DRIVER macros as possible * Don't include net_stack.h, we don't need it here; and fix callout.h following that.
This commit is contained in:
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
|
||||||
|
#include <util/list.h>
|
||||||
|
|
||||||
|
|
||||||
struct callout {
|
struct callout {
|
||||||
struct list_link link;
|
struct list_link link;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
|
|
||||||
#include <kernel/lock.h>
|
#include <kernel/lock.h>
|
||||||
#include <net_stack.h>
|
|
||||||
|
|
||||||
#undef __unused
|
#undef __unused
|
||||||
#define __unused
|
#define __unused
|
||||||
@@ -64,7 +63,6 @@ typedef struct {
|
|||||||
#define DRIVER_MODULE_NAME(name, busname) \
|
#define DRIVER_MODULE_NAME(name, busname) \
|
||||||
__fbsd_ ## name ## _ ## busname
|
__fbsd_ ## name ## _ ## busname
|
||||||
|
|
||||||
status_t _fbsd_init_hardware(driver_t *driver[]);
|
|
||||||
status_t _fbsd_init_drivers(driver_t *driver[]);
|
status_t _fbsd_init_drivers(driver_t *driver[]);
|
||||||
status_t _fbsd_uninit_drivers(driver_t *driver[]);
|
status_t _fbsd_uninit_drivers(driver_t *driver[]);
|
||||||
|
|
||||||
@@ -85,15 +83,13 @@ status_t wlan_close(void*);
|
|||||||
* While gcc 2.95 packs everything from the static library onto
|
* While gcc 2.95 packs everything from the static library onto
|
||||||
* the final binary, gcc 4.x rightfuly doesn't. */
|
* the final binary, gcc 4.x rightfuly doesn't. */
|
||||||
|
|
||||||
#define HAIKU_FBSD_DRIVERS_GLUE(publicname) \
|
#define HAIKU_FBSD_DRIVERS_CORE_GLUE(publicname) \
|
||||||
extern const char *gDeviceNameList[]; \
|
extern const char *gDeviceNameList[]; \
|
||||||
extern device_hooks gDeviceHooks; \
|
extern device_hooks gDeviceHooks; \
|
||||||
const char *gDriverName = #publicname; \
|
const char *gDriverName = #publicname; \
|
||||||
int32 api_version = B_CUR_DRIVER_API_VERSION; \
|
int32 api_version = B_CUR_DRIVER_API_VERSION; \
|
||||||
status_t init_hardware() \
|
status_t init_hardware() \
|
||||||
{ \
|
{ return B_OK; } \
|
||||||
return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware); \
|
|
||||||
} \
|
|
||||||
status_t init_driver() \
|
status_t init_driver() \
|
||||||
{ \
|
{ \
|
||||||
return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers); \
|
return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers); \
|
||||||
@@ -105,7 +101,10 @@ status_t wlan_close(void*);
|
|||||||
const char **publish_devices() \
|
const char **publish_devices() \
|
||||||
{ return gDeviceNameList; } \
|
{ return gDeviceNameList; } \
|
||||||
device_hooks *find_device(const char *name) \
|
device_hooks *find_device(const char *name) \
|
||||||
{ return &gDeviceHooks; } \
|
{ return &gDeviceHooks; }
|
||||||
|
|
||||||
|
#define HAIKU_FBSD_DRIVERS_GLUE(publicname) \
|
||||||
|
HAIKU_FBSD_DRIVERS_CORE_GLUE(publicname) \
|
||||||
status_t init_wlan_stack(void) \
|
status_t init_wlan_stack(void) \
|
||||||
{ return B_OK; } \
|
{ return B_OK; } \
|
||||||
void uninit_wlan_stack(void) {} \
|
void uninit_wlan_stack(void) {} \
|
||||||
@@ -120,7 +119,7 @@ status_t wlan_close(void*);
|
|||||||
{ return B_OK; }
|
{ return B_OK; }
|
||||||
|
|
||||||
#define HAIKU_FBSD_DRIVER_GLUE(publicname, name, busname) \
|
#define HAIKU_FBSD_DRIVER_GLUE(publicname, name, busname) \
|
||||||
extern driver_t *DRIVER_MODULE_NAME(name, busname); \
|
extern driver_t* DRIVER_MODULE_NAME(name, busname); \
|
||||||
status_t __haiku_handle_fbsd_drivers_list(status_t (*proc)(driver_t *[])) {\
|
status_t __haiku_handle_fbsd_drivers_list(status_t (*proc)(driver_t *[])) {\
|
||||||
driver_t *drivers[] = { \
|
driver_t *drivers[] = { \
|
||||||
DRIVER_MODULE_NAME(name, busname), \
|
DRIVER_MODULE_NAME(name, busname), \
|
||||||
@@ -131,26 +130,7 @@ status_t wlan_close(void*);
|
|||||||
HAIKU_FBSD_DRIVERS_GLUE(publicname);
|
HAIKU_FBSD_DRIVERS_GLUE(publicname);
|
||||||
|
|
||||||
#define HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname) \
|
#define HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname) \
|
||||||
extern const char *gDeviceNameList[]; \
|
HAIKU_FBSD_DRIVERS_CORE_GLUE(publicname)
|
||||||
extern device_hooks gDeviceHooks; \
|
|
||||||
const char *gDriverName = #publicname; \
|
|
||||||
int32 api_version = B_CUR_DRIVER_API_VERSION; \
|
|
||||||
status_t init_hardware() \
|
|
||||||
{ \
|
|
||||||
return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware); \
|
|
||||||
} \
|
|
||||||
status_t init_driver() \
|
|
||||||
{ \
|
|
||||||
return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers); \
|
|
||||||
} \
|
|
||||||
void uninit_driver() \
|
|
||||||
{ \
|
|
||||||
__haiku_handle_fbsd_drivers_list(_fbsd_uninit_drivers); \
|
|
||||||
} \
|
|
||||||
const char **publish_devices() \
|
|
||||||
{ return gDeviceNameList; } \
|
|
||||||
device_hooks *find_device(const char *name) \
|
|
||||||
{ return &gDeviceHooks; }
|
|
||||||
|
|
||||||
#define HAIKU_FBSD_WLAN_DRIVER_GLUE(publicname, name, busname) \
|
#define HAIKU_FBSD_WLAN_DRIVER_GLUE(publicname, name, busname) \
|
||||||
extern driver_t *DRIVER_MODULE_NAME(name, busname); \
|
extern driver_t *DRIVER_MODULE_NAME(name, busname); \
|
||||||
|
|||||||
@@ -96,62 +96,6 @@ get_pci_info(struct device *device)
|
|||||||
// #pragma mark - Haiku Driver API
|
// #pragma mark - Haiku Driver API
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
_fbsd_init_hardware(driver_t *drivers[])
|
|
||||||
{
|
|
||||||
status_t status = B_ENTRY_NOT_FOUND;
|
|
||||||
device_t root;
|
|
||||||
pci_info *info;
|
|
||||||
driver_t *driver = NULL;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
status = init_root_device(&root);
|
|
||||||
if (status != B_OK)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
for (info = get_pci_info(root); gPci->get_nth_pci_info(i, info) == B_OK;
|
|
||||||
i++) {
|
|
||||||
int index;
|
|
||||||
driver = NULL;
|
|
||||||
|
|
||||||
for (index = 0; drivers[index] && gDeviceCount < MAX_DEVICES
|
|
||||||
&& driver == NULL; index++) {
|
|
||||||
int result;
|
|
||||||
device_t device;
|
|
||||||
status = add_child_device(drivers[index], root, &device);
|
|
||||||
if (status < B_OK)
|
|
||||||
break;
|
|
||||||
|
|
||||||
result = device->methods.probe(device);
|
|
||||||
if (result >= 0) {
|
|
||||||
TRACE(("%s, found %s at %d\n", gDriverName,
|
|
||||||
device_get_desc(device), i));
|
|
||||||
driver = drivers[index];
|
|
||||||
}
|
|
||||||
device_delete_child(root, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (driver != NULL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
device_delete_child(NULL, root);
|
|
||||||
|
|
||||||
if (driver == NULL) {
|
|
||||||
status = B_ERROR;
|
|
||||||
TRACE(("%s: no hardware found.\n", gDriverName));
|
|
||||||
}
|
|
||||||
err:
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
TRACE(("%s: status 0x%lx\n", gDriverName, status));
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
_fbsd_init_drivers(driver_t *drivers[])
|
_fbsd_init_drivers(driver_t *drivers[])
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user