libubootenv
libuboot.h
1/*
2 * (C) Copyright 2019
3 * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8#ifdef __cplusplus
9#include <cstddef>
10
11extern "C" {
12#endif
13
14#pragma once
15
16struct uboot_ctx;
17
18#define DEVNAME_MAX_LENGTH 256
19
20#define DEVNAME_SEPARATOR ':'
21
27 char *devname;
29 long long int offset;
31 size_t envsize;
33 size_t sectorsize;
35 unsigned long envsectors;
36};
37
43 const char *version;
45 unsigned int version_num;
46};
47
53
60int libuboot_read_config(struct uboot_ctx *ctx, const char *config);
61
68int libuboot_read_config_ext(struct uboot_ctx **ctx, const char *config);
69
76struct uboot_ctx *libuboot_get_namespace(struct uboot_ctx *ctxlist, const char *name);
77
84const char *libuboot_namespace_from_dt(void);
85
92int libuboot_configure(struct uboot_ctx *ctx,
94
107int libuboot_load_file(struct uboot_ctx *ctx, const char *filename);
108
117int libuboot_env_store(struct uboot_ctx *ctx);
118
128int libuboot_initialize(struct uboot_ctx **out,
129 struct uboot_env_device *envdevs);
130
135void libuboot_exit(struct uboot_ctx *ctx);
136
142int libuboot_open(struct uboot_ctx *ctx);
143
152void libuboot_close(struct uboot_ctx *ctx);
153
164int libuboot_set_env(struct uboot_ctx *ctx, const char *varname, const char *value);
165
177char *libuboot_get_env(struct uboot_ctx *ctx, const char *varname);
178
188void *libuboot_iterator(struct uboot_ctx *ctx, void *next);
189
195const char *libuboot_getname(void *entry);
196
202const char *libuboot_getvalue(void *entry);
203
204#ifdef __cplusplus
205}
206#endif
Definition: uboot_private.h:114
char * name
Definition: uboot_private.h:130
struct uboot_ctx * ctxlist
Definition: uboot_private.h:136
struct uboot_flash_env envdevs[2]
Definition: uboot_private.h:122
Definition: libuboot.h:25
long long int offset
Definition: libuboot.h:29
size_t envsize
Definition: libuboot.h:31
size_t sectorsize
Definition: libuboot.h:33
char * devname
Definition: libuboot.h:27
unsigned long envsectors
Definition: libuboot.h:35
Definition: libuboot.h:41
unsigned int version_num
Definition: libuboot.h:45
const char * version
Definition: libuboot.h:43
int libuboot_read_config(struct uboot_ctx *ctx, const char *config)
Read U-Boot environment configuration from a file.
Definition: uboot_env.c:1785
struct uboot_ctx * libuboot_get_namespace(struct uboot_ctx *ctxlist, const char *name)
Get ctx from namespace.
Definition: uboot_env.c:1986
const struct uboot_version_info * libuboot_version_info(void)
Return information about library version.
Definition: uboot_env.c:1009
char * libuboot_get_env(struct uboot_ctx *ctx, const char *varname)
Get a variable.
Definition: uboot_env.c:1918
int libuboot_set_env(struct uboot_ctx *ctx, const char *varname, const char *value)
Set a variable.
Definition: uboot_env.c:1853
void libuboot_close(struct uboot_ctx *ctx)
Release an environment.
Definition: uboot_env.c:2064
const char * libuboot_getname(void *entry)
Accessor to get variable name from DB entry.
Definition: uboot_env.c:1930
int libuboot_initialize(struct uboot_ctx **out, struct uboot_env_device *envdevs)
Initialize the library.
Definition: uboot_env.c:2034
int libuboot_read_config_ext(struct uboot_ctx **ctxlist, const char *config)
Read U-Boot environment configuration from a file - new API.
Definition: uboot_env.c:1685
const char * libuboot_namespace_from_dt(void)
Look for bootloader namespace from DT.
Definition: uboot_env.c:2009
int libuboot_configure(struct uboot_ctx *ctx, struct uboot_env_device *envdevs)
Read U-Boot environment configuration from structure.
Definition: uboot_env.c:1952
int libuboot_open(struct uboot_ctx *ctx)
Load an environment.
Definition: uboot_env.c:2056
int libuboot_load_file(struct uboot_ctx *ctx, const char *filename)
Import environment from file.
Definition: uboot_env.c:1634
const char * libuboot_getvalue(void *entry)
Accessor to get variable value from DB entry.
Definition: uboot_env.c:1937
void libuboot_exit(struct uboot_ctx *ctx)
Release all resources and exit the library.
Definition: uboot_env.c:2082
int libuboot_env_store(struct uboot_ctx *ctx)
Flush environment to the storage.
Definition: uboot_env.c:1031
void * libuboot_iterator(struct uboot_ctx *ctx, void *next)
Iterator.
Definition: uboot_env.c:1944