Author: bonefish Date: 2010-06-22 14:22:35 +0200 (Tue, 22 Jun 2010) New Revision: 37221 Changeset: http://dev.haiku-os.org/changeset/37221/haiku Added: haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.cpp haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.h Modified: haiku/trunk/src/libs/compat/freebsd_network/Jamfile haiku/trunk/src/libs/compat/freebsd_network/compat.c Log: Reimplemented _kernel_contigmalloc() to support the physical address restrictions. Modified: haiku/trunk/src/libs/compat/freebsd_network/Jamfile =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2010-06-21 23:22:59 UTC (rev 37220) +++ haiku/trunk/src/libs/compat/freebsd_network/Jamfile 2010-06-22 12:22:35 UTC (rev 37221) @@ -17,6 +17,7 @@ callout.c clock.c compat.c + compat_cpp.cpp condvar.c Condvar.cpp device.c Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2010-06-21 23:22:59 UTC (rev 37220) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2010-06-22 12:22:35 UTC (rev 37221) @@ -22,7 +22,9 @@ #include <compat/dev/mii/miivar.h> +#include "compat_cpp.h" + spinlock __haiku_intr_spinlock; struct net_stack_module_info *gStack; @@ -587,24 +589,8 @@ vm_paddr_t low, vm_paddr_t high, unsigned long alignment, unsigned long boundary) { - char name[256]; - area_id area; - void *addr; - - snprintf(name, sizeof(name), "contig:%s:%d", file, line); - - area = create_area(name, &addr, B_ANY_KERNEL_ADDRESS, size, - B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); - if (area < 0) - return NULL; - - if (flags & M_ZERO) - memset(addr, 0, size); - - //driver_printf("(%s) addr = %p, area = %ld, size = %lu\n", - // name, addr, area, size); - - return addr; + return _kernel_contigmalloc_cpp(file, line, size, low, high, + alignment, boundary, (flags & M_ZERO) != 0, (flags & M_NOWAIT) != 0); } Added: haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.cpp =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.cpp (rev 0) +++ haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.cpp 2010-06-22 12:22:35 UTC (rev 37221) @@ -0,0 +1,46 @@ +/* + * Copyright 2010, Ingo Weinhold, ingo_weinhold@xxxxxxx + * Distributed under the terms of the MIT License. + */ + + +#include "compat_cpp.h" + +#include <stdio.h> +#include <string.h> + +#include <kernel/vm/vm.h> + + +void* +_kernel_contigmalloc_cpp(const char* file, int line, size_t size, + phys_addr_t low, phys_addr_t high, phys_size_t alignment, + phys_size_t boundary, bool zero, bool dontWait) +{ + size = ROUNDUP(size, B_PAGE_SIZE); + + uint32 creationFlags = (zero ? 0 : CREATE_AREA_DONT_CLEAR) + | (dontWait ? CREATE_AREA_DONT_WAIT : 0); + + char name[B_OS_NAME_LENGTH]; + const char* baseName = strrchr(file, '/'); + baseName = baseName != NULL ? baseName + 1 : file; + snprintf(name, sizeof(name), "contig:%s:%d", baseName, line); + + virtual_address_restrictions virtualRestrictions = {}; + + physical_address_restrictions physicalRestrictions = {}; + physicalRestrictions.low_address = low; + physicalRestrictions.high_address = high; + physicalRestrictions.alignment = alignment; + physicalRestrictions.boundary = boundary; + + void* address; + area_id area = create_area_etc(B_SYSTEM_TEAM, name, size, B_CONTIGUOUS, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, creationFlags, + &virtualRestrictions, &physicalRestrictions, &address); + if (area < 0) + return NULL; + + return address; +} Added: haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.h (rev 0) +++ haiku/trunk/src/libs/compat/freebsd_network/compat_cpp.h 2010-06-22 12:22:35 UTC (rev 37221) @@ -0,0 +1,27 @@ +/* + * Copyright 2010, Ingo Weinhold, ingo_weinhold@xxxxxxx + * Distributed under the terms of the MIT License. + */ +#ifndef _FREE_BSD_NETWORK_COMPAT_CPP_H +#define _FREE_BSD_NETWORK_COMPAT_CPP_H + + +#include <SupportDefs.h> + + +#ifdef __cplusplus +extern "C" { +#endif + + +void* _kernel_contigmalloc_cpp(const char* file, int line, size_t size, + phys_addr_t low, phys_addr_t high, phys_size_t alignment, + phys_size_t boundary, bool zero, bool dontWait); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _FREE_BSD_NETWORK_COMPAT_CPP_H */