home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- access;
- symbols
- version39-41:1.2;
- locks;
- comment @ * @;
-
-
- 1.3
- date 92.08.09.20.55.51; author amiga; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 92.07.04.19.18.21; author mwild; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 92.05.14.19.55.40; author mwild; state Exp;
- branches;
- next ;
-
-
- desc
- @startup code for programs invoked by standard shells (commandline parsing)
- @
-
-
- 1.3
- log
- @import sysbase
- @
- text
- @/*
- * This file is part of ixemul.library for the Amiga.
- * Copyright (C) 1991, 1992 Markus M. Wild
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: ix_startup.c,v 1.2 1992/07/04 19:18:21 mwild Exp $
- *
- * $Log: ix_startup.c,v $
- * Revision 1.2 1992/07/04 19:18:21 mwild
- * remove SIGWINCH handler before returning
- *
- * Revision 1.1 1992/05/14 19:55:40 mwild
- * Initial revision
- *
- */
-
- #define KERNEL
- #include "ixemul.h"
-
- #ifdef DEBUG
- #define DP(a) kprintf a
- #else
- #define DP(a)
- #endif
-
- #define exit_buf u.u_jmp_buf
- extern struct ExecBase *SysBase;
-
- /*
- * Note: I kept the partition into startup and _main(), although in this
- * case, both functions could be done in one function, since this is
- * a library, and the user can't override _main anyway but globally...
- */
-
- int
- ix_startup (char *aline, int alen,
- int expand, char *wb_default_window, u_int main, int *real_errno)
- {
- struct Process *me = (struct Process *) SysBase->ThisTask;
- int exit_val;
- struct WBStartup *wb_msg;
-
- /*
- * The following code to reset the fpu might not be necessary, BUT since
- * a CLI shell doesn't spawn a new process when executing a command - it
- * insteads calls the command like a subroutine - it depends on the Shell
- * whether the fpu is setup correctly. And I don't like to depend on any
- * thing ;-)
- */
-
- if (SysBase->AttnFlags & AFF_68881)
- /* reset fpu into a defined state */
- asm volatile ("
- moveml a5/a6,sp@@-
- lea pc@@(Lreset_fpu-.+2),a5
- movel 4:w,a6
- jsr a6@@(-30) | Supervisor()
- bra Lafter_reset_fpu
-
- Lreset_fpu:
- clrl sp@@-
- frestore sp@@+
- rte
-
- Lafter_reset_fpu:
- moveml sp@@+,a5/a6");
-
- /* first deal with WB messages, since those HAVE to be answered properly,
- * even if we should fail later (memory, whatever..) */
-
- if (! me->pr_CLI)
- {
- /* we have been started by Workbench. Get the StartupMsg */
- WaitPort (& me->pr_MsgPort);
- wb_msg = (struct WBStartup *) GetMsg (& me->pr_MsgPort);
- /* further processing in _main () */
- }
- else
- {
- /* for usage by sys_exit() for example */
- u.u_argline = aline;
- u.u_arglinelen = alen;
- }
-
- u.u_expand_cmd_line = expand;
- if (real_errno) u.u_errno = real_errno;
-
- DP(("ix_startup(start): sp = $%lx\n",({int res;asm("movel sp,%0" : "=g" (res));res;})));
-
- exit_val = setjmp (exit_buf);
-
- if (! exit_val)
- {
- /* from now on it's save to allow signals */
- syscall (SYS_sigsetmask, 0);
-
- /* the first time thru call the program */
- exit_val = me->pr_CLI ? syscall (SYS__main, aline, alen, main)
- : syscall (SYS__main, wb_msg, wb_default_window, main);
- }
- else
- /* in this case we came from a longjmp-call */
- exit_val --;
-
- ix_remove_sigwinch ();
-
- /* if started from workbench, Forbid(), since on reply WB will deallocate
- * our task... */
- if (! me->pr_CLI)
- {
- Forbid ();
- ReplyMsg ((struct Message *) wb_msg);
- }
-
- DP(("ix_startup(end): sp = $%lx\n",({int res;asm("movel sp,%0" : "=g" (res));res;})));
-
- return exit_val;
- }
-
- /* this just jumps right back into ix_startup() */
- void
- _exit (int retcode)
- {
- longjmp (exit_buf, retcode + 1);
- }
- @
-
-
- 1.2
- log
- @remove SIGWINCH handler before returning
- @
- text
- @d19 1
- a19 1
- * $Id: ix_startup.c,v 1.1 1992/05/14 19:55:40 mwild Exp $
- d22 3
- d40 1
- a51 1
- struct ExecBase *SysBase = *(void **)4;
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d19 1
- a19 1
- * $Id$
- d21 4
- a24 1
- * $Log$
- d114 2
- @
-