* Since vtophys() is no public API in FreeBSD, vtophys() is now a macro to

pmap_kextract() not vice versa, just like it is done in FreeBSD itself.
* Added missing contigmalloc() definition for kernel drivers.
* Fixed the "*_devclass defined but not used" warning.
* Fixed warnings.
* Added/adjusted (to our style guide) the license headers for the files I
  touched.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22802 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-11-02 15:00:45 +00:00
parent 53715fe060
commit 00abfdbe15
4 changed files with 46 additions and 38 deletions
+17 -21
View File
@@ -1,11 +1,8 @@
/* /*
* Copyright 2007, Hugo Santos. All Rights Reserved. * Copyright 2007, Hugo Santos, [email protected]. All Rights Reserved.
* Copyright 2004, Marcus Overhagen. All Rights Reserved.
*
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*
* Authors:
* Hugo Santos, [email protected]
*
* Some of this code is based on previous work by Marcus Overhagen.
*/ */
#include "device.h" #include "device.h"
@@ -21,25 +18,26 @@
#include <compat/dev/mii/miivar.h> #include <compat/dev/mii/miivar.h>
#define DEBUG_PCI #define DEBUG_PCI
#ifdef DEBUG_PCI #ifdef DEBUG_PCI
#define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args) # define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args)
#else #else
#define TRACE_PCI(dev, format, args...) do { } while (0) # define TRACE_PCI(dev, format, args...) do { } while (0)
#endif #endif
spinlock __haiku_intr_spinlock; spinlock __haiku_intr_spinlock;
struct net_stack_module_info *gStack; struct net_stack_module_info *gStack;
pci_module_info *gPci; pci_module_info *gPci;
uint32_t uint32_t
pci_read_config(device_t dev, int offset, int size) pci_read_config(device_t dev, int offset, int size)
{ {
uint32_t value = gPci->read_pci_config(NETDEV(dev)->pci_info.bus, uint32_t value = gPci->read_pci_config(NETDEV(dev)->pci_info.bus,
NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function, NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function,
offset, size); offset, size);
TRACE_PCI(dev, "pci_read_config(%i, %i) = 0x%lx\n", offset, size, value); TRACE_PCI(dev, "pci_read_config(%i, %i) = 0x%x\n", offset, size, value);
return value; return value;
} }
@@ -47,7 +45,7 @@ pci_read_config(device_t dev, int offset, int size)
void void
pci_write_config(device_t dev, int offset, uint32_t value, int size) pci_write_config(device_t dev, int offset, uint32_t value, int size)
{ {
TRACE_PCI(dev, "pci_write_config(%i, 0x%lx, %i)\n", offset, value, size); TRACE_PCI(dev, "pci_write_config(%i, 0x%x, %i)\n", offset, value, size);
gPci->write_pci_config(NETDEV(dev)->pci_info.bus, gPci->write_pci_config(NETDEV(dev)->pci_info.bus,
NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function, NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function,
@@ -517,19 +515,17 @@ _kernel_contigfree(void *addr, size_t size)
} }
/* Marcus' vtophys */ vm_paddr_t
unsigned long pmap_kextract(vm_offset_t virtualAddress)
vtophys(vm_offset_t vaddr)
{ {
physical_entry pe; physical_entry entry;
status_t status; status_t status = get_memory_map((void *)virtualAddress, 1, &entry, 1);
if (status < B_OK) {
status = get_memory_map((void *)vaddr, 1, &pe, 1);
if (status < 0)
panic("fbsd compat: get_memory_map failed for %p, error %08lx\n", panic("fbsd compat: get_memory_map failed for %p, error %08lx\n",
(void *)vaddr, status); (void *)virtualAddress, status);
}
return (unsigned long)pe.address; return (vm_paddr_t)entry.address;
} }
@@ -1,19 +1,19 @@
/* /*
* Copyright 2007, Hugo Santos. All Rights Reserved. * Copyright 2007, Hugo Santos. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*
* Authors:
* Hugo Santos, [email protected]
*/ */
#ifndef _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ #ifndef _FBSD_COMPAT_SYS_HAIKU_MODULE_H_
#define _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ #define _FBSD_COMPAT_SYS_HAIKU_MODULE_H_
#include <Drivers.h> /* for device_hooks */
#include <Drivers.h>
#include <KernelExport.h> #include <KernelExport.h>
#include <lock.h> /* mutex, recursive_lock for mtx */ #include <lock.h>
#include <net_stack.h> /* net_timer, for callout */ #include <net_stack.h>
#undef ASSERT /* private/kernel/debug.h sets it */
#undef ASSERT
/* private/kernel/debug.h sets it */
typedef struct device *device_t; typedef struct device *device_t;
typedef struct devclass *devclass_t; typedef struct devclass *devclass_t;
@@ -148,7 +148,7 @@ enum {
driver_t driver = { #name, methods, size } driver_t driver = { #name, methods, size }
#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \ #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \
driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver) driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver); \
devclass_t *__class_ ## busname ## _ ## devclass = &(devclass)
#endif /* _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ */
#endif
@@ -1,3 +1,7 @@
/*
* Copyright 2007, Hugo Santos. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FBSD_COMPAT_SYS_MALLOC_H_ #ifndef _FBSD_COMPAT_SYS_MALLOC_H_
#define _FBSD_COMPAT_SYS_MALLOC_H_ #define _FBSD_COMPAT_SYS_MALLOC_H_
@@ -9,6 +13,7 @@
#define M_WAITOK 0x0002 #define M_WAITOK 0x0002
#define M_ZERO 0x0100 #define M_ZERO 0x0100
#define M_DEVBUF
void *_kernel_malloc(size_t size, int flags); void *_kernel_malloc(size_t size, int flags);
void _kernel_free(void *ptr); void _kernel_free(void *ptr);
@@ -24,7 +29,7 @@ void _kernel_contigfree(void *addr, unsigned long size);
#define kernel_free( ptr, base) \ #define kernel_free( ptr, base) \
_kernel_free(ptr) _kernel_free(ptr)
#define kernel_contigmalloc(size, base, flags, low, high, alignment, boundary) \ #define kernel_contigmalloc(size, type, flags, low, high, alignment, boundary) \
_kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \ _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \
alignment, boundary) alignment, boundary)
@@ -32,8 +37,11 @@ void _kernel_contigfree(void *addr, unsigned long size);
_kernel_contigfree(addr, size) _kernel_contigfree(addr, size)
#ifdef FBSD_DRIVER #ifdef FBSD_DRIVER
#define malloc(size, tag, flags) kernel_malloc(size, tag, flags) # define malloc(size, tag, flags) kernel_malloc(size, tag, flags)
#define free(pointer, tag) kernel_free(pointer, tag) # define free(pointer, tag) kernel_free(pointer, tag)
# define contigmalloc(size, type, flags, low, high, alignment, boundary) \
_kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \
alignment, boundary)
#endif #endif
#endif #endif /* _FBSD_COMPAT_SYS_MALLOC_H_ */
@@ -1,3 +1,7 @@
/*
* Copyright 2007, Hugo Santos. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FBSD_COMPAT_VM_VM_H_ #ifndef _FBSD_COMPAT_VM_VM_H_
#define _FBSD_COMPAT_VM_VM_H_ #define _FBSD_COMPAT_VM_VM_H_
@@ -15,8 +19,8 @@ typedef void * pmap_t;
#define pmap_extract(...) NULL #define pmap_extract(...) NULL
#define pmap_kextract(vaddr) vtophys(vaddr) vm_paddr_t pmap_kextract(vm_offset_t virtualAddress);
unsigned long vtophys(vm_offset_t vaddr); #define vtophys(vaddr) pmap_kextract(virtualAddress)
#endif #endif /* _FBSD_COMPAT_VM_VM_H_ */