Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8732 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6169bb1f81
commit
d885b0a17c
@ -48,7 +48,8 @@ static void clear_page(addr_t pa);
|
||||
static int32 page_scrubber(void *);
|
||||
|
||||
|
||||
static vm_page *dequeue_page(page_queue *q)
|
||||
static vm_page *
|
||||
dequeue_page(page_queue *q)
|
||||
{
|
||||
vm_page *page;
|
||||
|
||||
@ -67,7 +68,8 @@ static vm_page *dequeue_page(page_queue *q)
|
||||
}
|
||||
|
||||
|
||||
static void enqueue_page(page_queue *q, vm_page *page)
|
||||
static void
|
||||
enqueue_page(page_queue *q, vm_page *page)
|
||||
{
|
||||
if (q->head != NULL)
|
||||
q->head->queue_prev = page;
|
||||
@ -85,7 +87,8 @@ static void enqueue_page(page_queue *q, vm_page *page)
|
||||
}
|
||||
|
||||
|
||||
static void remove_page_from_queue(page_queue *q, vm_page *page)
|
||||
static void
|
||||
remove_page_from_queue(page_queue *q, vm_page *page)
|
||||
{
|
||||
if (page->queue_prev != NULL)
|
||||
page->queue_prev->queue_next = page->queue_next;
|
||||
@ -101,7 +104,8 @@ static void remove_page_from_queue(page_queue *q, vm_page *page)
|
||||
}
|
||||
|
||||
|
||||
static void move_page_to_queue(page_queue *from_q, page_queue *to_q, vm_page *page)
|
||||
static void
|
||||
move_page_to_queue(page_queue *from_q, page_queue *to_q, vm_page *page)
|
||||
{
|
||||
if (from_q != to_q) {
|
||||
remove_page_from_queue(from_q, page);
|
||||
@ -188,7 +192,9 @@ static int pageout_daemon()
|
||||
}
|
||||
#endif
|
||||
|
||||
int vm_page_init(kernel_args *ka)
|
||||
|
||||
int
|
||||
vm_page_init(kernel_args *ka)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -342,7 +348,9 @@ page_scrubber(void *unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void clear_page(addr_t pa)
|
||||
|
||||
static void
|
||||
clear_page(addr_t pa)
|
||||
{
|
||||
addr_t va;
|
||||
|
||||
@ -355,12 +363,16 @@ static void clear_page(addr_t pa)
|
||||
vm_put_physical_page(va);
|
||||
}
|
||||
|
||||
int vm_mark_page_inuse(addr_t page)
|
||||
|
||||
int
|
||||
vm_mark_page_inuse(addr_t page)
|
||||
{
|
||||
return vm_mark_page_range_inuse(page, 1);
|
||||
}
|
||||
|
||||
int vm_mark_page_range_inuse(addr_t start_page, addr_t len)
|
||||
|
||||
int
|
||||
vm_mark_page_range_inuse(addr_t start_page, addr_t len)
|
||||
{
|
||||
vm_page *page;
|
||||
addr_t i;
|
||||
@ -408,7 +420,9 @@ int vm_mark_page_range_inuse(addr_t start_page, addr_t len)
|
||||
return i;
|
||||
}
|
||||
|
||||
vm_page *vm_page_allocate_specific_page(addr_t page_num, int page_state)
|
||||
|
||||
vm_page *
|
||||
vm_page_allocate_specific_page(addr_t page_num, int page_state)
|
||||
{
|
||||
vm_page *p;
|
||||
int old_page_state = PAGE_STATE_BUSY;
|
||||
@ -447,16 +461,16 @@ out:
|
||||
release_spinlock(&page_lock);
|
||||
restore_interrupts(state);
|
||||
|
||||
if (p != NULL && page_state == PAGE_STATE_CLEAR &&
|
||||
(old_page_state == PAGE_STATE_FREE || old_page_state == PAGE_STATE_UNUSED)) {
|
||||
|
||||
if (p != NULL && page_state == PAGE_STATE_CLEAR
|
||||
&& (old_page_state == PAGE_STATE_FREE || old_page_state == PAGE_STATE_UNUSED))
|
||||
clear_page(p->ppn * PAGE_SIZE);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
vm_page *vm_page_allocate_page(int page_state)
|
||||
|
||||
vm_page *
|
||||
vm_page_allocate_page(int page_state)
|
||||
{
|
||||
vm_page *p;
|
||||
page_queue *q;
|
||||
@ -506,7 +520,9 @@ vm_page *vm_page_allocate_page(int page_state)
|
||||
return p;
|
||||
}
|
||||
|
||||
vm_page *vm_page_allocate_page_run(int page_state, addr_t len)
|
||||
|
||||
vm_page *
|
||||
vm_page_allocate_page_run(int page_state, addr_t len)
|
||||
{
|
||||
unsigned int start;
|
||||
unsigned int i;
|
||||
@ -520,12 +536,12 @@ vm_page *vm_page_allocate_page_run(int page_state, addr_t len)
|
||||
|
||||
for (;;) {
|
||||
bool foundit = true;
|
||||
if(start + len >= num_pages) {
|
||||
if (start + len >= num_pages)
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if(all_pages[start + i].state != PAGE_STATE_FREE &&
|
||||
all_pages[start + i].state != PAGE_STATE_CLEAR) {
|
||||
if (all_pages[start + i].state != PAGE_STATE_FREE
|
||||
&& all_pages[start + i].state != PAGE_STATE_CLEAR) {
|
||||
foundit = false;
|
||||
i++;
|
||||
break;
|
||||
@ -551,10 +567,13 @@ vm_page *vm_page_allocate_page_run(int page_state, addr_t len)
|
||||
return first_page;
|
||||
}
|
||||
|
||||
vm_page *vm_lookup_page(addr_t page_num)
|
||||
|
||||
vm_page *
|
||||
vm_lookup_page(addr_t page_num)
|
||||
{
|
||||
if (page_num < physical_page_offset)
|
||||
return NULL;
|
||||
|
||||
page_num -= physical_page_offset;
|
||||
if (page_num >= num_pages)
|
||||
return NULL;
|
||||
@ -562,7 +581,9 @@ vm_page *vm_lookup_page(addr_t page_num)
|
||||
return &all_pages[page_num];
|
||||
}
|
||||
|
||||
static int vm_page_set_state_nolock(vm_page *page, int page_state)
|
||||
|
||||
static int
|
||||
vm_page_set_state_nolock(vm_page *page, int page_state)
|
||||
{
|
||||
page_queue *from_q = NULL;
|
||||
page_queue *to_q = NULL;
|
||||
@ -614,7 +635,9 @@ static int vm_page_set_state_nolock(vm_page *page, int page_state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vm_page_set_state(vm_page *page, int page_state)
|
||||
|
||||
int
|
||||
vm_page_set_state(vm_page *page, int page_state)
|
||||
{
|
||||
int err;
|
||||
int state = disable_interrupts();
|
||||
@ -628,17 +651,23 @@ int vm_page_set_state(vm_page *page, int page_state)
|
||||
return err;
|
||||
}
|
||||
|
||||
addr_t vm_page_num_pages()
|
||||
|
||||
addr_t
|
||||
vm_page_num_pages(void)
|
||||
{
|
||||
return num_pages;
|
||||
}
|
||||
|
||||
addr_t vm_page_num_free_pages()
|
||||
|
||||
addr_t
|
||||
vm_page_num_free_pages(void)
|
||||
{
|
||||
return page_free_queue.count + page_clear_queue.count;
|
||||
}
|
||||
|
||||
static int dump_free_page_table(int argc, char **argv)
|
||||
|
||||
static int
|
||||
dump_free_page_table(int argc, char **argv)
|
||||
{
|
||||
dprintf("not finished\n");
|
||||
return 0;
|
||||
@ -694,7 +723,8 @@ dump_page_queue(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
static int dump_page_stats(int argc, char **argv)
|
||||
static int
|
||||
dump_page_stats(int argc, char **argv)
|
||||
{
|
||||
unsigned int page_types[8];
|
||||
addr_t i;
|
||||
@ -814,10 +844,11 @@ out:
|
||||
return spot;
|
||||
}
|
||||
|
||||
// XXX horrible brute-force method of determining if the page can be allocated
|
||||
|
||||
static bool
|
||||
is_page_in_phys_range(kernel_args *ka, addr_t paddr)
|
||||
{
|
||||
// XXX horrible brute-force method of determining if the page can be allocated
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ka->num_physical_memory_ranges; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user