1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * (C) Copyright 2000-2009
3*4882a593Smuzhiyun * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+
6*4882a593Smuzhiyun */
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun #ifndef __COMMON_H_
9*4882a593Smuzhiyun #define __COMMON_H_ 1
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun #ifndef __ASSEMBLY__ /* put C only stuff in this section */
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun typedef unsigned char uchar;
14*4882a593Smuzhiyun typedef volatile unsigned long vu_long;
15*4882a593Smuzhiyun typedef volatile unsigned short vu_short;
16*4882a593Smuzhiyun typedef volatile unsigned char vu_char;
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun /* Allow sharing constants with type modifiers between C and assembly. */
19*4882a593Smuzhiyun #define _AC(X, Y) (X##Y)
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun #include <config.h>
22*4882a593Smuzhiyun #include <errno.h>
23*4882a593Smuzhiyun #include <time.h>
24*4882a593Smuzhiyun #include <asm-offsets.h>
25*4882a593Smuzhiyun #include <linux/bitops.h>
26*4882a593Smuzhiyun #include <linux/bug.h>
27*4882a593Smuzhiyun #include <linux/delay.h>
28*4882a593Smuzhiyun #include <linux/types.h>
29*4882a593Smuzhiyun #include <linux/printk.h>
30*4882a593Smuzhiyun #include <linux/string.h>
31*4882a593Smuzhiyun #include <linux/stringify.h>
32*4882a593Smuzhiyun #include <asm/ptrace.h>
33*4882a593Smuzhiyun #include <stdarg.h>
34*4882a593Smuzhiyun #include <stdio.h>
35*4882a593Smuzhiyun #include <linux/kernel.h>
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun #include <part.h>
38*4882a593Smuzhiyun #include <flash.h>
39*4882a593Smuzhiyun #include <image.h>
40*4882a593Smuzhiyun #include <stacktrace.h>
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun /* Bring in printf format macros if inttypes.h is included */
43*4882a593Smuzhiyun #define __STDC_FORMAT_MACROS
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun #ifdef __LP64__
46*4882a593Smuzhiyun #define CONFIG_SYS_SUPPORT_64BIT_DATA
47*4882a593Smuzhiyun #endif
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun #include <log.h>
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun #if (__STDC_VERSION__ >= 201112L) || defined(__cplusplus)
52*4882a593Smuzhiyun # undef static_assert
53*4882a593Smuzhiyun # define static_assert _Static_assert
54*4882a593Smuzhiyun #endif
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun #if !CONFIG_IS_ENABLED(IRQ)
57*4882a593Smuzhiyun typedef void (interrupt_handler_t)(void *);
58*4882a593Smuzhiyun #else
59*4882a593Smuzhiyun typedef void (interrupt_handler_t)(int, void *);
60*4882a593Smuzhiyun #endif
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun #include <asm/u-boot.h> /* boot information for Linux kernel */
63*4882a593Smuzhiyun #include <asm/global_data.h> /* global data used for startup functions */
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun #if defined(CONFIG_ENV_IS_EMBEDDED)
66*4882a593Smuzhiyun #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
67*4882a593Smuzhiyun #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
68*4882a593Smuzhiyun (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
69*4882a593Smuzhiyun defined(CONFIG_ENV_IS_IN_NVRAM)
70*4882a593Smuzhiyun #define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
71*4882a593Smuzhiyun #else
72*4882a593Smuzhiyun #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
73*4882a593Smuzhiyun #endif
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun /*
76*4882a593Smuzhiyun * Function Prototypes
77*4882a593Smuzhiyun */
78*4882a593Smuzhiyun int dram_init(void);
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun /**
81*4882a593Smuzhiyun * dram_init_banksize() - Set up DRAM bank sizes
82*4882a593Smuzhiyun *
83*4882a593Smuzhiyun * This can be implemented by boards to set up the DRAM bank information in
84*4882a593Smuzhiyun * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
85*4882a593Smuzhiyun * is called.
86*4882a593Smuzhiyun *
87*4882a593Smuzhiyun * If this is not provided, a default implementation will try to set up a
88*4882a593Smuzhiyun * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
89*4882a593Smuzhiyun * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
90*4882a593Smuzhiyun * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
91*4882a593Smuzhiyun * get_effective_memsize().
92*4882a593Smuzhiyun *
93*4882a593Smuzhiyun * @return 0 if OK, -ve on error
94*4882a593Smuzhiyun */
95*4882a593Smuzhiyun int dram_init_banksize(void);
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun void hang (void) __attribute__ ((noreturn));
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun int timer_init(void);
100*4882a593Smuzhiyun int cpu_init(void);
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun #include <display_options.h>
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun /* common/main.c */
105*4882a593Smuzhiyun void main_loop (void);
106*4882a593Smuzhiyun void autoboot_command_fail_handle(void);
107*4882a593Smuzhiyun int run_command(const char *cmd, int flag);
108*4882a593Smuzhiyun int run_command_repeatable(const char *cmd, int flag);
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun /**
111*4882a593Smuzhiyun * Run a list of commands separated by ; or even \0
112*4882a593Smuzhiyun *
113*4882a593Smuzhiyun * Note that if 'len' is not -1, then the command does not need to be nul
114*4882a593Smuzhiyun * terminated, Memory will be allocated for the command in that case.
115*4882a593Smuzhiyun *
116*4882a593Smuzhiyun * @param cmd List of commands to run, each separated bu semicolon
117*4882a593Smuzhiyun * @param len Length of commands excluding terminator if known (-1 if not)
118*4882a593Smuzhiyun * @param flag Execution flags (CMD_FLAG_...)
119*4882a593Smuzhiyun * @return 0 on success, or != 0 on error.
120*4882a593Smuzhiyun */
121*4882a593Smuzhiyun int run_command_list(const char *cmd, int len, int flag);
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun /* arch/$(ARCH)/lib/board.c */
124*4882a593Smuzhiyun void board_init_f(ulong);
125*4882a593Smuzhiyun void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun /**
128*4882a593Smuzhiyun * ulong board_init_f_alloc_reserve - allocate reserved area
129*4882a593Smuzhiyun *
130*4882a593Smuzhiyun * This function is called by each architecture very early in the start-up
131*4882a593Smuzhiyun * code to allow the C runtime to reserve space on the stack for writable
132*4882a593Smuzhiyun * 'globals' such as GD and the malloc arena.
133*4882a593Smuzhiyun *
134*4882a593Smuzhiyun * @top: top of the reserve area, growing down.
135*4882a593Smuzhiyun * @return: bottom of reserved area
136*4882a593Smuzhiyun */
137*4882a593Smuzhiyun ulong board_init_f_alloc_reserve(ulong top);
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun /**
140*4882a593Smuzhiyun * board_init_f_init_reserve - initialize the reserved area(s)
141*4882a593Smuzhiyun *
142*4882a593Smuzhiyun * This function is called once the C runtime has allocated the reserved
143*4882a593Smuzhiyun * area on the stack. It must initialize the GD at the base of that area.
144*4882a593Smuzhiyun *
145*4882a593Smuzhiyun * @base: top from which reservation was done
146*4882a593Smuzhiyun */
147*4882a593Smuzhiyun void board_init_f_init_reserve(ulong base);
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun /*
150*4882a593Smuzhiyun * Board-specific Platform code can init serial earlier if needed
151*4882a593Smuzhiyun */
152*4882a593Smuzhiyun __weak int board_init_f_boot_flags(void);
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun /**
155*4882a593Smuzhiyun * arch_setup_gd() - Set up the global_data pointer
156*4882a593Smuzhiyun *
157*4882a593Smuzhiyun * This pointer is special in some architectures and cannot easily be assigned
158*4882a593Smuzhiyun * to. For example on x86 it is implemented by adding a specific record to its
159*4882a593Smuzhiyun * Global Descriptor Table! So we we provide a function to carry out this task.
160*4882a593Smuzhiyun * For most architectures this can simply be:
161*4882a593Smuzhiyun *
162*4882a593Smuzhiyun * gd = gd_ptr;
163*4882a593Smuzhiyun *
164*4882a593Smuzhiyun * @gd_ptr: Pointer to global data
165*4882a593Smuzhiyun */
166*4882a593Smuzhiyun void arch_setup_gd(gd_t *gd_ptr);
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun int checkboard(void);
169*4882a593Smuzhiyun int show_board_info(void);
170*4882a593Smuzhiyun int checkflash(void);
171*4882a593Smuzhiyun int checkdram(void);
172*4882a593Smuzhiyun int last_stage_init(void);
173*4882a593Smuzhiyun extern ulong monitor_flash_len;
174*4882a593Smuzhiyun int mac_read_from_eeprom(void);
175*4882a593Smuzhiyun extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
176*4882a593Smuzhiyun extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
177*4882a593Smuzhiyun int set_cpu_clk_info(void);
178*4882a593Smuzhiyun int mdm_init(void);
179*4882a593Smuzhiyun int print_cpuinfo(void);
180*4882a593Smuzhiyun int update_flash_size(int flash_size);
181*4882a593Smuzhiyun int arch_early_init_r(void);
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun /*
184*4882a593Smuzhiyun * setup_board_extra() - Fill in extra details in the bd_t structure
185*4882a593Smuzhiyun *
186*4882a593Smuzhiyun * @return 0 if OK, -ve on error
187*4882a593Smuzhiyun */
188*4882a593Smuzhiyun int setup_board_extra(void);
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun /**
191*4882a593Smuzhiyun * arch_fsp_init() - perform firmware support package init
192*4882a593Smuzhiyun *
193*4882a593Smuzhiyun * Where U-Boot relies on binary blobs to handle part of the system init, this
194*4882a593Smuzhiyun * function can be used to set up the blobs. This is used on some Intel
195*4882a593Smuzhiyun * platforms.
196*4882a593Smuzhiyun */
197*4882a593Smuzhiyun int arch_fsp_init(void);
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun /**
200*4882a593Smuzhiyun * arch_cpu_init_dm() - init CPU after driver model is available
201*4882a593Smuzhiyun *
202*4882a593Smuzhiyun * This is called immediately after driver model is available before
203*4882a593Smuzhiyun * relocation. This is similar to arch_cpu_init() but is able to reference
204*4882a593Smuzhiyun * devices
205*4882a593Smuzhiyun *
206*4882a593Smuzhiyun * @return 0 if OK, -ve on error
207*4882a593Smuzhiyun */
208*4882a593Smuzhiyun int arch_cpu_init_dm(void);
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun /**
211*4882a593Smuzhiyun * Reserve all necessary stacks
212*4882a593Smuzhiyun *
213*4882a593Smuzhiyun * This is used in generic board init sequence in common/board_f.c. Each
214*4882a593Smuzhiyun * architecture could provide this function to tailor the required stacks.
215*4882a593Smuzhiyun *
216*4882a593Smuzhiyun * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
217*4882a593Smuzhiyun * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
218*4882a593Smuzhiyun * require only this can leave it untouched.
219*4882a593Smuzhiyun *
220*4882a593Smuzhiyun * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
221*4882a593Smuzhiyun * positions of the stack. The stack pointer(s) will be set to this later.
222*4882a593Smuzhiyun * gd->irq_sp is only required, if the architecture needs it.
223*4882a593Smuzhiyun *
224*4882a593Smuzhiyun * @return 0 if no error
225*4882a593Smuzhiyun */
226*4882a593Smuzhiyun __weak int arch_reserve_stacks(void);
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun /**
229*4882a593Smuzhiyun * Show the DRAM size in a board-specific way
230*4882a593Smuzhiyun *
231*4882a593Smuzhiyun * This is used by boards to display DRAM information in their own way.
232*4882a593Smuzhiyun *
233*4882a593Smuzhiyun * @param size Size of DRAM (which should be displayed along with other info)
234*4882a593Smuzhiyun */
235*4882a593Smuzhiyun void board_show_dram(phys_size_t size);
236*4882a593Smuzhiyun
237*4882a593Smuzhiyun /**
238*4882a593Smuzhiyun * arch_fixup_fdt() - Write arch-specific information to fdt
239*4882a593Smuzhiyun *
240*4882a593Smuzhiyun * Defined in arch/$(ARCH)/lib/bootm-fdt.c
241*4882a593Smuzhiyun *
242*4882a593Smuzhiyun * @blob: FDT blob to write to
243*4882a593Smuzhiyun * @return 0 if ok, or -ve FDT_ERR_... on failure
244*4882a593Smuzhiyun */
245*4882a593Smuzhiyun int arch_fixup_fdt(void *blob);
246*4882a593Smuzhiyun
247*4882a593Smuzhiyun int reserve_mmu(void);
248*4882a593Smuzhiyun /* common/flash.c */
249*4882a593Smuzhiyun void flash_perror (int);
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun /* common/cmd_source.c */
252*4882a593Smuzhiyun int source (ulong addr, const char *fit_uname);
253*4882a593Smuzhiyun
254*4882a593Smuzhiyun extern ulong load_addr; /* Default Load Address */
255*4882a593Smuzhiyun extern ulong save_addr; /* Default Save Address */
256*4882a593Smuzhiyun extern ulong save_size; /* Default Save Size */
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun /* common/cmd_net.c */
259*4882a593Smuzhiyun int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
260*4882a593Smuzhiyun
261*4882a593Smuzhiyun /* common/cmd_fat.c */
262*4882a593Smuzhiyun int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun /* common/cmd_ext2.c */
265*4882a593Smuzhiyun int do_ext2load(cmd_tbl_t *, int, int, char * const []);
266*4882a593Smuzhiyun
267*4882a593Smuzhiyun /* common/cmd_nvedit.c */
268*4882a593Smuzhiyun int env_init (void);
269*4882a593Smuzhiyun void env_relocate (void);
270*4882a593Smuzhiyun int envmatch (uchar *, int);
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun /**
273*4882a593Smuzhiyun * env_get() - Look up the value of an environment variable
274*4882a593Smuzhiyun *
275*4882a593Smuzhiyun * In U-Boot proper this can be called before relocation (which is when the
276*4882a593Smuzhiyun * environment is loaded from storage, i.e. GD_FLG_ENV_READY is 0). In that
277*4882a593Smuzhiyun * case this function calls env_get_f().
278*4882a593Smuzhiyun *
279*4882a593Smuzhiyun * @varname: Variable to look up
280*4882a593Smuzhiyun * @return value of variable, or NULL if not found
281*4882a593Smuzhiyun */
282*4882a593Smuzhiyun char *env_get(const char *varname);
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun /**
285*4882a593Smuzhiyun * env_get_f() - Look up the value of an environment variable (early)
286*4882a593Smuzhiyun *
287*4882a593Smuzhiyun * This function is called from env_get() if the environment has not been
288*4882a593Smuzhiyun * loaded yet (GD_FLG_ENV_READY flag is 0). Some environment locations will
289*4882a593Smuzhiyun * support reading the value (slowly) and some will not.
290*4882a593Smuzhiyun *
291*4882a593Smuzhiyun * @varname: Variable to look up
292*4882a593Smuzhiyun * @return value of variable, or NULL if not found
293*4882a593Smuzhiyun */
294*4882a593Smuzhiyun int env_get_f(const char *name, char *buf, unsigned len);
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun /**
297*4882a593Smuzhiyun * env_get_ulong() - Return an environment variable as an integer value
298*4882a593Smuzhiyun *
299*4882a593Smuzhiyun * Most U-Boot environment variables store hex values. For those which store
300*4882a593Smuzhiyun * (e.g.) base-10 integers, this function can be used to read the value.
301*4882a593Smuzhiyun *
302*4882a593Smuzhiyun * @name: Variable to look up
303*4882a593Smuzhiyun * @base: Base to use (e.g. 10 for base 10, 2 for binary)
304*4882a593Smuzhiyun * @default_val: Default value to return if no value is found
305*4882a593Smuzhiyun * @return the value found, or @default_val if none
306*4882a593Smuzhiyun */
307*4882a593Smuzhiyun ulong env_get_ulong(const char *name, int base, ulong default_val);
308*4882a593Smuzhiyun
309*4882a593Smuzhiyun /**
310*4882a593Smuzhiyun * env_get_hex() - Return an environment variable as a hex value
311*4882a593Smuzhiyun *
312*4882a593Smuzhiyun * Decode an environment as a hex number (it may or may not have a 0x
313*4882a593Smuzhiyun * prefix). If the environment variable cannot be found, or does not start
314*4882a593Smuzhiyun * with hex digits, the default value is returned.
315*4882a593Smuzhiyun *
316*4882a593Smuzhiyun * @varname: Variable to decode
317*4882a593Smuzhiyun * @default_val: Value to return on error
318*4882a593Smuzhiyun */
319*4882a593Smuzhiyun ulong env_get_hex(const char *varname, ulong default_val);
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun /*
322*4882a593Smuzhiyun * Read an environment variable as a boolean
323*4882a593Smuzhiyun * Return -1 if variable does not exist (default to true)
324*4882a593Smuzhiyun */
325*4882a593Smuzhiyun int env_get_yesno(const char *var);
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun /**
328*4882a593Smuzhiyun * env_set() - set an environment variable
329*4882a593Smuzhiyun *
330*4882a593Smuzhiyun * This sets or deletes the value of an environment variable. For setting the
331*4882a593Smuzhiyun * value the variable is created if it does not already exist.
332*4882a593Smuzhiyun *
333*4882a593Smuzhiyun * @varname: Variable to adjust
334*4882a593Smuzhiyun * @value: Value to set for the variable, or NULL or "" to delete the variable
335*4882a593Smuzhiyun * @return 0 if OK, 1 on error
336*4882a593Smuzhiyun */
337*4882a593Smuzhiyun int env_set(const char *varname, const char *value);
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun /**
340*4882a593Smuzhiyun * env_update() - update sub value of an environment variable
341*4882a593Smuzhiyun *
342*4882a593Smuzhiyun * This add/append/replace the sub value of an environment variable.
343*4882a593Smuzhiyun *
344*4882a593Smuzhiyun * @varname: Variable to adjust
345*4882a593Smuzhiyun * @valude: Value to append/replace
346*4882a593Smuzhiyun * @ignore: Value to be ignore if in varvalue
347*4882a593Smuzhiyun * @return 0 if OK, 1 on error
348*4882a593Smuzhiyun */
349*4882a593Smuzhiyun int env_update_filter(const char *varname, const char *varvalue,
350*4882a593Smuzhiyun const char *ignore);
351*4882a593Smuzhiyun
352*4882a593Smuzhiyun /**
353*4882a593Smuzhiyun * env_update_extract_subset() - extract subset value from an environment variable
354*4882a593Smuzhiyun *
355*4882a593Smuzhiyun * This extract subset value from an environment variable
356*4882a593Smuzhiyun *
357*4882a593Smuzhiyun * @varname: Parent Variable where to extract subset value, the subset value
358*4882a593Smuzhiyun * will be removed from it.
359*4882a593Smuzhiyun * @subset_varname: Variable to save subset value
360*4882a593Smuzhiyun * @subset_key: Key value to find out subset value
361*4882a593Smuzhiyun * @return 0 if OK, 1 on error
362*4882a593Smuzhiyun */
363*4882a593Smuzhiyun int env_update_extract_subset(const char *varname,
364*4882a593Smuzhiyun const char *subset_varname,
365*4882a593Smuzhiyun const char *subset_key);
366*4882a593Smuzhiyun /**
367*4882a593Smuzhiyun * env_update() - update sub value of an environment variable
368*4882a593Smuzhiyun *
369*4882a593Smuzhiyun * This add/append/replace the sub value of an environment variable.
370*4882a593Smuzhiyun *
371*4882a593Smuzhiyun * @varname: Variable to adjust
372*4882a593Smuzhiyun * @valude: Value to append/replace
373*4882a593Smuzhiyun * @return 0 if OK, 1 on error
374*4882a593Smuzhiyun */
375*4882a593Smuzhiyun int env_update(const char *varname, const char *varvalue);
376*4882a593Smuzhiyun
377*4882a593Smuzhiyun /**
378*4882a593Smuzhiyun * env_exist() - check sub value of an environment variable is exist or not
379*4882a593Smuzhiyun *
380*4882a593Smuzhiyun * @varname: Variable to look up
381*4882a593Smuzhiyun * @value: Value to check
382*4882a593Smuzhiyun * @return posItion of varvalue if exist, otherwise NULL
383*4882a593Smuzhiyun */
384*4882a593Smuzhiyun char *env_exist(const char *varname, const char *varvalue);
385*4882a593Smuzhiyun
386*4882a593Smuzhiyun /**
387*4882a593Smuzhiyun * env_delete() - delete sub value of an environment variable
388*4882a593Smuzhiyun *
389*4882a593Smuzhiyun * @varname: Variable to look up
390*4882a593Smuzhiyun * @value: Item head of value to delete
391*4882a593Smuzhiyun * @complete_match: complete match whole words
392*4882a593Smuzhiyun * @return 0 if ok, 1 on error
393*4882a593Smuzhiyun */
394*4882a593Smuzhiyun int env_delete(const char *varname, const char *varvalue, int complete_match);
395*4882a593Smuzhiyun
396*4882a593Smuzhiyun /**
397*4882a593Smuzhiyun * env_set_ulong() - set an environment variable to an integer
398*4882a593Smuzhiyun *
399*4882a593Smuzhiyun * @varname: Variable to adjust
400*4882a593Smuzhiyun * @value: Value to set for the variable (will be converted to a string)
401*4882a593Smuzhiyun * @return 0 if OK, 1 on error
402*4882a593Smuzhiyun */
403*4882a593Smuzhiyun int env_set_ulong(const char *varname, ulong value);
404*4882a593Smuzhiyun
405*4882a593Smuzhiyun /**
406*4882a593Smuzhiyun * env_set_hex() - set an environment variable to a hex value
407*4882a593Smuzhiyun *
408*4882a593Smuzhiyun * @varname: Variable to adjust
409*4882a593Smuzhiyun * @value: Value to set for the variable (will be converted to a hex string)
410*4882a593Smuzhiyun * @return 0 if OK, 1 on error
411*4882a593Smuzhiyun */
412*4882a593Smuzhiyun int env_set_hex(const char *varname, ulong value);
413*4882a593Smuzhiyun
414*4882a593Smuzhiyun /**
415*4882a593Smuzhiyun * env_set_addr - Set an environment variable to an address in hex
416*4882a593Smuzhiyun *
417*4882a593Smuzhiyun * @varname: Environment variable to set
418*4882a593Smuzhiyun * @addr: Value to set it to
419*4882a593Smuzhiyun * @return 0 if ok, 1 on error
420*4882a593Smuzhiyun */
env_set_addr(const char * varname,const void * addr)421*4882a593Smuzhiyun static inline int env_set_addr(const char *varname, const void *addr)
422*4882a593Smuzhiyun {
423*4882a593Smuzhiyun return env_set_hex(varname, (ulong)addr);
424*4882a593Smuzhiyun }
425*4882a593Smuzhiyun
426*4882a593Smuzhiyun #ifdef CONFIG_AUTO_COMPLETE
427*4882a593Smuzhiyun int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
428*4882a593Smuzhiyun #endif
429*4882a593Smuzhiyun int get_env_id (void);
430*4882a593Smuzhiyun
431*4882a593Smuzhiyun void pci_init (void);
432*4882a593Smuzhiyun void pci_init_board(void);
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun #if defined(CONFIG_DTB_RESELECT)
435*4882a593Smuzhiyun int embedded_dtb_select(void);
436*4882a593Smuzhiyun #endif
437*4882a593Smuzhiyun
438*4882a593Smuzhiyun int misc_init_f (void);
439*4882a593Smuzhiyun int misc_init_r (void);
440*4882a593Smuzhiyun
441*4882a593Smuzhiyun /* common/exports.c */
442*4882a593Smuzhiyun void jumptable_init(void);
443*4882a593Smuzhiyun
444*4882a593Smuzhiyun /* common/kallsysm.c */
445*4882a593Smuzhiyun const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
446*4882a593Smuzhiyun
447*4882a593Smuzhiyun /* common/memsize.c */
448*4882a593Smuzhiyun long get_ram_size (long *, long);
449*4882a593Smuzhiyun phys_size_t get_effective_memsize(void);
450*4882a593Smuzhiyun
451*4882a593Smuzhiyun /* $(BOARD)/$(BOARD).c */
452*4882a593Smuzhiyun void reset_phy (void);
453*4882a593Smuzhiyun void fdc_hw_init (void);
454*4882a593Smuzhiyun
455*4882a593Smuzhiyun /* $(BOARD)/eeprom.c */
456*4882a593Smuzhiyun #ifdef CONFIG_CMD_EEPROM
457*4882a593Smuzhiyun void eeprom_init (int bus);
458*4882a593Smuzhiyun int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
459*4882a593Smuzhiyun int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
460*4882a593Smuzhiyun #else
461*4882a593Smuzhiyun /*
462*4882a593Smuzhiyun * Some EEPROM code is depecated because it used the legacy I2C interface. Add
463*4882a593Smuzhiyun * some macros here so we don't have to touch every one of those uses
464*4882a593Smuzhiyun */
465*4882a593Smuzhiyun #define eeprom_init(bus)
466*4882a593Smuzhiyun #define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
467*4882a593Smuzhiyun #define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
468*4882a593Smuzhiyun #endif
469*4882a593Smuzhiyun
470*4882a593Smuzhiyun #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
471*4882a593Smuzhiyun # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
472*4882a593Smuzhiyun #endif
473*4882a593Smuzhiyun
474*4882a593Smuzhiyun #if defined(CONFIG_MPC8XX_SPI)
475*4882a593Smuzhiyun extern void spi_init_f (void);
476*4882a593Smuzhiyun extern void spi_init_r (void);
477*4882a593Smuzhiyun extern ssize_t spi_read (uchar *, int, uchar *, int);
478*4882a593Smuzhiyun extern ssize_t spi_write (uchar *, int, uchar *, int);
479*4882a593Smuzhiyun #endif
480*4882a593Smuzhiyun
481*4882a593Smuzhiyun /* $(BOARD)/$(BOARD).c */
482*4882a593Smuzhiyun int board_early_init_f (void);
483*4882a593Smuzhiyun int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */
484*4882a593Smuzhiyun int board_late_init (void);
485*4882a593Smuzhiyun int board_postclk_init (void); /* after clocks/timebase, before env/serial */
486*4882a593Smuzhiyun int board_early_init_r (void);
487*4882a593Smuzhiyun void board_poweroff (void);
488*4882a593Smuzhiyun void board_env_fixup(void);
489*4882a593Smuzhiyun
490*4882a593Smuzhiyun #if defined(CONFIG_SYS_DRAM_TEST)
491*4882a593Smuzhiyun int testdram(void);
492*4882a593Smuzhiyun #endif /* CONFIG_SYS_DRAM_TEST */
493*4882a593Smuzhiyun
494*4882a593Smuzhiyun /* $(CPU)/start.S */
495*4882a593Smuzhiyun int icache_status (void);
496*4882a593Smuzhiyun void icache_enable (void);
497*4882a593Smuzhiyun void icache_disable(void);
498*4882a593Smuzhiyun int dcache_status (void);
499*4882a593Smuzhiyun void dcache_enable (void);
500*4882a593Smuzhiyun void dcache_disable(void);
501*4882a593Smuzhiyun void mmu_disable(void);
502*4882a593Smuzhiyun #if defined(CONFIG_ARM)
503*4882a593Smuzhiyun void relocate_code(ulong);
504*4882a593Smuzhiyun #else
505*4882a593Smuzhiyun void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
506*4882a593Smuzhiyun #endif
507*4882a593Smuzhiyun ulong get_endaddr (void);
508*4882a593Smuzhiyun void trap_init (ulong);
509*4882a593Smuzhiyun
510*4882a593Smuzhiyun /* $(CPU)/cpu.c */
cpumask_next(int cpu,unsigned int mask)511*4882a593Smuzhiyun static inline int cpumask_next(int cpu, unsigned int mask)
512*4882a593Smuzhiyun {
513*4882a593Smuzhiyun for (cpu++; !((1 << cpu) & mask); cpu++)
514*4882a593Smuzhiyun ;
515*4882a593Smuzhiyun
516*4882a593Smuzhiyun return cpu;
517*4882a593Smuzhiyun }
518*4882a593Smuzhiyun
519*4882a593Smuzhiyun #define for_each_cpu(iter, cpu, num_cpus, mask) \
520*4882a593Smuzhiyun for (iter = 0, cpu = cpumask_next(-1, mask); \
521*4882a593Smuzhiyun iter < num_cpus; \
522*4882a593Smuzhiyun iter++, cpu = cpumask_next(cpu, mask)) \
523*4882a593Smuzhiyun
524*4882a593Smuzhiyun int cpu_numcores (void);
525*4882a593Smuzhiyun int cpu_num_dspcores(void);
526*4882a593Smuzhiyun u32 cpu_mask (void);
527*4882a593Smuzhiyun u32 cpu_dsp_mask(void);
528*4882a593Smuzhiyun int is_core_valid (unsigned int);
529*4882a593Smuzhiyun
530*4882a593Smuzhiyun /**
531*4882a593Smuzhiyun * arch_cpu_init() - basic cpu-dependent setup for an architecture
532*4882a593Smuzhiyun *
533*4882a593Smuzhiyun * This is called after early malloc is available. It should handle any
534*4882a593Smuzhiyun * CPU- or SoC- specific init needed to continue the init sequence. See
535*4882a593Smuzhiyun * board_f.c for where it is called. If this is not provided, a default
536*4882a593Smuzhiyun * version (which does nothing) will be used.
537*4882a593Smuzhiyun */
538*4882a593Smuzhiyun int arch_cpu_init(void);
539*4882a593Smuzhiyun
540*4882a593Smuzhiyun void s_init(void);
541*4882a593Smuzhiyun
542*4882a593Smuzhiyun int checkcpu (void);
543*4882a593Smuzhiyun int checkicache (void);
544*4882a593Smuzhiyun int checkdcache (void);
545*4882a593Smuzhiyun void upmconfig (unsigned int, unsigned int *, unsigned int);
546*4882a593Smuzhiyun ulong get_tbclk (void);
547*4882a593Smuzhiyun void reset_misc (void);
548*4882a593Smuzhiyun void reset_cpu (ulong addr);
549*4882a593Smuzhiyun void ft_cpu_setup(void *blob, bd_t *bd);
550*4882a593Smuzhiyun void ft_pci_setup(void *blob, bd_t *bd);
551*4882a593Smuzhiyun
552*4882a593Smuzhiyun void smp_set_core_boot_addr(unsigned long addr, int corenr);
553*4882a593Smuzhiyun void smp_kick_all_cpus(void);
554*4882a593Smuzhiyun
555*4882a593Smuzhiyun /* $(CPU)/serial.c */
556*4882a593Smuzhiyun int serial_init (void);
557*4882a593Smuzhiyun void serial_setbrg (void);
558*4882a593Smuzhiyun void serial_putc (const char);
559*4882a593Smuzhiyun void serial_clear (void);
560*4882a593Smuzhiyun void serial_putc_raw(const char);
561*4882a593Smuzhiyun void serial_puts (const char *);
562*4882a593Smuzhiyun int serial_getc (void);
563*4882a593Smuzhiyun int serial_tstc (void);
564*4882a593Smuzhiyun
565*4882a593Smuzhiyun /* $(CPU)/speed.c */
566*4882a593Smuzhiyun int get_clocks (void);
567*4882a593Smuzhiyun ulong get_bus_freq (ulong);
568*4882a593Smuzhiyun int get_serial_clock(void);
569*4882a593Smuzhiyun
570*4882a593Smuzhiyun int cpu_init_r (void);
571*4882a593Smuzhiyun
572*4882a593Smuzhiyun /* $(CPU)/interrupts.c */
573*4882a593Smuzhiyun int interrupt_init (void);
574*4882a593Smuzhiyun void timer_interrupt (struct pt_regs *);
575*4882a593Smuzhiyun void external_interrupt (struct pt_regs *);
576*4882a593Smuzhiyun void irq_install_handler(int, interrupt_handler_t *, void *);
577*4882a593Smuzhiyun void irq_free_handler (int);
578*4882a593Smuzhiyun void reset_timer (void);
579*4882a593Smuzhiyun
580*4882a593Smuzhiyun /* Return value of monotonic microsecond timer */
581*4882a593Smuzhiyun unsigned long timer_get_us(void);
582*4882a593Smuzhiyun
583*4882a593Smuzhiyun void enable_interrupts (void);
584*4882a593Smuzhiyun int disable_interrupts (void);
585*4882a593Smuzhiyun
586*4882a593Smuzhiyun /* $(CPU)/.../commproc.c */
587*4882a593Smuzhiyun int dpram_init (void);
588*4882a593Smuzhiyun uint dpram_base(void);
589*4882a593Smuzhiyun uint dpram_base_align(uint align);
590*4882a593Smuzhiyun uint dpram_alloc(uint size);
591*4882a593Smuzhiyun uint dpram_alloc_align(uint size,uint align);
592*4882a593Smuzhiyun void bootcount_store (ulong);
593*4882a593Smuzhiyun ulong bootcount_load (void);
594*4882a593Smuzhiyun #define BOOTCOUNT_MAGIC 0xB001C041
595*4882a593Smuzhiyun
596*4882a593Smuzhiyun /* $(CPU)/.../<eth> */
597*4882a593Smuzhiyun void mii_init (void);
598*4882a593Smuzhiyun
599*4882a593Smuzhiyun /* $(CPU)/.../lcd.c */
600*4882a593Smuzhiyun ulong lcd_setmem (ulong);
601*4882a593Smuzhiyun
602*4882a593Smuzhiyun /* $(CPU)/.../video.c */
603*4882a593Smuzhiyun ulong video_setmem (ulong);
604*4882a593Smuzhiyun
605*4882a593Smuzhiyun /* arch/$(ARCH)/lib/cache.c */
606*4882a593Smuzhiyun void enable_caches(void);
607*4882a593Smuzhiyun void flush_cache (unsigned long, unsigned long);
608*4882a593Smuzhiyun void flush_dcache_all(void);
609*4882a593Smuzhiyun void flush_dcache_range(unsigned long start, unsigned long stop);
610*4882a593Smuzhiyun void invalidate_dcache_range(unsigned long start, unsigned long stop);
611*4882a593Smuzhiyun void invalidate_dcache_all(void);
612*4882a593Smuzhiyun void invalidate_icache_all(void);
613*4882a593Smuzhiyun
614*4882a593Smuzhiyun enum {
615*4882a593Smuzhiyun /* Disable caches (else flush caches but leave them active) */
616*4882a593Smuzhiyun CBL_DISABLE_CACHES = 1 << 0,
617*4882a593Smuzhiyun CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1,
618*4882a593Smuzhiyun
619*4882a593Smuzhiyun CBL_ALL = 3,
620*4882a593Smuzhiyun };
621*4882a593Smuzhiyun
622*4882a593Smuzhiyun /**
623*4882a593Smuzhiyun * Clean up ready for linux
624*4882a593Smuzhiyun *
625*4882a593Smuzhiyun * @param flags Flags to control what is done
626*4882a593Smuzhiyun */
627*4882a593Smuzhiyun int cleanup_before_linux_select(int flags);
628*4882a593Smuzhiyun
629*4882a593Smuzhiyun /* arch/$(ARCH)/lib/ticks.S */
630*4882a593Smuzhiyun uint64_t get_ticks(void);
631*4882a593Smuzhiyun void wait_ticks (unsigned long);
632*4882a593Smuzhiyun
633*4882a593Smuzhiyun /* arch/$(ARCH)/lib/time.c */
634*4882a593Smuzhiyun ulong usec2ticks (unsigned long usec);
635*4882a593Smuzhiyun ulong ticks2usec (unsigned long ticks);
636*4882a593Smuzhiyun
637*4882a593Smuzhiyun /* lib/gunzip.c */
638*4882a593Smuzhiyun int gzip_parse_header(const unsigned char *src, unsigned long len);
639*4882a593Smuzhiyun int gunzip(void *, int, unsigned char *, unsigned long *);
640*4882a593Smuzhiyun int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
641*4882a593Smuzhiyun int stoponerr, int offset);
642*4882a593Smuzhiyun
643*4882a593Smuzhiyun /**
644*4882a593Smuzhiyun * gzwrite progress indicators: defined weak to allow board-specific
645*4882a593Smuzhiyun * overrides:
646*4882a593Smuzhiyun *
647*4882a593Smuzhiyun * gzwrite_progress_init called on startup
648*4882a593Smuzhiyun * gzwrite_progress called during decompress/write loop
649*4882a593Smuzhiyun * gzwrite_progress_finish called at end of loop to
650*4882a593Smuzhiyun * indicate success (retcode=0) or failure
651*4882a593Smuzhiyun */
652*4882a593Smuzhiyun void gzwrite_progress_init(u64 expected_size);
653*4882a593Smuzhiyun
654*4882a593Smuzhiyun void gzwrite_progress(int iteration,
655*4882a593Smuzhiyun u64 bytes_written,
656*4882a593Smuzhiyun u64 total_bytes);
657*4882a593Smuzhiyun
658*4882a593Smuzhiyun void gzwrite_progress_finish(int retcode,
659*4882a593Smuzhiyun u64 totalwritten,
660*4882a593Smuzhiyun u64 totalsize,
661*4882a593Smuzhiyun u32 expected_crc,
662*4882a593Smuzhiyun u32 calculated_crc);
663*4882a593Smuzhiyun
664*4882a593Smuzhiyun /**
665*4882a593Smuzhiyun * decompress and write gzipped image from memory to block device
666*4882a593Smuzhiyun *
667*4882a593Smuzhiyun * @param src compressed image address
668*4882a593Smuzhiyun * @param len compressed image length in bytes
669*4882a593Smuzhiyun * @param dev block device descriptor
670*4882a593Smuzhiyun * @param szwritebuf bytes per write (pad to erase size)
671*4882a593Smuzhiyun * @param startoffs offset in bytes of first write
672*4882a593Smuzhiyun * @param szexpected expected uncompressed length
673*4882a593Smuzhiyun * may be zero to use gzip trailer
674*4882a593Smuzhiyun * for files under 4GiB
675*4882a593Smuzhiyun */
676*4882a593Smuzhiyun int gzwrite(unsigned char *src, int len,
677*4882a593Smuzhiyun struct blk_desc *dev,
678*4882a593Smuzhiyun unsigned long szwritebuf,
679*4882a593Smuzhiyun u64 startoffs,
680*4882a593Smuzhiyun u64 szexpected);
681*4882a593Smuzhiyun
682*4882a593Smuzhiyun #include <u-boot/lz4.h>
683*4882a593Smuzhiyun
684*4882a593Smuzhiyun /* lib/qsort.c */
685*4882a593Smuzhiyun void qsort(void *base, size_t nmemb, size_t size,
686*4882a593Smuzhiyun int(*compar)(const void *, const void *));
687*4882a593Smuzhiyun int strcmp_compar(const void *, const void *);
688*4882a593Smuzhiyun
689*4882a593Smuzhiyun /* lib/uuid.c */
690*4882a593Smuzhiyun #include <uuid.h>
691*4882a593Smuzhiyun
692*4882a593Smuzhiyun /* lib/vsprintf.c */
693*4882a593Smuzhiyun #include <vsprintf.h>
694*4882a593Smuzhiyun
695*4882a593Smuzhiyun /* lib/strmhz.c */
696*4882a593Smuzhiyun char * strmhz(char *buf, unsigned long hz);
697*4882a593Smuzhiyun
698*4882a593Smuzhiyun /* lib/crc32.c */
699*4882a593Smuzhiyun #include <u-boot/crc.h>
700*4882a593Smuzhiyun
701*4882a593Smuzhiyun /* lib/rand.c */
702*4882a593Smuzhiyun #define RAND_MAX -1U
703*4882a593Smuzhiyun void srand(unsigned int seed);
704*4882a593Smuzhiyun unsigned int rand(void);
705*4882a593Smuzhiyun unsigned int rand_r(unsigned int *seedp);
706*4882a593Smuzhiyun
707*4882a593Smuzhiyun /*
708*4882a593Smuzhiyun * STDIO based functions (can always be used)
709*4882a593Smuzhiyun */
710*4882a593Smuzhiyun /* serial stuff */
711*4882a593Smuzhiyun int serial_printf (const char *fmt, ...)
712*4882a593Smuzhiyun __attribute__ ((format (__printf__, 1, 2)));
713*4882a593Smuzhiyun
714*4882a593Smuzhiyun /* lib/gzip.c */
715*4882a593Smuzhiyun int gzip(void *dst, unsigned long *lenp,
716*4882a593Smuzhiyun unsigned char *src, unsigned long srclen);
717*4882a593Smuzhiyun int zzip(void *dst, unsigned long *lenp, unsigned char *src,
718*4882a593Smuzhiyun unsigned long srclen, int stoponerr,
719*4882a593Smuzhiyun int (*func)(unsigned long, unsigned long));
720*4882a593Smuzhiyun
721*4882a593Smuzhiyun /* lib/net_utils.c */
722*4882a593Smuzhiyun #include <net.h>
env_get_ip(char * var)723*4882a593Smuzhiyun static inline struct in_addr env_get_ip(char *var)
724*4882a593Smuzhiyun {
725*4882a593Smuzhiyun return string_to_ip(env_get(var));
726*4882a593Smuzhiyun }
727*4882a593Smuzhiyun
728*4882a593Smuzhiyun int pcmcia_init (void);
729*4882a593Smuzhiyun
730*4882a593Smuzhiyun #ifdef CONFIG_LED_STATUS
731*4882a593Smuzhiyun # include <status_led.h>
732*4882a593Smuzhiyun #endif
733*4882a593Smuzhiyun
734*4882a593Smuzhiyun #include <bootstage.h>
735*4882a593Smuzhiyun
736*4882a593Smuzhiyun #ifdef CONFIG_SHOW_ACTIVITY
737*4882a593Smuzhiyun void show_activity(int arg);
738*4882a593Smuzhiyun #endif
739*4882a593Smuzhiyun
740*4882a593Smuzhiyun /* Multicore arch functions */
741*4882a593Smuzhiyun #ifdef CONFIG_MP
742*4882a593Smuzhiyun int cpu_status(int nr);
743*4882a593Smuzhiyun int cpu_reset(int nr);
744*4882a593Smuzhiyun int cpu_disable(int nr);
745*4882a593Smuzhiyun int cpu_release(int nr, int argc, char * const argv[]);
746*4882a593Smuzhiyun #endif
747*4882a593Smuzhiyun
748*4882a593Smuzhiyun #else /* __ASSEMBLY__ */
749*4882a593Smuzhiyun
750*4882a593Smuzhiyun /* Drop a C type modifier (like in 3UL) for constants used in assembly. */
751*4882a593Smuzhiyun #define _AC(X, Y) X
752*4882a593Smuzhiyun
753*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
754*4882a593Smuzhiyun
755*4882a593Smuzhiyun /* Put only stuff here that the assembler can digest */
756*4882a593Smuzhiyun
757*4882a593Smuzhiyun /* Declare an unsigned long constant digestable both by C and an assembler. */
758*4882a593Smuzhiyun #define UL(x) _AC(x, UL)
759*4882a593Smuzhiyun
760*4882a593Smuzhiyun #ifdef CONFIG_POST
761*4882a593Smuzhiyun #define CONFIG_HAS_POST
762*4882a593Smuzhiyun #ifndef CONFIG_POST_ALT_LIST
763*4882a593Smuzhiyun #define CONFIG_POST_STD_LIST
764*4882a593Smuzhiyun #endif
765*4882a593Smuzhiyun #endif
766*4882a593Smuzhiyun
767*4882a593Smuzhiyun #ifdef CONFIG_INIT_CRITICAL
768*4882a593Smuzhiyun #error CONFIG_INIT_CRITICAL is deprecated!
769*4882a593Smuzhiyun #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
770*4882a593Smuzhiyun #endif
771*4882a593Smuzhiyun
772*4882a593Smuzhiyun #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
773*4882a593Smuzhiyun
774*4882a593Smuzhiyun /*
775*4882a593Smuzhiyun * check_member() - Check the offset of a structure member
776*4882a593Smuzhiyun *
777*4882a593Smuzhiyun * @structure: Name of structure (e.g. global_data)
778*4882a593Smuzhiyun * @member: Name of member (e.g. baudrate)
779*4882a593Smuzhiyun * @offset: Expected offset in bytes
780*4882a593Smuzhiyun */
781*4882a593Smuzhiyun #define check_member(structure, member, offset) _Static_assert( \
782*4882a593Smuzhiyun offsetof(struct structure, member) == offset, \
783*4882a593Smuzhiyun "`struct " #structure "` offset for `" #member "` is not " #offset)
784*4882a593Smuzhiyun
785*4882a593Smuzhiyun /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
786*4882a593Smuzhiyun #ifdef CONFIG_EFI_STUB
787*4882a593Smuzhiyun #define ll_boot_init() false
788*4882a593Smuzhiyun #else
789*4882a593Smuzhiyun #define ll_boot_init() true
790*4882a593Smuzhiyun #endif
791*4882a593Smuzhiyun
792*4882a593Smuzhiyun /* Pull in stuff for the build system */
793*4882a593Smuzhiyun #ifdef DO_DEPS_ONLY
794*4882a593Smuzhiyun # include <environment.h>
795*4882a593Smuzhiyun #endif
796*4882a593Smuzhiyun
797*4882a593Smuzhiyun #endif /* __COMMON_H_ */
798