summaryrefslogtreecommitdiffstats
path: root/sbe/sbefw/sbecmdparser.H
blob: b6b694812c5251f435c691288cf66f7dcf9553f1 (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
/*
 * @file: ppe/sbe/sbefw/sbecmdparser.H
 *
 * @brief This file contains the SBE command details
 *
 */

#ifndef __SBEFW_SBECMDPARSER_H
#define __SBEFW_SBECMDPARSER_H

#include <stdint.h>


/**
 *  @brief SBE Command structure associating an opcode of a command
 *         to the processing function as well as the allowed states
 *
 */
typedef uint32_t (*sbeChipOpFunc_t) (uint8_t *i_pArg);

typedef struct {
    sbeChipOpFunc_t   cmd_func;   /* Command function pointer */
    uint8_t           cmd_opcode; /* Command opcode */
    uint8_t  cmd_state_fence;     /* Command fencing based on SBE state */
} sbeCmdStruct_t;


/**
 *  @brief SBE Command Fence attributes
 *
 */
enum sbe_command_fence_attrs
{
    SBE_FENCE_AT_ISTEP          = 0x80, ///< Fence off the cmd at istep state
    SBE_FENCE_AT_CONTINUOUS_IPL = 0x40, ///< Fence off the cmd at cont IPL
    SBE_FENCE_AT_RUNTIME        = 0x20, ///< Fence off the cmd at Runtime state
    SBE_FENCE_AT_MPIPL          = 0x10, ///< Fence off the cmd at MPIPL state
    SBE_NO_FENCE                = 0x00, ///< Allow cmd in all states
};


/**
  * @brief sbeValidateCmdClass  Validates the command class and opcode
  *
  * @param[in]     i_cmdClass    Command class code
  * @param[in]     i_cmdOpcode   Command opcode
  *
  * @return uint8_t  return code
  *               SBE_SEC_OPERATION_SUCCESSFUL - Command found
  *               SBE_SEC_COMMAND_CLASS_NOT_SUPPORTED
  *               SBE_SEC_COMMAND_NOT_SUPPORTED
  */
uint8_t sbeValidateCmdClass (const uint8_t i_cmdClass,
                             const uint8_t i_cmdOpcode);

/**
  * @brief sbeIsCmdAllowedAtState  Validates if the command is allowed
  *        at the current SBE state
  *
  * @param[in]    i_cmdClass    Command class code
  * @param[in]    i_cmdOpcode   Command opcode
  *
  * @return       true  command is allowed at the current state
  *               false command is not allowed at the current state
  */
bool sbeIsCmdAllowedAtState (const uint8_t i_cmdClass,
                             const uint8_t i_cmdOpcode);


/**
  * @brief sbeCmdFunc_t Typical signature for any SBE ChipOp back-end function
  *
  * @param[in]  uint8_t *i_pArg  Pointer to the argument to be passed to
  *                              the chipOp function
  *
  * @return     uint32_t Return code from the chipOp function
  */
typedef uint32_t ( *sbeCmdFunc_t ) (uint8_t *i_pArg);


/**
  * @brief sbeFindCmdFunc  Finds the function corresponding to the command
  *
  * @param[in]     i_cmdClass    Command class code
  * @param[in]     i_cmdOpcode   Command opcode
  *
  * @return  sbeCmdFunc_t A pointer to the corresponding ChipOps function
  */
sbeCmdFunc_t sbeFindCmdFunc (const uint8_t i_cmdClass,
                             const uint8_t i_cmdOpcode);


#endif // __SBEFW_SBECMDPARSER_H
OpenPOWER on IntegriCloud