blob: 53eeb18028a29953d49fcd0784509b4272769e0e [file] [log] [blame]
Andrew Jefferyf050fcf2018-02-22 17:35:34 +10301// 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 Jeffery30bcf842018-03-26 12:13:20 +103015#include "vpnor/test/tmpd.hpp"
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103016
17static constexpr auto BLOCK_SIZE = 0x1000;
18
19const std::string toc[] = {
20 "partition01=TEST1,00001000,00002000,80,ECC,READONLY",
21};
22
23int 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 Jeffery742a1f62018-03-02 09:26:03 +103039 init_vpnor_from_paths(ctx);
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103040
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}