xref: /openbmc/phosphor-mboxd/test/mark_write_dirty_v2.c (revision 4fe996c2e7f157d521b5c8732e8b80e03bd25ff0)
1*4fe996c2SAndrew Jeffery // SPDX-License-Identifier: Apache-2.0
2*4fe996c2SAndrew Jeffery // Copyright (C) 2018 IBM Corp.
34397af94SAndrew Jeffery 
44397af94SAndrew Jeffery #include <assert.h>
54397af94SAndrew Jeffery 
64397af94SAndrew Jeffery #include "mbox.h"
74397af94SAndrew Jeffery #include "mboxd_msg.h"
84397af94SAndrew Jeffery 
94397af94SAndrew Jeffery #include "test/mbox.h"
104397af94SAndrew Jeffery #include "test/system.h"
114397af94SAndrew Jeffery 
124397af94SAndrew Jeffery static const uint8_t get_info[] = {
134397af94SAndrew Jeffery 	0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
144397af94SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
154397af94SAndrew Jeffery };
164397af94SAndrew Jeffery 
174397af94SAndrew Jeffery static const uint8_t create_write_window[] = {
184397af94SAndrew Jeffery 	0x06, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
194397af94SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
204397af94SAndrew Jeffery };
214397af94SAndrew Jeffery 
224397af94SAndrew Jeffery static const uint8_t mark_write_dirty[] = {
234397af94SAndrew Jeffery 	0x07, 0x02, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
244397af94SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
254397af94SAndrew Jeffery };
264397af94SAndrew Jeffery 
274397af94SAndrew Jeffery static const uint8_t response[] = {
284397af94SAndrew Jeffery 	0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294397af94SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x01
304397af94SAndrew Jeffery };
314397af94SAndrew Jeffery 
324397af94SAndrew Jeffery uint8_t data[3] = { 0xaa, 0x55, 0xaa };
334397af94SAndrew Jeffery 
344397af94SAndrew Jeffery #define MEM_SIZE	sizeof(data)
354397af94SAndrew Jeffery #define ERASE_SIZE	1
364397af94SAndrew Jeffery #define N_WINDOWS	1
374397af94SAndrew Jeffery #define WINDOW_SIZE	sizeof(data)
384397af94SAndrew Jeffery 
main(void)394397af94SAndrew Jeffery int main(void)
404397af94SAndrew Jeffery {
414397af94SAndrew Jeffery 	struct mbox_context *ctx;
424397af94SAndrew Jeffery 	int rc;
434397af94SAndrew Jeffery 
444397af94SAndrew Jeffery 	system_set_reserved_size(MEM_SIZE);
454397af94SAndrew Jeffery 	system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
464397af94SAndrew Jeffery 
474397af94SAndrew Jeffery 	ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
484397af94SAndrew Jeffery 	rc = mbox_set_mtd_data(ctx, data, sizeof(data));
494397af94SAndrew Jeffery 	assert(rc == 0);
504397af94SAndrew Jeffery 
514397af94SAndrew Jeffery 	rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
524397af94SAndrew Jeffery 	assert(rc == 1);
534397af94SAndrew Jeffery 
544397af94SAndrew Jeffery 	rc = mbox_command_dispatch(ctx, create_write_window,
554397af94SAndrew Jeffery 			sizeof(create_write_window));
564397af94SAndrew Jeffery 	assert(rc == 1);
574397af94SAndrew Jeffery 
584397af94SAndrew Jeffery 	rc = mbox_command_dispatch(ctx, mark_write_dirty,
594397af94SAndrew Jeffery 			sizeof(mark_write_dirty));
604397af94SAndrew Jeffery 	assert(rc == 1);
614397af94SAndrew Jeffery 
624397af94SAndrew Jeffery 	rc = mbox_cmp(ctx, response, sizeof(response));
634397af94SAndrew Jeffery 	assert(rc == 0);
644397af94SAndrew Jeffery 
654397af94SAndrew Jeffery 	return rc;
664397af94SAndrew Jeffery };
67