Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2013 23:41:18 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Tim Kientzle <kientzle@freebsd.org>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: PHYSADDR
Message-ID:  <1A428660-39FB-45EB-979B-103F7E83BC4A@bsdimp.com>
In-Reply-To: <E886046B-1612-425B-902B-72D4B0E93618@freebsd.org>
References:  <E886046B-1612-425B-902B-72D4B0E93618@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On Feb 27, 2013, at 11:27 PM, Tim Kientzle wrote:

> Starting to look at what is needed for a Generic ARM kernel.
> There's a lot here; I sincerely hope I'm not the only one=85 ;-)
>=20
> First up:  Can we get rid of PHYSADDR?

There's lots of places in the tree that use it, but not so many that a =
whack-a-mole approach wouldn't work.

> I think we can always compute it at runtime from PC.
>=20
> For example, I think this works in several places:
>   and r0, pc, #0xF0000000

This only works early in boot before we've turned on the MMU, right?

> And I've found at least one reference that I think can be simply
> eliminated:
>=20
> Index: arm/elf_trampoline.c
> =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
> --- arm/elf_trampoline.c	(revision 247250)
> +++ arm/elf_trampoline.c	(working copy)
> @@ -169,7 +169,7 @@
> void
> _startC(void)
> {
> -	int physaddr =3D KERNPHYSADDR;
> +	unsigned int physaddr =3D (unsigned int)&_start & 0xfffff000;

How'd you come up with this? Perhaps we should just define KERNPHYSADDR =
as this gross expression :)

But isn't _start a virtual address, not a physical address?

> 	int tmp1;
> 	unsigned int sp =3D ((unsigned int)&_end & ~3) + 4;
> #if defined(FLASHADDR) && defined(LOADERRAMADDR)
> @@ -189,10 +189,9 @@
> 		 */
> 		unsigned int target_addr;
> 		unsigned int tmp_sp;
> -		uint32_t src_addr =3D (uint32_t)&_start - PHYSADDR + =
FLASHADDR
> -		    + (pc - FLASHADDR - ((uint32_t)&_startC - PHYSADDR)) =
& 0xfffff000;
> +		uint32_t src_addr =3D (uint32_t)&_start;

I'm not sure how this works...

> -		target_addr =3D (unsigned int)&_start - PHYSADDR + =
LOADERRAMADDR;
> +		target_addr =3D (unsigned int)&_start - (pc & =
0xf0000000) + LOADERRAMADDR;

This might work, but I'd suggest a PC_TO_PHYSADDR(pc) macro or something =
similar...

> 		tmp_sp =3D target_addr + 0x100000 +
> 		    (unsigned int)&_end - (unsigned int)&_start;
> 		memcpy((char *)target_addr, (char *)src_addr,
>=20
>=20
> Tim
>=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1A428660-39FB-45EB-979B-103F7E83BC4A>