vm_page_allocate_page_run(): Added parameter "limit", specifying the upper
physical address limit for the page run to allocate. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37086 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -61,7 +61,7 @@ bool vm_page_try_reserve_pages(vm_page_reservation* reservation, uint32 count,
|
|||||||
struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
|
struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
|
||||||
uint32 flags);
|
uint32 flags);
|
||||||
struct vm_page *vm_page_allocate_page_run(uint32 flags, phys_addr_t base,
|
struct vm_page *vm_page_allocate_page_run(uint32 flags, phys_addr_t base,
|
||||||
page_num_t length, int priority);
|
phys_addr_t limit, page_num_t length, int priority);
|
||||||
struct vm_page *vm_page_at_index(int32 index);
|
struct vm_page *vm_page_at_index(int32 index);
|
||||||
struct vm_page *vm_lookup_page(page_num_t pageNumber);
|
struct vm_page *vm_lookup_page(page_num_t pageNumber);
|
||||||
bool vm_page_is_dummy(struct vm_page *page);
|
bool vm_page_is_dummy(struct vm_page *page);
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ Aperture::AllocateMemory(aperture_memory *memory, uint32 flags)
|
|||||||
|
|
||||||
if ((flags & B_APERTURE_NEED_PHYSICAL) != 0) {
|
if ((flags & B_APERTURE_NEED_PHYSICAL) != 0) {
|
||||||
memory->page = vm_page_allocate_page_run(
|
memory->page = vm_page_allocate_page_run(
|
||||||
PAGE_STATE_WIRED | VM_PAGE_ALLOC_CLEAR, 0, count,
|
PAGE_STATE_WIRED | VM_PAGE_ALLOC_CLEAR, 0, 0, count,
|
||||||
VM_PRIORITY_SYSTEM);
|
VM_PRIORITY_SYSTEM);
|
||||||
if (memory->page == NULL)
|
if (memory->page == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|||||||
@@ -1181,7 +1181,7 @@ vm_create_anonymous_area(team_id team, const char* name, void** address,
|
|||||||
// we try to allocate the page run here upfront as this may easily
|
// we try to allocate the page run here upfront as this may easily
|
||||||
// fail for obvious reasons
|
// fail for obvious reasons
|
||||||
page = vm_page_allocate_page_run(PAGE_STATE_WIRED | pageAllocFlags,
|
page = vm_page_allocate_page_run(PAGE_STATE_WIRED | pageAllocFlags,
|
||||||
physicalAddress, size / B_PAGE_SIZE, priority);
|
physicalAddress, 0, size / B_PAGE_SIZE, priority);
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
status = B_NO_MEMORY;
|
status = B_NO_MEMORY;
|
||||||
goto err0;
|
goto err0;
|
||||||
|
|||||||
@@ -3319,11 +3319,30 @@ allocate_page_run(page_num_t start, page_num_t length, uint32 flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vm_page *
|
/*! Allocate a physically contiguous range of pages.
|
||||||
vm_page_allocate_page_run(uint32 flags, phys_addr_t base, page_num_t length,
|
|
||||||
int priority)
|
\param flags Page allocation flags. Encodes the state the function shall
|
||||||
|
set the allocated pages to, whether the pages shall be marked busy
|
||||||
|
(VM_PAGE_ALLOC_BUSY), and whether the pages shall be cleared
|
||||||
|
(VM_PAGE_ALLOC_CLEAR).
|
||||||
|
\param base The first acceptable physical address where the page run may
|
||||||
|
start.
|
||||||
|
\param limit The last acceptable physical address where the page run may
|
||||||
|
end (i.e. it must hold runStartAddress + runSize <= limit). If \c 0,
|
||||||
|
the limit is ignored.
|
||||||
|
\param length The number of contiguous pages to allocate.
|
||||||
|
\param priority The page reservation priority (as passed to
|
||||||
|
vm_page_reserve_pages()).
|
||||||
|
\return The first page of the allocated page run on success; \c NULL
|
||||||
|
when the allocation failed.
|
||||||
|
*/
|
||||||
|
vm_page*
|
||||||
|
vm_page_allocate_page_run(uint32 flags, phys_addr_t base, phys_addr_t limit,
|
||||||
|
page_num_t length, int priority)
|
||||||
{
|
{
|
||||||
page_num_t start = base >> PAGE_SHIFT;
|
page_num_t start = base / B_PAGE_SIZE;
|
||||||
|
page_num_t end = std::min(limit > 0 ? limit / B_PAGE_SIZE : sNumPages,
|
||||||
|
sNumPages);
|
||||||
|
|
||||||
vm_page_reservation reservation;
|
vm_page_reservation reservation;
|
||||||
vm_page_reserve_pages(&reservation, length, priority);
|
vm_page_reserve_pages(&reservation, length, priority);
|
||||||
@@ -3338,8 +3357,7 @@ vm_page_allocate_page_run(uint32 flags, phys_addr_t base, page_num_t length,
|
|||||||
int useCached = freePages > 0 && (page_num_t)freePages > 2 * length ? 0 : 1;
|
int useCached = freePages > 0 && (page_num_t)freePages > 2 * length ? 0 : 1;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
bool foundRun = true;
|
if (start + length > end) {
|
||||||
if (start + length > sNumPages) {
|
|
||||||
if (useCached == 0) {
|
if (useCached == 0) {
|
||||||
// The first iteration with free pages only was unsuccessful.
|
// The first iteration with free pages only was unsuccessful.
|
||||||
// Try again also considering cached pages.
|
// Try again also considering cached pages.
|
||||||
@@ -3356,6 +3374,7 @@ vm_page_allocate_page_run(uint32 flags, phys_addr_t base, page_num_t length,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool foundRun = true;
|
||||||
page_num_t i;
|
page_num_t i;
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
uint32 pageState = sPages[start + i].State();
|
uint32 pageState = sPages[start + i].State();
|
||||||
|
|||||||
Reference in New Issue
Block a user