1 /* -------------------------------- Arctic Core ------------------------------
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
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>.
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
14 * -------------------------------- Arctic Core ------------------------------*/
21 #include "simple_printf.h"
\r
23 extern uint32 os_dbg_mask;
\r
26 * 0 master print normal, 1-print
\r
27 * 1 master print isr 1-print
\r
28 * 2 normal 0-stdout,1-ramlog
\r
37 * So when debugging the kernel using the ISS you want to use:
\r
40 * Ramlog all the way:
\r
44 extern uint32 os_dbg_mask;
\r
46 #define STR_TASK "OS_TASK"
\r
47 #define STR_ALARM "OS_ALARM"
\r
48 #define STR_STBL "OS_STBL"
\r
51 #define os_dbg_printf(format,...) \
\r
52 if( os_dbg_mask & OS_DBG_MASTER_PRINT ) { \
\r
53 simple_printf(format,## __VA_ARGS__ ); \
\r
56 #define os_dbg_isr_printf(format,...) \
\r
57 if( os_dbg_mask & OS_DBG_ISR_MASTER_PRINT ) { \
\r
58 simple_printf(format,## __VA_ARGS__ ); \
\r
61 #define os_isr_printf(_mask,format,...) \
\r
62 if( (os_dbg_mask & OS_DBG_ISR_MASTER_PRINT) && ((_mask)>255 ) ) { \
\r
63 if( os_dbg_mask & D_ISR_STDOUT ) { \
\r
64 simple_printf("[%08d] : ",GetOsTick()); \
\r
65 simple_printf(format,## __VA_ARGS__ ); \
\r
67 ramlog_printf("[%08d] : ",GetOsTick()); \
\r
68 ramlog_printf(format,## __VA_ARGS__ ); \
\r
72 #define os_std_printf(_mask,format,...) \
\r
73 if( (os_dbg_mask & OS_DBG_MASTER_PRINT) && ((_mask)>255 ) ) { \
\r
74 if( os_dbg_mask & D_STDOUT) { \
\r
75 simple_printf("[%08d] : ",GetOsTick()); \
\r
76 simple_printf(format,## __VA_ARGS__ ); \
\r
78 ramlog_printf("[%08d] : ",GetOsTick()); \
\r
79 ramlog_printf(format,## __VA_ARGS__ ); \
\r
84 #define os_isr_printf(D_TASK,format,...) \
\r
85 if( (os_dbg_mask | OS_DBG_ISR_MASTER_PRINT | OS_DBG_TASK) \
\r
86 == os_dbg_mask ) { \
\r
87 simple_printf("[%08d] %s: ",GetOsTick(), STR_TASK); \
\r
88 simple_printf(format,## __VA_ARGS__ ); \
\r
91 #define os_dbg_task_printf(format,...) \
\r
92 if( (os_dbg_mask | OS_DBG_MASTER_PRINT | OS_DBG_TASK) \
\r
93 == os_dbg_mask ) { \
\r
94 simple_printf("[%08d] %s: ",GetOsTick(), STR_TASK); \
\r
95 simple_printf(format,## __VA_ARGS__ ); \
\r
100 static inline void Irq_Disable( void ) {
\r
104 static inline void Irq_Enable( void ) {
\r
111 #define os_dbg_m_printf(_x,format,...) \
\r
112 if( (os_dbg_mask | OS_DBG_ISR_MASTER_PRINT | (_x)) == os_dbg_mask) { \
\r
113 simple_printf(format,## __VA_ARGS__ ); \
\r
118 * PCB manipulating functions
\r
121 static inline procid_t get_curr_pid( void ) {
\r
122 return os_sys.curr_pcb->pid;
\r
125 static inline pcb_t *get_curr_pcb( void ) {
\r
126 return os_sys.curr_pcb;
\r
129 static inline void set_curr_pcb( pcb_t *pcb ) {
\r
130 os_sys.curr_pcb = pcb;
\r
133 static inline _Bool is_idle_task( pcb_t *pcb ){
\r
134 return (pcb->pid == 0);
\r
137 static inline procid_t get_curr_prio( void ){
\r
138 return os_sys.curr_pcb->prio;
\r
141 static inline TickType get_os_tick( void ) {
\r
142 return os_sys.tick;
\r
145 static inline app_t *get_curr_application( void ) {
\r
146 return get_curr_pcb()->application;
\r
149 static inline uint32_t get_curr_application_id( void ) {
\r
150 return get_curr_pcb()->application->application_id;
\r
153 static inline struct resource_obj_s *os_get_resource_int_p( void ) {
\r
154 return get_curr_pcb()->resource_int_p;
\r
161 static inline uint32_t os_task_nr_to_mask( uint32_t nr ) {
\r
166 pcb_t *os_find_top_prio_proc( void );
\r
167 pcb_t *os_find_task( TaskType tid );
\r
170 void os_resource_get_internal(void );
\r
171 void os_resource_release_internal( void );
\r
173 pcb_t * os_alloc_new_pcb( void );
\r
176 void OsTick( void );
\r
178 void *Os_Isr( void *stack, void *pcb_p );
\r
181 #endif /*INTERNAL_H_*/
\r