blob: fa53003fb1ae6165e1b92e31eabe3b05c7498cc2 [file] [log] [blame]
Andrew Jeffery7c5a1092018-03-26 11:16:05 +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 Jeffery7c5a1092018-03-26 11:16:05 +10306#include <assert.h>
7
Andrew Jeffery53c21aa2018-03-26 11:56:16 +10308#include "vpnor/mboxd_pnor_partition_table.h"
Andrew Jeffery7c5a1092018-03-26 11:16:05 +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 Jeffery7c5a1092018-03-26 11:16:05 +103016
17const std::string toc[] = {
18 "partition01=HBB,00001000,00002000,80,ECC,READONLY",
19};
20
21static const auto BLOCK_SIZE = 4096;
22static const auto MEM_SIZE = BLOCK_SIZE * 2;
23static const auto ERASE_SIZE = BLOCK_SIZE;
24static const auto N_WINDOWS = 1;
25static const auto WINDOW_SIZE = BLOCK_SIZE;
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, 0x01, 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{
William A. Kennington IIId5f1d402018-10-11 13:55:04 -070043 struct mbox_context* ctx;
Andrew Jeffery7c5a1092018-03-26 11:16:05 +103044
45 system_set_reserved_size(MEM_SIZE);
46 system_set_mtd_sizes(MEM_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 == 1);
56
57 rc = mbox_command_dispatch(ctx, create_write_window,
58 sizeof(create_write_window));
59 assert(rc == 7);
60
61 rc = mbox_cmp(ctx, response, sizeof(response));
62 assert(rc == 0);
63
64 return rc;
65}