]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/include/sys.h
Merge with tip
[arc.git] / system / kernel / include / sys.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 #ifndef SYS_H_\r
17 #define SYS_H_\r
18 \r
19 struct os_conf_global_hook_s;\r
20 \r
21 typedef enum  {\r
22         OP_SET_EVENT = 1,\r
23         OP_WAIT_EVENT = 2,\r
24         OP_ACTIVATE_TASK = 4,\r
25         OP_TERMINATE_TASK = 8,\r
26         OP_SCHEDULE = 16,\r
27         OP_CHAIN_TASK = 32,\r
28         OP_RELEASE_RESOURCE = 64,\r
29         OP_SLEEP = 128,\r
30 } OpType ;\r
31 \r
32 typedef struct sys_s {\r
33 //      OsApplicationType *curr_application;\r
34         /* Current running task*/\r
35         OsPcbType *curr_pcb;\r
36         /* List of all tasks */\r
37         OsPcbType *pcb_list;\r
38 \r
39         OsPcbType *chainedPcbPtr;\r
40         /* Interrupt nested count */\r
41         uint32 int_nest_cnt;\r
42         /* The current operation */\r
43         uint8_t op;\r
44         /* Ptr to the interrupt stack */\r
45         void *int_stack;\r
46         // The os tick\r
47         TickType tick;\r
48         // 1-The scheduler is locked (by GetResource() or something else)\r
49 //      int scheduler_lock;\r
50         /* Hooks */\r
51         struct OsHooks *hooks;\r
52 \r
53         // parameters for functions, used by OSErrorXXX()\r
54         uint32_t param1;\r
55         uint32_t param2;\r
56         uint32_t param3;\r
57         uint32_t serviceId;\r
58 \r
59         /* Current Application mode */\r
60         AppModeType appMode;\r
61 \r
62 //      uint32_t flags;\r
63 \r
64         uint32_t task_cnt;\r
65 \r
66 #if defined(USE_KERNEL_EXTRA)\r
67         /* List of PCB's to be put in ready list when timeout */\r
68         TAILQ_HEAD(,OsPcb) timerHead;           // TASK\r
69 #endif\r
70 \r
71         /* List of all pcb's,\r
72          * Only needed for non-static configuration of the kernel\r
73          */\r
74         TAILQ_HEAD(,OsPcb) pcb_head;\r
75         /* Ready queue */\r
76         TAILQ_HEAD(,OsPcb) ready_head;\r
77 \r
78         /* Occording to OSEK 8.3 RES_SCHEDULER is accessible to all tasks */\r
79         OsResourceType resScheduler;\r
80 } sys_t;\r
81 \r
82 extern sys_t os_sys;\r
83 \r
84 static inline OsPcbType *Os_TaskGetCurrent(  void ) {\r
85         return os_sys.curr_pcb;\r
86 }\r
87 \r
88 #if 0\r
89 static uint32_t OSErrorGetServiceId( void ) {\r
90         return os_sys.serviceId;\r
91 }\r
92 #endif\r
93 \r
94 \r
95 #endif /*SYS_H_*/\r