Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 2 | /* |
Simon Glass | 1ed83ba | 2019-08-02 09:44:27 -0600 | [diff] [blame] | 3 | * Common header file for U-Boot |
| 4 | * |
| 5 | * This file still includes quite a bit of stuff that should be in separate |
Simon Glass | adaaa48 | 2019-11-14 12:57:43 -0700 | [diff] [blame] | 6 | * headers. Please think before adding more things. |
Simon Glass | 495a5dc | 2019-11-14 12:57:30 -0700 | [diff] [blame] | 7 | * Patches to remove things are welcome. |
Simon Glass | 1ed83ba | 2019-08-02 09:44:27 -0600 | [diff] [blame] | 8 | * |
Wolfgang Denk | f342f86 | 2009-05-16 10:47:45 +0200 | [diff] [blame] | 9 | * (C) Copyright 2000-2009 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 10 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #ifndef __COMMON_H_ |
Wolfgang Denk | bcbd521 | 2012-01-06 07:36:44 +0100 | [diff] [blame] | 14 | #define __COMMON_H_ 1 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 15 | |
Wolfgang Denk | 66e8d44 | 2009-07-24 00:17:48 +0200 | [diff] [blame] | 16 | #ifndef __ASSEMBLY__ /* put C only stuff in this section */ |
| 17 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 18 | #include <config.h> |
Joe Hershberger | cbf1a93 | 2016-04-04 04:07:33 -0500 | [diff] [blame] | 19 | #include <errno.h> |
Masahiro Yamada | a4f0b8e | 2016-12-28 00:36:00 +0900 | [diff] [blame] | 20 | #include <time.h> |
Wolfgang Denk | 0191e47 | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 21 | #include <asm-offsets.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 22 | #include <linux/bitops.h> |
Masahiro Yamada | 958f0f0 | 2017-09-16 14:10:45 +0900 | [diff] [blame] | 23 | #include <linux/bug.h> |
Masahiro Yamada | 29d2a62 | 2016-12-28 00:35:59 +0900 | [diff] [blame] | 24 | #include <linux/delay.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 25 | #include <linux/types.h> |
Masahiro Yamada | bf9c293 | 2017-09-16 14:10:40 +0900 | [diff] [blame] | 26 | #include <linux/printk.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 27 | #include <linux/string.h> |
Marek Vasut | a3f1634 | 2012-09-27 17:08:15 +0200 | [diff] [blame] | 28 | #include <linux/stringify.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 29 | #include <asm/ptrace.h> |
| 30 | #include <stdarg.h> |
Masahiro Yamada | 5e882e9 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 31 | #include <stdio.h> |
Masahiro Yamada | bd42662 | 2014-11-07 03:03:28 +0900 | [diff] [blame] | 32 | #include <linux/kernel.h> |
Simon Glass | 7613579 | 2017-05-17 08:23:05 -0600 | [diff] [blame] | 33 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 34 | #include <part.h> |
| 35 | #include <flash.h> |
| 36 | #include <image.h> |
| 37 | |
York Sun | 6c48001 | 2014-02-26 17:03:19 -0800 | [diff] [blame] | 38 | #ifdef __LP64__ |
| 39 | #define CONFIG_SYS_SUPPORT_64BIT_DATA |
| 40 | #endif |
| 41 | |
Simon Glass | 9054a02 | 2017-12-04 13:48:20 -0700 | [diff] [blame] | 42 | #include <log.h> |
Simon Glass | 02aa9e6 | 2011-06-29 09:49:34 +0000 | [diff] [blame] | 43 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 44 | #include <asm/u-boot.h> /* boot information for Linux kernel */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 45 | #include <asm/global_data.h> /* global data used for startup functions */ |
| 46 | |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 47 | /* startup functions, used in: |
| 48 | * common/board_f.c |
Patrick Delaunay | 98c8bbc | 2018-03-13 13:57:01 +0100 | [diff] [blame] | 49 | * common/init/board_init.c |
Patrick Delaunay | b76e7cf | 2018-03-13 13:57:02 +0100 | [diff] [blame] | 50 | * common/board_r.c |
Patrick Delaunay | b1d2344 | 2018-03-13 13:57:03 +0100 | [diff] [blame] | 51 | * common/board_info.c |
Patrick Delaunay | a0a2b21 | 2018-03-13 13:57:00 +0100 | [diff] [blame] | 52 | */ |
Patrick Delaunay | c6bfcd5 | 2018-03-09 18:28:12 +0100 | [diff] [blame] | 53 | #include <init.h> |
| 54 | |
wdenk | 452cfd6 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 55 | /* |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 56 | * Function Prototypes |
| 57 | */ |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 58 | void hang (void) __attribute__ ((noreturn)); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 59 | |
Simon Glass | 7da617c | 2015-04-28 20:25:07 -0600 | [diff] [blame] | 60 | #include <display_options.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 61 | |
Wolfgang Denk | 85c25df | 2009-04-01 23:34:12 +0200 | [diff] [blame] | 62 | /* common/cmd_source.c */ |
| 63 | int source (ulong addr, const char *fit_uname); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 64 | |
Simon Glass | 892265d | 2019-12-28 10:45:02 -0700 | [diff] [blame^] | 65 | extern ulong image_load_addr; /* Default Load Address */ |
| 66 | extern ulong image_save_addr; /* Default Save Address */ |
| 67 | extern ulong image_save_size; /* Default Save Size */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 68 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 69 | /* common/memsize.c */ |
Albert ARIBAUD | a960673 | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 70 | long get_ram_size (long *, long); |
York Sun | 863e8d8 | 2014-02-11 11:57:26 -0800 | [diff] [blame] | 71 | phys_size_t get_effective_memsize(void); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 72 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 73 | #if defined(CONFIG_SYS_DRAM_TEST) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 74 | int testdram(void); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 75 | #endif /* CONFIG_SYS_DRAM_TEST */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 76 | |
Jason Hobbs | 6e39cce | 2011-08-23 11:06:56 +0000 | [diff] [blame] | 77 | /* lib/uuid.c */ |
Przemyslaw Marczak | 0c81336 | 2014-04-02 10:20:03 +0200 | [diff] [blame] | 78 | #include <uuid.h> |
Jason Hobbs | 6e39cce | 2011-08-23 11:06:56 +0000 | [diff] [blame] | 79 | |
Peter Tyser | 685b7f5 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 80 | /* lib/vsprintf.c */ |
Simon Glass | f7ae6806 | 2011-11-02 09:52:07 +0000 | [diff] [blame] | 81 | #include <vsprintf.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 82 | |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 83 | /* lib/net_utils.c */ |
| 84 | #include <net.h> |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 85 | |
Simon Glass | 8445d00 | 2012-01-14 15:24:44 +0000 | [diff] [blame] | 86 | #include <bootstage.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 87 | |
Andre Przywara | 9fcee53 | 2017-01-02 11:48:30 +0000 | [diff] [blame] | 88 | #else /* __ASSEMBLY__ */ |
| 89 | |
Andre Przywara | 9fcee53 | 2017-01-02 11:48:30 +0000 | [diff] [blame] | 90 | #endif /* __ASSEMBLY__ */ |
Wolfgang Denk | 66e8d44 | 2009-07-24 00:17:48 +0200 | [diff] [blame] | 91 | |
| 92 | /* Put only stuff here that the assembler can digest */ |
| 93 | |
Anton Staaf | 07a036a | 2011-09-02 13:45:28 +0000 | [diff] [blame] | 94 | #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) |
Andy Fleming | 2ef5ed0 | 2008-06-16 13:58:53 -0500 | [diff] [blame] | 95 | |
Anton Staaf | cda2e48 | 2011-10-17 16:46:13 -0700 | [diff] [blame] | 96 | /* |
Simon Glass | d61718b | 2015-06-23 15:38:31 -0600 | [diff] [blame] | 97 | * check_member() - Check the offset of a structure member |
| 98 | * |
| 99 | * @structure: Name of structure (e.g. global_data) |
| 100 | * @member: Name of member (e.g. baudrate) |
| 101 | * @offset: Expected offset in bytes |
| 102 | */ |
| 103 | #define check_member(structure, member, offset) _Static_assert( \ |
| 104 | offsetof(struct structure, member) == offset, \ |
| 105 | "`struct " #structure "` offset for `" #member "` is not " #offset) |
| 106 | |
Mike Frysinger | 63b8f12 | 2011-07-08 10:44:25 +0000 | [diff] [blame] | 107 | /* Pull in stuff for the build system */ |
| 108 | #ifdef DO_DEPS_ONLY |
Simon Glass | 9d1f619 | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 109 | # include <env_internal.h> |
Mike Frysinger | 63b8f12 | 2011-07-08 10:44:25 +0000 | [diff] [blame] | 110 | #endif |
| 111 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 112 | #endif /* __COMMON_H_ */ |