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" |
| 12 | #include "mbox.h" |
| 13 | #include "mboxd_flash.h" |
| 14 | |
Andrew Jeffery | 30bcf84 | 2018-03-26 12:13:20 +1030 | [diff] [blame^] | 15 | #include "vpnor/test/tmpd.hpp" |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 16 | |
| 17 | static constexpr auto BLOCK_SIZE = 0x1000; |
| 18 | |
| 19 | const std::string toc[] = { |
| 20 | "partition01=TEST1,00001000,00002000,80,ECC,READONLY", |
| 21 | }; |
| 22 | |
| 23 | int main(void) |
| 24 | { |
| 25 | namespace fs = std::experimental::filesystem; |
| 26 | namespace test = openpower::virtual_pnor::test; |
| 27 | |
| 28 | struct mbox_context _ctx, *ctx = &_ctx; |
| 29 | uint8_t src[8] = {0}; |
| 30 | int rc; |
| 31 | |
| 32 | /* Setup */ |
| 33 | memset(ctx, 0, sizeof(mbox_context)); |
| 34 | |
| 35 | mbox_vlog = &mbox_log_console; |
| 36 | verbosity = (verbose)2; |
| 37 | |
| 38 | test::VpnorRoot root(ctx, toc, BLOCK_SIZE); |
Andrew Jeffery | 742a1f6 | 2018-03-02 09:26:03 +1030 | [diff] [blame] | 39 | init_vpnor_from_paths(ctx); |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 40 | |
| 41 | /* Test */ |
| 42 | rc = write_flash(ctx, 0x1000, src, sizeof(src)); |
| 43 | |
| 44 | /* Verify we can't write to RO partitions */ |
| 45 | assert(rc != 0); |
| 46 | |
| 47 | destroy_vpnor(ctx); |
| 48 | |
| 49 | return 0; |
| 50 | } |