steve@bungia.mn.org (Steve Yelvington) (07/15/89)
References: <458@medusa.informatik.uni-erlangen.de> Here is a complete desk accessory kit for the Sozobon C compiler. Well, almost complete. You need GEM bindings, such as GEMFAST or GEMQ, to make it work. The first file (dastart.s) is a general desk accessory startup module. The second (reboot.c) is a C program demonstrating how to write a desk accessory. The example lets you point and click to reboot the system. jas dastart.s cc -Oc reboot.c ld -o reboot.acc dastart.o reboot.o \lib\aes???.a \lib\dlibs.a ^ use the name of your | GEM AES bindings This code is in the public domain. -- Steve Yelvington 0/ ====cut here 0\==================================================== ********************************************************* * dastart.s -- desk accessory startup code for Atari ST * * public domain -- July 1989 by Steve Yelvington * * written for Sozobon C and jas.ttp assembler * ********************************************************* .bss .even stackbottom: .ds.b 1024 * Set up a small stack initstack: .ds.l 1 * and a top for it saveret: .ds.l 1 * A place to store PC during OS traps .text * Watch closely; this won't last long! begin_acc: * We start move.l #initstack,sp * by loading the stack pointer jsr _main * jump to main() of the desk accessory clr.w (sp) * Shouldn't get here! Put a zero on the stack trap #1 * and terminate (Pterm0) ********************************************************** * That's all there is to it. The rest of this file * * provides gemdos, xbios and bios hooks on the assumption* * that your DA might actually do something. :-) * * Note: I'm not checking the stack here. See DSTART.S by * * Dale Schumacher if you want to do that sort of thing * ********************************************************** .globl _gemdos _gemdos: move.l (sp)+,saveret * save return address trap #1 * hand off to the operating system move.l saveret,-(sp) * restore the natural order of things rts .globl _bios _bios: move.l (sp)+,saveret trap #13 move.l saveret,-(sp) rts .globl _xbios _xbios: move.l (sp)+,saveret trap #14 move.l saveret,-(sp) rts .globl _crystal * NOTICE: this is an AES binding needed with the GEMQ library... * just comment it out if you use only GEMFAST. _crystal: move.l 4(sp),d1 * load aes parameter block ptr into d1 move.w #$C8,d0 * load magic number into d0 trap #2 * kick AES into action rts 0/ ====cut here 0\==================================================== /* * reboot.c * desk accessory to reboot the system * Public domain 1989 by Steve Yelvington * link dastart.o, then this module, then the GEM bindings, then dlibs. * Note the inline assembler ... it probably will need massaging * for compilers other than the Sozobon package. Be sure to * #define (or -D) GEMFAST to avoid the AES arrays if you have that * bindings library. */ #include <osbind.h> #define MENU_ID " Reboot system " #define AC_OPEN 40 #ifndef GEMFAST /* these arrays aren't needed for GEMFAST, but GEMQ requires them */ int contrl[12], intin[128], intout[128], ptsin[128], ptsout[128]; #endif main() { int apid, menuid, msgbuf[8]; apid = appl_init(); /* say hello to the AES */ menuid = menu_register(apid, MENU_ID); /* add me to the Desk menu */ while (1) /* loop forever */ { evnt_mesag(msgbuf); if ( (msgbuf[0] == AC_OPEN) && (msgbuf[4] == menuid) ) wakeup(); } appl_exit(); /* you'll never get here -- supposedly */ } wakeup() /* * This is where the desk accessory becomes active. */ { int retval; retval = form_alert(1, "[3][?|Really reboot the system|?][No!|Warm boot|Cold boot]"); if (retval-1) /* button 1 is no */ reboot(retval-2); /* button 2 is warm boot */ } reboot(cold) int cold; /* * Force the Atari ST to reset itself. If cold is TRUE, the * system will do a cold reboot, otherwise a warm boot. * Based on assembler code by apratt@atari.UUCP (Allan Pratt). * This function never returns, natch. */ { Super(0L); /* go into supervisor mode */ if (cold) asm("clr.l $420"); asm("move.l $4f2,a0"); /* a0 -> OS header */ asm("move.l 4(a0),a1"); /* a1 -> reset handler */ asm("jmp (a1)"); /* jump there. That's a reset. */ } 0/ ====cut here 0\==================================================== #define steve@thelake.UUCP pwcs!stag!thelake!steve #define steve@thelake.citadel the_land!class68!thelake!steve