blob: 445b0a17c1760781bd74801fcf8922a9ff68d79e [file] [log] [blame]
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +10301// 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"
Andrew Jeffery53c21aa2018-03-26 11:56:16 +10308#include "vpnor/mboxd_pnor_partition_table.h"
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +10309
10extern "C" {
11#include "test/mbox.h"
12#include "test/system.h"
13}
14
Andrew Jeffery30bcf842018-03-26 12:13:20 +103015#include "vpnor/test/tmpd.hpp"
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +103016
17const std::string toc[] = {
18 "partition01=HBB,00001000,00002000,80,ECC,READONLY",
19};
20
21static constexpr auto BLOCK_SIZE = 4096;
22static constexpr auto MEM_SIZE = (BLOCK_SIZE * 2);
23static constexpr auto ERASE_SIZE = BLOCK_SIZE;
24static constexpr auto N_WINDOWS = 1;
25static constexpr auto WINDOW_SIZE = BLOCK_SIZE;
26static constexpr auto PNOR_SIZE = (BLOCK_SIZE * 4);
27
28static const uint8_t get_info[] = {0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00};
31
32/* Request access beyond the last (only) partition */
33static const uint8_t create_read_window[] = {0x04, 0x01, 0x03, 0x00, 0x01, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00};
36
37static const uint8_t response[] = {0x04, 0x01, 0xfe, 0xff, 0x01, 0x00, 0x03,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
39
40int main()
41{
42 namespace test = openpower::virtual_pnor::test;
43
44 struct mbox_context *ctx;
45 int rc;
46
47 system_set_reserved_size(MEM_SIZE);
48 system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE);
49
50 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
51 test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
Andrew Jeffery742a1f62018-03-02 09:26:03 +103052 init_vpnor_from_paths(ctx);
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +103053
54 rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
55 assert(rc == 1);
56
57 rc = mbox_command_dispatch(ctx, create_read_window,
58 sizeof(create_read_window));
59 assert(rc == 1);
60
61 rc = mbox_cmp(ctx, response, sizeof(response));
62 assert(rc == 0);
63
64 return 0;
65}