blob: e5671b1583a626f74f8bedb0e6cb9a9e7d366720 [file] [log] [blame]
Andrew Jefferyf050fcf2018-02-22 17:35:34 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
Andrew Jeffery261f61a2019-03-14 09:57:28 +10303#include "config.h"
Andrew Jefferyf050fcf2018-02-22 17:35:34 +10304
Andrew Jeffery261f61a2019-03-14 09:57:28 +10305extern "C" {
6#include "common.h"
7#include "flash.h"
8#include "mboxd.h"
9}
10
11#include "vpnor/test/tmpd.hpp"
12
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103013#include <fcntl.h>
14#include <sys/mman.h>
15#include <sys/stat.h>
16#include <sys/types.h>
17#include <unistd.h>
18
Andrew Jeffery261f61a2019-03-14 09:57:28 +103019#include <cassert>
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103020
21static constexpr auto BLOCK_SIZE = 0x1000;
22
23const std::string toc[] = {
24 "partition01=TEST1,00001000,00002000,80,ECC,READONLY",
25};
26
27int 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 Jeffery742a1f62018-03-02 09:26:03 +103043 init_vpnor_from_paths(ctx);
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103044
45 /* Test */
Andrew Jeffery0293f2f2018-08-08 16:59:45 +093046 rc = flash_write(ctx, 0x1000, src, sizeof(src));
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103047
48 /* Verify we can't write to RO partitions */
49 assert(rc != 0);
50
51 destroy_vpnor(ctx);
52
53 return 0;
54}