Skip to content

Commit 35c9559

Browse files
amboarstewartsmith
authored andcommitted
libflash: Add ipmi-hiomap
ipmi-hiomap implements the PNOR access control protocol formerly known as "the mbox protocol" but uses IPMI instead of the AST LPC mailbox as a transport. As there is no-longer any mailbox involved in this alternate implementation the old protocol name is quite misleading, and so it has been renamed to "the hiomap protoocol" (Host I/O Mapping protocol). The same commands and events are used though this client-side implementation assumes v2 of the protocol is supported by the BMC. The code is a heavily-reworked copy of the mbox-flash source and is introduced this way to allow for the mbox implementation's eventual removal. mbox-flash should in theory be renamed to mbox-hiomap for consistency, but as it is on life-support effective immediately we may as well just remove it entirely when the time is right. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> [stewart: prlog debug over prerror for mbox fallback, fix indent] Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
1 parent c0b8454 commit 35c9559

File tree

7 files changed

+972
-18
lines changed

7 files changed

+972
-18
lines changed

include/hiomap.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* Copyright 2018 IBM Corp.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
* implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __HIOMAP_H
18+
#define __HIOMAP_H
19+
20+
#include <ccan/endian/endian.h>
21+
#include <ccan/short_types/short_types.h>
22+
#include <compiler.h>
23+
#include <stdint.h>
24+
25+
#define HIOMAP_V1 1
26+
#define HIOMAP_V2 2
27+
28+
#define HIOMAP_C_RESET 1
29+
#define HIOMAP_C_GET_INFO 2
30+
#define HIOMAP_C_GET_FLASH_INFO 3
31+
#define HIOMAP_C_CREATE_READ_WINDOW 4
32+
#define HIOMAP_C_CLOSE_WINDOW 5
33+
#define HIOMAP_C_CREATE_WRITE_WINDOW 6
34+
#define HIOMAP_C_MARK_DIRTY 7
35+
#define HIOMAP_C_FLUSH 8
36+
#define HIOMAP_C_ACK 9
37+
#define HIOMAP_C_ERASE 10
38+
#define HIOMAP_C_DEVICE_NAME 11
39+
#define HIOMAP_C_LOCK 12
40+
41+
#define HIOMAP_E_ACK_MASK 0x3
42+
#define HIOMAP_E_PROTOCOL_RESET (1 << 0)
43+
#define HIOMAP_E_WINDOW_RESET (1 << 1)
44+
#define HIOMAP_E_FLASH_LOST (1 << 6)
45+
#define HIOMAP_E_DAEMON_READY (1 << 7)
46+
47+
struct hiomap_v2_range {
48+
le16 offset;
49+
le16 size;
50+
} __packed;
51+
52+
struct hiomap_v2_info {
53+
uint8_t block_size_shift;
54+
le16 timeout;
55+
} __packed;
56+
57+
struct hiomap_v2_flash_info {
58+
le16 total_size;
59+
le16 erase_granule;
60+
} __packed;
61+
62+
struct hiomap_v2_create_window {
63+
le16 lpc_addr;
64+
le16 size;
65+
le16 offset;
66+
} __packed;
67+
68+
#endif /* __HIOMAP_H */

include/lpc-mbox.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@
1717
#ifndef __LPC_MBOX_H
1818
#define __LPC_MBOX_H
1919

20+
#include <hiomap.h>
2021
#include <opal.h>
2122
#include <ccan/endian/endian.h>
2223

2324
#define BMC_MBOX_ARGS_REGS 11
2425
#define BMC_MBOX_READ_REGS 16
2526
#define BMC_MBOX_WRITE_REGS 13
2627

27-
#define MBOX_C_RESET_STATE 0x01
28-
#define MBOX_C_GET_MBOX_INFO 0x02
29-
#define MBOX_C_GET_FLASH_INFO 0x03
30-
#define MBOX_C_CREATE_READ_WINDOW 0x04
31-
#define MBOX_C_CLOSE_WINDOW 0x05
32-
#define MBOX_C_CREATE_WRITE_WINDOW 0x06
33-
#define MBOX_C_MARK_WRITE_DIRTY 0x07
34-
#define MBOX_C_WRITE_FLUSH 0x08
35-
#define MBOX_C_BMC_EVENT_ACK 0x09
36-
#define MBOX_C_MARK_WRITE_ERASED 0x0a
37-
#define MBOX_C_GET_FLASH_NAME 0xb /* Unimplemented */
38-
#define MBOX_C_MARK_LOCKED 0x0c
28+
#define MBOX_C_RESET_STATE HIOMAP_C_RESET
29+
#define MBOX_C_GET_MBOX_INFO HIOMAP_C_GET_INFO
30+
#define MBOX_C_GET_FLASH_INFO HIOMAP_C_GET_FLASH_INFO
31+
#define MBOX_C_CREATE_READ_WINDOW HIOMAP_C_CREATE_READ_WINDOW
32+
#define MBOX_C_CLOSE_WINDOW HIOMAP_C_CLOSE_WINDOW
33+
#define MBOX_C_CREATE_WRITE_WINDOW HIOMAP_C_CREATE_WRITE_WINDOW
34+
#define MBOX_C_MARK_WRITE_DIRTY HIOMAP_C_MARK_DIRTY
35+
#define MBOX_C_WRITE_FLUSH HIOMAP_C_FLUSH
36+
#define MBOX_C_BMC_EVENT_ACK HIOMAP_C_ACK
37+
#define MBOX_C_MARK_WRITE_ERASED HIOMAP_C_ERASE
38+
#define MBOX_C_GET_FLASH_NAME HIOMAP_C_DEVICE_NAME
39+
#define MBOX_C_MARK_LOCKED HIOMAP_C_LOCK
3940
#define MBOX_COMMAND_COUNT 12
4041

4142
#define MBOX_R_SUCCESS 0x01
@@ -48,11 +49,11 @@
4849
#define MBOX_R_SEQ_ERROR 0x08
4950
#define MBOX_R_LOCKED 0x09
5051

51-
#define MBOX_ATTN_ACK_MASK 0x3
52-
#define MBOX_ATTN_BMC_REBOOT (1 << 0)
53-
#define MBOX_ATTN_BMC_WINDOW_RESET (1 << 1)
54-
#define MBOX_ATTN_BMC_FLASH_LOST (1 << 6)
55-
#define MBOX_ATTN_BMC_DAEMON_READY (1 << 7)
52+
#define MBOX_ATTN_ACK_MASK HIOMAP_E_ACK_MASK
53+
#define MBOX_ATTN_BMC_REBOOT HIOMAP_E_PROTOCOL_RESET
54+
#define MBOX_ATTN_BMC_WINDOW_RESET HIOMAP_E_WINDOW_RESET
55+
#define MBOX_ATTN_BMC_FLASH_LOST HIOMAP_E_FLASH_LOST
56+
#define MBOX_ATTN_BMC_DAEMON_READY HIOMAP_E_DAEMON_READY
5657

5758
/* Default poll interval before interrupts are working */
5859
#define MBOX_DEFAULT_POLL_MS 200

include/platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct bmc_platform {
4343
*/
4444
uint32_t ipmi_oem_partial_add_esel;
4545
uint32_t ipmi_oem_pnor_access_status;
46+
uint32_t ipmi_oem_hiomap_cmd;
4647
};
4748

4849
/* OpenCAPI platform-specific I2C information */

libflash/Makefile.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LIBFLASH_SRCS = libflash.c libffs.c ecc.c blocklevel.c mbox-flash.c
1+
LIBFLASH_SRCS = libflash.c libffs.c ecc.c blocklevel.c mbox-flash.c ipmi-hiomap.c
22
LIBFLASH_OBJS = $(LIBFLASH_SRCS:%.c=%.o)
33

44
SUBDIRS += libflash

0 commit comments

Comments
 (0)