August 16, 2025

Sun 3 bootrom souce - Tour: startup and diagnostics

The show starts when the system powers up and comes out of reset. The 68020 will fetch two 32 bit words from the start of ROM. This takes us to sun3/romvec.s where we see this:
 .long  INITSP          | Initial SSP for hardware RESET
 .long  _hardreset      | Initial PC  for hardware RESET
Setting the stack pointer won't be of much use until we get the MMU set up so that we can access RAM. The system powers up in "boot mode" which forces all instruction access to the ROM until that bit is changed.

The address "_hardreset" is in sun3/trap.s. The business of entry point names that begin with an underscore dates back to the days of the Sun compiler. When you called a function xyz() in C code, unbeknownst to you, the symbol name in the assembly (and linker) world was _xyz. The current gnu "gcc" compiler does not follow this convention, so whereever necessary I have eliminated these underscores. But in calls from assembly code to assembly code, they remain.

After just a small amount of initialization, a call is made to _selftest which is in diag/diag.s. The call is made by a jump. We don't have a stack yet, so we cannot use a bsr or jsr. The file diag/diag.s is big -- just over 3200 lines of code. It takes pains not to reference memory. It makes calls (but only 1 level deep) by using the a6 register to hold the return address. It hand crafts code for each call, loading the return address into this register, then using a "jra" instruction to make the call. The subroutine then returns using "jra a6@".

When the diagnostics have finished (with success), a real call using jbsr is made to "mapmem()" in sys/mapmem.c -- the only real call made from this code, then it returns to trap.s using:

	jra     _reset_common
This code may call monreset() in sys/reset.c, but the big thing is when it calls monitor() in sys/commands.c -- this is the interactive monitor we know and love.

This gives the ">" prompt and in this version of the bootrom you can type "h" to get help. Typing "b" will make it try to boot, in my setup it does the following:

>b
Boot: ie(0,0,0)
ie: cannot initialize
Typing "k2" is also interesting, and gives the output below. What decides whether it fires up the interactive monitor instead of going on to auto-boot. That is a topic for the future.
>k2
Selftest Passed.

Sun Workstation, Model Sun-3/75M or Sun-3/160M, Sun-2 keyboard
ROM Rev 2.1, 4MB memory installed, Serial #17403
Ethernet address 8:0:20:1:DB:0

Testing 4 Megabytes of Memory ... Completed.

Auto-boot in progress...
Boot: ie(0,0,0)
ie: cannot initialize

The message that announces the workstation type comes from the function banner() in sys/banner.c. I just added a line to the banner message:

Sun Workstation, Model Sun-3/75M or Sun-3/160M, Sun-2 keyboard
Generated 3-16-2025
ROM Rev 2.1, 4MB memory installed, Serial #17403
Ethernet address 8:0:20:1:DB:0
I intend to augment this to indicate the time, date, and perhap host and user who did the build.

For the record, the "h" command gives:

>h
Boot PROM Monitor Commands

----------------------------------------------------------------------------
a [digit]                               | Open CPU Addr Reg (0-7)
b [dev([cntrl],[unit],[part])]          | Boot a file
c [addr]                                | Continue program at Addr
d [digit]                               | Open CPU Data Reg (0-7)
e [addr]                                | Open Addr as 16 bit word
f beg_addr end_addr pattn [size]        | Fill Memory
g [addr]                                | Go to Addr
h                                       | Help Menu
k [number]                              | Reset (0)CPU, (1)MMU, (2)System
l [addr]                                | Open Addr as 32 bit long
m [addr]                                | Open Segment Map
o [addr]                                | Open Addr as 8 bit byte
p [addr]                                | Open Page Map
q [addr]                                | Open EEPROM
r                                       | Open CPU Regs (i.e. PC)
s [digit]                               | Set/Query Function Code (0-7)
t [y/n/c]                               | Trace: Yes/No/Continue
u [arg]                                 | Select Console Device
v beg_addr end_addr [size]              | Display Memory
w [addr] [string]                       | Vector
x                                       | Extended Diag Tests
z [addr]                                | Set Breakpoint
----------------------------------------------------------------------------

Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org