blob: 5965ebfa35f0014956b8027b08e52e7906d7d448 [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" {
Evan Lojewskif1e547c2019-03-14 14:34:33 +10306#include "backend.h"
Andrew Jeffery261f61a2019-03-14 09:57:28 +10307#include "common.h"
Andrew Jeffery261f61a2019-03-14 09:57:28 +10308#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
Evan Lojewskif1e547c2019-03-14 14:34:33 +103042 ctx->backend.flash_size = 0x2000;
43 test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE);
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103044
45 /* Test */
Andrew Jeffery0297e5b2019-03-14 16:36:27 +103046 rc = backend_write(&ctx->backend, 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
Andrew Jefferyf050fcf2018-02-22 17:35:34 +103051 return 0;
52}