xref: /openbmc/phosphor-mboxd/test/mark_read_dirty.c (revision 4fe996c2e7f157d521b5c8732e8b80e03bd25ff0)
1*4fe996c2SAndrew Jeffery // SPDX-License-Identifier: Apache-2.0
2*4fe996c2SAndrew Jeffery // Copyright (C) 2018 IBM Corp.
3ea469b06SAndrew Jeffery 
4ea469b06SAndrew Jeffery #include <assert.h>
5ea469b06SAndrew Jeffery 
6ea469b06SAndrew Jeffery #include "mbox.h"
7ea469b06SAndrew Jeffery #include "mboxd_msg.h"
8ea469b06SAndrew Jeffery 
9ea469b06SAndrew Jeffery #include "test/mbox.h"
10ea469b06SAndrew Jeffery #include "test/system.h"
11ea469b06SAndrew Jeffery 
12ea469b06SAndrew Jeffery static const uint8_t get_info[] = {
13ea469b06SAndrew Jeffery 	0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
14ea469b06SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
15ea469b06SAndrew Jeffery };
16ea469b06SAndrew Jeffery 
17ea469b06SAndrew Jeffery static const uint8_t create_read_window[] = {
18ea469b06SAndrew Jeffery 	0x04, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
19ea469b06SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20ea469b06SAndrew Jeffery };
21ea469b06SAndrew Jeffery 
22ea469b06SAndrew Jeffery static const uint8_t mark_write_dirty[] = {
23ea469b06SAndrew Jeffery 	0x07, 0x02, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
24ea469b06SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
25ea469b06SAndrew Jeffery };
26ea469b06SAndrew Jeffery 
27ea469b06SAndrew Jeffery static const uint8_t response[] = {
28ea469b06SAndrew Jeffery 	0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29ea469b06SAndrew Jeffery 	0x00, 0x00, 0x00, 0x00, 0x00, 0x07
30ea469b06SAndrew Jeffery };
31ea469b06SAndrew Jeffery 
32ea469b06SAndrew Jeffery uint8_t data[3] = { 0xaa, 0x55, 0xaa };
33ea469b06SAndrew Jeffery 
34ea469b06SAndrew Jeffery #define MEM_SIZE	sizeof(data)
35ea469b06SAndrew Jeffery #define ERASE_SIZE	1
36ea469b06SAndrew Jeffery #define N_WINDOWS	1
37ea469b06SAndrew Jeffery #define WINDOW_SIZE	sizeof(data)
38ea469b06SAndrew Jeffery 
main(void)39ea469b06SAndrew Jeffery int main(void)
40ea469b06SAndrew Jeffery {
41ea469b06SAndrew Jeffery 	struct mbox_context *ctx;
42ea469b06SAndrew Jeffery 	int rc;
43ea469b06SAndrew Jeffery 
44ea469b06SAndrew Jeffery 	system_set_reserved_size(MEM_SIZE);
45ea469b06SAndrew Jeffery 	system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
46ea469b06SAndrew Jeffery 
47ea469b06SAndrew Jeffery 	ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
48ea469b06SAndrew Jeffery 
49ea469b06SAndrew Jeffery 	rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
50ea469b06SAndrew Jeffery 	assert(rc == 1);
51ea469b06SAndrew Jeffery 
52ea469b06SAndrew Jeffery 	rc = mbox_command_dispatch(ctx, create_read_window,
53ea469b06SAndrew Jeffery 			sizeof(create_read_window));
54ea469b06SAndrew Jeffery 	assert(rc == 1);
55ea469b06SAndrew Jeffery 
56ea469b06SAndrew Jeffery 	rc = mbox_command_dispatch(ctx, mark_write_dirty,
57ea469b06SAndrew Jeffery 			sizeof(mark_write_dirty));
58ea469b06SAndrew Jeffery 	assert(rc == 7);
59ea469b06SAndrew Jeffery 
60ea469b06SAndrew Jeffery 	rc = mbox_cmp(ctx, response, sizeof(response));
61ea469b06SAndrew Jeffery 	assert(rc == 0);
62ea469b06SAndrew Jeffery 
63ea469b06SAndrew Jeffery 	return rc;
64ea469b06SAndrew Jeffery };
65