Reimplemented _kernel_contigmalloc() to support the physical address

restrictions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37221 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-06-22 12:22:35 +00:00
parent 06a6bec0c0
commit c5e722714e
4 changed files with 78 additions and 18 deletions

View File

@ -17,6 +17,7 @@ KernelStaticLibrary libfreebsd_network.a :
callout.c
clock.c
compat.c
compat_cpp.cpp
condvar.c
Condvar.cpp
device.c

View File

@ -22,6 +22,8 @@
#include <compat/dev/mii/miivar.h>
#include "compat_cpp.h"
spinlock __haiku_intr_spinlock;
@ -587,24 +589,8 @@ _kernel_contigmalloc(const char *file, int line, size_t size, int flags,
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);
}

View File

@ -0,0 +1,46 @@
/*
* Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
* 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;
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
* 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 */