VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

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