image.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * LoongArch binary image header for EFI(PE/COFF) format.
  4. *
  5. * Author: Youling Tang <tangyouling@kylinos.cn>
  6. * Copyright (C) 2025 KylinSoft Corporation.
  7. */
  8. #ifndef __ASM_IMAGE_H
  9. #define __ASM_IMAGE_H
  10. #ifndef __ASSEMBLER__
  11. /**
  12. * struct loongarch_image_header
  13. *
  14. * @dos_sig: Optional PE format 'MZ' signature.
  15. * @padding_1: Reserved.
  16. * @kernel_entry: Kernel image entry pointer.
  17. * @kernel_asize: An estimated size of the memory image size in LSB byte order.
  18. * @text_offset: The image load offset in LSB byte order.
  19. * @padding_2: Reserved.
  20. * @pe_header: Optional offset to a PE format header.
  21. **/
  22. struct loongarch_image_header {
  23. uint8_t dos_sig[2];
  24. uint16_t padding_1[3];
  25. uint64_t kernel_entry;
  26. uint64_t kernel_asize;
  27. uint64_t text_offset;
  28. uint32_t padding_2[7];
  29. uint32_t pe_header;
  30. };
  31. /*
  32. * loongarch_header_check_dos_sig - Helper to check the header
  33. *
  34. * Returns true (non-zero) if 'MZ' signature is found.
  35. */
  36. static inline int loongarch_header_check_dos_sig(const struct loongarch_image_header *h)
  37. {
  38. if (!h)
  39. return 0;
  40. return (h->dos_sig[0] == 'M' && h->dos_sig[1] == 'Z');
  41. }
  42. #endif /* __ASSEMBLER__ */
  43. #endif /* __ASM_IMAGE_H */