kernel: adjust formatting
This commit is contained in:
60
vm/page.c
60
vm/page.c
@@ -1,41 +1,41 @@
|
||||
#include <mango/types.h>
|
||||
#include <mango/libc/string.h>
|
||||
#include <mango/memblock.h>
|
||||
#include <mango/printk.h>
|
||||
#include <mango/types.h>
|
||||
#include <mango/vm.h>
|
||||
#include <mango/libc/string.h>
|
||||
|
||||
/* Pre-calculated page order -> size conversion table */
|
||||
static size_t page_order_bytes[] = {
|
||||
[VM_PAGE_4K] = 0x1000,
|
||||
[VM_PAGE_8K] = 0x2000,
|
||||
[VM_PAGE_16K] = 0x4000,
|
||||
[VM_PAGE_32K] = 0x8000,
|
||||
[VM_PAGE_64K] = 0x10000,
|
||||
[VM_PAGE_4K] = 0x1000,
|
||||
[VM_PAGE_8K] = 0x2000,
|
||||
[VM_PAGE_16K] = 0x4000,
|
||||
[VM_PAGE_32K] = 0x8000,
|
||||
[VM_PAGE_64K] = 0x10000,
|
||||
[VM_PAGE_128K] = 0x20000,
|
||||
[VM_PAGE_256K] = 0x40000,
|
||||
[VM_PAGE_512K] = 0x80000,
|
||||
[VM_PAGE_1M] = 0x100000,
|
||||
[VM_PAGE_2M] = 0x200000,
|
||||
[VM_PAGE_4M] = 0x400000,
|
||||
[VM_PAGE_8M] = 0x800000,
|
||||
[VM_PAGE_16M] = 0x1000000,
|
||||
[VM_PAGE_32M] = 0x2000000,
|
||||
[VM_PAGE_64M] = 0x4000000,
|
||||
[VM_PAGE_1M] = 0x100000,
|
||||
[VM_PAGE_2M] = 0x200000,
|
||||
[VM_PAGE_4M] = 0x400000,
|
||||
[VM_PAGE_8M] = 0x800000,
|
||||
[VM_PAGE_16M] = 0x1000000,
|
||||
[VM_PAGE_32M] = 0x2000000,
|
||||
[VM_PAGE_64M] = 0x4000000,
|
||||
[VM_PAGE_128M] = 0x8000000,
|
||||
|
||||
/* vm can support pages of this size, but
|
||||
struct vm_page only has 4 bits with which to store
|
||||
the page order, which cannot accomodate these
|
||||
larger order numbers */
|
||||
struct vm_page only has 4 bits with which to store
|
||||
the page order, which cannot accomodate these
|
||||
larger order numbers */
|
||||
[VM_PAGE_256M] = 0x10000000,
|
||||
[VM_PAGE_512M] = 0x20000000,
|
||||
[VM_PAGE_1G] = 0x40000000,
|
||||
[VM_PAGE_2G] = 0x80000000,
|
||||
[VM_PAGE_4G] = 0x100000000,
|
||||
[VM_PAGE_8G] = 0x200000000,
|
||||
[VM_PAGE_16G] = 0x400000000,
|
||||
[VM_PAGE_32G] = 0x800000000,
|
||||
[VM_PAGE_64G] = 0x1000000000,
|
||||
[VM_PAGE_1G] = 0x40000000,
|
||||
[VM_PAGE_2G] = 0x80000000,
|
||||
[VM_PAGE_4G] = 0x100000000,
|
||||
[VM_PAGE_8G] = 0x200000000,
|
||||
[VM_PAGE_16G] = 0x400000000,
|
||||
[VM_PAGE_32G] = 0x800000000,
|
||||
[VM_PAGE_64G] = 0x1000000000,
|
||||
};
|
||||
|
||||
phys_addr_t vm_virt_to_phys(void *p)
|
||||
@@ -56,7 +56,8 @@ phys_addr_t vm_virt_to_phys(void *p)
|
||||
|
||||
void *vm_phys_to_virt(phys_addr_t p)
|
||||
{
|
||||
if (p >= (memblock.m_alloc_start - memblock.m_voffset) && p < (memblock.m_alloc_end - memblock.m_voffset)) {
|
||||
if (p >= (memblock.m_alloc_start - memblock.m_voffset)
|
||||
&& p < (memblock.m_alloc_end - memblock.m_voffset)) {
|
||||
return memblock_phys_to_virt(p);
|
||||
}
|
||||
|
||||
@@ -124,11 +125,10 @@ vm_alignment_t vm_page_order_to_alignment(enum vm_page_order order)
|
||||
return ~(page_order_bytes[order] - 1);
|
||||
}
|
||||
|
||||
|
||||
size_t vm_bytes_to_pages(size_t bytes)
|
||||
{
|
||||
if (bytes & (VM_PAGE_SIZE-1)) {
|
||||
bytes &= ~(VM_PAGE_SIZE-1);
|
||||
if (bytes & (VM_PAGE_SIZE - 1)) {
|
||||
bytes &= ~(VM_PAGE_SIZE - 1);
|
||||
bytes += VM_PAGE_SIZE;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,6 @@ struct vm_zone *vm_page_get_zone(struct vm_page *pg)
|
||||
return &node->pg_zones[pg->p_zone];
|
||||
}
|
||||
|
||||
|
||||
struct vm_page *vm_page_alloc(enum vm_page_order order, enum vm_flags flags)
|
||||
{
|
||||
/* TODO prefer nodes closer to us */
|
||||
@@ -232,7 +231,8 @@ struct vm_page *vm_page_merge(struct vm_page *a, struct vm_page *b)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((a->p_flags & (VM_PAGE_ALLOC | VM_PAGE_RESERVED)) != (b->p_flags & (VM_PAGE_ALLOC | VM_PAGE_RESERVED))) {
|
||||
if ((a->p_flags & (VM_PAGE_ALLOC | VM_PAGE_RESERVED))
|
||||
!= (b->p_flags & (VM_PAGE_ALLOC | VM_PAGE_RESERVED))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user