blob: e6747c8aab5ff8e2a38a504e8d8d6d6a404d752e [file] [log] [blame]
Andrew Jeffery730e3b02018-02-23 18:09:22 +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 Jeffery730e3b02018-02-23 18:09:22 +10306#include <assert.h>
7#include <string.h>
8
Andrew Jeffery53c21aa2018-03-26 11:56:16 +10309#include "vpnor/mboxd_pnor_partition_table.h"
Andrew Jeffery730e3b02018-02-23 18:09:22 +103010
11extern "C" {
12#include "test/mbox.h"
13#include "test/system.h"
14}
15
Andrew Jeffery30bcf842018-03-26 12:13:20 +103016#include "vpnor/test/tmpd.hpp"
Andrew Jeffery730e3b02018-02-23 18:09:22 +103017
18const std::string toc[] = {
19 "partition01=HBB,00002000,00003000,80,ECC,READONLY",
20};
21
22static constexpr auto BLOCK_SIZE = 4096;
23static constexpr auto MEM_SIZE = BLOCK_SIZE * 2;
24static constexpr auto ERASE_SIZE = BLOCK_SIZE;
25static constexpr auto N_WINDOWS = 1;
26static constexpr auto WINDOW_SIZE = BLOCK_SIZE;
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 below the specified partition */
33static const uint8_t create_read_window[] = {0x04, 0x01, 0x01, 0x00, 0x01, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00};
36
37int main()
38{
39 namespace test = openpower::virtual_pnor::test;
40
William A. Kennington IIId5f1d402018-10-11 13:55:04 -070041 struct mbox_context* ctx;
Andrew Jeffery730e3b02018-02-23 18:09:22 +103042 int rc;
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 test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
Andrew Jeffery742a1f62018-03-02 09:26:03 +103049 init_vpnor_from_paths(ctx);
Andrew Jeffery730e3b02018-02-23 18:09:22 +103050
51 rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
52 assert(rc == 1);
53
54 rc = mbox_command_dispatch(ctx, create_read_window,
55 sizeof(create_read_window));
56 return !(rc == 1);
57}