]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/create.c
Initial commit.
[arc.git] / system / kernel / create.c
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
6  * This source code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published by the
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14  * -------------------------------- Arctic Core ------------------------------*/
15
16
17
18
19
20
21
22
23 /*\r
24  * create.c\r
25  *\r
26  *  Created on: 2009-jan-16\r
27  *      Author: mahi\r
28  */\r
29 \r
30 #include <stdint.h>\r
31 #include <stdlib.h>\r
32 #include <assert.h>\r
33 #include <sys/queue.h>\r
34 #include <string.h>\r
35 #include "sys.h"\r
36 #include "pcb.h"\r
37 #include "Os.h"\r
38 \r
39 #define os_alloc(_x)    malloc(_x)\r
40 \r
41 pcb_t * os_alloc_new_pcb( void ) {\r
42         void *h = os_alloc(sizeof(pcb_t));\r
43         memset(h,0,sizeof(pcb_t));\r
44         assert(h!=NULL);\r
45         return h;\r
46 }\r
47 \r
48 #if 0\r
49 typedef void (*Os_IsrEntryType)(void);\r
50 \r
51 \r
52 typedef Os_IsrInfo_s {\r
53         Os_IsrEntryType entry;\r
54         uint32_t vector;\r
55         uint8_t priority;\r
56 } Os_IsrInfoType;\r
57 #endif\r
58 \r
59 \r
60 extern TaskType os_add_task( pcb_t *pcb );\r
61 \r
62 static uint8 stackTop = 0x42;\r
63 \r
64 TaskType Os_CreateIsr( void (*entry)(void ), uint8_t prio, const char *name )\r
65 {\r
66         pcb_t *pcb = os_alloc_new_pcb();\r
67         strncpy(pcb->name,name,TASK_NAME_SIZE);\r
68         pcb->vector = -1;\r
69         pcb->prio = prio;\r
70         pcb->proc_type  = PROC_ISR2;\r
71         pcb->state = ST_SUSPENDED;\r
72         pcb->entry = entry;\r
73         pcb->stack.top = &stackTop;\r
74 \r
75         return os_add_task(pcb);\r
76 }\r
77 \r