kernel: adjust formatting
This commit is contained in:
+43
-28
@@ -22,21 +22,22 @@
|
||||
#ifndef MANGO_MEMBLOCK_H_
|
||||
#define MANGO_MEMBLOCK_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
#include <mango/types.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MEMBLOCK_INIT_MEMORY_REGION_COUNT 128
|
||||
#define MEMBLOCK_INIT_MEMORY_REGION_COUNT 128
|
||||
#define MEMBLOCK_INIT_RESERVED_REGION_COUNT 128
|
||||
|
||||
#define __for_each_mem_range(i, type_a, type_b, p_start, p_end) \
|
||||
for ((i)->__idx = 0, __next_memory_region(i, type_a, type_b, p_start, p_end); \
|
||||
(i)->__idx != ULLONG_MAX; \
|
||||
__next_memory_region(i, type_a, type_b, p_start, p_end))
|
||||
#define __for_each_mem_range(i, type_a, type_b, p_start, p_end) \
|
||||
for ((i)->__idx = 0, \
|
||||
__next_memory_region(i, type_a, type_b, p_start, p_end); \
|
||||
(i)->__idx != ULLONG_MAX; \
|
||||
__next_memory_region(i, type_a, type_b, p_start, p_end))
|
||||
|
||||
/* iterate through all memory regions known to memblock.
|
||||
|
||||
@@ -47,7 +48,7 @@ extern "C" {
|
||||
|
||||
@param i the iterator. this should be a pointer of type struct memblock_iter.
|
||||
for each iteration, this structure will be filled with details about
|
||||
the current memory region.
|
||||
the current memory region.
|
||||
@param p_start the lower bound of the memory region to iterate through.
|
||||
if you don't want to use a lower bound, pass 0.
|
||||
@param p_end the upper bound of the memory region to iterate through.
|
||||
@@ -65,7 +66,7 @@ extern "C" {
|
||||
struct memblock_iter it;
|
||||
for_each_mem_region (&it, 0x40000, 0x80000) { ... }
|
||||
*/
|
||||
#define for_each_mem_range(i, p_start, p_end) \
|
||||
#define for_each_mem_range(i, p_start, p_end) \
|
||||
__for_each_mem_range(i, &memblock.memory, NULL, p_start, p_end)
|
||||
|
||||
/* iterate through all memory regions reserved using memblock.
|
||||
@@ -77,7 +78,7 @@ extern "C" {
|
||||
|
||||
@param i the iterator. this should be a pointer of type struct memblock_iter.
|
||||
for each iteration, this structure will be filled with details about
|
||||
the current memory region.
|
||||
the current memory region.
|
||||
@param p_start the lower bound of the memory region to iterate through.
|
||||
if you don't want to use a lower bound, pass 0.
|
||||
@param p_end the upper bound of the memory region to iterate through.
|
||||
@@ -95,7 +96,7 @@ extern "C" {
|
||||
struct memblock_iter it;
|
||||
for_each_reserved_mem_region (&it, 0x40000, 0x80000) { ... }
|
||||
*/
|
||||
#define for_each_reserved_mem_range(i, p_start, p_end) \
|
||||
#define for_each_reserved_mem_range(i, p_start, p_end) \
|
||||
__for_each_mem_range(i, &memblock.reserved, NULL, p_start, p_end)
|
||||
|
||||
/* iterate through all memory regions known by memblock to be free.
|
||||
@@ -108,7 +109,7 @@ extern "C" {
|
||||
|
||||
@param i the iterator. this should be a pointer of type struct memblock_iter.
|
||||
for each iteration, this structure will be filled with details about
|
||||
the current memory region.
|
||||
the current memory region.
|
||||
@param p_start the lower bound of the memory region to iterate through.
|
||||
if you don't want to use a lower bound, pass 0.
|
||||
@param p_end the upper bound of the memory region to iterate through.
|
||||
@@ -138,19 +139,25 @@ extern "C" {
|
||||
- 0x08000 -> 0x08fff
|
||||
- 0x10000 -> 0x1ffff
|
||||
*/
|
||||
#define for_each_free_mem_range(i, p_start, p_end) \
|
||||
__for_each_mem_range(i, &memblock.memory, &memblock.reserved, p_start, p_end)
|
||||
#define for_each_free_mem_range(i, p_start, p_end) \
|
||||
__for_each_mem_range( \
|
||||
i, \
|
||||
&memblock.memory, \
|
||||
&memblock.reserved, \
|
||||
p_start, \
|
||||
p_end)
|
||||
|
||||
typedef uint64_t memblock_index_t;
|
||||
|
||||
enum memblock_region_status {
|
||||
/* Used in memblock.memory regions, indicates that the memory region exists */
|
||||
/* Used in memblock.memory regions, indicates that the memory region
|
||||
* exists */
|
||||
MEMBLOCK_MEMORY = 0,
|
||||
/* Used in memblock.reserved regions, indicates that the memory region was reserved
|
||||
* by a call to memblock_alloc() */
|
||||
/* Used in memblock.reserved regions, indicates that the memory region
|
||||
* was reserved by a call to memblock_alloc() */
|
||||
MEMBLOCK_ALLOC,
|
||||
/* Used in memblock.reserved regions, indicates that the memory region was reserved
|
||||
* by a call to memblock_reserve() */
|
||||
/* Used in memblock.reserved regions, indicates that the memory region
|
||||
* was reserved by a call to memblock_reserve() */
|
||||
MEMBLOCK_RESERVED,
|
||||
};
|
||||
|
||||
@@ -176,9 +183,10 @@ struct memblock {
|
||||
/* bounds of the memory region that can be used by memblock_alloc()
|
||||
both of these are virtual addresses */
|
||||
uintptr_t m_alloc_start, m_alloc_end;
|
||||
/* memblock assumes that all memory in the alloc zone is contiguously mapped
|
||||
(if paging is enabled). m_voffset is the offset that needs to be added to
|
||||
a given physical address to get the corresponding virtual address */
|
||||
/* memblock assumes that all memory in the alloc zone is contiguously
|
||||
mapped (if paging is enabled). m_voffset is the offset that needs to
|
||||
be added to a given physical address to get the corresponding virtual
|
||||
address */
|
||||
uintptr_t m_voffset;
|
||||
|
||||
struct memblock_type memory;
|
||||
@@ -212,7 +220,10 @@ extern int __next_mem_range(struct memblock_iter *it);
|
||||
@param voffset the offset between the physical address of a given page and
|
||||
its corresponding virtual address.
|
||||
*/
|
||||
extern int memblock_init(uintptr_t alloc_start, uintptr_t alloc_end, uintptr_t voffset);
|
||||
extern int memblock_init(
|
||||
uintptr_t alloc_start,
|
||||
uintptr_t alloc_end,
|
||||
uintptr_t voffset);
|
||||
|
||||
/* add a region of memory to memblock.
|
||||
|
||||
@@ -234,7 +245,8 @@ extern int memblock_add(phys_addr_t base, size_t size);
|
||||
reserved memory will not be used by memblock_alloc(), and will remain
|
||||
reserved when the vm_page memory map is initialised.
|
||||
|
||||
@param base the physical address of the start of the memory region to reserve.
|
||||
@param base the physical address of the start of the memory region to
|
||||
reserve.
|
||||
@oaram size the size of the memory region to reserve in bytes.
|
||||
*/
|
||||
extern int memblock_reserve(phys_addr_t base, size_t size);
|
||||
@@ -257,7 +269,7 @@ extern int memblock_reserve(phys_addr_t base, size_t size);
|
||||
@param size the size of the buffer to allocate in bytes.
|
||||
@param align the alignment to use. for example, an alignment of 4096
|
||||
will result in the returned pointer being a multiple
|
||||
of 4096. this must be a power of 2.
|
||||
of 4096. this must be a power of 2.
|
||||
*/
|
||||
extern void *memblock_alloc(size_t size, phys_addr_t align);
|
||||
|
||||
@@ -279,7 +291,7 @@ extern void *memblock_alloc(size_t size, phys_addr_t align);
|
||||
@param size the size of the buffer to allocate in bytes.
|
||||
@param align the alignment to use. for example, an alignment of 4096
|
||||
will result in the returned pointer being a multiple
|
||||
of 4096. this must be a power of 2.
|
||||
of 4096. this must be a power of 2.
|
||||
*/
|
||||
extern phys_addr_t memblock_alloc_phys(size_t size, phys_addr_t align);
|
||||
|
||||
@@ -319,9 +331,12 @@ extern phys_addr_t memblock_virt_to_phys(void *p);
|
||||
*/
|
||||
extern void *memblock_phys_to_virt(phys_addr_t p);
|
||||
|
||||
extern void __next_memory_region(struct memblock_iter *it, \
|
||||
struct memblock_type *type_a, struct memblock_type *type_b,
|
||||
phys_addr_t start, phys_addr_t end);
|
||||
extern void __next_memory_region(
|
||||
struct memblock_iter *it,
|
||||
struct memblock_type *type_a,
|
||||
struct memblock_type *type_b,
|
||||
phys_addr_t start,
|
||||
phys_addr_t end);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user