Home | History | Annotate | Download | only in tools
      1 #ifndef AVB_TOOLS_H
      2 #define AVB_TOOLS_H
      3 
      4 #include <app_nugget.h>
      5 #include <application.h>
      6 #include <avb.h>
      7 #include <nos/debug.h>
      8 #include <nos/NuggetClientInterface.h>
      9 
     10 #include "nugget/app/avb/avb.pb.h"
     11 
     12 #include <memory>
     13 #include <string>
     14 
     15 #define ASSERT_NO_ERROR(code, msg) \
     16   do { \
     17     int value = code; \
     18     ASSERT_EQ(value, app_status::APP_SUCCESS) \
     19         << value << " is " << nos::StatusCodeString(value) << msg; \
     20   } while(0)
     21 
     22 using namespace nugget::app::avb;
     23 
     24 namespace avb_tools {
     25 
     26 // Utility AVB calls.
     27 struct ResetMessage {
     28   uint64_t nonce;
     29   uint8_t data[AVB_DEVICE_DATA_SIZE];
     30 };
     31 
     32 void SetBootloader(nos::NuggetClientInterface *client);
     33 void BootloaderDone(nos::NuggetClientInterface *client);
     34 void GetState(nos::NuggetClientInterface *client, bool *bootloader,
     35               bool *production, uint8_t *locks);
     36 int Reset(nos::NuggetClientInterface *client, ResetRequest_ResetKind kind,
     37           const uint8_t *sig, size_t size);
     38 int GetResetChallenge(nos::NuggetClientInterface *client,
     39                       uint32_t *selector, uint64_t *nonce,
     40                       uint8_t *device_data, size_t *len);
     41 int SetProduction(nos::NuggetClientInterface *client, bool production,
     42                   const uint8_t *data, size_t size);
     43 void ResetProduction(nos::NuggetClientInterface *client);
     44 
     45 }  // namespace avb_tools
     46 
     47 #endif  // AVB_TOOLS_H
     48