Commit 26558dbb authored by Andrew Jeffery's avatar Andrew Jeffery
Browse files

mboxd: Refactor and rename mbox.h to mboxd.h


Refine the purpose of the header file to represent what's required for
the daemon itself, not its constituent pieces. Rather, split those
definitions out to their respective header files and include them as
necessary.

Finally the header file is renamed to better reflect its purpose.

Change-Id: I48c409f57d96c844589cd865b24f197477dfe87c
Signed-off-by: Andrew Jeffery's avatarAndrew Jeffery <andrew@aj.id.au>
parent 55260cef
......@@ -3,8 +3,9 @@
#include <errno.h>
#include <stdlib.h>
#include "common.h"
#include "dbus.h"
#include "mbox.h"
#include "mboxd.h"
#include "flash.h"
#include "lpc.h"
#include "transport_mbox.h"
......
......@@ -7,7 +7,7 @@
#include "common.h"
#include "dbus.h"
#include "control_dbus.h"
#include "mbox.h"
#include "mboxd.h"
typedef int (*control_action)(struct mbox_context *context);
......
#ifndef DBUS_CONTROL_H
#define DBUS_CONTROL_H
#include "mbox.h"
struct mbox_context;
int control_dbus_init(struct mbox_context *context);
void control_dbus_free(struct mbox_context *context);
......
......@@ -6,7 +6,7 @@
#include "common.h"
#include "dbus.h"
#include "control_dbus.h"
#include "mbox.h"
#include "mboxd.h"
/* Command IDs (Legacy interface) */
#define DBUS_C_PING 0x00
......
......@@ -26,7 +26,7 @@
#include <errno.h>
#include <mtd/mtd-abi.h>
#include "mbox.h"
#include "mboxd.h"
#include "common.h"
#include "flash.h"
......
......@@ -4,13 +4,15 @@
#ifndef FLASH_H
#define FLASH_H
#include <stdint.h>
#define FLASH_DIRTY 0x00
#define FLASH_ERASED 0x01
/* Estimate as to how long (milliseconds) it takes to access a MB from flash */
#define FLASH_ACCESS_MS_PER_MB 8000
#include "mbox.h"
struct mbox_context;
int flash_dev_init(struct mbox_context *context);
void flash_dev_free(struct mbox_context *context);
......
......@@ -24,7 +24,7 @@
#include <unistd.h>
#include <inttypes.h>
#include "mbox.h"
#include "mboxd.h"
#include "common.h"
#include "lpc.h"
#include "flash.h"
......
......@@ -4,6 +4,8 @@
#ifndef LPC_H
#define LPC_H
struct mbox_context;
int lpc_dev_init(struct mbox_context *context);
void lpc_dev_free(struct mbox_context *context);
int lpc_map_flash(struct mbox_context *context);
......
......@@ -3,9 +3,10 @@
#define _GNU_SOURCE
#include "mbox.h"
#include "lpc.h"
struct mbox_context;
/*
* lpc_reset() - Reset the lpc bus mapping
* @context: The mbox context pointer
......
......@@ -27,7 +27,7 @@
#include <systemd/sd-bus.h>
#include "config.h"
#include "mbox.h"
#include "mboxd.h"
#include "common.h"
#include "dbus.h"
#include "control_dbus.h"
......
......@@ -12,6 +12,7 @@
#include "protocol.h"
#include "transport.h"
#include "vpnor/mboxd_pnor_partition_table.h"
#include "windows.h"
enum api_version {
API_VERSION_INVAL = 0,
......@@ -24,29 +25,6 @@ enum api_version {
#define THIS_NAME "Mailbox Daemon"
/* Command Values */
#define MBOX_C_RESET_STATE 0x01
#define MBOX_C_GET_MBOX_INFO 0x02
#define MBOX_C_GET_FLASH_INFO 0x03
#define MBOX_C_READ_WINDOW 0x04
#define MBOX_C_CLOSE_WINDOW 0x05
#define MBOX_C_WRITE_WINDOW 0x06
#define MBOX_C_WRITE_DIRTY 0x07
#define MBOX_C_WRITE_FLUSH 0x08
#define MBOX_C_ACK 0x09
#define MBOX_C_WRITE_ERASE 0x0a
#define NUM_MBOX_CMDS MBOX_C_WRITE_ERASE
/* Response Values */
#define MBOX_R_SUCCESS 0x01
#define MBOX_R_PARAM_ERROR 0x02
#define MBOX_R_WRITE_ERROR 0x03
#define MBOX_R_SYSTEM_ERROR 0x04
#define MBOX_R_TIMEOUT 0x05
#define MBOX_R_BUSY 0x06
#define MBOX_R_WINDOW_ERROR 0x07
#define MBOX_R_SEQ_ERROR 0x08
/* Argument Flags */
#define FLAGS_NONE 0x00
#define FLAGS_SHORT_LIFETIME 0x01
......@@ -64,21 +42,6 @@ enum api_version {
BMC_EVENT_FLASH_CTRL_LOST | \
BMC_EVENT_DAEMON_READY)
/* MBOX Registers */
#define MBOX_HOST_PATH "/dev/aspeed-mbox"
#define MBOX_HOST_TIMEOUT_SEC 1
#define MBOX_ARGS_BYTES 11
#define MBOX_REG_BYTES 16
#define MBOX_HOST_EVENT 14
#define MBOX_BMC_EVENT 15
#define BLOCK_SIZE_SHIFT_V1 12 /* 4K */
/* Window Dirty/Erase bytemap masks */
#define WINDOW_CLEAN 0x00
#define WINDOW_DIRTY 0x01
#define WINDOW_ERASED 0x02
/* Put polled file descriptors first */
#define DBUS_FD 0
#define MBOX_FD 1
......@@ -91,6 +54,7 @@ enum api_version {
#define MAPS_FLASH (1 << 0)
#define MAPS_MEM (1 << 1)
#define STATE_SUSPENDED (1 << 7)
enum mbox_state {
/* Still Initing */
UNINITIALISED = 0,
......@@ -104,37 +68,6 @@ enum mbox_state {
SUSPEND_MAPS_MEM = STATE_SUSPENDED | MAPS_MEM
};
#define FLASH_OFFSET_UNINIT 0xFFFFFFFF
struct window_context {
void *mem; /* Portion of Reserved Memory Region */
uint32_t flash_offset; /* Flash area the window maps (bytes) */
uint32_t size; /* Window Size (bytes) power-of-2 */
uint8_t *dirty_bmap; /* Bytemap of the dirty/erased state */
uint32_t age; /* Used for LRU eviction scheme */
};
struct window_list {
uint32_t num;
uint32_t max_age;
uint32_t default_size;
struct window_context *window;
};
struct mbox_msg {
uint8_t command;
uint8_t seq;
uint8_t args[MBOX_ARGS_BYTES];
uint8_t response;
};
union mbox_regs {
uint8_t raw[MBOX_REG_BYTES];
struct mbox_msg msg;
};
struct mbox_context;
struct mbox_context {
enum api_version version;
const struct protocol_ops *protocol;
......
......@@ -7,10 +7,12 @@
#include "common.h"
#include "flash.h"
#include "mbox.h"
#include "mboxd.h"
#include "lpc.h"
#include "windows.h"
#define BLOCK_SIZE_SHIFT_V1 12 /* 4K */
/*
* protocol_events_set() - Set BMC events
* @context: The mbox context pointer
......
......@@ -4,7 +4,7 @@
#include <errno.h>
#include "mbox.h"
#include "mboxd.h"
#include "protocol.h"
static const struct protocol_ops protocol_ops_v1 = {
......
......@@ -7,7 +7,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include "mbox.h"
#include "mboxd.h"
#include "protocol.h"
#include "transport_mbox.h"
#include "test/mbox.h"
......
......@@ -3,7 +3,7 @@
#include <assert.h>
#include "mbox.h"
#include "mboxd.h"
#include "transport_mbox.h"
#include "test/mbox.h"
......
......@@ -3,7 +3,7 @@
#include <assert.h>
#include "mbox.h"
#include "mboxd.h"
#include "transport_mbox.h"
#include "test/mbox.h"
......
......@@ -2,8 +2,9 @@
// Copyright (C) 2018 IBM Corp.
#include <assert.h>
#include <string.h>
#include "mbox.h"
#include "mboxd.h"
#include "transport_mbox.h"
#include "test/mbox.h"
......
......@@ -2,8 +2,9 @@
// Copyright (C) 2018 IBM Corp.
#include <assert.h>
#include <string.h>
#include "mbox.h"
#include "mboxd.h"
#include "transport_mbox.h"
#include "test/mbox.h"
......
......@@ -3,7 +3,7 @@
#include <assert.h>
#include "mbox.h"
#include "mboxd.h"
#include "transport_mbox.h"
#include "test/mbox.h"
......
......@@ -10,7 +10,7 @@
#include <unistd.h>
#include "common.h"
#include "mbox.h"
#include "mboxd.h"
#include "flash.h"
#include "test/tmpf.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment