blob: 72a8953d92eca8713cdefb0aa3b2f28196d46d81 [file] [log] [blame]
Deepak Kodihallib6a446f2017-04-29 13:01:49 -05001#include "mboxd_pnor_partition_table.h"
2#include "mbox.h"
3#include "pnor_partition_table.hpp"
4
5struct vpnor_partition_table
6{
7 openpower::virtual_pnor::partition::Table* table = nullptr;
8};
9
10void vpnor_create_partition_table(struct mbox_context *context)
11{
12 if (context)
13 {
14 if (!context->vpnor)
15 {
16 context->vpnor = new vpnor_partition_table;
17 context->vpnor->table =
18 new openpower::virtual_pnor::partition::Table;
19 }
20 }
21}
22
23size_t vpnor_get_partition_table_size(const struct mbox_context *context)
24{
25 return context && context->vpnor ?
26 context->vpnor->table->size() : 0;
27}
28
29const struct pnor_partition_table* vpnor_get_partition_table(
30 const struct mbox_context *context)
31{
32 return context && context->vpnor ?
33 &(context->vpnor->table->getHostTable()) : nullptr;
34}
35
36const struct pnor_partition* vpnor_get_partition(
37 const struct mbox_context *context,
38 const size_t offset)
39{
40 return context && context->vpnor ?
41 &(context->vpnor->table->partition(offset)) : nullptr;
42}
43
44void vpnor_destroy_partition_table(struct mbox_context *context)
45{
46 if(context && context->vpnor)
47 {
48 delete context->vpnor->table;
49 delete context->vpnor;
50 context->vpnor = nullptr;
51 }
52}