From 4a241f2ac30f7539467e086d9af1dabfde8bd997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 1 Dec 2007 17:34:59 +0000 Subject: [PATCH] Some more extensions to the FreeBSD compatibility layer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23043 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/compat/freebsd_network/bus.c | 44 +++++++++++++++++++ .../freebsd_network/compat/dev/pci/pcivar.h | 17 +++++++ .../freebsd_network/compat/sys/callout.h | 12 ++++- .../compat/freebsd_network/compat/sys/param.h | 18 +++++++- 4 files changed, 87 insertions(+), 4 deletions(-) diff --git a/src/libs/compat/freebsd_network/bus.c b/src/libs/compat/freebsd_network/bus.c index 5ca5c0b139..000ad01a68 100644 --- a/src/libs/compat/freebsd_network/bus.c +++ b/src/libs/compat/freebsd_network/bus.c @@ -515,6 +515,50 @@ pci_get_revid(device_t dev) } +uint32_t +pci_get_domain(device_t dev) +{ + return 0; +} + + +uint8_t +pci_get_bus(device_t dev) +{ + pci_info *info + = &((struct root_device_softc *)dev->root->softc)->pci_info; + return info->bus; +} + + +uint8_t +pci_get_slot(device_t dev) +{ + pci_info *info + = &((struct root_device_softc *)dev->root->softc)->pci_info; + return info->device; +} + + +uint8_t +pci_get_function(device_t dev) +{ + pci_info *info + = &((struct root_device_softc *)dev->root->softc)->pci_info; + return info->function; +} + + +device_t +pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot, uint8_t func) +{ + // We don't support that yet - if we want to support the multi port + // feature of the Broadcom BCM 570x driver, we would have to change + // that. + return NULL; +} + + static void pci_set_command_bit(device_t dev, uint16_t bit) { diff --git a/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h b/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h index fc33ef2e0e..8dde0ba799 100644 --- a/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h +++ b/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h @@ -9,6 +9,10 @@ #include +#define PCI_RF_DENSE 0x10000 + // ignored on x86 + + int pci_enable_busmaster(device_t dev); int pci_enable_io(device_t dev, int reg); @@ -25,6 +29,13 @@ uint8_t pci_get_revid(device_t dev); uint32_t pci_read_config(device_t dev, int reg, int width); void pci_write_config(device_t dev, int reg, uint32_t val, int width); +uint32_t pci_get_domain(device_t dev); +uint8_t pci_get_bus(device_t dev); +uint8_t pci_get_slot(device_t dev); +uint8_t pci_get_function(device_t dev); +device_t pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot, + uint8_t func); + int pci_find_extcap(device_t dev, int capability, int *capreg); int pci_msi_count(device_t dev); @@ -33,4 +44,10 @@ int pci_release_msi(device_t dev); int pci_msix_count(device_t dev); int pci_alloc_msix(device_t dev, int *count); +static inline int +pci_get_vpd_ident(device_t dev, const char **identptr) +{ + return -1; +} + #endif /* _FBSD_COMPAT_DEV_PCI_PCIVAR_H_ */ diff --git a/src/libs/compat/freebsd_network/compat/sys/callout.h b/src/libs/compat/freebsd_network/compat/sys/callout.h index 8395676d12..8084c6750e 100644 --- a/src/libs/compat/freebsd_network/compat/sys/callout.h +++ b/src/libs/compat/freebsd_network/compat/sys/callout.h @@ -1,3 +1,7 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FBSD_COMPAT_SYS_CALLOUT_H_ #define _FBSD_COMPAT_SYS_CALLOUT_H_ @@ -16,13 +20,17 @@ struct callout { }; -void callout_init_mtx(struct callout *, struct mtx *, int); +void callout_init_mtx(struct callout *c, struct mtx *mutex, int flags); int callout_reset(struct callout *, int, void (*)(void *), void *); #define callout_drain(c) _callout_stop_safe(c, 1) #define callout_stop(c) _callout_stop_safe(c, 0) int _callout_stop_safe(struct callout *, int); +#define callout_pending(c) ((c)->c_timer.due > 0) +#define callout_active(c) ((c)->c_timer.due == -1) + // TODO: there is currently no way to find out about this! + static inline void callout_init(struct callout *c, int mpsafe) @@ -33,4 +41,4 @@ callout_init(struct callout *c, int mpsafe) callout_init_mtx(c, &Giant, 0); } -#endif +#endif /* _FBSD_COMPAT_SYS_CALLOUT_H_ */ diff --git a/src/libs/compat/freebsd_network/compat/sys/param.h b/src/libs/compat/freebsd_network/compat/sys/param.h index 1816d57030..77515c1fc9 100644 --- a/src/libs/compat/freebsd_network/compat/sys/param.h +++ b/src/libs/compat/freebsd_network/compat/sys/param.h @@ -1,8 +1,18 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FBSD_COMPAT_SYS_PARAM_H_ #define _FBSD_COMPAT_SYS_PARAM_H_ + #include + +/* The version this compatibility layer is based on */ +#define __FreeBSD_version 700053 + + #define MAXBSIZE 0x10000 #define PAGE_SHIFT 12 @@ -28,11 +38,15 @@ #define MCLSHIFT 11 #endif -#define MCLBYTES (1 << MCLSHIFT) +#define MCLBYTES (1 << MCLSHIFT) + +#define MJUMPAGESIZE PAGE_SIZE +#define MJUM9BYTES (9 * 1024) +#define MJUM16BYTES (16 * 1024) #define ALIGN_BYTES (sizeof(int) - 1) #define ALIGN(x) ((((unsigned)x) + ALIGN_BYTES) & ~ALIGN_BYTES) #define roundup2(x, y) (((x) + ((y) - 1)) & (~((y) - 1))) -#endif +#endif /* _FBSD_COMPAT_SYS_PARAM_H_ */