Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 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" |
Andrew Jeffery | 26558db | 2018-08-10 00:22:38 +0930 | [diff] [blame] | 12 | #include "mboxd.h" |
Andrew Jeffery | 71eaa73 | 2018-08-08 16:44:24 +0930 | [diff] [blame] | 13 | |
| 14 | extern "C" { |
Andrew Jeffery | eebc6bd | 2018-08-08 10:38:19 +0930 | [diff] [blame] | 15 | #include "flash.h" |
Andrew Jeffery | 71eaa73 | 2018-08-08 16:44:24 +0930 | [diff] [blame] | 16 | } |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 17 | |
Andrew Jeffery | 30bcf84 | 2018-03-26 12:13:20 +1030 | [diff] [blame] | 18 | #include "vpnor/test/tmpd.hpp" |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 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); |
Andrew Jeffery | 742a1f6 | 2018-03-02 09:26:03 +1030 | [diff] [blame] | 42 | init_vpnor_from_paths(ctx); |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 43 | |
| 44 | /* Test */ |
Andrew Jeffery | 0293f2f | 2018-08-08 16:59:45 +0930 | [diff] [blame] | 45 | rc = flash_write(ctx, 0x1000, src, sizeof(src)); |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 46 | |
| 47 | /* Verify we can't write to RO partitions */ |
| 48 | assert(rc != 0); |
| 49 | |
| 50 | destroy_vpnor(ctx); |
| 51 | |
| 52 | return 0; |
| 53 | } |