From 4692c99460ab22f1d4fe36ae84d893af6edbb133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 12 Dec 2004 20:53:47 +0000 Subject: [PATCH] Added function that allocates more than one page at a time, but without the need for having them in a run. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10406 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/vm/vm_page.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/kernel/core/vm/vm_page.c b/src/kernel/core/vm/vm_page.c index b6025302de..acb578ab60 100755 --- a/src/kernel/core/vm/vm_page.c +++ b/src/kernel/core/vm/vm_page.c @@ -645,6 +645,32 @@ vm_page_allocate_page(int page_state) } +/** Allocates a number of pages and puts their pointers into the provided + * array. All pages are marked busy. + * Returns B_OK on success, and B_NO_MEMORY when there aren't any free + * pages left to allocate. + */ + +status_t +vm_page_allocate_pages(int pageState, vm_page **pages, uint32 numPages) +{ + uint32 i; + + for (i = 0; i < numPages; i++) { + pages[i] = vm_page_allocate_page(pageState); + if (pages[i] == NULL) { + // allocation failed, we need to free what we already have + while (i-- > 0) + vm_page_set_state(pages[i], pageState); + + return B_NO_MEMORY; + } + } + + return B_OK; +} + + vm_page * vm_page_allocate_page_run(int page_state, addr_t len) {