blob: e09ac6922cf4ce30d22de20ff4fb4406a4bec1c8 [file] [log] [blame]
Andrew Jeffery7c5a1092018-03-26 11:16:05 +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
16const std::string toc[] = {
17 "partition01=HBB,00001000,00002000,80,ECC,READONLY",
18};
19
20static const auto BLOCK_SIZE = 4096;
21static const auto MEM_SIZE = BLOCK_SIZE * 2;
22static const auto ERASE_SIZE = BLOCK_SIZE;
23static const auto N_WINDOWS = 1;
24static const auto WINDOW_SIZE = BLOCK_SIZE;
25
26static const uint8_t get_info[] = {0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00};
29
30// offset 0x100 and size 6
31static const uint8_t create_write_window[] = {
32 0x06, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
34
35static const uint8_t response[] = {0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07};
37
38namespace test = openpower::virtual_pnor::test;
39
40int main()
41{
42 struct mbox_context *ctx;
43
44 system_set_reserved_size(MEM_SIZE);
45 system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
46
47 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
48
49 test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
50
51 init_vpnor_from_paths(ctx);
52
53 int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
54 assert(rc == 1);
55
56 rc = mbox_command_dispatch(ctx, create_write_window,
57 sizeof(create_write_window));
58 assert(rc == 7);
59
60 rc = mbox_cmp(ctx, response, sizeof(response));
61 assert(rc == 0);
62
63 return rc;
64}