* 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:
@@ -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.
|
||||
*
|
||||
* Authors:
|
||||
* Hugo Santos, [email protected]
|
||||
*
|
||||
* Some of this code is based on previous work by Marcus Overhagen.
|
||||
*/
|
||||
|
||||
#include "device.h"
|
||||
@@ -21,25 +18,26 @@
|
||||
#include <compat/dev/mii/miivar.h>
|
||||
|
||||
#define 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
|
||||
#define TRACE_PCI(dev, format, args...) do { } while (0)
|
||||
# define TRACE_PCI(dev, format, args...) do { } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
spinlock __haiku_intr_spinlock;
|
||||
|
||||
struct net_stack_module_info *gStack;
|
||||
pci_module_info *gPci;
|
||||
|
||||
|
||||
uint32_t
|
||||
pci_read_config(device_t dev, int offset, int size)
|
||||
{
|
||||
uint32_t value = gPci->read_pci_config(NETDEV(dev)->pci_info.bus,
|
||||
NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -47,7 +45,7 @@ pci_read_config(device_t dev, int offset, int size)
|
||||
void
|
||||
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,
|
||||
NETDEV(dev)->pci_info.device, NETDEV(dev)->pci_info.function,
|
||||
@@ -517,19 +515,17 @@ _kernel_contigfree(void *addr, size_t size)
|
||||
}
|
||||
|
||||
|
||||
/* Marcus' vtophys */
|
||||
unsigned long
|
||||
vtophys(vm_offset_t vaddr)
|
||||
vm_paddr_t
|
||||
pmap_kextract(vm_offset_t virtualAddress)
|
||||
{
|
||||
physical_entry pe;
|
||||
status_t status;
|
||||
|
||||
status = get_memory_map((void *)vaddr, 1, &pe, 1);
|
||||
if (status < 0)
|
||||
physical_entry entry;
|
||||
status_t status = get_memory_map((void *)virtualAddress, 1, &entry, 1);
|
||||
if (status < B_OK) {
|
||||
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.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Hugo Santos, [email protected]
|
||||
*/
|
||||
#ifndef _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 <lock.h> /* mutex, recursive_lock for mtx */
|
||||
#include <net_stack.h> /* net_timer, for callout */
|
||||
#undef ASSERT /* private/kernel/debug.h sets it */
|
||||
#include <lock.h>
|
||||
#include <net_stack.h>
|
||||
|
||||
#undef ASSERT
|
||||
/* private/kernel/debug.h sets it */
|
||||
|
||||
typedef struct device *device_t;
|
||||
typedef struct devclass *devclass_t;
|
||||
@@ -148,7 +148,7 @@ enum {
|
||||
driver_t driver = { #name, methods, size }
|
||||
|
||||
#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
|
||||
#endif /* _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ */
|
||||
|
||||
@@ -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_
|
||||
#define _FBSD_COMPAT_SYS_MALLOC_H_
|
||||
|
||||
@@ -9,6 +13,7 @@
|
||||
#define M_WAITOK 0x0002
|
||||
#define M_ZERO 0x0100
|
||||
|
||||
#define M_DEVBUF
|
||||
|
||||
void *_kernel_malloc(size_t size, int flags);
|
||||
void _kernel_free(void *ptr);
|
||||
@@ -24,7 +29,7 @@ void _kernel_contigfree(void *addr, unsigned long size);
|
||||
#define kernel_free( ptr, base) \
|
||||
_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, \
|
||||
alignment, boundary)
|
||||
|
||||
@@ -32,8 +37,11 @@ void _kernel_contigfree(void *addr, unsigned long size);
|
||||
_kernel_contigfree(addr, size)
|
||||
|
||||
#ifdef FBSD_DRIVER
|
||||
#define malloc(size, tag, flags) kernel_malloc(size, tag, flags)
|
||||
#define free(pointer, tag) kernel_free(pointer, tag)
|
||||
# define malloc(size, tag, flags) kernel_malloc(size, tag, flags)
|
||||
# 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 /* _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_
|
||||
#define _FBSD_COMPAT_VM_VM_H_
|
||||
|
||||
@@ -15,8 +19,8 @@ typedef void * pmap_t;
|
||||
#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_ */
|
||||
|
||||
Reference in New Issue
Block a user