Loading...
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | /* SPDX-License-Identifier: GPL-2.0+ */ /* * Uclass implementation for boot schema * * Copyright 2025 Canonical Ltd * Written by Simon Glass <simon.glass@canonical.com> */ #ifndef __bootctl_state_h #define __bootctl_state_h #include <abuf.h> #include <alist.h> struct udevice; /** * struct state - State information which can be read and written * * @bflow: Bootflow for this OS */ struct bc_state { struct alist subnodes; }; /** * struct bc_state_ops - Operations for the UI */ struct bc_state_ops { /** * read_bool() - Read a boolean value * * @dev: Device to access * @key: Key to access * @valp: Returns boolean value on success * Return: 0 if OK, or -ve error code */ int (*read_bool)(struct udevice *dev, const char *key, bool *valp); /** * write_bool() - Write a boolean value * * @dev: Device to access * @key: Key to access * @val: Value to write * Return: 0 if OK, or -ve error code */ int (*write_bool)(struct udevice *dev, const char *key, bool val); /** * read_int() - Read an integer value * * This holds a 64-bit integer * * @dev: Device to access * @key: Key to access * @valp: Returns integer value on success * Return: 0 if OK, or -ve error code */ int (*read_int)(struct udevice *dev, const char *key, long *valp); /** * write_str() - Write an integer value * * This holds a 64-bit integer * * @dev: Device to access * @key: Key to access * @val: Value to write * Return: 0 if OK, or -ve error code */ int (*write_int)(struct udevice *dev, const char *key, long val); /** * read_str() - Read a string value * * @dev: Device to access * @key: Key to access * @valp: Returns string value on success * Return: 0 if OK, or -ve error code */ int (*read_str)(struct udevice *dev, const char *key, const char **valp); /** * write_str() - Write a string value * * @dev: Device to access * @key: Key to access * @val: Value to write * Return: 0 if OK, or -ve error code */ int (*write_str)(struct udevice *dev, const char *key, const char *val); /** * load() - Read in the current state * * Return: 0 if OK, or -ve error code */ int (*load)(struct udevice *dev); /** * save() - Write out the current state * * Return: 0 if OK, or -ve error code */ int (*save)(struct udevice *dev); /** * save_to_buf() - Write the current state to a buffer * * The buffer is inited and filled with the contents of the state as it * would be written to a file * * Return: 0 if OK, or -ve error code */ int (*save_to_buf)(struct udevice *dev, struct abuf *buf); /** * clear() - Clear all values * * Return: 0 if OK, or -ve error code */ int (*clear)(struct udevice *dev); }; #define bc_state_get_ops(dev) ((struct bc_state_ops *)(dev)->driver->ops) /** * bc_state_read_bool() - Read a boolean value * * @dev: Device to access * @key: Key to access * @valp: Returns boolean value on success * Return: 0 if OK, or -ve error code */ int bc_state_read_bool(struct udevice *dev, const char *key, bool *valp); /** * bc_state_write_bool() - Write a boolean value * * Sets the value for a key, overwriting any existing value * * @dev: Device to access * @key: Key to access * @val: Value to write * Return: 0 if OK, or -ve error code */ int bc_state_write_bool(struct udevice *dev, const char *key, bool val); /** * bc_state_read_int() - Read an integer value * * This holds a 64-bit integer * * @dev: Device to access * @key: Key to access * @valp: Returns integer value on success * Return: 0 if OK, or -ve error code */ int bc_state_read_int(struct udevice *dev, const char *key, long *valp); /** * bc_state_write_str() - Write an integer value * * This holds a 64-bit integer * * @dev: Device to access * @key: Key to access * @val: Value to write * Return: 0 if OK, or -ve error code */ int bc_state_write_int(struct udevice *dev, const char *key, long val); /** * bc_state_read_str() - Read a string value * * @dev: Device to access * @key: Key to access * @valp: Returns string value on success * Return: 0 if OK, or -ve error code */ int bc_state_read_str(struct udevice *dev, const char *key, const char **valp); /** * bc_state_write_str() - Write a string value * * @dev: Device to access * @key: Key to access * @val: Value to write * Return: 0 if OK, or -ve error code */ int bc_state_write_str(struct udevice *dev, const char *key, const char *val); /** * bc_state_load() - Load state from a file * * @dev: Device to access * Return: 0 if OK, or -ve error code */ int bc_state_load(struct udevice *dev); /** * bc_state_save() - Save state to a file * * @dev: Device to access * Return: 0 if OK, or -ve error code */ int bc_state_save(struct udevice *dev); /** * bc_state_save_to_buf() - Write the current state to a buffer * * The buffer is inited and filled with the contents of the state as it * would be written to a file * * Return: 0 if OK, or -ve error code */ int bc_state_save_to_buf(struct udevice *dev, struct abuf *buf); /** * bc_state_clear() - Clear all values * * Return: 0 if OK, or -ve error code */ int bc_state_clear(struct udevice *dev); #endif |