Skip to content

Commit

Permalink
libflash: Add ipmi-hiomap
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
amboar authored and stewartsmith committed Oct 11, 2018
1 parent c0b8454 commit 35c9559
Show file tree
Hide file tree
Showing 7 changed files with 972 additions and 18 deletions.
68 changes: 68 additions & 0 deletions include/hiomap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Copyright 2018 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 __HIOMAP_H
#define __HIOMAP_H

#include <ccan/endian/endian.h>
#include <ccan/short_types/short_types.h>
#include <compiler.h>
#include <stdint.h>

#define HIOMAP_V1 1
#define HIOMAP_V2 2

#define HIOMAP_C_RESET 1
#define HIOMAP_C_GET_INFO 2
#define HIOMAP_C_GET_FLASH_INFO 3
#define HIOMAP_C_CREATE_READ_WINDOW 4
#define HIOMAP_C_CLOSE_WINDOW 5
#define HIOMAP_C_CREATE_WRITE_WINDOW 6
#define HIOMAP_C_MARK_DIRTY 7
#define HIOMAP_C_FLUSH 8
#define HIOMAP_C_ACK 9
#define HIOMAP_C_ERASE 10
#define HIOMAP_C_DEVICE_NAME 11
#define HIOMAP_C_LOCK 12

#define HIOMAP_E_ACK_MASK 0x3
#define HIOMAP_E_PROTOCOL_RESET (1 << 0)
#define HIOMAP_E_WINDOW_RESET (1 << 1)
#define HIOMAP_E_FLASH_LOST (1 << 6)
#define HIOMAP_E_DAEMON_READY (1 << 7)

struct hiomap_v2_range {
le16 offset;
le16 size;
} __packed;

struct hiomap_v2_info {
uint8_t block_size_shift;
le16 timeout;
} __packed;

struct hiomap_v2_flash_info {
le16 total_size;
le16 erase_granule;
} __packed;

struct hiomap_v2_create_window {
le16 lpc_addr;
le16 size;
le16 offset;
} __packed;

#endif /* __HIOMAP_H */
35 changes: 18 additions & 17 deletions include/lpc-mbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@
#ifndef __LPC_MBOX_H
#define __LPC_MBOX_H

#include <hiomap.h>
#include <opal.h>
#include <ccan/endian/endian.h>

#define BMC_MBOX_ARGS_REGS 11
#define BMC_MBOX_READ_REGS 16
#define BMC_MBOX_WRITE_REGS 13

#define MBOX_C_RESET_STATE 0x01
#define MBOX_C_GET_MBOX_INFO 0x02
#define MBOX_C_GET_FLASH_INFO 0x03
#define MBOX_C_CREATE_READ_WINDOW 0x04
#define MBOX_C_CLOSE_WINDOW 0x05
#define MBOX_C_CREATE_WRITE_WINDOW 0x06
#define MBOX_C_MARK_WRITE_DIRTY 0x07
#define MBOX_C_WRITE_FLUSH 0x08
#define MBOX_C_BMC_EVENT_ACK 0x09
#define MBOX_C_MARK_WRITE_ERASED 0x0a
#define MBOX_C_GET_FLASH_NAME 0xb /* Unimplemented */
#define MBOX_C_MARK_LOCKED 0x0c
#define MBOX_C_RESET_STATE HIOMAP_C_RESET
#define MBOX_C_GET_MBOX_INFO HIOMAP_C_GET_INFO
#define MBOX_C_GET_FLASH_INFO HIOMAP_C_GET_FLASH_INFO
#define MBOX_C_CREATE_READ_WINDOW HIOMAP_C_CREATE_READ_WINDOW
#define MBOX_C_CLOSE_WINDOW HIOMAP_C_CLOSE_WINDOW
#define MBOX_C_CREATE_WRITE_WINDOW HIOMAP_C_CREATE_WRITE_WINDOW
#define MBOX_C_MARK_WRITE_DIRTY HIOMAP_C_MARK_DIRTY
#define MBOX_C_WRITE_FLUSH HIOMAP_C_FLUSH
#define MBOX_C_BMC_EVENT_ACK HIOMAP_C_ACK
#define MBOX_C_MARK_WRITE_ERASED HIOMAP_C_ERASE
#define MBOX_C_GET_FLASH_NAME HIOMAP_C_DEVICE_NAME
#define MBOX_C_MARK_LOCKED HIOMAP_C_LOCK
#define MBOX_COMMAND_COUNT 12

#define MBOX_R_SUCCESS 0x01
Expand All @@ -48,11 +49,11 @@
#define MBOX_R_SEQ_ERROR 0x08
#define MBOX_R_LOCKED 0x09

#define MBOX_ATTN_ACK_MASK 0x3
#define MBOX_ATTN_BMC_REBOOT (1 << 0)
#define MBOX_ATTN_BMC_WINDOW_RESET (1 << 1)
#define MBOX_ATTN_BMC_FLASH_LOST (1 << 6)
#define MBOX_ATTN_BMC_DAEMON_READY (1 << 7)
#define MBOX_ATTN_ACK_MASK HIOMAP_E_ACK_MASK
#define MBOX_ATTN_BMC_REBOOT HIOMAP_E_PROTOCOL_RESET
#define MBOX_ATTN_BMC_WINDOW_RESET HIOMAP_E_WINDOW_RESET
#define MBOX_ATTN_BMC_FLASH_LOST HIOMAP_E_FLASH_LOST
#define MBOX_ATTN_BMC_DAEMON_READY HIOMAP_E_DAEMON_READY

/* Default poll interval before interrupts are working */
#define MBOX_DEFAULT_POLL_MS 200
Expand Down
1 change: 1 addition & 0 deletions include/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct bmc_platform {
*/
uint32_t ipmi_oem_partial_add_esel;
uint32_t ipmi_oem_pnor_access_status;
uint32_t ipmi_oem_hiomap_cmd;
};

/* OpenCAPI platform-specific I2C information */
Expand Down
2 changes: 1 addition & 1 deletion libflash/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LIBFLASH_SRCS = libflash.c libffs.c ecc.c blocklevel.c mbox-flash.c
LIBFLASH_SRCS = libflash.c libffs.c ecc.c blocklevel.c mbox-flash.c ipmi-hiomap.c
LIBFLASH_OBJS = $(LIBFLASH_SRCS:%.c=%.o)

SUBDIRS += libflash
Expand Down

0 comments on commit 35c9559

Please sign in to comment.