]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/contrib/octeon-sdk/cvmx-log.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / contrib / octeon-sdk / cvmx-log.h
1 /***********************license start***************
2  * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
3  * reserved.
4  *
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *   * Redistributions of source code must retain the above copyright
11  *     notice, this list of conditions and the following disclaimer.
12  *
13  *   * Redistributions in binary form must reproduce the above
14  *     copyright notice, this list of conditions and the following
15  *     disclaimer in the documentation and/or other materials provided
16  *     with the distribution.
17
18  *   * Neither the name of Cavium Inc. nor the names of
19  *     its contributors may be used to endorse or promote products
20  *     derived from this software without specific prior written
21  *     permission.
22
23  * This Software, including technical data, may be subject to U.S. export  control
24  * laws, including the U.S. Export Administration Act and its  associated
25  * regulations, and may be subject to export or import  regulations in other
26  * countries.
27
28  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30  * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31  * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32  * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33  * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34  * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35  * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36  * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37  * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38  ***********************license end**************************************/
39
40
41
42
43
44
45 #ifndef __CVMX_LOG_H__
46 #define __CVMX_LOG_H__
47
48 /**
49  * @file
50  *
51  * cvmx-log supplies a fast log buffer implementation. Each core writes
52  * log data to a differnet buffer to avoid synchronization overhead. Function
53  * call logging can be turned on with the GCC option "-pg".
54  *
55  * <hr>$Revision: 70030 $<hr>
56  */
57
58 #ifdef CVMX_BUILD_FOR_LINUX_KERNEL
59 #include <asm/octeon/cvmx-core.h>
60 #else
61 #include "cvmx-core.h"
62 #endif
63
64 #ifdef  __cplusplus
65 extern "C" {
66 #endif
67
68 /*
69  * Add CVMX_LOG_DISABLE_PC_LOGGING as an attribute to and function prototype
70  * that you don't want logged when the gcc option "-pg" is supplied. We
71  * use it on the cvmx-log functions since it is pointless to log the
72  * calling of a function than in itself writes to the log.
73  */
74 #define CVMX_LOG_DISABLE_PC_LOGGING __attribute__((no_instrument_function))
75
76 /**
77  * Log a constant printf style format string with 0 to 4
78  * arguments. The string must persist until the log is read,
79  * but the parameters are copied into the log.
80  *
81  * @param format  Constant printf style format string.
82  * @param numberx 64bit argument to the printf format string
83  */
84 void cvmx_log_printf0(const char *format) CVMX_LOG_DISABLE_PC_LOGGING;
85 void cvmx_log_printf1(const char *format, uint64_t number1) CVMX_LOG_DISABLE_PC_LOGGING;
86 void cvmx_log_printf2(const char *format, uint64_t number1, uint64_t number2) CVMX_LOG_DISABLE_PC_LOGGING;
87 void cvmx_log_printf3(const char *format, uint64_t number1, uint64_t number2, uint64_t number3) CVMX_LOG_DISABLE_PC_LOGGING;
88 void cvmx_log_printf4(const char *format, uint64_t number1, uint64_t number2, uint64_t number3, uint64_t number4) CVMX_LOG_DISABLE_PC_LOGGING;
89
90 /**
91  * Log an arbitrary block of 64bit words. At most 255 64bit
92  * words can be logged. The words are copied into the log.
93  *
94  * @param size_in_dwords
95  *               Number of 64bit dwords to copy into the log.
96  * @param data   Array of 64bit dwords to copy
97  */
98 void cvmx_log_data(uint64_t size_in_dwords, const uint64_t *data) CVMX_LOG_DISABLE_PC_LOGGING;
99
100 /**
101  * Log a structured data object. Post processing will use the
102  * debugging information in the ELF file to determine how to
103  * display the structure. Max of 2032 bytes.
104  *
105  * Example:
106  * cvmx_log_structure("cvmx_wqe_t", work, sizeof(*work));
107  *
108  * @param type   C typedef expressed as a string. This will be used to
109  *               lookup the structure in the debugging infirmation.
110  * @param data   Data to be written to the log.
111  * @param size_in_bytes
112  *               Size if the data in bytes. Normally you'll use the
113  *               sizeof() operator here.
114  */
115 void cvmx_log_structure(const char *type, void *data, int size_in_bytes) CVMX_LOG_DISABLE_PC_LOGGING;
116
117 /**
118  * Setup the mips performance counters
119  *
120  * @param counter1 Event type for counter 1
121  * @param counter2 Event type for counter 2
122  */
123 void cvmx_log_perf_setup(cvmx_core_perf_t counter1, cvmx_core_perf_t counter2);
124
125 /**
126  * Log the performance counters
127  */
128 void cvmx_log_perf(void) CVMX_LOG_DISABLE_PC_LOGGING;
129
130 /**
131  * Display the current log in a human readable format.
132  */
133 void cvmx_log_display(void);
134
135 #ifdef  __cplusplus
136 }
137 #endif
138
139 #endif