00001
00002
00003
00004
00005
00006 #include <linux/bitops.h>
00007 #include <linux/config.h>
00008 #include <linux/mm.h>
00009 #include <linux/vmalloc.h>
00010
00011 #include<dyndef.h>
00012 #include<fcbdef.h>
00013 #include<ipldef.h>
00014 #include<irpdef.h>
00015 #include<mpwdef.h>
00016 #include<schdef.h>
00017 #include<system_data_cells.h>
00018 #include<vmspte.h>
00019 #include<ssdef.h>
00020 #include<pfndef.h>
00021 #include<pfldef.h>
00022 #include<wcbdef.h>
00023 #include <linux/slab.h>
00024 #include <linux/init.h>
00025 #include <misc_routines.h>
00026 #include <mmg_routines.h>
00027
00028 #if 0
00029 struct _irp * mpw_gl_irpfl = &mpw$gl_irpfl;
00030 struct _irp * mpw_gl_irpbl = &mpw$gl_irpfl;
00031 #endif
00032
00033 unsigned char mpw_gb_state;
00034
00035 void mmg_purgempl(unsigned long command);
00036
00037 void mmg_wrtmfypag(void) {
00038 #if 0
00039
00040 if (mmg_gl_maxpfidx==0)
00041 return;
00042 #endif
00043 #if 0
00044 if (sch_gl_mfylim>sch$gl_mfycnt)
00045 return;
00046 #else
00047 if (1>sch_gl_mfycnt)
00048 return;
00049 #endif
00050 if (test_and_set_bit(SCH_V_MPW,&sch$gl_sip))
00051 return;
00052 #if 0
00053 setipl(IPL__MMG);
00054 vmslock(&SPIN_MMG,-1);
00055 #endif
00056 mmg_purgempl(MPW$C_MAINTAIN);
00057
00058 test_and_clear_bit(SCH_V_MPW,&sch$gl_sip);
00059 }
00060
00061 void mmg_purgempl(unsigned long command) {
00062 if (1>sch_gl_mfycnt)
00063 return;
00064 if (mpw_ar_perfstats==MPW$C_SVAPTE)
00065 return;
00066 mpw_gb_state=command;
00067
00068 struct _irp * i=kmalloc(sizeof(struct _irp),GFP_KERNEL);
00069 memset(i,0,sizeof(struct _irp));
00070
00071 i->irp_b_type=DYN$C_INIT;
00072 #if 0
00073 i->irp_b_efn=efn;
00074 i->irp_l_ast=astadr;
00075 i->irp_l_astprm=astprm;
00076 i->irp_l_iosb=iosb;
00077 i->irp_w_chan=chan;
00078 i->irp_l_func=func;
00079 i->irp_b_pri=p->pcb$b_pri;
00080 i->irp_l_qio_p1=p1;
00081 i->irp_l_qio_p2=p2;
00082 i->irp_l_qio_p3=p3;
00083 i->irp_l_qio_p4=p4;
00084 i->irp_l_qio_p5=p5;
00085 i->irp_l_qio_p6=p6;
00086 i->irp_l_ucb=ctl$gl_ccbbase[chan].ccb$l_ucb;
00087 i->irp_l_pid=current->pcb$l_pid;
00088 i->irp_l_sts|=IRP$M_BUFIO;
00089 #endif
00090
00091 long * apte = &i->irp_cdrp;
00092 long * aphv = apte + 1;
00093
00094 struct _pfn * pfn = pfn_al_tail[PFN$C_MFYPAGLST];
00095 mmg_rempfn(PFN$C_MFYPAGLST,pfn);
00096
00097 #if 0
00098 long old_va=pfn->virtual;
00099 #endif
00100 int pfl_page;
00101 int sts=mmg_allocpagfil1(1, &pfl_page);
00102
00103 if (sts!=SS__NORMAL)
00104 return;
00105
00106
00107 #if 0
00108 int * mypage=vmalloc(4096);
00109
00110 pfn->virtual=mypage;
00111 unsigned long * pte = findpte_new(ctl_gl_pcb->mm,mypage);
00112 long oldpte = *pte;
00113 #endif
00114 long pfnno = pfn-&mem_map[0];
00115
00116 struct _mypte * otherpte=pfn->pfn_q_pte_index;
00117 struct _mypte * mypte = otherpte;
00118 struct _pte * pte = otherpte;
00119 #if 0
00120 *(unsigned long *)pte=*(long*)otherpte;
00121 #endif
00122 *(unsigned long *)pte|=_PAGE_PRESENT;
00123
00124 #ifndef __arch_um__
00125 __flush_tlb();
00126 #endif
00127
00128 extern int myswapfile;
00129 struct _pfl * pfl = myswapfile;
00130
00131 if (pfl->pfl_l_window->wcb$l_fcb->fcb$l_fill_5)
00132 block_write_full_page3(pfl->pfl_l_window->wcb$l_fcb, pfn, pfl_page);
00133 else
00134 ods2_block_write_full_page3(pfl->pfl_l_window, pfn, pfl_page);
00135 #if 0
00136 pfn->virtual=old_va;
00137 #endif
00138 printk("Wrote to pfl_page %x %x %x\n",pfl_page,otherpte,*(long*)otherpte);
00139
00140 *(unsigned long *)pte&=~_PAGE_PRESENT;
00141 #if 0
00142 *pte=oldpte;
00143 #endif
00144 #ifndef __arch_um__
00145 __flush_tlb();
00146 #endif
00147 #if 0
00148 vfree(mypage);
00149 #endif
00150
00151 long * tmp=otherpte;
00152 *tmp=0;
00153 otherpte->pte_v_typ1=1;
00154 otherpte->pte_v_pgflpag=pfl_page;
00155 pfn->pfn_q_bak=*(long*)otherpte;
00156
00157 mmg_inspfn(PFN$C_FREPAGLST,pfn,0);
00158
00159 kfree(i);
00160
00161 }
00162