00001
00002
00003
00004
00005
00006 #define __KERNEL_SYSCALLS__
00007
00008 #define errno kernel_errno
00009
00010 #include<linux/linkage.h>
00011 #include<linux/mm.h>
00012 #include<descrip.h>
00013 #include<dyndef.h>
00014 #include<ihddef.h>
00015 #include<ihadef.h>
00016 #include<lnmdef.h>
00017 #include<lnmstrdef.h>
00018 #include<misc.h>
00019 #include<pqbdef.h>
00020 #include<ssdef.h>
00021 #include<system_service_setup.h>
00022
00023 #include "linux/unistd.h"
00024 #include "asm/ptrace.h"
00025 #include <asm/pgalloc.h>
00026 #include <asm/uaccess.h>
00027 #include <linux/slab.h>
00028 #include <exe_routines.h>
00029 #include <misc_routines.h>
00030
00031 struct _lnmth lnm_prc_dir_table_header;
00032
00033 struct _lnmx lnm_prc_dir_xlat = {
00034 lnmx_l_flags : LNMX$M_TERMINAL,
00035 lnmx_l_index : LNMX$C_TABLE,
00036 lnmx_l_next : 0
00037 };
00038
00039 struct _lnmb lnm_prc_dir = {
00040 lnmb_l_flink: 0,
00041 lnmb_l_blink: 0,
00042 lnmb_w_size: sizeof(struct _lnmb),
00043 lnmb_b_type: DYN$C_LNM,
00044 lnmb_b_acmode: MODE_K_KERNEL,
00045 lnmb_l_lnmx : 0,
00046 lnmb_l_table : 0,
00047 lnmb_b_flags : LNM$M_NO_ALIAS|LNM$M_TABLE|LNM$M_NO_DELETE,
00048 lnmb_b_count : 21,
00049 lnmb_t_name : "LNM$PROCESS_DIRECTORY",
00050 };
00051
00052 struct _lnmth lnm_prc_dir_table_header={
00053 lnmth_l_flags: LNMTH$M_DIRECTORY,
00054 lnmth_l_hash : 0,
00055 lnmth_l_orb : 0,
00056 lnmth_l_name : 0,
00057 lnmth_l_parent : 0,
00058 lnmth_l_child : 0,
00059 lnmth_l_sibling : 0,
00060 lnmth_l_qtable : 0,
00061 lnmth_l_byteslm : 0x7fffffff,
00062 lnmth_l_bytes : 0x7fffffff
00063 };
00064
00065 struct _lnmth lnm_prc_table_header;
00066
00067 struct _lnmx lnm_prc_xlat = {
00068 lnmx_l_flags : LNMX$M_TERMINAL,
00069 lnmx_l_index : LNMX$C_TABLE,
00070 lnmx_l_next : 0
00071 };
00072
00073 struct _lnmb lnm_prc = {
00074 lnmb_l_flink: 0,
00075 lnmb_l_blink: 0,
00076 lnmb_w_size: sizeof(struct _lnmb),
00077 lnmb_b_type: DYN$C_LNM,
00078 lnmb_b_acmode: MODE_K_KERNEL,
00079 lnmb_l_lnmx : 0,
00080 lnmb_l_table : 0,
00081 lnmb_b_flags : LNM$M_NO_ALIAS|LNM$M_TABLE,
00082 lnmb_b_count : 17,
00083 lnmb_t_name : "LNM$PROCESS_TABLE",
00084 };
00085
00086 struct _lnmth lnm_prc_table_header={
00087 lnmth_l_flags: 0,
00088 lnmth_l_hash : 0,
00089 lnmth_l_orb : 0,
00090 lnmth_l_name : 0,
00091 lnmth_l_parent : 0,
00092 lnmth_l_child : 0,
00093 lnmth_l_sibling : 0,
00094 lnmth_l_qtable : 0,
00095 lnmth_l_byteslm : 0x7fffffff,
00096 lnmth_l_bytes : 0x7fffffff
00097 };
00098
00099 void lnm_init_prc(struct _pcb * p) {
00100
00101
00102
00103
00104 unsigned long ahash;
00105 unsigned long * myhash;
00106 int status;
00107
00108 struct lnmhshp * hash = kmalloc (sizeof(struct lnmhshp),GFP_KERNEL);
00109 memset(hash,0,sizeof(struct lnmhshp));
00110
00111 _DESCRIPTOR(mypartab,"LNM$PROCESS_DIRECTORY");
00112
00113 _DESCRIPTOR(mytabnam,"LNM$PROCESS_TABLE");
00114 _DESCRIPTOR(sysinput,"SYS$INPUT");
00115 _DESCRIPTOR(sysoutput,"SYS$OUTPUT");
00116 _DESCRIPTOR(syserror,"SYS$ERROR");
00117 _DESCRIPTOR(syscommand,"SYS$COMMAND");
00118
00119 struct item_list_3 itm[3];
00120
00121 struct _lnmb * lnm_process_directory=&lnm_prc_dir;
00122 struct _lnmth * lnm_process_directory_table_header=&lnm_prc_dir_table_header;
00123
00124 struct _lnmb * dir_lnmb = kmalloc(sizeof(struct _lnmb),GFP_KERNEL);
00125 struct _lnmx * dir_lnmx = kmalloc(sizeof(struct _lnmx),GFP_KERNEL);
00126 struct _lnmth * dir_lnmth = kmalloc(sizeof(struct _lnmth),GFP_KERNEL);
00127 struct _lnmb * tab_lnmb = kmalloc(sizeof(struct _lnmb),GFP_KERNEL);
00128 struct _lnmx * tab_lnmx = kmalloc(sizeof(struct _lnmx),GFP_KERNEL);
00129 struct _lnmth * tab_lnmth = kmalloc(sizeof(struct _lnmth),GFP_KERNEL);
00130
00131 memcpy(dir_lnmb, &lnm_prc_dir, sizeof(struct _lnmb));
00132 memcpy(dir_lnmx, &lnm_prc_dir_xlat, sizeof(struct _lnmx));
00133 memcpy(dir_lnmth, &lnm_prc_dir_table_header, sizeof(struct _lnmth));
00134 memcpy(tab_lnmb, &lnm_prc, sizeof(struct _lnmb));
00135 memcpy(tab_lnmx, &lnm_prc_xlat, sizeof(struct _lnmx));
00136 memcpy(tab_lnmth, &lnm_prc_table_header, sizeof(struct _lnmth));
00137
00138 ctl_gl_lnmdirect = dir_lnmb;
00139 ctl_gl_lnmhash = hash;
00140
00141
00142
00143
00144
00145 dir_lnmth->lnmth_l_child = tab_lnmth;
00146 tab_lnmth->lnmth_l_parent = dir_lnmth;
00147 dir_lnmth->lnmth_l_hash = hash;
00148 tab_lnmth->lnmth_l_hash = hash;
00149 tab_lnmb->lnmb_l_table=tab_lnmth;
00150 dir_lnmth->lnmth_l_name=dir_lnmb;
00151 tab_lnmth->lnmth_l_name=tab_lnmb;
00152 dir_lnmb->lnmb_l_lnmx=dir_lnmx;
00153 tab_lnmb->lnmb_l_lnmx=tab_lnmx;
00154
00155
00156
00157
00158
00159
00160 myhash=&ahash;
00161 status=lnm_hash(mypartab.dsc$w_length,mypartab.dsc$a_pointer,0xffff,myhash);
00162 #ifdef LNM_DEBUG
00163 lnmprintf("here %x %x\n",myhash,*myhash);
00164 #endif
00165
00166 hash->entry[2*(*myhash)]=dir_lnmb;
00167 hash->entry[2*(*myhash)+1]=dir_lnmb;
00168
00169 status=lnm_hash(mytabnam.dsc$w_length,mytabnam.dsc$a_pointer,0xffff,myhash);
00170 #ifdef LNM_DEBUG
00171 lnmprintf("here %x %x\n",myhash,*myhash);
00172 #endif
00173
00174 hash->entry[2*(*myhash)]=tab_lnmb;
00175 hash->entry[2*(*myhash)+1]=tab_lnmb;
00176
00177 dir_lnmb->lnmb_l_flink=dir_lnmb;
00178 dir_lnmb->lnmb_l_blink=dir_lnmb;
00179 tab_lnmb->lnmb_l_flink=tab_lnmb;
00180 tab_lnmb->lnmb_l_blink=tab_lnmb;
00181
00182 itm[0].item_code=LNM__STRING;
00183 #if 0
00184 itm[0].buflen=6;
00185 itm[0].bufaddr="opa0:";
00186 #else
00187 itm[0].buflen=5;
00188 char * myterm = kmalloc(5, GFP_KERNEL);
00189 memcpy(myterm, p->pcb_t_terminal, 4);
00190 myterm[4]=':';
00191 itm[0].bufaddr=myterm;
00192
00193 #endif
00194 int len = 4;
00195 int retlen = 4;
00196 int zero = 0, one = 1, two = 2;
00197 itm[1].item_code=LNM__INDEX;
00198 itm[1].buflen=&len;
00199 itm[1].retlenaddr=&retlen;
00200 itm[1].bufaddr=&zero;
00201 memset(&itm[2],0,sizeof(struct item_list_3));
00202
00203 exe_crelnm(0,&mytabnam,&sysinput,0,itm);
00204 itm[1].bufaddr=&one;
00205 exe_crelnm(0,&mytabnam,&sysoutput,0,itm);
00206 itm[1].bufaddr=&two;
00207 exe_crelnm(0,&mytabnam,&syserror,0,itm);
00208 itm[1].bufaddr=&one;
00209 exe_crelnm(0,&mytabnam,&syscommand,0,itm);
00210
00211 kfree(myterm);
00212 }
00213
00214 static char * plus_colon(char * name) {
00215
00216 int len=strlen(name);
00217 char * new = kmalloc(len+2,GFP_KERNEL);
00218 memcpy(new, name, len);
00219 new[len]=':';
00220 new[len+1]=0;
00221 return new;
00222 }
00223 int exe_procstrt(struct _pcb * p) {
00224 #if 0
00225 #ifdef __arch_um__
00226 asm volatile ("movl 0x9ffffff0,%esp");
00227 #else
00228 asm volatile ("movl 0xbffffff0,%esp");
00229 #endif
00230 #endif
00231 #ifdef __arch_um__
00232
00233 flush_tlb_mm(p->mm);
00234 #else
00235 #ifdef __i386__
00236 #if 0
00237 __asm__ ("movl %%edi,%0; ":"=r" (p));
00238 #else
00239 p = ctl_gl_pcb;
00240 #endif
00241 #endif
00242 #ifdef __x86_64__
00243 #if 0
00244 __asm__ ("movq %%rbx,%0; ":"=r" (p));
00245 #else
00246 p = ctl_gl_pcb;
00247 #endif
00248 #endif
00249
00250 #endif
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 mm_segment_t fs;
00297 unsigned long sts;
00298 struct dsc_descriptor aname;
00299 struct dsc_descriptor dflnam;
00300 struct _ihd * hdrbuf;
00301 struct _iha * active;
00302
00303 void (*func)(void);
00304
00305 struct _pqb * pqb = p->pcb_l_pqb;
00306
00307 ctl_gq_procpriv = pqb->pqb$q_prvmsk;
00308 p->pcb_l_priv=ctl$gq_procpriv;
00309
00310 int len = strlen(pqb->pqb_t_image);
00311
00312 #ifdef __arch_um__
00313 struct pt_regs * regs = &p;
00314 regs = ¤t->thread.regs;
00315 #else
00316 #endif
00317
00318
00319 lnm_init_prc(current);
00320
00321 if (strncmp(".exe",pqb->pqb_t_image+len-4,4)) goto do_execve;
00322
00323 xqp_init2();
00324 #ifdef CONFIG_VMS
00325 exttwo_init2(0);
00326 #endif
00327
00328 aname.dsc_w_length=len-4;
00329 aname.dsc_a_pointer=pqb->pqb$t_image;
00330 dflnam.dsc_w_length=len;
00331 dflnam.dsc_a_pointer=pqb->pqb$t_image;
00332
00333 sts=exe_imgact(&aname,&dflnam,&hdrbuf,0,0,0,0,0);
00334 printk("imgact got sts %x\n",sts);
00335
00336 if (sts!=SS__NORMAL) return sts;
00337
00338 active=(unsigned long)hdrbuf+hdrbuf->ihd_w_activoff;
00339
00340 func=active->iha_l_tfradr1;
00341
00342 printk("entering image? %x\n",func);
00343 func();
00344 printk("after image\n");
00345
00346 return SS__NORMAL;
00347
00348 do_execve:
00349
00350 fs = get_fs();
00351 set_fs(KERNEL_DS);
00352
00353
00354 void ** argv = 0;
00355 void * args[2];
00356 #ifdef CONFIG_VMS
00357 int found = strcmp(pqb->pqb_t_input,"[vms$common.sysexe]startup.com")==0;
00358 found |= strcmp(pqb->pqb_t_input,"[vms$common.sysexe]install.com")==0;
00359 if (found) {
00360 argv=args;
00361 args[1]=0;
00362 args[0]=pqb->pqb_t_input;
00363 } else {
00364 #if 1
00365 sys_close(0);
00366 sys_close(1);
00367 sys_close(2);
00368 #else
00369 ctl_gl_pcb->files->fd[0]=0;
00370 ctl_gl_pcb->files->fd[1]=0;
00371 ctl_gl_pcb->files->fd[2]=0;
00372 #endif
00373 void sys_open_term();
00374 #if 1
00375 if (pqb->pqb_t_input[0]) sys_open_term(plus_colon(pqb->pqb$t_input));
00376 if (pqb->pqb_t_output[0]) sys_open_term(plus_colon(pqb->pqb$t_output));
00377 if (pqb->pqb_t_error[0]) sys_open_term(plus_colon(pqb->pqb$t_error));
00378 #else
00379 if (pqb->pqb_t_input[0]) sys_open_term(p->pcb$t_terminal);
00380 if (pqb->pqb_t_output[0]) sys_open_term(p->pcb$t_terminal);
00381 if (pqb->pqb_t_error[0]) sys_open_term(p->pcb$t_terminal);
00382 #endif
00383 }
00384 #endif
00385 execve(pqb->pqb_t_image,argv,0);
00386 set_fs(fs);
00387
00388 if (0) {
00389 int (*fn)(int arg);
00390 int arg;
00391
00392 fn(0);
00393 }
00394 }
00395