1210284Sjmallett/***********************license start***************
2232812Sjmallett * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
3215990Sjmallett * reserved.
4210284Sjmallett *
5210284Sjmallett *
6215990Sjmallett * Redistribution and use in source and binary forms, with or without
7215990Sjmallett * modification, are permitted provided that the following conditions are
8215990Sjmallett * met:
9210284Sjmallett *
10215990Sjmallett *   * Redistributions of source code must retain the above copyright
11215990Sjmallett *     notice, this list of conditions and the following disclaimer.
12210284Sjmallett *
13215990Sjmallett *   * Redistributions in binary form must reproduce the above
14215990Sjmallett *     copyright notice, this list of conditions and the following
15215990Sjmallett *     disclaimer in the documentation and/or other materials provided
16215990Sjmallett *     with the distribution.
17215990Sjmallett
18232812Sjmallett *   * Neither the name of Cavium Inc. nor the names of
19215990Sjmallett *     its contributors may be used to endorse or promote products
20215990Sjmallett *     derived from this software without specific prior written
21215990Sjmallett *     permission.
22215990Sjmallett
23215990Sjmallett * This Software, including technical data, may be subject to U.S. export  control
24215990Sjmallett * laws, including the U.S. Export Administration Act and its  associated
25215990Sjmallett * regulations, and may be subject to export or import  regulations in other
26215990Sjmallett * countries.
27215990Sjmallett
28215990Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29232812Sjmallett * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30215990Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31215990Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32215990Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33215990Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34215990Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35215990Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36215990Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37215990Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38210284Sjmallett ***********************license end**************************************/
39210284Sjmallett
40210284Sjmallett
41210284Sjmallett
42210284Sjmallett
43210284Sjmallett
44215990Sjmallett
45210284Sjmallett#ifndef __CVMX_LOG_H__
46210284Sjmallett#define __CVMX_LOG_H__
47210284Sjmallett
48210284Sjmallett/**
49210284Sjmallett * @file
50210284Sjmallett *
51210284Sjmallett * cvmx-log supplies a fast log buffer implementation. Each core writes
52210284Sjmallett * log data to a differnet buffer to avoid synchronization overhead. Function
53210284Sjmallett * call logging can be turned on with the GCC option "-pg".
54210284Sjmallett *
55232812Sjmallett * <hr>$Revision: 70030 $<hr>
56210284Sjmallett */
57210284Sjmallett
58232812Sjmallett#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
59232812Sjmallett#include <asm/octeon/cvmx-core.h>
60232812Sjmallett#else
61232812Sjmallett#include "cvmx-core.h"
62232812Sjmallett#endif
63232812Sjmallett
64210284Sjmallett#ifdef	__cplusplus
65210284Sjmallettextern "C" {
66210284Sjmallett#endif
67210284Sjmallett
68210284Sjmallett/*
69210284Sjmallett * Add CVMX_LOG_DISABLE_PC_LOGGING as an attribute to and function prototype
70210284Sjmallett * that you don't want logged when the gcc option "-pg" is supplied. We
71210284Sjmallett * use it on the cvmx-log functions since it is pointless to log the
72210284Sjmallett * calling of a function than in itself writes to the log.
73210284Sjmallett */
74210284Sjmallett#define CVMX_LOG_DISABLE_PC_LOGGING __attribute__((no_instrument_function))
75210284Sjmallett
76210284Sjmallett/**
77210284Sjmallett * Log a constant printf style format string with 0 to 4
78210284Sjmallett * arguments. The string must persist until the log is read,
79210284Sjmallett * but the parameters are copied into the log.
80210284Sjmallett *
81210284Sjmallett * @param format  Constant printf style format string.
82210284Sjmallett * @param numberx 64bit argument to the printf format string
83210284Sjmallett */
84210284Sjmallettvoid cvmx_log_printf0(const char *format) CVMX_LOG_DISABLE_PC_LOGGING;
85210284Sjmallettvoid cvmx_log_printf1(const char *format, uint64_t number1) CVMX_LOG_DISABLE_PC_LOGGING;
86210284Sjmallettvoid cvmx_log_printf2(const char *format, uint64_t number1, uint64_t number2) CVMX_LOG_DISABLE_PC_LOGGING;
87210284Sjmallettvoid cvmx_log_printf3(const char *format, uint64_t number1, uint64_t number2, uint64_t number3) CVMX_LOG_DISABLE_PC_LOGGING;
88210284Sjmallettvoid cvmx_log_printf4(const char *format, uint64_t number1, uint64_t number2, uint64_t number3, uint64_t number4) CVMX_LOG_DISABLE_PC_LOGGING;
89210284Sjmallett
90210284Sjmallett/**
91210284Sjmallett * Log an arbitrary block of 64bit words. At most 255 64bit
92210284Sjmallett * words can be logged. The words are copied into the log.
93210284Sjmallett *
94210284Sjmallett * @param size_in_dwords
95210284Sjmallett *               Number of 64bit dwords to copy into the log.
96210284Sjmallett * @param data   Array of 64bit dwords to copy
97210284Sjmallett */
98210284Sjmallettvoid cvmx_log_data(uint64_t size_in_dwords, const uint64_t *data) CVMX_LOG_DISABLE_PC_LOGGING;
99210284Sjmallett
100210284Sjmallett/**
101210284Sjmallett * Log a structured data object. Post processing will use the
102210284Sjmallett * debugging information in the ELF file to determine how to
103210284Sjmallett * display the structure. Max of 2032 bytes.
104210284Sjmallett *
105210284Sjmallett * Example:
106210284Sjmallett * cvmx_log_structure("cvmx_wqe_t", work, sizeof(*work));
107210284Sjmallett *
108210284Sjmallett * @param type   C typedef expressed as a string. This will be used to
109210284Sjmallett *               lookup the structure in the debugging infirmation.
110210284Sjmallett * @param data   Data to be written to the log.
111210284Sjmallett * @param size_in_bytes
112210284Sjmallett *               Size if the data in bytes. Normally you'll use the
113210284Sjmallett *               sizeof() operator here.
114210284Sjmallett */
115210284Sjmallettvoid cvmx_log_structure(const char *type, void *data, int size_in_bytes) CVMX_LOG_DISABLE_PC_LOGGING;
116210284Sjmallett
117210284Sjmallett/**
118210284Sjmallett * Setup the mips performance counters
119210284Sjmallett *
120210284Sjmallett * @param counter1 Event type for counter 1
121210284Sjmallett * @param counter2 Event type for counter 2
122210284Sjmallett */
123215990Sjmallettvoid cvmx_log_perf_setup(cvmx_core_perf_t counter1, cvmx_core_perf_t counter2);
124210284Sjmallett
125210284Sjmallett/**
126210284Sjmallett * Log the performance counters
127210284Sjmallett */
128210284Sjmallettvoid cvmx_log_perf(void) CVMX_LOG_DISABLE_PC_LOGGING;
129210284Sjmallett
130210284Sjmallett/**
131210284Sjmallett * Display the current log in a human readable format.
132210284Sjmallett */
133210284Sjmallettvoid cvmx_log_display(void);
134210284Sjmallett
135210284Sjmallett#ifdef	__cplusplus
136210284Sjmallett}
137210284Sjmallett#endif
138210284Sjmallett
139210284Sjmallett#endif
140