From 50321a53550f16d3461f077d1e8a830e2da3f221 Mon Sep 17 00:00:00 2001 From: Markuss Broks Date: Mon, 13 Jun 2022 18:50:51 +0300 Subject: [PATCH 1/5] board: *, main: Drop PAYLOAD_SIZE, use compile time kernel size Signed-off-by: Markuss Broks --- asm/linker.lds.S | 2 ++ include/board/board-dreamlte.h | 1 - include/board/board-n61ap.h | 1 - main.c | 6 ++++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/asm/linker.lds.S b/asm/linker.lds.S index 8255500b..03f6c63b 100644 --- a/asm/linker.lds.S +++ b/asm/linker.lds.S @@ -25,4 +25,6 @@ SECTIONS kernel = .; KERNEL_PATH } + + kernel_size = SIZEOF(.kernel); } diff --git a/include/board/board-dreamlte.h b/include/board/board-dreamlte.h index f8466b94..e0dc97f3 100644 --- a/include/board/board-dreamlte.h +++ b/include/board/board-dreamlte.h @@ -7,6 +7,5 @@ #define BOARD_DREAMLTE_H_ #define PAYLOAD_ENTRY 0x90000000 -#define PAYLOAD_SIZE 0x2000000 #endif // BOARD_DREAMLTE_H_ diff --git a/include/board/board-n61ap.h b/include/board/board-n61ap.h index 0b1715dc..bc2571ab 100644 --- a/include/board/board-n61ap.h +++ b/include/board/board-n61ap.h @@ -8,6 +8,5 @@ /* TODO: Adjust PAYLOAD_ENTRY */ #define PAYLOAD_ENTRY 0x830000000 -#define PAYLOAD_SIZE 0x2000000 #endif // BOARD_N61AP_H_ diff --git a/main.c b/main.c index 17a0cf0d..ed0f1317 100644 --- a/main.c +++ b/main.c @@ -7,12 +7,14 @@ /* Device specific board config, copied in runtime */ #include +extern unsigned long kernel_size; + void main(void* dt, void* kernel) { /* Initialize SoC and Board specific peripherals/quirks */ soc_init(); board_init(); /* Copy kernel to memory and boot */ - memcpy((void*)PAYLOAD_ENTRY, kernel, PAYLOAD_SIZE); - load_kernel(dt, 0, 0, 0, (void*)PAYLOAD_ENTRY); + memcpy((void*)PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size); + load_kernel(dt, 0, 0, 0, (void*)PAYLOAD_ENTRY); } From 6d5d964955965741af73077c3a8cd1bbc2eaa99d Mon Sep 17 00:00:00 2001 From: Markuss Broks Date: Mon, 13 Jun 2022 19:03:35 +0300 Subject: [PATCH 2/5] soc: exynos: Add basic support for Exynos 9810 Signed-off-by: Markuss Broks --- include/soc/exynos9810.h | 12 ++++++++++++ soc/Makefile | 2 ++ soc/exynos/exynos9810.c | 11 +++++++++++ 3 files changed, 25 insertions(+) create mode 100644 include/soc/exynos9810.h create mode 100644 soc/exynos/exynos9810.c diff --git a/include/soc/exynos9810.h b/include/soc/exynos9810.h new file mode 100644 index 00000000..95358902 --- /dev/null +++ b/include/soc/exynos9810.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022, Markuss Broks + */ + +#ifndef EXYNOS9810_H_ /* Include guard */ +#define EXYNOS9810_H_ + +#define DECON_F_BASE 0x16030000 +#define HW_SW_TRIG_CONTROL 0x70 + +#endif // EXYNOS9810_H_ diff --git a/soc/Makefile b/soc/Makefile index 07765ece..e5001660 100644 --- a/soc/Makefile +++ b/soc/Makefile @@ -30,6 +30,8 @@ board_codename := $(word 2,$(split_board)) # Exynos ifeq ($(SOC),exynos8895) brand_name=exynos +else ifeq ($(SOC),exynos9810) +brand_name=exynos endif # Apple diff --git a/soc/exynos/exynos9810.c b/soc/exynos/exynos9810.c new file mode 100644 index 00000000..cbd749fc --- /dev/null +++ b/soc/exynos/exynos9810.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022, Markuss Broks + */ + +#include + +void soc_init(void) { + /* Allow framebuffer to be written to */ + *(int*) (DECON_F_BASE + HW_SW_TRIG_CONTROL) = 0x1281; +} From aa70ec5f42eabb6066e84a6a2da4da0a7d2cf424 Mon Sep 17 00:00:00 2001 From: Markuss Broks Date: Mon, 13 Jun 2022 19:03:54 +0300 Subject: [PATCH 3/5] board: starlte: Add support for Samsung Galaxy S9 Signed-off-by: Markuss Broks --- board/samsung/board-starlte.c | 10 ++++++++++ include/board/board-starlte.h | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 board/samsung/board-starlte.c create mode 100644 include/board/board-starlte.h diff --git a/board/samsung/board-starlte.c b/board/samsung/board-starlte.c new file mode 100644 index 00000000..2a820a17 --- /dev/null +++ b/board/samsung/board-starlte.c @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022, Markuss Broks + */ + +#include + +void board_init(void) { + +} diff --git a/include/board/board-starlte.h b/include/board/board-starlte.h new file mode 100644 index 00000000..ef719ba2 --- /dev/null +++ b/include/board/board-starlte.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022, Markuss Broks + */ + +#ifndef BOARD_STARLTE_H /* Include guard */ +#define BOARD_STARLTE_H + +#define PAYLOAD_ENTRY 0x90000000 + +#endif // BOARD_STARLTE_H From b295ac57ce8849d1ba11088a0fb9204eac3ffe35 Mon Sep 17 00:00:00 2001 From: Markuss Broks Date: Mon, 13 Jun 2022 19:08:36 +0300 Subject: [PATCH 4/5] main: Add support for booting without knowing the load address Signed-off-by: Markuss Broks --- asm/Start.S | 1 + asm/linker.lds.S | 1 + include/main.h | 2 ++ main.c | 14 +++++++++++--- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/asm/Start.S b/asm/Start.S index 316d0a6c..003520b1 100644 --- a/asm/Start.S +++ b/asm/Start.S @@ -5,6 +5,7 @@ adr x0, dtb adr x1, kernel + adrp x2, end b main .global load_kernel diff --git a/asm/linker.lds.S b/asm/linker.lds.S index 03f6c63b..401a4de8 100644 --- a/asm/linker.lds.S +++ b/asm/linker.lds.S @@ -25,6 +25,7 @@ SECTIONS kernel = .; KERNEL_PATH } + end = .; kernel_size = SIZEOF(.kernel); } diff --git a/include/main.h b/include/main.h index 4d9241bb..6cdc9e9d 100644 --- a/include/main.h +++ b/include/main.h @@ -6,6 +6,8 @@ #ifndef MAIN_H_ /* Include guard */ #define MAIN_H_ +#define SZ_2M 0x00200000 + extern void load_kernel(void* dtb, void* x1, void* x2, void* x3, void* kernel); extern void soc_init(void); extern void board_init(void); diff --git a/main.c b/main.c index ed0f1317..8d172ecb 100644 --- a/main.c +++ b/main.c @@ -9,12 +9,20 @@ extern unsigned long kernel_size; -void main(void* dt, void* kernel) { +void main(void* dt, void* kernel, void* end) { + void* kernel_load; /* Initialize SoC and Board specific peripherals/quirks */ soc_init(); board_init(); +#ifndef PAYLOAD_ENTRY + /* Find closest 2MB-aligned address to our load location */ + kernel_load = (void *) ((((unsigned long long)end - 1) | (SZ_2M - 1)) + 1); +#else + kernel_load = (void *) PAYLOAD_ENTRY; +#endif + /* Copy kernel to memory and boot */ - memcpy((void*)PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size); - load_kernel(dt, 0, 0, 0, (void*)PAYLOAD_ENTRY); + memcpy((void*)kernel_load, kernel, (unsigned long) &kernel_size); + load_kernel(dt, 0, 0, 0, (void*)kernel_load); } From f6f373a75c417942cb37cc92d00bc043744debbf Mon Sep 17 00:00:00 2001 From: Markuss Broks Date: Mon, 13 Jun 2022 19:35:43 +0300 Subject: [PATCH 5/5] board and soc: generic: Add support for a generic board Signed-off-by: Markuss Broks --- board/generic/board-generic.c | 13 +++++++++++++ include/board/board-generic.h | 11 +++++++++++ soc/Makefile | 5 +++++ soc/generic/generic.c | 8 ++++++++ 4 files changed, 37 insertions(+) create mode 100644 board/generic/board-generic.c create mode 100644 include/board/board-generic.h create mode 100644 soc/generic/generic.c diff --git a/board/generic/board-generic.c b/board/generic/board-generic.c new file mode 100644 index 00000000..cd0c262a --- /dev/null +++ b/board/generic/board-generic.c @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022, Markuss Broks + */ + +/* This is a generic board file. This should work on every device + * as long as it's loaded in physical memory with enough space to + * put the kernel image ahead of it on closest 2MiB-aligned address. + */ + +void board_init(void) { + +} diff --git a/include/board/board-generic.h b/include/board/board-generic.h new file mode 100644 index 00000000..50e29945 --- /dev/null +++ b/include/board/board-generic.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022, Markuss Broks + */ + +#ifndef BOARD_GENERIC_H /* Include guard */ +#define BOARD_GENERIC_H + +/* Nothing really is here :) */ + +#endif // BOARD_GENERIC_H diff --git a/soc/Makefile b/soc/Makefile index e5001660..41a03eda 100644 --- a/soc/Makefile +++ b/soc/Makefile @@ -39,6 +39,11 @@ ifeq ($(SOC),t7000) brand_name=apple endif +# Generic +ifeq ($(SOC),generic) +brand_name=generic +endif + all: $(brand_name)/$(SOC).o copy-soc copy-soc: diff --git a/soc/generic/generic.c b/soc/generic/generic.c new file mode 100644 index 00000000..98da6ee7 --- /dev/null +++ b/soc/generic/generic.c @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022, Markuss Broks + */ + +void soc_init(void) { + /* We don't know anything about the SoC so we can't do anything... */ +}