Port-amigappc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Design papers: kernel memory map and kernel relocator


after discussing the kernel memory map with Wolfgang Solfrank (whom I cc:)
and how to do a relocator with Michael Rock, I edited the memory map document
and wrote a relocator document, which I enclose for your final comment.

Knowledge of the bebox/macppc/ofwppc pmap modules is assumed.


$Id: kernel-address-map,v 1.5 1999/01/26 20:33:44 is Exp $

NetBSD/amigappc virtual kernel addressing:

Addresses given are high 16 bits.

Range           Cache   Description                     real range

0000 - 03f0     0       Amiga I/O + chipmem + Z2mem     0000 - 00ff *
0400 - 07ff     1       A3000/4000 mainboard. memory    0700 - 07ff
0800 - 0fff     1       CPU-slot-memory on A[34]000

1000 - 7fff     0/1     Z3-i/o or. memory-boards
                        Blizzard PPC memory

d000 - dfff     1       userland window, non-BAT
e000 - efff     1       kernel map, non-BAT

fc00 - ffff     1       exception code, bootstrappig    fff0 - fff7

The software BAT table contains pieces for 64MB segments, but uses
bigger pieces if adjacent, to reduce trap frequency. E.g.:

highbits        range inserted into BAT register
0400                    0400 - 07ff
0800                    0800 - 0fff
0C00                    0800 - 0fff

The kernel is linked to its memory segment base address. 
In a later version, it will relocate itself during startup.
$Id: kernel-relocator,v 1.1 1999/01/26 20:58:16 is Exp is $

Kernel relocation:

The first thing the kernel will do, eventually, is to relocate itself.
[Until then you'll have to link the kernel for the memory you'll be using.]

Pseudo-code of kernel-startup (but would be in assembler code, I think):
register vaddr_t thediff;
register u_int16_t highdiff;
register vaddr_t whereami;
register u_int16_t *q, **p;
u_int16_t **reloctable;

thediff = whereami - addresskernelislinkedfor;
p = reloctable + thediff;       /* we're not relocated yet */
highdiff = thediff >> 16;

while (q = *p++) {
        q += thediff;           /* where is that address really */
        *q += highdiff;         /* adjust the high bits */
reloctable is an array of pointers pointing to the high 16 bits of
addresses, generated during compile time by a magic program out of
the PPC_RELOC_16_UPPER and the 32bit relocation records. We won't
have "absolute" 16bit branches (other than maybe _into_ the exception
table, which dont need to be relocated anyway).

magic-program would either be written in C, linking to libbfd to get at the
interesting stuff, or even a shell + awk + sed script operating on objdump
output. The latter helps setting up cross compilation.

Link procedure:

ld -r -dc -o netbsd-intermediate.o kernelstartup.o $OTHEROBJECTS
magic-program -o reloctable.s netbsd-intermediate.o
as -o reloctable.o reloctable.s
ld -o netbsd netbsd-intermediate.o reloctable.o

[-r:    link and resolve everything internal, but keep relocation info.
 -dc:   allocate space for common symbols, anyway.]

Home | Main Index | Thread Index | Old Index