1 /* nvramparser.h 2 3 Copyright (c) 2016, Nikolaj Schlej. All rights reserved. 4 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php. 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 */ 14 15 #ifndef NVRAMPARSER_H 16 #define NVRAMPARSER_H 17 18 #include <vector> 19 20 #include "basetypes.h" 21 #include "ustring.h" 22 #include "ubytearray.h" 23 #include "treemodel.h" 24 #include "ffsparser.h" 25 26 #ifdef U_ENABLE_NVRAM_PARSING_SUPPORT 27 class NvramParser 28 { 29 public: 30 // Default constructor and destructor NvramParser(TreeModel * treeModel,FfsParser * parser)31 NvramParser(TreeModel* treeModel, FfsParser* parser) : model(treeModel), ffsParser(parser) {} ~NvramParser()32 ~NvramParser() {} 33 34 // Returns messages getMessages()35 std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; } 36 // Clears messages clearMessages()37 void clearMessages() { messagesVector.clear(); } 38 39 // NVRAM parsing 40 USTATUS parseNvramVolumeBody(const UModelIndex & index); 41 USTATUS parseNvarStore(const UModelIndex & index); 42 43 private: 44 TreeModel *model; 45 FfsParser *ffsParser; 46 std::vector<std::pair<UString, UModelIndex> > messagesVector; 47 void msg(const UString & message, const UModelIndex & index = UModelIndex()) { 48 messagesVector.push_back(std::pair<UString, UModelIndex>(message, index)); 49 }; 50 51 USTATUS findNextStore(const UModelIndex & index, const UByteArray & volume, const UINT32 localOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset); 52 USTATUS getStoreSize(const UByteArray & data, const UINT32 storeOffset, UINT32 & storeSize); 53 USTATUS parseStoreHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 54 55 USTATUS parseVssStoreHeader(const UByteArray & store, const UINT32 localOffset, const bool sizeOverride, const UModelIndex & parent, UModelIndex & index); 56 USTATUS parseVss2StoreHeader(const UByteArray & store, const UINT32 localOffset, const bool sizeOverride, const UModelIndex & parent, UModelIndex & index); 57 USTATUS parseFtwStoreHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 58 USTATUS parseFdcStoreHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 59 USTATUS parseFsysStoreHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 60 USTATUS parseEvsaStoreHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 61 USTATUS parseFlashMapStoreHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 62 USTATUS parseCmdbStoreHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 63 USTATUS parseSlicPubkeyHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 64 USTATUS parseSlicMarkerHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); 65 66 USTATUS parseFdcStoreBody(const UModelIndex & index); 67 USTATUS parseVssStoreBody(const UModelIndex & index, const UINT8 alignment); 68 USTATUS parseFsysStoreBody(const UModelIndex & index); 69 USTATUS parseEvsaStoreBody(const UModelIndex & index); 70 USTATUS parseFlashMapBody(const UModelIndex & index); 71 }; 72 #else 73 class NvramParser 74 { 75 public: 76 // Default constructor and destructor NvramParser(TreeModel * treeModel,FfsParser * parser)77 NvramParser(TreeModel* treeModel, FfsParser* parser) { U_UNUSED_PARAMETER(treeModel); U_UNUSED_PARAMETER(parser); } ~NvramParser()78 ~NvramParser() {} 79 80 // Returns messages getMessages()81 std::vector<std::pair<UString, UModelIndex> > getMessages() const { return std::vector<std::pair<UString, UModelIndex> >(); } 82 // Clears messages clearMessages()83 void clearMessages() {} 84 85 // NVRAM parsing parseNvramVolumeBody(const UModelIndex &)86 USTATUS parseNvramVolumeBody(const UModelIndex &) { return U_SUCCESS; } parseNvarStore(const UModelIndex &)87 USTATUS parseNvarStore(const UModelIndex &) { return U_SUCCESS; } 88 }; 89 #endif // U_ENABLE_NVRAM_PARSING_SUPPORT 90 #endif // NVRAMPARSER_H 91