Subject: Re: A small request.
To: Matt Thomas <matt@3am-software.com>
From: Chris Gilbert <chris@paradox.demon.co.uk>
List: port-arm32
Date: 04/18/2001 11:20:55
On Wednesday 18 April 2001  6:27 am, Matt Thomas wrote:
> I need a favor.  I need a small snippet of arm assembly to initialize
> a L1 page table with a few entries, turn on the MMU, and jump to _start
> at its new address (0xf000xxxx).  (e.g. this is done before start is
> called).
>
> The Netwinder bios xfers control before the MMU is turned on.  Whereas
> it seems the various arm32 ports already have an MMU enabled.  This causes
> the netwinder kernel to fall over and die quite quickly.
>
> I need entries for
> 	0x00000000..0x000fffff -> 0x00000000
> 	0x00000000..0x007fffff -> 0xf0000000
> 	0x7c000000..0x7c0fffff -> 0xfd200000
>
> The page table should be placed at 0x8000 (before and not used by the
> kernel).

Certainly the places to look at map_section, setttb functions, although the 
setttb functions maybe overkill as I presume the caches, tlb, etc aren't on 
either so you may just need to do something like:

mov	r0, #0x8000
mcr	15, 0, r0, c2, c0, 0

turning the mmu on is done by doing something like:

/* set mmu bit (you may want to set other bits as well) */
mov	r1, #1

/* fetch current control state */
mrc	15, 0, r0, c1, c0, 0
orr	r0, r1
/* set new control state */
mcr	15, 0, r0, c1, c0, 0

/* make sure the pipeline isn't going to get confused (may not actually be 
needed */
mov	r0, r0
mov	r0, r0

/* now running on virtual addresses */
add	pc, pc, #0xf0000000
mov	r0, r0
mov	r0, r0

/* with a bit of luck should be running at the 0xf0000000 range of addrs now 
*/

b	_start

Note this is mailer code, so may or may not actually work.  Note that you do 
need to have a direct virtual to physical mapping for the code that enables 
the mmu, otherwise the mmu comes on and the PC is pointing at nothing, and 
would probably abort in some way.

Cheers,
Chris