summaryrefslogtreecommitdiffstats
path: root/protocol.h
blob: 2c1e725e5216f6d4ee151cb101493f4f9a1b305d (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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright (C) 2018 IBM Corp. */

#ifndef PROTOCOL_H
#define PROTOCOL_H

struct mbox_context;
struct transport_ops;

/*
 * The GET_MBOX_INFO command is special as it can change the interface based on
 * negotiation. As such we need to accommodate all response types
 */
struct protocol_get_info {
	struct {
		uint8_t api_version;
	} req;
	struct {
		uint8_t api_version;
		union {
			struct {
				uint16_t read_window_size;
				uint16_t write_window_size;
			} v1;
			struct {
				uint8_t block_size_shift;
				uint16_t timeout;
			} v2;
		};
	} resp;
};

struct protocol_get_flash_info {
	struct {
		union {
			struct {
				uint32_t flash_size;
				uint32_t erase_size;
			} v1;
			struct {
				uint16_t flash_size;
				uint16_t erase_size;
			} v2;
		};
	} resp;
};

struct protocol_create_window {
	struct {
		uint16_t offset;
		uint16_t size;
		uint8_t id;
		bool ro;
	} req;
	struct {
		uint16_t lpc_address;
		uint16_t size;
		uint16_t offset;
	} resp;
};

struct protocol_mark_dirty {
	struct {
		union {
			struct {
				uint16_t offset;
				uint32_t size;
			} v1;
			struct {
				uint16_t offset;
				uint16_t size;
			} v2;
		};
	} req;
};

struct protocol_erase {
	struct {
		uint16_t offset;
		uint16_t size;
	} req;
};

struct protocol_flush {
	struct {
		uint16_t offset;
		uint32_t size;
	} req;
};

struct protocol_close {
	struct {
		uint8_t flags;
	} req;
};

struct protocol_ack {
	struct {
		uint8_t flags;
	} req;
};

struct protocol_ops {
	int (*reset)(struct mbox_context *context);
	int (*get_info)(struct mbox_context *context,
			struct protocol_get_info *io);
	int (*get_flash_info)(struct mbox_context *context,
			      struct protocol_get_flash_info *io);
	int (*create_window)(struct mbox_context *context,
			     struct protocol_create_window *io);
	int (*mark_dirty)(struct mbox_context *context,
			  struct protocol_mark_dirty *io);
	int (*erase)(struct mbox_context *context, struct protocol_erase *io);
	int (*flush)(struct mbox_context *context, struct protocol_flush *io);
	int (*close)(struct mbox_context *context, struct protocol_close *io);
	int (*ack)(struct mbox_context *context, struct protocol_ack *io);
};

int protocol_init(struct mbox_context *context);
void protocol_free(struct mbox_context *context);

int protocol_negotiate_version(struct mbox_context *context, uint8_t requested);

int protocol_events_put(struct mbox_context *context,
			const struct transport_ops *ops);
int protocol_events_set(struct mbox_context *context, uint8_t bmc_event);
int protocol_events_clear(struct mbox_context *context, uint8_t bmc_event);

/* Protocol v1 */
int protocol_v1_reset(struct mbox_context *context);
int protocol_v1_get_info(struct mbox_context *context,
			 struct protocol_get_info *io);
int protocol_v1_get_flash_info(struct mbox_context *context,
			       struct protocol_get_flash_info *io);
int protocol_v1_create_window(struct mbox_context *context,
			      struct protocol_create_window *io);
int protocol_v1_mark_dirty(struct mbox_context *context,
			   struct protocol_mark_dirty *io);
int protocol_v1_flush(struct mbox_context *context, struct protocol_flush *io);
int protocol_v1_close(struct mbox_context *context, struct protocol_close *io);
int protocol_v1_ack(struct mbox_context *context, struct protocol_ack *io);

/* Protocol v2 */
int protocol_v2_get_info(struct mbox_context *context,
			 struct protocol_get_info *io);
int protocol_v2_get_flash_info(struct mbox_context *context,
			       struct protocol_get_flash_info *io);
int protocol_v2_create_window(struct mbox_context *context,
			      struct protocol_create_window *io);
int protocol_v2_mark_dirty(struct mbox_context *context,
			   struct protocol_mark_dirty *io);
int protocol_v2_erase(struct mbox_context *context,
		      struct protocol_erase *io);
int protocol_v2_flush(struct mbox_context *context, struct protocol_flush *io);
int protocol_v2_close(struct mbox_context *context, struct protocol_close *io);

#endif /* PROTOCOL_H */
OpenPOWER on IntegriCloud