aboutsummaryrefslogtreecommitdiff
path: root/include/ipmi.h
blob: 8cc7e5a0e78d39f9c1057ab0302cc03d7dcf0266 (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
/* Copyright 2013-2014 IBM Corp.
 *
 * 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.
 */

#ifndef __IPMI_H
#define __IPMI_H

#include <stdint.h>

/*
 * IPMI codes as defined by the standard.
 */
#define IPMI_NETFN_APP_REQUEST		0x06
#define IPMI_NETFN_APP_RESPONSE		0x07
#define IPMI_GET_DEVICE_ID_CMD		0x01
#define IPMI_COLD_RESET_CMD		0x02
#define IPMI_WARM_RESET_CMD		0x03
#define IPMI_CLEAR_MSG_FLAGS_CMD	0x30
#define IPMI_GET_DEVICE_GUID_CMD	0x08
#define IPMI_GET_MSG_FLAGS_CMD		0x31
#define IPMI_SEND_MSG_CMD		0x34
#define IPMI_GET_MSG_CMD		0x33
#define IPMI_SET_BMC_GLOBAL_ENABLES_CMD	0x2e
#define IPMI_GET_BMC_GLOBAL_ENABLES_CMD	0x2f
#define IPMI_READ_EVENT_MSG_BUFFER_CMD	0x35
#define IPMI_GET_CHANNEL_INFO_CMD	0x42

#define IPMI_NETFN_CHASSIS_REQUEST	0x00
#define IPMI_NETFN_CHASSIS_RESPONSE	0x01
#define   IPMI_SET_CHASSIS_PWR_DOWN_CMD 0x00
#define   IPMI_SET_CHASSIS_PWR_UP_CMD   0x01
#define   IPMI_SET_CHASSIS_PWR_CYCLE_CMD 0x02

#define IPMI_NETFN_STORAGE_REQUEST	0x0a
#define IPMI_NETFN_STORAGE_RESPONSE	0x0b
#define   IPMI_GET_SEL_INFO_CMD		0x40
#define   IPMI_GET_SEL_TIME_CMD		0x48
#define   IPMI_SET_SEL_TIME_CMD		0x49

/*
 * IPMI response codes.
 */
#define IPMI_CC_NO_ERROR		0x00
#define IPMI_NODE_BUSY_ERR		0xc0
#define IPMI_INVALID_COMMAND_ERR	0xc1
#define IPMI_TIMEOUT_ERR		0xc3
#define IPMI_ERR_MSG_TRUNCATED		0xc6
#define IPMI_REQ_LEN_INVALID_ERR	0xc7
#define IPMI_REQ_LEN_EXCEEDED_ERR	0xc8
#define IPMI_NOT_IN_MY_STATE_ERR	0xd5	/* IPMI 2.0 */
#define IPMI_LOST_ARBITRATION_ERR	0x81
#define IPMI_BUS_ERR			0x82
#define IPMI_NAK_ON_WRITE_ERR		0x83
#define IPMI_ERR_UNSPECIFIED		0xff

struct ipmi_msg {
	uint8_t netfn;
	uint8_t cmd;
	uint8_t cc;
	uint8_t *req_data;
	uint8_t req_data_len;
	uint8_t *resp_data;
	uint8_t resp_data_len;
};

/* Initialise the IPMI interface */
void ipmi_init(void);

/* Change the power state of the P8 */
int64_t ipmi_opal_chassis_request(uint64_t request);

#endif