smp: enable smp
This is a very large patch. Don't feel like splitting it up. Change locking discipline for rbtrees. Most changes are this. Fix stack init logic for application processors, and start them up. Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
33d6f72cfe
commit
3e5abada9b
17 changed files with 123 additions and 52 deletions
16
mem/alloc.c
16
mem/alloc.c
|
|
@ -67,11 +67,13 @@ void *kalloc(size_t size, u64 flags)
|
|||
entry->flags = flags;
|
||||
entry->type = alloc_type;
|
||||
|
||||
rbt_lock(&kalloc_tree);
|
||||
rbnode_t *node = rbt_insert(&kalloc_tree, (u64)ret);
|
||||
if (!node)
|
||||
panic("kalloc_tree unavailable\n");
|
||||
|
||||
node->value = (u64)entry;
|
||||
rbt_unlock(&kalloc_tree);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
@ -91,10 +93,13 @@ void kfree(void *ptr)
|
|||
if (!ptr)
|
||||
return;
|
||||
|
||||
rbt_lock(&kalloc_tree);
|
||||
rbnode_t *node = rbt_search(&kalloc_tree, (u64)ptr);
|
||||
|
||||
if (!node)
|
||||
if (!node) {
|
||||
rbt_unlock(&kalloc_tree);
|
||||
panic("invalid kfree: %p\n", ptr);
|
||||
}
|
||||
|
||||
struct alloc_entry *entry = (void *)node->value;
|
||||
|
||||
|
|
@ -112,23 +117,30 @@ void kfree(void *ptr)
|
|||
goto out_1;
|
||||
}
|
||||
}
|
||||
rbt_unlock(&kalloc_tree);
|
||||
panic("kfree: slab size not found\n");
|
||||
out_1:
|
||||
break;
|
||||
default:
|
||||
rbt_unlock(&kalloc_tree);
|
||||
panic("invalid kfree entry type: %d\n", entry->type);
|
||||
break;
|
||||
}
|
||||
rbt_unlock(&kalloc_tree);
|
||||
}
|
||||
|
||||
void *krealloc(void *old, size_t size, u64 flags)
|
||||
{
|
||||
rbt_lock(&kalloc_tree);
|
||||
rbnode_t *node = rbt_search(&kalloc_tree, (u64)old);
|
||||
|
||||
if (!node)
|
||||
if (!node) {
|
||||
rbt_unlock(&kalloc_tree);
|
||||
return kalloc(size, flags);
|
||||
}
|
||||
|
||||
struct alloc_entry *entry = (void *)node->value;
|
||||
rbt_unlock(&kalloc_tree);
|
||||
|
||||
void *new = kalloc(size, flags);
|
||||
if (!new)
|
||||
|
|
|
|||
Loading…
Reference in a new issue