2 * Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/endian.h>
37 #include <sys/param.h>
38 #include <sys/ctype.h>
39 #include <sys/malloc.h>
40 #include <sys/systm.h>
51 #include "bhnd_nvram_private.h"
53 #include "bhnd_nvram_datavar.h"
55 #include "bhnd_nvram_data_bcmreg.h" /* for BCM_NVRAM_MAGIC */
58 * Broadcom "Board Text" data class.
60 * This format is used to provide external NVRAM data for some
61 * fullmac WiFi devices, and as an input format when programming
65 struct bhnd_nvram_btxt {
66 struct bhnd_nvram_data nv; /**< common instance state */
67 struct bhnd_nvram_io *data; /**< memory-backed board text data */
68 size_t count; /**< variable count */
71 BHND_NVRAM_DATA_CLASS_DEFN(btxt, "Broadcom Board Text",
72 BHND_NVRAM_DATA_CAP_DEVPATHS, sizeof(struct bhnd_nvram_btxt))
74 /** Minimal identification header */
75 union bhnd_nvram_btxt_ident {
80 static void *bhnd_nvram_btxt_offset_to_cookiep(struct bhnd_nvram_btxt *btxt,
82 static size_t bhnd_nvram_btxt_cookiep_to_offset(struct bhnd_nvram_btxt *btxt,
85 static int bhnd_nvram_btxt_entry_len(struct bhnd_nvram_io *io,
86 size_t offset, size_t *line_len, size_t *env_len);
87 static int bhnd_nvram_btxt_seek_next(struct bhnd_nvram_io *io,
89 static int bhnd_nvram_btxt_seek_eol(struct bhnd_nvram_io *io,
93 bhnd_nvram_btxt_probe(struct bhnd_nvram_io *io)
95 union bhnd_nvram_btxt_ident ident;
99 /* Look at the initial header for something that looks like
100 * an ASCII board text file */
101 if ((error = bhnd_nvram_io_read(io, 0x0, &ident, sizeof(ident))))
104 /* The BCM NVRAM format uses a 'FLSH' little endian magic value, which
105 * shouldn't be interpreted as BTXT */
106 if (le32toh(ident.bcm_magic) == BCM_NVRAM_MAGIC)
109 /* Don't match on non-ASCII/non-printable data */
110 for (size_t i = 0; i < nitems(ident.btxt); i++) {
112 if (!bhnd_nv_isprint(c))
116 /* The first character should either be a valid key char (alpha),
117 * whitespace, or the start of a comment ('#') */
119 if (!bhnd_nv_isspace(c) && !bhnd_nv_isalpha(c) && c != '#')
122 /* We assert a low priority, given that we've only scanned an
123 * initial few bytes of the file. */
124 return (BHND_NVRAM_DATA_PROBE_MAYBE);
128 * Parser states for bhnd_nvram_bcm_getvar_direct_common().
131 BTXT_PARSE_LINE_START,
134 BTXT_PARSE_NEXT_LINE,
135 BTXT_PARSE_VALUE_START,
140 bhnd_nvram_btxt_getvar_direct(struct bhnd_nvram_io *io, const char *name,
141 void *outp, size_t *olen, bhnd_nvram_type otype)
144 btxt_parse_state pstate;
145 size_t limit, offset;
146 size_t buflen, bufpos;
147 size_t namelen, namepos;
151 limit = bhnd_nvram_io_getsize(io);
154 /* Loop our parser until we find the requested variable, or hit EOF */
155 pstate = BTXT_PARSE_LINE_START;
158 namelen = strlen(name);
162 while ((offset - bufpos) < limit) {
163 BHND_NV_ASSERT(bufpos <= buflen,
164 ("buf position invalid (%zu > %zu)", bufpos, buflen));
165 BHND_NV_ASSERT(buflen <= sizeof(buf),
166 ("buf length invalid (%zu > %zu", buflen, sizeof(buf)));
168 /* Repopulate our parse buffer? */
169 if (buflen - bufpos == 0) {
170 BHND_NV_ASSERT(offset < limit, ("offset overrun"));
172 buflen = bhnd_nv_ummin(sizeof(buf), limit - offset);
175 error = bhnd_nvram_io_read(io, offset, buf, buflen);
183 case BTXT_PARSE_LINE_START:
184 BHND_NV_ASSERT(bufpos < buflen, ("empty buffer!"));
186 /* Reset name matching position */
189 /* Trim any leading whitespace */
190 while (bufpos < buflen && bhnd_nv_isspace(buf[bufpos]))
195 if (bufpos == buflen) {
196 /* Continue parsing the line */
197 pstate = BTXT_PARSE_LINE_START;
198 } else if (bufpos < buflen && buf[bufpos] == '#') {
199 /* Comment; skip to next line */
200 pstate = BTXT_PARSE_NEXT_LINE;
202 /* Start name matching */
203 pstate = BTXT_PARSE_KEY;
208 case BTXT_PARSE_KEY: {
209 size_t navail, nleft;
211 nleft = namelen - namepos;
212 navail = bhnd_nv_ummin(buflen - bufpos, nleft);
214 if (strncmp(name+namepos, buf+bufpos, navail) == 0) {
219 if (namepos == namelen) {
220 /* Matched the full variable; look for
221 * its trailing delimiter */
222 pstate = BTXT_PARSE_KEY_END;
224 /* Continue matching the name */
225 pstate = BTXT_PARSE_KEY;
228 /* No match; advance to next entry and restart
230 pstate = BTXT_PARSE_NEXT_LINE;
236 case BTXT_PARSE_KEY_END:
237 BHND_NV_ASSERT(bufpos < buflen, ("empty buffer!"));
239 if (buf[bufpos] == '=') {
240 /* Key fully matched; advance past '=' and
243 pstate = BTXT_PARSE_VALUE_START;
245 /* No match; advance to next line and restart
247 pstate = BTXT_PARSE_NEXT_LINE;
252 case BTXT_PARSE_NEXT_LINE: {
255 /* Scan for a '\r', '\n', or '\r\n' terminator */
256 p = memchr(buf+bufpos, '\n', buflen - bufpos);
258 p = memchr(buf+bufpos, '\r', buflen - bufpos);
261 /* Found entry terminator; restart name
262 * matching at next line */
263 pstate = BTXT_PARSE_LINE_START;
266 /* Consumed full buffer looking for newline;
267 * force repopulation of the buffer and
269 pstate = BTXT_PARSE_NEXT_LINE;
276 case BTXT_PARSE_VALUE_START: {
279 /* Scan for a terminating newline */
280 p = memchr(buf+bufpos, '\n', buflen - bufpos);
282 p = memchr(buf+bufpos, '\r', buflen - bufpos);
285 /* Found entry terminator; parse the value */
286 vlen = p - &buf[bufpos];
287 pstate = BTXT_PARSE_VALUE;
289 } else if (p == NULL && offset == limit) {
290 /* Hit EOF without a terminating newline;
291 * treat the entry as implicitly terminated */
292 vlen = buflen - bufpos;
293 pstate = BTXT_PARSE_VALUE;
295 } else if (p == NULL && bufpos > 0) {
298 /* Move existing value data to start of
300 memmove(buf, buf+bufpos, buflen - bufpos);
304 /* Populate full buffer to allow retry of
306 nread = bhnd_nv_ummin(sizeof(buf) - buflen,
309 error = bhnd_nvram_io_read(io, offset,
317 /* Value exceeds our buffer capacity */
318 BHND_NV_LOG("cannot parse value for '%s' "
319 "(exceeds %zu byte limit)\n", name,
328 case BTXT_PARSE_VALUE:
329 BHND_NV_ASSERT(vlen <= buflen, ("value buf overrun"));
331 /* Trim any trailing whitespace */
332 while (vlen > 0 && bhnd_nv_isspace(buf[bufpos+vlen-1]))
335 /* Write the value to the caller's buffer */
336 return (bhnd_nvram_value_coerce(buf+bufpos, vlen,
337 BHND_NVRAM_TYPE_STRING, outp, olen, otype));
341 /* Variable not found */
346 bhnd_nvram_btxt_serialize(bhnd_nvram_data_class *cls, bhnd_nvram_plist *props,
347 bhnd_nvram_plist *options, void *outp, size_t *olen)
349 bhnd_nvram_prop *prop;
350 size_t limit, nbytes;
353 /* Determine output byte limit */
361 /* Write all properties */
363 while ((prop = bhnd_nvram_plist_next(props, prop)) != NULL) {
367 size_t name_len, value_len;
369 if (outp == NULL || limit < nbytes) {
373 p = ((char *)outp) + nbytes;
374 prop_limit = limit - nbytes;
377 /* Fetch and write 'name=' to output */
378 name = bhnd_nvram_prop_name(prop);
379 name_len = strlen(name) + 1;
381 if (prop_limit > name_len) {
382 memcpy(p, name, name_len - 1);
383 p[name_len - 1] = '=';
385 prop_limit -= name_len;
392 /* Advance byte count */
393 if (SIZE_MAX - nbytes < name_len)
394 return (EFTYPE); /* would overflow size_t */
398 /* Write NUL-terminated value to output, rewrite NUL as
399 * '\n' record delimiter */
400 value_len = prop_limit;
401 error = bhnd_nvram_prop_encode(prop, p, &value_len,
402 BHND_NVRAM_TYPE_STRING);
403 if (p != NULL && error == 0) {
404 /* Replace trailing '\0' with newline */
405 BHND_NV_ASSERT(value_len > 0, ("string length missing "
406 "minimum required trailing NUL"));
408 *(p + (value_len - 1)) = '\n';
409 } else if (error && error != ENOMEM) {
410 /* If encoding failed for any reason other than ENOMEM
411 * (which we'll detect and report after encoding all
412 * properties), return immediately */
413 BHND_NV_LOG("error serializing %s to required type "
415 bhnd_nvram_type_name(BHND_NVRAM_TYPE_STRING),
420 /* Advance byte count */
421 if (SIZE_MAX - nbytes < value_len)
422 return (EFTYPE); /* would overflow size_t */
427 /* Provide required length */
440 * Initialize @p btxt with the provided board text data mapped by @p src.
442 * @param btxt A newly allocated data instance.
445 bhnd_nvram_btxt_init(struct bhnd_nvram_btxt *btxt, struct bhnd_nvram_io *src)
448 const char *name, *value;
449 size_t name_len, value_len;
450 size_t line_len, env_len;
451 size_t io_offset, io_size, str_size;
454 BHND_NV_ASSERT(btxt->data == NULL, ("btxt data already allocated"));
456 if ((btxt->data = bhnd_nvram_iobuf_copy(src)) == NULL)
459 io_size = bhnd_nvram_io_getsize(btxt->data);
462 /* Fetch a pointer mapping the entirity of the board text data */
463 error = bhnd_nvram_io_read_ptr(btxt->data, 0x0, &ptr, io_size, NULL);
467 /* Determine the actual size, minus any terminating NUL. We
468 * parse NUL-terminated C strings, but do not include NUL termination
469 * in our internal or serialized representations */
470 str_size = strnlen(ptr, io_size);
472 /* If the terminating NUL is not found at the end of the buffer,
473 * this is BCM-RAW or other NUL-delimited NVRAM format. */
474 if (str_size < io_size && str_size + 1 < io_size)
477 /* Adjust buffer size to account for NUL termination (if any) */
479 if ((error = bhnd_nvram_io_setsize(btxt->data, io_size)))
482 /* Process the buffer */
484 while (io_offset < io_size) {
487 /* Seek to the next key=value entry */
488 if ((error = bhnd_nvram_btxt_seek_next(btxt->data, &io_offset)))
491 /* Determine the entry and line length */
492 error = bhnd_nvram_btxt_entry_len(btxt->data, io_offset,
493 &line_len, &env_len);
499 BHND_NV_ASSERT(io_offset == io_size,
500 ("zero-length record returned from "
501 "bhnd_nvram_btxt_seek_next()"));
505 /* Fetch a pointer to the line start */
506 error = bhnd_nvram_io_read_ptr(btxt->data, io_offset, &envp,
511 /* Parse the key=value string */
512 error = bhnd_nvram_parse_env(envp, env_len, '=', &name,
513 &name_len, &value, &value_len);
518 /* Insert a '\0' character, replacing the '=' delimiter and
519 * allowing us to vend references directly to the variable
521 error = bhnd_nvram_io_write(btxt->data, io_offset+name_len,
526 /* Add to variable count */
529 /* Advance past EOL */
530 io_offset += line_len;
537 bhnd_nvram_btxt_new(struct bhnd_nvram_data *nv, struct bhnd_nvram_io *io)
539 struct bhnd_nvram_btxt *btxt;
542 /* Allocate and initialize the BTXT data instance */
543 btxt = (struct bhnd_nvram_btxt *)nv;
545 /* Parse the BTXT input data and initialize our backing
546 * data representation */
547 if ((error = bhnd_nvram_btxt_init(btxt, io))) {
548 bhnd_nvram_btxt_free(nv);
556 bhnd_nvram_btxt_free(struct bhnd_nvram_data *nv)
558 struct bhnd_nvram_btxt *btxt = (struct bhnd_nvram_btxt *)nv;
559 if (btxt->data != NULL)
560 bhnd_nvram_io_free(btxt->data);
564 bhnd_nvram_btxt_count(struct bhnd_nvram_data *nv)
566 struct bhnd_nvram_btxt *btxt = (struct bhnd_nvram_btxt *)nv;
567 return (btxt->count);
570 static bhnd_nvram_plist *
571 bhnd_nvram_btxt_options(struct bhnd_nvram_data *nv)
577 bhnd_nvram_btxt_caps(struct bhnd_nvram_data *nv)
579 return (BHND_NVRAM_DATA_CAP_READ_PTR|BHND_NVRAM_DATA_CAP_DEVPATHS);
583 bhnd_nvram_btxt_find(struct bhnd_nvram_data *nv, const char *name)
585 return (bhnd_nvram_data_generic_find(nv, name));
589 bhnd_nvram_btxt_next(struct bhnd_nvram_data *nv, void **cookiep)
591 struct bhnd_nvram_btxt *btxt;
593 size_t io_offset, io_size;
596 btxt = (struct bhnd_nvram_btxt *)nv;
598 io_size = bhnd_nvram_io_getsize(btxt->data);
600 if (*cookiep == NULL) {
601 /* Start search at initial file offset */
604 /* Start search after the current entry */
605 io_offset = bhnd_nvram_btxt_cookiep_to_offset(btxt, *cookiep);
607 /* Scan past the current entry by finding the next newline */
608 error = bhnd_nvram_btxt_seek_eol(btxt->data, &io_offset);
610 BHND_NV_LOG("unexpected error in seek_eol(): %d\n",
616 /* Already at EOF? */
617 if (io_offset == io_size)
620 /* Seek to the first valid entry, or EOF */
621 if ((error = bhnd_nvram_btxt_seek_next(btxt->data, &io_offset))) {
622 BHND_NV_LOG("unexpected error in seek_next(): %d\n", error);
627 if (io_offset == io_size)
630 /* Provide the new cookie for this offset */
631 *cookiep = bhnd_nvram_btxt_offset_to_cookiep(btxt, io_offset);
633 /* Fetch the name pointer; it must be at least 1 byte long */
634 error = bhnd_nvram_io_read_ptr(btxt->data, io_offset, &nptr, 1, NULL);
636 BHND_NV_LOG("unexpected error in read_ptr(): %d\n", error);
640 /* Return the name pointer */
645 bhnd_nvram_btxt_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1,
648 if (cookiep1 < cookiep2)
651 if (cookiep1 > cookiep2)
658 bhnd_nvram_btxt_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *buf,
659 size_t *len, bhnd_nvram_type type)
661 return (bhnd_nvram_data_generic_rp_getvar(nv, cookiep, buf, len, type));
665 bhnd_nvram_btxt_copy_val(struct bhnd_nvram_data *nv, void *cookiep,
666 bhnd_nvram_val **value)
668 return (bhnd_nvram_data_generic_rp_copy_val(nv, cookiep, value));
672 bhnd_nvram_btxt_getvar_ptr(struct bhnd_nvram_data *nv, void *cookiep,
673 size_t *len, bhnd_nvram_type *type)
675 struct bhnd_nvram_btxt *btxt;
678 size_t io_offset, io_size;
679 size_t line_len, env_len;
682 btxt = (struct bhnd_nvram_btxt *)nv;
684 io_size = bhnd_nvram_io_getsize(btxt->data);
685 io_offset = bhnd_nvram_btxt_cookiep_to_offset(btxt, cookiep);
688 if (io_offset == io_size)
691 /* Determine the entry length */
692 error = bhnd_nvram_btxt_entry_len(btxt->data, io_offset, &line_len,
695 BHND_NV_LOG("unexpected error in entry_len(): %d\n", error);
699 /* Fetch the entry's value pointer and length */
700 error = bhnd_nvram_io_read_ptr(btxt->data, io_offset, &eptr, env_len,
703 BHND_NV_LOG("unexpected error in read_ptr(): %d\n", error);
707 error = bhnd_nvram_parse_env(eptr, env_len, '\0', NULL, NULL, &vptr,
710 BHND_NV_LOG("unexpected error in parse_env(): %d\n", error);
714 /* Type is always CSTR */
715 *type = BHND_NVRAM_TYPE_STRING;
721 bhnd_nvram_btxt_getvar_name(struct bhnd_nvram_data *nv, void *cookiep)
723 struct bhnd_nvram_btxt *btxt;
725 size_t io_offset, io_size;
728 btxt = (struct bhnd_nvram_btxt *)nv;
730 io_size = bhnd_nvram_io_getsize(btxt->data);
731 io_offset = bhnd_nvram_btxt_cookiep_to_offset(btxt, cookiep);
734 if (io_offset == io_size)
735 BHND_NV_PANIC("invalid cookiep: %p", cookiep);
737 /* Variable name is found directly at the given offset; trailing
738 * NUL means we can assume that it's at least 1 byte long */
739 error = bhnd_nvram_io_read_ptr(btxt->data, io_offset, &ptr, 1, NULL);
741 BHND_NV_PANIC("unexpected error in read_ptr(): %d\n", error);
747 * Return a cookiep for the given I/O offset.
750 bhnd_nvram_btxt_offset_to_cookiep(struct bhnd_nvram_btxt *btxt,
756 BHND_NV_ASSERT(io_offset < bhnd_nvram_io_getsize(btxt->data),
757 ("io_offset %zu out-of-range", io_offset));
758 BHND_NV_ASSERT(io_offset < UINTPTR_MAX,
759 ("io_offset %#zx exceeds UINTPTR_MAX", io_offset));
761 error = bhnd_nvram_io_read_ptr(btxt->data, 0x0, &ptr, io_offset, NULL);
763 BHND_NV_PANIC("error mapping offset %zu: %d", io_offset, error);
765 ptr = (const uint8_t *)ptr + io_offset;
766 return (__DECONST(void *, ptr));
769 /* Convert a cookiep back to an I/O offset */
771 bhnd_nvram_btxt_cookiep_to_offset(struct bhnd_nvram_btxt *btxt, void *cookiep)
778 BHND_NV_ASSERT(cookiep != NULL, ("null cookiep"));
780 io_size = bhnd_nvram_io_getsize(btxt->data);
781 error = bhnd_nvram_io_read_ptr(btxt->data, 0x0, &ptr, io_size, NULL);
783 BHND_NV_PANIC("error mapping offset %zu: %d", io_size, error);
785 offset = (const uint8_t *)cookiep - (const uint8_t *)ptr;
786 BHND_NV_ASSERT(offset >= 0, ("invalid cookiep"));
787 BHND_NV_ASSERT((uintptr_t)offset < SIZE_MAX, ("cookiep > SIZE_MAX)"));
788 BHND_NV_ASSERT((uintptr_t)offset <= io_size, ("cookiep > io_size)"));
790 return ((size_t)offset);
793 /* Determine the entry length and env 'key=value' string length of the entry
796 bhnd_nvram_btxt_entry_len(struct bhnd_nvram_io *io, size_t offset,
797 size_t *line_len, size_t *env_len)
799 const uint8_t *baseptr, *p;
804 /* Fetch read buffer */
805 if ((error = bhnd_nvram_io_read_ptr(io, offset, &rbuf, 0, &nbytes)))
808 /* Find record termination (EOL, or '#') */
811 while ((size_t)(p - baseptr) < nbytes) {
812 if (*p == '#' || *p == '\n' || *p == '\r')
818 /* Got line length, now trim any trailing whitespace to determine
819 * actual env length */
820 *line_len = p - baseptr;
821 *env_len = *line_len;
823 for (size_t i = 0; i < *line_len; i++) {
824 char c = baseptr[*line_len - i - 1];
825 if (!bhnd_nv_isspace(c))
834 /* Seek past the next line ending (\r, \r\n, or \n) */
836 bhnd_nvram_btxt_seek_eol(struct bhnd_nvram_io *io, size_t *offset)
838 const uint8_t *baseptr, *p;
843 /* Fetch read buffer */
844 if ((error = bhnd_nvram_io_read_ptr(io, *offset, &rbuf, 0, &nbytes)))
849 while ((size_t)(p - baseptr) < nbytes) {
852 /* Advance to next char. The next position may be EOF, in which
853 * case a read will be invalid */
857 /* CR, check for optional LF */
858 if ((size_t)(p - baseptr) < nbytes) {
864 } else if (c == '\n') {
869 /* Hit newline or EOF */
870 *offset += (p - baseptr);
874 /* Seek to the next valid non-comment line (or EOF) */
876 bhnd_nvram_btxt_seek_next(struct bhnd_nvram_io *io, size_t *offset)
878 const uint8_t *baseptr, *p;
883 /* Fetch read buffer */
884 if ((error = bhnd_nvram_io_read_ptr(io, *offset, &rbuf, 0, &nbytes)))
887 /* Skip leading whitespace and comments */
890 while ((size_t)(p - baseptr) < nbytes) {
893 /* Skip whitespace */
894 if (bhnd_nv_isspace(c)) {
899 /* Skip entire comment line */
901 size_t line_off = *offset + (p - baseptr);
903 if ((error = bhnd_nvram_btxt_seek_eol(io, &line_off)))
906 p = baseptr + (line_off - *offset);
910 /* Non-whitespace, non-comment */
914 *offset += (p - baseptr);
919 bhnd_nvram_btxt_filter_setvar(struct bhnd_nvram_data *nv, const char *name,
920 bhnd_nvram_val *value, bhnd_nvram_val **result)
924 bhnd_nvram_type itype;
928 /* Name (trimmed of any path prefix) must be valid */
929 if (!bhnd_nvram_validate_name(bhnd_nvram_trim_path_name(name)))
932 /* Value must be bcm-formatted string */
933 error = bhnd_nvram_val_convert_new(&str, &bhnd_nvram_val_bcm_string_fmt,
934 value, BHND_NVRAM_VAL_DYNAMIC);
938 /* Value string must not contain our record delimiter character ('\n'),
939 * or our comment character ('#') */
940 inp = bhnd_nvram_val_bytes(str, &ilen, &itype);
941 BHND_NV_ASSERT(itype == BHND_NVRAM_TYPE_STRING, ("non-string value"));
942 for (size_t i = 0; i < ilen; i++) {
946 BHND_NV_LOG("invalid character (%#hhx) in value\n",
948 bhnd_nvram_val_release(str);
953 /* Success. Transfer result ownership to the caller. */
959 bhnd_nvram_btxt_filter_unsetvar(struct bhnd_nvram_data *nv, const char *name)
961 /* We permit deletion of any variable */