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 *
11 * (c) Copyright 1983, Hewlett-Packard Company, see the file
12 *            HP_disclaimer at the root of the PSL file tree
13 *
14 *
15 ******************************************************************************
16 * Revisions:
17 *
18 * 23-Feb-89 (Chris Burdorf)
19 *  Made  call to psl_main in main call copy_argv to pass the static
20 *  copy of argv to get around unexec problems.
21 * 15-Jun-88, (Tsuyoshi Yamamoto)
22 *  Added init-malloc-param(), _iob[] initializer, _dtabsize for SUN4 PORT.
23 * 21-Sep-86 (Leigh Stoller)
24 *  Removed calls to the io-map functions. None of this was needed for the Sun.
25 *  Removed the 68020_advise function.
26 * 07-Jul-86 (Leigh Stoller)
27 *  Removed Calls to echooff and echoon since they are not needed for the top
28 *   loop, only for Nmode. Who knows why HP used them in the first place.
29 * 30-Apr-86 (Leigh Stoller)
30 * Copied this file from gator kernel directory and changed calls to terminal-
31 *  state to echooff and echoon, which are contained in echo.c
32 *
33 ******************************************************************************
34 */
35 #include <stdio.h>
36 #include <string.h>
37 #include <setjmp.h>
38 
39 #ifndef LINUX
40 #include <ieeefp.h>
41 #endif
42 
43 jmp_buf mainenv;
44 char *reduceaus;
45 
c2reduce(cntl,argc,argv,buffin)46 c2reduce(cntl,argc,argv,buffin)
47 
48 int cntl,argc;
49 char *argv[], buffin;
50 {
51   int val;
52 
53   if(cntl==0) { /* init call */
54   clear_iob();             /* clear garbage pointer in _iob[]    */
55   clear_dtabsize();
56   setvbuf(stdout,NULL,_IOLBF,BUFSIZ);
57 
58   reduceaus = (char *) NULL;
59 
60   val=setjmp(mainenv);        /* set non-local return point for exit    */
61 
62   if (val == 0)
63      _psl_main(argc,copy_argv(argc,argv));
64               };
65   if(cntl==1) { /* subsequent calls after init; everything clean */
66   val=setjmp(mainenv);        /* set non-local return point for exit    */
67 
68   if (val == 0) _reduceup(buffin, reduceaus = malloc(3000),30,3000);
69   if (reduceaus!= (char *) NULL)
70        printf("reduceausgabe:%s\n",(int) reduceaus +4);
71                };
72 
73 return (reduceaus);
74 
75 }
76 
77 
78 
os_startup_hook(argc,argv)79 os_startup_hook(argc, argv)
80      int argc;
81      char *argv[];
82 {
83   setupbpsandheap(argc, argv);   /* Allocate bps and heap areas. */
84 }
85 
os_cleanup_hook(x)86 os_cleanup_hook(x)
87 int x;
88 
89 { if(x==17) longjmp(mainenv,17);
90     else  if(x==3)  longjmp(mainenv,3); else longjmp(mainenv,1);
91 }
92 
clear_iob()93 clear_iob()
94 {
95 }
96 
97 /*
98  *    Some static area must be initialized on hot start.
99  *    There may be other area to be initialized but we have no idea
100  *    to know them.
101  *
102  *    _dtabsize ----_end
103  */
104 
105 
106 extern char *end;
107 /*
108  *     Size of dtabsize is 0x34c bytes.
109  */
clear_dtabsize()110 clear_dtabsize()
111 {
112  int i;
113  }
114 
115 #ifndef LINUX
116 
117    /* look for the last occurrence of character c in string s;
118       if found, return pointer to string part, NULL otherwise */
rindex(s,c)119 char * rindex(s,c)
120         char * s; char c;
121         { int i,l; char x;
122           for (i=0; s[i]!='\000'; i++);
123           for (i=i-1; (s[i] !=c) && (i>=0) ; i--);
124           if (i<0) return(NULL); else return(& s[i]);
125         }
126 
127    /* look for the first occurrence of character c in string s;
128       if found, return pointer to string part, NULL otherwise */
129 
index(s,c)130 char * index(s,c)
131         char * s; char c;
132         { int i,l; char x;
133           for (i=0; (s[i] !=c) && (s[i]!='\000') ; i++);
134           if (s[i]=='\000') return(NULL); else return(& s[i]);
135         }
136 
bzero(b,length)137 bzero (b,length)
138 char * b; int length;
139 { int i;
140   for (i=0; i<length; i++) b[i]='\000' ; }
141 
142 #endif
143