intel_fit_ptr.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright (c) 2016 Google, Inc
  3. # Written by Simon Glass <sjg@chromium.org>
  4. #
  5. # Entry-type module for a pointer to an Intel Firmware Image Table
  6. #
  7. import struct
  8. from binman.etype.blob_ext import Entry_blob_ext
  9. class Entry_intel_fit_ptr(Entry_blob_ext):
  10. """Intel Firmware Image Table (FIT) pointer
  11. This entry contains a pointer to the FIT. It is required to be at address
  12. 0xffffffc0 in the image.
  13. """
  14. def __init__(self, section, etype, node):
  15. super().__init__(section, etype, node)
  16. if self.HasSibling('intel-fit') is False:
  17. self.Raise("'intel-fit-ptr' section must have an 'intel-fit' sibling")
  18. def _GetContents(self):
  19. fit_pos = self.GetSiblingImagePos('intel-fit')
  20. return struct.pack('<II', fit_pos or 0, 0)
  21. def ObtainContents(self):
  22. self.SetContents(self._GetContents())
  23. return True
  24. def ProcessContents(self):
  25. """Write an updated version of the FIT pointer to this entry
  26. This is necessary since image_pos is not available when ObtainContents()
  27. is called, since by then the entries have not been packed in the image.
  28. """
  29. return self.ProcessContentsUpdate(self._GetContents())
  30. def Pack(self, offset):
  31. """Special pack method to set the offset to the right place"""
  32. return super().Pack(0xffffffc0)