From be56ff83f50790615f4695b8763e845b74599008 Mon Sep 17 00:00:00 2001 From: fuxuan Date: Fri, 19 Jul 2024 09:30:31 +0800 Subject: [PATCH] RAS: Modify recipe name for libcper Reformat the code and use the b64c git repository for the original code. Signed-off-by: fuxuan --- .../recipes-phytium/ipmi/phytium-ipmi-oem.bb | 2 +- .../arm-libcper.bb => ras/libcper-arm.bb} | 0 .../0001-b64-Adjusted-the-code.patch | 1398 ++++++----------- ...Adapted-to-the-Phytium-platform-CPER.patch | 48 +- 4 files changed, 472 insertions(+), 976 deletions(-) rename meta-phytium/recipes-phytium/{libcper/arm-libcper.bb => ras/libcper-arm.bb} (100%) rename meta-phytium/recipes-phytium/{libcper/arm-libcper => ras/libcper-arm}/0001-b64-Adjusted-the-code.patch (47%) rename meta-phytium/recipes-phytium/{libcper/arm-libcper => ras/libcper-arm}/0002-sections-Adapted-to-the-Phytium-platform-CPER.patch (78%) diff --git a/meta-phytium/recipes-phytium/ipmi/phytium-ipmi-oem.bb b/meta-phytium/recipes-phytium/ipmi/phytium-ipmi-oem.bb index 01a098af98..a5878974c1 100644 --- a/meta-phytium/recipes-phytium/ipmi/phytium-ipmi-oem.bb +++ b/meta-phytium/recipes-phytium/ipmi/phytium-ipmi-oem.bb @@ -11,7 +11,7 @@ PV = "1.0+git${SRCPV}" S = "${WORKDIR}/git" -DEPENDS = "boost phosphor-ipmi-host phosphor-logging arm-libcper json-c" +DEPENDS = "boost phosphor-ipmi-host phosphor-logging libcper-arm json-c" inherit cmake obmc-phosphor-ipmiprovider-symlink diff --git a/meta-phytium/recipes-phytium/libcper/arm-libcper.bb b/meta-phytium/recipes-phytium/ras/libcper-arm.bb similarity index 100% rename from meta-phytium/recipes-phytium/libcper/arm-libcper.bb rename to meta-phytium/recipes-phytium/ras/libcper-arm.bb diff --git a/meta-phytium/recipes-phytium/libcper/arm-libcper/0001-b64-Adjusted-the-code.patch b/meta-phytium/recipes-phytium/ras/libcper-arm/0001-b64-Adjusted-the-code.patch similarity index 47% rename from meta-phytium/recipes-phytium/libcper/arm-libcper/0001-b64-Adjusted-the-code.patch rename to meta-phytium/recipes-phytium/ras/libcper-arm/0001-b64-Adjusted-the-code.patch index 56a9c4c831..d5f1f170ec 100644 --- a/meta-phytium/recipes-phytium/libcper/arm-libcper/0001-b64-Adjusted-the-code.patch +++ b/meta-phytium/recipes-phytium/ras/libcper-arm/0001-b64-Adjusted-the-code.patch @@ -1,4 +1,4 @@ -From fbab5cbed70b89f66e5f133608ec7ccda388cd72 Mon Sep 17 00:00:00 2001 +From d800614b646f669eb2a2c4045ebd2f5b08f6177f Mon Sep 17 00:00:00 2001 From: Tian Jingzai Date: Mon, 8 Apr 2024 10:58:45 +0800 Subject: [PATCH 1/2] b64: Adjusted the code @@ -8,85 +8,76 @@ Added B64 code and synchronously updated CMakeLists.txt. Signed-off-by: Tian Jingzai Change-Id: If103cde24d4ad459030a059f4edab1e797c06795 --- - CMakeLists.txt | 94 +++----------- - b64.h | 84 +++++++++++++ - buffer.c | 33 +++++ - cli-app/cper-convert.c | 6 +- - common-utils.c | 2 +- - cper-parse.c | 6 +- - cper-parse.h | 11 +- - cper-parse.i | 2 +- - cper-utils.c | 6 +- - decode.c | 117 ++++++++++++++++++ - docs/GeneratorExtensions.md | 4 +- - docs/OEMExtensions.md | 8 +- - encode.c | 93 ++++++++++++++ - generator/cper-generate-cli.c | 4 +- - generator/cper-generate.c | 4 +- - generator/gen-utils.c | 4 +- - generator/sections/gen-section-arm.c | 6 +- - generator/sections/gen-section-ccix-per.c | 4 +- - .../sections/gen-section-cxl-component.c | 4 +- - generator/sections/gen-section-cxl-protocol.c | 6 +- - generator/sections/gen-section-dmar.c | 8 +- - generator/sections/gen-section-firmware.c | 4 +- - generator/sections/gen-section-generic.c | 4 +- - generator/sections/gen-section-ia32x64.c | 2 +- - generator/sections/gen-section-memory.c | 6 +- - generator/sections/gen-section-pci-bus.c | 4 +- - generator/sections/gen-section-pci-dev.c | 6 +- - generator/sections/gen-section-pcie.c | 4 +- - generator/sections/gen-section.c | 2 +- - ir-parse.c | 4 +- - json-schema.c | 4 +- - json-schema.h | 2 +- - sections/cper-section-arm.c | 6 +- - sections/cper-section-arm.h | 2 +- - sections/cper-section-ccix-per.c | 6 +- - sections/cper-section-ccix-per.h | 2 +- - sections/cper-section-cxl-component.c | 6 +- - sections/cper-section-cxl-component.h | 2 +- - sections/cper-section-cxl-protocol.c | 6 +- - sections/cper-section-cxl-protocol.h | 2 +- - sections/cper-section-dmar-generic.c | 4 +- - sections/cper-section-dmar-generic.h | 2 +- - sections/cper-section-dmar-iommu.c | 6 +- - sections/cper-section-dmar-iommu.h | 2 +- - sections/cper-section-dmar-vtd.c | 6 +- - sections/cper-section-dmar-vtd.h | 2 +- - sections/cper-section-firmware.c | 4 +- - sections/cper-section-firmware.h | 2 +- - sections/cper-section-generic.c | 4 +- - sections/cper-section-generic.h | 2 +- - sections/cper-section-ia32x64.c | 6 +- - sections/cper-section-ia32x64.h | 2 +- - sections/cper-section-ipf.c | 4 +- - sections/cper-section-ipf.h | 2 +- - sections/cper-section-memory.c | 4 +- - sections/cper-section-memory.h | 2 +- - sections/cper-section-pci-bus.c | 4 +- - sections/cper-section-pci-bus.h | 2 +- - sections/cper-section-pci-dev.c | 4 +- - sections/cper-section-pci-dev.h | 2 +- - sections/cper-section-pcie.c | 6 +- - sections/cper-section-pcie.h | 2 +- - sections/cper-section.c | 2 +- - sections/cper-section.h | 2 +- - .../document/cper-json-specification.tex | 8 +- - .../json/sections/cper-cxl-protocol.json | 30 ++--- - tests/ir-tests.cpp | 4 +- - tests/test-utils.cpp | 2 +- - 68 files changed, 490 insertions(+), 212 deletions(-) - create mode 100644 b64.h - create mode 100644 buffer.c - create mode 100644 decode.c - create mode 100644 encode.c + CMakeLists.txt | 76 +++-------------- + b64c/.travis.yml | 13 +++ + b64c/CMakeLists.txt | 13 +++ + b64c/LICENSE | 21 +++++ + b64c/README.md | 84 ++++++++++++++++++ + b64c/b64.h | 84 ++++++++++++++++++ + b64c/buffer.c | 33 ++++++++ + b64c/clib.json | 9 ++ + b64c/decode.c | 117 ++++++++++++++++++++++++++ + b64c/encode.c | 93 ++++++++++++++++++++ + b64c/package.json | 9 ++ + b64c/test.c | 63 ++++++++++++++ + cli-app/cper-convert.c | 2 +- + cper-parse.c | 2 +- + cper-parse.h | 4 +- + cper-utils.c | 2 +- + docs/OEMExtensions.md | 4 +- + ir-parse.c | 2 +- + json-schema.c | 2 +- + json-schema.h | 2 +- + sections/cper-section-arm.c | 2 +- + sections/cper-section-arm.h | 2 +- + sections/cper-section-ccix-per.c | 2 +- + sections/cper-section-ccix-per.h | 2 +- + sections/cper-section-cxl-component.c | 2 +- + sections/cper-section-cxl-component.h | 2 +- + sections/cper-section-cxl-protocol.c | 2 +- + sections/cper-section-cxl-protocol.h | 2 +- + sections/cper-section-dmar-generic.c | 2 +- + sections/cper-section-dmar-generic.h | 2 +- + sections/cper-section-dmar-iommu.c | 2 +- + sections/cper-section-dmar-iommu.h | 2 +- + sections/cper-section-dmar-vtd.c | 2 +- + sections/cper-section-dmar-vtd.h | 2 +- + sections/cper-section-firmware.c | 2 +- + sections/cper-section-firmware.h | 2 +- + sections/cper-section-generic.c | 2 +- + sections/cper-section-generic.h | 2 +- + sections/cper-section-ia32x64.c | 2 +- + sections/cper-section-ia32x64.h | 2 +- + sections/cper-section-ipf.c | 2 +- + sections/cper-section-ipf.h | 2 +- + sections/cper-section-memory.c | 2 +- + sections/cper-section-memory.h | 2 +- + sections/cper-section-pci-bus.c | 2 +- + sections/cper-section-pci-bus.h | 2 +- + sections/cper-section-pci-dev.c | 2 +- + sections/cper-section-pci-dev.h | 2 +- + sections/cper-section-pcie.c | 2 +- + sections/cper-section-pcie.h | 2 +- + sections/cper-section.h | 2 +- + tests/ir-tests.cpp | 2 +- + 52 files changed, 591 insertions(+), 108 deletions(-) + create mode 100644 b64c/.travis.yml + create mode 100644 b64c/CMakeLists.txt + create mode 100644 b64c/LICENSE + create mode 100644 b64c/README.md + create mode 100644 b64c/b64.h + create mode 100644 b64c/buffer.c + create mode 100644 b64c/clib.json + create mode 100644 b64c/decode.c + create mode 100644 b64c/encode.c + create mode 100644 b64c/package.json + create mode 100644 b64c/test.c diff --git a/CMakeLists.txt b/CMakeLists.txt -index 86b3b81..b5cff63 100644 +index 86b3b81..95b5a00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -1,13 +1,5 @@ +@@ -1,16 +1,5 @@ cmake_minimum_required(VERSION 3.10) project(CPERParse) -include(FetchContent) @@ -97,10 +88,13 @@ index 86b3b81..b5cff63 100644 - find_package(PythonLibs 3 REQUIRED) - find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} REQUIRED) -endif() +- +-# GoogleTest requires at least C++14. +-set(CMAKE_CXX_STANDARD 14) - # GoogleTest requires at least C++14. - set(CMAKE_CXX_STANDARD 14) -@@ -18,91 +10,43 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + # Output into subdirectories /lib and /bin. + set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) +@@ -18,33 +7,11 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -131,36 +125,11 @@ index 86b3b81..b5cff63 100644 file(GLOB EDKSources edk/*.c) file(GLOB GeneratorSectionSources generator/sections/*.c) -add_library(cper-parse STATIC -- cper-parse.c -- ir-parse.c -- cper-utils.c -+file(GLOB B64Sources buffer.c decode.c encode.c) -+add_library(cper-parse STATIC -+ cper-parse.c -+ ir-parse.c -+ cper-utils.c - common-utils.c -- json-schema.c -- ${SectionSources} -+ json-schema.c -+ ${SectionSources} - ${EDKSources} -+ ${B64Sources} - ) --add_library(cper-generate STATIC -- generator/cper-generate.c -- generator/gen-utils.c -+add_library(cper-generate STATIC -+ generator/cper-generate.c -+ generator/gen-utils.c - common-utils.c -- ${GeneratorSectionSources} -+ ${GeneratorSectionSources} - ${EDKSources} - ) - add_executable(cper-convert cli-app/cper-convert.c) --add_executable(cper-generate-cli -+add_executable(cper-generate-cli ++add_library(cper-parse SHARED + cper-parse.c + ir-parse.c + cper-utils.c +@@ -65,44 +32,21 @@ add_executable(cper-generate-cli generator/cper-generate-cli.c ${EDKSources} ) @@ -173,11 +142,12 @@ index 86b3b81..b5cff63 100644 - ${GeneratorSectionSources} - ${EDKSources} -) ++add_subdirectory(b64c) # Linking, compile & property setup for targets. -target_link_libraries(cper-tests cper-parse json-c GTest::gtest_main) --target_link_libraries(cper-parse json-c b64c) -+target_link_libraries(cper-parse json-c) ++target_include_directories(cper-parse PRIVATE b64c) + target_link_libraries(cper-parse json-c b64c) target_link_libraries(cper-convert cper-parse) target_link_libraries(cper-generate-cli cper-generate) target_compile_options(cper-parse PRIVATE -Wno-address-of-packed-member) @@ -190,7 +160,12 @@ index 86b3b81..b5cff63 100644 - -# Add tests to GoogleTest. -#gtest_discover_tests(cper-tests WORKING_DIRECTORY bin/) -- ++install (TARGETS cper-convert RUNTIME DESTINATION bin) ++install (TARGETS cper-generate-cli RUNTIME DESTINATION bin) ++install (TARGETS cper-parse LIBRARY DESTINATION lib) ++install (TARGETS b64c LIBRARY DESTINATION lib) ++install (FILES cper-parse.h DESTINATION include) + -# Generate Python bindings with SWIG. -if (BUILD_PYTHON_LIBS) - include_directories(cperparse_pylib ${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) @@ -207,16 +182,169 @@ index 86b3b81..b5cff63 100644 - ) -endif() \ No newline at end of file -+install (TARGETS cper-convert RUNTIME DESTINATION bin) -+install (TARGETS cper-generate-cli RUNTIME DESTINATION bin) -+install (TARGETS cper-parse LIBRARY DESTINATION lib -+ ARCHIVE DESTINATION lib) -+install (FILES cper-parse.h DESTINATION include) -diff --git a/b64.h b/b64.h ++set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector") ++set_target_properties(cper-parse PROPERTIES VERSION 0.85) +diff --git a/b64c/.travis.yml b/b64c/.travis.yml +new file mode 100644 +index 0000000..58076d4 +--- /dev/null ++++ b/b64c/.travis.yml +@@ -0,0 +1,13 @@ ++language: c ++before_install: ++ - sudo apt-get update ++ - sudo apt-get install libcurl4-gnutls-dev valgrind -qq ++ - git clone https://github.com/clibs/clib.git /tmp/clib ++ - sudo make -C /tmp/clib install ++install: clib install --dev ++script: ++ - make test ++ - valgrind --leak-check=full --error-exitcode=1 ./test ++ - make clean ++ - make test USE_CUSTOM_MALLOC=true ++ - valgrind --leak-check=full --error-exitcode=1 ./test +diff --git a/b64c/CMakeLists.txt b/b64c/CMakeLists.txt +new file mode 100644 +index 0000000..b793811 +--- /dev/null ++++ b/b64c/CMakeLists.txt +@@ -0,0 +1,13 @@ ++cmake_minimum_required(VERSION 3.14) ++ ++set(PROJECT_NAME b64c) ++project(${PROJECT_NAME} LANGUAGES C) ++ ++add_library(${PROJECT_NAME} SHARED ++ buffer.c ++ decode.c ++ encode.c ++) ++ ++target_include_directories(${PROJECT_NAME} INTERFACE .) ++set_target_properties(b64c PROPERTIES VERSION 0.85) +diff --git a/b64c/LICENSE b/b64c/LICENSE +new file mode 100644 +index 0000000..78b34d5 +--- /dev/null ++++ b/b64c/LICENSE +@@ -0,0 +1,21 @@ ++The MIT License (MIT) ++ ++Copyright (c) 2014 Little Star Media, Inc. ++ ++Permission is hereby granted, free of charge, to any person obtaining a copy ++of this software and associated documentation files (the "Software"), to deal ++in the Software without restriction, including without limitation the rights ++to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++copies of the Software, and to permit persons to whom the Software is ++furnished to do so, subject to the following conditions: ++ ++The above copyright notice and this permission notice shall be included in all ++copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++SOFTWARE. +\ No newline at end of file +diff --git a/b64c/README.md b/b64c/README.md +new file mode 100644 +index 0000000..0555c0d +--- /dev/null ++++ b/b64c/README.md +@@ -0,0 +1,84 @@ ++b64.c ++===== ++ ++Base64 encode/decode ++ ++## install ++ ++```sh ++$ clib install jwerle/b64.c ++``` ++ ++## usage ++ ++```c ++#include ++``` ++ ++or ++ ++```c ++#include ++``` ++ ++## example ++ ++```c ++#include ++#include ++#include ++#include "b64.h" ++ ++int ++main (void) { ++ unsigned char *str = "brian the monkey and bradley the kinkajou are friends"; ++ char *enc = b64_encode(str, strlen(str)); ++ ++ printf("%s\n", enc); // YnJpYW4gdGhlIG1vbmtleSBhbmQgYnJhZGxleSB0aGUga2lua2Fqb3UgYXJlIGZyaWVuZHM= ++ ++ char *dec = b64_decode(enc, strlen(enc)); ++ ++ printf("%s\n", dec); // brian the monkey and bradley the kinkajou are friends ++ free(enc); ++ free(dec); ++ return 0; ++} ++``` ++ ++## api ++ ++Base64 index table ++ ++```c ++ ++static const char b64_table[] = { ++ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', ++ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', ++ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', ++ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', ++ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', ++ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', ++ 'w', 'x', 'y', 'z', '0', '1', '2', '3', ++ '4', '5', '6', '7', '8', '9', '+', '/' ++}; ++``` ++ ++Encode `unsigned char *` source with `size_t` size. ++Returns a `char *` base64 encoded string ++ ++```c ++char * ++b64_encode (const unsigned char *, size_t); ++``` ++ ++Decode `char *` source with `size_t` size. ++Returns a `unsigned char *` base64 decoded string ++ ++```c ++unsigned char * ++b64_decode (const char *, size_t); ++``` ++ ++## license ++ ++MIT +diff --git a/b64c/b64.h b/b64c/b64.h new file mode 100644 index 0000000..e39d746 --- /dev/null -+++ b/b64.h ++++ b/b64c/b64.h @@ -0,0 +1,84 @@ + +/** @@ -302,11 +430,11 @@ index 0000000..e39d746 +#endif + +#endif -diff --git a/buffer.c b/buffer.c +diff --git a/b64c/buffer.c b/b64c/buffer.c new file mode 100644 index 0000000..2d684ee --- /dev/null -+++ b/buffer.c ++++ b/b64c/buffer.c @@ -0,0 +1,33 @@ +#include +#include @@ -341,125 +469,26 @@ index 0000000..2d684ee + + return 0; +} -diff --git a/cli-app/cper-convert.c b/cli-app/cper-convert.c -index 86a6d6f..05b2db4 100644 ---- a/cli-app/cper-convert.c -+++ b/cli-app/cper-convert.c -@@ -1,7 +1,7 @@ - /** - * A user-space application linking to the CPER-JSON conversion library which allows for easy -- * conversion between CPER and CPER-JSON formats. -- * -+ * conversion between CPER and CPER-JSON formats. -+ * - * Author: Lawrence.Tang@arm.com - **/ - -@@ -9,7 +9,7 @@ - #include - #include - #include --#include -+#include - #include "../cper-parse.h" - #include "../json-schema.h" - -diff --git a/common-utils.c b/common-utils.c -index 38c4317..9209a6f 100644 ---- a/common-utils.c -+++ b/common-utils.c -@@ -1,7 +1,7 @@ - /** - * Describes common utility functions shared between CPER projects within this repository. - * No functions here depend on json-c or b64.c. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - -diff --git a/cper-parse.c b/cper-parse.c -index e66ed28..3548d58 100644 ---- a/cper-parse.c -+++ b/cper-parse.c -@@ -1,12 +1,12 @@ - /** -- * Describes high level functions for converting an entire CPER log, and functions for parsing -+ * Describes high level functions for converting an entire CPER log, and functions for parsing - * CPER headers and section descriptions into an intermediate JSON format. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - - #include --#include -+#include - #include "b64.h" - #include "edk/Cper.h" - #include "cper-parse.h" -diff --git a/cper-parse.h b/cper-parse.h -index 40c2bf4..81d5d88 100644 ---- a/cper-parse.h -+++ b/cper-parse.h -@@ -1,6 +1,7 @@ - #ifndef CPER_PARSE_H - #define CPER_PARSE_H --#include -+#include -+#include - - #define CPER_HEADER_VALID_BITFIELD_NAMES (const char*[]) {"platformIDValid", "timestampValid", "partitionIDValid"} - #define CPER_SECTION_DESCRIPTOR_VALID_BITFIELD_NAMES (const char*[]) {"fruIDValid", "fruStringValid"} -@@ -15,4 +16,10 @@ json_object* cper_single_section_to_ir(FILE* cper_section_file); - void ir_to_cper(json_object* ir, FILE* out); - void ir_single_section_to_cper(json_object* ir, FILE* out); - --#endif -\ No newline at end of file -+char * -+b64_encode (const unsigned char *src, size_t len); -+unsigned char * -+b64_decode (const char *src, size_t len); -+unsigned char * -+b64_decode_ex (const char *src, size_t len, size_t *decsize); -+#endif -diff --git a/cper-parse.i b/cper-parse.i -index 7ba1da4..a5d042f 100644 ---- a/cper-parse.i -+++ b/cper-parse.i -@@ -1,7 +1,7 @@ - %module cperparse - %{ - #include "cper-parse.h" -- #include -+ #include - #include - %} - -diff --git a/cper-utils.c b/cper-utils.c -index 8fe3a2e..d10e400 100644 ---- a/cper-utils.c -+++ b/cper-utils.c -@@ -1,11 +1,11 @@ - /** -- * Describes utility functions for parsing CPER into JSON IR. -- * -+ * Describes utility functions for parsing CPER into JSON IR. -+ * - * Author: Lawrence.Tang@arm.com - **/ - - #include --#include -+#include - #include "edk/Cper.h" - #include "cper-utils.h" - -diff --git a/decode.c b/decode.c +diff --git a/b64c/clib.json b/b64c/clib.json +new file mode 100644 +index 0000000..ed7e045 +--- /dev/null ++++ b/b64c/clib.json +@@ -0,0 +1,9 @@ ++{ ++ "name": "b64", ++ "repo": "jwerle/b64.c", ++ "version": "0.1.0", ++ "description": "Base64 encode/decode", ++ "keywords": ["base", "64", "crypto"], ++ "src": ["b64.h", "encode.c", "decode.c", "buffer.c"], ++ "development": { "jwerle/libok": "*" } ++} +diff --git a/b64c/decode.c b/b64c/decode.c new file mode 100644 index 0000000..38093bb --- /dev/null -+++ b/decode.c ++++ b/b64c/decode.c @@ -0,0 +1,117 @@ + +/** @@ -578,69 +607,11 @@ index 0000000..38093bb + + return (unsigned char*) decbuf.ptr; +} -diff --git a/docs/GeneratorExtensions.md b/docs/GeneratorExtensions.md -index 0664b8f..7c89f83 100644 ---- a/docs/GeneratorExtensions.md -+++ b/docs/GeneratorExtensions.md -@@ -17,7 +17,7 @@ size_t generate_section_myvendor(void** location); - ```c - /** - * Functions for generating pseudo-random MyVendor error sections. -- * -+ * - * Author: author@example.com - **/ - -@@ -54,7 +54,7 @@ Now that a GUID and generation function are created for our section, we can fina - ```c - /** - * Describes available section generators to the CPER generator. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - #include "gen-section.h" -diff --git a/docs/OEMExtensions.md b/docs/OEMExtensions.md -index 68bc1c3..7e53d96 100644 ---- a/docs/OEMExtensions.md -+++ b/docs/OEMExtensions.md -@@ -10,7 +10,7 @@ For the purposes of example here, we will create a fake CPER section, "myVendorS - #ifndef CPER_SECTION_MYVENDOR - #define CPER_SECTION_MYVENDOR - --#include -+#include - #include "../edk/Cper.h" - - json_object* cper_section_myvendor_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor); -@@ -24,11 +24,11 @@ void ir_section_myvendor_to_cper(json_object* section, FILE* out); - /** - * Describes functions for converting MyVendor sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: author@example.com - **/ - #include --#include -+#include - #include "../edk/Cper.h" - #include "cper-section-ccix-per.h" - -@@ -76,7 +76,7 @@ Open `sections/cper-section.c` and add your definition to the `section_definitio - ```c - /** - * Describes available sections to the CPER parser. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - #include "../edk/Cper.h" -diff --git a/encode.c b/encode.c +diff --git a/b64c/encode.c b/b64c/encode.c new file mode 100644 index 0000000..68e7924 --- /dev/null -+++ b/encode.c ++++ b/b64c/encode.c @@ -0,0 +1,93 @@ + +/** @@ -735,363 +706,175 @@ index 0000000..68e7924 + + return encbuf.ptr; +} -diff --git a/generator/cper-generate-cli.c b/generator/cper-generate-cli.c -index f5b0c85..b326930 100644 ---- a/generator/cper-generate-cli.c -+++ b/generator/cper-generate-cli.c -@@ -1,6 +1,6 @@ - /** -- * A user-space application for generating pseudo-random specification compliant CPER records. -- * -+ * A user-space application for generating pseudo-random specification compliant CPER records. -+ * - * Author: Lawrence.Tang@arm.com - **/ - -diff --git a/generator/cper-generate.c b/generator/cper-generate.c -index c8819f6..c4c59e0 100644 ---- a/generator/cper-generate.c -+++ b/generator/cper-generate.c -@@ -1,6 +1,6 @@ - /** -- * Describes functions for generating pseudo-random specification compliant CPER records. -- * -+ * Describes functions for generating pseudo-random specification compliant CPER records. -+ * - * Author: Lawrence.Tang@arm.com - **/ - -diff --git a/generator/gen-utils.c b/generator/gen-utils.c -index c986b09..ac443ae 100644 ---- a/generator/gen-utils.c -+++ b/generator/gen-utils.c -@@ -1,6 +1,6 @@ - /** -- * Utility functions to assist in generating pseudo-random CPER sections. -- * -+ * Utility functions to assist in generating pseudo-random CPER sections. -+ * - * Author: Lawrence.Tang@arm.com - **/ - #include -diff --git a/generator/sections/gen-section-arm.c b/generator/sections/gen-section-arm.c -index 7ec94a7..6efa791 100644 ---- a/generator/sections/gen-section-arm.c -+++ b/generator/sections/gen-section-arm.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER ARM processor sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - -@@ -47,7 +47,7 @@ size_t generate_section_arm(void** location) - *(info_nums + 1) = context_structure_num; - UINT32* section_length = (UINT32*)(section + 8); - *section_length = total_len; -- -+ - //Error affinity. - *(section + 12) = rand() % 4; - -@@ -153,7 +153,7 @@ size_t generate_arm_context_info(void** location) - case 5: - reg_size = 136; - break; -- -+ - //AARCH64 EL2 - case 6: - reg_size = 120; -diff --git a/generator/sections/gen-section-ccix-per.c b/generator/sections/gen-section-ccix-per.c -index c820d72..7b56e9f 100644 ---- a/generator/sections/gen-section-ccix-per.c -+++ b/generator/sections/gen-section-ccix-per.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CCIX PER error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - -@@ -20,7 +20,7 @@ size_t generate_section_ccix_per(void** location) - //Create random bytes. - int size = 16 + log_len; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - UINT64* validation = (UINT64*)(bytes + 4); - *validation &= 0b111; //Validation bits 3-63. -diff --git a/generator/sections/gen-section-cxl-component.c b/generator/sections/gen-section-cxl-component.c -index 5fb6789..12b061a 100644 ---- a/generator/sections/gen-section-cxl-component.c -+++ b/generator/sections/gen-section-cxl-component.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CXL component error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - -@@ -31,7 +31,7 @@ size_t generate_section_cxl_component(void** location) - //Set expected values. - UINT32* length = (UINT32*)bytes; - *length = size; -- -+ - //Set return values, exit. - *location = bytes; - return size; -diff --git a/generator/sections/gen-section-cxl-protocol.c b/generator/sections/gen-section-cxl-protocol.c -index 71a1105..2e05455 100644 ---- a/generator/sections/gen-section-cxl-protocol.c -+++ b/generator/sections/gen-section-cxl-protocol.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CXL protocol error sections. -- * +diff --git a/b64c/package.json b/b64c/package.json +new file mode 100644 +index 0000000..ed7e045 +--- /dev/null ++++ b/b64c/package.json +@@ -0,0 +1,9 @@ ++{ ++ "name": "b64", ++ "repo": "jwerle/b64.c", ++ "version": "0.1.0", ++ "description": "Base64 encode/decode", ++ "keywords": ["base", "64", "crypto"], ++ "src": ["b64.h", "encode.c", "decode.c", "buffer.c"], ++ "development": { "jwerle/libok": "*" } ++} +diff --git a/b64c/test.c b/b64c/test.c +new file mode 100644 +index 0000000..50aab9c +--- /dev/null ++++ b/b64c/test.c +@@ -0,0 +1,63 @@ ++ ++/** ++ * `test.c' - b64 + * - * Author: Lawrence.Tang@arm.com - **/ ++ * copyright (c) 2014 joseph werle ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "b64.h" ++ ++#define S(x) # x ++#define t(m, a, b) ({ \ ++ char tmp[1024]; \ ++ sprintf(tmp, "%s(%s) = %s", S(m), S(a), S(b)); \ ++ char *r = (char *) m(a, strlen((char *) a)); \ ++ assert(0 == strcmp(b, r)); \ ++ free(r); \ ++ ok(tmp); \ ++}) ++ ++void* custom_malloc(size_t size){ ++ if (size == 0){ ++ /* On some systems malloc doesn't allow for size = 0 */ ++ return NULL; ++ } ++ return malloc(size); ++} ++ ++void* custom_realloc(void* ptr, size_t size){ ++ return realloc(ptr, size); ++} ++ ++int ++main (void) { ++ ++ // encode ++ { ++ t(b64_encode, (const unsigned char *) "bradley", "YnJhZGxleQ=="); ++ t(b64_encode, (const unsigned char *) "kinkajou", "a2lua2Fqb3U="); ++ t(b64_encode, (const unsigned char *) "vino", "dmlubw=="); ++ t(b64_encode, ++ (const unsigned char *) "brian the monkey and bradley the kinkajou are friends", ++ "YnJpYW4gdGhlIG1vbmtleSBhbmQgYnJhZGxleSB0aGUga2lua2Fqb3UgYXJlIGZyaWVuZHM="); ++ } ++ ++ // decode ++ { ++ t(b64_decode, "Y2FzaWxsZXJv", "casillero"); ++ t(b64_decode, "aGF4", "hax"); ++ t(b64_decode, "bW9ua2V5cyBhbmQgZG9ncw==", "monkeys and dogs"); ++ t(b64_decode, ++ "dGhlIGtpbmtham91IGFuZCBtb25rZXkgZm91Z2h0IG92ZXIgdGhlIGJhbmFuYQ==", ++ "the kinkajou and monkey fought over the banana"); ++ } ++ ++ ok_done(); ++ return 0; ++} +diff --git a/cli-app/cper-convert.c b/cli-app/cper-convert.c +index 86a6d6f..fd506bb 100644 +--- a/cli-app/cper-convert.c ++++ b/cli-app/cper-convert.c +@@ -9,7 +9,7 @@ + #include + #include + #include +-#include ++#include + #include "../cper-parse.h" + #include "../json-schema.h" -@@ -25,7 +25,7 @@ size_t generate_section_cxl_protocol(void** location) - //Set CXL agent type. - int cxl_agent_type = rand() % 2; - *(bytes + 8) = cxl_agent_type; -- -+ - //Set reserved areas to zero. - UINT64* validation = (UINT64*)bytes; - *validation &= 0b111111; //Validation bits 6-63. -@@ -38,7 +38,7 @@ size_t generate_section_cxl_protocol(void** location) - for (int i=0; i<3; i++) - *(bytes + 21 + i) = 0; //CXL agent address bytes 5-7. - } -- -+ - *(bytes + 34) &= ~0b111; //Device ID byte 10 bits 0-2. - UINT32* reserved = (UINT32*)(bytes + 36); - *reserved = 0; //Device ID bytes 12-15. -diff --git a/generator/sections/gen-section-dmar.c b/generator/sections/gen-section-dmar.c -index 66cc70a..15946ff 100644 ---- a/generator/sections/gen-section-dmar.c -+++ b/generator/sections/gen-section-dmar.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER DMAr error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com +diff --git a/cper-parse.c b/cper-parse.c +index e66ed28..cf77711 100644 +--- a/cper-parse.c ++++ b/cper-parse.c +@@ -6,7 +6,7 @@ **/ -@@ -16,7 +16,7 @@ size_t generate_section_dmar_generic(void** location) - //Create random bytes. - int size = 32; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - UINT64* reserved = (UINT64*)(bytes + 16); - *reserved = 0; -@@ -40,7 +40,7 @@ size_t generate_section_dmar_vtd(void** location) - //Create random bytes. - int size = 144; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - for (int i=0; i<12; i++) - *(bytes + 36 + i) = 0; //Reserved bytes 36-47. -@@ -63,7 +63,7 @@ size_t generate_section_dmar_iommu(void** location) - //Create random bytes. - int size = 144; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - for (int i=0; i<7; i++) - *(bytes + 1 + i) = 0; //Reserved bytes 1 to 7. -diff --git a/generator/sections/gen-section-firmware.c b/generator/sections/gen-section-firmware.c -index 7ba93ee..0213eb6 100644 ---- a/generator/sections/gen-section-firmware.c -+++ b/generator/sections/gen-section-firmware.c + #include +-#include ++#include + #include "b64.h" + #include "edk/Cper.h" + #include "cper-parse.h" +diff --git a/cper-parse.h b/cper-parse.h +index 40c2bf4..c278be7 100644 +--- a/cper-parse.h ++++ b/cper-parse.h @@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER firmware error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ + #ifndef CPER_PARSE_H + #define CPER_PARSE_H +-#include ++#include -@@ -16,7 +16,7 @@ size_t generate_section_firmware(void** location) - //Create random bytes. - int size = 32; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - for (int i=0; i<6; i++) - *(bytes + 2 + i) = 0; //Reserved bytes 2-7. -diff --git a/generator/sections/gen-section-generic.c b/generator/sections/gen-section-generic.c -index e9a2ea0..9355c21 100644 ---- a/generator/sections/gen-section-generic.c -+++ b/generator/sections/gen-section-generic.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER generic processor sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ + #define CPER_HEADER_VALID_BITFIELD_NAMES (const char*[]) {"platformIDValid", "timestampValid", "partitionIDValid"} + #define CPER_SECTION_DESCRIPTOR_VALID_BITFIELD_NAMES (const char*[]) {"fruIDValid", "fruStringValid"} +@@ -15,4 +15,4 @@ json_object* cper_single_section_to_ir(FILE* cper_section_file); + void ir_to_cper(json_object* ir, FILE* out); + void ir_single_section_to_cper(json_object* ir, FILE* out); -@@ -21,7 +21,7 @@ size_t generate_section_generic(void** location) - *((UINT64*)start_byte) &= 0xFFF; - *(start_byte + 12) &= 0b111; - *((UINT16*)(start_byte + 14)) = 0x0; -- -+ - //Ensure CPU brand string does not terminate early. - for (int i=0; i<128; i++) - { -diff --git a/generator/sections/gen-section-ia32x64.c b/generator/sections/gen-section-ia32x64.c -index a01d2b7..8d2cfcb 100644 ---- a/generator/sections/gen-section-ia32x64.c -+++ b/generator/sections/gen-section-ia32x64.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER IA32/x64 sections. -- * -+ * - * Author: Lawrence.Tang@arm.com +-#endif +\ No newline at end of file ++#endif +diff --git a/cper-utils.c b/cper-utils.c +index 8fe3a2e..dd307a1 100644 +--- a/cper-utils.c ++++ b/cper-utils.c +@@ -5,7 +5,7 @@ **/ -diff --git a/generator/sections/gen-section-memory.c b/generator/sections/gen-section-memory.c -index 9d405a4..f3f4bfa 100644 ---- a/generator/sections/gen-section-memory.c -+++ b/generator/sections/gen-section-memory.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER platform memory error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ + #include +-#include ++#include + #include "edk/Cper.h" + #include "cper-utils.h" -@@ -16,7 +16,7 @@ size_t generate_section_memory(void** location) - //Create random bytes. - int size = 80; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - UINT64* validation = (UINT64*)bytes; - *validation &= 0x2FFFFF; //Validation 22-63 -@@ -40,7 +40,7 @@ size_t generate_section_memory2(void** location) - //Create random bytes. - int size = 96; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - UINT64* validation = (UINT64*)bytes; - *validation &= 0x2FFFFF; //Validation 22-63 -diff --git a/generator/sections/gen-section-pci-bus.c b/generator/sections/gen-section-pci-bus.c -index 1aee19a..9c29cc0 100644 ---- a/generator/sections/gen-section-pci-bus.c -+++ b/generator/sections/gen-section-pci-bus.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER PCI/PCI-X bus error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ +diff --git a/docs/OEMExtensions.md b/docs/OEMExtensions.md +index 68bc1c3..de36c1d 100644 +--- a/docs/OEMExtensions.md ++++ b/docs/OEMExtensions.md +@@ -10,7 +10,7 @@ For the purposes of example here, we will create a fake CPER section, "myVendorS + #ifndef CPER_SECTION_MYVENDOR + #define CPER_SECTION_MYVENDOR -@@ -16,7 +16,7 @@ size_t generate_section_pci_bus(void** location) - //Create random bytes. - int size = 72; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - UINT64* validation = (UINT64*)bytes; - *validation &= 0x1FF; //Validation 9-63 -diff --git a/generator/sections/gen-section-pci-dev.c b/generator/sections/gen-section-pci-dev.c -index 339f98c..b7f78e1 100644 ---- a/generator/sections/gen-section-pci-dev.c -+++ b/generator/sections/gen-section-pci-dev.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER PCI component error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ +-#include ++#include + #include "../edk/Cper.h" -@@ -21,13 +21,13 @@ size_t generate_section_pci_dev(void** location) - //Create random bytes. - int size = 40 + (num_registers * 16); - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - UINT64* validation = (UINT64*)bytes; - *validation &= 0b11111; //Validation 5-63 - for (int i=0; i<5; i++) - *(bytes + 27 + i) = 0; //Bytes 11-15 of ID info. -- -+ - //Set expected values. - UINT32* memory_number_field = (UINT32*)(bytes + 32); - UINT32* io_number_field = (UINT32*)(bytes + 36); -diff --git a/generator/sections/gen-section-pcie.c b/generator/sections/gen-section-pcie.c -index aa1be6b..ddc9664 100644 ---- a/generator/sections/gen-section-pcie.c -+++ b/generator/sections/gen-section-pcie.c -@@ -1,6 +1,6 @@ - /** - * Functions for generating pseudo-random CPER PCIe error sections. -- * -+ * - * Author: Lawrence.Tang@arm.com + json_object* cper_section_myvendor_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor); +@@ -28,7 +28,7 @@ void ir_section_myvendor_to_cper(json_object* section, FILE* out); + * Author: author@example.com **/ + #include +-#include ++#include + #include "../edk/Cper.h" + #include "cper-section-ccix-per.h" -@@ -18,7 +18,7 @@ size_t generate_section_pcie(void** location) - //Create random bytes. - int size = 208; - UINT8* bytes = generate_random_bytes(size); -- -+ - //Set reserved areas to zero. - UINT64* validation = (UINT64*)bytes; - *validation &= 0xFF; //Validation 8-63 -diff --git a/generator/sections/gen-section.c b/generator/sections/gen-section.c -index 012f88f..3713a43 100644 ---- a/generator/sections/gen-section.c -+++ b/generator/sections/gen-section.c -@@ -1,6 +1,6 @@ - /** - * Describes available section generators to the CPER generator. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - #include "gen-section.h" diff --git a/ir-parse.c b/ir-parse.c -index 35c35c8..e2e19c7 100644 +index 35c35c8..87c423c 100644 --- a/ir-parse.c +++ b/ir-parse.c -@@ -1,12 +1,12 @@ - /** - * Describes functions for parsing JSON IR CPER data into binary CPER format. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ +@@ -6,7 +6,7 @@ #include #include @@ -1101,18 +884,9 @@ index 35c35c8..e2e19c7 100644 #include "edk/Cper.h" #include "cper-parse.h" diff --git a/json-schema.c b/json-schema.c -index 16ddef5..79febbb 100644 +index 16ddef5..1e143f2 100644 --- a/json-schema.c +++ b/json-schema.c -@@ -1,7 +1,7 @@ - /** - * A very basic, non-complete implementation of a validator for the JSON Schema specification, - * for validating CPER-JSON. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - @@ -11,7 +11,7 @@ #include #include @@ -1136,26 +910,18 @@ index 02e45c6..3299c1c 100644 #define JSON_SCHEMA_VERSION "https://json-schema.org/draft/2020-12/schema" #define JSON_ERROR_MSG_MAX_LEN 512 diff --git a/sections/cper-section-arm.c b/sections/cper-section-arm.c -index 6537f40..858a10e 100644 +index 6537f40..f10c874 100644 --- a/sections/cper-section-arm.c +++ b/sections/cper-section-arm.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting ARM CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-arm.h" diff --git a/sections/cper-section-arm.h b/sections/cper-section-arm.h index 1468405..2d405e3 100644 --- a/sections/cper-section-arm.h @@ -1170,26 +936,18 @@ index 1468405..2d405e3 100644 #define ARM_ERROR_VALID_BITFIELD_NAMES (const char*[]) \ diff --git a/sections/cper-section-ccix-per.c b/sections/cper-section-ccix-per.c -index 4240afc..f8e94b3 100644 +index 4240afc..bdf9ee8 100644 --- a/sections/cper-section-ccix-per.c +++ b/sections/cper-section-ccix-per.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting CCIX PER log CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-ccix-per.h" diff --git a/sections/cper-section-ccix-per.h b/sections/cper-section-ccix-per.h index a6a557c..cde63e1 100644 --- a/sections/cper-section-ccix-per.h @@ -1204,25 +962,18 @@ index a6a557c..cde63e1 100644 #define CCIX_PER_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"ccixSourceIDValid", "ccixPortIDValid", "ccixPERLogValid"} diff --git a/sections/cper-section-cxl-component.c b/sections/cper-section-cxl-component.c -index 098b20d..472d245 100644 +index 098b20d..aae7948 100644 --- a/sections/cper-section-cxl-component.c +++ b/sections/cper-section-cxl-component.c -@@ -1,12 +1,12 @@ - /** - * Describes functions for converting CXL component error CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * +@@ -5,7 +5,7 @@ * Author: Lawrence.Tang@arm.com **/ #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-cxl-component.h" diff --git a/sections/cper-section-cxl-component.h b/sections/cper-section-cxl-component.h index 21a1374..bdf4285 100644 --- a/sections/cper-section-cxl-component.h @@ -1237,26 +988,18 @@ index 21a1374..bdf4285 100644 #define CXL_COMPONENT_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"deviceIDValid", "deviceSerialValid", \ diff --git a/sections/cper-section-cxl-protocol.c b/sections/cper-section-cxl-protocol.c -index 7cb1bbe..25d1547 100644 +index 7cb1bbe..73e6d74 100644 --- a/sections/cper-section-cxl-protocol.c +++ b/sections/cper-section-cxl-protocol.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting CXL protocol error CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-cxl-protocol.h" diff --git a/sections/cper-section-cxl-protocol.h b/sections/cper-section-cxl-protocol.h index c7c2c1c..0872ba7 100644 --- a/sections/cper-section-cxl-protocol.h @@ -1271,15 +1014,10 @@ index c7c2c1c..0872ba7 100644 #define CXL_PROTOCOL_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"cxlAgentTypeValid", "cxlAgentAddressValid", \ diff --git a/sections/cper-section-dmar-generic.c b/sections/cper-section-dmar-generic.c -index 6136232..23b1e6a 100644 +index 6136232..ba99be1 100644 --- a/sections/cper-section-dmar-generic.c +++ b/sections/cper-section-dmar-generic.c -@@ -1,11 +1,11 @@ - /** - * Describes functions for converting generic DMAr CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * +@@ -5,7 +5,7 @@ * Author: Lawrence.Tang@arm.com **/ #include @@ -1302,26 +1040,18 @@ index e9757b0..8cd3da1 100644 #define DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_KEYS (int []){0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB} diff --git a/sections/cper-section-dmar-iommu.c b/sections/cper-section-dmar-iommu.c -index f33c4ec..2bb291e 100644 +index f33c4ec..6b2b1da 100644 --- a/sections/cper-section-dmar-iommu.c +++ b/sections/cper-section-dmar-iommu.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting IOMMU specific DMAr CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-dmar-iommu.h" diff --git a/sections/cper-section-dmar-iommu.h b/sections/cper-section-dmar-iommu.h index 0fec283..6737a4b 100644 --- a/sections/cper-section-dmar-iommu.h @@ -1336,26 +1066,18 @@ index 0fec283..6737a4b 100644 json_object* cper_section_dmar_iommu_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor); diff --git a/sections/cper-section-dmar-vtd.c b/sections/cper-section-dmar-vtd.c -index 5d938f4..0d93ec7 100644 +index 5d938f4..300adf9 100644 --- a/sections/cper-section-dmar-vtd.c +++ b/sections/cper-section-dmar-vtd.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting VT-d specific DMAr CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-dmar-vtd.h" diff --git a/sections/cper-section-dmar-vtd.h b/sections/cper-section-dmar-vtd.h index 4f84657..df5b44f 100644 --- a/sections/cper-section-dmar-vtd.h @@ -1370,15 +1092,10 @@ index 4f84657..df5b44f 100644 #define VTD_FAULT_RECORD_TYPES_KEYS (int []){0, 1} diff --git a/sections/cper-section-firmware.c b/sections/cper-section-firmware.c -index e45015a..f94b6e1 100644 +index e45015a..5cb873d 100644 --- a/sections/cper-section-firmware.c +++ b/sections/cper-section-firmware.c -@@ -1,11 +1,11 @@ - /** - * Describes functions for converting firmware CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * +@@ -5,7 +5,7 @@ * Author: Lawrence.Tang@arm.com **/ #include @@ -1401,17 +1118,10 @@ index 4e0f528..09889ff 100644 #define FIRMWARE_ERROR_RECORD_TYPES_KEYS (int []){0, 1, 2} diff --git a/sections/cper-section-generic.c b/sections/cper-section-generic.c -index 6a0de01..de2fe7b 100644 +index 6a0de01..2de0c2d 100644 --- a/sections/cper-section-generic.c +++ b/sections/cper-section-generic.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting processor-generic CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ +@@ -7,7 +7,7 @@ #include #include @@ -1434,26 +1144,18 @@ index 95ba66e..5355ae9 100644 #define GENERIC_PROC_TYPES_KEYS (int []){0, 1, 2} diff --git a/sections/cper-section-ia32x64.c b/sections/cper-section-ia32x64.c -index a7dcc18..fac8580 100644 +index a7dcc18..ccb8d45 100644 --- a/sections/cper-section-ia32x64.c +++ b/sections/cper-section-ia32x64.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting IA32/x64 CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-ia32x64.h" diff --git a/sections/cper-section-ia32x64.h b/sections/cper-section-ia32x64.h index 875681e..7c88973 100644 --- a/sections/cper-section-ia32x64.h @@ -1468,15 +1170,10 @@ index 875681e..7c88973 100644 #define IA32X64_PROCESSOR_ERROR_VALID_BITFIELD_NAMES (const char*[]) \ diff --git a/sections/cper-section-ipf.c b/sections/cper-section-ipf.c -index bc62493..0488622 100644 +index bc62493..5a6508b 100644 --- a/sections/cper-section-ipf.c +++ b/sections/cper-section-ipf.c -@@ -1,11 +1,11 @@ - /** - * Describes functions for converting Intel IPF CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * +@@ -5,7 +5,7 @@ * Author: Lawrence.Tang@arm.com **/ #include @@ -1499,15 +1196,10 @@ index e90a16e..6978335 100644 #define IPF_MOD_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"checkInfoValid", "requestorIdentifierValid", \ diff --git a/sections/cper-section-memory.c b/sections/cper-section-memory.c -index 1ed2b9b..20d7add 100644 +index 1ed2b9b..1a3b5ca 100644 --- a/sections/cper-section-memory.c +++ b/sections/cper-section-memory.c -@@ -1,11 +1,11 @@ - /** - * Describes functions for converting memory error CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * +@@ -5,7 +5,7 @@ * Author: Lawrence.Tang@arm.com **/ #include @@ -1530,16 +1222,10 @@ index 81be6ff..5c1fed4 100644 #define MEMORY_ERROR_VALID_BITFIELD_NAMES (const char*[]) \ diff --git a/sections/cper-section-pci-bus.c b/sections/cper-section-pci-bus.c -index 33d0d03..26d6358 100644 +index 33d0d03..7c81578 100644 --- a/sections/cper-section-pci-bus.c +++ b/sections/cper-section-pci-bus.c -@@ -1,12 +1,12 @@ - /** - * Describes functions for converting PCI/PCI-X bus CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include #include @@ -1562,15 +1248,10 @@ index cf4371a..d3e438d 100644 #define PCI_BUS_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"errorStatusValid", "errorTypeValid", \ diff --git a/sections/cper-section-pci-dev.c b/sections/cper-section-pci-dev.c -index 5f40183..56f47ec 100644 +index 5f40183..c826d1f 100644 --- a/sections/cper-section-pci-dev.c +++ b/sections/cper-section-pci-dev.c -@@ -1,11 +1,11 @@ - /** - * Describes functions for converting PCI/PCI-X device CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * +@@ -5,7 +5,7 @@ * Author: Lawrence.Tang@arm.com **/ #include @@ -1593,26 +1274,18 @@ index e261d44..ff83ddf 100644 #define PCI_DEV_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"errorStatusValid", "idInfoValid", "memoryNumberValid", \ diff --git a/sections/cper-section-pcie.c b/sections/cper-section-pcie.c -index cf68b3f..f9dada0 100644 +index cf68b3f..9575400 100644 --- a/sections/cper-section-pcie.c +++ b/sections/cper-section-pcie.c -@@ -1,13 +1,13 @@ - /** - * Describes functions for converting PCIe CPER sections from binary and JSON format - * into an intermediate format. -- * -+ * - * Author: Lawrence.Tang@arm.com +@@ -6,7 +6,7 @@ **/ #include #include -#include --#include "b64.h" +#include -+#include "../b64.h" + #include "b64.h" #include "../edk/Cper.h" #include "../cper-utils.h" - #include "cper-section-pcie.h" diff --git a/sections/cper-section-pcie.h b/sections/cper-section-pcie.h index a2a43a4..7f1de9a 100644 --- a/sections/cper-section-pcie.h @@ -1626,18 +1299,6 @@ index a2a43a4..7f1de9a 100644 #include "../edk/Cper.h" #define PCIE_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"portTypeValid", "versionValid", "commandStatusValid", \ -diff --git a/sections/cper-section.c b/sections/cper-section.c -index 82a44a5..e1d3b93 100644 ---- a/sections/cper-section.c -+++ b/sections/cper-section.c -@@ -1,6 +1,6 @@ - /** - * Describes available sections to the CPER parser. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - #include "../edk/Cper.h" diff --git a/sections/cper-section.h b/sections/cper-section.h index 4379f91..d83f5b5 100644 --- a/sections/cper-section.h @@ -1651,137 +1312,10 @@ index 4379f91..d83f5b5 100644 #include #include #include "../edk/Cper.h" -diff --git a/specification/document/cper-json-specification.tex b/specification/document/cper-json-specification.tex -index 1e93781..a7e6ad5 100644 ---- a/specification/document/cper-json-specification.tex -+++ b/specification/document/cper-json-specification.tex -@@ -33,7 +33,7 @@ First revision released [DATE].}} - \end{table} - \FloatBarrier - } -- -+ - \begin{document} - \maketitle - \tableofcontents -@@ -357,7 +357,7 @@ This structure describes the validation bitfield structure of an IA32/x64 Error - \jsontable{table:ia32x64processorflagsstructure} - localAPICIDValid & boolean & Whether the "localAPICID" field of the IA32/x64 Error section (\ref{section:ia32x64errorsection}) is valid.\\ - \hline --cpuIDInfoValid & boolean & Whether the "cpuidInfo" field of the IA32/x64 Error section (\ref{section:ia32x64errorsection}) is valid.\\ -+cpuIDInfoValid & boolean & Whether the "cpuidInfo" field of the IA32/x64 Error section (\ref{section:ia32x64errorsection}) is valid.\\ - \hline - processorErrorInfoNum & int & The number of IA32/x64 Processor Error Info Structures (\ref{subsection:ia32x64processorerrorinfostructure}) that are included with this error section.\\ - \hline -@@ -396,7 +396,7 @@ requestorID & uint64 & Identifies the requestor associated with the error.\\ - \hline - responderID & uint64 & Identifies the responder associated with the error.\\ - \hline --instructionPointer & uint64 & Identifies the instruction executing when the error occurred.\\ -+instructionPointer & uint64 & Identifies the instruction executing when the error occurred.\\ - \jsontableend{IA32/x64 Processor Error Info structure field table.} - - % IA32/x64 Processor Error Info Validation structure. -@@ -767,7 +767,7 @@ errorType.name & string & The human readable name, if available, of the error ty - multipleError.value & int & If the value of this field is 2 or greater, the raw value of the number of errors that occurred. Otherwise, the raw value of the multiple error status.\\ - multipleError.type & string & The human readable value, if available, of what type of multiple error this is (single error, multiple error).\\ - \hline --flags & object & An ARM Processor Error Info Flags structure as defined in Subsection \ref{subsection:armprocessorerrorinfoflagsstructure}.\\ -+flags & object & An ARM Processor Error Info Flags structure as defined in Subsection \ref{subsection:armprocessorerrorinfoflagsstructure}.\\ - \hline - errorInformation & object & An error information structure, as defined in one of Subsections \ref{subsection:armprocessorerrorinfoerrorinformationcachetlbstructure} or \ref{subsection:armprocessorerrorinfoerrorinformationbusstructure}, or . Which structure this is depends on the \texttt{errorType.value} field.\\ - \hline -diff --git a/specification/json/sections/cper-cxl-protocol.json b/specification/json/sections/cper-cxl-protocol.json -index bc22453..69ba347 100644 ---- a/specification/json/sections/cper-cxl-protocol.json -+++ b/specification/json/sections/cper-cxl-protocol.json -@@ -43,16 +43,16 @@ - "type": "object", - "required": ["functionNumber", "deviceNumber", "busNumber", "segmentNumber"], - "properties": { -- "functionNumber": { -+ "functionNumber": { - "type": "integer" - }, -- "deviceNumber": { -+ "deviceNumber": { - "type": "integer" - }, -- "busNumber": { -+ "busNumber": { - "type": "integer" - }, -- "segmentNumber": { -+ "segmentNumber": { - "type": "integer" - } - } -@@ -72,42 +72,42 @@ - "type": "object", - "required": ["vendorID", "deviceID", "subsystemVendorID", "subsystemDeviceID", "classCode", "slotNumber"], - "properties": { -- "vendorID": { -+ "vendorID": { - "type": "integer" - }, -- "deviceID": { -+ "deviceID": { - "type": "integer" - }, -- "subsystemVendorID": { -+ "subsystemVendorID": { - "type": "integer" - }, -- "subsystemDeviceID": { -+ "subsystemDeviceID": { - "type": "integer" - }, -- "classCode": { -+ "classCode": { - "type": "integer" - }, -- "slotNumber": { -+ "slotNumber": { - "type": "integer" - } - } - }, -- "deviceSerial": { -+ "deviceSerial": { - "type": "integer" - }, - "capabilityStructure": { - "type": "string" - }, -- "dvsecLength": { -+ "dvsecLength": { - "type": "integer" - }, -- "errorLogLength": { -+ "errorLogLength": { - "type": "integer" - }, -- "cxlDVSEC": { -+ "cxlDVSEC": { - "type": "string" - }, -- "cxlErrorLog": { -+ "cxlErrorLog": { - "type": "string" - } - } diff --git a/tests/ir-tests.cpp b/tests/ir-tests.cpp -index affa305..8c3351c 100644 +index affa305..e4c3aae 100644 --- a/tests/ir-tests.cpp +++ b/tests/ir-tests.cpp -@@ -1,6 +1,6 @@ - /** - * Defines tests for validating CPER-JSON IR output from the cper-parse library. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - @@ -8,7 +8,7 @@ #include "gtest/gtest.h" #include "test-utils.hpp" @@ -1791,18 +1325,6 @@ index affa305..8c3351c 100644 #include "../cper-parse.h" #include "../json-schema.h" #include "../generator/cper-generate.h" -diff --git a/tests/test-utils.cpp b/tests/test-utils.cpp -index 87cd429..ee42fa9 100644 ---- a/tests/test-utils.cpp -+++ b/tests/test-utils.cpp -@@ -1,6 +1,6 @@ - /** - * Defines utility functions for testing CPER-JSON IR output from the cper-parse library. -- * -+ * - * Author: Lawrence.Tang@arm.com - **/ - -- 2.23.0 diff --git a/meta-phytium/recipes-phytium/libcper/arm-libcper/0002-sections-Adapted-to-the-Phytium-platform-CPER.patch b/meta-phytium/recipes-phytium/ras/libcper-arm/0002-sections-Adapted-to-the-Phytium-platform-CPER.patch similarity index 78% rename from meta-phytium/recipes-phytium/libcper/arm-libcper/0002-sections-Adapted-to-the-Phytium-platform-CPER.patch rename to meta-phytium/recipes-phytium/ras/libcper-arm/0002-sections-Adapted-to-the-Phytium-platform-CPER.patch index 5b70f44925..bacc4b1207 100644 --- a/meta-phytium/recipes-phytium/libcper/arm-libcper/0002-sections-Adapted-to-the-Phytium-platform-CPER.patch +++ b/meta-phytium/recipes-phytium/ras/libcper-arm/0002-sections-Adapted-to-the-Phytium-platform-CPER.patch @@ -1,53 +1,28 @@ -From 3c51964e5018f80869d6a7e6322715509bac3750 Mon Sep 17 00:00:00 2001 -From: Tian Jingzai -Date: Mon, 8 Apr 2024 14:40:20 +0800 +From 275b24ffbfc21871eca929caa3a01c2d6a0678b5 Mon Sep 17 00:00:00 2001 +From: fuxuan +Date: Fri, 19 Jul 2024 17:04:58 +0800 Subject: [PATCH 2/2] sections: Adapted to the Phytium platform CPER -Added phytium error record CPER section parsing, -And change the library to dynamic library. +Added phytium error record CPER section parsing -Signed-off-by: Tian Jingzai -Change-Id: I2e8506931cede1b09f428d4ed331b21d6e2fb852 +Signed-off-by: fuxuan --- - CMakeLists.txt | 6 +-- sections/cper-section-phytium.c | 93 +++++++++++++++++++++++++++++++++ sections/cper-section-phytium.h | 32 ++++++++++++ - sections/cper-section.c | 4 +- - 4 files changed, 131 insertions(+), 4 deletions(-) + sections/cper-section.c | 2 + + 3 files changed, 127 insertions(+) create mode 100755 sections/cper-section-phytium.c create mode 100755 sections/cper-section-phytium.h -diff --git a/CMakeLists.txt b/CMakeLists.txt -index b5cff63..781faff 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -15,7 +15,7 @@ file(GLOB SectionSources sections/*.c) - file(GLOB EDKSources edk/*.c) - file(GLOB GeneratorSectionSources generator/sections/*.c) - file(GLOB B64Sources buffer.c decode.c encode.c) --add_library(cper-parse STATIC -+add_library(cper-parse SHARED - cper-parse.c - ir-parse.c - cper-utils.c -@@ -47,6 +47,6 @@ set_target_properties(cper-generate-cli PROPERTIES OUTPUT_NAME "cper-generate") - - install (TARGETS cper-convert RUNTIME DESTINATION bin) - install (TARGETS cper-generate-cli RUNTIME DESTINATION bin) --install (TARGETS cper-parse LIBRARY DESTINATION lib -- ARCHIVE DESTINATION lib) -+install (TARGETS cper-parse LIBRARY DESTINATION lib) - install (FILES cper-parse.h DESTINATION include) -+set_target_properties(cper-parse PROPERTIES VERSION 0.7) diff --git a/sections/cper-section-phytium.c b/sections/cper-section-phytium.c new file mode 100755 -index 0000000..53cf707 +index 0000000..71d6d09 --- /dev/null +++ b/sections/cper-section-phytium.c @@ -0,0 +1,93 @@ +#include +#include -+#include "../b64.h" ++#include "b64.h" +#include "../edk/Cper.h" +#include "../cper-utils.h" +#include "cper-section-phytium.h" @@ -177,7 +152,7 @@ index 0000000..2401141 +#endif + diff --git a/sections/cper-section.c b/sections/cper-section.c -index e1d3b93..7da787e 100644 +index 82a44a5..4447989 100644 --- a/sections/cper-section.c +++ b/sections/cper-section.c @@ -20,6 +20,7 @@ @@ -194,9 +169,8 @@ index e1d3b93..7da787e 100644 {&gEfiCxlMldPortErrorSectionGuid, "CXL MLD Port Component Error", cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper}, + {&gEfiPhytiumErrorSectionGuid, "Phytium Error Record", cper_section_phytium_to_ir, ir_section_phytium_to_cper}, }; --const size_t section_definitions_len = sizeof(section_definitions) / sizeof(CPER_SECTION_DEFINITION); + const size_t section_definitions_len = sizeof(section_definitions) / sizeof(CPER_SECTION_DEFINITION); \ No newline at end of file -+const size_t section_definitions_len = sizeof(section_definitions) / sizeof(CPER_SECTION_DEFINITION); -- 2.23.0 -- Gitee