mirror of
https://github.com/drasko/codezero.git
synced 2026-01-18 22:03:16 +01:00
Removed kmalloc. Initialization path resolved, almost done.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
Import('env')
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
src_local = ['physmem.c', 'irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'kmalloc.c', 'space.c', 'bootm.c', 'resource.c', 'container.c', 'capability.c']
|
||||
src_local = ['physmem.c', 'irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'space.c', 'bootm.c', 'resource.c', 'container.c', 'capability.c']
|
||||
|
||||
obj = env.Object(src_local)
|
||||
Return('obj')
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <l4/generic/cap-types.h>
|
||||
#include <l4/api/errno.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
#include INC_SUBARCH(mm.h)
|
||||
#include INC_ARCH(linker.h)
|
||||
|
||||
/*
|
||||
* FIXME:
|
||||
@@ -192,21 +194,45 @@ void task_setup_utcb(struct ktcb *task, struct pager *pager)
|
||||
}
|
||||
|
||||
#if 0
|
||||
void switch_stack(struct ktcb *task)
|
||||
{
|
||||
register u32 stack asm("sp");
|
||||
register u32 fp asm("fp");
|
||||
register u32 newstack = align((unsigned long)task + PAGE_SIZE, sizeof(short));
|
||||
signed long long offset = newstack - __bootstack;
|
||||
|
||||
fp += offset;
|
||||
sp += offset;
|
||||
/*
|
||||
* NOTE: This is not useful because FP stores references to
|
||||
* old stack so even if stacks are copied, unwinding is not
|
||||
* possible, which makes copying pointless. If there was no
|
||||
* FP, it may make sense, but this is not tested.
|
||||
*
|
||||
* Copy current stack contents to new one,
|
||||
* and jump to that stack by modifying sp and frame pointer.
|
||||
*/
|
||||
int switch_stacks(struct ktcb *task)
|
||||
{
|
||||
volatile register unsigned int stack asm("sp");
|
||||
volatile register unsigned int frameptr asm("fp");
|
||||
volatile register unsigned int newstack;
|
||||
unsigned int stack_size = (unsigned int)_bootstack - stack;
|
||||
|
||||
newstack = align((unsigned long)task + PAGE_SIZE - 1,
|
||||
STACK_ALIGNMENT);
|
||||
|
||||
/* Copy stack contents to new stack */
|
||||
memcpy(&newstack, __bootstack, stack - __bootstack);
|
||||
memcpy((void *)(newstack - stack_size),
|
||||
(void *)stack, stack_size);
|
||||
|
||||
/* Switch to new stack */
|
||||
/*
|
||||
* Switch to new stack, as new stack
|
||||
* minus currently used stack size
|
||||
*/
|
||||
stack = newstack - stack_size;
|
||||
|
||||
/*
|
||||
* Frame ptr is new stack minus the original
|
||||
* difference from start of boot stack to current fptr
|
||||
*/
|
||||
frameptr = newstack -
|
||||
((unsigned int)_bootstack - frameptr);
|
||||
|
||||
/* We should be able to return safely */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -247,6 +273,7 @@ int init_first_pager(struct pager *pager,
|
||||
|
||||
task->space = space;
|
||||
task->container = cont;
|
||||
pager->tcb = task;
|
||||
|
||||
/* Map the task's space */
|
||||
add_mapping_pgd(pager->start_lma, pager->start_vma,
|
||||
@@ -291,6 +318,8 @@ int init_pager(struct pager *pager, struct container *cont)
|
||||
|
||||
task->container = cont;
|
||||
|
||||
pager->tcb = task;
|
||||
|
||||
add_mapping_pgd(pager->start_lma, pager->start_vma,
|
||||
page_align_up(pager->memsize),
|
||||
MAP_USR_DEFAULT_FLAGS, TASK_PGD(task));
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Memory pool based kmalloc.
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <l4/lib/list.h>
|
||||
#include <l4/lib/memcache.h>
|
||||
#include <l4/generic/resource.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
|
||||
/* Supports this many different kmalloc sizes */
|
||||
#define KMALLOC_POOLS_MAX 5
|
||||
|
||||
struct kmalloc_pool_head {
|
||||
struct link cache_list;
|
||||
int occupied;
|
||||
int total_caches;
|
||||
int cache_size;
|
||||
};
|
||||
|
||||
struct kmalloc_mempool {
|
||||
int total;
|
||||
struct kmalloc_pool_head pool_head[KMALLOC_POOLS_MAX];
|
||||
struct mutex kmalloc_mutex;
|
||||
};
|
||||
struct kmalloc_mempool km_pool;
|
||||
|
||||
void init_kmalloc()
|
||||
{
|
||||
for (int i = 0; i < KMALLOC_POOLS_MAX; i++) {
|
||||
link_init(&km_pool.pool_head[i].cache_list);
|
||||
km_pool.pool_head[i].occupied = 0;
|
||||
km_pool.pool_head[i].total_caches = 0;
|
||||
km_pool.pool_head[i].cache_size = 0;
|
||||
}
|
||||
mutex_init(&km_pool.kmalloc_mutex);
|
||||
}
|
||||
|
||||
void *kmalloc(int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kfree(void *p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *kzalloc(int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <l4/generic/space.h>
|
||||
#include <l4/generic/container.h>
|
||||
#include <l4/generic/tcb.h>
|
||||
#include <l4/generic/kmalloc.h>
|
||||
#include <l4/api/space.h>
|
||||
#include <l4/api/errno.h>
|
||||
#include <l4/api/kip.h>
|
||||
@@ -87,7 +86,7 @@ void address_space_delete(struct address_space *space)
|
||||
id_del(space_id_pool, space->spid);
|
||||
|
||||
/* Deallocate the space structure */
|
||||
kfree(space);
|
||||
free_space(space);
|
||||
}
|
||||
|
||||
struct address_space *address_space_create(struct address_space *orig)
|
||||
@@ -126,7 +125,7 @@ struct address_space *address_space_create(struct address_space *orig)
|
||||
/* Copy its user entries/tables */
|
||||
if ((err = copy_user_tables(space, orig)) < 0) {
|
||||
free_pgd(pgd);
|
||||
kfree(space);
|
||||
free_space(space);
|
||||
return PTR_ERR(err);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user