00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include<starlet.h>
00012 #include<iodef.h>
00013 #include<ssdef.h>
00014 #include<descrip.h>
00015 #include<misc.h>
00016 #include<irpdef.h>
00017 #include<ucbdef.h>
00018 #include<ddbdef.h>
00019 #include<ccbdef.h>
00020 #include<lnmdef.h>
00021 #include<sbdef.h>
00022 #include<system_data_cells.h>
00023 #include<sysgen.h>
00024 #include <ioc_routines.h>
00025 #include<linux/vmalloc.h>
00026 #include<linux/linkage.h>
00027 #include <exe_routines.h>
00028 #include <lnmsub.h>
00029 #include <lnmstrdef.h>
00030
00031
00032
00033
00034
00035
00036 int ioc_ffchan(unsigned short int *chan) {
00037 unsigned short int i;
00038 for (i=0; i<CHANNELCNT && ctl_gl_ccbbase[i].ccb$b_amod; i++) ;
00039 if (ctl_gl_ccbbase[i].ccb$b_amod)
00040 return SS__NOIOCHAN;
00041 else {
00042 *chan=i;
00043 return SS__NORMAL;
00044 }
00045 }
00046
00047 int ioc_searchdev(struct return_values *r, void * devnam) {
00048
00049 return ioc_search(r,devnam);
00050 }
00051
00052 extern struct _sb othersb;
00053
00054 long int dsc_strtol(const char *nptr, int len, char **endptr, int base) {
00055 char str[len+1];
00056 memcpy(str, nptr, len);
00057 str[len]=0;
00058
00059 return simple_strtol(str, endptr, base);
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 int ioc_search(struct return_values *r, void * devnam) {
00071 char out[255];
00072 int outlen;
00073 char * outagain;
00074 memset(out,0,255);
00075
00076 int sts = ioc_std_trandevnam(devnam, 0, out, &outlen, &outagain);
00077
00078
00079
00080 struct dsc_descriptor *s=devnam;
00081 struct _ddb * d=ioc_gl_devlist;
00082 char * node = 0;
00083 int nodelen = 0;
00084 char * devstr;
00085 int devstrlen;
00086 if ((sts&1)==1) {
00087 devstr=out;
00088 devstrlen=outlen;
00089 devstrlen=strlen(out);
00090 } else {
00091 devstr=s->dsc_a_pointer;
00092 devstrlen=s->dsc_w_length;
00093 }
00094 char * device = strchr(devstr,'_');
00095 if (device>=(devstr+devstrlen))
00096 device=0;
00097 if (device) {
00098 node=devstr;
00099 nodelen=device-node;
00100 device++;
00101 } else {
00102 device=devstr;
00103 }
00104 {
00105
00106 int i;
00107 for(i=0;i<3;i++) {
00108 if (device[i]>='A' && device[i]<='Z') device[i]|=0x20;
00109 }
00110 }
00111
00112 do {
00113
00114 struct _sb * sb=d->ddb_ps_sb;
00115 if ((node==0) && sb)
00116 goto next;
00117 if (node && (sb==0))
00118 goto next;
00119 if (sb && 0!=strncmp(&sb->sb_t_nodename[1],node,nodelen))
00120 goto next;
00121 if (!memcmp(&d->ddb_t_name[1],device,3)) {
00122 struct _ucb * tmp = d->ddb_ps_ucb;
00123 char * c=device;
00124 #if 1
00125 char unit=dsc_strtol(&c[3], devstrlen-3-(device-devstr), 0, 10);
00126
00127 #else
00128 char unit=c[3]-48;
00129 #endif
00130 do {
00131
00132 if (unit==tmp->ucb_w_unit)
00133 goto out;
00134 tmp=tmp->ucb_l_link;
00135 } while (tmp && tmp!=d->ddb_ps_ucb);
00136 return SS__NOSUCHDEV;
00137 out:
00138 r->val1=tmp;
00139 return SS__NORMAL;
00140
00141
00142 }
00143 next:
00144 d=d->ddb_ps_link;
00145 } while (d && d!=ioc_gl_devlist);
00146 return SS__NOSUCHDEV;
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 int ioc_verify_chan(unsigned short int chan, struct _ccb ** ccbp) {
00156 struct _ccb * ccb=&ctl_gl_ccbbase[chan];
00157
00158
00159 if (ccb->ccb_b_amod==1) {
00160 *ccbp=ccb;
00161 return SS__NORMAL;
00162 } else
00163 return 0;
00164 }
00165
00166
00167
00168
00169
00170 int ioc_std_trandevnam (void * descr_p, int flags, char *buf, int *outlen, void **out_p) {
00171 #if 0
00172 int sts;
00173 _DESCRIPTOR(mytabnam_, "LNM$SYSTEM_TABLE");
00174 struct dsc_descriptor * mytabnam = &mytabnam_;
00175 _DESCRIPTOR(mytabnam2_, "LNM$PROCESS_TABLE");
00176 struct dsc_descriptor * mytabnam2 = &mytabnam2_;
00177 struct item_list_3 itm[2];
00178 itm[0].item_code=LNM__STRING;
00179 itm[0].buflen=4;
00180 itm[0].retlenaddr=outlen;
00181 itm[0].bufaddr=buf;
00182 memset(&itm[1],0,sizeof(struct item_list_3));
00183 *out_p=buf;
00184 struct dsc_descriptor * d = descr_p, descr;
00185 descr.dsc_a_pointer=d->dsc$a_pointer;
00186 char * c = strchr(d->dsc_a_pointer,':');
00187 if (c)
00188 descr.dsc_w_length=(long)c-(long)d->dsc$a_pointer;
00189 else
00190 descr.dsc_w_length=d->dsc$w_length;
00191 descr_p=&descr;
00192 sts=exe_trnlnm(0,mytabnam,descr_p,0,itm);
00193 if (sts&1)
00194 return sts;
00195 sts=exe_trnlnm(0,mytabnam2,descr_p,0,itm);
00196 return sts;
00197 #else
00198 int sts;
00199 _DESCRIPTOR(mytabnam_, "LNM$SYSTEM_TABLE");
00200 struct dsc_descriptor * mytabnam = &mytabnam_;
00201 _DESCRIPTOR(mytabnam2_, "LNM$PROCESS_TABLE");
00202 struct dsc_descriptor * mytabnam2 = &mytabnam2_;
00203 *out_p=buf;
00204 struct dsc_descriptor * d = descr_p, descr;
00205 descr.dsc_a_pointer=d->dsc$a_pointer;
00206 char * c = strchr(d->dsc_a_pointer,':');
00207 if (c)
00208 descr.dsc_w_length=(long)c-(long)d->dsc$a_pointer;
00209 else
00210 descr.dsc_w_length=d->dsc$w_length;
00211 descr_p=&descr;
00212 struct dsc_descriptor * descr_p2 = descr_p;
00213 struct struct_lnm_ret ret={0,0};
00214 sts=lnm_searchlog(&ret,descr_p2->dsc$w_length,descr_p2->dsc$a_pointer,mytabnam->dsc$w_length,mytabnam->dsc$a_pointer);
00215 if (sts&1)
00216 goto found;
00217 sts=lnm_searchlog(&ret,descr_p2->dsc$w_length,descr_p2->dsc$a_pointer,mytabnam2->dsc$w_length,mytabnam2->dsc$a_pointer);
00218 if ((sts&1)==0)
00219 return sts;
00220 found:
00221 *outlen=(ret.mylnmb)->lnmb_l_lnmx->lnmx$l_xlen;
00222 memcpy(buf,(ret.mylnmb)->lnmb_l_lnmx->lnmx$t_xlation,*outlen);
00223 return sts;
00224 #endif
00225
00226 }
00227
00228 int ioc_std_search (void * descr_p, int flags, void *lock_val_p, struct _ucb **ucb_p, struct _ddb **ddb_p, struct _sb **sb_p) {
00229
00230 }
00231
00232 int ioc_std_searchdev (void * descr_p, struct _ucb **ucb_p, struct _ddb **ddb_p, struct _sb **sb_p) {
00233
00234 }
00235
00236