blob: 95e953c7fcb4d27a8e901eb61f0112cf8e08f246 [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"
Andrew Jeffery71eaa732018-08-08 16:44:24 +093013
14extern "C" {
Andrew Jefferyeebc6bd2018-08-08 10:38:19 +093015#include "flash.h"
Andrew Jeffery71eaa732018-08-08 16:44:24 +093016}
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103017
Andrew Jeffery30bcf842018-03-26 12:13:20 +103018#include "vpnor/test/tmpd.hpp"
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103019
20static constexpr auto BLOCK_SIZE = 0x1000;
21
22const std::string toc[] = {
23 "partition01=TEST1,00001000,00002000,80,ECC,READONLY",
24};
25
26int 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 Jeffery742a1f62018-03-02 09:26:03 +103042 init_vpnor_from_paths(ctx);
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103043
44 /* Test */
Andrew Jeffery0293f2f2018-08-08 16:59:45 +093045 rc = flash_write(ctx, 0x1000, src, sizeof(src));
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103046
47 /* Verify we can't write to RO partitions */
48 assert(rc != 0);
49
50 destroy_vpnor(ctx);
51
52 return 0;
53}