00001 // _Id: sysassign.c,v 1.19 2009-05-09 13:31:09 roart Exp $ 00002 // _Locker: $ 00003 00004 // Author. Roar Thronęs. 00005 /** 00006 \file sysassign.c 00007 \brief QIO assign channel - TODO still more doc 00008 \author Roar Thronęs 00009 */ 00010 00011 #include<linux/config.h> 00012 00013 #include<starlet.h> 00014 #include<iodef.h> 00015 #include<ssdef.h> 00016 #include<misc.h> 00017 #include<irpdef.h> 00018 #include<ucbdef.h> 00019 #include<ccbdef.h> 00020 #include <ddtdef.h> 00021 #include<system_data_cells.h> 00022 #include <ioc_routines.h> 00023 #include<linux/linkage.h> 00024 #include <sch_routines.h> 00025 #include <ioc_routines.h> 00026 00027 #include <descrip.h> 00028 00029 #include <ipl.h> 00030 00031 /** 00032 \brief assign i/o channel system service - see 5.2 21.5.2 00033 \param devnam device name 00034 \param chan return channel value 00035 \param acmode access mode 00036 \param mbxnam mailbox name 00037 \param flags misc flags - TODO not yet used 00038 */ 00039 00040 asmlinkage int exe_assign(void *devnam, unsigned short int *chan,unsigned int acmode, void *mbxnam, int flags) { 00041 /** 21.5.2.1 */ 00042 int status; 00043 /** probe chan writeable - MISSING */ 00044 /** probe mbxnam readable - MISSING */ 00045 /** probe devnam readable - MISSING */ 00046 /** handle acmode - MISSING */ 00047 struct _ccb * c; 00048 struct _ucb * u; 00049 struct _ddb * d; 00050 struct return_values r,r2={0,0}; 00051 // printk("here assign\n"); 00052 /** lock i/o db */ 00053 sch_iolockw(); // moved up because of global db 00054 /** find free channel */ 00055 status=ioc_ffchan(chan); 00056 /** if error return */ 00057 /** TODO maybe also unlock i/o db */ 00058 if (status!=SS__NORMAL) return status; 00059 /* lock i/o db */ 00060 // sch_iolockw(); 00061 // printk("here assign %x\n", chan); 00062 c=&ctl_gl_ccbbase[*chan]; 00063 c->ccb_b_amod=1; /* wherever this gets set */ 00064 // printk("here assign\n"); 00065 /** search for an eventual mbxnam */ 00066 if (mbxnam) ioc_searchdev(&r2,mbxnam); 00067 /** search for devnam */ 00068 status=ioc_search(&r,devnam); 00069 //printk("here assign\n"); 00070 /** if error unlock i/o db and return */ 00071 if (status!=SS__NORMAL) { 00072 sch_iounlock(); 00073 return status; 00074 } 00075 u=r.val1; 00076 00077 u->ucb_l_amb=r2.val1; // maybe set associated mb someplace? 00078 00079 /* not yet? 00080 c=vmalloc(sizeof(struct _ccb)); 00081 bzero(c,sizeof(struct _ccb)); 00082 */ 00083 00084 /** 21.5.2.2 */ 00085 00086 if (u->ucb_l_sts&UCB$M_TEMPLATE) { 00087 /** if network dev, test for NETMBX priv - MISSING */ 00088 /** ucb quota check - MISSING */ 00089 struct _ucb * new; 00090 struct _ddt * ddt=u->ucb_l_ddt; 00091 /** invoke ucb cloning */ 00092 int sts=ioc_std_clone_ucb(u, &new); 00093 /** store uic in its orb - MISSING */ 00094 /** set deleteucb bit - MISSING */ 00095 /** if template is a mailbox, set delmbx - MISSING */ 00096 /** clear refc - MISSING */ 00097 /** invoke ioc_debit_ucb - MISSING */ 00098 u=new; 00099 printk("ucb cloned in assign %x\n",ddt->ddt_l_cloneducb); 00100 if (ddt->ddt_l_cloneducb) { 00101 int (*fn)() = ddt->ddt_l_cloneducb; 00102 /** invoke ddt cloneucb routine */ 00103 fn(u); 00104 /** handle error return - MISSING */ 00105 /** if nonshared device set ucb pid - MISSING */ 00106 /** 21.5.2.2.3 associated mbx processing - MISSING */ 00107 } 00108 } 00109 00110 /** 21.5.2.2.4 local device final processing */ 00111 00112 /** if appropiate, invoke ioc_lock_dev - MISSING */ 00113 00114 /** if nonshared and nonowned, set pid - MISSING */ 00115 00116 /** set ccb ucb */ 00117 c->ccb_l_ucb=u; 00118 00119 /** increase ucb ref count */ 00120 c->ccb_l_ucb->ucb$l_refc++; 00121 00122 /** set ccb amod - MISSING */ 00123 00124 /** set ccb sts - MISSING */ 00125 00126 /** chan was previously written */ 00127 00128 /** unlock i/o db and return normal? */ 00129 sch_iounlock(); 00130 setipl(0); // simulate rei 00131 return status; 00132 00133 /** 21.5.2.3 assign non-local - MISSING */ 00134 /** it might have worked once, but clustering etc is non-working now */ 00135 } 00136 00137 00138