1 /******************************************************************************
2 *
3 * File:         $PXK/OS-HOOKS.C
4 * Description:  OS specific startup and cleanup hooks.
5 * Author:       RAM, HP/FSD
6 * Created:      9-Mar-84
7 * Modified:    15-Jul-85 10:10:51 (RAM)
8 * Mode:         Text
9 * Package:
10 * Status:       Open Source: BSD License
11 *
12 *  (c) Copyright 1983, Hewlett-Packard Company, see the file
13 *             HP_disclaimer at the root of the PSL file tree
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
17 *
18 *    * Redistributions of source code must retain the relevant copyright
19 *      notice, this list of conditions and the following disclaimer.
20 *    * Redistributions in binary form must reproduce the above copyright
21 *      notice, this list of conditions and the following disclaimer in the
22 *      documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
28 * CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************
38 * Revisions:
39 *
40 * 23-Feb-89 (Chris Burdorf)
41 *  Made  call to psl_main in main call copy_argv to pass the static
42 *  copy of argv to get around unexec problems.
43 * 15-Jun-88, (Tsuyoshi Yamamoto)
44 *  Added init-malloc-param(), _iob[] initializer, _dtabsize for SUN4 PORT.
45 * 21-Sep-86 (Leigh Stoller)
46 *  Removed calls to the io-map functions. None of this was needed for the Sun.
47 *  Removed the 68020_advise function.
48 * 07-Jul-86 (Leigh Stoller)
49 *  Removed Calls to echooff and echoon since they are not needed for the top
50 *   loop, only for Nmode. Who knows why HP used them in the first place.
51 * 30-Apr-86 (Leigh Stoller)
52 * Copied this file from gator kernel directory and changed calls to terminal-
53 *  state to echooff and echoon, which are contained in echo.c
54 *
55 ******************************************************************************
56 */
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <string.h>
60 #include <setjmp.h>
61 
62 #ifndef LINUX
63 //#include <ieeefp.h>
64 #endif
65 
66 jmp_buf mainenv;
67 char *abs_execfilepath;
68 
69 void clear_iob();
70 void clear_dtabsize();
71 void psl_main(int argc, char *argv[]);
72 
73 char ** copy_argv(int, char*[]);
74 
75 int Debug = 0;
76 
77 int
main(argc,argv)78 main(argc,argv)
79 int argc;
80 char *argv[];
81 {
82   int val;
83 
84   clear_iob();             /* clear garbage pointer in _iob[]    */
85   clear_dtabsize();
86   /* fpsetround(FP_RZ);  */
87 /*  init_malloc_param(); */       /* reset malloc parameters.        */
88     setvbuf(stdout,NULL,_IOLBF,BUFSIZ);
89     /* Record path to exec file */
90   if (argc > 0)
91     abs_execfilepath = realpath(argv[0],NULL);
92 
93  if (getenv("BPSL_DEBUG") != NULL)
94      Debug = 1;
95 
96  val=setjmp(mainenv);        /* set non-local return point for exit    */
97 
98   if (val == 0)
99      psl_main(argc,copy_argv(argc,argv));
100 
101 exit(0);
102 
103 }
104 
105 
106 int setupbpsandheap(int argc, char *argv[]);
107 
108 void
os_startup_hook(argc,argv)109 os_startup_hook(argc, argv)
110      int argc;
111      char *argv[];
112 {
113   setupbpsandheap(argc, argv);   /* Allocate bps and heap areas. */
114 }
115 
116 void
os_cleanup_hook()117 os_cleanup_hook()
118 {
119 longjmp(mainenv,1);
120 }
121 
get_execfilepath()122 char * get_execfilepath ()
123 {
124   return abs_execfilepath;
125 }
126 
127 void
clear_iob()128 clear_iob()
129 {
130 }
131 
132 /*
133  *    Some static area must be initialized on hot start.
134  *    There may be other area to be initialized but we have no idea
135  *    to know them.
136  *
137  *    _dtabsize ----_end
138  */
139 
140 
141 extern char *end;
142 /*
143  *     Size of dtabsize is 0x34c bytes.
144  */
145 void
clear_dtabsize()146 clear_dtabsize()
147 {
148  int i;
149  }
150 
151