blob: 76694fcc84d8e117745ff4299b9dde4d55d0870b [file] [log] [blame]
Andrew Jeffery8b910232018-03-29 10:41:41 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
3
William A. Kennington IIId5f1d402018-10-11 13:55:04 -07004#include "config.h"
5
Andrew Jeffery8b910232018-03-29 10:41:41 +10306extern "C" {
7#include "test/mbox.h"
8#include "test/system.h"
9}
10
Andrew Jeffery30bcf842018-03-26 12:13:20 +103011#include "vpnor/test/tmpd.hpp"
Andrew Jeffery8b910232018-03-29 10:41:41 +103012
Andrew Jeffery261f61a2019-03-14 09:57:28 +103013#include <cassert>
14
15#include "vpnor/mboxd_pnor_partition_table.h"
16
Andrew Jeffery8b910232018-03-29 10:41:41 +103017static constexpr auto BLOCK_SIZE = 0x1000;
18static constexpr auto ERASE_SIZE = BLOCK_SIZE;
19static constexpr auto N_WINDOWS = 1;
20static constexpr auto WINDOW_SIZE = BLOCK_SIZE;
21static constexpr auto MEM_SIZE = WINDOW_SIZE;
22static constexpr auto PNOR_SIZE = 3 * BLOCK_SIZE;
23
24const std::string toc[] = {
25 "partition01=HBB,00001000,00002000,80,ECC,READWRITE",
26};
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// offset 0x100 and size 6
33static const uint8_t create_write_window[] = {
34 0x06, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
36
37static const uint8_t response[] = {0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07};
39
40namespace test = openpower::virtual_pnor::test;
41
42int main()
43{
William A. Kennington IIId5f1d402018-10-11 13:55:04 -070044 struct mbox_context* ctx;
Andrew Jeffery8b910232018-03-29 10:41:41 +103045
46 system_set_reserved_size(MEM_SIZE);
47 system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE);
48
49 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
50
51 test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
52
53 init_vpnor_from_paths(ctx);
54
55 int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
56 assert(rc == MBOX_R_SUCCESS);
57
58 rc = mbox_command_dispatch(ctx, create_write_window,
59 sizeof(create_write_window));
60 assert(rc == MBOX_R_WINDOW_ERROR);
61
62 rc = mbox_cmp(ctx, response, sizeof(response));
63 assert(rc == 0);
64
65 return rc;
66}