summaryrefslogtreecommitdiffstats
path: root/src/usr/errl/plugins/errludparser.H
blob: 39e28929b4a5ec16d19b423e419d2c73406a02a8 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/errl/plugins/errludparser.H $                         */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef ERRL_UDPARSER_H
#define ERRL_UDPARSER_H

/**
 *  @file errludparser.H
 *
 *  To create a function that errl calls to parse user detail data, a
 *  component's plugin/<comp>Parse.C file should include this file and call the
 *  ERRL_MAKE_UD_PARSER macro
 */

#include <netinet/in.h>

/**
 * @brief Endian swap a uint64_t. This is not provided by in.h
 */
inline uint64_t ntohll( uint64_t i )
#if __BYTE_ORDER == __LITTLE_ENDIAN
{
    //  CONTEXT_x86_nfp
    uint64_t hi;
    uint64_t lo;
    uint32_t * pword = reinterpret_cast<uint32_t*>(&i);

    hi = ntohl( *pword );
    lo = ntohl( *(pword+1) );

    return (hi<<32)|lo;
}
#elif __BYTE_ORDER == __BIG_ENDIAN
{
    // CONTEXT_ppc (or maybe CONTEXT_aix_nfp)
    return i;
}
#else
#error Unexpected endian context.
#endif

// FSP includes
#include <errlplugins.H>
#include <errlusrparser.H>
#include "hbfwUdIds.H"

/**
 * @brief Macro that generates a function and plugin object to parse a
 *        component's error log user detail data
 */
#define ERRL_MAKE_UD_PARSER(FACTORY, COMPID) \
static bool myDataParse(\
    ErrlUsrParser& i_parser, void* i_buffer, uint32_t i_buflen,\
    errlver_t i_ver, errlsubsec_t i_sst)\
{\
    bool l_rc = false;\
    FACTORY l_factory;\
    ERRORLOG::ErrlUserDetailsParser * l_pParser =\
        l_factory.createParser(i_sst);\
    if (l_pParser)\
    {\
        l_rc = true;\
        l_pParser->parse(i_ver, i_parser, i_buffer, i_buflen);\
    }\
    return l_rc;\
}\
static errl::DataPlugin g_DataPlugin(COMPID, myDataParse, ERRL_CID_HOSTBOOT);

#endif

OpenPOWER on IntegriCloud