1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright (C) 2018 IBM Corp. 3 4 #include "config.h" 5 6 #include <assert.h> 7 #include <string.h> 8 9 #include "vpnor/mboxd_pnor_partition_table.h" 10 11 extern "C" { 12 #include "test/mbox.h" 13 #include "test/system.h" 14 } 15 16 #include "vpnor/test/tmpd.hpp" 17 18 const std::string toc[] = { 19 "partition01=HBB,00001000,00002000,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 static constexpr auto PNOR_SIZE = (BLOCK_SIZE * 4); 28 29 static 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 */ 34 static 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 38 static const uint8_t response[] = {0x04, 0x01, 0xfe, 0xff, 0x01, 0x00, 0x03, 39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; 40 41 int main() 42 { 43 namespace test = openpower::virtual_pnor::test; 44 45 struct mbox_context* ctx; 46 int rc; 47 48 system_set_reserved_size(MEM_SIZE); 49 system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE); 50 51 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); 52 test::VpnorRoot root(ctx, toc, BLOCK_SIZE); 53 init_vpnor_from_paths(ctx); 54 55 rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); 56 assert(rc == 1); 57 58 rc = mbox_command_dispatch(ctx, create_read_window, 59 sizeof(create_read_window)); 60 assert(rc == 1); 61 62 rc = mbox_cmp(ctx, response, sizeof(response)); 63 assert(rc == 0); 64 65 return 0; 66 } 67