kernel: don't use typedef for enums or non-opaque structs
This commit is contained in:
@@ -38,12 +38,12 @@
|
||||
be bounded by the defined memory regions, and not by this constant. */
|
||||
#define ADDR_MAX (~(uintptr_t)0)
|
||||
|
||||
static memblock_region_t init_memory_regions[MEMBLOCK_INIT_MEMORY_REGION_COUNT];
|
||||
static memblock_region_t init_reserved_regions[MEMBLOCK_INIT_RESERVED_REGION_COUNT];
|
||||
static struct memblock_region init_memory_regions[MEMBLOCK_INIT_MEMORY_REGION_COUNT];
|
||||
static struct memblock_region init_reserved_regions[MEMBLOCK_INIT_RESERVED_REGION_COUNT];
|
||||
|
||||
static phys_addr_t do_alloc(size_t size, phys_addr_t align);
|
||||
|
||||
memblock_t memblock = {
|
||||
struct memblock memblock = {
|
||||
.memory.regions = init_memory_regions,
|
||||
.memory.count = 0,
|
||||
.memory.max = MEMBLOCK_INIT_MEMORY_REGION_COUNT,
|
||||
@@ -55,33 +55,33 @@ memblock_t memblock = {
|
||||
.reserved.name = "reserved",
|
||||
};
|
||||
|
||||
static void memblock_double_capacity(memblock_type_t *type)
|
||||
static void memblock_double_capacity(struct memblock_type *type)
|
||||
{
|
||||
size_t new_max = type->max * 2;
|
||||
|
||||
phys_addr_t new_regions_p = do_alloc(new_max * sizeof(memblock_region_t), 8);
|
||||
phys_addr_t new_regions_p = do_alloc(new_max * sizeof(struct memblock_region), 8);
|
||||
|
||||
void *new_regions = (void *)(new_regions_p + memblock.m_voffset);
|
||||
memcpy(new_regions, type->regions, type->count * sizeof(memblock_region_t));
|
||||
memcpy(new_regions, type->regions, type->count * sizeof(struct memblock_region));
|
||||
|
||||
type->regions = new_regions;
|
||||
type->max = new_max;
|
||||
}
|
||||
|
||||
static int memblock_insert_region(memblock_type_t *type, memblock_region_t *to_add)
|
||||
static int memblock_insert_region(struct memblock_type *type, struct memblock_region *to_add)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < type->count; i++) {
|
||||
const memblock_region_t *cur = &type->regions[i];
|
||||
const struct memblock_region *cur = &type->regions[i];
|
||||
|
||||
if (cur->base >= to_add->limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
memblock_region_t *src = &type->regions[i];
|
||||
memblock_region_t *dst = &type->regions[i + 1];
|
||||
struct memblock_region *src = &type->regions[i];
|
||||
struct memblock_region *dst = &type->regions[i + 1];
|
||||
unsigned int count = type->count - i;
|
||||
|
||||
memmove(dst, src, count * sizeof *src);
|
||||
@@ -92,14 +92,14 @@ static int memblock_insert_region(memblock_type_t *type, memblock_region_t *to_a
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int memblock_remove_region(memblock_type_t *type, unsigned int i)
|
||||
static int memblock_remove_region(struct memblock_type *type, unsigned int i)
|
||||
{
|
||||
if (i >= type->count) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memblock_region_t *src = &type->regions[i + 1];
|
||||
memblock_region_t *dst = &type->regions[i];
|
||||
struct memblock_region *src = &type->regions[i + 1];
|
||||
struct memblock_region *dst = &type->regions[i];
|
||||
unsigned int count = type->count - i;
|
||||
|
||||
memmove(dst, src, count * sizeof *src);
|
||||
@@ -116,7 +116,7 @@ int memblock_init(uintptr_t alloc_start, uintptr_t alloc_end, uintptr_t voffset)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int memblock_add_range(memblock_type_t *type, uintptr_t base, size_t size, memblock_region_status_t status)
|
||||
int memblock_add_range(struct memblock_type *type, uintptr_t base, size_t size, enum memblock_region_status status)
|
||||
{
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
@@ -131,12 +131,12 @@ int memblock_add_range(memblock_type_t *type, uintptr_t base, size_t size, membl
|
||||
return 0;
|
||||
}
|
||||
|
||||
memblock_region_t new_region = { .base = base, .limit = limit, .status = status };
|
||||
struct memblock_region new_region = { .base = base, .limit = limit, .status = status };
|
||||
|
||||
/* two regions with different statuses CANNOT intersect. we first need to check
|
||||
to make sure the region being added doesn't violate this rule. */
|
||||
for (unsigned int i = 0; i < type->count; i++) {
|
||||
memblock_region_t *cur_region = &type->regions[i];
|
||||
struct memblock_region *cur_region = &type->regions[i];
|
||||
|
||||
if (new_region.base > cur_region->limit || new_region.limit < cur_region->base) {
|
||||
continue;
|
||||
@@ -152,7 +152,7 @@ int memblock_add_range(memblock_type_t *type, uintptr_t base, size_t size, membl
|
||||
bool add_new = true;
|
||||
|
||||
for (unsigned int i = 0; i < type->count; i++) {
|
||||
memblock_region_t *cur_region = &type->regions[i];
|
||||
struct memblock_region *cur_region = &type->regions[i];
|
||||
|
||||
/* case 1: the region being added and the current region have no connection what-so-ever (no overlaps) */
|
||||
if (cur_region->limit + 1 < new_region.base || cur_region->base > new_region.limit) {
|
||||
@@ -244,7 +244,7 @@ static phys_addr_t do_alloc(size_t size, phys_addr_t align)
|
||||
phys_addr_t region_start = memblock.m_alloc_start - memblock.m_voffset;
|
||||
phys_addr_t region_end = memblock.m_alloc_end - memblock.m_voffset;
|
||||
|
||||
memblock_iter_t it;
|
||||
struct memblock_iter it;
|
||||
for_each_free_mem_range (&it, region_start, region_end) {
|
||||
phys_addr_t base = it.it_base;
|
||||
if (base & (align - 1)) {
|
||||
@@ -306,13 +306,13 @@ int memblock_free_phys(phys_addr_t addr, size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __next_memory_region(memblock_iter_t *it, memblock_type_t *type_a, memblock_type_t *type_b, uintptr_t start, uintptr_t end)
|
||||
void __next_memory_region(struct memblock_iter *it, struct memblock_type *type_a, struct memblock_type *type_b, uintptr_t start, uintptr_t end)
|
||||
{
|
||||
unsigned int idx_a = IDX_A(it->__idx);
|
||||
unsigned int idx_b = IDX_B(it->__idx);
|
||||
|
||||
for (; idx_a < type_a->count; idx_a++) {
|
||||
memblock_region_t *m = &type_a->regions[idx_a];
|
||||
struct memblock_region *m = &type_a->regions[idx_a];
|
||||
|
||||
uintptr_t m_start = m->base;
|
||||
uintptr_t m_end = m->limit;
|
||||
@@ -337,7 +337,7 @@ void __next_memory_region(memblock_iter_t *it, memblock_type_t *type_a, memblock
|
||||
}
|
||||
|
||||
for (; idx_b < type_b->count + 1; idx_b++) {
|
||||
memblock_region_t *r = &type_b->regions[idx_b];
|
||||
struct memblock_region *r = &type_b->regions[idx_b];
|
||||
|
||||
/* r_start and r_end delimit the region of memory between the current and previous reserved regions.
|
||||
if we have gone past the last reserved region, these variables delimit the range between the end
|
||||
|
||||
Reference in New Issue
Block a user