metalsvm/kernel/main.c

95 lines
2.2 KiB
C
Raw Normal View History

/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of MetalSVM.
*/
#include <metalsvm/stddef.h>
#include <metalsvm/stdio.h>
#include <metalsvm/time.h>
#include <metalsvm/irq.h>
#include <metalsvm/irqflags.h>
#include <metalsvm/mmu.h>
#include <metalsvm/tasks.h>
#include <metalsvm/processor.h>
#include <asm/kb.h>
void* STDCALL foo(void* arg)
{
int i;
if (!arg)
return NULL;
for(i=0; i<5; i++) {
kputs((char*) arg);
sleep(1);
}
return NULL;
}
void* STDCALL join_test(void* arg)
{
int ret;
tid_t id;
ret = create_kernel_task(&id, foo, "Hello from foo2\n", 0);
kprintf("Wait for task %u: ret = %d\n", id, ret);
ret = join_kernel_task(id);
kprintf("Task %u finished: ret = %d\n", id, ret);
return NULL;
}
int main(void)
{
tid_t id1, id2;
system_init();
irq_init();
koutput_init();
timer_init();
#ifdef USE_KEYBOARD
keyboard_init();
#endif
mmu_init();
multitasking_init();
irq_enable();
kprintf("Here is MetalSVM %s\n", METALSVM_VERSION);
detect_cpu_frequency();
kprintf("Processor frequency: %d MHz\n", get_cpu_frequency()/1000000);
kprintf("Total memory: %u MBytes\n", atomic_size_read(&total_memory)/(1024*1024));
kprintf("Current allocated memory: %u KBytes\n", atomic_size_read(&total_allocated_memory)/1024);
kprintf("Current available memory: %u MBytes\n", atomic_size_read(&total_available_memory)/(1024*1024));
timer_set_frequency(TIMER_FREQ);
create_kernel_task(&id1, foo, "Hello from foo1\n", 8192);
create_kernel_task(&id2, join_test, NULL, 0);
current_task->idle = 1;
schedule();
while(1) {
NOP8;
}
return 0;
}