1*4fe996c2SAndrew Jeffery // SPDX-License-Identifier: Apache-2.0
2*4fe996c2SAndrew Jeffery // Copyright (C) 2018 IBM Corp.
3bcacb4e6SAndrew Jeffery
4bcacb4e6SAndrew Jeffery #include <assert.h>
5bcacb4e6SAndrew Jeffery
6bcacb4e6SAndrew Jeffery #include "mbox.h"
7bcacb4e6SAndrew Jeffery #include "mboxd_msg.h"
8bcacb4e6SAndrew Jeffery
9bcacb4e6SAndrew Jeffery #include "test/mbox.h"
10bcacb4e6SAndrew Jeffery #include "test/system.h"
11bcacb4e6SAndrew Jeffery
12bcacb4e6SAndrew Jeffery static const uint8_t command[] = {
13bcacb4e6SAndrew Jeffery 0x02, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14bcacb4e6SAndrew Jeffery 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
15bcacb4e6SAndrew Jeffery };
16bcacb4e6SAndrew Jeffery
17bcacb4e6SAndrew Jeffery static const uint8_t response[] = {
18bcacb4e6SAndrew Jeffery 0x02, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19bcacb4e6SAndrew Jeffery 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
20bcacb4e6SAndrew Jeffery };
21bcacb4e6SAndrew Jeffery
22bcacb4e6SAndrew Jeffery #define MEM_SIZE 3
23bcacb4e6SAndrew Jeffery #define ERASE_SIZE 1
24bcacb4e6SAndrew Jeffery #define N_WINDOWS 1
25bcacb4e6SAndrew Jeffery #define WINDOW_SIZE 1
26bcacb4e6SAndrew Jeffery
27bcacb4e6SAndrew Jeffery #include <stdio.h>
28bcacb4e6SAndrew Jeffery
main(void)29bcacb4e6SAndrew Jeffery int main(void)
30bcacb4e6SAndrew Jeffery {
31bcacb4e6SAndrew Jeffery struct mbox_context *ctx;
32bcacb4e6SAndrew Jeffery int rc;
33bcacb4e6SAndrew Jeffery
34bcacb4e6SAndrew Jeffery system_set_reserved_size(MEM_SIZE);
35bcacb4e6SAndrew Jeffery system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
36bcacb4e6SAndrew Jeffery
37bcacb4e6SAndrew Jeffery ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
38bcacb4e6SAndrew Jeffery
39bcacb4e6SAndrew Jeffery rc = mbox_command_dispatch(ctx, command, sizeof(command));
40bcacb4e6SAndrew Jeffery assert(rc == 2);
41bcacb4e6SAndrew Jeffery
42bcacb4e6SAndrew Jeffery rc = mbox_cmp(ctx, response, sizeof(response));
43bcacb4e6SAndrew Jeffery assert(rc == 0);
44bcacb4e6SAndrew Jeffery
45bcacb4e6SAndrew Jeffery return rc;
46bcacb4e6SAndrew Jeffery }
47