^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) .. _bootconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Boot Configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) :Author: Masami Hiramatsu <mhiramat@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Overview
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) The boot configuration expands the current kernel command line to support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) additional key-value data when booting the kernel in an efficient way.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) This allows administrators to pass a structured-Key config file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Config File Syntax
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) The boot config syntax is a simple structured key-value. Each key consists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) of dot-connected-words, and key and value are connected by ``=``. The value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) has to be terminated by semi-colon (``;``) or newline (``\n``).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) For array value, array entries are separated by comma (``,``). ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) KEY[.WORD[...]] = VALUE[, VALUE2[...]][;]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Unlike the kernel command line syntax, spaces are OK around the comma and ``=``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) Each key word must contain only alphabets, numbers, dash (``-``) or underscore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) (``_``). And each value only contains printable characters or spaces except
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) for delimiters such as semi-colon (``;``), new-line (``\n``), comma (``,``),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) hash (``#``) and closing brace (``}``).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) If you want to use those delimiters in a value, you can use either double-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) quotes (``"VALUE"``) or single-quotes (``'VALUE'``) to quote it. Note that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) you can not escape these quotes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) There can be a key which doesn't have value or has an empty value. Those keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) are used for checking if the key exists or not (like a boolean).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Key-Value Syntax
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) The boot config file syntax allows user to merge partially same word keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) by brace. For example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) foo.bar.baz = value1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) foo.bar.qux.quux = value2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) These can be written also in::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) foo.bar {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) baz = value1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) qux.quux = value2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) Or more shorter, written as following::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) foo.bar { baz = value1; qux.quux = value2 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) In both styles, same key words are automatically merged when parsing it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) at boot time. So you can append similar trees or key-values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) Same-key Values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) It is prohibited that two or more values or arrays share a same-key.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) For example,::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) foo = bar, baz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) foo = qux # !ERROR! we can not re-define same key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) If you want to update the value, you must use the override operator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ``:=`` explicitly. For example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) foo = bar, baz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) foo := qux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) then, the ``qux`` is assigned to ``foo`` key. This is useful for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) overriding the default value by adding (partial) custom bootconfigs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) without parsing the default bootconfig.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) If you want to append the value to existing key as an array member,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) you can use ``+=`` operator. For example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) foo = bar, baz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) foo += qux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) In this case, the key ``foo`` has ``bar``, ``baz`` and ``qux``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) Moreover, sub-keys and a value can coexist under a parent key.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) For example, following config is allowed.::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) foo = value1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) foo.bar = value2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) foo := value3 # This will update foo's value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) Note, since there is no syntax to put a raw value directly under a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) structured key, you have to define it outside of the brace. For example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) foo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) bar = value1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) bar {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) baz = value2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) qux = value3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) Also, the order of the value node under a key is fixed. If there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) are a value and subkeys, the value is always the first child node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) of the key. Thus if user specifies subkeys first, e.g.::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) foo.bar = value1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) foo = value2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) In the program (and /proc/bootconfig), it will be shown as below::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) foo = value2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) foo.bar = value1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) Comments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) --------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) The config syntax accepts shell-script style comments. The comments starting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) with hash ("#") until newline ("\n") will be ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) # comment line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) foo = value # value is set to foo.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) bar = 1, # 1st element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 2, # 2nd element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 3 # 3rd element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) This is parsed as below::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) foo = value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) bar = 1, 2, 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) Note that you can not put a comment between value and delimiter(``,`` or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) ``;``). This means following config has a syntax error ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) key = 1 # comment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) ,2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /proc/bootconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /proc/bootconfig is a user-space interface of the boot config.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) Unlike /proc/cmdline, this file shows the key-value style list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) Each key-value pair is shown in each line with following style::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) KEY[.WORDS...] = "[VALUE]"[,"VALUE2"...]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) Boot Kernel With a Boot Config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) ==============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) Since the boot configuration file is loaded with initrd, it will be added
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) to the end of the initrd (initramfs) image file with padding, size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) checksum and 12-byte magic word as below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) [initrd][bootconfig][padding][size(le32)][checksum(le32)][#BOOTCONFIG\n]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) The size and checksum fields are unsigned 32bit little endian value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) When the boot configuration is added to the initrd image, the total
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) file size is aligned to 4 bytes. To fill the gap, null characters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) (``\0``) will be added. Thus the ``size`` is the length of the bootconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) file + padding bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) The Linux kernel decodes the last part of the initrd image in memory to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) get the boot configuration data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) Because of this "piggyback" method, there is no need to change or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) update the boot loader and the kernel image itself as long as the boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) loader passes the correct initrd file size. If by any chance, the boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) loader passes a longer size, the kernel feils to find the bootconfig data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) To do this operation, Linux kernel provides "bootconfig" command under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) tools/bootconfig, which allows admin to apply or delete the config file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) to/from initrd image. You can build it by the following command::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) # make -C tools/bootconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) To add your boot config file to initrd image, run bootconfig as below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) (Old data is removed automatically if exists)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) # tools/bootconfig/bootconfig -a your-config /boot/initrd.img-X.Y.Z
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) To remove the config from the image, you can use -d option as below::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) # tools/bootconfig/bootconfig -d /boot/initrd.img-X.Y.Z
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) Then add "bootconfig" on the normal kernel command line to tell the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) kernel to look for the bootconfig at the end of the initrd file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) Config File Limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) Currently the maximum config size size is 32KB and the total key-words (not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) key-value entries) must be under 1024 nodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) Note: this is not the number of entries but nodes, an entry must consume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) more than 2 nodes (a key-word and a value). So theoretically, it will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) up to 512 key-value pairs. If keys contains 3 words in average, it can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) contain 256 key-value pairs. In most cases, the number of config items
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) will be under 100 entries and smaller than 8KB, so it would be enough.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) If the node number exceeds 1024, parser returns an error even if the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) size is smaller than 32KB. (Note that this maximum size is not including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) the padding null characters.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) Anyway, since bootconfig command verifies it when appending a boot config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) to initrd image, user can notice it before boot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) Bootconfig APIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) User can query or loop on key-value pairs, also it is possible to find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) a root (prefix) key node and find key-values under that node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) If you have a key string, you can query the value directly with the key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) using xbc_find_value(). If you want to know what keys exist in the boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) config, you can use xbc_for_each_key_value() to iterate key-value pairs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) Note that you need to use xbc_array_for_each_value() for accessing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) each array's value, e.g.::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) vnode = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) xbc_find_value("key.word", &vnode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if (vnode && xbc_node_is_array(vnode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) xbc_array_for_each_value(vnode, value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) printk("%s ", value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) If you want to focus on keys which have a prefix string, you can use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) xbc_find_node() to find a node by the prefix string, and iterate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) keys under the prefix node with xbc_node_for_each_key_value().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) But the most typical usage is to get the named value under prefix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) or get the named array under prefix as below::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) root = xbc_find_node("key.prefix");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) value = xbc_node_find_value(root, "option", &vnode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) xbc_node_for_each_array_value(root, "array-option", value, anode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) This accesses a value of "key.prefix.option" and an array of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) "key.prefix.array-option".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) Locking is not needed, since after initialization, the config becomes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) read-only. All data and keys must be copied if you need to modify it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) Functions and structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .. kernel-doc:: include/linux/bootconfig.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .. kernel-doc:: lib/bootconfig.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)