xref: /openbmc/u-boot/lib/asm-offsets.c (revision f739fcd8)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Adapted from Linux v2.6.36 kernel: arch/powerpc/kernel/asm-offsets.c
4  *
5  * This program is used to generate definitions needed by
6  * assembly language modules.
7  *
8  * We use the technique used in the OSF Mach kernel code:
9  * generate asm statements containing #defines,
10  * compile this file to assembler, and then extract the
11  * #defines from the assembly-language output.
12  */
13 
14 #include <common.h>
15 
16 #include <linux/kbuild.h>
17 
18 int main(void)
19 {
20 	/* Round up to make sure size gives nice stack alignment */
21 	DEFINE(GENERATED_GBL_DATA_SIZE,
22 		(sizeof(struct global_data) + 15) & ~15);
23 
24 	DEFINE(GENERATED_BD_INFO_SIZE,
25 		(sizeof(struct bd_info) + 15) & ~15);
26 
27 	DEFINE(GD_SIZE, sizeof(struct global_data));
28 
29 	DEFINE(GD_BD, offsetof(struct global_data, bd));
30 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
31 	DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
32 #endif
33 
34 	DEFINE(GD_RELOCADDR, offsetof(struct global_data, relocaddr));
35 
36 	DEFINE(GD_RELOC_OFF, offsetof(struct global_data, reloc_off));
37 
38 	DEFINE(GD_START_ADDR_SP, offsetof(struct global_data, start_addr_sp));
39 
40 	DEFINE(GD_NEW_GD, offsetof(struct global_data, new_gd));
41 
42 	return 0;
43 }
44