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