summaryrefslogtreecommitdiffstats
path: root/include/common.h
Commit message (Collapse)AuthorAgeFilesLines
* include: move PAGE_ definitions into linux/pagemap.hAhmad Fatoum2023-09-211-5/+1
| | | | | | | | | | | <common.h> is a fat header and we shouldn't need to include it just to get a definition for PAGE_SIZE. In Linux PAGE_SIZE is defined per architecture, but in barebox we only have 4K pages so far, so let's move it into <linux/pagemap.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230911150900.3584523-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* relocate_to_current_adr: hang directly on error instead of panic()Ahmad Fatoum2022-10-051-0/+6
| | | | | | | | | | | | | | | | panic() will format a panic message, turn on a panic LED, dump a stack trace and finally either restart the system or print a message to ask the user to restart the system before hanging. When relocation fails, all of these aren't possible, so instead of devolving into undefined behavior, fall directly into an infinite loop. Motivation for this change is to avoid linking printf code when it's only usage is the relocation error case. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220930154247.756577-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: add generic of_prepend_machine_compatible()Oleksij Rempel2022-05-051-0/+3
| | | | | | | | Add generic function to extend/fixup machine compatible. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220503091220.3871612-4-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: add $global.serial_number with device tree fixupAhmad Fatoum2022-05-051-0/+3
| | | | | | | | | | | This new variable can be set by boards from C code or from the environment to change the serial number fixed up into the kernel device tree. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220503091220.3871612-2-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: move ARRAY_AND_SIZE to <linux/kernel.h>Ahmad Fatoum2021-11-011-2/+0
| | | | | | | | | | Linux defines this macro at multiple places. We define it once, but in <common.h>, which is a bit heavy weight. Move it next to the ARRAY_SIZE() definition. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141739.2207431-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: <asm-generic/bug.h>: make self-containedAhmad Fatoum2021-11-011-9/+0
| | | | | | | | | | <asm-generic/bug.h> so far depended on a preceding <common.h> to get the dump_stack() definition. Move dump_stack() to the new printk.h and drop the remaining puts() use to make header self-contained. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141739.2207431-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: add dedicated header for printf/printkAhmad Fatoum2021-11-011-1/+1
| | | | | | | | | | | | Including <stdio.h> for printf is a bit problematic, because it pulls in other headers for <console.h>, which includes quite a few more headers as well. To make it easier to share code between barebox and host tools make <printk.h> the new minimal header for printf and move the extra logging stuff into <linux/printk.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141739.2207431-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: print buildsystem version in barebox bannerSteffen Trumtrar2020-09-251-0/+1
| | | | | | | | | When the barebox banner is enabled and printed during startup, also show information about the buildsystem version: the exact state of the barebox binary and its config. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: Fix do_autoboot_countdown() running multiple timesSascha Hauer2020-06-261-0/+1
| | | | | | | | | | The comment above do_autoboot_countdown() states: "This function can be called multiple times, it is executed only the first time.". Since 1973892533 ("startup: don't clobber original autoboot state") This is no longer the case. Bring back the old and documented behaviour. Fixes: 1973892533 ("startup: don't clobber original autoboot state") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common.h: move the generic IOMEM definition to asm-generic/io.hMasahiro Yamada2020-05-051-4/+0
| | | | | | | | | | | arch/mips/include/asm/io.h defines arch-specific IOMEM(). The generic definition of IOMEM() should go to asm-generic/io.h because it is a collection of fallback defaults when there is no specific definition in <asm/io.h>. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common.h: move and rename lregion_overlap()Masahiro Yamada2020-05-051-14/+0
| | | | | | | | | | | | lregion_overlap() is only used by common/startup.c There is no need to define it in include/common.h While I was here, I also renamed it to region_overlap(), and got rid of the 'inline' keyword. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common.h: remove unused region_overlap()Masahiro Yamada2020-05-051-9/+0
| | | | | | | This is not used at all. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWNAhmad Fatoum2020-04-271-1/+1
| | | | | | | | | If we export the autoboot state variable for customization, having unknown as default is not so helpful. Rename it to what actually happens (abortable countdown). Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: add SPDX GPL-2.0-or-later license tags where applicableRoland Hieber2020-02-171-11/+1
| | | | | | Signed-off-by: Roland Hieber <rohieb@rohieb.name> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: provide stubs for ctrlc_* functionsLucas Stach2019-12-021-0/+5
| | | | | | | | Currently the stubs are only provided for CONFIG_CONSOLE_SIMPLE, but they are also needed for CONSOLE_NONE. Move them to the header. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Kconfig: retire empty <asm/barebox.h>Ahmad Fatoum2019-08-301-2/+0
| | | | | | | With the latest changes, this file is empty on all archs. Drop it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Kconfig: create Kconfig symbol for ARCH_HAS_STACK_DUMPAhmad Fatoum2019-08-301-1/+1
| | | | | | | | Other arch-specific features are exposed in Kconfig too, so do here likewise. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-07-121-0/+10
|\
| * startup: Factor out the autoboot counter to separate functionSascha Hauer2019-07-031-0/+10
| | | | | | | | | | | | | | | | | | The autoboot countdown is part of the init function. This patch factors out this code to a separate function to allow boards to call it at a different time. Also boards can set the autoboot state manually in case they have its own idea how to interrupt the autoboot process. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: Add missing arguments to memcpy_parse_options()Andrey Smirnov2019-07-091-1/+2
|/ | | | | | | | | | | | | Memcpy use-case differs from that of memcmp in default access type and destination file mode. This was missed in original commit that introduced memcpy_parse_options(). Add said parameters to memcpy_parse_options(), so the can be correctly specified depending on the use-case. Fixes: ddf4cca339 ("commands: Introduce memcpy_parse_options()") Reported-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: Introduce memcpy_parse_options()Andrey Smirnov2019-05-281-0/+2
| | | | | | | | | Both memcpy and memcmp have identical options, so in order to share code between them, introduce memcpy_parse_options() and change both tools to use it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Shell: Handle aborting loops betterSascha Hauer2019-04-241-1/+3
| | | | | | | | | | | | | | | | | | It's easy to get stuck in an infinite loop in the hush shell: while true; do sleep 1; done The 'sleep' command will check for ctrl-c with the ctrlc() function. This will abort the sleep command. Hush then checks for ctrl-c again in the loop. The ctrl-c in the buffer has already been eaten by the sleep command, so the loop will continue. With this patch we remember the presence of a ctrl-c character in a variable instead of checking for a new character each time. The variable must be resetted explicitly by calling ctrlc_handled() which will be called by the shell in the outer loop. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* memory_display: move prototype to include/printk.hSascha Hauer2018-12-031-10/+0
| | | | | | | It's where the kernel has the print_hex_dump prototypes aswell, it's a better match for these. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: Do not use environment when overlapping with other partitionsSascha Hauer2018-09-261-0/+10
| | | | | | | | | | | Environment partitions are usually specified with their hardcoded offset and size, either in the device tree or the board file. These partitions potentially overlap with other partitions read from the partition table. Overlapping partitions for sure have bad effects. Be more friendly to our users and warn them when such a situation occurs and stop using that partition for storing the environment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include/common: Make use of ALIGN and ALIGN_DOWNAndrey Smirnov2018-08-221-2/+2
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include/common.h: move IOMEM declaration for MIPS to arch/mips/include/asm/io.hPeter Mamonov2018-05-241-5/+2
| | | | | Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: base: use root_node compatible as suggestion for a hostnameOleksij Rempel2018-01-171-0/+1
| | | | | | | | | | | | | | | | on some SoCs we can use generic PLL and RAM initialization. In this cases we create board file only to provide a host name. With this patch host name will be created from device tree compatible. For example: compatible = "board_vendor,board", "chip_vendor,soc" the host name will be: "board" This function will not overwrite a host name which is already set by board or machine code. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* linux/kernel.h: move ALIGN_DOWN() to include/linux/kernel.hMasahiro Yamada2018-01-051-2/+0
| | | | | | | | | | Linux commit ed067d4a859f ("linux/kernel.h: Add ALIGN_DOWN macro") moved ALIGN_DOWN to include/linux/kernel.h. Let's do likewise. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poweroff: Allow to register poweroff handlersSascha Hauer2017-03-301-3/+0
| | | | | | | | | | Allow to register handlers for poweroff. This allows to have multiple poweroff implementations in a single binary. The implementation is close to the restart handlers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* libfile: move open_and_lseek() to libfileSascha Hauer2016-04-151-1/+0
| | | | | | | libfile is a collection of helpers for handling files. open_and_lseek() is a perfect match for this, so move it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: move crc specific stuff to crc.hSascha Hauer2016-04-151-6/+0
| | | | | | | We have a crc.h, so move our crc function prototypes there to further cleanup common.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: move shell prototypes to shell.hSascha Hauer2016-04-151-11/+0
| | | | | | We have a shell,h, so move shell specific prototypes there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include/common.h: remove unused struct memarea_infoSascha Hauer2016-04-151-10/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: move run_command prototype to command.hSascha Hauer2016-04-151-1/+0
| | | | | | run_command fits much better into command.h, move it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: Remove do_execute and thumb2_executeTrent Piepho2015-12-071-6/+0
| | | | | | | | | | | | | | | | | | | | In commit 104a6a7ccfb7928ca5dc28c8cbe0ea231ffc45ee support was added for Thumb2. It added do_execute() as a way to provide arch dependent calling veneers for use in "go" and thumb2_execute() as the thumb2 to arm veneer. But thumb2_execute() isn't necessary as gcc generates a proper calling sequence from a standard function pointer call. Thumb2 barebox is compiled with the AAPCS ABI which requires this. It also had a bug and didn't pass the arguments properly, but code execute via "go" rarely uses arguments so this wasn't very noticeable. Since thumb2 was always the only user of do_execute(), go ahead and delete that too. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* clock: remove duplicate xdelay declarationsSascha Hauer2015-09-231-4/+1
| | | | | | | | ndelay is declared in include/clock.h, udelay in include/common.h and mdelay in include/common.h and include/clock.h. Move them all to include/clock.h and remove duplicates. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* restart: replace reset_cpu with registered restart handlersSascha Hauer2015-08-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | This replaces the reset_cpu() function which every SoC or board must provide with registered handlers. This makes it possible to have multiple reset functions for boards which have multiple ways to reset the machine. Also boards which have no way at all to reset the machine no longer have to provide a dummy reset_cpu() function. The problem this solves is that some machines have external PMICs or similar to reset the system which have to be preferred over the internal SoC reset, because the PMIC can reset not only the SoC but also the external devices. To pick the right way to reset a machine each handler has a priority. The default priority is 100 and all currently existing restart handlers are registered with this priority. of_get_restart_priority() allows to retrieve the priority from the device tree which makes it possible for boards to give certain restart handlers a higher priority in order to use this one instead of the default one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move board_shutdown to exitcall infrastructureHerve Codina2015-07-131-1/+0
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move arch_shutdown to exitcall infrastructureHerve Codina2015-07-131-2/+0
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* linux/kernel.h: move some macros and prototypesMasahiro Yamada2015-01-291-58/+0
| | | | | | | | | | The include/common.h is still cluttered (although much better than U-Boot). It contains various utility macros that originates in Linux. Move them to the original place, include/linux/kernel.h, to slim down include/common.h. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* asm-generic/bug.h: move BUG(), BUG_ON(), WARN(), WARN_ON() macrosMasahiro Yamada2015-01-291-32/+0
| | | | | | | | In Linux, these macros are defined in include/asm-generic/bug.h. To tidy up common.h, move BUG(), BUG_ON(), WARN(), WARN_ON() there. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* linux/bug.h: move BUILD_BUG_ON*() macrosMasahiro Yamada2015-01-291-19/+1
| | | | | | | | | | | In Linux, the macros BUILD_BUG_ON* are defined in include/linux/bug.h. To tidy up common.h, move BUILD_BUG_* there. MAYBE_BUILD_BUG_ON is not used in barebox and it was removed from Linux long time ago. Drop it from barebox, too. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* linux/kernel.h: move *_MAX, *_MIN macrosMasahiro Yamada2015-01-211-13/+0
| | | | | | | | | | | Linux defines *_MAX, *_MIN macros in include/linux/kernel.h. Let's follow this way to slim down the common.h. This change should have no impact because include/common.h already includes <linux/kernel.h>. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common.h: use special IOMEM() for MIPSAntony Pavlov2014-09-111-0/+6
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-host'Sascha Hauer2014-08-071-0/+16
|\ | | | | | | | | Conflicts: drivers/usb/core/Makefile
| * include: import {lower,upper}_32_bits helpersSebastian Hesselbarth2014-07-281-0/+16
| | | | | | | | | | | | | | | | This imports {lower,upper}_32_bits defines to allow to get upper and lower 32b part of a 64b number. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Add release stringSascha Hauer2014-07-221-0/+1
|/ | | | | | | | | Currently we only have version_string which contains information about the date the binary was compiled and by whom it has been compiled. This adds a release_string which only contains the plain release version. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: fix macro WARNChristoph Fritz2014-05-131-1/+2
| | | | | Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add shell_expand functionSascha Hauer2014-03-281-0/+9
| | | | | | shell_expand expands shell variables in a string. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>