fb11e647
vrobic
reseau statique a...
|
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*
* Copyright (C) 2013 Freie Universitรคt Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup core_internal
* @{
*
* @file
* @brief Platform-independent kernel initilization
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include "kernel_init.h"
#include "sched.h"
#include "thread.h"
#include "lpm.h"
#include "irq.h"
#include "log.h"
#ifdef MODULE_SCHEDSTATISTICS
#include "sched.h"
#endif
#define ENABLE_DEBUG (0)
#include "debug.h"
#ifdef MODULE_AUTO_INIT
#include <auto_init.h>
#endif
volatile int lpm_prevent_sleep = 0;
extern int main(void);
static void *main_trampoline(void *arg)
{
(void) arg;
#ifdef MODULE_AUTO_INIT
auto_init();
#endif
#ifdef MODULE_SCHEDSTATISTICS
schedstat *stat = &sched_pidlist[thread_getpid()];
stat->laststart = 0;
#endif
LOG_INFO("main(): This is RIOT! (Version: " RIOT_VERSION ")\n");
main();
return NULL;
}
static void *idle_thread(void *arg)
{
(void) arg;
while (1) {
if (lpm_prevent_sleep) {
lpm_set(LPM_IDLE);
}
else {
lpm_set(LPM_IDLE);
/* lpm_set(LPM_SLEEP); */
/* lpm_set(LPM_POWERDOWN); */
}
}
return NULL;
}
const char *main_name = "main";
const char *idle_name = "idle";
static char main_stack[THREAD_STACKSIZE_MAIN];
static char idle_stack[THREAD_STACKSIZE_IDLE];
void kernel_init(void)
{
(void) irq_disable();
thread_create(idle_stack, sizeof(idle_stack),
THREAD_PRIORITY_IDLE,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
idle_thread, NULL, idle_name);
thread_create(main_stack, sizeof(main_stack),
THREAD_PRIORITY_MAIN,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
main_trampoline, NULL, main_name);
cpu_switch_context_exit();
}
|