From owner-freebsd-arm@FreeBSD.ORG Fri Jun 20 02:19:37 2014 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BF772822 for ; Fri, 20 Jun 2014 02:19:37 +0000 (UTC) Received: from mho-01-ewr.mailhop.org (mho-03-ewr.mailhop.org [204.13.248.66]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 919FE24F0 for ; Fri, 20 Jun 2014 02:19:37 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WxoQR-0006XY-Bp; Fri, 20 Jun 2014 02:19:35 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id s5K2JWet001761; Thu, 19 Jun 2014 20:19:32 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX182o4kPo+ry5Md8VZCzBy59 Subject: Re: locore.S and debugging initial stages of kernel From: Ian Lepore To: Warner Losh In-Reply-To: <776BC360-5D2F-435C-B2B0-38449D4AB56D@bsdimp.com> References: <53A3619C.3020505@narod.ru> <776BC360-5D2F-435C-B2B0-38449D4AB56D@bsdimp.com> Content-Type: text/plain; charset="windows-1251" Date: Thu, 19 Jun 2014 20:19:32 -0600 Message-ID: <1403230772.20883.281.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by damnhippie.dyndns.org id s5K2JWet001761 Cc: freebsd-arm@FreeBSD.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 02:19:37 -0000 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 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