00001
00002
00003
00004
00005
00006
00007 #include <linux/config.h>
00008 #include <linux/slab.h>
00009 #include <linux/kernel_stat.h>
00010 #include <linux/swap.h>
00011 #include <linux/swapctl.h>
00012 #include <linux/smp_lock.h>
00013 #include <linux/pagemap.h>
00014 #include <linux/init.h>
00015 #include <linux/highmem.h>
00016 #include <linux/file.h>
00017 #include <linux/compiler.h>
00018
00019 #include <asm/pgalloc.h>
00020
00021 #include <system_service_setup.h>
00022 #include <system_data_cells.h>
00023 #include <lnmstrdef.h>
00024 #include <dyndef.h>
00025 #include <lnmdef.h>
00026 #include <descrip.h>
00027 #include <starlet.h>
00028
00029 #include <fabdef.h>
00030 #include <rabdef.h>
00031 #include <pfldef.h>
00032 #include <pflmapdef.h>
00033 #include <exe_routines.h>
00034 #include <misc_routines.h>
00035 #include <mmg_routines.h>
00036
00037 #include <vfddef.h>
00038
00039 #ifdef CONFIG_VMS
00040
00041 struct mm_struct *swap_mm = &init_mm;
00042
00043 DECLARE_WAIT_QUEUE_HEAD(kswapd_wait);
00044
00045 int fastcall try_to_free_pages(zone_t *classzone, unsigned int gfp_mask, unsigned int order)
00046 {
00047 #if 0
00048 int priority = DEF_PRIORITY;
00049 int nr_pages = SWAP_CLUSTER_MAX;
00050
00051 gfp_mask = pf_gfp_mask(gfp_mask);
00052 do {
00053 nr_pages = shrink_caches(classzone, priority, gfp_mask, nr_pages);
00054 if (nr_pages <= 0)
00055 return 1;
00056 } while (--priority);
00057
00058
00059
00060
00061
00062 out_of_memory();
00063 return 0;
00064 #endif
00065 return 1;
00066 }
00067
00068 void balance(void) {
00069 if (sch_gl_freelim<=sch$gl_freecnt || sch$gl_freelim>= sgn$gl_freegoal) {
00070
00071
00072
00073 mmg_purgempl(0);
00074 }
00075 }
00076
00077 void swapsched(void) {
00078
00079 }
00080
00081 int pagefile=0;
00082 int myswapfile=0;
00083
00084 int kswapd(void *unused)
00085 {
00086 struct task_struct *tsk = current;
00087 DECLARE_WAITQUEUE(wait, tsk);
00088
00089 signed long long time=-10000000*5;
00090 #ifdef __i386__
00091 exe_schdwk(0,0,&time,0);
00092 #endif
00093 sys_hiber();
00094
00095 xqp_init2();
00096 #ifdef CONFIG_VMS
00097 extern void * global_e2_vcb;
00098 exttwo_init2(global_e2_vcb);
00099 #endif
00100
00101 #if 0
00102 daemonize();
00103 #endif
00104 strcpy(tsk->pcb_t_lname, "SWAPPER");
00105 sch_gl_swppid=tsk->pcb$l_pid;
00106 sigfillset(&tsk->blocked);
00107
00108 struct file * file=0;
00109 #ifndef CONFIG_VMS
00110 extern int mount_root_vfs;
00111 if (mount_root_vfs)
00112 file = filp_open("/vms_common/sysexe/pagefile.sys",O_RDONLY,0);
00113 #else
00114 file = rms_open_exec("[vms_common.sysexe]pagefile.sys");
00115 #endif
00116 if (!IS_ERR(file)) {
00117 char * c, *b, *n;
00118 char buf[1024];
00119 if (file==0)
00120 goto out;
00121 #if 0
00122 if (((struct _fcb *)(file))->fcb_b_type!=DYN$C_FCB) {
00123 printk("uh oh, not FCB\n");
00124 }
00125 #endif
00126 struct vms_fd * vms_fd = fget(file);
00127 struct _rabdef * rab = vms_fd->vfd_l_fd_p;
00128 struct _fabdef * fab = rab->rab_l_fab;
00129 int pages = fab->fab_l_alq >> 3;
00130 #if 0
00131 int pages=fcb->fcb_l_filesize>>12;
00132 #endif
00133 int bitmapsiz=pages>>3;
00134 struct _pfl * pfl=kmalloc(sizeof(struct _pfl)+bitmapsiz,GFP_KERNEL);
00135 memset(pfl,0,sizeof(struct _pfl)+bitmapsiz);
00136
00137 extern struct _pfl swap_info_pfl[];
00138
00139 myswapfile=pfl;
00140 pfl->pfl_b_type=DYN$C_PFL;
00141 pfl->pfl_w_size=sizeof(struct _pfl)+bitmapsiz;
00142 pfl->pfl_l_pgflx=0;
00143 #if 0
00144 pfl->pfl_l_window=fcb->fcb$l_wlfl;
00145 #else
00146 int chan = fab->fab_l_stv;
00147 struct _ccb * ccb = &ctl_ga_ccb_table[chan];
00148 pfl->pfl_l_window = ccb->ccb$l_wind;
00149 #endif
00150 pfl->pfl_l_bitmapsiz=bitmapsiz;
00151 pfl->pfl_l_frepagcnt=pages;
00152 pfl->pfl_l_bitmap=(long)pfl+sizeof(struct _pfl);
00153 pfl->pfl_l_startbyte=(long)pfl+sizeof(struct _pfl);
00154 printk("%%SWAPPER-I-DEBUG, Pagefile installed, pages %x\n",pages);
00155 pagefile=1;
00156 } else {
00157 out:
00158 printk("%%SWAPPER-I-DEBUG, Pagefile not installed\n");
00159 pagefile=0;
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 tsk->flags |= PF_MEMALLOC;
00175
00176
00177
00178
00179 for (;;) {
00180 __set_current_state(TASK_INTERRUPTIBLE);
00181 #if 0
00182 add_wait_queue(&kswapd_wait, &wait);
00183
00184 mb();
00185
00186
00187 if ((current->pcb_l_sts&PCB$M_WAKEPEN)==0)
00188 schedule();
00189
00190 __set_current_state(TASK_RUNNING);
00191 remove_wait_queue(&kswapd_wait, &wait);
00192
00193 #endif
00194
00195 sys_hiber();
00196
00197
00198 balance();
00199 mmg_wrtmfypag();
00200 swapsched();
00201
00202
00203
00204
00205 }
00206 }
00207
00208 int __init kswapd_init(void)
00209 {
00210 printk("Starting kswapd\n");
00211 swap_setup();
00212 kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL);
00213 return 0;
00214 }
00215
00216 #if 0
00217 module_init(kswapd_init)
00218 #endif
00219 #endif
00220
00221 struct _lnmth lnm_sys_dir_table_header;
00222
00223 struct _lnmx lnm_sys_dir_xlat = {
00224 lnmx_l_flags : LNMX$M_TERMINAL,
00225 lnmx_l_index : LNMX$C_TABLE,
00226 lnmx_l_next : 0
00227 };
00228
00229 struct _lnmb lnm_sys_dir = {
00230 lnmb_l_flink: &lnm_sys_dir,
00231 lnmb_l_blink: &lnm_sys_dir,
00232 lnmb_w_size: sizeof(struct _lnmb),
00233 lnmb_b_type: DYN$C_LNM,
00234 lnmb_b_acmode: MODE_K_KERNEL,
00235 lnmb_l_lnmx : &lnm_sys_dir_xlat,
00236 lnmb_l_table : &lnm_sys_dir_table_header,
00237 lnmb_b_flags : LNM$M_NO_ALIAS|LNM$M_TABLE|LNM$M_NO_DELETE,
00238 lnmb_b_count : 20,
00239 lnmb_t_name : "LNM$SYSTEM_DIRECTORY",
00240 };
00241
00242 long lnm_sys_dir_p = &lnm_sys_dir;
00243
00244 struct _lnmth lnm_sys_dir_table_header={
00245 lnmth_l_flags:LNMTH$M_SHAREABLE|LNMTH$M_DIRECTORY,
00246 lnmth_l_hash : 0,
00247 lnmth_l_orb : 0,
00248 lnmth_l_name : &lnm_sys_dir,
00249 lnmth_l_parent : 0,
00250 lnmth_l_child : 0,
00251 lnmth_l_sibling : 0,
00252 lnmth_l_qtable : 0,
00253 lnmth_l_byteslm : 0x7fffffff,
00254 lnmth_l_bytes : 0x7fffffff
00255 };
00256
00257 struct _lnmth lnm_sys_table_header;
00258
00259 struct _lnmx lnm_sys_xlat = {
00260 lnmx_l_flags : LNMX$M_TERMINAL,
00261 lnmx_l_index : LNMX$C_TABLE,
00262 lnmx_l_next : 0
00263 };
00264
00265 struct _lnmb lnm_sys = {
00266 lnmb_l_flink: &lnm_sys,
00267 lnmb_l_blink: &lnm_sys,
00268 lnmb_w_size: sizeof(struct _lnmb),
00269 lnmb_b_type: DYN$C_LNM,
00270 lnmb_b_acmode: MODE_K_KERNEL,
00271 lnmb_l_lnmx : &lnm_sys_xlat,
00272 lnmb_l_table : &lnm_sys_table_header,
00273 lnmb_b_flags : LNM$M_NO_ALIAS|LNM$M_TABLE,
00274 lnmb_b_count : 16,
00275 lnmb_t_name : "LNM$SYSTEM_TABLE",
00276 };
00277
00278 struct _lnmth lnm_sys_table_header={
00279 lnmth_l_flags: LNMTH$M_SYSTEM|LNMTH$M_SHAREABLE,
00280 lnmth_l_hash : 0,
00281 lnmth_l_orb : 0,
00282 lnmth_l_name : &lnm_sys,
00283 lnmth_l_parent : 0,
00284 lnmth_l_child : 0,
00285 lnmth_l_sibling : 0,
00286 lnmth_l_qtable : 0,
00287 lnmth_l_byteslm : 0x7fffffff,
00288 lnmth_l_bytes : 0x7fffffff
00289 };
00290
00291 void lnm_init_sys(void) {
00292
00293
00294
00295
00296 unsigned long ahash;
00297 unsigned long * myhash;
00298 int status;
00299 struct _lnmb * lnm_system_directory=&lnm_sys_dir;
00300 struct _lnmth * lnm_system_directory_table_header=&lnm_sys_dir_table_header;
00301
00302 _DESCRIPTOR(mypartab,"LNM$SYSTEM_DIRECTORY");
00303
00304 _DESCRIPTOR(mytabnam,"LNM$SYSTEM_TABLE");
00305
00306
00307
00308
00309
00310 lnm_sys_dir_table_header.lnmth_l_child = &lnm_sys_table_header;
00311 lnm_sys_table_header.lnmth_l_parent = &lnm_sys_dir_table_header;
00312 lnm_sys_dir_table_header.lnmth_l_hash = &lnmhshs;
00313 lnm_sys_table_header.lnmth_l_hash = &lnmhshs;
00314 lnm_sys.lnmb_l_table=&lnm_sys_dir_table_header;
00315
00316 lnm_al_dirtbl[0]=&lnm_sys_dir_p;
00317 lnm_al_dirtbl[1]=&ctl$gl_lnmdirect;
00318
00319
00320
00321
00322 myhash=&ahash;
00323 status=lnm_hash(mypartab.dsc$w_length,mypartab.dsc$a_pointer,0xffff,myhash);
00324 #ifdef LNM_DEBUG
00325 lnmprintf("here %x %x\n",myhash,*myhash);
00326 #endif
00327 lnmhshs.entry[2*(*myhash)]=lnm_system_directory;
00328 lnmhshs.entry[2*(*myhash)+1]=lnm_system_directory;
00329 status=lnm_hash(mytabnam.dsc$w_length,mytabnam.dsc$a_pointer,0xffff,myhash);
00330 #ifdef LNM_DEBUG
00331 lnmprintf("here %x %x\n",myhash,*myhash);
00332 #endif
00333 lnmhshs.entry[2*(*myhash)]=&lnm_sys;
00334 lnmhshs.entry[2*(*myhash)+1]=&lnm_sys;
00335 }
00336
00337 void exe_swapinit(void) {
00338
00339
00340
00341
00342
00343
00344
00345 mainloop:
00346 goto mainloop;
00347
00348 }
00349