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