LCOV - code coverage report
Current view: top level - AP_HAL_Linux - Storage.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 1 100.0 %
Date: 2026-09-09 11:02:08 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AP_HAL/AP_HAL.h>
       4             : 
       5             : #define LINUX_STORAGE_SIZE HAL_STORAGE_SIZE
       6             : #define LINUX_STORAGE_MAX_WRITE 512
       7             : #define LINUX_STORAGE_LINE_SHIFT 9
       8             : #define LINUX_STORAGE_LINE_SIZE (1<<LINUX_STORAGE_LINE_SHIFT)
       9             : #define LINUX_STORAGE_NUM_LINES (LINUX_STORAGE_SIZE/LINUX_STORAGE_LINE_SIZE)
      10             : 
      11             : namespace Linux {
      12             : 
      13             : class Storage : public AP_HAL::Storage
      14             : {
      15             : public:
      16          48 :     Storage() : _fd(-1),_dirty_mask(0) { }
      17             : 
      18             :     static Storage *from(AP_HAL::Storage *storage) {
      19             :         return static_cast<Storage*>(storage);
      20             :     }
      21             : 
      22             : 
      23             :     void init() override;
      24             : 
      25             :     uint8_t  read_byte(uint16_t loc);
      26             :     uint16_t read_word(uint16_t loc);
      27             :     uint32_t read_dword(uint16_t loc);
      28             :     void     read_block(void *dst, uint16_t src, size_t n) override;
      29             : 
      30             :     void write_byte(uint16_t loc, uint8_t value);
      31             :     void write_word(uint16_t loc, uint16_t value);
      32             :     void write_dword(uint16_t loc, uint32_t value);
      33             :     void write_block(uint16_t dst, const void* src, size_t n) override;
      34             : 
      35             :     bool get_storage_ptr(void *&ptr, size_t &size) override;
      36             : 
      37             :     virtual void _timer_tick(void) override;
      38             : 
      39             : protected:
      40             :     void _mark_dirty(uint16_t loc, uint16_t length);
      41             :     int _storage_create(const char *dpath);
      42             : 
      43             :     int _fd;
      44             :     volatile bool _initialised;
      45             :     volatile uint32_t _dirty_mask;
      46             :     uint8_t _buffer[LINUX_STORAGE_SIZE];
      47             : };
      48             : 
      49             : }

Generated by: LCOV version 1.14