commit | a7d2cdddcc94db11e7d684108da8806e4560c124 | [log] [tgz] |
---|---|---|
author | Ed Tanous <etanous@nvidia.com> | Mon Jul 15 11:07:27 2024 -0700 |
committer | Ed Tanous <ed@tanous.net> | Tue Jul 16 00:26:23 2024 +0000 |
tree | 3d0ade747aa926e2d03b0d9d0995008dc277a2a5 | |
parent | c833a3acae150113c748fd030558a7c12a44129d [diff] |
Move to embedded base64 Base64 encode/decode is a relatively simple algorithm, and currently libcper takes a dependency on libb64 for this. libb64 does not have methods for determining the encoded size or decoded size, and rely on the user to provide the right buffer sizes, which libcper currently approximates as 2X the input size (which is incorrect). This commit removes the libb64 dependency entirely, and inlines a libcper specific base64 encoder and decoder, using EDK2-allowed types. The implementation itself is unique to libcper and makes the following design decisions. 1. Malloc is performed within the base64_<> functions. This reduces the number of malloc calls total, and removes the need for separately determining the output size. 2. Arguments are passed in by EDK2-types under the assumption that this will keep compatibility with EDK2 implementations. 3. Incremental parsing is not supported. CPER records are expected to be algorithmically small, and buffered such that the entire value fits in memory. This was already an assumption, but dropping the support for incremental encoding significantly reduces the amount of code to support it. It could be added back in the future if needed. Change-Id: Idb010db105067ea317dbee05c2663511ab3c6611 Signed-off-by: Ed Tanous <ed@tanous.net>
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 ninji -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.