Skip to content

Commit

Permalink
libsel4allocman: simplify code
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
axel-h committed Nov 24, 2023
1 parent 0804fd0 commit 920c766
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions libsel4allocman/src/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,7 @@ static int handle_device_untyped_cap(add_untypeds_state_t *state, uintptr_t padd
bool cap_tainted = false;
int error;
uintptr_t ut_end = paddr + BIT(size_bits);
int num_regions = 0;
if (state != NULL) {
num_regions = state->num_regions;
}
int num_regions = state ? state->num_regions : 0;
for (int i = 0; i < num_regions; i++) {
pmem_region_t *region = &state->regions[i];
uint64_t region_end = region->base_addr + region->length;
Expand Down Expand Up @@ -1128,15 +1125,14 @@ int allocman_add_simple_untypeds_with_regions(allocman_t *alloc, simple_t *simpl
uintptr_t paddr;
bool device;
cspacepath_t path = allocman_cspace_make_path(alloc, simple_get_nth_untyped(simple, i, &size_bits, &paddr, &device));
int dev_type = device ? ALLOCMAN_UT_DEV : ALLOCMAN_UT_KERNEL;
// If it is regular UT memory, then we add cap and move on.
if (dev_type == ALLOCMAN_UT_KERNEL) {
error = allocman_utspace_add_uts(alloc, 1, &path, &size_bits, &paddr, dev_type);
ZF_LOGF_IF(error, "Could not add kernel untyped.");
} else {
// Otherwise we are Device untyped.
if (device) {
// Separates device RAM memory into separate untyped caps
error = handle_device_untyped_cap(state, paddr, size_bits, &path, alloc);
ZF_LOGF_IF(error, "bootstrap_arch_handle_device_untyped_cap failed.");
ZF_LOGF_IF(error, "handle_device_untyped_cap failed (%d).", error);
} else {
// for regular UT memory we add cap
error = allocman_utspace_add_uts(alloc, 1, &path, &size_bits, &paddr, ALLOCMAN_UT_KERNEL);
ZF_LOGF_IF(error, "Could not add kernel untyped (%d).", error);
}
}
if (state) {
Expand Down

0 comments on commit 920c766

Please sign in to comment.