boot_module.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-07-15 JasonHu,GuEe-GUI first version
  9. */
  10. #ifndef __BOOT_MODULE_H__
  11. #define __BOOT_MODULE_H__
  12. #include <rtdef.h>
  13. #define BOOT_MODULE_INFO_ADDR 0x3F1000
  14. #define SIZE_MB (1024*1024)
  15. #define MAX_BOOT_MODULES_NUM 1
  16. #define MAX_BOOT_MODULES_SIZE (1 * SIZE_MB)
  17. enum boot_module_type
  18. {
  19. // Unknown type
  20. BOOT_MODULE_UNKNOWN = 0,
  21. };
  22. struct boot_modules_info_block
  23. {
  24. rt_uint32_t modules_num;
  25. rt_uint32_t modules_size;
  26. struct {
  27. rt_uint32_t type;
  28. rt_uint32_t size;
  29. rt_uint32_t start;
  30. rt_uint32_t end;
  31. } modules[MAX_BOOT_MODULES_NUM];
  32. } __attribute__((packed));
  33. rt_inline void boot_module_info_init()
  34. {
  35. struct boot_modules_info_block *modules_info = (struct boot_modules_info_block *)BOOT_MODULE_INFO_ADDR;
  36. modules_info->modules_num = 0;
  37. modules_info->modules_size = 0;
  38. }
  39. rt_inline void *boot_module_info_find(unsigned long base_addr, enum boot_module_type type)
  40. {
  41. int i;
  42. struct boot_modules_info_block *modules_info;
  43. modules_info = (struct boot_modules_info_block *)(base_addr + BOOT_MODULE_INFO_ADDR);
  44. for (i = 0; i < modules_info->modules_num; ++i)
  45. {
  46. if (modules_info->modules[i].type == type)
  47. {
  48. return (void*)(base_addr + modules_info->modules[i].start);
  49. }
  50. }
  51. return (void*)0;
  52. }
  53. #endif /* __BOOT_MODULE_H__ */