Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 1 | #include "mboxd_pnor_partition_table.h" |
| 2 | #include "mbox.h" |
| 3 | #include "pnor_partition_table.hpp" |
| 4 | |
| 5 | struct vpnor_partition_table |
| 6 | { |
| 7 | openpower::virtual_pnor::partition::Table* table = nullptr; |
| 8 | }; |
| 9 | |
| 10 | void 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 | |
| 23 | size_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 | |
| 29 | const 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 | |
| 36 | const 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 | |
| 44 | void 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 | } |