From a7ad3ace523d19be103e03f6244e0e797354fe0f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 12 Nov 2007 15:02:23 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@87 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/include/ch.h | 4 +++ src/include/debug.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/include/threads.h | 4 +++ 3 files changed, 78 insertions(+) create mode 100644 src/include/debug.h (limited to 'src/include') diff --git a/src/include/ch.h b/src/include/ch.h index 9df1b8363..1102f4013 100644 --- a/src/include/ch.h +++ b/src/include/ch.h @@ -83,6 +83,10 @@ #include "serial.h" #endif +#ifndef _DEBUG_H_ +#include "debug.h" +#endif + /* * Common values. */ diff --git a/src/include/debug.h b/src/include/debug.h new file mode 100644 index 000000000..5a4f3ac44 --- /dev/null +++ b/src/include/debug.h @@ -0,0 +1,70 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @addtogroup Debug + * @{ + */ + +#ifndef _DEBUG_H_ +#define _DEBUG_H_ + +#ifdef CH_USE_DEBUG + +#define TRACE_BUFFER_SIZE 1024 + +typedef struct { + void *cse_slpdata; + t_time cse_time; + UWORD16 cse_state: 4; + UWORD16 cse_tid: 12; +} CtxSwcEvent; + +typedef struct { + t_size tb_size; + CtxSwcEvent *tb_ptr; + CtxSwcEvent tb_buffer[TRACE_BUFFER_SIZE]; +} TraceBuffer; + +extern CtxSwcEvent *dbgnext; +extern TraceBuffer dbgtb; +extern char *dbglastmsg; + +#ifdef __cplusplus +extern "C" { +#endif + void chDbgInit(void); + void chDbgTrace(Thread *otp, Thread *ntp); + void chDbgPuts(char *msg); + void chDbgPanic(char *msg); +#ifdef __cplusplus +} +#endif + +#else /* CH_USE_DEBUG */ + +#define chDbgInit() +#define chDbgPuts(msg) {} +#define chDbgPanic(msg) {} + +#endif /* CH_USE_DEBUG */ + +#endif /* _DEBUG_H_ */ + +/** @} */ diff --git a/src/include/threads.h b/src/include/threads.h index effad525c..e4cd8376e 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -41,6 +41,8 @@ struct Thread { /** The thread priority.*/ t_prio p_prio; /* End of the fields shared with the ReadyList structure. */ + /** Thread identifier. */ + t_tid p_tid; /** Current thread state.*/ t_tstate p_state; /** Mode flags.*/ @@ -68,6 +70,8 @@ struct Thread { /** Message (only while in \p PRSNDMSG state).*/ t_msg p_msg; #endif + /** Generic way to access the union.*/ + void *p_common; }; /** Machine dependent processor context.*/ Context p_ctx; -- cgit v1.2.3