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
main(argc,argv)68 main(argc,argv)
69 int argc;
70 char *argv[];
71 {
72 int val;
73
74 clear_iob(); /* clear garbage pointer in _iob[] */
75 clear_dtabsize();
76 /* fpsetround(FP_RZ); */
77 /* init_malloc_param(); /* reset malloc parameters. */
78 setvbuf(stdout,NULL,_IOLBF,BUFSIZ);
79
80 val=setjmp(mainenv); /* set non-local return point for exit */
81
82 if (val == 0)
83 psl_main(argc,copy_argv(argc,argv));
84
85 exit(0);
86
87 }
88
89
os_startup_hook(argc,argv)90 os_startup_hook(argc, argv)
91 int argc;
92 char *argv[];
93 {
94 setupbpsandheap(argc, argv); /* Allocate bps and heap areas. */
95 }
96
os_cleanup_hook()97 os_cleanup_hook()
98 {
99 longjmp(mainenv,1);
100 }
101
clear_iob()102 clear_iob()
103 {
104 }
105
106 /*
107 * Some static area must be initialized on hot start.
108 * There may be other area to be initialized but we have no idea
109 * to know them.
110 *
111 * _dtabsize ----_end
112 */
113
114
115 extern char *end;
116 /*
117 * Size of dtabsize is 0x34c bytes.
118 */
clear_dtabsize()119 clear_dtabsize()
120 {
121 int i;
122 }
123
124 #ifndef LINUX
125
126 /* look for the last occurrence of character c in string s;
127 if found, return pointer to string part, NULL otherwise */
rindex(s,c)128 char * rindex(s,c)
129 char * s; char c;
130 { int i,l; char x;
131 for (i=0; s[i]!='\000'; i++);
132 for (i=i-1; (s[i] !=c) && (i>=0) ; i--);
133 if (i<0) return(NULL); else return(& s[i]);
134 }
135
136 /* look for the first occurrence of character c in string s;
137 if found, return pointer to string part, NULL otherwise */
138
index(s,c)139 char * index(s,c)
140 char * s; char c;
141 { int i,l; char x;
142 for (i=0; (s[i] !=c) && (s[i]!='\000') ; i++);
143 if (s[i]=='\000') return(NULL); else return(& s[i]);
144 }
145
bzero(b,length)146 bzero (b,length)
147 char * b; int length;
148 { int i;
149 for (i=0; i<length; i++) b[i]='\000' ; }
150
151 #endif
152