global_data.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * (C) Copyright 2002-2010
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __ASM_GBL_DATA_H
  8. #define __ASM_GBL_DATA_H
  9. #ifndef __ASSEMBLY__
  10. #include <asm/processor.h>
  11. enum pei_boot_mode_t {
  12. PEI_BOOT_NONE = 0,
  13. PEI_BOOT_SOFT_RESET,
  14. PEI_BOOT_RESUME,
  15. };
  16. struct dimm_info {
  17. uint32_t dimm_size;
  18. uint16_t ddr_type;
  19. uint16_t ddr_frequency;
  20. uint8_t rank_per_dimm;
  21. uint8_t channel_num;
  22. uint8_t dimm_num;
  23. uint8_t bank_locator;
  24. /* The 5th byte is '\0' for the end of string */
  25. uint8_t serial[5];
  26. /* The 19th byte is '\0' for the end of string */
  27. uint8_t module_part_number[19];
  28. uint16_t mod_id;
  29. uint8_t mod_type;
  30. uint8_t bus_width;
  31. } __packed;
  32. struct pei_memory_info {
  33. uint8_t dimm_cnt;
  34. /* Maximum num of dimm is 8 */
  35. struct dimm_info dimm[8];
  36. } __packed;
  37. struct memory_area {
  38. uint64_t start;
  39. uint64_t size;
  40. };
  41. struct memory_info {
  42. int num_areas;
  43. uint64_t total_memory;
  44. uint64_t total_32bit_memory;
  45. struct memory_area area[CONFIG_NR_DRAM_BANKS];
  46. };
  47. #define MAX_MTRR_REQUESTS 8
  48. /**
  49. * A request for a memory region to be set up in a particular way. These
  50. * requests are processed before board_init_r() is called. They are generally
  51. * optional and can be ignored with some performance impact.
  52. */
  53. struct mtrr_request {
  54. int type; /* MTRR_TYPE_... */
  55. uint64_t start;
  56. uint64_t size;
  57. };
  58. /* Architecture-specific global data */
  59. struct arch_global_data {
  60. u64 gdt[X86_GDT_NUM_ENTRIES] __aligned(16);
  61. struct global_data *gd_addr; /* Location of Global Data */
  62. uint8_t x86; /* CPU family */
  63. uint8_t x86_vendor; /* CPU vendor */
  64. uint8_t x86_model;
  65. uint8_t x86_mask;
  66. uint32_t x86_device;
  67. uint64_t tsc_base; /* Initial value returned by rdtsc() */
  68. void *new_fdt; /* Relocated FDT */
  69. uint32_t bist; /* Built-in self test value */
  70. enum pei_boot_mode_t pei_boot_mode;
  71. const struct pch_gpio_map *gpio_map; /* board GPIO map */
  72. struct memory_info meminfo; /* Memory information */
  73. struct pei_memory_info pei_meminfo; /* PEI memory information */
  74. #ifdef CONFIG_HAVE_FSP
  75. void *hob_list; /* FSP HOB list */
  76. #endif
  77. struct mtrr_request mtrr_req[MAX_MTRR_REQUESTS];
  78. int mtrr_req_count;
  79. int has_mtrr;
  80. /* MRC training data to save for the next boot */
  81. char *mrc_output;
  82. unsigned int mrc_output_len;
  83. ulong table; /* Table pointer from previous loader */
  84. struct irq_routing_table *pirq_routing_table;
  85. #ifdef CONFIG_SEABIOS
  86. u32 high_table_ptr;
  87. u32 high_table_limit;
  88. #endif
  89. };
  90. #endif
  91. #include <asm-generic/global_data.h>
  92. #ifndef __ASSEMBLY__
  93. # if defined(CONFIG_EFI_APP) || CONFIG_IS_ENABLED(X86_64)
  94. /* TODO(sjg@chromium.org): Consider using a fixed register for gd on x86_64 */
  95. #define gd global_data_ptr
  96. #define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr
  97. # else
  98. static inline __attribute__((no_instrument_function)) gd_t *get_fs_gd_ptr(void)
  99. {
  100. gd_t *gd_ptr;
  101. #if CONFIG_IS_ENABLED(X86_64)
  102. asm volatile("fs mov 0, %0\n" : "=r" (gd_ptr));
  103. #else
  104. asm volatile("fs movl 0, %0\n" : "=r" (gd_ptr));
  105. #endif
  106. return gd_ptr;
  107. }
  108. #define gd get_fs_gd_ptr()
  109. #define DECLARE_GLOBAL_DATA_PTR
  110. # endif
  111. #endif
  112. /*
  113. * Our private Global Data Flags
  114. */
  115. #define GD_FLG_COLD_BOOT 0x10000 /* Cold Boot */
  116. #define GD_FLG_WARM_BOOT 0x20000 /* Warm Boot */
  117. #endif /* __ASM_GBL_DATA_H */