forked from vsamtuc/tinyos3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kernel_init.c
75 lines (50 loc) · 1.27 KB
/
kernel_init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef NVALGRIND
#include <valgrind/valgrind.h>
#endif
#include "bios.h"
#include "tinyos.h"
#include "kernel_sched.h"
#include "kernel_proc.h"
#include "kernel_dev.h"
#include "kernel_streams.h"
/*
*
* Initialization code
*
*/
/* Parameters from the 'boot' call are passed to boot_tinyos()
via static variables. */
static struct {
Task init_task;
int argl;
void* args;
} boot_rec;
/* Per-core boot function for tinyos */
void boot_tinyos_kernel()
{
if(cpu_core_id==0) {
/* Initialize the kenrel data structures */
initialize_processes();
initialize_devices();
initialize_files();
initialize_scheduler();
/* The boot task is executed normally! */
if(Exec(boot_rec.init_task, boot_rec.argl, boot_rec.args)!=1)
FATAL("The init process does not have PID==1");
}
cpu_core_barrier_sync();
#ifndef NVALGRIND
VALGRIND_PRINTF_BACKTRACE("TINYOS: Entering scheduler for core %d\n",cpu_core_id);
#endif
run_scheduler();
if(cpu_core_id==0) {
/* Here, we could add cleanup after the scheduler has ended. */
}
}
void boot(uint ncores, uint nterm, Task boot_task, int argl, void* args)
{
boot_rec.init_task = boot_task;
boot_rec.argl = argl;
boot_rec.args = args;
vm_boot(boot_tinyos_kernel, ncores, nterm);
}