1 // SPDX-License-Identifier: Apache-2.0
2 // Copyright (C) 2018 IBM Corp.
3
4 #include <assert.h>
5
6 #include "config.h"
7 #include "vpnor/mboxd_pnor_partition_table.h"
8
9 extern "C" {
10 #include "test/mbox.h"
11 #include "test/system.h"
12 }
13
14 #include "vpnor/test/tmpd.hpp"
15
16 static constexpr auto BLOCK_SIZE = 0x1000;
17 static constexpr auto ERASE_SIZE = BLOCK_SIZE;
18 static constexpr auto N_WINDOWS = 1;
19 static constexpr auto WINDOW_SIZE = BLOCK_SIZE;
20 static constexpr auto MEM_SIZE = WINDOW_SIZE;
21 static constexpr auto PNOR_SIZE = 3 * BLOCK_SIZE;
22
23 const std::string toc[] = {
24 "partition01=HBB,00001000,00002000,80,ECC,READWRITE",
25 };
26
27 static const uint8_t get_info[] = {0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00};
30
31 // offset 0x100 and size 6
32 static const uint8_t create_write_window[] = {
33 0x06, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
35
36 static const uint8_t response[] = {0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07};
38
39 namespace test = openpower::virtual_pnor::test;
40
main()41 int main()
42 {
43 struct mbox_context *ctx;
44
45 system_set_reserved_size(MEM_SIZE);
46 system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE);
47
48 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
49
50 test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
51
52 init_vpnor_from_paths(ctx);
53
54 int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
55 assert(rc == MBOX_R_SUCCESS);
56
57 rc = mbox_command_dispatch(ctx, create_write_window,
58 sizeof(create_write_window));
59 assert(rc == MBOX_R_WINDOW_ERROR);
60
61 rc = mbox_cmp(ctx, response, sizeof(response));
62 assert(rc == 0);
63
64 return rc;
65 }
66