blob: b493fad694b9c8941b584b1dd8095914a8c980df [file] [log] [blame]
Andrew Jeffery8b910232018-03-29 10:41:41 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
3
4#include <assert.h>
5
6#include "config.h"
7#include "mboxd_pnor_partition_table.h"
8
9extern "C" {
10#include "test/mbox.h"
11#include "test/system.h"
12}
13
14#include "test/vpnor/tmpd.hpp"
15
16static constexpr auto BLOCK_SIZE = 0x1000;
17static constexpr auto ERASE_SIZE = BLOCK_SIZE;
18static constexpr auto N_WINDOWS = 1;
19static constexpr auto WINDOW_SIZE = BLOCK_SIZE;
20static constexpr auto MEM_SIZE = WINDOW_SIZE;
21static constexpr auto PNOR_SIZE = 3 * BLOCK_SIZE;
22
23const std::string toc[] = {
24 "partition01=HBB,00001000,00002000,80,ECC,READWRITE",
25};
26
27static 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
32static 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
36static const uint8_t response[] = {0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07};
38
39namespace test = openpower::virtual_pnor::test;
40
41int 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}