1 // SPDX-License-Identifier: Apache-2.0
2 // Copyright (C) 2018 IBM Corp.
3 
4 #include <assert.h>
5 #include <string.h>
6 
7 #include "config.h"
8 #include "vpnor/mboxd_pnor_partition_table.h"
9 
10 extern "C" {
11 #include "test/mbox.h"
12 #include "test/system.h"
13 }
14 
15 #include "vpnor/test/tmpd.hpp"
16 
17 const std::string toc[] = {
18     "partition01=HBB,00002000,00003000,80,ECC,READONLY",
19 };
20 
21 static constexpr auto BLOCK_SIZE = 4096;
22 static constexpr auto MEM_SIZE = BLOCK_SIZE * 2;
23 static constexpr auto ERASE_SIZE = BLOCK_SIZE;
24 static constexpr auto N_WINDOWS = 1;
25 static constexpr auto WINDOW_SIZE = BLOCK_SIZE;
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 /* Request access below the specified partition */
32 static const uint8_t create_read_window[] = {0x04, 0x01, 0x01, 0x00, 0x01, 0x00,
33                                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34                                              0x00, 0x00, 0x00, 0x00};
35 
36 int main()
37 {
38     namespace test = openpower::virtual_pnor::test;
39 
40     struct mbox_context *ctx;
41     int rc;
42 
43     system_set_reserved_size(MEM_SIZE);
44     system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
45 
46     ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
47     test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
48     init_vpnor_from_paths(ctx);
49 
50     rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
51     assert(rc == 1);
52 
53     rc = mbox_command_dispatch(ctx, create_read_window,
54                                sizeof(create_read_window));
55     return !(rc == 1);
56 }
57