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