blob: 3bc2ac24cf3e6a6f2a7af33a609efad70869d769 [file] [log] [blame]
wdenk591dda52002-11-18 00:14:45 +00001/*
Wolfgang Denkf710efd2010-07-24 20:22:02 +02002 * (C) Copyright 2002-2010
wdenk591dda52002-11-18 00:14:45 +00003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk591dda52002-11-18 00:14:45 +00006 */
7
8#ifndef __ASM_GBL_DATA_H
9#define __ASM_GBL_DATA_H
Simon Glass3ac47d72012-12-13 20:48:30 +000010
11#ifndef __ASSEMBLY__
12
Simon Glass9909bf32015-08-10 20:44:31 -060013#include <asm/processor.h>
14
Simon Glass30580fc2014-11-12 22:42:23 -070015enum pei_boot_mode_t {
16 PEI_BOOT_NONE = 0,
17 PEI_BOOT_SOFT_RESET,
18 PEI_BOOT_RESUME,
19
20};
21
Simon Glassd21f34e2016-03-11 22:07:26 -070022struct 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
39struct pei_memory_info {
40 uint8_t dimm_cnt;
41 /* Maximum num of dimm is 8 */
42 struct dimm_info dimm[8];
43} __packed;
44
Simon Glass268eefd2014-11-12 22:42:28 -070045struct memory_area {
46 uint64_t start;
47 uint64_t size;
48};
49
50struct 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
Simon Glass7bf5b9e2015-01-01 16:18:07 -070057#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 */
64struct mtrr_request {
65 int type; /* MTRR_TYPE_... */
66 uint64_t start;
67 uint64_t size;
68};
69
Simon Glass3ac47d72012-12-13 20:48:30 +000070/* Architecture-specific global data */
71struct arch_global_data {
Simon Glass9909bf32015-08-10 20:44:31 -060072 u64 gdt[X86_GDT_NUM_ENTRIES] __aligned(16);
Bin Meng47eac042015-01-22 11:29:40 +080073 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;
Bin Meng035c1d22014-11-09 22:18:56 +080078 uint32_t x86_device;
Simon Glass6fa6e4a2013-02-28 19:26:12 +000079 uint64_t tsc_base; /* Initial value returned by rdtsc() */
Simon Glass347c05b2013-02-28 19:26:15 +000080 void *new_fdt; /* Relocated FDT */
Simon Glass1f4476c2014-11-06 13:20:10 -070081 uint32_t bist; /* Built-in self test value */
Simon Glass30580fc2014-11-12 22:42:23 -070082 enum pei_boot_mode_t pei_boot_mode;
Simon Glass60af0172014-11-12 22:42:24 -070083 const struct pch_gpio_map *gpio_map; /* board GPIO map */
Simon Glass268eefd2014-11-12 22:42:28 -070084 struct memory_info meminfo; /* Memory information */
Simon Glassd21f34e2016-03-11 22:07:26 -070085 struct pei_memory_info pei_meminfo; /* PEI memory information */
Bin Meng005f0af2014-12-12 21:05:31 +080086#ifdef CONFIG_HAVE_FSP
Bin Meng47eac042015-01-22 11:29:40 +080087 void *hob_list; /* FSP HOB list */
Bin Meng005f0af2014-12-12 21:05:31 +080088#endif
Simon Glass7bf5b9e2015-01-01 16:18:07 -070089 struct mtrr_request mtrr_req[MAX_MTRR_REQUESTS];
90 int mtrr_req_count;
Bin Meng47eac042015-01-22 11:29:40 +080091 int has_mtrr;
Simon Glass428dfa42015-01-19 22:16:14 -070092 /* MRC training data to save for the next boot */
93 char *mrc_output;
94 unsigned int mrc_output_len;
Simon Glassf95ad8c2015-08-04 12:33:57 -060095 ulong table; /* Table pointer from previous loader */
Simon Glass3ac47d72012-12-13 20:48:30 +000096};
97
Graeme Russ3c28f482011-09-01 00:48:27 +000098#endif
wdenk591dda52002-11-18 00:14:45 +000099
Simon Glassd3887632012-12-13 20:49:27 +0000100#include <asm-generic/global_data.h>
101
102#ifndef __ASSEMBLY__
Simon Glass7f65c092015-07-31 09:31:35 -0600103# ifdef CONFIG_EFI_APP
104
105#define gd global_data_ptr
106
107#define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr
108# else
Simon Glass42081ce2013-06-11 11:14:52 -0700109static inline __attribute__((no_instrument_function)) gd_t *get_fs_gd_ptr(void)
Graeme Russ35368962011-12-31 22:58:15 +1100110{
111 gd_t *gd_ptr;
112
113 asm volatile("fs movl 0, %0\n" : "=r" (gd_ptr));
114
115 return gd_ptr;
116}
117
118#define gd get_fs_gd_ptr()
Graeme Russ5fb91cc2010-10-07 20:03:29 +1100119
Simon Glass5d18dc92015-07-31 09:31:28 -0600120#define DECLARE_GLOBAL_DATA_PTR
Simon Glass7f65c092015-07-31 09:31:35 -0600121# endif
Simon Glass5d18dc92015-07-31 09:31:28 -0600122
Graeme Russ5fb91cc2010-10-07 20:03:29 +1100123#endif
124
Gabe Blackef899322012-11-03 11:41:28 +0000125/*
126 * Our private Global Data Flags
127 */
Simon Glass5d18dc92015-07-31 09:31:28 -0600128#define GD_FLG_COLD_BOOT 0x10000 /* Cold Boot */
129#define GD_FLG_WARM_BOOT 0x20000 /* Warm Boot */
wdenk591dda52002-11-18 00:14:45 +0000130
131#endif /* __ASM_GBL_DATA_H */