Andrew Jeffery | a138f56 | 2018-02-27 16:58:02 +1030 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright (C) 2018 IBM Corp. |
William A. Kennington III | d5f1d40 | 2018-10-11 13:55:04 -0700 | [diff] [blame^] | 3 | #include "config.h" |
| 4 | |
| 5 | #include "vpnor/pnor_partition_table.hpp" |
| 6 | |
Andrew Jeffery | a138f56 | 2018-02-27 16:58:02 +1030 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | #include <string.h> |
| 9 | |
Andrew Jeffery | a138f56 | 2018-02-27 16:58:02 +1030 | [diff] [blame] | 10 | extern "C" { |
| 11 | #include "test/mbox.h" |
| 12 | #include "test/system.h" |
| 13 | } |
| 14 | |
Andrew Jeffery | 30bcf84 | 2018-03-26 12:13:20 +1030 | [diff] [blame] | 15 | #include "vpnor/test/tmpd.hpp" |
Andrew Jeffery | a138f56 | 2018-02-27 16:58:02 +1030 | [diff] [blame] | 16 | |
| 17 | static constexpr auto BLOCK_SIZE = 0x1000; |
| 18 | static constexpr auto ERASE_SIZE = BLOCK_SIZE; |
| 19 | static constexpr auto PNOR_SIZE = 64 * 1024 * 1024; |
| 20 | static constexpr auto MEM_SIZE = 32 * 1024 * 1024; |
| 21 | static constexpr auto N_WINDOWS = 1; |
| 22 | static constexpr auto WINDOW_SIZE = BLOCK_SIZE * 2; |
| 23 | |
| 24 | const std::string toc[] = { |
| 25 | "partition01=ONE,00001000,00002000,80,", |
| 26 | "partition02=TWO,00002000,00004000,80,", |
| 27 | "partition03=THREE,00004000,00008000,80,", |
| 28 | }; |
| 29 | |
| 30 | int main() |
| 31 | { |
| 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 | |
| 40 | ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); |
| 41 | |
| 42 | test::VpnorRoot root(ctx, toc, BLOCK_SIZE); |
Andrew Jeffery | 742a1f6 | 2018-03-02 09:26:03 +1030 | [diff] [blame] | 43 | vpnor::partition::Table table(ctx); |
Andrew Jeffery | a138f56 | 2018-02-27 16:58:02 +1030 | [diff] [blame] | 44 | |
| 45 | const struct pnor_partition& part = table.partition("TWO"); |
| 46 | assert(part.data.id == 2); |
| 47 | assert(part.data.base == 2); |
| 48 | assert(part.data.size == 2); |
| 49 | |
| 50 | return 0; |
| 51 | } |