STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
emmc_log.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "emmc_port.h"
#include "flight_state.h"
Include dependency graph for emmc_log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  emmc_log_chunk_t
struct  emmc_log_config_t
struct  emmc_log_stats_t
struct  emmc_log_t

Macros

#define EMMC_LOG_CHUNK_BLOCKS   32U
#define EMMC_LOG_CHUNK_BYTES   (EMMC_LOG_CHUNK_BLOCKS * EMMC_BLOCK_SIZE)
#define EMMC_LOG_MAX_CHUNKS   16U
#define EMMC_LOG_HEADER_BYTES   20U
#define EMMC_LOG_PAYLOAD_BYTES   (EMMC_BLOCK_SIZE - EMMC_LOG_HEADER_BYTES - 4U)
#define EMMC_LOG_RECORD_HEADER_BYTES   6U
#define EMMC_LOG_SUPER_MAGIC   0x31425353UL /* "SSB1" */
#define EMMC_LOG_BLOCK_MAGIC   0x31474C53UL /* "SLG1" */
#define EMMC_LOG_LAYOUT_VERSION   1U
#define EMMC_LOG_KIND_DATA   1U
#define EMMC_LOG_KIND_PAD   2U
#define EMMC_REC_SESSION_START   0x01U /* data: u8 state entered */
#define EMMC_REC_STATE   0x02U /* data: u8 from, u8 to */
#define EMMC_REC_SESSION_END   0x03U /* data: u8 state entered */
#define EMMC_REC_DROPPED   0x04U /* data: u32 records lost before this */
#define EMMC_REC_USER_FIRST   0x10U
#define EMMC_LOG_DEFAULT_DATA_START   8192UL

Enumerations

enum  emmc_disk_state_t { EMMC_DISK_UNMOUNTED = 0 , EMMC_DISK_MOUNTED , EMMC_DISK_FULL , EMMC_DISK_FAULT }
enum  emmc_chunk_state_t { EMMC_CHUNK_FREE = 0 , EMMC_CHUNK_FILLING , EMMC_CHUNK_READY }

Functions

emmc_log_config_t emmc_log_default_config (void)
emmc_status_t emmc_log_init (emmc_log_t *log, const emmc_port_t *port, void *context, const emmc_log_config_t *config, emmc_log_chunk_t *chunks, uint8_t chunk_count, uint8_t *scratch)
bool emmc_log_on_state (emmc_log_t *log, flight_state_t from, flight_state_t to, uint32_t now_ms)
bool emmc_log_append (emmc_log_t *log, uint8_t type, uint32_t t_ms, const void *data, uint8_t len)
void emmc_log_flush (emmc_log_t *log)
emmc_status_t emmc_log_service (emmc_log_t *log, uint32_t now_ms)
uint8_t emmc_log_backlog (const emmc_log_t *log)
uint32_t emmc_log_crc32 (const void *data, uint32_t len)

Macro Definition Documentation

◆ EMMC_LOG_BLOCK_MAGIC

#define EMMC_LOG_BLOCK_MAGIC   0x31474C53UL /* "SLG1" */

Definition at line 64 of file emmc_log.h.

Referenced by emmc_log_service(), format(), and probe().

◆ EMMC_LOG_CHUNK_BLOCKS

#define EMMC_LOG_CHUNK_BLOCKS   32U

Definition at line 55 of file emmc_log.h.

Referenced by close_block(), emmc_log_service(), mount(), and seal().

◆ EMMC_LOG_CHUNK_BYTES

#define EMMC_LOG_CHUNK_BYTES   (EMMC_LOG_CHUNK_BLOCKS * EMMC_BLOCK_SIZE)

Definition at line 56 of file emmc_log.h.

Referenced by acquire().

◆ EMMC_LOG_DEFAULT_DATA_START

#define EMMC_LOG_DEFAULT_DATA_START   8192UL

Definition at line 78 of file emmc_log.h.

Referenced by emmc_log_default_config().

◆ EMMC_LOG_HEADER_BYTES

#define EMMC_LOG_HEADER_BYTES   20U

Definition at line 59 of file emmc_log.h.

Referenced by put_record().

◆ EMMC_LOG_KIND_DATA

#define EMMC_LOG_KIND_DATA   1U

Definition at line 67 of file emmc_log.h.

Referenced by close_block(), and probe().

◆ EMMC_LOG_KIND_PAD

#define EMMC_LOG_KIND_PAD   2U

Definition at line 68 of file emmc_log.h.

Referenced by probe(), and seal().

◆ EMMC_LOG_LAYOUT_VERSION

#define EMMC_LOG_LAYOUT_VERSION   1U

Definition at line 65 of file emmc_log.h.

Referenced by format(), and mount().

◆ EMMC_LOG_MAX_CHUNKS

#define EMMC_LOG_MAX_CHUNKS   16U

Definition at line 57 of file emmc_log.h.

Referenced by emmc_log_init(), and test_invalid_init().

◆ EMMC_LOG_PAYLOAD_BYTES

#define EMMC_LOG_PAYLOAD_BYTES   (EMMC_BLOCK_SIZE - EMMC_LOG_HEADER_BYTES - 4U)

Definition at line 60 of file emmc_log.h.

Referenced by probe(), and put_record().

◆ EMMC_LOG_RECORD_HEADER_BYTES

#define EMMC_LOG_RECORD_HEADER_BYTES   6U

Definition at line 61 of file emmc_log.h.

Referenced by put_record().

◆ EMMC_LOG_SUPER_MAGIC

#define EMMC_LOG_SUPER_MAGIC   0x31425353UL /* "SSB1" */

Definition at line 63 of file emmc_log.h.

Referenced by format(), and mount().

◆ EMMC_REC_DROPPED

#define EMMC_REC_DROPPED   0x04U /* data: u32 records lost before this */

Definition at line 74 of file emmc_log.h.

Referenced by keep(), and test_backpressure().

◆ EMMC_REC_SESSION_END

#define EMMC_REC_SESSION_END   0x03U /* data: u8 state entered */

Definition at line 73 of file emmc_log.h.

Referenced by check_emmc_roundtrip(), emmc_log_on_state(), and test_session_roundtrip().

◆ EMMC_REC_SESSION_START

#define EMMC_REC_SESSION_START   0x01U /* data: u8 state entered */

Definition at line 71 of file emmc_log.h.

Referenced by check_emmc_roundtrip(), emmc_log_on_state(), and test_session_roundtrip().

◆ EMMC_REC_STATE

#define EMMC_REC_STATE   0x02U /* data: u8 from, u8 to */

Definition at line 72 of file emmc_log.h.

Referenced by check_emmc_roundtrip(), emmc_log_on_state(), and test_flight_keeps_recording().

◆ EMMC_REC_USER_FIRST

#define EMMC_REC_USER_FIRST   0x10U

Definition at line 75 of file emmc_log.h.

Referenced by check_conservation(), and check_emmc_stall().

Enumeration Type Documentation

◆ emmc_chunk_state_t

Enumerator
EMMC_CHUNK_FREE 
EMMC_CHUNK_FILLING 
EMMC_CHUNK_READY 

Definition at line 108 of file emmc_log.h.

◆ emmc_disk_state_t

Enumerator
EMMC_DISK_UNMOUNTED 
EMMC_DISK_MOUNTED 
EMMC_DISK_FULL 
EMMC_DISK_FAULT 

Definition at line 92 of file emmc_log.h.

Function Documentation

◆ emmc_log_append()

bool emmc_log_append ( emmc_log_t * log,
uint8_t type,
uint32_t t_ms,
const void * data,
uint8_t len )

◆ emmc_log_backlog()

uint8_t emmc_log_backlog ( const emmc_log_t * log)

◆ emmc_log_crc32()

uint32_t emmc_log_crc32 ( const void * data,
uint32_t len )

Definition at line 31 of file emmc_log.c.

References p.

Referenced by emmc_log_service(), format(), mount(), probe(), and test_crc().

◆ emmc_log_default_config()

◆ emmc_log_flush()

◆ emmc_log_init()

◆ emmc_log_on_state()

◆ emmc_log_service()