summaryrefslogtreecommitdiffstats
path: root/src/usr/trace/entry.H
blob: 77ec1f0b0d56ab6814581a73dc46dfc35522ac04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/trace/entry.H $                                       */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __TRACE_ENTRY_H
#define __TRACE_ENTRY_H

/** @file entry.H
 *
 *  Definition of both the Hostboot-unique "entry" structure and the
 *  fsp-trace common entry structures.
 */

#include <trace/interface.H>

namespace TRACE
{
    /** @struct Entry
     *
     *  @brief Maintains the data for an entry in the Hostboot trace buffers.
     *
     *  In order to allow easy traversal of component trace buffers when they
     *  are in a common buffer, this entry maintains a linked-list of entries
     *  within the same buffer.
     *
     *  Important conventions:
     *     * (comp == NULL) - Entry is "expired" and no longer valid.
     *     * (committed == 0) - Entry is still in the process of being created
     *                          by a client.
     *
     *  If we wished to reduce the size of this structure in the future, to
     *  reduce the memory impact of tracing, we could turn the pointers here
     *  into a "short pointer" which is only 32bits since all Hostboot heap
     *  addresses are under 4GB.
     */
    struct Entry
    {
        ComponentDesc* comp;    //< Component Descriptor for this Entry.
        Entry* next;            //< Linked-list 'next' ptr.
        Entry* prev;            //< Linked-list 'prev' ptr.
        volatile uint16_t committed;     //< Committed status.
        uint16_t size;          //< Size of data portion.
        char data[0];           //< Start of 'fsp-trace' style structure.
    };

    //----- Below are structures directly from FSP for fsp-trace ------//

    const uint32_t TRACE_BUF_VERSION = 0x01;    // Trace buffer version
    const uint32_t TRACE_COMP_TRACE  = 0x434F;  // Component Field Trace - "CO"
    const uint32_t TRACE_FIELDTRACE  = 0x4654;  // Field Trace - "FT"
    const uint32_t TRACE_FIELDBIN    = 0x4644;  // Binary Field Trace - "FD"
    const uint32_t TRACE_TIME_REAL   = 0;       // upper 32 = secs,
                                                // lower 32 = microsecs
    const uint32_t TRACE_BUF_CONT    = 2;       // Trace buffer is continuous
                                                // trace style.

    /*!
     * @brief Timestamp and thread id for each trace entry.
     */
    struct trace_entry_stamp_t
    {
        uint32_t tbh;        /*!< timestamp upper part */
        uint32_t tbl;        /*!< timestamp lower part */
        uint32_t tid;        /*!< process/thread id */
    };

    /*
     * @brief Structure is used by adal app. layer to fill in trace info.
     */
    struct trace_entry_head_t
    {
        uint16_t length;    /*!< size of trace entry */
        uint16_t tag;       /*!< type of entry: xTRACE xDUMP, (un)packed */
        uint32_t hash;      /*!< a value for the (format) string */
        uint32_t line;      /*!< source file line number of trace call */
    };

    /*
     * @brief Binary first writes header and time stamp.
     */
    struct trace_bin_entry_t {
        trace_entry_stamp_t stamp;
        trace_entry_head_t head;
        char data[0];
    };

    /*
     * @brief Structure is put at beginning of all trace buffers
     */
    struct trace_buf_head_t {
        unsigned char ver;         /*!< version of this struct (1)          */
        unsigned char hdr_len;     /*!< size of this struct in bytes        */
        unsigned char time_flg;    /*!< meaning of timestamp entry field    */
        unsigned char endian_flg;  /*!< flag for big ('B') or little
                                        ('L') endian */
        char comp[TRAC_COMP_SIZE]; /*!< the buffer name as specified in
                                        init call*/
        uint32_t size;             /*!< size of buffer, including this struct*/
        uint32_t times_wrap;       /*!< how often the buffer wrapped        */
        uint32_t next_free;        /*!< offset of the byte behind the latest
                                        entry*/
        uint32_t te_count;         /*!< Updated each time a trace is done   */
        uint32_t extracted;        /*!< Not currently used                  */
    };



}
#endif
OpenPOWER on IntegriCloud