00001
00002
00003
00004
00005
00006 #include<linux/linkage.h>
00007 #include<linux/sched.h>
00008 #include<linux/completion.h>
00009 #include<linux/personality.h>
00010 #include<linux/mm.h>
00011 #include<linux/module.h>
00012
00013 #include<system_data_cells.h>
00014 #include<descrip.h>
00015 #include<dyndef.h>
00016 #include<ipldef.h>
00017 #include<phddef.h>
00018 #include<pqbdef.h>
00019 #include<prcdef.h>
00020 #include<pridef.h>
00021 #include<rdedef.h>
00022 #include<secdef.h>
00023 #include<ssdef.h>
00024 #include<starlet.h>
00025 #include <queue.h>
00026 #include <exe_routines.h>
00027 #include <misc_routines.h>
00028 #include <sch_routines.h>
00029 #include <internals.h>
00030
00031 #include <linux/sched.h>
00032 #include <linux/slab.h>
00033
00034 #ifndef __arch_um__
00035 #include<asm/uaccess.h>
00036 #endif
00037
00038 struct _generic_64 {
00039 long long l;
00040 };
00041
00042 asmlinkage int exe_creprc(unsigned int *pidadr, void *image, void *input, void *output, void *error, struct _generic_64 *prvadr, unsigned int *quota, void*prcnam, unsigned int baspri, unsigned int uic, unsigned short int mbxunt, unsigned int stsflg,...);
00043
00044 asmlinkage int exe_creprc_wrap(struct struct_args *s) {
00045 return exe_creprc(s->s1,s->s2,s->s3,s->s4,s->s5,s->s6,s->s7,s->s8,s->s9,s->s10,s->s11,s->s12);
00046 }
00047
00048 asmlinkage int exe_creprc(unsigned int *pidadr, void *image, void *input, void *output, void *error, struct _generic_64 *prvadr, unsigned int *quota, void*prcnam, unsigned int baspri, unsigned int uic, unsigned short int mbxunt, unsigned int stsflg,...) {
00049 unsigned long stack_here;
00050 struct _pcb * p, * cur;
00051 int retval;
00052
00053 struct dsc_descriptor * imd = image, * ind = input, * oud = output, * erd = error;
00054
00055 unsigned long clone_flags=CLONE_VFORK;
00056
00057
00058 ctl_gl_creprc_flags = stsflg;
00059
00060
00061 if (stsflg&PRC_M_DETACH) {
00062
00063 }
00064 if (uic) {
00065
00066 }
00067
00068 cur=ctl_gl_pcb;
00069 vmslock(&SPIN_SCHED, IPL__SCHED);
00070 vmslock(&SPIN_MMG, IPL__MMG);
00071 p = alloc_task_struct();
00072
00073 memset(p,0,sizeof(struct _pcb));
00074
00075
00076
00077 p->sigmask_lock = SPIN_LOCK_UNLOCKED;
00078 p->alloc_lock = SPIN_LOCK_UNLOCKED;
00079
00080 qhead_init(&p->pcb_l_astqfl);
00081
00082
00083 p->pcb_b_type = DYN$C_PCB;
00084
00085 p->pcb_b_asten=15;
00086 p->phd_b_astlvl=4;
00087 p->pr_astlvl=4;
00088 p->psl=0;
00089 p->pslindex=0;
00090
00091 qhead_init(&p->pcb_l_lockqfl);
00092
00093 p->pcb_l_permanent_capability = sch$gl_default_process_cap;
00094 p->pcb_l_capability = p->pcb$l_permanent_capability;
00095
00096
00097
00098
00099
00100 if (prcnam) {
00101 struct dsc_descriptor *s=prcnam;
00102 strncpy(p->pcb_t_lname,s->dsc$a_pointer,s->dsc$w_length);
00103 }
00104
00105 p->pcb_l_priv=ctl$gl_pcb->pcb$l_priv;
00106
00107 p->pcb_b_prib=31-baspri;
00108 p->pcb_b_pri=31-baspri-6;
00109
00110 p->pcb_w_quant=-QUANTUM;
00111
00112
00113 p->pcb_l_uic=ctl$gl_pcb->pcb$l_uic;
00114
00115
00116
00117
00118 p->pcb_l_pqb=kmalloc(sizeof(struct _pqb),GFP_KERNEL);
00119 memset(p->pcb_l_pqb,0,sizeof(struct _pqb));
00120
00121 struct _pqb * pqb = p->pcb_l_pqb;
00122
00123 pqb->pqb_q_prvmsk = ctl$gq_procpriv;
00124
00125 if (imd)
00126 memcpy(pqb->pqb_t_image,imd->dsc$a_pointer,imd->dsc$w_length);
00127 if (ind)
00128 memcpy(pqb->pqb_t_input,ind->dsc$a_pointer,ind->dsc$w_length);
00129 if (oud)
00130 memcpy(pqb->pqb_t_output,oud->dsc$a_pointer,oud->dsc$w_length);
00131 if (erd)
00132 memcpy(pqb->pqb_t_error,erd->dsc$a_pointer,erd->dsc$w_length);
00133
00134 if (oud)
00135 memcpy(p->pcb_t_terminal,oud->dsc$a_pointer,oud->dsc$w_length);
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 #if 0
00146 setipl(IPL__MMG);
00147 vmslock(&SPIN_SCHED,-1);
00148
00149
00150 #endif
00151
00152 p->pcb_l_pid=alloc_ipid();
00153 {
00154 unsigned long *vec=sch_gl_pcbvec;
00155 vec[p->pcb_l_pid&0xffff]=p;
00156 }
00157 p->pcb_l_epid=exe$ipid_to_epid(p->pcb$l_pid);
00158
00159
00160
00161
00162
00163 retval = -EAGAIN;
00164
00165
00166
00167
00168
00169
00170 #if 0
00171 if (atomic_read(&p->user->processes) >= p->rlim[RLIMIT_NPROC].rlim_cur
00172 && !capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE))
00173 goto bad_fork_free;
00174
00175 atomic_inc(&p->user->__count);
00176 atomic_inc(&p->user->processes);
00177 #endif
00178
00179
00180
00181
00182
00183
00184
00185 get_exec_domain(p->exec_domain);
00186
00187 if (p->binfmt && p->binfmt->module)
00188 __MOD_INC_USE_COUNT(p->binfmt->module);
00189
00190 p->did_exec = 0;
00191 p->swappable = 0;
00192 p->state = TASK_UNINTERRUPTIBLE;
00193
00194
00195
00196
00197 p->run_list.next = NULL;
00198 p->run_list.prev = NULL;
00199
00200 p->p_cptr = NULL;
00201 init_waitqueue_head(&p->wait_chldexit);
00202 p->vfork_done = NULL;
00203 spin_lock_init(&p->alloc_lock);
00204
00205 p->sigpending = 0;
00206 init_sigpending(&p->pending);
00207
00208 p->it_real_value = p->it_virt_value = p->it_prof_value = 0;
00209 p->it_real_incr = p->it_virt_incr = p->it_prof_incr = 0;
00210 init_timer(&p->real_timer);
00211 p->real_timer.data = (unsigned long) p;
00212
00213 p->leader = 0;
00214 p->tty_old_pgrp = 0;
00215 p->times.tms_utime = p->times.tms_stime = 0;
00216 p->times.tms_cutime = p->times.tms_cstime = 0;
00217 p->lock_depth = -1;
00218 p->start_time = jiffies;
00219
00220 INIT_LIST_HEAD(&p->local_pages);
00221
00222 p->files = current->files;
00223 p->fs = current->fs;
00224 p->sig = current->sig;
00225
00226
00227 if (copy_files(clone_flags, p))
00228 goto bad_fork_cleanup;
00229 if (copy_fs(clone_flags, p))
00230 goto bad_fork_cleanup_files;
00231 if (copy_sighand(clone_flags, p))
00232 goto bad_fork_cleanup_fs;
00233
00234 bad_fork_cleanup:
00235 bad_fork_cleanup_files:
00236 bad_fork_cleanup_fs:
00237
00238
00239
00240
00241
00242
00243 p->swappable = 1;
00244 p->exit_signal = 0;
00245 p->pdeath_signal = 0;
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 retval = p->pcb_l_epid;
00261 INIT_LIST_HEAD(&p->thread_group);
00262
00263
00264 write_lock_irq(&tasklist_lock);
00265
00266
00267 p->p_opptr = current->p_opptr;
00268 p->p_pptr = current->p_pptr;
00269
00270 p->p_opptr = current ;
00271 p->p_pptr = current ;
00272
00273 SET_LINKS(p);
00274
00275 nr_threads++;
00276 write_unlock_irq(&tasklist_lock);
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 memcpy(p->rlim, current->rlim, sizeof(p->rlim));
00289
00290 qhead_init(&p->pcb_l_sqfl);
00291
00292 struct mm_struct * mm = mm_alloc();
00293 p->mm = mm;
00294 p->active_mm = mm;
00295
00296 p->user = INIT_USER;
00297
00298 spin_lock(&mmlist_lock);
00299 #if 0
00300 list_add(&mm->mmlist, &p->p_pptr->mm->mmlist);
00301 #endif
00302 mmlist_nr++;
00303 spin_unlock(&mmlist_lock);
00304
00305 #ifdef __arch_um__
00306 flush_tlb_mm(mm);
00307 #endif
00308
00309
00310
00311
00312
00313 p->pcb_l_phd=kmalloc(sizeof(struct _phd),GFP_KERNEL);
00314 init_phd(p->pcb_l_phd);
00315
00316 init_fork_p1pp(p,p->pcb_l_phd,ctl$gl_pcb,ctl$gl_pcb->pcb$l_phd);
00317 #ifdef __x86_64__
00318 shell_init_other(p,ctl_gl_pcb,0x7ff80000-0x1000,0x7fffe000);
00319 shell_init_other(p,ctl_gl_pcb,0x7ff80000-0x2000,0x7fffe000);
00320 shell_init_other(p,ctl_gl_pcb,0x7ff90000-0x1000,0x7fffe000);
00321 shell_init_other(p,ctl_gl_pcb,0x7ff90000-0x2000,0x7fffe000);
00322 shell_init_other(p,ctl_gl_pcb,0x7ffa0000-0x1000,0x7fffe000);
00323 shell_init_other(p,ctl_gl_pcb,0x7ffa0000-0x2000,0x7fffe000);
00324 #else
00325 shell_init_other(p,ctl_gl_pcb,0x7ff80000-0x1000,0x7fffe000);
00326 shell_init_other(p,ctl_gl_pcb,0x7ff80000-0x2000,0x7fffe000);
00327 shell_init_other(p,ctl_gl_pcb,0x7ff90000-0x1000,0x7fffe000);
00328 shell_init_other(p,ctl_gl_pcb,0x7ff90000-0x2000,0x7fffe000);
00329 #endif
00330 int exe_procstrt(struct _pcb * p);
00331 #ifdef __arch_um__
00332 current->thread.request.u.thread.proc = exe_procstrt;
00333 current->thread.request.u.thread.arg = p;
00334 retval = new_thread(0, clone_flags, 0, 0, p, 0);
00335
00336 void * regs = &p->thread.regs;
00337 #else
00338 struct pt_regs * regs = &pidadr;
00339
00340 retval = new_thread(0, clone_flags, 0, 0, p, 0);
00341 #endif
00342
00343 int eip=0,esp=0;
00344
00345
00346
00347 sch_chse(p, PRI$_TICOM);
00348
00349 vmsunlock(&SPIN_MMG,-1);
00350 vmsunlock(&SPIN_SCHED,0);
00351
00352 return SS__NORMAL;
00353
00354 #if 0
00355 return sys_execve(((struct dsc_descriptor *)image)->dsc$a_pointer,0,0);
00356
00357 return SS__NORMAL;
00358 #endif
00359
00360 #if 0
00361 {
00362 char * filename=((struct dsc_descriptor *)image)->dsc$a_pointer;
00363 char ** argv=0;
00364 char ** envp=0;
00365 struct pt_regs * regs=0;
00366 struct linux_binprm bprm;
00367 struct file *file;
00368 int retval;
00369 int i;
00370
00371 file = open_exec(filename);
00372
00373 retval = PTR_ERR(file);
00374 if (IS_ERR(file))
00375 return retval;
00376
00377 bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
00378 memset(bprm.page, 0, MAX_ARG_PAGES*sizeof(bprm.page[0]));
00379
00380 bprm.file = file;
00381 bprm.filename = filename;
00382 bprm.sh_bang = 0;
00383 bprm.loader = 0;
00384 bprm.exec = 0;
00385 if ((bprm.argc = count(argv, bprm.p / sizeof(void *))) < 0) {
00386 allow_write_access(file);
00387 fput(file);
00388
00389 return bprm.argc;
00390 }
00391
00392 if ((bprm.envc = count(envp, bprm.p / sizeof(void *))) < 0) {
00393 allow_write_access(file);
00394 fput(file);
00395
00396 return bprm.envc;
00397 }
00398
00399 retval = prepare_binprm(&bprm);
00400
00401 if (retval < 0)
00402 goto out;
00403
00404 retval = copy_strings_kernel(1, &bprm.filename, &bprm);
00405
00406 if (retval < 0)
00407 goto out;
00408
00409 bprm.exec = bprm.p;
00410 retval = copy_strings(bprm.envc, envp, &bprm);
00411
00412 if (retval < 0)
00413 goto out;
00414
00415 retval = copy_strings(bprm.argc, argv, &bprm);
00416
00417 if (retval < 0)
00418 goto out;
00419
00420 retval = search_binary_handler(&bprm,regs);
00421 if (retval >= 0)
00422
00423 return retval;
00424
00425 out:
00426
00427 allow_write_access(bprm.file);
00428 if (bprm.file)
00429 fput(bprm.file);
00430
00431 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
00432 struct page * page = bprm.page[i];
00433 if (page)
00434 __free_page(page);
00435 }
00436
00437 return retval;
00438 }
00439 #endif
00440
00441 fork_out:
00442 return retval;
00443
00444 bad_fork_free:
00445 free_task_struct(p);
00446 goto fork_out;
00447
00448 }
00449
00450