xref: /openbmc/libcper/README.md (revision 462f9f698b2dffd68bc660edb07e57155eec74d9)
1f0f95574SLawrence Tang# CPER JSON Representation & Conversion Library
2044afd01SJohn Chung
3044afd01SJohn ChungThis repository specifies a structure for representing UEFI CPER records (as
4044afd01SJohn Chungdescribed in UEFI Specification Appendix N) in a human-readable JSON format, in
5044afd01SJohn Chungaddition to a library which can readily convert back and forth between the
6044afd01SJohn Chungstandard CPER binary format and the specified structured JSON.
7f0f95574SLawrence Tang
8e31af623SLawrence Tang## Prerequisites
9044afd01SJohn Chung
10044afd01SJohn ChungBefore building this library and its associated tools, you must have meson
11044afd01SJohn Chung(>=1.1.1)
12e31af623SLawrence Tang
13f0f95574SLawrence Tang## Building
14044afd01SJohn Chung
15197ea120SJohn ChungThis project uses Meson (>=1.1.1). To build for native architecture, simply run:
16044afd01SJohn Chung
1718a6b127SGeorge Liu```sh
18197ea120SJohn Chungmeson setup build
19*462f9f69SGeorge Liuninja -C build
202ca29e52SLawrence Tang```
212ca29e52SLawrence Tang
2202c801a5SLawrence Tang## Usage
23044afd01SJohn Chung
24044afd01SJohn ChungThis project comes with several binaries to help you deal with CPER binary and
25044afd01SJohn ChungCPER-JSON. The first of these is `cper-convert`, which is a command line tool
26044afd01SJohn Chungthat can be found in `build/`. With this, you can convert to and from CPER and
27044afd01SJohn ChungCPER-JSON through the command line. An example usage scenario is below:
28044afd01SJohn Chung
2918a6b127SGeorge Liu```sh
3002c801a5SLawrence Tangcper-convert to-cper samples/cper-json-test-arm.json --out cper.dump
3102c801a5SLawrence Tangcper-convert to-json cper.generated.dump
3202c801a5SLawrence Tang```
33044afd01SJohn Chung
34044afd01SJohn ChungAnother tool bundled with this repository is `cper-generate`, found in `build/`.
35044afd01SJohn ChungThis allows you to generate pseudo-random valid CPER records with sections of
36044afd01SJohn Chungspecified types for testing purposes. An example use of the program is below:
37044afd01SJohn Chung
3818a6b127SGeorge Liu```sh
3902c801a5SLawrence Tangcper-generate --out cper.generated.dump --sections generic ia32x64
4002c801a5SLawrence Tang```
4102c801a5SLawrence Tang
42044afd01SJohn ChungHelp for both of these tools can be accessed through using the `--help` flag in
43044afd01SJohn Chungisolation.
44044afd01SJohn Chung
45044afd01SJohn ChungFinally, a static library containing symbols for converting CPER and CPER-JSON
46044afd01SJohn Chungbetween an intermediate JSON format can be found generated at
47044afd01SJohn Chung`lib/libcper-parse.a`. This contains the following useful library symbols:
48044afd01SJohn Chung
4918a6b127SGeorge Liu```sh
5002c801a5SLawrence Tangjson_object* cper_to_ir(FILE* cper_file);
5102c801a5SLawrence Tangvoid ir_to_cper(json_object* ir, FILE* out);
5202c801a5SLawrence Tang```
5302c801a5SLawrence Tang
54f0f95574SLawrence Tang## Specification
55044afd01SJohn Chung
56044afd01SJohn ChungThe specification for this project's CPER-JSON format can be found in
57044afd01SJohn Chung`specification/`, defined in both JSON Schema format and also as a LaTeX
58044afd01SJohn Chungdocument. Specification for the CPER binary format can be found in
59044afd01SJohn Chung[UEFI Specification Appendix N](https://uefi.org/sites/default/files/resources/UEFI_Spec_2_9_2021_03_18.pdf)
60044afd01SJohn Chung(2021/03/18).
6197481380SLawrence Tang
6297481380SLawrence Tang## Usage Examples
63044afd01SJohn Chung
64044afd01SJohn ChungThis library is utilised in a proof of concept displaying CPER communication
65044afd01SJohn Chungbetween a SatMC and OpenBMC board, including a conversion into CPER JSON for
66044afd01SJohn Chunglogging that utilises this library. You can find information on how to reproduce
67044afd01SJohn Chungthe prototype at the
68044afd01SJohn Chung[scripts repository](https://gitlab.arm.com/server_management/cper-poc-scripts),
69044afd01SJohn Chungand example usage of the library itself at the
70044afd01SJohn Chung[pldm](https://gitlab.arm.com/server_management/pldm) repository.
71