Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright (C) 2018 IBM Corp. |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 3 | #include "config.h" |
William A. Kennington III | d5f1d40 | 2018-10-11 13:55:04 -0700 | [diff] [blame] | 4 | |
Andrew Jeffery | 53c21aa | 2018-03-26 11:56:16 +1030 | [diff] [blame] | 5 | #include "vpnor/pnor_partition_table.hpp" |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Common/error.hpp" |
| 7 | |
Andrew Jeffery | 261f61a | 2019-03-14 09:57:28 +1030 | [diff] [blame] | 8 | #include <cassert> |
| 9 | #include <cstring> |
William A. Kennington III | d5f1d40 | 2018-10-11 13:55:04 -0700 | [diff] [blame] | 10 | |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 11 | extern "C" { |
| 12 | #include "test/mbox.h" |
| 13 | #include "test/system.h" |
| 14 | } |
| 15 | |
Andrew Jeffery | 30bcf84 | 2018-03-26 12:13:20 +1030 | [diff] [blame] | 16 | #include "vpnor/test/tmpd.hpp" |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 17 | |
| 18 | static constexpr auto BLOCK_SIZE = 0x1000; |
| 19 | static constexpr auto ERASE_SIZE = BLOCK_SIZE; |
| 20 | static constexpr auto PNOR_SIZE = 64 * 1024 * 1024; |
| 21 | static constexpr auto MEM_SIZE = 32 * 1024 * 1024; |
| 22 | static constexpr auto N_WINDOWS = 1; |
| 23 | static constexpr auto WINDOW_SIZE = BLOCK_SIZE * 2; |
| 24 | |
| 25 | const std::string toc[] = { |
| 26 | "partition01=ONE,00001000,00002000,80,", |
| 27 | }; |
| 28 | |
| 29 | int main() |
| 30 | { |
| 31 | namespace err = sdbusplus::xyz::openbmc_project::Common::Error; |
| 32 | namespace test = openpower::virtual_pnor::test; |
| 33 | namespace vpnor = openpower::virtual_pnor; |
| 34 | |
| 35 | struct mbox_context* ctx; |
| 36 | |
| 37 | system_set_reserved_size(MEM_SIZE); |
| 38 | system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE); |
| 39 | |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 40 | ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE); |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 41 | |
Evan Lojewski | f1e547c | 2019-03-14 14:34:33 +1030 | [diff] [blame] | 42 | test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE); |
| 43 | vpnor::partition::Table table(&ctx->backend); |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 44 | |
| 45 | try |
| 46 | { |
| 47 | table.partition("TWO"); |
| 48 | } |
Andrew Jeffery | ae1edb9 | 2018-02-28 23:16:48 +1030 | [diff] [blame] | 49 | catch (vpnor::UnknownPartition& e) |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 50 | { |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | assert(false); |
| 55 | } |