fconf_nt_config_getter.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2020, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <common/fdt_wrappers.h>
  8. #include <libfdt.h>
  9. #include <fconf_nt_config_getter.h>
  10. #include <plat/common/platform.h>
  11. struct event_log_config_t event_log_config;
  12. int fconf_populate_event_log_config(uintptr_t config)
  13. {
  14. int err;
  15. int node;
  16. /* Necessary to work with libfdt APIs */
  17. const void *dtb = (const void *)config;
  18. /*
  19. * Find the offset of the node containing "arm,tpm_event_log"
  20. * compatible property
  21. */
  22. const char *compatible_str = "arm,tpm_event_log";
  23. node = fdt_node_offset_by_compatible(dtb, -1, compatible_str);
  24. if (node < 0) {
  25. ERROR("FCONF: Can't find '%s' compatible in dtb\n",
  26. compatible_str);
  27. return node;
  28. }
  29. /* Retrieve Event Log details from the DTB */
  30. #ifdef SPD_opteed
  31. err = fdtw_read_cells(dtb, node, "tpm_event_log_sm_addr", 2,
  32. &event_log_config.tpm_event_log_sm_addr);
  33. if (err < 0) {
  34. ERROR("FCONF: Read cell failed for 'tpm_event_log_sm_addr'\n");
  35. return err;
  36. }
  37. #endif
  38. err = fdtw_read_cells(dtb, node,
  39. "tpm_event_log_addr", 2, &event_log_config.tpm_event_log_addr);
  40. if (err < 0) {
  41. ERROR("FCONF: Read cell failed for 'tpm_event_log_addr'\n");
  42. return err;
  43. }
  44. err = fdtw_read_cells(dtb, node,
  45. "tpm_event_log_size", 1, &event_log_config.tpm_event_log_size);
  46. if (err < 0) {
  47. ERROR("FCONF: Read cell failed for 'tpm_event_log_size'\n");
  48. }
  49. return err;
  50. }
  51. FCONF_REGISTER_POPULATOR(NT_CONFIG, event_log_config,
  52. fconf_populate_event_log_config);