* Added B_PHYSICAL_BASE_ADDRESS address specification for anonymous areas.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26456 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-07-16 23:32:25 +00:00
parent 736352dcf5
commit 6db6b628d6
4 changed files with 14 additions and 5 deletions

View File

@ -86,6 +86,7 @@ typedef struct {
/* address specifications for mapping physical memory */
#define B_ANY_KERNEL_BLOCK_ADDRESS (B_ANY_KERNEL_ADDRESS + 1)
#define B_PHYSICAL_BASE_ADDRESS (B_ANY_KERNEL_ADDRESS + 2)
/* area protection flags for the kernel */
#define B_KERNEL_READ_AREA 16

View File

@ -48,7 +48,8 @@ void vm_page_reserve_pages(uint32 count);
struct vm_page *vm_page_allocate_page(int pageState, bool reserved);
status_t vm_page_allocate_pages(int pageState, struct vm_page **pages,
uint32 numPages);
struct vm_page *vm_page_allocate_page_run(int state, addr_t length);
struct vm_page *vm_page_allocate_page_run(int state, addr_t base,
addr_t length);
struct vm_page *vm_page_at_index(int32 index);
struct vm_page *vm_lookup_page(addr_t pageNumber);

View File

@ -1573,6 +1573,7 @@ vm_create_anonymous_area(team_id team, const char *name, void **address,
vm_page *page = NULL;
bool isStack = (protection & B_STACK_AREA) != 0;
bool canOvercommit = false;
addr_t physicalBase = 0;
TRACE(("create_anonymous_area %s: size 0x%lx\n", name, size));
@ -1597,6 +1598,10 @@ vm_create_anonymous_area(team_id team, const char *name, void **address,
case B_ANY_KERNEL_ADDRESS:
case B_ANY_KERNEL_BLOCK_ADDRESS:
break;
case B_PHYSICAL_BASE_ADDRESS:
physicalBase = (addr_t)*address;
addressSpec = B_ANY_KERNEL_ADDRESS;
break;
default:
return B_BAD_VALUE;
@ -1629,7 +1634,8 @@ vm_create_anonymous_area(team_id team, const char *name, void **address,
if (wiring == B_CONTIGUOUS) {
// we try to allocate the page run here upfront as this may easily
// fail for obvious reasons
page = vm_page_allocate_page_run(PAGE_STATE_CLEAR, size / B_PAGE_SIZE);
page = vm_page_allocate_page_run(PAGE_STATE_CLEAR, physicalBase,
size / B_PAGE_SIZE);
if (page == NULL)
return B_NO_MEMORY;
}

View File

@ -1761,14 +1761,15 @@ vm_page_allocate_pages(int pageState, vm_page **pages, uint32 numPages)
vm_page *
vm_page_allocate_page_run(int pageState, addr_t length)
vm_page_allocate_page_run(int pageState, addr_t base, addr_t length)
{
vm_page *firstPage = NULL;
uint32 start = 0;
uint32 start = base >> PAGE_SHIFT;
InterruptsSpinLocker locker(sPageLock);
if (sFreePageQueue.count + sClearPageQueue.count - sReservedPages < length) {
if (sFreePageQueue.count + sClearPageQueue.count - sReservedPages
< length) {
// TODO: add more tries, ie. free some inactive, ...
// no free space
return NULL;