global_data.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. enum pei_boot_mode_t {
  11. PEI_BOOT_NONE = 0,
  12. PEI_BOOT_SOFT_RESET,
  13. PEI_BOOT_RESUME,
  14. };
  15. struct dimm_info {
  16. uint32_t dimm_size;
  17. uint16_t ddr_type;
  18. uint16_t ddr_frequency;
  19. uint8_t rank_per_dimm;
  20. uint8_t channel_num;
  21. uint8_t dimm_num;
  22. uint8_t bank_locator;
  23. /* The 5th byte is '\0' for the end of string */
  24. uint8_t serial[5];
  25. /* The 19th byte is '\0' for the end of string */
  26. uint8_t module_part_number[19];
  27. uint16_t mod_id;
  28. uint8_t mod_type;
  29. uint8_t bus_width;
  30. } __packed;
  31. struct pei_memory_info {
  32. uint8_t dimm_cnt;
  33. /* Maximum num of dimm is 8 */
  34. struct dimm_info dimm[8];
  35. } __packed;
  36. struct memory_area {
  37. uint64_t start;
  38. uint64_t size;
  39. };
  40. struct memory_info {
  41. int num_areas;
  42. uint64_t total_memory;
  43. uint64_t total_32bit_memory;
  44. struct memory_area area[CONFIG_NR_DRAM_BANKS];
  45. };
  46. #define MAX_MTRR_REQUESTS 8
  47. /**
  48. * A request for a memory region to be set up in a particular way. These
  49. * requests are processed before board_init_r() is called. They are generally
  50. * optional and can be ignored with some performance impact.
  51. */
  52. struct mtrr_request {
  53. int type; /* MTRR_TYPE_... */
  54. uint64_t start;
  55. uint64_t size;
  56. };
  57. /* Architecture-specific global data */
  58. struct arch_global_data {
  59. u64 gdt[X86_GDT_NUM_ENTRIES] __aligned(16);
  60. struct global_data *gd_addr; /* Location of Global Data */
  61. uint8_t x86; /* CPU family */
  62. uint8_t x86_vendor; /* CPU vendor */
  63. uint8_t x86_model;
  64. uint8_t x86_mask;
  65. uint32_t x86_device;
  66. uint64_t tsc_base; /* Initial value returned by rdtsc() */
  67. unsigned long clock_rate; /* Clock rate of timer in Hz */
  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. int turbo_state; /* Current turbo state */
  85. struct irq_routing_table *pirq_routing_table;
  86. #ifdef CONFIG_SEABIOS
  87. u32 high_table_ptr;
  88. u32 high_table_limit;
  89. #endif
  90. #ifdef CONFIG_HAVE_ACPI_RESUME
  91. int prev_sleep_state; /* Previous sleep state ACPI_S0/1../5 */
  92. ulong backup_mem; /* Backup memory address for S3 */
  93. #endif
  94. };
  95. #endif
  96. #include <asm-generic/global_data.h>
  97. #ifndef __ASSEMBLY__
  98. # if defined(CONFIG_EFI_APP) || CONFIG_IS_ENABLED(X86_64)
  99. /* TODO(sjg@chromium.org): Consider using a fixed register for gd on x86_64 */
  100. #define gd global_data_ptr
  101. #define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr
  102. # else
  103. static inline __attribute__((no_instrument_function)) gd_t *get_fs_gd_ptr(void)
  104. {
  105. gd_t *gd_ptr;
  106. #if CONFIG_IS_ENABLED(X86_64)
  107. asm volatile("fs mov 0, %0\n" : "=r" (gd_ptr));
  108. #else
  109. asm volatile("fs movl 0, %0\n" : "=r" (gd_ptr));
  110. #endif
  111. return gd_ptr;
  112. }
  113. #define gd get_fs_gd_ptr()
  114. #define DECLARE_GLOBAL_DATA_PTR
  115. # endif
  116. #endif
  117. /*
  118. * Our private Global Data Flags
  119. */
  120. #define GD_FLG_COLD_BOOT 0x10000 /* Cold Boot */
  121. #define GD_FLG_WARM_BOOT 0x20000 /* Warm Boot */
  122. #endif /* __ASM_GBL_DATA_H */