130bcf84cSAndrew Jeffery // SPDX-License-Identifier: Apache-2.0 230bcf84cSAndrew Jeffery // Copyright (C) 2018 IBM Corp. 3d5f1d40fSWilliam A. Kennington III #include "config.h" 4d5f1d40fSWilliam A. Kennington III 5d5f1d40fSWilliam A. Kennington III #include "vpnor/pnor_partition_table.hpp" 6d5f1d40fSWilliam A. Kennington III 7261f61a1SAndrew Jeffery #include <cassert> 8261f61a1SAndrew Jeffery #include <cstring> 930bcf84cSAndrew Jeffery 1030bcf84cSAndrew Jeffery extern "C" { 1130bcf84cSAndrew Jeffery #include "test/mbox.h" 1230bcf84cSAndrew Jeffery #include "test/system.h" 1330bcf84cSAndrew Jeffery } 1430bcf84cSAndrew Jeffery 1530bcf84cSAndrew Jeffery #include "vpnor/test/tmpd.hpp" 1630bcf84cSAndrew Jeffery 1730bcf84cSAndrew Jeffery static constexpr auto BLOCK_SIZE = 0x1000; 1830bcf84cSAndrew Jeffery static constexpr auto ERASE_SIZE = BLOCK_SIZE; 1930bcf84cSAndrew Jeffery static constexpr auto PNOR_SIZE = 64 * 1024 * 1024; 2030bcf84cSAndrew Jeffery static constexpr auto MEM_SIZE = 32 * 1024 * 1024; 2130bcf84cSAndrew Jeffery static constexpr auto N_WINDOWS = 1; 2230bcf84cSAndrew Jeffery static constexpr auto WINDOW_SIZE = BLOCK_SIZE * 2; 2330bcf84cSAndrew Jeffery 2430bcf84cSAndrew Jeffery const std::string toc[] = { 2530bcf84cSAndrew Jeffery "partition01=ONE,00001000,00002000,80,", 2630bcf84cSAndrew Jeffery "partition02=TWO,00002000,00004000,80,", 2730bcf84cSAndrew Jeffery "partition03=THREE,00004000,00008000,80,", 2830bcf84cSAndrew Jeffery }; 2930bcf84cSAndrew Jeffery 3030bcf84cSAndrew Jeffery int main() 3130bcf84cSAndrew Jeffery { 3230bcf84cSAndrew Jeffery namespace test = openpower::virtual_pnor::test; 3330bcf84cSAndrew Jeffery namespace vpnor = openpower::virtual_pnor; 3430bcf84cSAndrew Jeffery 3530bcf84cSAndrew Jeffery struct mbox_context* ctx; 3630bcf84cSAndrew Jeffery 3730bcf84cSAndrew Jeffery system_set_reserved_size(MEM_SIZE); 3830bcf84cSAndrew Jeffery system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE); 3930bcf84cSAndrew Jeffery 40*f1e547c7SEvan Lojewski ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE); 4130bcf84cSAndrew Jeffery 42*f1e547c7SEvan Lojewski test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE); 43*f1e547c7SEvan Lojewski vpnor::partition::Table table(&ctx->backend); 4430bcf84cSAndrew Jeffery 4530bcf84cSAndrew Jeffery const struct pnor_partition& part = table.partition("TWO"); 4630bcf84cSAndrew Jeffery assert(part.data.id == 2); 4730bcf84cSAndrew Jeffery assert(part.data.base == 2); 4830bcf84cSAndrew Jeffery assert(part.data.size == 2); 4930bcf84cSAndrew Jeffery 5030bcf84cSAndrew Jeffery return 0; 5130bcf84cSAndrew Jeffery } 52