1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright (C) 2018 IBM Corp. 3 4 #include <assert.h> 5 #include <fcntl.h> 6 #include <sys/mman.h> 7 #include <sys/stat.h> 8 #include <sys/types.h> 9 #include <unistd.h> 10 11 #include "common.h" 12 #include "mboxd.h" 13 14 extern "C" { 15 #include "flash.h" 16 } 17 18 #include "vpnor/test/tmpd.hpp" 19 20 static constexpr auto BLOCK_SIZE = 0x1000; 21 22 const std::string toc[] = { 23 "partition01=TEST1,00001000,00002000,80,ECC,READONLY", 24 }; 25 26 int main(void) 27 { 28 namespace fs = std::experimental::filesystem; 29 namespace test = openpower::virtual_pnor::test; 30 31 struct mbox_context _ctx, *ctx = &_ctx; 32 uint8_t src[8] = {0}; 33 int rc; 34 35 /* Setup */ 36 memset(ctx, 0, sizeof(mbox_context)); 37 38 mbox_vlog = &mbox_log_console; 39 verbosity = (verbose)2; 40 41 test::VpnorRoot root(ctx, toc, BLOCK_SIZE); 42 init_vpnor_from_paths(ctx); 43 44 /* Test */ 45 rc = flash_write(ctx, 0x1000, src, sizeof(src)); 46 47 /* Verify we can't write to RO partitions */ 48 assert(rc != 0); 49 50 destroy_vpnor(ctx); 51 52 return 0; 53 } 54