1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright (C) 2018 IBM Corp. 3 4 #include <assert.h> 5 6 #include "config.h" 7 #include "vpnor/mboxd_pnor_partition_table.h" 8 9 extern "C" { 10 #include "test/mbox.h" 11 #include "test/system.h" 12 } 13 14 #include "vpnor/test/tmpd.hpp" 15 16 const std::string toc[] = { 17 "partition01=HBB,00001000,00002000,80,ECC,READWRITE", 18 }; 19 20 static const auto BLOCK_SIZE = 4096; 21 static const auto MEM_SIZE = BLOCK_SIZE * 2; 22 static const auto ERASE_SIZE = BLOCK_SIZE; 23 static const auto N_WINDOWS = 1; 24 static const auto WINDOW_SIZE = BLOCK_SIZE; 25 26 static const uint8_t get_info[] = {0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 0x00, 0x00, 0x00, 0x00}; 29 30 // offset 0x100 and size 6 31 static const uint8_t create_write_window[] = { 32 0x06, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 34 35 static const uint8_t response[] = {0x06, 0x01, 0xfe, 0xff, 0x01, 0x00, 0x01, 36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; 37 38 namespace test = openpower::virtual_pnor::test; 39 40 int main() 41 { 42 struct mbox_context *ctx; 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 49 test::VpnorRoot root(ctx, toc, BLOCK_SIZE); 50 51 init_vpnor_from_paths(ctx); 52 53 int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); 54 assert(rc == 1); 55 56 rc = mbox_command_dispatch(ctx, create_write_window, 57 sizeof(create_write_window)); 58 assert(rc == 1); 59 60 rc = mbox_cmp(ctx, response, sizeof(response)); 61 assert(rc == 0); 62 63 return rc; 64 } 65