diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2022-03-27 20:57:01 +0200 |
---|---|---|
committer | David Bauer <mail@david-bauer.net> | 2022-10-14 23:13:02 +0200 |
commit | a296055b82fbb20457273492069ce9d62009e2a1 (patch) | |
tree | 83db19e52b93c16e832ba33f9f11f20514d6a159 /target/linux/mpc85xx/image/spi-loader/stdio.c | |
parent | 63e5ba8e69f03a584b707520db0a0821eda3024f (diff) | |
download | upstream-a296055b82fbb20457273492069ce9d62009e2a1.tar.gz upstream-a296055b82fbb20457273492069ce9d62009e2a1.tar.bz2 upstream-a296055b82fbb20457273492069ce9d62009e2a1.zip |
mpc85xx: add SPI kernel loader for TP-Link TL-WDR4900 v1
Similar to the lzma-loader on our MIPS targets, the spi-loader acts as
a second-stage loader that will then load and start the actual kernel.
As the TL-WDR4900 uses SPI-NOR and the P1010 family does not have support
for memory mapping of this type of flash, this loader needs to contain a
basic driver for the FSL ESPI controller.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Diffstat (limited to 'target/linux/mpc85xx/image/spi-loader/stdio.c')
-rw-r--r-- | target/linux/mpc85xx/image/spi-loader/stdio.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/target/linux/mpc85xx/image/spi-loader/stdio.c b/target/linux/mpc85xx/image/spi-loader/stdio.c new file mode 100644 index 0000000000..3aa55d0613 --- /dev/null +++ b/target/linux/mpc85xx/image/spi-loader/stdio.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 2022 Matthias Schiffer <mschiffer@universe-factory.net> + */ + +#include <stdio.h> + +int puts(const char *s) +{ + while (*s) + putchar(*s++); + return 0; +} + +void put_u4(uint8_t v) +{ + v &= 0xf; + switch (v) { + case 0x0 ... 0x9: + putchar('0' + v); + break; + case 0xa ... 0xf: + putchar('a' + (v - 0xa)); + } +} + +void put_u8(uint8_t v) +{ + put_u4(v >> 4); + put_u4(v); +} + +void put_u16(uint16_t v) +{ + put_u8(v >> 8); + put_u8(v); +} + +void put_u32(uint32_t v) +{ + put_u16(v >> 16); + put_u16(v); +} + +void put_ptr(const void *p) +{ + put_u32((uint32_t)p); +} + +void put_array(const void *p, size_t l) +{ + const uint8_t *c = p; + size_t i; + for (i = 0; i < l; i++) { + put_u8(c[i]); + putchar(' '); + } + putchar('\n'); +} |