hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
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
128
129
130
131
132
133
134
135
136
137
138
/** @file
  Generic IPMI stack head file during PEI phase
 
  @copyright
  Copyright 2017 - 2021 Intel Corporation. <BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent
**/
 
#ifndef _PEI_IPMI_INIT_H_
#define _PEI_IPMI_INIT_H_
 
#include <PiPei.h>
#include <Uefi.h>
 
#include <Ppi/IpmiTransportPpi.h>
 
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/TimerLib.h>
#include <Library/PciLib.h>
 
#include "PeiIpmiBmcDef.h"
#include "PeiIpmiBmc.h"
 
//
// Prototypes
//
#define MBXDAT_B                          0x0B
#define BMC_KCS_TIMEOUT_PEI               5     // [s] Single KSC request timeout
#define KCS_DELAY_UNIT_PEI                1000  // [s] Each KSC IO delay
#define IPMI_DEFAULT_IO_BASE              0xCA2
 
//
// Internal(hook) function list
//
EFI_STATUS
SendPreBootSignaltoBmc (
  IN CONST EFI_PEI_SERVICES             **PeiServices
  )
  /*++
 
Routine Description:
  Send Pre-Boot signal to BMC
 
Arguments:
  PeiServices           - General purpose services available to every PEIM.
 
Returns:
  EFI_SUCCESS           - Success
--*/
;
 
EFI_STATUS
PeiIpmiSendCommand (
  IN      PEI_IPMI_TRANSPORT_PPI       *This,
  IN      UINT8                        NetFunction,
  IN      UINT8                        Lun,
  IN      UINT8                        Command,
  IN      UINT8                        *CommandData,
  IN      UINT32                       CommandDataSize,
  IN OUT  UINT8                        *ResponseData,
  IN OUT  UINT32                       *ResponseDataSize
  )
/*++
 
Routine Description:
  Send IPMI command to BMC
 
Arguments:
  This              - Pointer to IPMI protocol instance
  NetFunction       - Net Function of command to send
  Lun               - LUN of command to send
  Command           - IPMI command to send
  CommandData       - Pointer to command data buffer, if needed
  CommandDataSize   - Size of command data buffer
  ResponseData      - Pointer to response data buffer
  ResponseDataSize  - Pointer to response data buffer size
 
Returns:
  EFI_INVALID_PARAMETER - One of the input values is bad
  EFI_DEVICE_ERROR      - IPMI command failed
  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
  EFI_UNSUPPORTED       - Command is not supported by BMC
  EFI_SUCCESS           - Command completed successfully
--*/
;
 
EFI_STATUS
PeiGetIpmiBmcStatus (
  IN  PEI_IPMI_TRANSPORT_PPI                           *This,
  OUT BMC_STATUS                                       *BmcStatus,
  OUT SM_COM_ADDRESS                                   *ComAddress
  )
/*++
 
Routine Description:
  Updates the BMC status and returns the Com Address
 
Arguments:
  This        - Pointer to IPMI protocol instance
  BmcStatus   - BMC status
  ComAddress  - Com Address
 
Returns:
  EFI_SUCCESS - Success
--*/
;
 
//
// internal function list
//
EFI_STATUS
GetDeviceId (
  IN      PEI_IPMI_BMC_INSTANCE_DATA   *mIpmiInstance
  )
/*++
 
Routine Description:
  Execute the Get Device ID command to determine whether or not the BMC is in Force Update
  Mode.  If it is, then report it to the error manager.
 
Arguments:
  mIpmiInstance   - Data structure describing BMC variables and used for sending commands
  StatusCodeValue - An array used to accumulate error codes for later reporting.
  ErrorCount      - Counter used to keep track of error codes in StatusCodeValue
 
Returns:
  Status
 
--*/
;
#endif //_PEI_IPMI_INIT_H_