source: rtems/bsps/arm/atsam/include/libchip/include/trace.h @ 71c5552f

Last change on this file since 71c5552f was 2afb22b, checked in by Chris Johns <chrisj@…>, on Dec 23, 2017 at 7:18:56 AM

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100644
File size: 8.8 KB
Line 
1/* ---------------------------------------------------------------------------- */
2/*                  Atmel Microcontroller Software Support                      */
3/*                       SAM Software Package License                           */
4/* ---------------------------------------------------------------------------- */
5/* Copyright (c) 2015, Atmel Corporation                                        */
6/*                                                                              */
7/* All rights reserved.                                                         */
8/*                                                                              */
9/* Redistribution and use in source and binary forms, with or without           */
10/* modification, are permitted provided that the following condition is met:    */
11/*                                                                              */
12/* - Redistributions of source code must retain the above copyright notice,     */
13/* this list of conditions and the disclaimer below.                            */
14/*                                                                              */
15/* Atmel's name may not be used to endorse or promote products derived from     */
16/* this software without specific prior written permission.                     */
17/*                                                                              */
18/* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
19/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
21/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
22/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
24/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
25/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
26/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
28/* ---------------------------------------------------------------------------- */
29
30/**
31 *  \file
32 *
33 *  \par Purpose
34 *
35 *  Standard output methods for reporting debug information, warnings and
36 *  errors, which can be easily be turned on/off.
37 *
38 *  \par Usage
39 *  -# Initialize the DBGU using TRACE_CONFIGURE() if you intend to eventually
40 *     disable ALL traces; otherwise use DBGU_Configure().
41 *  -# Uses the TRACE_DEBUG(), TRACE_INFO(), TRACE_WARNING(), TRACE_ERROR()
42 *     TRACE_FATAL() macros to output traces throughout the program.
43 *  -# Each type of trace has a level : Debug 5, Info 4, Warning 3, Error 2
44 *     and Fatal 1. Disable a group of traces by changing the value of
45 *     TRACE_LEVEL during compilation; traces with a level bigger than TRACE_LEVEL
46 *     are not generated. To generate no trace, use the reserved value 0.
47 *  -# Trace disabling can be static or dynamic. If dynamic disabling is selected
48 *     the trace level can be modified in runtime. If static disabling is selected
49 *     the disabled traces are not compiled.
50 *
51 *  \par traceLevels Trace level description
52 *  -# TRACE_DEBUG (5): Traces whose only purpose is for debugging the program,
53 *     and which do not produce meaningful information otherwise.
54 *  -# TRACE_INFO (4): Informational trace about the program execution. Should
55 *     enable the user to see the execution flow.
56 *  -# TRACE_WARNING (3): Indicates that a minor error has happened. In most case
57 *     it can be discarded safely; it may even be expected.
58 *  -# TRACE_ERROR (2): Indicates an error which may not stop the program execution,
59 *     but which indicates there is a problem with the code.
60 *  -# TRACE_FATAL (1): Indicates a major error which prevents the program from going
61 *     any further.
62 */
63
64#ifndef _TRACE_
65#define _TRACE_
66
67/*
68 *         Headers
69 */
70
71#include "pio.h"
72
73#include <stdio.h>
74
75/*
76 *         Global Definitions
77 */
78
79/**  Softpack Version */
80#define SOFTPACK_VERSION       "1.5"
81
82
83#define TRACE_LEVEL_DEBUG      5
84#define TRACE_LEVEL_INFO       4
85#define TRACE_LEVEL_WARNING    3
86#define TRACE_LEVEL_ERROR      2
87#define TRACE_LEVEL_FATAL      1
88#define TRACE_LEVEL_NO_TRACE   0
89
90/* By default, all traces are output except the debug one. */
91#if !defined(TRACE_LEVEL)
92        #define TRACE_LEVEL TRACE_LEVEL_INFO
93#endif
94
95/* By default, trace level is static (not dynamic) */
96#if !defined(DYN_TRACES)
97        #define DYN_TRACES 0
98#endif
99
100#if defined(NOTRACE)
101        #error "Error: NOTRACE has to be not defined !"
102#endif
103
104#undef NOTRACE
105#if (DYN_TRACES==0)
106        #if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)
107                #define NOTRACE
108        #endif
109#endif
110
111
112
113/* ------------------------------------------------------------------------------
114 *         Global Macros
115 * ------------------------------------------------------------------------------
116 */
117
118extern void TRACE_CONFIGURE(uint32_t dwBaudRate, uint32_t dwMCk);
119
120/**
121 *  Initializes the DBGU for ISP project
122 *
123 *  \param mode  DBGU mode.
124 *  \param baudrate  DBGU baudrate.
125 *  \param mck  Master clock frequency.
126 */
127#ifndef DYNTRACE
128        #define DYNTRACE 0
129#endif
130
131#if (TRACE_LEVEL==0) && (DYNTRACE==0)
132#define TRACE_CONFIGURE_ISP(mode, baudrate, mck) {}
133#else
134#define TRACE_CONFIGURE_ISP(mode, baudrate, mck) { \
135                const Pin pinsUART0[] = {PINS_UART}; \
136                PIO_Configure(pinsUART0, PIO_LISTSIZE(pinsUART0)); \
137                UART_Configure(baudrate, mck); \
138        }
139#endif
140
141/**
142 *  Outputs a formatted string using 'printf' if the log level is high
143 *  enough. Can be disabled by defining TRACE_LEVEL=0 during compilation.
144 *  \param ...  Additional parameters depending on formatted string.
145 */
146#if defined(NOTRACE)
147
148        /* Empty macro */
149        #define TRACE_DEBUG(...)      { }
150        #define TRACE_INFO(...)       { }
151        #define TRACE_WARNING(...)    { }
152        #define TRACE_ERROR(...)      { }
153        #define TRACE_FATAL(...)      { while (1); }
154
155        #define TRACE_DEBUG_WP(...)   { }
156        #define TRACE_INFO_WP(...)    { }
157        #define TRACE_WARNING_WP(...) { }
158        #define TRACE_ERROR_WP(...)   { }
159        #define TRACE_FATAL_WP(...)   { while (1); }
160
161#elif (DYN_TRACES == 1)
162
163        /* Trace output depends on dwTraceLevel value */
164        #define TRACE_DEBUG(...)      { if (dwTraceLevel >= TRACE_LEVEL_DEBUG)   { printf("-D- " __VA_ARGS__); } }
165        #define TRACE_INFO(...)       { if (dwTraceLevel >= TRACE_LEVEL_INFO)    { printf("-I- " __VA_ARGS__); } }
166        #define TRACE_WARNING(...)    { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }
167        #define TRACE_ERROR(...)      { if (dwTraceLevel >= TRACE_LEVEL_ERROR)   { printf("-E- " __VA_ARGS__); } }
168        #define TRACE_FATAL(...)      { if (dwTraceLevel >= TRACE_LEVEL_FATAL)   { printf("-F- " __VA_ARGS__); while (1); } }
169
170        #define TRACE_DEBUG_WP(...)   { if (dwTraceLevel >= TRACE_LEVEL_DEBUG)   { printf(__VA_ARGS__); } }
171        #define TRACE_INFO_WP(...)    { if (dwTraceLevel >= TRACE_LEVEL_INFO)    { printf(__VA_ARGS__); } }
172        #define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }
173        #define TRACE_ERROR_WP(...)   { if (dwTraceLevel >= TRACE_LEVEL_ERROR)   { printf(__VA_ARGS__); } }
174        #define TRACE_FATAL_WP(...)   { if (dwTraceLevel >= TRACE_LEVEL_FATAL)   { printf(__VA_ARGS__); while (1); } }
175
176#else
177
178        /* Trace compilation depends on TRACE_LEVEL value */
179        #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
180                #define TRACE_DEBUG(...)      { printf("-D- " __VA_ARGS__); }
181                #define TRACE_DEBUG_WP(...)   { printf(__VA_ARGS__); }
182        #else
183                #define TRACE_DEBUG(...)      { }
184                #define TRACE_DEBUG_WP(...)   { }
185        #endif
186
187        #if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
188                #define TRACE_INFO(...)       { printf("-I- " __VA_ARGS__); }
189                #define TRACE_INFO_WP(...)    { printf(__VA_ARGS__); }
190        #else
191                #define TRACE_INFO(...)       { }
192                #define TRACE_INFO_WP(...)    { }
193        #endif
194
195        #if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
196                #define TRACE_WARNING(...)    { printf("-W- " __VA_ARGS__); }
197                #define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }
198        #else
199                #define TRACE_WARNING(...)    { }
200                #define TRACE_WARNING_WP(...) { }
201        #endif
202
203        #if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
204                #define TRACE_ERROR(...)      { printf("-E- " __VA_ARGS__); }
205                #define TRACE_ERROR_WP(...)   { printf(__VA_ARGS__); }
206        #else
207                #define TRACE_ERROR(...)      { }
208                #define TRACE_ERROR_WP(...)   { }
209        #endif
210
211        #if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
212                #define TRACE_FATAL(...)      { printf("-F- " __VA_ARGS__); while (1); }
213                #define TRACE_FATAL_WP(...)   { printf(__VA_ARGS__); while (1); }
214        #else
215                #define TRACE_FATAL(...)      { while (1); }
216                #define TRACE_FATAL_WP(...)   { while (1); }
217        #endif
218
219#endif
220
221
222/**
223 *        Exported variables
224 */
225/** Depending on DYN_TRACES, dwTraceLevel is a modifiable runtime variable or a define */
226#if !defined(NOTRACE) && (DYN_TRACES == 1)
227        extern uint32_t dwTraceLevel;
228#endif
229
230#endif //#ifndef TRACE_H
231
Note: See TracBrowser for help on using the repository browser.