Andrew Jeffery | 730e3b0 | 2018-02-23 18:09:22 +1030 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright (C) 2018 IBM Corp. |
| 3 | |
William A. Kennington III | d5f1d40 | 2018-10-11 13:55:04 -0700 | [diff] [blame] | 4 | #include "config.h" |
| 5 | |
Andrew Jeffery | 730e3b0 | 2018-02-23 18:09:22 +1030 | [diff] [blame] | 6 | extern "C" { |
| 7 | #include "test/mbox.h" |
| 8 | #include "test/system.h" |
| 9 | } |
| 10 | |
Andrew Jeffery | 30bcf84 | 2018-03-26 12:13:20 +1030 | [diff] [blame] | 11 | #include "vpnor/test/tmpd.hpp" |
Andrew Jeffery | 730e3b0 | 2018-02-23 18:09:22 +1030 | [diff] [blame] | 12 | |
Andrew Jeffery | 261f61a | 2019-03-14 09:57:28 +1030 | [diff] [blame] | 13 | #include <cassert> |
| 14 | #include <cstring> |
| 15 | |
Andrew Jeffery | f4bc335 | 2019-03-18 12:09:48 +1030 | [diff] [blame^] | 16 | #include "vpnor/backend.h" |
Andrew Jeffery | 261f61a | 2019-03-14 09:57:28 +1030 | [diff] [blame] | 17 | |
Andrew Jeffery | 730e3b0 | 2018-02-23 18:09:22 +1030 | [diff] [blame] | 18 | const std::string toc[] = { |
| 19 | "partition01=HBB,00002000,00003000,80,ECC,READONLY", |
| 20 | }; |
| 21 | |
| 22 | static constexpr auto BLOCK_SIZE = 4096; |
| 23 | static constexpr auto MEM_SIZE = BLOCK_SIZE * 2; |
| 24 | static constexpr auto ERASE_SIZE = BLOCK_SIZE; |
| 25 | static constexpr auto N_WINDOWS = 1; |
| 26 | static constexpr auto WINDOW_SIZE = BLOCK_SIZE; |
| 27 | |
| 28 | static 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 */ |
| 33 | static 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 | |
| 37 | int main() |
| 38 | { |
| 39 | namespace test = openpower::virtual_pnor::test; |
| 40 | |
William A. Kennington III | d5f1d40 | 2018-10-11 13:55:04 -0700 | [diff] [blame] | 41 | struct mbox_context* ctx; |
Andrew Jeffery | 730e3b0 | 2018-02-23 18:09:22 +1030 | [diff] [blame] | 42 | int rc; |
| 43 | |
| 44 | system_set_reserved_size(MEM_SIZE); |
| 45 | system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE); |
| 46 | |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 47 | ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE); |
| 48 | test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE); |
Andrew Jeffery | 730e3b0 | 2018-02-23 18:09:22 +1030 | [diff] [blame] | 49 | |
| 50 | rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); |
| 51 | assert(rc == 1); |
| 52 | |
| 53 | rc = mbox_command_dispatch(ctx, create_read_window, |
| 54 | sizeof(create_read_window)); |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 55 | |
Andrew Jeffery | 730e3b0 | 2018-02-23 18:09:22 +1030 | [diff] [blame] | 56 | return !(rc == 1); |
| 57 | } |