GEMDOS Device I/O and Process Control
System Functions
In addition to character device functions, GEMDOS also con
tains a number of system control functions. These include
routines to manage system memory, to execute and termi
nate programs, and to get and set the DOS clock and calen
dar. The first of these allow you to change the 68000 proces
sor's privilege mode, or to find what the current mode is.
The 68000 allows certain operations to be performed in su
pervisor mode that cannot be performed from the normal
user mode. On the ST, these include reading or writing to
system variables stored in memory locations below 2048
($800), and reading or writing to hardware registers located
above 167444482 ($FF80000). The macro name of the function
used to switch modes is Super(), and its syntax is:
long stack, oldstack;
oldstack = Super(stack);
The meaning of stack will vary depending on what you want
the function to do. If you set stack to - 1L (OxFFFFFFFF), the
function returns a code in oldstack which specifies the current
privilege mode. If the value returned in oldstack is 0, the pro
cessor is user mode. If the value returned is 1, it's in supervi
sor mode.
If stack is set to any value other than - 1L, the function
will toggle the current privilege mode. If the processor is in
user mode, it will be set to supervisor mode, with the super
visor stack set to the address passed in stack. If you wish to
make the supervisor stack address the same as that of the
user stack, pass a value of 0L in
stack. The address of the
previous supervisor stack is returned in oldstack. This value
should be saved, so you may restore the old supervisor stack
value when you switch back to user mode.
If the function is called when the processor is in supervi
sor mode, GEMDOS sets it to user mode and sets the super
visor stack value back to the address passed in stack. This ad
dress should be the same one returned in oldstack when you
first sent the processor into supervisor mode. It's important
that the supervisor stack exist in memory outside the control
of your program, so when your program terminates, the sys
tem still has a workable stack area. If you fail to set the su
pervisor stack back to its original value before your program
terminates, you may crash the system. An example of proper
95