Andrew Jeffery | 8b91023 | 2018-03-29 10:41:41 +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 | 8b91023 | 2018-03-29 10:41:41 +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 | 8b91023 | 2018-03-29 10:41:41 +1030 | [diff] [blame] | 12 | |
Andrew Jeffery | 261f61a | 2019-03-14 09:57:28 +1030 | [diff] [blame] | 13 | #include <cassert> |
| 14 | |
| 15 | #include "vpnor/mboxd_pnor_partition_table.h" |
| 16 | |
Andrew Jeffery | 8b91023 | 2018-03-29 10:41:41 +1030 | [diff] [blame] | 17 | static constexpr auto BLOCK_SIZE = 0x1000; |
| 18 | static constexpr auto ERASE_SIZE = BLOCK_SIZE; |
| 19 | static constexpr auto N_WINDOWS = 1; |
| 20 | static constexpr auto WINDOW_SIZE = BLOCK_SIZE; |
| 21 | static constexpr auto MEM_SIZE = WINDOW_SIZE; |
| 22 | static constexpr auto PNOR_SIZE = 3 * BLOCK_SIZE; |
| 23 | |
| 24 | const std::string toc[] = { |
| 25 | "partition01=HBB,00001000,00002000,80,ECC,READWRITE", |
| 26 | }; |
| 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 | // offset 0x100 and size 6 |
| 33 | static const uint8_t create_write_window[] = { |
| 34 | 0x06, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 36 | |
| 37 | static const uint8_t response[] = {0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07}; |
| 39 | |
| 40 | namespace test = openpower::virtual_pnor::test; |
| 41 | |
| 42 | int main() |
| 43 | { |
William A. Kennington III | d5f1d40 | 2018-10-11 13:55:04 -0700 | [diff] [blame] | 44 | struct mbox_context* ctx; |
Andrew Jeffery | 8b91023 | 2018-03-29 10:41:41 +1030 | [diff] [blame] | 45 | |
| 46 | system_set_reserved_size(MEM_SIZE); |
| 47 | system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE); |
| 48 | |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 49 | ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE); |
Andrew Jeffery | 8b91023 | 2018-03-29 10:41:41 +1030 | [diff] [blame] | 50 | |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 51 | test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE); |
Andrew Jeffery | 8b91023 | 2018-03-29 10:41:41 +1030 | [diff] [blame] | 52 | |
| 53 | int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); |
| 54 | assert(rc == MBOX_R_SUCCESS); |
| 55 | |
| 56 | rc = mbox_command_dispatch(ctx, create_write_window, |
| 57 | sizeof(create_write_window)); |
| 58 | assert(rc == MBOX_R_WINDOW_ERROR); |
| 59 | |
| 60 | rc = mbox_cmp(ctx, response, sizeof(response)); |
| 61 | assert(rc == 0); |
| 62 | |
| 63 | return rc; |
| 64 | } |