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" { |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 6 | #include "backend.h" |
Andrew Jeffery | 261f61a | 2019-03-14 09:57:28 +1030 | [diff] [blame] | 7 | #include "common.h" |
Andrew Jeffery | 261f61a | 2019-03-14 09:57:28 +1030 | [diff] [blame] | 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 | |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 42 | ctx->backend.flash_size = 0x2000; |
| 43 | test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE); |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 44 | |
| 45 | /* Test */ |
Andrew Jeffery | 0297e5b | 2019-03-14 16:36:27 +1030 | [diff] [blame] | 46 | rc = backend_write(&ctx->backend, 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 | |
Andrew Jeffery | f050fcf | 2018-02-22 17:35:34 +1030 | [diff] [blame] | 51 | return 0; |
| 52 | } |