Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Jun 2014 20:19:32 -0600
From:      Ian Lepore <ian@FreeBSD.org>
To:        Warner Losh <imp@bsdimp.com>
Cc:        freebsd-arm@FreeBSD.org
Subject:   Re: locore.S and debugging initial stages of kernel
Message-ID:  <1403230772.20883.281.camel@revolution.hippie.lan>
In-Reply-To: <776BC360-5D2F-435C-B2B0-38449D4AB56D@bsdimp.com>
References:  <53A3619C.3020505@narod.ru> <776BC360-5D2F-435C-B2B0-38449D4AB56D@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 2014-06-19 at 19:59 -0600, Warner Losh wrote:
> Look at EARLY_PRINTF code, unless Ian has removed it because it isn=92t=
 needed once you have a static mapping for the UART in place=85
>=20
> But if the code is really early, consider encoding numbers in the the L=
EDs on your board.
>=20
> Warner
>=20
> On Jun 19, 2014, at 4:18 PM, Stepan Dyatkovskiy <stpworld@narod.ru> wro=
te:
>=20
> > Hi all,
> > I would like to check several things in locore.S. But I don't have JT=
AG debugger, so I have to use printf-like functions. Are there any known =
ways to do it?
> >=20
> > Thanks!
> > -Stepan

You can't really use the EARLY_PRINTF stuff in locore.S, at least, not
until you get to the last few lines before calling initarm().

I usually emit single chars by writing directly the console uart
register.  This technique works up until the code that turns on the MMU.
If you want to keep emitting chars after that point, you have to map the
uart reg (va=3Dpa), and the EARLY_PRINTF mechanism will do that for you. =
=20

In general the technique is purely machine-specific, so there's never
been anything checked in for it.  For example, here's how I do it for
imx6, whose tx register is at 0x02020040:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- locore.S	(revision 266921)
+++ locore.S	(working copy)
@@ -75,6 +75,9 @@
  * For both types of boot we gather up the args, put them in a struct
arm_boot_params
  * structure and pass that to initarm.
  */
+
+#define EMIT(rg, chr) mov rg,chr ; str rg,[r10]
+
 ENTRY_NP(btext)
 ASENTRY_NP(_start)
 	STOP_UNWINDING		/* Can't unwind into the bootloader! */
@@ -84,6 +87,11 @@
 	mov	ip, r2		/* Save meta data */
 	mov	fp, r3		/* Future expansion */
=20
+	mov	r10, #0x02000000 /* make r10 point */
+	orr	r10, #0x00020000 /* to imx6 uart */
+	orr	r10, #0x00000040 /* xmit register */
+	EMIT(r1, #'a')
+
 	/* Make sure interrupts are disabled. */
 	mrs	r7, cpsr
 	orr	r7, r7, #(I32_bit|F32_bit)
@@ -144,6 +152,7 @@
 	nop
 	mov	pc, r7
 Lunmapped:
+	EMIT(r1, #'b')
 	/*
 	 * Build page table from scratch.
 	 */

-- Ian





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1403230772.20883.281.camel>