130bcf84cSAndrew Jeffery // SPDX-License-Identifier: Apache-2.0 230bcf84cSAndrew Jeffery // Copyright (C) 2018 IBM Corp. 330bcf84cSAndrew Jeffery #include "config.h" 4d5f1d40fSWilliam A. Kennington III 530bcf84cSAndrew Jeffery extern "C" { 6035ad76bSAndrew Jeffery #include "backend.h" 730bcf84cSAndrew Jeffery #include "test/mbox.h" 830bcf84cSAndrew Jeffery #include "test/system.h" 930bcf84cSAndrew Jeffery } 1030bcf84cSAndrew Jeffery 11*de08ca2dSAndrew Jeffery #include "vpnor/table.hpp" 1230bcf84cSAndrew Jeffery #include "vpnor/test/tmpd.hpp" 13035ad76bSAndrew Jeffery #include "xyz/openbmc_project/Common/error.hpp" 14035ad76bSAndrew Jeffery 15035ad76bSAndrew Jeffery #include <cassert> 16035ad76bSAndrew Jeffery #include <cstring> 1730bcf84cSAndrew Jeffery 1830bcf84cSAndrew Jeffery static constexpr auto BLOCK_SIZE = 0x1000; 1930bcf84cSAndrew Jeffery static constexpr auto ERASE_SIZE = BLOCK_SIZE; 2030bcf84cSAndrew Jeffery static constexpr auto PNOR_SIZE = 64 * 1024 * 1024; 2130bcf84cSAndrew Jeffery static constexpr auto MEM_SIZE = 32 * 1024 * 1024; 2230bcf84cSAndrew Jeffery static constexpr auto N_WINDOWS = 1; 2330bcf84cSAndrew Jeffery static constexpr auto WINDOW_SIZE = BLOCK_SIZE * 2; 2430bcf84cSAndrew Jeffery 2530bcf84cSAndrew Jeffery const std::string toc[] = { 2630bcf84cSAndrew Jeffery "partition01=ONE,00001000,00002000,80,", 2730bcf84cSAndrew Jeffery }; 2830bcf84cSAndrew Jeffery main()2930bcf84cSAndrew Jefferyint main() 3030bcf84cSAndrew Jeffery { 3130bcf84cSAndrew Jeffery namespace err = sdbusplus::xyz::openbmc_project::Common::Error; 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 40f1e547c7SEvan Lojewski ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE); 4130bcf84cSAndrew Jeffery 42f1e547c7SEvan Lojewski test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE); 43f1e547c7SEvan Lojewski vpnor::partition::Table table(&ctx->backend); 4430bcf84cSAndrew Jeffery 4530bcf84cSAndrew Jeffery try 4630bcf84cSAndrew Jeffery { 4730bcf84cSAndrew Jeffery table.partition("TWO"); 4830bcf84cSAndrew Jeffery } 4930bcf84cSAndrew Jeffery catch (vpnor::UnknownPartition& e) 5030bcf84cSAndrew Jeffery { 5130bcf84cSAndrew Jeffery return 0; 5230bcf84cSAndrew Jeffery } 5330bcf84cSAndrew Jeffery 5430bcf84cSAndrew Jeffery assert(false); 5530bcf84cSAndrew Jeffery } 56