commit | bd1814de02a5eb0e4cd4e4bd4f1210d460f9b6f5 | [log] [tgz] |
---|---|---|
author | Khang D Nguyen <khangng@os.amperecomputing.com> | Mon Mar 31 13:07:49 2025 +0700 |
committer | Khang D Nguyen <khangng@os.amperecomputing.com> | Fri Apr 04 12:09:55 2025 +0700 |
tree | 34067586b76b6026228ba175bcd9dc44027b674d | |
parent | 559780e3224d90b62a18aedea0fc1bccadc3977e [diff] |
Ensure FRU text is printable ASCII Currently, libcper currently fails to compile on my machine (GCC 13): ../cper-utils.c: In function ‘add_untrusted_string’: ../cper-utils.c:467:23: error: comparison is always false due to limited range of data type [-Werror=type-limits] 467 | if (c < 0) { | ^ The reason seems to be that char signedness is implementation-defined, we have to explicitly use unsigned char or signed char to get a portable char type. In our case, char is unsigned char, hence the warning. Apparently we are trying to validate ASCII strings from the records. Those strings seem to be used for display purpose only, so I think replacing it with a more precise printable ASCII test, which also does not care about char signedness, is appropriate here. This changes the JSON fruText property to appear only with printable ASCII FRU content. As a result, all of the examples have been changed where applicable. Some sections use FRU content with a predefined format (pcie, cxlprotocol) so fruText has been completely removed from those JSON objects like in the case of non-printable ASCII FRU content. Tested: oompile successfully Change-Id: I98c7c10a674c8817e0b2cbe82c26f6590d8d716a Signed-off-by: Khang D Nguyen <khangng@os.amperecomputing.com>
This repository specifies a structure for representing UEFI CPER records (as described in UEFI Specification Appendix N) in a human-readable JSON format, in addition to a library which can readily convert back and forth between the standard CPER binary format and the specified structured JSON.
Before building this library and its associated tools, you must have meson (>=1.1.1)
This project uses Meson (>=1.1.1). To build for native architecture, simply run:
meson setup build ninja -C build
This project comes with several binaries to help you deal with CPER binary and CPER-JSON. The first of these is cper-convert
, which is a command line tool that can be found in build/
. With this, you can convert to and from CPER and CPER-JSON through the command line. An example usage scenario is below:
cper-convert to-cper samples/cper-json-test-arm.json --out cper.dump cper-convert to-json cper.generated.dump
Another tool bundled with this repository is cper-generate
, found in build/
. This allows you to generate pseudo-random valid CPER records with sections of specified types for testing purposes. An example use of the program is below:
cper-generate --out cper.generated.dump --sections generic ia32x64
Help for both of these tools can be accessed through using the --help
flag in isolation.
Finally, a static library containing symbols for converting CPER and CPER-JSON between an intermediate JSON format can be found generated at lib/libcper-parse.a
. This contains the following useful library symbols:
json_object* cper_to_ir(FILE* cper_file); void ir_to_cper(json_object* ir, FILE* out);
The specification for this project's CPER-JSON format can be found in specification/
, defined in both JSON Schema format and also as a LaTeX document. Specification for the CPER binary format can be found in UEFI Specification Appendix N (2021/03/18).
This library is utilised in a proof of concept displaying CPER communication between a SatMC and OpenBMC board, including a conversion into CPER JSON for logging that utilises this library. You can find information on how to reproduce the prototype at the scripts repository, and example usage of the library itself at the pldm repository.