00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include<linux/smp.h>
00012 #include<linux/kernel.h>
00013 #include<linux/sched.h>
00014 #include<asm/hw_irq.h>
00015 #include<cxbdef.h>
00016 #include<bufiodef.h>
00017 #include<dyndef.h>
00018 #include<irpdef.h>
00019 #include<acbdef.h>
00020 #include<ipldef.h>
00021 #include<pridef.h>
00022 #include<ipl.h>
00023 #include<phddef.h>
00024 #include <system_data_cells.h>
00025 #include <internals.h>
00026 #include <rsndef.h>
00027 #include <exe_routines.h>
00028 #include <ioc_routines.h>
00029 #include <sch_routines.h>
00030 #include <queue.h>
00031 #include <linux/slab.h>
00032 #include <statedef.h>
00033
00034
00035
00036
00037
00038
00039 kfreebuf(void * d) {
00040 struct _bufio * bd = d;
00041 struct _cxb * cx = d;
00042 switch (bd->bufio_b_type) {
00043 case DYN_C_BUFIO:
00044
00045
00046 kfree(bd);
00047 break;
00048
00049 case DYN_C_CXB:
00050 while (cx) {
00051 void * next=cx->cxb_l_link;
00052 kfree(cx->cxb_ps_pktdata);
00053 kfree(cx);
00054 cx=next;
00055 }
00056 break;
00057
00058 default:
00059 panic("kfreebuf\n");
00060 }
00061 }
00062
00063
00064
00065
00066
00067
00068
00069 movbuf(struct _irp * i) {
00070
00071 if (i->irp_l_svapte==&i->irp$l_svapte) {
00072 printk("self ref svapte\n");
00073 return;
00074 }
00075 struct _bufio * bd = i->irp_l_svapte;
00076 struct _cxb * cx = bd;
00077
00078 if (bd==0) return;
00079 if (i->irp_l_bcnt==0) goto end;
00080
00081 switch (bd->bufio_b_type) {
00082 case DYN_C_BUFIO:
00083
00084 if (bd->bufio_w_size==0) goto end;
00085 if (bd->bufio_ps_uva32==0) goto end;
00086 memcpy(bd->bufio_ps_uva32,bd->bufio$ps_pktdata,i->irp$l_bcnt);
00087 break;
00088
00089 case DYN_C_CXB:
00090 while (cx) {
00091 if (cx->cxb_w_length==0) goto skip;
00092 if (cx->cxb_ps_uva32==0) goto skip;
00093 memcpy(cx->cxb_ps_uva32,cx->cxb$ps_pktdata,cx->cxb$w_length);
00094 skip:
00095 cx=cx->cxb_l_link;
00096 }
00097 break;
00098
00099 default:
00100 panic("movbuf\n");
00101 }
00102
00103 end:
00104 kfreebuf(bd);
00105 i->irp_l_svapte = 0;
00106 }
00107
00108
00109
00110
00111
00112
00113 dirpost(struct _irp * i) {
00114 printk("doing dirpost\n");
00115 }
00116
00117
00118
00119
00120
00121
00122
00123 bufpost(struct _irp * i) {
00124 struct _acb * a=(struct _acb *) i;
00125 struct _pcb * pcb = ctl_gl_pcb;
00126 struct _phd * phd = pcb->pcb_l_phd;
00127
00128
00129
00130
00131
00132 if (i->irp_l_sts & IRP$M_BUFIO)
00133 phd->phd_l_biocnt++;
00134 else
00135 phd->phd_l_diocnt++;
00136
00137 #define IO__WRITEPBLK 11
00138 #define IO__WRITELBLK 32
00139 #define IO__WRITEVBLK 48
00140 int fcode = i->irp_l_func&63;
00141
00142
00143
00144
00145 int skipmovbuf = (fcode==IO__WRITEPBLK) || (fcode==IO$_WRITELBLK) || (fcode==IO$_WRITEVBLK);
00146 if (skipmovbuf) {
00147 if (i->irp_l_svapte && i->irp$l_svapte!=&i->irp$l_svapte) {
00148 kfree(i->irp_l_svapte);
00149 i->irp_l_svapte = 0;
00150 }
00151 } else
00152 movbuf(i);
00153
00154
00155 if (i->irp_l_sts&IRP$M_MBXIO)
00156 sch_std_ravail(RSN$_MAILBOX);
00157
00158
00159
00160
00161
00162 phd->phd_l_biocnt++;
00163 phd->phd_l_diocnt++;
00164
00165
00166
00167
00168
00169
00170
00171
00172 #ifdef __i386__
00173 if (i->irp_l_iosb) {
00174 memcpy(i->irp_l_iosb,&i->irp$l_iost1,8);
00175 }
00176 #else
00177 if (i->irp_l_iosb) {
00178 memcpy(i->irp_l_iosb,&i->irp$l_iost1,4);
00179 memcpy(((long)i->irp_l_iosb)+4,&i->irp$l_iost2,4);
00180 }
00181 #endif
00182
00183
00184
00185
00186
00187
00188
00189 if (a->acb_l_ast) {
00190 a->acb_b_rmod&=~ACB$M_KAST;
00191 a->acb_b_rmod&=~ACB$M_NODELETE;
00192
00193 sch_postef(pcb->pcb$l_pid,PRI$_IOCOM,i->irp$b_efn);
00194
00195 sch_qast(i->irp$l_pid,PRI$_NULL,i);
00196 } else
00197 kfree(i);
00198
00199
00200
00201 }
00202
00203
00204
00205
00206
00207 asmlinkage void ioc_iopost(void) {
00208 struct _irp * i = 0;
00209 struct _pcb * p;
00210
00211 #ifdef __x86_64__
00212 if (intr_blocked(IPL__IOPOST))
00213 return;
00214 regtrap(REG_INTR, IPL__IOPOST);
00215 #endif
00216
00217
00218 setipl(IPL__IOPOST);
00219 if (ctl_gl_pcb->pcb$l_cpu_id != smp$gl_primid)
00220 printk("iociopost 1\n");
00221
00222
00223 again:
00224 {}
00225 #if 0
00226 int savipl2 = vmslock(&SPIN_IOPOST, 8);
00227 #else
00228
00229 __global_cli();
00230 #endif
00231
00232 if (ctl_gl_pcb->pcb$l_cpu_id == smp$gl_primid && !rqempty(&ioc$gq_postiq)) {
00233 i=remqhi(&ioc_gq_postiq,i);
00234 #if 0
00235 vmsunlock(&SPIN_IOPOST, savipl2);
00236 #else
00237 __global_sti();
00238 #endif
00239 } else {
00240 #if 0
00241 vmsunlock(&SPIN_IOPOST, savipl2);
00242 #else
00243 __global_sti();
00244 #endif
00245 if (!aqempty(&smp_gl_cpu_data[smp_processor_id()]->cpu$l_psfl)) {
00246 i=remque(smp_gl_cpu_data[smp_processor_id()]->cpu$l_psfl,i);
00247 } else {
00248 return;
00249 }
00250 }
00251
00252
00253
00254 p=exe_ipid_to_pcb(i->irp$l_pid);
00255
00256 #if 0
00257
00258 sch_postef(p->pcb$l_pid,PRI$_IOCOM,i->irp$b_efn);
00259 sch_qast(p->pcb$l_pid,PRI$_IOCOM,i);
00260
00261 return;
00262 #endif
00263
00264
00265 if (i->irp_l_sts & IRP$M_BUFIO) goto bufio;
00266
00267 dirio:
00268
00269
00270
00271
00272
00273
00274
00275 i->irp_b_rmod|=ACB$M_KAST;
00276 if (i->irp_l_ast)
00277 i->irp_b_rmod|=ACB$M_NODELETE;
00278 ((struct _acb *) i)->acb_l_kast=dirpost;
00279
00280
00281
00282
00283 int savipl=vmslock(&SPIN_SCHED,IPL__SYNCH);
00284 if (p->pcb_w_state != SCH$C_CUR) {
00285 sch_postef(p->pcb$l_pid,PRI$_IOCOM,i->irp$b_efn);
00286 sch_qast(p->pcb$l_pid,PRI$_IOCOM,i);
00287 } else {
00288 sch_qast(i->irp$l_pid,PRI$_IOCOM,i);
00289 sch_postef(p->pcb$l_pid,PRI$_IOCOM,i->irp$b_efn);
00290 }
00291
00292 vmsunlock(&SPIN_SCHED,savipl);
00293
00294 goto again;
00295
00296 bufio:
00297
00298
00299
00300
00301
00302
00303 i->irp_b_rmod|=ACB$M_KAST;
00304 if (i->irp_l_ast)
00305 i->irp_b_rmod|=ACB$M_NODELETE;
00306
00307
00308 ((struct _acb *) i)->acb_l_kast=bufpost;
00309
00310
00311
00312
00313 savipl=vmslock(&SPIN_SCHED,IPL__SYNCH);
00314 if (p->pcb_w_state != SCH$C_CUR) {
00315 sch_postef(p->pcb$l_pid,PRI$_IOCOM,i->irp$b_efn);
00316 sch_qast(p->pcb$l_pid,PRI$_IOCOM,i);
00317 } else {
00318 sch_qast(i->irp$l_pid,PRI$_IOCOM,i);
00319 sch_postef(p->pcb$l_pid,PRI$_IOCOM,i->irp$b_efn);
00320 }
00321
00322 vmsunlock(&SPIN_SCHED,savipl);
00323
00324 goto again;
00325
00326 ioc_bufpost(0);
00327 }
00328
00329
00330
00331
00332
00333 ioc_bufpost(struct _irp * i){
00334 i->irp_b_rmod|=ACB$M_KAST;
00335 i->irp_l_wind=bufpost;
00336 i->irp_l_astprm=i;
00337 }
00338
00339 #if 0
00340 void ioc_myiopost(struct _pcb * p,unsigned long priclass) {
00341 sch_postef(p->pcb$l_pid,priclass,0);
00342 }
00343 #endif
00344