What Needs to be done for a NeXT Emulator

Started by cjbriare, August 17, 2010, 01:34:34 am

Previous topic - Next topic


Another advantage of an open-source M68K emulator is it could be ported to older PPC Macs which have no good x86 options for NeXT emulation.


Probably QEMU would be a good platform to run next68k but a real emulator is a necessary step. Many hardware registers are not documented, in particular the DMA chip. The only partial informations I found are in netBSD sources but comments are a bit short :).

Emulator is now blocked in some rtc chip reading or config. I found a similar code in netBSD rtc.c source.

In very early POST, the stack resides at the end of video RAM in $0B0307xx


I think that progress would be much faster if you used Basilisk II source code as your base.


It uses the UAE 68k CPU emulator engine and the source code is very very modular.

- UAE CPU engine ("uae_cpu/*", not needed on all systems)
- ROM patches ("rom_patches.cpp", "slot_rom.cpp" and "emul_op.cpp")
- resource patches ("rsrc_patches.cpp" and "emul_op.cpp")
- PRAM Utilities replacement ("xpram.cpp")
- ADB Manager replacement ("adb.cpp")
- Time Manager replacement ("timer.cpp")
- SCSI Manager replacement ("scsi.cpp")
- video driver ("video.cpp")
- audio component ("audio.cpp")
- floppy driver ("sony.cpp")
- disk driver ("disk.cpp")
- CD-ROM driver ("cdrom.cpp")
- external file system ("extfs.cpp")
- serial drivers ("serial.cpp")
- Ethernet driver ("ether.cpp")
- system-dependant device access ("sys_*.cpp")
- user interface strings ("user_strings.cpp")
- preferences management ("prefs.cpp" and "prefs_editor_*.cpp")

Basilisk II has been ported to the following systems:

Unix with X11 (Linux i386/x86_64, Solaris 2.5, FreeBSD 3.x, IRIX 6.5)
Mac OS X (PowerPC and Intel)
Windows NT/2000/XP
BeOS R4 (PowerPC and Intel)
AmigaOS 3.x

You can immensely simplify the code by eliminating the diverse types of emulator modes:

"Basilisk II is designed to run on many different hardware platforms and on
many different operating systems. To provide optimal performance under all
environments, it can run in four different modes, depending on the features
of the underlying environment (the modes are selected with the REAL_ADDRESSING,
DIRECT_ADDRESSING and EMULATED_68K defines in "sysdeps.h")"
White Box running OPENSTEP 4.2
Dual Pentium III 550MHz | 320MB ECC SDRAM
Matrox Millenium II 8MB
SanDisk 2GB Compact Flash (CF-to-IDE)


Basilisk is a good emulator but it uses an old variant of uae without real support of MMU (at least it was the case last time I read the code).
An atari TT is much close to a next than a mac, MMU is used by system.
hatari/aranym is a good base for now, to explore the POST rom, it was not too difficult to remove items but it may be a bit limited for timed events (centered on video/cpu/mfp).

For now, the real time clock must be added...


after reading Basilisk code ;)
MMU support seems limited to mac with some black magic :

void REGPARAM2 frame_host_565_lput(uaecptr addr, uae_u32 l)
   uae_u32 *m;
   m = (uae_u32 *)(FrameBaseDiff + addr);
   l = (l & 0x001f001f) | ((l << 1) & 0xffc0ffc0);
   *m = swap_words(l);

but I agree the code is clear and easy to navigate while hatari is more demo-coder oriented ;)
the code sample is a bit wrong, this is videoram access, MMU is not emulated by Basilisk that is limited to a 68020 CPU with a flat 32bit memory model


Is there somewhere documentation about NeXT harware ? Something else and more detailled than schematics that can be found ?

I took a look in my NeXT Archive DVDs but can find anything interesting wich may help Gilles....

Wee ned a Technical Specifications Manual....

Seems that there is some information form NeXT, see here

A lot of link are dead, now, like peak, channelu... :( Somes mirros: http://nextstuff.info/
Apple & NeXT


in particular we need information about System control registers 1 & 2 that resides in x0200Cxxx and x0200Dxxx

SCR2 should be real time clock.

We have datasheets of the clock component (at least the old 68HC68T1) but don't know how it is connected to next (access to component are serial).


found this interesting message of monitor in some doc:

Memory Configurations  -  m
The  m  command displays information on the memory installed in sockets 0
through 15 (the original NeXT had 16 RAM slots).  The output should be
something like this:

Memory sockets 0-3 have 4MB page mode SIMMs installed (0x4000000-0x4400000)
Memory sockets 4-7 have 4MB page mode SIMMs installed (0x5000000-0x53fe000)
Memory sockets 8-11 have no SIMMS installed (0x0-0x0)
Memory sockets 12-15 have no SIMMS installed (0x0-0x0)

=> may means that a part of RAM is used for something else, maybe to shadow a part of the ROM?


good news, some information seems correct.

you need to force the boot, otherwise it goes in an endless loop (soft power off?)

r A7=$0B03F7C4
r PC=$01004956

first screenshot :

I'll update svn sources soon


Apple & NeXT


svn is updated.
To see the boot screen, you need the Rev2.6_v66.BIN file.
When screen gets scrambled (this pattern may be a video ram test),
type rightAlt + Pause
then in debugger
r A7=$0B03F7C4
r PC=$01004956

(it bypasses a test in ROM)

There is probably a ROM checksum, so cannot patch binary for now...


think I understood how RTC is connected.
RTC is accessed with 2 bit write and 1 bit read from 32bit register SCR2.
to write you need to set data then loop clock with a delay
a write is 2 byte write, register then value
a read is a write for register then a read of value
maybe newer chip have a burst read mode.

netBSD sources are clear when you take them with the right angle :)


A little step more ! Nice Job !

I was able to build Previous on MacOsX. Still no debugger yet, need to change Alt-PAUSE to Alt-anythingelse. It should work, but no way....

Gilles really need help !  :D
Apple & NeXT


in configuration.c file:
   ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG] = SDLK_PAUSE;

change to another key more macosX friendly...  (PAUSE/F16 seems problematic)