Subject: bad assumptions in locore.s
To: None <port-sparc@sun-lamp.cs.berkeley.edu>
From: David S. Miller <davem@nadzieja.rutgers.edu>
List: port-sparc
Date: 11/30/1994 23:26:42
Theo and friends,

While teaching myself about the sun boot-prom monitor I found some bad
assumptions in the netbsd sparc/locore.s boot code. In the code after
dostart: a test is made to see if SUN4C is supported in the kernel
after which if it does not test out and the prom says this is a sun4c
it proceeds to call the prom_forth_evel() prom routine like so:

	set  sun4c_notsup-KERNBASE, %o0
	ld   [%g7 + 0x7c], %o1
	call %o1
	nop

This ASSUMES v2 prom semantics to the forth-eval routine which takes
the evaluation string (null-terminated) as its first arguement
(ie. %o0) however there are sun4c which have a v0 prom (I have one :-(
) and this code will fail miserable because it will think that the
strings address is the length of the string and the address of the
forth-eval routine is the start of the string. Result? garbage on the
screen as the prom tries to execute the garbage characters and after
three lines says "memory address not aligned".

What should be done is a test right at the beginning of the code for
the boot_prom version number (I think it is the first or second
element of the boot_prom structure) before trying to eval things.
>From v0 to v2 the forth_eval semantics changed from:

prom_forth_eval(int length, char* forth_string)

to

prom_forth_eval(char* forth_string_null_terminated)

I am sure if I look elsewhere this assumption also appears in
different forms.

Later,
David S. Miller
davem@nadzieja.rutgers.edu