locore.S and debugging initial stages of kernel
Ian Lepore
ian at FreeBSD.org
Fri Jun 20 02:19:37 UTC 2014
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’t needed once you have a static mapping for the UART in place…
>
> But if the code is really early, consider encoding numbers in the the LEDs on your board.
>
> Warner
>
> On Jun 19, 2014, at 4:18 PM, Stepan Dyatkovskiy <stpworld at narod.ru> wrote:
>
> > Hi all,
> > I would like to check several things in locore.S. But I don't have JTAG debugger, so I have to use printf-like functions. Are there any known ways to do it?
> >
> > 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=pa), and the EARLY_PRINTF mechanism will do that for you.
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:
===================================================================
--- 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 */
+ 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
More information about the freebsd-arm
mailing list