2010-07-31 15:53:30 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2010-08-22 09:56:02 +00:00
|
|
|
#include <metalsvm/string.h>
|
2010-07-31 15:53:30 +00:00
|
|
|
#include <metalsvm/time.h>
|
2014-01-09 16:20:18 +01:00
|
|
|
#include <metalsvm/memory.h>
|
2010-07-31 15:53:30 +00:00
|
|
|
#include <metalsvm/tasks.h>
|
|
|
|
#include <metalsvm/processor.h>
|
2010-11-30 06:06:28 +00:00
|
|
|
#include <metalsvm/errno.h>
|
2010-12-10 06:16:58 +00:00
|
|
|
#include <metalsvm/init.h>
|
2011-08-06 15:52:47 +02:00
|
|
|
#include <metalsvm/fs.h>
|
2010-08-04 17:22:58 +00:00
|
|
|
#include <asm/irq.h>
|
2010-08-11 18:52:43 +00:00
|
|
|
#include <asm/irqflags.h>
|
2013-10-24 12:36:05 +02:00
|
|
|
#include <asm/page.h>
|
2010-07-31 15:53:30 +00:00
|
|
|
#include <asm/kb.h>
|
2011-04-23 00:13:12 -07:00
|
|
|
#ifdef CONFIG_ROCKCREEK
|
|
|
|
#include <asm/icc.h>
|
2011-08-16 03:29:54 -07:00
|
|
|
#include <asm/svm.h>
|
2011-04-23 00:13:12 -07:00
|
|
|
#endif
|
2010-07-31 15:53:30 +00:00
|
|
|
|
2010-11-04 08:27:53 +00:00
|
|
|
/*
|
|
|
|
* Note that linker symbols are not variables, they have no memory allocated for
|
|
|
|
* maintaining a value, rather their address is their value.
|
|
|
|
*/
|
2010-08-05 11:53:02 +00:00
|
|
|
extern const void kernel_start;
|
|
|
|
extern const void kernel_end;
|
2010-11-04 08:27:53 +00:00
|
|
|
extern char __BUILD_DATE;
|
|
|
|
extern char __BUILD_TIME;
|
2010-08-17 21:20:03 +00:00
|
|
|
|
2011-07-18 09:14:28 +02:00
|
|
|
#if MAX_CORES > 1
|
|
|
|
// idle loop of the application processors
|
|
|
|
int smp_main(void)
|
|
|
|
{
|
|
|
|
irq_enable();
|
|
|
|
|
2012-07-03 16:46:54 +02:00
|
|
|
#ifdef CONFIG_TICKLESS
|
|
|
|
disable_timer_irq();
|
|
|
|
#endif
|
|
|
|
|
2011-07-18 09:14:28 +02:00
|
|
|
while(1) {
|
2012-07-03 16:46:54 +02:00
|
|
|
check_workqueues();
|
2011-07-18 09:14:28 +02:00
|
|
|
HALT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-31 15:53:30 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
2011-10-04 00:02:33 -07:00
|
|
|
tid_t id;
|
|
|
|
|
2012-06-10 08:05:24 +02:00
|
|
|
lowlevel_init();
|
2011-03-07 20:02:24 +01:00
|
|
|
|
2011-05-21 11:51:22 +02:00
|
|
|
pushbg(COL_BLUE);
|
|
|
|
kprintf("This is MetalSVM %s Build %u, %u\n",
|
2014-01-09 13:32:00 +01:00
|
|
|
METALSVM_VERSION, &__BUILD_DATE, &__BUILD_TIME);
|
2011-05-21 11:51:22 +02:00
|
|
|
popbg();
|
2013-11-20 12:03:24 +01:00
|
|
|
|
2010-08-02 07:43:56 +00:00
|
|
|
system_init();
|
2010-07-31 15:53:30 +00:00
|
|
|
irq_init();
|
|
|
|
timer_init();
|
2010-08-05 11:53:02 +00:00
|
|
|
#ifdef CONFIG_KEYBOARD
|
2010-07-31 15:53:30 +00:00
|
|
|
keyboard_init();
|
2010-08-02 08:58:06 +00:00
|
|
|
#endif
|
2010-07-31 15:53:30 +00:00
|
|
|
multitasking_init();
|
2010-12-10 06:16:58 +00:00
|
|
|
mmu_init();
|
2011-04-08 07:24:47 -07:00
|
|
|
#ifdef CONFIG_ROCKCREEK
|
2011-04-23 00:13:12 -07:00
|
|
|
icc_init();
|
2011-08-16 03:29:54 -07:00
|
|
|
svm_init();
|
2011-04-08 07:24:47 -07:00
|
|
|
#endif
|
2013-11-20 12:03:24 +01:00
|
|
|
initrd_init();
|
2010-07-31 15:53:30 +00:00
|
|
|
|
|
|
|
irq_enable();
|
|
|
|
|
2010-08-05 11:53:02 +00:00
|
|
|
kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end);
|
2010-11-04 20:15:39 +00:00
|
|
|
system_calibration();
|
|
|
|
|
2010-11-24 18:58:42 +00:00
|
|
|
kprintf("Processor frequency: %u MHz\n", get_cpu_frequency());
|
2010-08-09 13:22:03 +00:00
|
|
|
kprintf("Total memory: %u MBytes\n", atomic_int32_read(&total_pages)/((1024*1024)/PAGE_SIZE));
|
|
|
|
kprintf("Current allocated memory: %u KBytes\n", atomic_int32_read(&total_allocated_pages)*(PAGE_SIZE/1024));
|
|
|
|
kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE));
|
2010-07-31 15:53:30 +00:00
|
|
|
|
2012-07-03 16:46:54 +02:00
|
|
|
#ifdef CONFIG_TICKLESS
|
|
|
|
disable_timer_irq();
|
|
|
|
#endif
|
|
|
|
|
2013-11-20 12:06:53 +01:00
|
|
|
sleep(2);
|
2011-10-04 00:02:33 -07:00
|
|
|
create_kernel_task(&id, initd, NULL, NORMAL_PRIO);
|
|
|
|
kprintf("Create initd with id %u\n", id);
|
2014-01-09 13:32:00 +01:00
|
|
|
|
2010-08-09 11:47:51 +00:00
|
|
|
reschedule();
|
2010-07-31 15:53:30 +00:00
|
|
|
|
2011-09-02 13:57:11 -07:00
|
|
|
while(1) {
|
|
|
|
check_workqueues();
|
2011-04-08 15:56:03 +02:00
|
|
|
HALT;
|
2010-07-31 15:53:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|