uboot_private.h
/*
* (C) Copyright 2019
* Stefano Babic, DENX Software Engineering, sbabic@denx.de.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <sys/queue.h>
#include <mtd/mtd-user.h>
#include "libuboot.h"
typedef enum {
TYPE_ATTR_STRING, /* default */
TYPE_ATTR_DECIMAL,
TYPE_ATTR_HEX,
TYPE_ATTR_BOOL,
TYPE_ATTR_IP,
TYPE_ATTR_MAC
} type_attribute;
typedef enum {
ACCESS_ATTR_ANY, /* default */
ACCESS_ATTR_READ_ONLY,
ACCESS_ATTR_WRITE_ONCE,
ACCESS_ATTR_CHANGE_DEFAULT,
} access_attribute;
enum flags_type {
FLAGS_NONE,
FLAGS_BOOLEAN,
FLAGS_INCREMENTAL
};
enum device_type {
DEVICE_NONE,
DEVICE_FILE,
DEVICE_MTD,
DEVICE_UBI,
};
struct uboot_env_noredund {
uint32_t crc;
char data[];
};
struct uboot_env_redund {
uint32_t crc;
unsigned char flags;
char data[];
};
struct uboot_flash_env {
char devname[DEVNAME_MAX_LENGTH];
long long int offset;
size_t envsize;
size_t sectorsize;
long unsigned int envsectors;
struct mtd_info_user mtdinfo;
uint32_t crc;
int fd;
unsigned char flags;
enum flags_type flagstype;
enum device_type device_type;
};
struct var_entry {
char *name;
char *value;
type_attribute type;
access_attribute access;
LIST_ENTRY(var_entry) next;
};
LIST_HEAD(vars, var_entry);
struct uboot_ctx {
bool redundant;
bool valid;
size_t size;
struct uboot_flash_env envdevs[2];
int current;
int lock;
struct vars varlist;
};
uboot_env_noredund::data
char data[]
Definition: uboot_private.h:55
uboot_flash_env::device_type
enum device_type device_type
Definition: uboot_private.h:89
uboot_flash_env::flagstype
enum flags_type flagstype
Definition: uboot_private.h:87
var_entry
Definition: uboot_private.h:94
uboot_flash_env::fd
int fd
Definition: uboot_private.h:83
uboot_flash_env::offset
long long int offset
Definition: uboot_private.h:71
uboot_env_redund::data
char data[]
Definition: uboot_private.h:64
var_entry::access
access_attribute access
Definition: uboot_private.h:102
uboot_env_redund::flags
unsigned char flags
Definition: uboot_private.h:62
uboot_flash_env::flags
unsigned char flags
Definition: uboot_private.h:85
uboot_env_noredund::crc
uint32_t crc
Definition: uboot_private.h:53
uboot_env_redund::crc
uint32_t crc
Definition: uboot_private.h:60
uboot_ctx::size
size_t size
Definition: uboot_private.h:117
uboot_ctx::lock
int lock
Definition: uboot_private.h:123
uboot_env_redund
Definition: uboot_private.h:58
uboot_ctx::current
int current
Definition: uboot_private.h:121
var_entry::name
char * name
Definition: uboot_private.h:96
uboot_ctx::varlist
struct vars varlist
Definition: uboot_private.h:125
uboot_flash_env
Definition: uboot_private.h:67
uboot_flash_env::envsectors
long unsigned int envsectors
Definition: uboot_private.h:77
uboot_flash_env::devname
char devname[DEVNAME_MAX_LENGTH]
Definition: uboot_private.h:69
uboot_flash_env::crc
uint32_t crc
Definition: uboot_private.h:81
uboot_ctx::redundant
bool redundant
Definition: uboot_private.h:113
uboot_ctx::valid
bool valid
Definition: uboot_private.h:115
var_entry::value
char * value
Definition: uboot_private.h:98
uboot_ctx::envdevs
struct uboot_flash_env envdevs[2]
Definition: uboot_private.h:119
uboot_flash_env::sectorsize
size_t sectorsize
Definition: uboot_private.h:75
var_entry::type
type_attribute type
Definition: uboot_private.h:100
var_entry::LIST_ENTRY
LIST_ENTRY(var_entry) next
uboot_flash_env::envsize
size_t envsize
Definition: uboot_private.h:73
uboot_flash_env::mtdinfo
struct mtd_info_user mtdinfo
Definition: uboot_private.h:79
uboot_env_noredund
Definition: uboot_private.h:51
uboot_ctx
Definition: uboot_private.h:111