1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

some cleanups, add some debug messages

This commit is contained in:
Stefan Lankes 2016-01-01 17:48:03 +01:00
parent d7ff12f781
commit f33f4e1047
3 changed files with 14 additions and 4 deletions

View file

@ -60,6 +60,7 @@
static struct netif mmnif_netif;
static const int sobufsize = 131072;
volatile int8_t shutdown = 0;
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
@ -70,6 +71,7 @@ extern const void kbss_start;
extern const void kbss_end;
extern const void tls_start;
extern const void tls_end;
extern const void __bss_start;
extern const void percore_start;
extern const void percore_end0;
extern const void percore_end;
@ -108,7 +110,7 @@ static int hermit_init(void)
uint32_t i;
size_t sz = (size_t) &percore_end0 - (size_t) &percore_start;
// initialize .bss section
// initialize .kbss section
memset((void*)&kbss_start, 0x00, ((size_t) &kbss_end - (size_t) &kbss_start));
// initialize .percore section => copy first section to all other sections
@ -254,6 +256,8 @@ static int initd(void* arg)
int argc;
char** argv = NULL;
kputs("Initd is running\n");
// setup heap
if (!curr_task->heap)
curr_task->heap = (vma_t*) kmalloc(sizeof(vma_t));
@ -375,6 +379,7 @@ static int initd(void* arg)
}
}
// call user code
libc_sd = c;
libc_start(argc, argv);
@ -411,6 +416,7 @@ int hermit_main(void)
kprintf("Isle %d of %d possible isles\n", isle, possible_isles);
kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end);
kprintf("TLS image starts at %p and ends at %p\n", &tls_start, &tls_end);
kprintf("Kernel BBS starts at %p and ends at %p\n", &kbss_start, &kbss_end);
kprintf("Per core data starts at %p and ends at %p\n", &percore_start, &percore_end);
kprintf("Per core size 0x%zd\n", (size_t) &percore_end0 - (size_t) &percore_start);
kprintf("Processor frequency: %u MHz\n", get_cpu_frequency());

View file

@ -315,7 +315,7 @@ int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio)
if ((core_id >= MAX_CORES) || !readyqueues[core_id].idle)
core_id = CORE_ID;
kprintf("start new thread on core %d\n", core_id);
kprintf("start new thread on core %d with base stack address %p\n", core_id, stack);
for(i=0; i<MAX_TASKS; i++) {
if (task_table[i].status == TASK_INVALID) {
@ -393,6 +393,7 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c
stack = kmalloc(KERNEL_STACK_SIZE);
if (BUILTIN_EXPECT(!stack, 0))
return -ENOMEM;
counter = kmalloc(sizeof(atomic_int64_t));
if (BUILTIN_EXPECT(!counter, 0)) {
kfree(stack);
@ -400,6 +401,8 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c
}
atomic_int64_set((atomic_int64_t*) counter, 0);
kprintf("start new thread on core %d with base stack address %p\n", core_id, stack);
spinlock_irqsave_lock(&table_lock);
for(i=0; i<MAX_TASKS; i++) {

View file

@ -43,7 +43,7 @@ static spinlock_t buddy_lock = SPINLOCK_INIT;
/** @brief Check if larger free buddies are available */
static inline int buddy_large_avail(uint8_t exp)
{
while (exp<BUDDY_MAX && !buddy_lists[exp-BUDDY_MIN])
while ((exp<BUDDY_MAX) && !buddy_lists[exp-BUDDY_MIN])
exp++;
return exp != BUDDY_MAX;
@ -75,7 +75,7 @@ static buddy_t* buddy_get(int exp)
// there is already a free buddy =>
// we remove it from the list
*list = buddy->next;
else if (exp >= BUDDY_ALLOC && !buddy_large_avail(exp))
else if ((exp >= BUDDY_ALLOC) && !buddy_large_avail(exp))
// theres no free buddy larger than exp =>
// we can allocate new memory
buddy = (buddy_t*) palloc(1<<exp, 0);
@ -114,6 +114,7 @@ void buddy_dump(void)
{
size_t free = 0;
int i;
for (i=0; i<BUDDY_LISTS; i++) {
buddy_t* buddy;
int exp = i+BUDDY_MIN;