[comp.sys.amiga.tech] Help with Supervisor State

sjm@well.UUCP (Stephen Moehle) (01/28/89)

    Well, since no one saw fit to help me out with using the 68851 on the
A2620 board, I have been blindly trying to figure it out.  I actually think
that I can get the 68851 to do what I want, but I cannot even try it.  Since
PMOVE is a privileged instruction, I have to get the 68020 into the supervisor
state first.  I have tried the following test:

#include <stdio.h>

long SuperState();

int i = 0;

main()
{
    long stack;

    stack = SuperState();
    i = 55;
    UserState(stack);
    printf("%d\n", i);
}

    The machine always GURUs with exception #3, Address Error, whether I run
it on the 68020 or the 68010.  I think it is dying in SuperState().  At least
the debugger never gets to the breakpoint at "i = 55".  What am I doing wrong?
How can I get the machine into supervisor state?  Please.

    My system consists of an A2000, A2620, WorkBench 1.3, 1.2 ROMS, and
Manx C 3.6.  I also run SetPatch.  Thanks.

Stephe
{ucbvax,pacbell,hplabs}!well!sjm     or     well!sjm@lll-winken.arpa
"You heard the weirdo man.  What is truth?"

daveh@cbmvax.UUCP (Dave Haynie) (01/31/89)

in article <10510@well.UUCP>, sjm@well.UUCP (Stephen Moehle) says:
> Keywords: supervisor state

>     Well, since no one saw fit to help me out with using the 68851 on the
> A2620 board, I have been blindly trying to figure it out.  I actually think
> that I can get the 68851 to do what I want, but I cannot even try it.  

Funny, I could never get the SuperState()/UserState() stuff to work, either.
No bother, really, though; I found two other ways to get there.  From C, 
you can run a subroutine as a software interrupt routine (set up the
routine, then Cause() it); interrupts run in Supervisor mode.  That's gonna
get kind of clumsy if you've got lots of supervisor stuff to do.  From
assembly language you can get to an Exec routine called Supervisor.  Basically,
you pass this call your subroutine, the subroutine is executed in Supervisor
mode, and then it exits with an RTE.  I use this method in my SetCPU program,
V1.3 and above.  Speaking of "and above", I'm just about done with a version
of SetCPU that lets you use the MMU for relocation of ROM into 32 bit RAM.
It's not extremely sophisticated, but it's currently working, and I'll probably
be posting it in the next few days.

> Stephe
> {ucbvax,pacbell,hplabs}!well!sjm     or     well!sjm@lll-winken.arpa
> "You heard the weirdo man.  What is truth?"
-- 
Dave Haynie  "The 32 Bit Guy"     Commodore-Amiga  "The Crew That Never Rests"
   {uunet|pyramid|rutgers}!cbmvax!daveh      PLINK: D-DAVE H     BIX: hazy
              Amiga -- It's not just a job, it's an obsession

bryce@cbmvax.UUCP (Bryce Nesbitt) (01/31/89)

In article <10510@well.UUCP> sjm@well.UUCP (Stephen Moehle) writes:
|
|    stack = SuperState();
|    i = 55;
|    UserState(stack);


The UserState() function does not work in 1.2/1.3 Kickstarts.  Sorry.

Software interrupts run in supervisor mode.
The "Supervisor()" function lets you trap to a supervisor function ending
in RTE.  Just put the address of the function in A5.  D0 is preserved
from the supervisor function.