blob: 8652d72958d914f4e969e634116e5c41569dd265 [file] [log] [blame]
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +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 Jeffery3c9bb3e2018-02-23 18:16:50 +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 Jeffery3c9bb3e2018-02-23 18:16:50 +103012
Andrew Jeffery261f61a2019-03-14 09:57:28 +103013#include <cassert>
14#include <cstring>
15
Andrew Jefferyf4bc3352019-03-18 12:09:48 +103016#include "vpnor/backend.h"
Andrew Jeffery261f61a2019-03-14 09:57:28 +103017
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +103018const std::string toc[] = {
19 "partition01=HBB,00001000,00002000,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;
27static constexpr auto PNOR_SIZE = (BLOCK_SIZE * 4);
28
29static const uint8_t get_info[] = {0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00};
32
33/* Request access beyond the last (only) partition */
34static const uint8_t create_read_window[] = {0x04, 0x01, 0x03, 0x00, 0x01, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00};
37
38static const uint8_t response[] = {0x04, 0x01, 0xfe, 0xff, 0x01, 0x00, 0x03,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
40
41int main()
42{
43 namespace test = openpower::virtual_pnor::test;
44
William A. Kennington IIId5f1d402018-10-11 13:55:04 -070045 struct mbox_context* ctx;
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +103046 int rc;
47
48 system_set_reserved_size(MEM_SIZE);
49 system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE);
50
Evan Lojewskif1e547c2019-03-14 14:34:33 +103051 ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE);
52 test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE);
Andrew Jeffery3c9bb3e2018-02-23 18:16:50 +103053
54 rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
55 assert(rc == 1);
56
57 rc = mbox_command_dispatch(ctx, create_read_window,
58 sizeof(create_read_window));
59 assert(rc == 1);
60
61 rc = mbox_cmp(ctx, response, sizeof(response));
62 assert(rc == 0);
63
64 return 0;
65}