00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include<linux/linkage.h>
00009 #include<asm/current.h>
00010 #include<system_data_cells.h>
00011 #include<ipl.h>
00012 #include<lckdef.h>
00013 #include<lckctxdef.h>
00014 #include<lksbdef.h>
00015 #include<misc.h>
00016 #include<ssdef.h>
00017 #include<starlet.h>
00018 #include<acbdef.h>
00019 #include<ipldef.h>
00020 #include<rsbdef.h>
00021 #include<lkbdef.h>
00022 #include<pridef.h>
00023 #include<descrip.h>
00024 #include<cdrpdef.h>
00025 #include <queue.h>
00026 #include <exe_routines.h>
00027 #include <misc_routines.h>
00028 #include <scs_routines.h>
00029 #include <sch_routines.h>
00030 #include <linux/slab.h>
00031 #include <internals.h>
00032 
00033 
00034 
00035 unsigned char lck_ar_compat_tbl[6]={0x3f,0x1f,0x7,0xb,3,1};
00036 #if 0
00037 unsigned char lck_ar_compat_tbl2[6,6]={
00038   {1,1,1,1,1,1},
00039   {0,1,1,1,1,1},
00040   {0,0,0,1,1,1},
00041   {0,0,1,0,1,1},
00042   {0,0,0,0,1,1},
00043   {0,0,0,0,0,1}
00044 };
00045 #endif
00046 
00047 unsigned char lck_synccvt_tbl[6]={1,3,7,0xb,0x1f,0x3f};
00048 
00049 unsigned char lck_quecvt_tbl[6]={0x3e,0x3c,0x38,0x34,0x20,0};
00050 
00051 unsigned char lck_ggmax_tbl[6]={0,0,8,4,0,0};
00052 
00053 unsigned char lck_ggred_tbl[6]={0,0,0,0,0xc,0};
00054 
00055 unsigned char lck_valblk_tbl[6]={0,0,0,0,0x1f,0x3f};
00056 
00057 unsigned char lck_al_dwncvt_tbl[6]={0,1,3,3,0xf,0x1f};
00058 
00059 void dlmmyerr(){}
00060 
00061 void dlmlisten(){}
00062 
00063 int dlminit(void) {
00064   char myname[]="dlm_dlm";
00065   char myinfo[]="dlm dlm";
00066 
00067   
00068   scs_std_listen(dlmlisten,dlmmyerr,myname,myinfo,0);
00069 }
00070 
00071 extern struct _rsb * reshashtbl[];
00072 extern unsigned long lockidtbl[];
00073 
00074 static int dlmconnected=0;
00075 
00076 dlm_msg(){}
00077 
00078 dlm_dg(){}
00079 
00080 dlm_err(){}
00081 
00082 void lck_snd_granted(struct _lkb * lck) {
00083   struct _cdrp * cdrp = kmalloc(sizeof(struct _cdrp), GFP_KERNEL);
00084   memset(cdrp,0,sizeof(struct _cdrp));
00085   cdrp->cdrp_l_val1=lck->lkb$l_remlkid;
00086   cdrp->cdrp_l_val2=lck-lockidtbl[0];
00087   if (!dlmconnected) {
00088     dlmconnected=1;
00089   }
00090   scs_std_senddg(0,500,cdrp);
00091 }
00092 
00093 
00094 static void * enq_find_oldest_parent(struct _rsb * res,struct _rsb * par) {
00095   struct _rsb * rsb=res;
00096   while (res) {
00097     rsb->rsb_b_depth++;
00098     par=res->rsb_l_parent;
00099     if (par==0) return res;
00100     res=par;
00101   };
00102 }
00103 
00104 int reshash(struct dsc_descriptor * d) {
00105   return d->dsc_w_length;
00106 }
00107 
00108 struct _rsb * find_reshashtbl(struct dsc_descriptor * d) {
00109   struct _rsb * tmp, *head=&reshashtbl[reshash(d)*2];
00110   tmp=head->rsb_l_hshchn;
00111   while (tmp!=head && strncmp(tmp->rsb_t_resnam,d->dsc$a_pointer,d->dsc$w_length)) {
00112     tmp=tmp->rsb_l_hshchn;
00113   }
00114   if (strncmp(tmp->rsb_t_resnam,d->dsc$a_pointer,d->dsc$w_length)) 
00115     return 0;
00116   else
00117     return tmp;
00118 }
00119 
00120 void insert_reshashtbl(struct _rsb *res) {
00121   struct dsc_descriptor d;
00122   d.dsc_w_length=res->rsb$b_rsnlen;
00123   d.dsc_a_pointer=res->rsb$t_resnam;
00124   insque(res,&reshashtbl[2*reshash(&d)]);
00125 }
00126 
00127 int insert_lck(struct _lkb * lck) {
00128   int i;
00129   for(i=1;i<LOCKIDTBL && (lockidtbl[i]&0xffff0000);i++) ;
00130   lockidtbl[i]=lck;
00131   
00132   return i;
00133 }
00134 
00135 asmlinkage int exe_enq(unsigned int efn, unsigned int lkmode, struct _lksb *lksb, unsigned int flags, void *resnam, unsigned int parid, void (*astadr)(), unsigned long astprm, void (*blkastadr)(), unsigned int acmode, unsigned int rsdm_id) {
00136   int convert;
00137   int retval=SS__NORMAL;
00138   int sts;
00139 
00140   
00141   if (lkmode>LCK_K_EXMODE) return SS$_BADPARAM;
00142 
00143   vmslock(&SPIN_SCS,IPL__SCS); 
00144   convert=flags&LCK_M_CONVERT;
00145   if (!convert) {
00146     
00147     struct _rsb * res = 0;
00148     struct _rsb * old;
00149     struct _lkb * lck = 0, *par = 0;
00150     struct dsc_descriptor * resnamdsc;
00151     int sserror=0;
00152 
00153     resnamdsc=resnam;
00154     if (resnamdsc->dsc_w_length==0 || resnamdsc->dsc$w_length>RSB$K_MAXLEN) { 
00155       sserror=SS__IVBUFLEN;
00156       goto error;
00157     }
00158     if (flags&LCK_M_EXPEDITE)
00159       if (lkmode!=LCK_K_NLMODE) {
00160         sserror=SS__UNSUPPORTED;
00161         goto error;
00162       }
00163 
00164     if (lkmode!=LCK_K_NLMODE) {
00165       sserror=SS__UNSUPPORTED;
00166       goto error;
00167     }
00168 
00169     res=kmalloc(sizeof(struct _rsb),GFP_KERNEL);
00170     memset(res,0,sizeof(struct _rsb));
00171     lck=kmalloc(sizeof(struct _lkb),GFP_KERNEL);
00172     memset(lck,0,sizeof(struct _lkb));
00173 
00174     lck->lkb_b_efn=efn;
00175     lck->lkb_l_flags=flags;
00176     lck->lkb_b_rqmode=lkmode;
00177     lck->lkb_l_cplastadr=astadr;
00178     lck->lkb_l_blkastadr=blkastadr;
00179     lck->lkb_l_astprm=astprm;
00180     lck->lkb_l_pid=current->pcb$l_pid;
00181     lck->lkb_l_lksb=lksb;
00182     qhead_init(&lck->lkb_l_sqfl);
00183     qhead_init(&lck->lkb_l_ownqfl);
00184 
00185     strncpy(res->rsb_t_resnam,resnamdsc->dsc$a_pointer,resnamdsc->dsc$w_length);
00186     res->rsb_b_rsnlen=resnamdsc->dsc$w_length;
00187 
00188     setipl(IPL__SCS);
00189     
00190     
00191 
00192     if (flags&LCK_M_SYSTEM) {
00193       
00194     } else {
00195         
00196     }
00197 
00198     if (parid==0) {
00199       
00200       
00201     } else {
00202       
00203       
00204       par=lockidtbl[parid];
00205       if (current->pcb_l_pid != par->lkb$l_pid) {
00206         vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00207         return SS__IVLOCKID;
00208       }
00209       
00210       if (par->lkb_b_state!=LKB$K_CONVERT  || par->lkb$b_state!=LKB$K_GRANTED) 
00211         if ((par->lkb_l_flags & LCK$M_CONVERT) == 0) {
00212             vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00213             return SS__PARNOTGRANT;
00214         }
00215       par->lkb_w_refcnt++;
00216       res->rsb_l_parent = par->lkb$l_rsb; 
00217       
00218       
00219       
00220       
00221       
00222       lck->lkb_l_parent=par;
00223     }
00224 
00225     old=find_reshashtbl(resnamdsc);
00226     if (!old) {
00227       lck_gl_rsbcnt++;
00228       lck_gl_lckcnt++;
00229       if (flags & LCK_M_SYNCSTS) retval=SS$_SYNCH;
00230       qhead_init(&res->rsb_l_grqfl);
00231       qhead_init(&res->rsb_l_cvtqfl);
00232       qhead_init(&res->rsb_l_wtqfl);
00233       
00234       lck->lkb_l_rsb=res;
00235       insert_reshashtbl(res);
00236       if (parid==0) {
00237         insque(&res->rsb_l_rrsfl,lck$gl_rrsfl);
00238         qhead_init(&res->rsb_l_srsfl);
00239         res->rsb_b_depth=0;
00240         res->rsb_l_rtrsb=res;
00241         exe_clref(lck->lkb$b_efn);
00242         insque(&lck->lkb_l_ownqfl,¤t->pcb$l_lockqfl);
00243         
00244         
00245         lksb->lksb_l_lkid=insert_lck(lck);
00246         lksb->lksb_w_status=SS$_NORMAL;
00247         
00248         sts = lck_grant_lock(lck ,res ,-1,lkmode,flags,efn,res->rsb$b_ggmode);
00249 
00250         goto end;
00251       } else {
00252         
00253         res->rsb_l_csid=par->lkb$l_rsb->rsb$l_csid;
00254         par->lkb_l_rsb->rsb$w_refcnt++;
00255         res->rsb_b_depth=par->lkb$l_rsb->rsb$b_depth+1;
00256         
00257         if (res->rsb_b_depth>10) { 
00258           retval=SS__EXDEPTH;
00259           goto error;
00260         }
00261         res->rsb_l_rtrsb=par->lkb$l_rsb->rsb$l_rtrsb;
00262         insque(&res->rsb_l_srsfl,&par->lkb$l_rsb->rsb$l_srsfl);
00263         if (par->lkb_l_csid) { 
00264           lck_snd_granted(lck);
00265         } else {
00266           sts = lck_grant_lock(lck,res,-1,lkmode,flags,efn,res->rsb$b_ggmode);
00267         }
00268       }
00269     } else {
00270       
00271       
00272       int granted = 0;
00273       if (flags & LCK_M_SYNCSTS) retval=SS$_SYNCH;
00274       kfree(res);
00275       res=old;
00276       lck->lkb_l_rsb=res;
00277 
00278       
00279 
00280       if (0!=test_bit(res->rsb_b_ggmode,&lck$ar_compat_tbl[lck->lkb$b_rqmode])) {
00281         if (aqempty(res->rsb_l_wtqfl)) {
00282           granted=1;
00283           
00284         } else {
00285           if (flags&LCK_M_NOQUEUE) {
00286             res->rsb_w_lckcnt--;
00287             kfree(lck);
00288             vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00289             return SS__NOTQUEUED;
00290           } else {
00291             lck->lkb_b_state=LKB$K_WAITING;
00292             insque(&lck->lkb_l_sqfl,res->rsb$l_wtqfl);
00293             lksb->lksb_w_status=0;
00294             lck->lkb_l_status|=LKB$M_ASYNC;
00295             maybe_blkast(res,lck);
00296           }
00297         }
00298       } else {
00299         
00300         if (flags&LCK_M_NOQUEUE) {
00301           res->rsb_w_lckcnt--;
00302           kfree(lck);
00303           vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00304           return SS__NOTQUEUED;
00305         } else {
00306           lck->lkb_b_state=LKB$K_WAITING;
00307           insque(&lck->lkb_l_sqfl,res->rsb$l_wtqfl);
00308           lksb->lksb_w_status=0;
00309           lck->lkb_l_status|=LKB$M_ASYNC;
00310           maybe_blkast(res,lck);
00311           
00312         }
00313       }
00314 
00315       lksb->lksb_l_lkid=insert_lck(lck);
00316       lksb->lksb_w_status=SS$_NORMAL;
00317 
00318       if ((granted & 1)==1) {
00319         if (0) { 
00320           lck_snd_granted(lck);
00321         } else {
00322           sts = lck_grant_lock(lck, res, -1,lkmode,flags,efn,res->rsb$b_ggmode);
00323         }
00324       }
00325     }
00326   end:
00327     
00328     vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00329     return retval;
00330   error:
00331     
00332     kfree(res);
00333     kfree(lck);
00334     vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00335     return sserror;
00336     
00337   } else { 
00338     
00339     int granted = 0, newmodes = 0;
00340     struct _lkb * lck;
00341     struct _rsb * res;
00342     void * dummy;
00343     int newmode;
00344     lck=lockidtbl[lksb->lksb_l_lkid];
00345     res=lck->lkb_l_rsb;
00346     if (lck->lkb_b_state!=LKB$K_GRANTED) {
00347       vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00348       return SS__CVTUNGRANT;
00349     }
00350     lck->lkb_b_efn=efn;
00351     lck->lkb_l_flags=flags;
00352     lck->lkb_b_rqmode=lkmode;
00353     lck->lkb_l_cplastadr=astadr;
00354     lck->lkb_l_blkastadr=blkastadr;
00355     lck->lkb_l_astprm=astprm;
00356     lck->lkb_l_lksb=lksb;
00357     remque(&lck->lkb_l_sqfl,&lck->lkb$l_sqfl);
00358     
00359     if (aqempty(res->rsb_l_cvtqfl) && aqempty(res->rsb$l_grqfl)) {
00360       sts = lck_grant_lock(lck ,res,lck->lkb$b_grmode,lkmode,flags,efn,-1);
00361       vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00362       return SS__NORMAL;
00363     } else { 
00364       if (res->rsb_b_cgmode!=lck->lkb$b_grmode) {
00365         newmode=res->rsb_b_ggmode;
00366       } else {
00367         newmode=find_highest(lck,res);
00368         newmodes= 0;
00369       }
00370       if (test_bit(lkmode,&lck_ar_compat_tbl[newmode])) {
00371         
00372         granted = 1;
00373       }
00374     }
00375 
00376     if (granted) {
00377       if (newmodes) {
00378         res->rsb_b_fgmode=newmode;
00379         res->rsb_b_ggmode=newmode;
00380         res->rsb_b_cgmode=newmode;
00381       }
00382       sts = lck_grant_lock(lck,res,lck->lkb$b_grmode,lkmode ,flags,efn,res->rsb$b_ggmode);
00383       grant_queued(res,newmode,1,1);
00384     } else {
00385       int wasempty=aqempty(&res->rsb_l_cvtqfl);
00386       lck->lkb_b_rqmode=lkmode;
00387       insque(&lck->lkb_l_sqfl,res->rsb$l_cvtqfl);
00388       lck->lkb_b_state=LKB$K_CONVERT;
00389       lksb->lksb_w_status=0;
00390       lck->lkb_l_status|=LKB$M_ASYNC;
00391       maybe_blkast(res,lck);
00392       if (wasempty)
00393         res->rsb_b_cgmode=newmode;
00394       sts=SS__NORMAL;
00395     }
00396     vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00397     return sts;
00398   }
00399   vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00400 }
00401 
00402 int lck_deqlock(struct _lkb *lck, int flags, unsigned int lkid) {
00403   vmslock(&SPIN_SCS,IPL__SCS);
00404   struct _rsb * res = lck->lkb_l_rsb;
00405   int newmode;
00406 
00407   remque(&lck->lkb_l_ownqfl,0);
00408   remque(&lck->lkb_l_sqfl,0);
00409 
00410   
00411 
00412   newmode=find_highest(lck,res);
00413 
00414   res->rsb_b_fgmode=newmode;
00415   res->rsb_b_ggmode=newmode;
00416   res->rsb_b_cgmode=newmode;
00417 
00418   grant_queued(res,0,1,1);
00419 
00420   if (lck->lkb_b_state) {
00421   }
00422   kfree(lck);
00423   lockidtbl[lkid] = lkid + 1;
00424   if (aqempty(&res->rsb_l_grqfl) && aqempty(&res->rsb$l_cvtqfl) && aqempty(&res->rsb$l_wtqfl) && aqempty(&res->rsb$l_rrsfl) && aqempty(&res->rsb$l_srsfl)) {
00425     remque(res, 0);
00426     kfree(res);
00427   }
00428   vmsunlock(&SPIN_SCS,IPL__ASTDEL);
00429 }
00430 
00431 asmlinkage int exe_deq(unsigned int lkid, void *valblk, unsigned int acmode, unsigned int flags) {
00432   int sts = SS__NORMAL;
00433   struct _lkb * lck;
00434   if (lkid) {
00435     lck = lockidtbl[lkid];
00436     sts = lck_deqlock(lck, flags, lkid);
00437     if (lck->lkb_l_parent!=lck && ((flags&LCK$M_DEQALL)==0)) {
00438       
00439       goto end;
00440     }
00441   } else {
00442     if (flags & LCK_M_DEQALL) {
00443       
00444     } else {
00445       return SS__SUBLOCKS;
00446     }
00447   }
00448  end:
00449   return sts;
00450 }
00451 
00452 void lock_iosb_kast(int par) {
00453   struct _lkb * lck = par;
00454   struct _lksb * lksb = lck->lkb_l_lksb;
00455   if (lck->lkb_l_status&LKB$M_ASYNC) {
00456 #if 0
00457     if (lksb) 
00458       lksb->lksb_w_status=SS$_NORMAL;
00459 #endif
00460     lck->lkb_l_status&=~LKB$M_ASYNC;
00461   }
00462   if (lck->lkb_l_status&LKB$M_DCPLAST) {
00463     lck->lkb_b_rmod=LKB$M_NODELETE;
00464     lck->lkb_l_ast=lck->lkb$l_cplastadr;
00465     lck->lkb_l_astprm=lck->lkb$l_oldastprm;
00466     sch_qast(lck->lkb$l_pid,PRI$_RESAVL,lck);
00467   }
00468 }
00469 
00470 int lck_grant_lock(struct _lkb * lck,struct _rsb * res, signed int curmode, signed int nextmode, int flags, int efn, signed int ggmode) {
00471   int retsts=SS__NORMAL;
00472   int blocking = 0;
00473 
00474   if (ggmode==-1 || nextmode>curmode) {
00475     res->rsb_b_ggmode=nextmode;
00476     res->rsb_b_fgmode=nextmode;
00477     res->rsb_b_cgmode=nextmode;
00478   }
00479 
00480   lck->lkb_b_grmode=nextmode;
00481   lck->lkb_l_lkst1=SS$_NORMAL;
00482 
00483   
00484 
00485   if (lck->lkb_l_blkastadr) {
00486     struct _lkb * head = &res->rsb_l_cvtqfl;
00487     int diff=((char*)&head->lkb_l_sqfl)-((char*)head);
00488     struct _lkb * next = res->rsb_l_cvtqfl - diff;
00489     head=((unsigned long)head)-diff;
00490 
00491     res->rsb_w_blkastcnt++;
00492 
00493     while (head!=next) {
00494       
00495       if (0==test_bit(nextmode,&lck_ar_compat_tbl[next->lkb$b_rqmode])) {
00496         blocking = 1;
00497         goto endblockchk;
00498       }
00499       next=next->lkb_l_sqfl-diff;
00500     }
00501 
00502     head = &res->rsb_l_wtqfl;
00503     next = res->rsb_l_wtqfl - diff;
00504     head=((unsigned long)head)-diff;
00505 
00506     while (head!=next) {
00507       
00508       if (0==test_bit(nextmode,&lck_ar_compat_tbl[next->lkb$b_rqmode])) {
00509         blocking = 1;
00510         goto endblockchk;
00511       }
00512       next=next->lkb_l_sqfl-diff;
00513     }
00514   }
00515  endblockchk:
00516 
00517   insque(&lck->lkb_l_sqfl,res->rsb$l_grqfl);
00518   lck->lkb_b_state=LKB$K_GRANTED;
00519 
00520   retsts=SS__SYNCH;
00521 
00522   lck->lkb_b_rmod|=ACB$M_NODELETE;
00523   lck->lkb_b_rmod&=~(LKB$M_KAST|LKB$M_PKAST);
00524 
00525   if (blocking || lck->lkb_l_cplastadr || (lck->lkb$l_status&LKB$M_ASYNC)) {
00526 
00527     if (blocking && lck->lkb_l_cplastadr) {
00528       lck->lkb_l_status|=LKB$M_DCPLAST;
00529       lck->lkb_l_oldastprm=lck->lkb$l_astprm;
00530       lck->lkb_b_rmod|=LKB$M_PKAST;
00531     }
00532 
00533     if (blocking) {
00534       lck->lkb_l_ast=lck->lkb$l_blkastadr;
00535     } else {
00536       lck->lkb_l_ast=lck->lkb$l_cplastadr;
00537     }
00538 
00539     if (lck->lkb_l_status&LKB$M_ASYNC || (lck->lkb$b_rmod&LKB$M_PKAST)) {
00540       if (0==(lck->lkb_b_rmod&LKB$M_PKAST)) {
00541         lck->lkb_b_rmod|=LKB$M_KAST;
00542       }
00543       lck->lkb_l_kast=lock_iosb_kast;
00544       lck->lkb_l_astprm=lck;
00545     }
00546 
00547 #if 0
00548     if (lck->lkb_l_cplastadr && (lck->lkb$l_flags&LCK$M_SYNCSTS)==0) {
00549       lck->lkb_l_ast=lck->lkb$l_cplastadr;
00550     }
00551 #endif
00552 
00553     sch_qast(lck->lkb$l_pid,PRI$_RESAVL,lck);
00554   }
00555 
00556   
00557 
00558   sch_postef(lck->lkb$l_pid,PRI$_RESAVL,lck->lkb$b_efn);
00559 
00560   return retsts;
00561 }
00562 
00563 int maybe_blkast(struct _rsb * res, struct _lkb * lck) {
00564   if (lck->lkb_l_blkastadr) {
00565     struct _lkb * head = &res->rsb_l_grqfl;
00566     int diff=((char*)&head->lkb_l_sqfl)-((char*)head);
00567     struct _lkb * next = res->rsb_l_grqfl - diff;
00568     head=((unsigned long)head)-diff;
00569 
00570     while (head!=next) {
00571       
00572       if (0==test_bit(next->lkb_b_grmode,&lck$ar_compat_tbl[lck->lkb$b_rqmode])) {
00573         next->lkb_b_rmod|=ACB$M_NODELETE;
00574         next->lkb_b_rmod&=~(LKB$M_KAST|LKB$M_PKAST);
00575         next->lkb_l_ast=next->lkb$l_blkastadr;
00576         sch_qast(next->lkb$l_pid,PRI$_RESAVL,next);
00577       }
00578       next=next->lkb_l_sqfl-diff;
00579     }
00580     
00581   }
00582   return SS__NORMAL;
00583 }
00584 
00585 int find_highest(struct _lkb * lck, struct _rsb * res) {
00586   int high=0;
00587   struct _lkb * skipme=&lck->lkb_l_sqfl;
00588 
00589   struct _lkb * head=&res->rsb_l_grqfl;
00590   struct _lkb * tmp=res->rsb_l_grqfl;
00591 
00592   int diff=((char*)&tmp->lkb_l_sqfl)-((char*)tmp);
00593 
00594   while (tmp!=head) {
00595     if (tmp!=skipme) {
00596       struct _lkb * lock=((char*)tmp)-((char*)diff);
00597       if (lock->lkb_b_grmode>high)
00598         high=lock->lkb_b_grmode;
00599     }
00600     tmp=tmp->lkb_l_astqfl; 
00601   }
00602 
00603   while (tmp!=head) {
00604     if (tmp!=skipme) {
00605       struct _lkb * lock=((char*)tmp)-((char*)diff);
00606       if (lock->lkb_b_grmode>high)
00607         high=lock->lkb_b_grmode;
00608     }
00609     tmp=tmp->lkb_l_astqfl; 
00610   }
00611 
00612   head=&res->rsb_l_cvtqfl;
00613   tmp=res->rsb_l_cvtqfl;
00614 
00615 
00616   return high;
00617 }
00618 
00619 int grant_queued(struct _rsb * res, int ggmode_not, int docvt, int dowt) {
00620   struct _lkb * head, * tmp;
00621   int diff;
00622   int newmode;
00623   if (docvt) {
00624     head=&res->rsb_l_cvtqfl;
00625     tmp=res->rsb_l_cvtqfl;
00626     diff=((char*)&tmp->lkb_l_sqfl)-((char*)tmp);
00627     while (head!=tmp) {
00628       tmp=((char *)tmp)-((char*)diff);
00629       newmode=res->rsb_b_ggmode;
00630       if (test_bit(tmp->lkb_b_rqmode,&lck$ar_compat_tbl[res->rsb$b_ggmode])) {
00631         struct _lkb * lck=tmp;
00632         struct _lkb * next=tmp->lkb_l_sqfl;
00633         remque(((int)tmp)+diff,0);
00634         lck_grant_lock(lck ,res,lck->lkb$b_grmode,lck->lkb$b_rqmode,0,0,res->rsb$b_ggmode);
00635         tmp=next;
00636         continue;
00637       }
00638       newmode=find_highest(tmp,res);
00639       if (res->rsb_b_ggmode==tmp->lkb$b_grmode) {
00640         if (test_bit(tmp->lkb_b_rqmode,&lck$ar_compat_tbl[newmode])) {
00641           struct _lkb * lck=tmp;
00642           struct _lkb * next=tmp->lkb_l_sqfl;
00643           remque(((int)tmp)+diff,0);
00644           lck_grant_lock(lck ,res,lck->lkb$b_grmode,lck->lkb$b_rqmode,0,0,res->rsb$b_ggmode);
00645           tmp=next;
00646           continue;
00647         } else {
00648           res->rsb_b_cgmode=newmode;
00649         }
00650       }
00651       tmp=tmp->lkb_l_sqfl;
00652     }
00653   }
00654   if (dowt) {
00655   }
00656 
00657 }
00658 
00659 asmlinkage int exe_enqw(unsigned int efn, unsigned int lkmode, struct _lksb *lksb, unsigned int flags, void *resnam, unsigned int parid, void (*astadr)(), unsigned long astprm, void (*blkastadr)(), unsigned int acmode, unsigned int rsdm_id) {
00660   int status=exe_enq(efn,lkmode,lksb,flags,resnam,parid,astadr,astprm,blkastadr,acmode,rsdm_id);
00661   printk("\n\nremember to do like qiow\n\n");
00662   if ((status&1)==0) return status;
00663   return exe_synch(efn,lksb);
00664 }
00665 
00666 asmlinkage int exe_enqw_wrap(struct struct_args * s) {
00667   return exe_enqw(s->s1,s->s2,s->s3,s->s4,s->s5,s->s6,s->s7,s->s8,s->s9,s->s10,s->s11);
00668 }
00669 
00670 
00671 asmlinkage int exe_enq_wrap(struct struct_args * s) {
00672   return exe_enq(s->s1,s->s2,s->s3,s->s4,s->s5,s->s6,s->s7,s->s8,s->s9,s->s10,s->s11);
00673 }
00674 
00675