-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsmd.h
38 lines (32 loc) · 1.2 KB
/
smd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef smd_h_included
#define smd_h_included
/* Copyright (c) 2020, Matthew Madison */
#include <stdbool.h>
#include "gpt.h"
typedef enum {
REDUNDANCY_OFF = 0,
REDUNDANCY_BOOTLOADER_ONLY = 1,
REDUNDANCY_FULL = 2,
} smd_redundancy_level_t;
struct smd_slot_s {
unsigned int slot_prio;
const char *slot_suffix;
unsigned int slot_retry_count;
bool slot_successful;
};
typedef struct smd_slot_s smd_slot_t;
struct smd_context_s;
typedef struct smd_context_s smd_context_t;
smd_context_t *smd_init(gpt_context_t *boot_gpt, int bootfd);
smd_context_t *smd_new(smd_redundancy_level_t level);
smd_context_t *smd_new_from_file(int fd);
void smd_finish(smd_context_t *ctx);
smd_redundancy_level_t smd_redundancy_level(smd_context_t *ctx);
int smd_set_redundancy_level(smd_context_t *ctx, smd_redundancy_level_t level);
int smd_slot_get(smd_context_t *ctx, unsigned int which, smd_slot_t *slot);
int smd_slot_mark_successful(smd_context_t *ctx, unsigned int which);
int smd_slot_mark_active(smd_context_t *ctx, unsigned int which);
int smd_get_current_slot(void);
int smd_update(smd_context_t *ctx, gpt_context_t *boot_gpt, int bootfd, bool force);
int smd_write_to_file(smd_context_t *ctx, int fd);
#endif /* smd_h_included */