shithub: plan9front

Download patch

ref: 9f54c2831717bc656df6e5a2fde2bf7be8e29fef
parent: 6b4b8e405ae17d5004085df03d166cddcc99c11b
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Apr 25 11:36:11 EDT 2021

bcm: try ATAGS/DTB pointer from R2 on entry

--- a/sys/src/9/bcm/armv6.s	Sun Apr 25 06:41:20 2021
+++ b/sys/src/9/bcm/armv6.s	Sun Apr 25 11:36:11 2021
@@ -76,6 +76,9 @@
 	MOVW	$1, R1
 	MCR	CpSC, 0, R1, C(CpSPM), C(CpSPMperf), CpSPMctl
 
+	/* first arg to main is saved R2 */
+	MOVW	R10, R0
+
 	/*
 	 * call main and loop forever if it returns
 	 */
--- a/sys/src/9/bcm/armv7.s	Sun Apr 25 06:41:20 2021
+++ b/sys/src/9/bcm/armv7.s	Sun Apr 25 11:36:11 2021
@@ -126,6 +126,9 @@
 	MOVW	$1, R1
 	MCR	CpSC, 0, R1, C(CpCLD), C(CpCLDena), CpCLDenapmnc
 
+	/* first arg to main is saved R2 */
+	MOVW	R10, R0
+
 	/*
 	 * call main and loop forever if it returns
 	 */
--- a/sys/src/9/bcm/bootargs.c	Sun Apr 25 06:41:20 2021
+++ b/sys/src/9/bcm/bootargs.c	Sun Apr 25 11:36:11 2021
@@ -265,7 +265,7 @@
 	uintptr len;
 
 	/*
-	 * kernel gets DTB/ATAGS pointer in R0 on entry
+	 * kernel gets DTB/ATAGS pointer on entry
 	 */
 	if(pa != 0 && (len = cankaddr(pa)) != 0){
 		void *va = KADDR(pa);
--- a/sys/src/9/bcm/l.s	Sun Apr 25 06:41:20 2021
+++ b/sys/src/9/bcm/l.s	Sun Apr 25 11:36:11 2021
@@ -10,6 +10,9 @@
  * other cpus enter at cpureset in armv7.s
  */
 TEXT _start(SB), 1, $-4
+	/* save R2 in extern register R10 (Mach *m) */
+	MOVW	R2, R10
+
 	/*
 	 * load physical base for SB addressing while mmu is off
 	 * keep a handy zero in R0 until first function call
--- a/sys/src/9/bcm/main.c	Sun Apr 25 06:41:20 2021
+++ b/sys/src/9/bcm/main.c	Sun Apr 25 11:36:11 2021
@@ -75,7 +75,7 @@
 }
 
 void
-main(void)
+main(uintptr arg0)
 {
 	extern char edata[], end[];
 	uint fw, board;
@@ -84,7 +84,7 @@
 	memset(edata, 0, end - edata);	/* clear bss */
 	mach0init();
 	quotefmtinstall();
-	bootargsinit(0);
+	bootargsinit(arg0);
 	confinit();		/* figures out amount of memory */
 	xinit();
 	uartconsinit();
--- a/sys/src/9/bcm/rebootcode.s	Sun Apr 25 06:41:20 2021
+++ b/sys/src/9/bcm/rebootcode.s	Sun Apr 25 11:36:11 2021
@@ -84,6 +84,7 @@
 	BEQ	dowfi		/* if zero, wait again */
 
 bootcpu:
+	MOVW	$0, R2		/* no ATAGS/DTB pointer */
 	BIC	$KSEGM, R8	/* entry to physical */
 	ORR	$PHYSDRAM, R8
 	BL	(R8)