Date: Tue, 13 Oct 2020 12:21:50 -0700 From: Mark Millard <marklmi@yahoo.com> To: Kyle Evans <kevans@FreeBSD.org>, freebsd-arm <freebsd-arm@freebsd.org> Cc: Oleksandr Tymoshenko <gonzo@freebsd.org> Subject: Re: RPi4B: an example of what RAM u-boot reserves during operation [patches updated] Message-ID: <8AEC8B5C-F375-4C81-9033-D864B6C47C57@yahoo.com> In-Reply-To: <B178FB1A-B4EA-4B0E-9FAD-D58463E1321E@yahoo.com> References: <A0293335-6DE2-452F-B179-0CCAFE5076BB@yahoo.com> <B178FB1A-B4EA-4B0E-9FAD-D58463E1321E@yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2020-Oct-12, at 17:32, Mark Millard <marklmi at yahoo.com> wrote: > On 2020-Oct-12, at 11:19, Mark Millard <marklmi at yahoo.com> wrote: >=20 >> . . . >=20 > U-Boot> bdinfo > lmb_dump_all: > . . . > reserved.cnt =3D 0x2 > reserved.size =3D 0x0 > reserved.reg[0x0].base =3D 0x0 > .size =3D 0x2000 > reserved.reg[0x1].base =3D 0x3db47b30 > .size =3D 0x4b84d0 > . . . The above does not cover as much as gonzo's old code did during u-boot's time frame: the reserved space was 0x4000 in size and that figure is supplied via x1 from argstub8-gic.bin code. So the below is about having that reserve also covered (during u-boot's time frame): U-Boot> bdinfo . . . lmb_dump_all: . . . reserved.cnt =3D 0x2 reserved.size =3D 0x0 reserved.reg[0x0].base =3D 0x0 .size =3D 0x4000 reserved.reg[0x1].base =3D 0x3db47b30 .size =3D 0x4b84d0 . . . I doubt that the patches below are appropriate to upstream in some respects. It is more targeted at being a sysutils/u-boot-rpi[34] patch because what armstub8*.bin supplies in x1 seems specific to the armstub8*.bin FreeBSD uses. I'll note that doing this has not changed the current "rainbow stage hangup" when u-boot and modern firmware are used together (usb not needing to be involved). # more = /usr/ports/sysutils/u-boot-rpi4/files/patch-board__raspberrypi__rpi__lowle= vel_init.S=20 --- board/raspberrypi/rpi/lowlevel_init.S.orig 2020-10-05 = 08:15:32.000000000 -0700 +++ board/raspberrypi/rpi/lowlevel_init.S 2020-10-13 = 11:33:39.273950000 -0700 @@ -18,9 +18,22 @@ #ifdef CONFIG_ARM64 adr x8, fw_dtb_pointer str x0, [x8] +#if defined(CONFIG_EFI_LOADER) + /* Setup to allow reserving the stack and such that is */ + /* after the likes of FreeBSD armstub8-gic.bin in RAM. */ + adr x8, armstub_rsrvd + str x1, [x8] +#endif #else ldr r8, =3Dfw_dtb_pointer str r2, [r8] +#if defined(CONFIG_EFI_LOADER) +#error "Before aarch64 does not use armstub*.bin files" + /* Setup to allow reserving the stack and such that is */ + /* after the likes of a armstub*.bin in RAM. */ + ldr r8, =3Darmstub_rsrvd + str r3, [r8] +#endif #endif =20 /* Returns */ # more = /usr/ports/sysutils/u-boot-rpi4/files/patch-board__raspberrypi__rpi__rpi.c= =20 --- board/raspberrypi/rpi/rpi.c.orig 2020-10-05 08:15:32.000000000 = -0700 +++ board/raspberrypi/rpi/rpi.c 2020-10-13 11:02:15.582706000 -0700 @@ -12,6 +12,7 @@ #include <fdt_simplefb.h> #include <init.h> #include <lcd.h> +#include <lmb.h> #include <memalign.h> #include <mmc.h> #include <asm/gpio.h> @@ -33,6 +34,7 @@ * does not get cleared later. */ unsigned long __section(".data") fw_dtb_pointer; +unsigned long __section(".data") armstub_rsrvd; =20 /* TODO(sjg@chromium.org): Move these to the msg.c file */ struct msg_get_arm_mem { @@ -494,4 +496,29 @@ #endif =20 return 0; +} + +void board_lmb_reserve(struct lmb *lmb) +{ +#ifdef CONFIG_EFI_LOADER + /* + * NOTE: lmb_reserve (and more) does not deal with overlaps with + * pre-existing reservations. + * But board_lmb_reserve is called before the original + * first-page is added. So use knowledge of what will = happen + * later to avoid overlaps. + */ + + phys_addr_t base =3D 0x0u; + phys_addr_t size =3D CONFIG_RPI_EFI_NR_SPIN_PAGES << = EFI_PAGE_SHIFT; + if (size < armstub_rsrvd) size =3D armstub_rsrvd; + + if (size <=3D EFI_PAGE_SIZE) return; + + /* Avoid future overlap */ + base +=3D EFI_PAGE_SIZE; + size -=3D EFI_PAGE_SIZE; + + lmb_reserve(lmb, base, size); +#endif } =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8AEC8B5C-F375-4C81-9033-D864B6C47C57>