global_data.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2002-2010
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #ifndef __ASM_GBL_DATA_H
  7. #define __ASM_GBL_DATA_H
  8. #ifndef __ASSEMBLY__
  9. #include <asm/processor.h>
  10. #include <asm/mrccache.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. /**
  59. * struct mrc_output - holds the MRC data
  60. *
  61. * @buf: MRC training data to save for the next boot. This is set to point to
  62. * the raw data after SDRAM init is complete. Then mrccache_setup()
  63. * turns it into a proper cache record with a checksum
  64. * @len: Length of @buf
  65. * @cache: Resulting cache record
  66. */
  67. struct mrc_output {
  68. char *buf;
  69. uint len;
  70. struct mrc_data_container *cache;
  71. };
  72. /* Architecture-specific global data */
  73. struct arch_global_data {
  74. u64 gdt[X86_GDT_NUM_ENTRIES] __aligned(16);
  75. struct global_data *gd_addr; /* Location of Global Data */
  76. uint8_t x86; /* CPU family */
  77. uint8_t x86_vendor; /* CPU vendor */
  78. uint8_t x86_model;
  79. uint8_t x86_mask;
  80. uint32_t x86_device;
  81. uint64_t tsc_base; /* Initial value returned by rdtsc() */
  82. bool tsc_inited; /* true if tsc is ready for use */
  83. unsigned long clock_rate; /* Clock rate of timer in Hz */
  84. void *new_fdt; /* Relocated FDT */
  85. uint32_t bist; /* Built-in self test value */
  86. enum pei_boot_mode_t pei_boot_mode;
  87. const struct pch_gpio_map *gpio_map; /* board GPIO map */
  88. struct memory_info meminfo; /* Memory information */
  89. struct pei_memory_info pei_meminfo; /* PEI memory information */
  90. #ifdef CONFIG_USE_HOB
  91. void *hob_list; /* FSP HOB list */
  92. #endif
  93. struct mtrr_request mtrr_req[MAX_MTRR_REQUESTS];
  94. int mtrr_req_count;
  95. int has_mtrr;
  96. /* MRC training data */
  97. struct mrc_output mrc[MRC_TYPE_COUNT];
  98. ulong table; /* Table pointer from previous loader */
  99. int turbo_state; /* Current turbo state */
  100. struct irq_routing_table *pirq_routing_table;
  101. int dw_i2c_num_cards; /* Used by designware i2c driver */
  102. #ifdef CONFIG_SEABIOS
  103. u32 high_table_ptr;
  104. u32 high_table_limit;
  105. #endif
  106. int prev_sleep_state; /* Previous sleep state ACPI_S0/1../5 */
  107. ulong backup_mem; /* Backup memory address for S3 */
  108. #ifdef CONFIG_FSP_VERSION2
  109. struct fsp_header *fsp_s_hdr; /* Pointer to FSP-S header */
  110. #endif
  111. void *itss_priv; /* Private ITSS data pointer */
  112. ulong acpi_start; /* Start address of ACPI tables */
  113. };
  114. #endif
  115. #include <asm-generic/global_data.h>
  116. #ifndef __ASSEMBLY__
  117. # if defined(CONFIG_EFI_APP) || CONFIG_IS_ENABLED(X86_64)
  118. /* TODO(sjg@chromium.org): Consider using a fixed register for gd on x86_64 */
  119. #define gd global_data_ptr
  120. #define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr
  121. # else
  122. static inline __attribute__((no_instrument_function)) gd_t *get_fs_gd_ptr(void)
  123. {
  124. gd_t *gd_ptr;
  125. #if CONFIG_IS_ENABLED(X86_64)
  126. asm volatile("fs mov 0, %0\n" : "=r" (gd_ptr));
  127. #else
  128. asm volatile("fs movl 0, %0\n" : "=r" (gd_ptr));
  129. #endif
  130. return gd_ptr;
  131. }
  132. #define gd get_fs_gd_ptr()
  133. #define DECLARE_GLOBAL_DATA_PTR
  134. # endif
  135. #endif
  136. #endif /* __ASM_GBL_DATA_H */