Port-m68k archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Porting to my custom 030 board
> > Do you have a
> > set of changes which just add support for a new machine? Ideally
> > something m68k, but I might glean some knowledge looking at another
> > machine type.
>
> % ls -1d sys/arch/*68*
> sys/arch/luna68k
> sys/arch/m68k
> sys/arch/mac68k
> sys/arch/mvme68k
> sys/arch/news68k
> sys/arch/next68k
> sys/arch/sun68k
> sys/arch/virt68k
> sys/arch/x68k
> %
>
> plus amiga, atari, hp300, with m68k being the common ground for the
> arch. Look through the ports, compare how they do things. Some will be
> closer to your hardware than others.
When I ported NetBSD to the news68k (SONY CISC NEWS) port (back in 1999),
I looked at
sys/arch/m68k
sys/arch/hp300
sys/arch/mvme68k
sys/arch/x68k
etc.
680x0 has so flexible MMU settings that it's a bit hard to see how
differences are handled among all ports, but we have to check the
following points:
- physical memory mappings (especially whether VA==PA for RAMs)
- how MMU should be set up (especially when VA != PA)
- how devices (especially serial console device) should be mapped
(PTE via 030 MMU, or TT0/TT1 mappings)
- mvme68k, news68k, and x68k use PA==VA mappings (i.e. RAM starts at 0x0)
- hp300 has a bit weird PA != VA mappings, so it prepares a special page
where PA == VA to turn MMU on:
https://mail-index.netbsd.org/tech-kern/1999/05/26/0015.html
- next68k has RAM from 0x40000000 so it uses temporary TT0/TT1 mappings
to turn MMU on
- x68k has optional "extended memory" mapped at PA >0x01000000 so
initialization is a bit complicated:
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/x68k/x68k/machdep.c#L1069-L1083
- mac68k is a bit difficult to read because it has many hacks
for Apple hardware (and MacOS Booter)
- cesfic may be a similar port as a simple embeded board, but it has
many leftover lines in various sources taken from hp300
- luna68k uses TT0/TT1 to map sparse device space (0x40000000-0xFFFFFFFF):
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/luna68k/luna68k/locore.s#L255-L261
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/luna68k/include/pmap.h
- amiga and atari have a bit different initialization functions due to
historical reasons
(though they use a common "4.4BSD/hp300 derived" pmap:
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/amiga/amiga/amiga_init.c#L198-L792
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/atari/atari/atari_init.c#L197-L691
- sun68k (sun3 and sun3x) uses completely different MMU settings
- sun3 uses Sun specific MMU, and sun3x uses full 3-level 030 MMU
- other NetBSD/m68k ports use 2-level MMU:
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/m68k/include/pmap_motorola.h#L115-L138
- NetBSD/m68k uses "incomplete (or faked)" 3-level MMU for 040/060
(use one page for first and second level tables; see pmap_bootstrap.c)
- you also have to prepare kernel config files under
sys/arch/${MACHINE}/conf, but maybe we can copy from the similar port
Anyway, we should check "start" function in locore.s to see
how early bootstrap initialization should be done:
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/news68k/news68k/locore.s#L118-L434
Next, we have to check pmap_bootstrap.c (called during the above "start")
to set up segment tables and page tables for kernel, RAM, and devices etc.
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/news68k/news68k/pmap_bootstrap.c
It's a bit annoying to set up serial console before MMU turned on,
but if your board has debug LEDs mapped somewhere we can use it for debug:
https://github.com/NetBSD/src/blob/netbsd-11/sys/arch/news68k/news68k/locore.s#L83-L93
Note the most important thing is "how to load your custom kernel binary
into the memory" and "how to jump to the loaded kernel."
Maybe you can use "objcopy -O binary" to get a raw kernel binary,
but it depends on your board firmware features.
I started porting NetBSD/news68k around 19990506, and got
a linked kernel on 19990530, then "kernel printf(9)" via
serial console worked (using NEWS-OS bootloader) on 19990603.
Good luck,
---
Izumi Tsutsui
Home |
Main Index |
Thread Index |
Old Index