iucv.c 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549
  1. /*
  2. * IUCV network driver
  3. *
  4. * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
  5. * Author(s):
  6. * Original source:
  7. * Alan Altmark (Alan_Altmark@us.ibm.com) Sept. 2000
  8. * Xenia Tkatschow (xenia@us.ibm.com)
  9. * 2Gb awareness and general cleanup:
  10. * Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
  11. *
  12. * Documentation used:
  13. * The original source
  14. * CP Programming Service, IBM document # SC24-5760
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 2, or (at your option)
  19. * any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. *
  30. */
  31. /* #define DEBUG */
  32. #include <linux/module.h>
  33. #include <linux/moduleparam.h>
  34. #include <linux/config.h>
  35. #include <linux/spinlock.h>
  36. #include <linux/kernel.h>
  37. #include <linux/slab.h>
  38. #include <linux/init.h>
  39. #include <linux/interrupt.h>
  40. #include <linux/list.h>
  41. #include <linux/errno.h>
  42. #include <linux/err.h>
  43. #include <linux/device.h>
  44. #include <asm/atomic.h>
  45. #include "iucv.h"
  46. #include <asm/io.h>
  47. #include <asm/s390_ext.h>
  48. #include <asm/ebcdic.h>
  49. #include <asm/smp.h>
  50. #include <asm/s390_rdev.h>
  51. /* FLAGS:
  52. * All flags are defined in the field IPFLAGS1 of each function
  53. * and can be found in CP Programming Services.
  54. * IPSRCCLS - Indicates you have specified a source class
  55. * IPFGMCL - Indicates you have specified a target class
  56. * IPFGPID - Indicates you have specified a pathid
  57. * IPFGMID - Indicates you have specified a message ID
  58. * IPANSLST - Indicates that you are using an address list for
  59. * reply data
  60. * IPBUFLST - Indicates that you are using an address list for
  61. * message data
  62. */
  63. #define IPSRCCLS 0x01
  64. #define IPFGMCL 0x01
  65. #define IPFGPID 0x02
  66. #define IPFGMID 0x04
  67. #define IPANSLST 0x08
  68. #define IPBUFLST 0x40
  69. static int
  70. iucv_bus_match (struct device *dev, struct device_driver *drv)
  71. {
  72. return 0;
  73. }
  74. struct bus_type iucv_bus = {
  75. .name = "iucv",
  76. .match = iucv_bus_match,
  77. };
  78. struct device *iucv_root;
  79. /* General IUCV interrupt structure */
  80. typedef struct {
  81. __u16 ippathid;
  82. __u8 res1;
  83. __u8 iptype;
  84. __u32 res2;
  85. __u8 ipvmid[8];
  86. __u8 res3[24];
  87. } iucv_GeneralInterrupt;
  88. static iucv_GeneralInterrupt *iucv_external_int_buffer = NULL;
  89. /* Spin Lock declaration */
  90. static DEFINE_SPINLOCK(iucv_lock);
  91. static int messagesDisabled = 0;
  92. /***************INTERRUPT HANDLING ***************/
  93. typedef struct {
  94. struct list_head queue;
  95. iucv_GeneralInterrupt data;
  96. } iucv_irqdata;
  97. static struct list_head iucv_irq_queue;
  98. static DEFINE_SPINLOCK(iucv_irq_queue_lock);
  99. /*
  100. *Internal function prototypes
  101. */
  102. static void iucv_tasklet_handler(unsigned long);
  103. static void iucv_irq_handler(struct pt_regs *, __u16);
  104. static DECLARE_TASKLET(iucv_tasklet,iucv_tasklet_handler,0);
  105. /************ FUNCTION ID'S ****************************/
  106. #define ACCEPT 10
  107. #define CONNECT 11
  108. #define DECLARE_BUFFER 12
  109. #define PURGE 9
  110. #define QUERY 0
  111. #define QUIESCE 13
  112. #define RECEIVE 5
  113. #define REJECT 8
  114. #define REPLY 6
  115. #define RESUME 14
  116. #define RETRIEVE_BUFFER 2
  117. #define SEND 4
  118. #define SETMASK 16
  119. #define SEVER 15
  120. /**
  121. * Structure: handler
  122. * members: list - list management.
  123. * structure: id
  124. * userid - 8 char array of machine identification
  125. * user_data - 16 char array for user identification
  126. * mask - 24 char array used to compare the 2 previous
  127. * interrupt_table - vector of interrupt functions.
  128. * pgm_data - ulong, application data that is passed
  129. * to the interrupt handlers
  130. */
  131. typedef struct handler_t {
  132. struct list_head list;
  133. struct {
  134. __u8 userid[8];
  135. __u8 user_data[16];
  136. __u8 mask[24];
  137. } id;
  138. iucv_interrupt_ops_t *interrupt_table;
  139. void *pgm_data;
  140. } handler;
  141. /**
  142. * iucv_handler_table: List of registered handlers.
  143. */
  144. static struct list_head iucv_handler_table;
  145. /**
  146. * iucv_pathid_table: an array of *handler pointing into
  147. * iucv_handler_table for fast indexing by pathid;
  148. */
  149. static handler **iucv_pathid_table;
  150. static unsigned long max_connections;
  151. /**
  152. * iucv_cpuid: contains the logical cpu number of the cpu which
  153. * has declared the iucv buffer by issuing DECLARE_BUFFER.
  154. * If no cpu has done the initialization iucv_cpuid contains -1.
  155. */
  156. static int iucv_cpuid = -1;
  157. /**
  158. * register_flag: is 0 when external interrupt has not been registered
  159. */
  160. static int register_flag;
  161. /****************FIVE 40-BYTE PARAMETER STRUCTURES******************/
  162. /* Data struct 1: iparml_control
  163. * Used for iucv_accept
  164. * iucv_connect
  165. * iucv_quiesce
  166. * iucv_resume
  167. * iucv_sever
  168. * iucv_retrieve_buffer
  169. * Data struct 2: iparml_dpl (data in parameter list)
  170. * Used for iucv_send_prmmsg
  171. * iucv_send2way_prmmsg
  172. * iucv_send2way_prmmsg_array
  173. * iucv_reply_prmmsg
  174. * Data struct 3: iparml_db (data in a buffer)
  175. * Used for iucv_receive
  176. * iucv_receive_array
  177. * iucv_reject
  178. * iucv_reply
  179. * iucv_reply_array
  180. * iucv_send
  181. * iucv_send_array
  182. * iucv_send2way
  183. * iucv_send2way_array
  184. * iucv_declare_buffer
  185. * Data struct 4: iparml_purge
  186. * Used for iucv_purge
  187. * iucv_query
  188. * Data struct 5: iparml_set_mask
  189. * Used for iucv_set_mask
  190. */
  191. typedef struct {
  192. __u16 ippathid;
  193. __u8 ipflags1;
  194. __u8 iprcode;
  195. __u16 ipmsglim;
  196. __u16 res1;
  197. __u8 ipvmid[8];
  198. __u8 ipuser[16];
  199. __u8 iptarget[8];
  200. } iparml_control;
  201. typedef struct {
  202. __u16 ippathid;
  203. __u8 ipflags1;
  204. __u8 iprcode;
  205. __u32 ipmsgid;
  206. __u32 iptrgcls;
  207. __u8 iprmmsg[8];
  208. __u32 ipsrccls;
  209. __u32 ipmsgtag;
  210. __u32 ipbfadr2;
  211. __u32 ipbfln2f;
  212. __u32 res;
  213. } iparml_dpl;
  214. typedef struct {
  215. __u16 ippathid;
  216. __u8 ipflags1;
  217. __u8 iprcode;
  218. __u32 ipmsgid;
  219. __u32 iptrgcls;
  220. __u32 ipbfadr1;
  221. __u32 ipbfln1f;
  222. __u32 ipsrccls;
  223. __u32 ipmsgtag;
  224. __u32 ipbfadr2;
  225. __u32 ipbfln2f;
  226. __u32 res;
  227. } iparml_db;
  228. typedef struct {
  229. __u16 ippathid;
  230. __u8 ipflags1;
  231. __u8 iprcode;
  232. __u32 ipmsgid;
  233. __u8 ipaudit[3];
  234. __u8 res1[5];
  235. __u32 res2;
  236. __u32 ipsrccls;
  237. __u32 ipmsgtag;
  238. __u32 res3[3];
  239. } iparml_purge;
  240. typedef struct {
  241. __u8 ipmask;
  242. __u8 res1[2];
  243. __u8 iprcode;
  244. __u32 res2[9];
  245. } iparml_set_mask;
  246. typedef struct {
  247. union {
  248. iparml_control p_ctrl;
  249. iparml_dpl p_dpl;
  250. iparml_db p_db;
  251. iparml_purge p_purge;
  252. iparml_set_mask p_set_mask;
  253. } param;
  254. atomic_t in_use;
  255. __u32 res;
  256. } __attribute__ ((aligned(8))) iucv_param;
  257. #define PARAM_POOL_SIZE (PAGE_SIZE / sizeof(iucv_param))
  258. static iucv_param * iucv_param_pool;
  259. MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
  260. MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
  261. MODULE_LICENSE("GPL");
  262. /*
  263. * Debugging stuff
  264. *******************************************************************************/
  265. #ifdef DEBUG
  266. static int debuglevel = 0;
  267. module_param(debuglevel, int, 0);
  268. MODULE_PARM_DESC(debuglevel,
  269. "Specifies the debug level (0=off ... 3=all)");
  270. static void
  271. iucv_dumpit(char *title, void *buf, int len)
  272. {
  273. int i;
  274. __u8 *p = (__u8 *)buf;
  275. if (debuglevel < 3)
  276. return;
  277. printk(KERN_DEBUG "%s\n", title);
  278. printk(" ");
  279. for (i = 0; i < len; i++) {
  280. if (!(i % 16) && i != 0)
  281. printk ("\n ");
  282. else if (!(i % 4) && i != 0)
  283. printk(" ");
  284. printk("%02X", *p++);
  285. }
  286. if (len % 16)
  287. printk ("\n");
  288. return;
  289. }
  290. #define iucv_debug(lvl, fmt, args...) \
  291. do { \
  292. if (debuglevel >= lvl) \
  293. printk(KERN_DEBUG "%s: " fmt "\n", __FUNCTION__ , ## args); \
  294. } while (0)
  295. #else
  296. #define iucv_debug(lvl, fmt, args...)
  297. #define iucv_dumpit(title, buf, len)
  298. #endif
  299. /*
  300. * Internal functions
  301. *******************************************************************************/
  302. /**
  303. * print start banner
  304. */
  305. static void
  306. iucv_banner(void)
  307. {
  308. printk(KERN_INFO "IUCV lowlevel driver initialized\n");
  309. }
  310. /**
  311. * iucv_init - Initialization
  312. *
  313. * Allocates and initializes various data structures.
  314. */
  315. static int
  316. iucv_init(void)
  317. {
  318. int ret;
  319. if (iucv_external_int_buffer)
  320. return 0;
  321. if (!MACHINE_IS_VM) {
  322. printk(KERN_ERR "IUCV: IUCV connection needs VM as base\n");
  323. return -EPROTONOSUPPORT;
  324. }
  325. ret = bus_register(&iucv_bus);
  326. if (ret) {
  327. printk(KERN_ERR "IUCV: failed to register bus.\n");
  328. return ret;
  329. }
  330. iucv_root = s390_root_dev_register("iucv");
  331. if (IS_ERR(iucv_root)) {
  332. printk(KERN_ERR "IUCV: failed to register iucv root.\n");
  333. bus_unregister(&iucv_bus);
  334. return PTR_ERR(iucv_root);
  335. }
  336. /* Note: GFP_DMA used used to get memory below 2G */
  337. iucv_external_int_buffer = kmalloc(sizeof(iucv_GeneralInterrupt),
  338. GFP_KERNEL|GFP_DMA);
  339. if (!iucv_external_int_buffer) {
  340. printk(KERN_WARNING
  341. "%s: Could not allocate external interrupt buffer\n",
  342. __FUNCTION__);
  343. s390_root_dev_unregister(iucv_root);
  344. bus_unregister(&iucv_bus);
  345. return -ENOMEM;
  346. }
  347. memset(iucv_external_int_buffer, 0, sizeof(iucv_GeneralInterrupt));
  348. /* Initialize parameter pool */
  349. iucv_param_pool = kmalloc(sizeof(iucv_param) * PARAM_POOL_SIZE,
  350. GFP_KERNEL|GFP_DMA);
  351. if (!iucv_param_pool) {
  352. printk(KERN_WARNING "%s: Could not allocate param pool\n",
  353. __FUNCTION__);
  354. kfree(iucv_external_int_buffer);
  355. iucv_external_int_buffer = NULL;
  356. s390_root_dev_unregister(iucv_root);
  357. bus_unregister(&iucv_bus);
  358. return -ENOMEM;
  359. }
  360. memset(iucv_param_pool, 0, sizeof(iucv_param) * PARAM_POOL_SIZE);
  361. /* Initialize irq queue */
  362. INIT_LIST_HEAD(&iucv_irq_queue);
  363. /* Initialize handler table */
  364. INIT_LIST_HEAD(&iucv_handler_table);
  365. iucv_banner();
  366. return 0;
  367. }
  368. /**
  369. * iucv_exit - De-Initialization
  370. *
  371. * Frees everything allocated from iucv_init.
  372. */
  373. static int iucv_retrieve_buffer (void);
  374. static void
  375. iucv_exit(void)
  376. {
  377. iucv_retrieve_buffer();
  378. kfree(iucv_external_int_buffer);
  379. iucv_external_int_buffer = NULL;
  380. kfree(iucv_param_pool);
  381. iucv_param_pool = NULL;
  382. s390_root_dev_unregister(iucv_root);
  383. bus_unregister(&iucv_bus);
  384. printk(KERN_INFO "IUCV lowlevel driver unloaded\n");
  385. }
  386. /**
  387. * grab_param: - Get a parameter buffer from the pre-allocated pool.
  388. *
  389. * This function searches for an unused element in the pre-allocated pool
  390. * of parameter buffers. If one is found, it marks it "in use" and returns
  391. * a pointer to it. The calling function is responsible for releasing it
  392. * when it has finished its usage.
  393. *
  394. * Returns: A pointer to iucv_param.
  395. */
  396. static __inline__ iucv_param *
  397. grab_param(void)
  398. {
  399. iucv_param *ptr;
  400. static int hint = 0;
  401. ptr = iucv_param_pool + hint;
  402. do {
  403. ptr++;
  404. if (ptr >= iucv_param_pool + PARAM_POOL_SIZE)
  405. ptr = iucv_param_pool;
  406. } while (atomic_cmpxchg(&ptr->in_use, 0, 1) != 0);
  407. hint = ptr - iucv_param_pool;
  408. memset(&ptr->param, 0, sizeof(ptr->param));
  409. return ptr;
  410. }
  411. /**
  412. * release_param - Release a parameter buffer.
  413. * @p: A pointer to a struct iucv_param, previously obtained by calling
  414. * grab_param().
  415. *
  416. * This function marks the specified parameter buffer "unused".
  417. */
  418. static __inline__ void
  419. release_param(void *p)
  420. {
  421. atomic_set(&((iucv_param *)p)->in_use, 0);
  422. }
  423. /**
  424. * iucv_add_handler: - Add a new handler
  425. * @new_handler: handle that is being entered into chain.
  426. *
  427. * Places new handle on iucv_handler_table, if identical handler is not
  428. * found.
  429. *
  430. * Returns: 0 on success, !0 on failure (handler already in chain).
  431. */
  432. static int
  433. iucv_add_handler (handler *new)
  434. {
  435. ulong flags;
  436. iucv_debug(1, "entering");
  437. iucv_dumpit("handler:", new, sizeof(handler));
  438. spin_lock_irqsave (&iucv_lock, flags);
  439. if (!list_empty(&iucv_handler_table)) {
  440. struct list_head *lh;
  441. /**
  442. * Search list for handler with identical id. If one
  443. * is found, the new handler is _not_ added.
  444. */
  445. list_for_each(lh, &iucv_handler_table) {
  446. handler *h = list_entry(lh, handler, list);
  447. if (!memcmp(&new->id, &h->id, sizeof(h->id))) {
  448. iucv_debug(1, "ret 1");
  449. spin_unlock_irqrestore (&iucv_lock, flags);
  450. return 1;
  451. }
  452. }
  453. }
  454. /**
  455. * If we get here, no handler was found.
  456. */
  457. INIT_LIST_HEAD(&new->list);
  458. list_add(&new->list, &iucv_handler_table);
  459. spin_unlock_irqrestore (&iucv_lock, flags);
  460. iucv_debug(1, "exiting");
  461. return 0;
  462. }
  463. /**
  464. * b2f0:
  465. * @code: identifier of IUCV call to CP.
  466. * @parm: pointer to 40 byte iparml area passed to CP
  467. *
  468. * Calls CP to execute IUCV commands.
  469. *
  470. * Returns: return code from CP's IUCV call
  471. */
  472. static __inline__ ulong
  473. b2f0(__u32 code, void *parm)
  474. {
  475. iucv_dumpit("iparml before b2f0 call:", parm, sizeof(iucv_param));
  476. asm volatile (
  477. "LRA 1,0(%1)\n\t"
  478. "LR 0,%0\n\t"
  479. ".long 0xb2f01000"
  480. :
  481. : "d" (code), "a" (parm)
  482. : "0", "1"
  483. );
  484. iucv_dumpit("iparml after b2f0 call:", parm, sizeof(iucv_param));
  485. return (unsigned long)*((__u8 *)(parm + 3));
  486. }
  487. /*
  488. * Name: iucv_add_pathid
  489. * Purpose: Adds a path id to the system.
  490. * Input: pathid - pathid that is going to be entered into system
  491. * handle - address of handler that the pathid will be associated
  492. * with.
  493. * pgm_data - token passed in by application.
  494. * Output: 0: successful addition of pathid
  495. * - EINVAL - pathid entry is being used by another application
  496. * - ENOMEM - storage allocation for a new pathid table failed
  497. */
  498. static int
  499. __iucv_add_pathid(__u16 pathid, handler *handler)
  500. {
  501. iucv_debug(1, "entering");
  502. iucv_debug(1, "handler is pointing to %p", handler);
  503. if (pathid > (max_connections - 1))
  504. return -EINVAL;
  505. if (iucv_pathid_table[pathid]) {
  506. iucv_debug(1, "pathid entry is %p", iucv_pathid_table[pathid]);
  507. printk(KERN_WARNING
  508. "%s: Pathid being used, error.\n", __FUNCTION__);
  509. return -EINVAL;
  510. }
  511. iucv_pathid_table[pathid] = handler;
  512. iucv_debug(1, "exiting");
  513. return 0;
  514. } /* end of add_pathid function */
  515. static int
  516. iucv_add_pathid(__u16 pathid, handler *handler)
  517. {
  518. ulong flags;
  519. int rc;
  520. spin_lock_irqsave (&iucv_lock, flags);
  521. rc = __iucv_add_pathid(pathid, handler);
  522. spin_unlock_irqrestore (&iucv_lock, flags);
  523. return rc;
  524. }
  525. static void
  526. iucv_remove_pathid(__u16 pathid)
  527. {
  528. ulong flags;
  529. if (pathid > (max_connections - 1))
  530. return;
  531. spin_lock_irqsave (&iucv_lock, flags);
  532. iucv_pathid_table[pathid] = NULL;
  533. spin_unlock_irqrestore (&iucv_lock, flags);
  534. }
  535. /**
  536. * iucv_declare_buffer_cpuid
  537. * Register at VM for subsequent IUCV operations. This is executed
  538. * on the reserved CPU iucv_cpuid. Called from iucv_declare_buffer().
  539. */
  540. static void
  541. iucv_declare_buffer_cpuid (void *result)
  542. {
  543. iparml_db *parm;
  544. parm = (iparml_db *)grab_param();
  545. parm->ipbfadr1 = virt_to_phys(iucv_external_int_buffer);
  546. if ((*((ulong *)result) = b2f0(DECLARE_BUFFER, parm)) == 1)
  547. *((ulong *)result) = parm->iprcode;
  548. release_param(parm);
  549. }
  550. /**
  551. * iucv_retrieve_buffer_cpuid:
  552. * Unregister IUCV usage at VM. This is always executed on the same
  553. * cpu that registered the buffer to VM.
  554. * Called from iucv_retrieve_buffer().
  555. */
  556. static void
  557. iucv_retrieve_buffer_cpuid (void *cpu)
  558. {
  559. iparml_control *parm;
  560. parm = (iparml_control *)grab_param();
  561. b2f0(RETRIEVE_BUFFER, parm);
  562. release_param(parm);
  563. }
  564. /**
  565. * Name: iucv_declare_buffer
  566. * Purpose: Specifies the guests real address of an external
  567. * interrupt.
  568. * Input: void
  569. * Output: iprcode - return code from b2f0 call
  570. */
  571. static int
  572. iucv_declare_buffer (void)
  573. {
  574. unsigned long flags;
  575. ulong b2f0_result;
  576. iucv_debug(1, "entering");
  577. b2f0_result = -ENODEV;
  578. spin_lock_irqsave (&iucv_lock, flags);
  579. if (iucv_cpuid == -1) {
  580. /* Reserve any cpu for use by iucv. */
  581. iucv_cpuid = smp_get_cpu(CPU_MASK_ALL);
  582. spin_unlock_irqrestore (&iucv_lock, flags);
  583. smp_call_function_on(iucv_declare_buffer_cpuid,
  584. &b2f0_result, 0, 1, iucv_cpuid);
  585. if (b2f0_result) {
  586. smp_put_cpu(iucv_cpuid);
  587. iucv_cpuid = -1;
  588. }
  589. iucv_debug(1, "Address of EIB = %p", iucv_external_int_buffer);
  590. } else {
  591. spin_unlock_irqrestore (&iucv_lock, flags);
  592. b2f0_result = 0;
  593. }
  594. iucv_debug(1, "exiting");
  595. return b2f0_result;
  596. }
  597. /**
  598. * iucv_retrieve_buffer:
  599. *
  600. * Terminates all use of IUCV.
  601. * Returns: return code from CP
  602. */
  603. static int
  604. iucv_retrieve_buffer (void)
  605. {
  606. iucv_debug(1, "entering");
  607. if (iucv_cpuid != -1) {
  608. smp_call_function_on(iucv_retrieve_buffer_cpuid,
  609. 0, 0, 1, iucv_cpuid);
  610. /* Release the cpu reserved by iucv_declare_buffer. */
  611. smp_put_cpu(iucv_cpuid);
  612. iucv_cpuid = -1;
  613. }
  614. iucv_debug(1, "exiting");
  615. return 0;
  616. }
  617. /**
  618. * iucv_remove_handler:
  619. * @users_handler: handler to be removed
  620. *
  621. * Remove handler when application unregisters.
  622. */
  623. static void
  624. iucv_remove_handler(handler *handler)
  625. {
  626. unsigned long flags;
  627. if ((!iucv_pathid_table) || (!handler))
  628. return;
  629. iucv_debug(1, "entering");
  630. spin_lock_irqsave (&iucv_lock, flags);
  631. list_del(&handler->list);
  632. if (list_empty(&iucv_handler_table)) {
  633. if (register_flag) {
  634. unregister_external_interrupt(0x4000, iucv_irq_handler);
  635. register_flag = 0;
  636. }
  637. }
  638. spin_unlock_irqrestore (&iucv_lock, flags);
  639. iucv_debug(1, "exiting");
  640. return;
  641. }
  642. /**
  643. * iucv_register_program:
  644. * @pgmname: user identification
  645. * @userid: machine identification
  646. * @pgmmask: Indicates which bits in the pgmname and userid combined will be
  647. * used to determine who is given control.
  648. * @ops: Address of interrupt handler table.
  649. * @pgm_data: Application data to be passed to interrupt handlers.
  650. *
  651. * Registers an application with IUCV.
  652. * Returns:
  653. * The address of handler, or NULL on failure.
  654. * NOTE on pgmmask:
  655. * If pgmname, userid and pgmmask are provided, pgmmask is entered into the
  656. * handler as is.
  657. * If pgmmask is NULL, the internal mask is set to all 0xff's
  658. * When userid is NULL, the first 8 bytes of the internal mask are forced
  659. * to 0x00.
  660. * If pgmmask and userid are NULL, the first 8 bytes of the internal mask
  661. * are forced to 0x00 and the last 16 bytes to 0xff.
  662. */
  663. iucv_handle_t
  664. iucv_register_program (__u8 pgmname[16],
  665. __u8 userid[8],
  666. __u8 pgmmask[24],
  667. iucv_interrupt_ops_t * ops, void *pgm_data)
  668. {
  669. ulong rc = 0; /* return code from function calls */
  670. handler *new_handler;
  671. iucv_debug(1, "entering");
  672. if (ops == NULL) {
  673. /* interrupt table is not defined */
  674. printk(KERN_WARNING "%s: Interrupt table is not defined, "
  675. "exiting\n", __FUNCTION__);
  676. return NULL;
  677. }
  678. if (!pgmname) {
  679. printk(KERN_WARNING "%s: pgmname not provided\n", __FUNCTION__);
  680. return NULL;
  681. }
  682. /* Allocate handler entry */
  683. new_handler = (handler *)kmalloc(sizeof(handler), GFP_ATOMIC);
  684. if (new_handler == NULL) {
  685. printk(KERN_WARNING "%s: storage allocation for new handler "
  686. "failed.\n", __FUNCTION__);
  687. return NULL;
  688. }
  689. if (!iucv_pathid_table) {
  690. if (iucv_init()) {
  691. kfree(new_handler);
  692. return NULL;
  693. }
  694. max_connections = iucv_query_maxconn();
  695. iucv_pathid_table = kmalloc(max_connections * sizeof(handler *),
  696. GFP_ATOMIC);
  697. if (iucv_pathid_table == NULL) {
  698. printk(KERN_WARNING "%s: iucv_pathid_table storage "
  699. "allocation failed\n", __FUNCTION__);
  700. kfree(new_handler);
  701. return NULL;
  702. }
  703. memset (iucv_pathid_table, 0, max_connections * sizeof(handler *));
  704. }
  705. memset(new_handler, 0, sizeof (handler));
  706. memcpy(new_handler->id.user_data, pgmname,
  707. sizeof (new_handler->id.user_data));
  708. if (userid) {
  709. memcpy (new_handler->id.userid, userid,
  710. sizeof (new_handler->id.userid));
  711. ASCEBC (new_handler->id.userid,
  712. sizeof (new_handler->id.userid));
  713. EBC_TOUPPER (new_handler->id.userid,
  714. sizeof (new_handler->id.userid));
  715. if (pgmmask) {
  716. memcpy (new_handler->id.mask, pgmmask,
  717. sizeof (new_handler->id.mask));
  718. } else {
  719. memset (new_handler->id.mask, 0xFF,
  720. sizeof (new_handler->id.mask));
  721. }
  722. } else {
  723. if (pgmmask) {
  724. memcpy (new_handler->id.mask, pgmmask,
  725. sizeof (new_handler->id.mask));
  726. } else {
  727. memset (new_handler->id.mask, 0xFF,
  728. sizeof (new_handler->id.mask));
  729. }
  730. memset (new_handler->id.userid, 0x00,
  731. sizeof (new_handler->id.userid));
  732. }
  733. /* fill in the rest of handler */
  734. new_handler->pgm_data = pgm_data;
  735. new_handler->interrupt_table = ops;
  736. /*
  737. * Check if someone else is registered with same pgmname, userid
  738. * and mask. If someone is already registered with same pgmname,
  739. * userid and mask, registration will fail and NULL will be returned
  740. * to the application.
  741. * If identical handler not found, then handler is added to list.
  742. */
  743. rc = iucv_add_handler(new_handler);
  744. if (rc) {
  745. printk(KERN_WARNING "%s: Someone already registered with same "
  746. "pgmname, userid, pgmmask\n", __FUNCTION__);
  747. kfree (new_handler);
  748. return NULL;
  749. }
  750. rc = iucv_declare_buffer();
  751. if (rc) {
  752. char *err = "Unknown";
  753. iucv_remove_handler(new_handler);
  754. kfree(new_handler);
  755. switch(rc) {
  756. case 0x03:
  757. err = "Directory error";
  758. break;
  759. case 0x0a:
  760. err = "Invalid length";
  761. break;
  762. case 0x13:
  763. err = "Buffer already exists";
  764. break;
  765. case 0x3e:
  766. err = "Buffer overlap";
  767. break;
  768. case 0x5c:
  769. err = "Paging or storage error";
  770. break;
  771. }
  772. printk(KERN_WARNING "%s: iucv_declare_buffer "
  773. "returned error 0x%02lx (%s)\n", __FUNCTION__, rc, err);
  774. return NULL;
  775. }
  776. if (!register_flag) {
  777. /* request the 0x4000 external interrupt */
  778. rc = register_external_interrupt (0x4000, iucv_irq_handler);
  779. if (rc) {
  780. iucv_remove_handler(new_handler);
  781. kfree (new_handler);
  782. printk(KERN_WARNING "%s: "
  783. "register_external_interrupt returned %ld\n",
  784. __FUNCTION__, rc);
  785. return NULL;
  786. }
  787. register_flag = 1;
  788. }
  789. iucv_debug(1, "exiting");
  790. return new_handler;
  791. } /* end of register function */
  792. /**
  793. * iucv_unregister_program:
  794. * @handle: address of handler
  795. *
  796. * Unregister application with IUCV.
  797. * Returns:
  798. * 0 on success, -EINVAL, if specified handle is invalid.
  799. */
  800. int
  801. iucv_unregister_program (iucv_handle_t handle)
  802. {
  803. handler *h = NULL;
  804. struct list_head *lh;
  805. int i;
  806. ulong flags;
  807. iucv_debug(1, "entering");
  808. iucv_debug(1, "address of handler is %p", h);
  809. /* Checking if handle is valid */
  810. spin_lock_irqsave (&iucv_lock, flags);
  811. list_for_each(lh, &iucv_handler_table) {
  812. if ((handler *)handle == list_entry(lh, handler, list)) {
  813. h = (handler *)handle;
  814. break;
  815. }
  816. }
  817. if (!h) {
  818. spin_unlock_irqrestore (&iucv_lock, flags);
  819. if (handle)
  820. printk(KERN_WARNING
  821. "%s: Handler not found in iucv_handler_table.\n",
  822. __FUNCTION__);
  823. else
  824. printk(KERN_WARNING
  825. "%s: NULL handle passed by application.\n",
  826. __FUNCTION__);
  827. return -EINVAL;
  828. }
  829. /**
  830. * First, walk thru iucv_pathid_table and sever any pathid which is
  831. * still pointing to the handler to be removed.
  832. */
  833. for (i = 0; i < max_connections; i++)
  834. if (iucv_pathid_table[i] == h) {
  835. spin_unlock_irqrestore (&iucv_lock, flags);
  836. iucv_sever(i, h->id.user_data);
  837. spin_lock_irqsave(&iucv_lock, flags);
  838. }
  839. spin_unlock_irqrestore (&iucv_lock, flags);
  840. iucv_remove_handler(h);
  841. kfree(h);
  842. iucv_debug(1, "exiting");
  843. return 0;
  844. }
  845. /**
  846. * iucv_accept:
  847. * @pathid: Path identification number
  848. * @msglim_reqstd: The number of outstanding messages requested.
  849. * @user_data: Data specified by the iucv_connect function.
  850. * @flags1: Contains options for this path.
  851. * - IPPRTY (0x20) Specifies if you want to send priority message.
  852. * - IPRMDATA (0x80) Specifies whether your program can handle a message
  853. * in the parameter list.
  854. * - IPQUSCE (0x40) Specifies whether you want to quiesce the path being
  855. * established.
  856. * @handle: Address of handler.
  857. * @pgm_data: Application data passed to interrupt handlers.
  858. * @flags1_out: Pointer to an int. If not NULL, on return the options for
  859. * the path are stored at the given location:
  860. * - IPPRTY (0x20) Indicates you may send a priority message.
  861. * @msglim: Pointer to an __u16. If not NULL, on return the maximum
  862. * number of outstanding messages is stored at the given
  863. * location.
  864. *
  865. * This function is issued after the user receives a Connection Pending external
  866. * interrupt and now wishes to complete the IUCV communication path.
  867. * Returns:
  868. * return code from CP
  869. */
  870. int
  871. iucv_accept(__u16 pathid, __u16 msglim_reqstd,
  872. __u8 user_data[16], int flags1,
  873. iucv_handle_t handle, void *pgm_data,
  874. int *flags1_out, __u16 * msglim)
  875. {
  876. ulong b2f0_result = 0;
  877. ulong flags;
  878. struct list_head *lh;
  879. handler *h = NULL;
  880. iparml_control *parm;
  881. iucv_debug(1, "entering");
  882. iucv_debug(1, "pathid = %d", pathid);
  883. /* Checking if handle is valid */
  884. spin_lock_irqsave (&iucv_lock, flags);
  885. list_for_each(lh, &iucv_handler_table) {
  886. if ((handler *)handle == list_entry(lh, handler, list)) {
  887. h = (handler *)handle;
  888. break;
  889. }
  890. }
  891. spin_unlock_irqrestore (&iucv_lock, flags);
  892. if (!h) {
  893. if (handle)
  894. printk(KERN_WARNING
  895. "%s: Handler not found in iucv_handler_table.\n",
  896. __FUNCTION__);
  897. else
  898. printk(KERN_WARNING
  899. "%s: NULL handle passed by application.\n",
  900. __FUNCTION__);
  901. return -EINVAL;
  902. }
  903. parm = (iparml_control *)grab_param();
  904. parm->ippathid = pathid;
  905. parm->ipmsglim = msglim_reqstd;
  906. if (user_data)
  907. memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
  908. parm->ipflags1 = (__u8)flags1;
  909. b2f0_result = b2f0(ACCEPT, parm);
  910. if (!b2f0_result) {
  911. if (msglim)
  912. *msglim = parm->ipmsglim;
  913. if (pgm_data)
  914. h->pgm_data = pgm_data;
  915. if (flags1_out)
  916. *flags1_out = (parm->ipflags1 & IPPRTY) ? IPPRTY : 0;
  917. }
  918. release_param(parm);
  919. iucv_debug(1, "exiting");
  920. return b2f0_result;
  921. }
  922. /**
  923. * iucv_connect:
  924. * @pathid: Path identification number
  925. * @msglim_reqstd: Number of outstanding messages requested
  926. * @user_data: 16-byte user data
  927. * @userid: 8-byte of user identification
  928. * @system_name: 8-byte identifying the system name
  929. * @flags1: Specifies options for this path:
  930. * - IPPRTY (0x20) Specifies if you want to send priority message.
  931. * - IPRMDATA (0x80) Specifies whether your program can handle a message
  932. * in the parameter list.
  933. * - IPQUSCE (0x40) Specifies whether you want to quiesce the path being
  934. * established.
  935. * - IPLOCAL (0x01) Allows an application to force the partner to be on the
  936. * local system. If local is specified then target class
  937. * cannot be specified.
  938. * @flags1_out: Pointer to an int. If not NULL, on return the options for
  939. * the path are stored at the given location:
  940. * - IPPRTY (0x20) Indicates you may send a priority message.
  941. * @msglim: Pointer to an __u16. If not NULL, on return the maximum
  942. * number of outstanding messages is stored at the given
  943. * location.
  944. * @handle: Address of handler.
  945. * @pgm_data: Application data to be passed to interrupt handlers.
  946. *
  947. * This function establishes an IUCV path. Although the connect may complete
  948. * successfully, you are not able to use the path until you receive an IUCV
  949. * Connection Complete external interrupt.
  950. * Returns: return code from CP, or one of the following
  951. * - ENOMEM
  952. * - return code from iucv_declare_buffer
  953. * - EINVAL - invalid handle passed by application
  954. * - EINVAL - pathid address is NULL
  955. * - ENOMEM - pathid table storage allocation failed
  956. * - return code from internal function add_pathid
  957. */
  958. int
  959. iucv_connect (__u16 *pathid, __u16 msglim_reqstd,
  960. __u8 user_data[16], __u8 userid[8],
  961. __u8 system_name[8], int flags1,
  962. int *flags1_out, __u16 * msglim,
  963. iucv_handle_t handle, void *pgm_data)
  964. {
  965. iparml_control *parm;
  966. iparml_control local_parm;
  967. struct list_head *lh;
  968. ulong b2f0_result = 0;
  969. ulong flags;
  970. int add_pathid_result = 0;
  971. handler *h = NULL;
  972. __u8 no_memory[16] = "NO MEMORY";
  973. iucv_debug(1, "entering");
  974. /* Checking if handle is valid */
  975. spin_lock_irqsave (&iucv_lock, flags);
  976. list_for_each(lh, &iucv_handler_table) {
  977. if ((handler *)handle == list_entry(lh, handler, list)) {
  978. h = (handler *)handle;
  979. break;
  980. }
  981. }
  982. spin_unlock_irqrestore (&iucv_lock, flags);
  983. if (!h) {
  984. if (handle)
  985. printk(KERN_WARNING
  986. "%s: Handler not found in iucv_handler_table.\n",
  987. __FUNCTION__);
  988. else
  989. printk(KERN_WARNING
  990. "%s: NULL handle passed by application.\n",
  991. __FUNCTION__);
  992. return -EINVAL;
  993. }
  994. if (pathid == NULL) {
  995. printk(KERN_WARNING "%s: NULL pathid pointer\n",
  996. __FUNCTION__);
  997. return -EINVAL;
  998. }
  999. parm = (iparml_control *)grab_param();
  1000. parm->ipmsglim = msglim_reqstd;
  1001. if (user_data)
  1002. memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
  1003. if (userid) {
  1004. memcpy(parm->ipvmid, userid, sizeof(parm->ipvmid));
  1005. ASCEBC(parm->ipvmid, sizeof(parm->ipvmid));
  1006. EBC_TOUPPER(parm->ipvmid, sizeof(parm->ipvmid));
  1007. }
  1008. if (system_name) {
  1009. memcpy(parm->iptarget, system_name, sizeof(parm->iptarget));
  1010. ASCEBC(parm->iptarget, sizeof(parm->iptarget));
  1011. EBC_TOUPPER(parm->iptarget, sizeof(parm->iptarget));
  1012. }
  1013. /* In order to establish an IUCV connection, the procedure is:
  1014. *
  1015. * b2f0(CONNECT)
  1016. * take the ippathid from the b2f0 call
  1017. * register the handler to the ippathid
  1018. *
  1019. * Unfortunately, the ConnectionEstablished message gets sent after the
  1020. * b2f0(CONNECT) call but before the register is handled.
  1021. *
  1022. * In order for this race condition to be eliminated, the IUCV Control
  1023. * Interrupts must be disabled for the above procedure.
  1024. *
  1025. * David Kennedy <dkennedy@linuxcare.com>
  1026. */
  1027. /* Enable everything but IUCV Control messages */
  1028. iucv_setmask(~(AllInterrupts));
  1029. messagesDisabled = 1;
  1030. spin_lock_irqsave (&iucv_lock, flags);
  1031. parm->ipflags1 = (__u8)flags1;
  1032. b2f0_result = b2f0(CONNECT, parm);
  1033. memcpy(&local_parm, parm, sizeof(local_parm));
  1034. release_param(parm);
  1035. parm = &local_parm;
  1036. if (!b2f0_result)
  1037. add_pathid_result = __iucv_add_pathid(parm->ippathid, h);
  1038. spin_unlock_irqrestore (&iucv_lock, flags);
  1039. if (b2f0_result) {
  1040. iucv_setmask(~0);
  1041. messagesDisabled = 0;
  1042. return b2f0_result;
  1043. }
  1044. *pathid = parm->ippathid;
  1045. /* Enable everything again */
  1046. iucv_setmask(IUCVControlInterruptsFlag);
  1047. if (msglim)
  1048. *msglim = parm->ipmsglim;
  1049. if (flags1_out)
  1050. *flags1_out = (parm->ipflags1 & IPPRTY) ? IPPRTY : 0;
  1051. if (add_pathid_result) {
  1052. iucv_sever(*pathid, no_memory);
  1053. printk(KERN_WARNING "%s: add_pathid failed with rc ="
  1054. " %d\n", __FUNCTION__, add_pathid_result);
  1055. return(add_pathid_result);
  1056. }
  1057. iucv_debug(1, "exiting");
  1058. return b2f0_result;
  1059. }
  1060. /**
  1061. * iucv_purge:
  1062. * @pathid: Path identification number
  1063. * @msgid: Message ID of message to purge.
  1064. * @srccls: Message class of the message to purge.
  1065. * @audit: Pointer to an __u32. If not NULL, on return, information about
  1066. * asynchronous errors that may have affected the normal completion
  1067. * of this message ist stored at the given location.
  1068. *
  1069. * Cancels a message you have sent.
  1070. * Returns: return code from CP
  1071. */
  1072. int
  1073. iucv_purge (__u16 pathid, __u32 msgid, __u32 srccls, __u32 *audit)
  1074. {
  1075. iparml_purge *parm;
  1076. ulong b2f0_result = 0;
  1077. iucv_debug(1, "entering");
  1078. iucv_debug(1, "pathid = %d", pathid);
  1079. parm = (iparml_purge *)grab_param();
  1080. parm->ipmsgid = msgid;
  1081. parm->ippathid = pathid;
  1082. parm->ipsrccls = srccls;
  1083. parm->ipflags1 |= (IPSRCCLS | IPFGMID | IPFGPID);
  1084. b2f0_result = b2f0(PURGE, parm);
  1085. if (!b2f0_result && audit) {
  1086. memcpy(audit, parm->ipaudit, sizeof(parm->ipaudit));
  1087. /* parm->ipaudit has only 3 bytes */
  1088. *audit >>= 8;
  1089. }
  1090. release_param(parm);
  1091. iucv_debug(1, "b2f0_result = %ld", b2f0_result);
  1092. iucv_debug(1, "exiting");
  1093. return b2f0_result;
  1094. }
  1095. /**
  1096. * iucv_query_generic:
  1097. * @want_maxconn: Flag, describing which value is to be returned.
  1098. *
  1099. * Helper function for iucv_query_maxconn() and iucv_query_bufsize().
  1100. *
  1101. * Returns: The buffersize, if want_maxconn is 0; the maximum number of
  1102. * connections, if want_maxconn is 1 or an error-code < 0 on failure.
  1103. */
  1104. static int
  1105. iucv_query_generic(int want_maxconn)
  1106. {
  1107. iparml_purge *parm = (iparml_purge *)grab_param();
  1108. int bufsize, maxconn;
  1109. int ccode;
  1110. /**
  1111. * Call b2f0 and store R0 (max buffer size),
  1112. * R1 (max connections) and CC.
  1113. */
  1114. asm volatile (
  1115. "LRA 1,0(%4)\n\t"
  1116. "LR 0,%3\n\t"
  1117. ".long 0xb2f01000\n\t"
  1118. "IPM %0\n\t"
  1119. "SRL %0,28\n\t"
  1120. "ST 0,%1\n\t"
  1121. "ST 1,%2\n\t"
  1122. : "=d" (ccode), "=m" (bufsize), "=m" (maxconn)
  1123. : "d" (QUERY), "a" (parm)
  1124. : "0", "1", "cc"
  1125. );
  1126. release_param(parm);
  1127. if (ccode)
  1128. return -EPERM;
  1129. if (want_maxconn)
  1130. return maxconn;
  1131. return bufsize;
  1132. }
  1133. /**
  1134. * iucv_query_maxconn:
  1135. *
  1136. * Determines the maximum number of connections thay may be established.
  1137. *
  1138. * Returns: Maximum number of connections that can be.
  1139. */
  1140. ulong
  1141. iucv_query_maxconn(void)
  1142. {
  1143. return iucv_query_generic(1);
  1144. }
  1145. /**
  1146. * iucv_query_bufsize:
  1147. *
  1148. * Determines the size of the external interrupt buffer.
  1149. *
  1150. * Returns: Size of external interrupt buffer.
  1151. */
  1152. ulong
  1153. iucv_query_bufsize (void)
  1154. {
  1155. return iucv_query_generic(0);
  1156. }
  1157. /**
  1158. * iucv_quiesce:
  1159. * @pathid: Path identification number
  1160. * @user_data: 16-byte user data
  1161. *
  1162. * Temporarily suspends incoming messages on an IUCV path.
  1163. * You can later reactivate the path by invoking the iucv_resume function.
  1164. * Returns: return code from CP
  1165. */
  1166. int
  1167. iucv_quiesce (__u16 pathid, __u8 user_data[16])
  1168. {
  1169. iparml_control *parm;
  1170. ulong b2f0_result = 0;
  1171. iucv_debug(1, "entering");
  1172. iucv_debug(1, "pathid = %d", pathid);
  1173. parm = (iparml_control *)grab_param();
  1174. memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
  1175. parm->ippathid = pathid;
  1176. b2f0_result = b2f0(QUIESCE, parm);
  1177. release_param(parm);
  1178. iucv_debug(1, "b2f0_result = %ld", b2f0_result);
  1179. iucv_debug(1, "exiting");
  1180. return b2f0_result;
  1181. }
  1182. /**
  1183. * iucv_receive:
  1184. * @pathid: Path identification number.
  1185. * @buffer: Address of buffer to receive. Must be below 2G.
  1186. * @buflen: Length of buffer to receive.
  1187. * @msgid: Specifies the message ID.
  1188. * @trgcls: Specifies target class.
  1189. * @flags1_out: Receives options for path on return.
  1190. * - IPNORPY (0x10) Specifies whether a reply is required
  1191. * - IPPRTY (0x20) Specifies if you want to send priority message
  1192. * - IPRMDATA (0x80) Specifies the data is contained in the parameter list
  1193. * @residual_buffer: Receives the address of buffer updated by the number
  1194. * of bytes you have received on return.
  1195. * @residual_length: On return, receives one of the following values:
  1196. * - 0 If the receive buffer is the same length as
  1197. * the message.
  1198. * - Remaining bytes in buffer If the receive buffer is longer than the
  1199. * message.
  1200. * - Remaining bytes in message If the receive buffer is shorter than the
  1201. * message.
  1202. *
  1203. * This function receives messages that are being sent to you over established
  1204. * paths.
  1205. * Returns: return code from CP IUCV call; If the receive buffer is shorter
  1206. * than the message, always 5
  1207. * -EINVAL - buffer address is pointing to NULL
  1208. */
  1209. int
  1210. iucv_receive (__u16 pathid, __u32 msgid, __u32 trgcls,
  1211. void *buffer, ulong buflen,
  1212. int *flags1_out, ulong * residual_buffer, ulong * residual_length)
  1213. {
  1214. iparml_db *parm;
  1215. ulong b2f0_result;
  1216. int moved = 0; /* number of bytes moved from parmlist to buffer */
  1217. iucv_debug(2, "entering");
  1218. if (!buffer)
  1219. return -EINVAL;
  1220. parm = (iparml_db *)grab_param();
  1221. parm->ipbfadr1 = (__u32) (addr_t) buffer;
  1222. parm->ipbfln1f = (__u32) ((ulong) buflen);
  1223. parm->ipmsgid = msgid;
  1224. parm->ippathid = pathid;
  1225. parm->iptrgcls = trgcls;
  1226. parm->ipflags1 = (IPFGPID | IPFGMID | IPFGMCL);
  1227. b2f0_result = b2f0(RECEIVE, parm);
  1228. if (!b2f0_result || b2f0_result == 5) {
  1229. if (flags1_out) {
  1230. iucv_debug(2, "*flags1_out = %d", *flags1_out);
  1231. *flags1_out = (parm->ipflags1 & (~0x07));
  1232. iucv_debug(2, "*flags1_out = %d", *flags1_out);
  1233. }
  1234. if (!(parm->ipflags1 & IPRMDATA)) { /*msg not in parmlist */
  1235. if (residual_length)
  1236. *residual_length = parm->ipbfln1f;
  1237. if (residual_buffer)
  1238. *residual_buffer = parm->ipbfadr1;
  1239. } else {
  1240. moved = min_t (unsigned long, buflen, 8);
  1241. memcpy ((char *) buffer,
  1242. (char *) &parm->ipbfadr1, moved);
  1243. if (buflen < 8)
  1244. b2f0_result = 5;
  1245. if (residual_length)
  1246. *residual_length = abs (buflen - 8);
  1247. if (residual_buffer)
  1248. *residual_buffer = (ulong) (buffer + moved);
  1249. }
  1250. }
  1251. release_param(parm);
  1252. iucv_debug(2, "exiting");
  1253. return b2f0_result;
  1254. }
  1255. /*
  1256. * Name: iucv_receive_array
  1257. * Purpose: This function receives messages that are being sent to you
  1258. * over established paths.
  1259. * Input: pathid - path identification number
  1260. * buffer - address of array of buffers
  1261. * buflen - total length of buffers
  1262. * msgid - specifies the message ID.
  1263. * trgcls - specifies target class
  1264. * Output:
  1265. * flags1_out: Options for path.
  1266. * IPNORPY - 0x10 specifies whether a reply is required
  1267. * IPPRTY - 0x20 specifies if you want to send priority message
  1268. * IPRMDATA - 0x80 specifies the data is contained in the parameter list
  1269. * residual_buffer - address points to the current list entry IUCV
  1270. * is working on.
  1271. * residual_length -
  1272. * Contains one of the following values, if the receive buffer is:
  1273. * The same length as the message, this field is zero.
  1274. * Longer than the message, this field contains the number of
  1275. * bytes remaining in the buffer.
  1276. * Shorter than the message, this field contains the residual
  1277. * count (that is, the number of bytes remaining in the
  1278. * message that does not fit into the buffer. In this case
  1279. * b2f0_result = 5.
  1280. * Return: b2f0_result - return code from CP
  1281. * (-EINVAL) - buffer address is NULL
  1282. */
  1283. int
  1284. iucv_receive_array (__u16 pathid,
  1285. __u32 msgid, __u32 trgcls,
  1286. iucv_array_t * buffer, ulong buflen,
  1287. int *flags1_out,
  1288. ulong * residual_buffer, ulong * residual_length)
  1289. {
  1290. iparml_db *parm;
  1291. ulong b2f0_result;
  1292. int i = 0, moved = 0, need_to_move = 8, dyn_len;
  1293. iucv_debug(2, "entering");
  1294. if (!buffer)
  1295. return -EINVAL;
  1296. parm = (iparml_db *)grab_param();
  1297. parm->ipbfadr1 = (__u32) ((ulong) buffer);
  1298. parm->ipbfln1f = (__u32) buflen;
  1299. parm->ipmsgid = msgid;
  1300. parm->ippathid = pathid;
  1301. parm->iptrgcls = trgcls;
  1302. parm->ipflags1 = (IPBUFLST | IPFGPID | IPFGMID | IPFGMCL);
  1303. b2f0_result = b2f0(RECEIVE, parm);
  1304. if (!b2f0_result || b2f0_result == 5) {
  1305. if (flags1_out) {
  1306. iucv_debug(2, "*flags1_out = %d", *flags1_out);
  1307. *flags1_out = (parm->ipflags1 & (~0x07));
  1308. iucv_debug(2, "*flags1_out = %d", *flags1_out);
  1309. }
  1310. if (!(parm->ipflags1 & IPRMDATA)) { /*msg not in parmlist */
  1311. if (residual_length)
  1312. *residual_length = parm->ipbfln1f;
  1313. if (residual_buffer)
  1314. *residual_buffer = parm->ipbfadr1;
  1315. } else {
  1316. /* copy msg from parmlist to users array. */
  1317. while ((moved < 8) && (moved < buflen)) {
  1318. dyn_len =
  1319. min_t (unsigned int,
  1320. (buffer + i)->length, need_to_move);
  1321. memcpy ((char *)((ulong)((buffer + i)->address)),
  1322. ((char *) &parm->ipbfadr1) + moved,
  1323. dyn_len);
  1324. moved += dyn_len;
  1325. need_to_move -= dyn_len;
  1326. (buffer + i)->address =
  1327. (__u32)
  1328. ((ulong)(__u8 *) ((ulong)(buffer + i)->address)
  1329. + dyn_len);
  1330. (buffer + i)->length -= dyn_len;
  1331. i++;
  1332. }
  1333. if (need_to_move) /* buflen < 8 bytes */
  1334. b2f0_result = 5;
  1335. if (residual_length)
  1336. *residual_length = abs (buflen - 8);
  1337. if (residual_buffer) {
  1338. if (!moved)
  1339. *residual_buffer = (ulong) buffer;
  1340. else
  1341. *residual_buffer =
  1342. (ulong) (buffer + (i - 1));
  1343. }
  1344. }
  1345. }
  1346. release_param(parm);
  1347. iucv_debug(2, "exiting");
  1348. return b2f0_result;
  1349. }
  1350. /**
  1351. * iucv_reject:
  1352. * @pathid: Path identification number.
  1353. * @msgid: Message ID of the message to reject.
  1354. * @trgcls: Target class of the message to reject.
  1355. * Returns: return code from CP
  1356. *
  1357. * Refuses a specified message. Between the time you are notified of a
  1358. * message and the time that you complete the message, the message may
  1359. * be rejected.
  1360. */
  1361. int
  1362. iucv_reject (__u16 pathid, __u32 msgid, __u32 trgcls)
  1363. {
  1364. iparml_db *parm;
  1365. ulong b2f0_result = 0;
  1366. iucv_debug(1, "entering");
  1367. iucv_debug(1, "pathid = %d", pathid);
  1368. parm = (iparml_db *)grab_param();
  1369. parm->ippathid = pathid;
  1370. parm->ipmsgid = msgid;
  1371. parm->iptrgcls = trgcls;
  1372. parm->ipflags1 = (IPFGMCL | IPFGMID | IPFGPID);
  1373. b2f0_result = b2f0(REJECT, parm);
  1374. release_param(parm);
  1375. iucv_debug(1, "b2f0_result = %ld", b2f0_result);
  1376. iucv_debug(1, "exiting");
  1377. return b2f0_result;
  1378. }
  1379. /*
  1380. * Name: iucv_reply
  1381. * Purpose: This function responds to the two-way messages that you
  1382. * receive. You must identify completely the message to
  1383. * which you wish to reply. ie, pathid, msgid, and trgcls.
  1384. * Input: pathid - path identification number
  1385. * msgid - specifies the message ID.
  1386. * trgcls - specifies target class
  1387. * flags1 - option for path
  1388. * IPPRTY- 0x20 - specifies if you want to send priority message
  1389. * buffer - address of reply buffer
  1390. * buflen - length of reply buffer
  1391. * Output: ipbfadr2 - Address of buffer updated by the number
  1392. * of bytes you have moved.
  1393. * ipbfln2f - Contains one of the following values:
  1394. * If the answer buffer is the same length as the reply, this field
  1395. * contains zero.
  1396. * If the answer buffer is longer than the reply, this field contains
  1397. * the number of bytes remaining in the buffer.
  1398. * If the answer buffer is shorter than the reply, this field contains
  1399. * a residual count (that is, the number of bytes remianing in the
  1400. * reply that does not fit into the buffer. In this
  1401. * case b2f0_result = 5.
  1402. * Return: b2f0_result - return code from CP
  1403. * (-EINVAL) - buffer address is NULL
  1404. */
  1405. int
  1406. iucv_reply (__u16 pathid,
  1407. __u32 msgid, __u32 trgcls,
  1408. int flags1,
  1409. void *buffer, ulong buflen, ulong * ipbfadr2, ulong * ipbfln2f)
  1410. {
  1411. iparml_db *parm;
  1412. ulong b2f0_result;
  1413. iucv_debug(2, "entering");
  1414. if (!buffer)
  1415. return -EINVAL;
  1416. parm = (iparml_db *)grab_param();
  1417. parm->ipbfadr2 = (__u32) ((ulong) buffer);
  1418. parm->ipbfln2f = (__u32) buflen; /* length of message */
  1419. parm->ippathid = pathid;
  1420. parm->ipmsgid = msgid;
  1421. parm->iptrgcls = trgcls;
  1422. parm->ipflags1 = (__u8) flags1; /* priority message */
  1423. b2f0_result = b2f0(REPLY, parm);
  1424. if ((!b2f0_result) || (b2f0_result == 5)) {
  1425. if (ipbfadr2)
  1426. *ipbfadr2 = parm->ipbfadr2;
  1427. if (ipbfln2f)
  1428. *ipbfln2f = parm->ipbfln2f;
  1429. }
  1430. release_param(parm);
  1431. iucv_debug(2, "exiting");
  1432. return b2f0_result;
  1433. }
  1434. /*
  1435. * Name: iucv_reply_array
  1436. * Purpose: This function responds to the two-way messages that you
  1437. * receive. You must identify completely the message to
  1438. * which you wish to reply. ie, pathid, msgid, and trgcls.
  1439. * The array identifies a list of addresses and lengths of
  1440. * discontiguous buffers that contains the reply data.
  1441. * Input: pathid - path identification number
  1442. * msgid - specifies the message ID.
  1443. * trgcls - specifies target class
  1444. * flags1 - option for path
  1445. * IPPRTY- specifies if you want to send priority message
  1446. * buffer - address of array of reply buffers
  1447. * buflen - total length of reply buffers
  1448. * Output: ipbfadr2 - Address of buffer which IUCV is currently working on.
  1449. * ipbfln2f - Contains one of the following values:
  1450. * If the answer buffer is the same length as the reply, this field
  1451. * contains zero.
  1452. * If the answer buffer is longer than the reply, this field contains
  1453. * the number of bytes remaining in the buffer.
  1454. * If the answer buffer is shorter than the reply, this field contains
  1455. * a residual count (that is, the number of bytes remianing in the
  1456. * reply that does not fit into the buffer. In this
  1457. * case b2f0_result = 5.
  1458. * Return: b2f0_result - return code from CP
  1459. * (-EINVAL) - buffer address is NULL
  1460. */
  1461. int
  1462. iucv_reply_array (__u16 pathid,
  1463. __u32 msgid, __u32 trgcls,
  1464. int flags1,
  1465. iucv_array_t * buffer,
  1466. ulong buflen, ulong * ipbfadr2, ulong * ipbfln2f)
  1467. {
  1468. iparml_db *parm;
  1469. ulong b2f0_result;
  1470. iucv_debug(2, "entering");
  1471. if (!buffer)
  1472. return -EINVAL;
  1473. parm = (iparml_db *)grab_param();
  1474. parm->ipbfadr2 = (__u32) ((ulong) buffer);
  1475. parm->ipbfln2f = buflen; /* length of message */
  1476. parm->ippathid = pathid;
  1477. parm->ipmsgid = msgid;
  1478. parm->iptrgcls = trgcls;
  1479. parm->ipflags1 = (IPANSLST | flags1);
  1480. b2f0_result = b2f0(REPLY, parm);
  1481. if ((!b2f0_result) || (b2f0_result == 5)) {
  1482. if (ipbfadr2)
  1483. *ipbfadr2 = parm->ipbfadr2;
  1484. if (ipbfln2f)
  1485. *ipbfln2f = parm->ipbfln2f;
  1486. }
  1487. release_param(parm);
  1488. iucv_debug(2, "exiting");
  1489. return b2f0_result;
  1490. }
  1491. /*
  1492. * Name: iucv_reply_prmmsg
  1493. * Purpose: This function responds to the two-way messages that you
  1494. * receive. You must identify completely the message to
  1495. * which you wish to reply. ie, pathid, msgid, and trgcls.
  1496. * Prmmsg signifies the data is moved into the
  1497. * parameter list.
  1498. * Input: pathid - path identification number
  1499. * msgid - specifies the message ID.
  1500. * trgcls - specifies target class
  1501. * flags1 - option for path
  1502. * IPPRTY- specifies if you want to send priority message
  1503. * prmmsg - 8-bytes of data to be placed into the parameter
  1504. * list.
  1505. * Output: NA
  1506. * Return: b2f0_result - return code from CP
  1507. */
  1508. int
  1509. iucv_reply_prmmsg (__u16 pathid,
  1510. __u32 msgid, __u32 trgcls, int flags1, __u8 prmmsg[8])
  1511. {
  1512. iparml_dpl *parm;
  1513. ulong b2f0_result;
  1514. iucv_debug(2, "entering");
  1515. parm = (iparml_dpl *)grab_param();
  1516. parm->ippathid = pathid;
  1517. parm->ipmsgid = msgid;
  1518. parm->iptrgcls = trgcls;
  1519. memcpy(parm->iprmmsg, prmmsg, sizeof (parm->iprmmsg));
  1520. parm->ipflags1 = (IPRMDATA | flags1);
  1521. b2f0_result = b2f0(REPLY, parm);
  1522. release_param(parm);
  1523. iucv_debug(2, "exiting");
  1524. return b2f0_result;
  1525. }
  1526. /**
  1527. * iucv_resume:
  1528. * @pathid: Path identification number
  1529. * @user_data: 16-byte of user data
  1530. *
  1531. * This function restores communication over a quiesced path.
  1532. * Returns: return code from CP
  1533. */
  1534. int
  1535. iucv_resume (__u16 pathid, __u8 user_data[16])
  1536. {
  1537. iparml_control *parm;
  1538. ulong b2f0_result = 0;
  1539. iucv_debug(1, "entering");
  1540. iucv_debug(1, "pathid = %d", pathid);
  1541. parm = (iparml_control *)grab_param();
  1542. memcpy (parm->ipuser, user_data, sizeof (*user_data));
  1543. parm->ippathid = pathid;
  1544. b2f0_result = b2f0(RESUME, parm);
  1545. release_param(parm);
  1546. iucv_debug(1, "exiting");
  1547. return b2f0_result;
  1548. }
  1549. /*
  1550. * Name: iucv_send
  1551. * Purpose: sends messages
  1552. * Input: pathid - ushort, pathid
  1553. * msgid - ulong *, id of message returned to caller
  1554. * trgcls - ulong, target message class
  1555. * srccls - ulong, source message class
  1556. * msgtag - ulong, message tag
  1557. * flags1 - Contains options for this path.
  1558. * IPPRTY - Ox20 - specifies if you want to send a priority message.
  1559. * buffer - pointer to buffer
  1560. * buflen - ulong, length of buffer
  1561. * Output: b2f0_result - return code from b2f0 call
  1562. * msgid - returns message id
  1563. */
  1564. int
  1565. iucv_send (__u16 pathid, __u32 * msgid,
  1566. __u32 trgcls, __u32 srccls,
  1567. __u32 msgtag, int flags1, void *buffer, ulong buflen)
  1568. {
  1569. iparml_db *parm;
  1570. ulong b2f0_result;
  1571. iucv_debug(2, "entering");
  1572. if (!buffer)
  1573. return -EINVAL;
  1574. parm = (iparml_db *)grab_param();
  1575. parm->ipbfadr1 = (__u32) ((ulong) buffer);
  1576. parm->ippathid = pathid;
  1577. parm->iptrgcls = trgcls;
  1578. parm->ipbfln1f = (__u32) buflen; /* length of message */
  1579. parm->ipsrccls = srccls;
  1580. parm->ipmsgtag = msgtag;
  1581. parm->ipflags1 = (IPNORPY | flags1); /* one way priority message */
  1582. b2f0_result = b2f0(SEND, parm);
  1583. if ((!b2f0_result) && (msgid))
  1584. *msgid = parm->ipmsgid;
  1585. release_param(parm);
  1586. iucv_debug(2, "exiting");
  1587. return b2f0_result;
  1588. }
  1589. /*
  1590. * Name: iucv_send_array
  1591. * Purpose: This function transmits data to another application.
  1592. * The contents of buffer is the address of the array of
  1593. * addresses and lengths of discontiguous buffers that hold
  1594. * the message text. This is a one-way message and the
  1595. * receiver will not reply to the message.
  1596. * Input: pathid - path identification number
  1597. * trgcls - specifies target class
  1598. * srccls - specifies the source message class
  1599. * msgtag - specifies a tag to be associated witht the message
  1600. * flags1 - option for path
  1601. * IPPRTY- specifies if you want to send priority message
  1602. * buffer - address of array of send buffers
  1603. * buflen - total length of send buffers
  1604. * Output: msgid - specifies the message ID.
  1605. * Return: b2f0_result - return code from CP
  1606. * (-EINVAL) - buffer address is NULL
  1607. */
  1608. int
  1609. iucv_send_array (__u16 pathid,
  1610. __u32 * msgid,
  1611. __u32 trgcls,
  1612. __u32 srccls,
  1613. __u32 msgtag, int flags1, iucv_array_t * buffer, ulong buflen)
  1614. {
  1615. iparml_db *parm;
  1616. ulong b2f0_result;
  1617. iucv_debug(2, "entering");
  1618. if (!buffer)
  1619. return -EINVAL;
  1620. parm = (iparml_db *)grab_param();
  1621. parm->ippathid = pathid;
  1622. parm->iptrgcls = trgcls;
  1623. parm->ipbfadr1 = (__u32) ((ulong) buffer);
  1624. parm->ipbfln1f = (__u32) buflen; /* length of message */
  1625. parm->ipsrccls = srccls;
  1626. parm->ipmsgtag = msgtag;
  1627. parm->ipflags1 = (IPNORPY | IPBUFLST | flags1);
  1628. b2f0_result = b2f0(SEND, parm);
  1629. if ((!b2f0_result) && (msgid))
  1630. *msgid = parm->ipmsgid;
  1631. release_param(parm);
  1632. iucv_debug(2, "exiting");
  1633. return b2f0_result;
  1634. }
  1635. /*
  1636. * Name: iucv_send_prmmsg
  1637. * Purpose: This function transmits data to another application.
  1638. * Prmmsg specifies that the 8-bytes of data are to be moved
  1639. * into the parameter list. This is a one-way message and the
  1640. * receiver will not reply to the message.
  1641. * Input: pathid - path identification number
  1642. * trgcls - specifies target class
  1643. * srccls - specifies the source message class
  1644. * msgtag - specifies a tag to be associated with the message
  1645. * flags1 - option for path
  1646. * IPPRTY- specifies if you want to send priority message
  1647. * prmmsg - 8-bytes of data to be placed into parameter list
  1648. * Output: msgid - specifies the message ID.
  1649. * Return: b2f0_result - return code from CP
  1650. */
  1651. int
  1652. iucv_send_prmmsg (__u16 pathid,
  1653. __u32 * msgid,
  1654. __u32 trgcls,
  1655. __u32 srccls, __u32 msgtag, int flags1, __u8 prmmsg[8])
  1656. {
  1657. iparml_dpl *parm;
  1658. ulong b2f0_result;
  1659. iucv_debug(2, "entering");
  1660. parm = (iparml_dpl *)grab_param();
  1661. parm->ippathid = pathid;
  1662. parm->iptrgcls = trgcls;
  1663. parm->ipsrccls = srccls;
  1664. parm->ipmsgtag = msgtag;
  1665. parm->ipflags1 = (IPRMDATA | IPNORPY | flags1);
  1666. memcpy(parm->iprmmsg, prmmsg, sizeof(parm->iprmmsg));
  1667. b2f0_result = b2f0(SEND, parm);
  1668. if ((!b2f0_result) && (msgid))
  1669. *msgid = parm->ipmsgid;
  1670. release_param(parm);
  1671. iucv_debug(2, "exiting");
  1672. return b2f0_result;
  1673. }
  1674. /*
  1675. * Name: iucv_send2way
  1676. * Purpose: This function transmits data to another application.
  1677. * Data to be transmitted is in a buffer. The receiver
  1678. * of the send is expected to reply to the message and
  1679. * a buffer is provided into which IUCV moves the reply
  1680. * to this message.
  1681. * Input: pathid - path identification number
  1682. * trgcls - specifies target class
  1683. * srccls - specifies the source message class
  1684. * msgtag - specifies a tag associated with the message
  1685. * flags1 - option for path
  1686. * IPPRTY- specifies if you want to send priority message
  1687. * buffer - address of send buffer
  1688. * buflen - length of send buffer
  1689. * ansbuf - address of buffer to reply with
  1690. * anslen - length of buffer to reply with
  1691. * Output: msgid - specifies the message ID.
  1692. * Return: b2f0_result - return code from CP
  1693. * (-EINVAL) - buffer or ansbuf address is NULL
  1694. */
  1695. int
  1696. iucv_send2way (__u16 pathid,
  1697. __u32 * msgid,
  1698. __u32 trgcls,
  1699. __u32 srccls,
  1700. __u32 msgtag,
  1701. int flags1,
  1702. void *buffer, ulong buflen, void *ansbuf, ulong anslen)
  1703. {
  1704. iparml_db *parm;
  1705. ulong b2f0_result;
  1706. iucv_debug(2, "entering");
  1707. if (!buffer || !ansbuf)
  1708. return -EINVAL;
  1709. parm = (iparml_db *)grab_param();
  1710. parm->ippathid = pathid;
  1711. parm->iptrgcls = trgcls;
  1712. parm->ipbfadr1 = (__u32) ((ulong) buffer);
  1713. parm->ipbfln1f = (__u32) buflen; /* length of message */
  1714. parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
  1715. parm->ipbfln2f = (__u32) anslen;
  1716. parm->ipsrccls = srccls;
  1717. parm->ipmsgtag = msgtag;
  1718. parm->ipflags1 = flags1; /* priority message */
  1719. b2f0_result = b2f0(SEND, parm);
  1720. if ((!b2f0_result) && (msgid))
  1721. *msgid = parm->ipmsgid;
  1722. release_param(parm);
  1723. iucv_debug(2, "exiting");
  1724. return b2f0_result;
  1725. }
  1726. /*
  1727. * Name: iucv_send2way_array
  1728. * Purpose: This function transmits data to another application.
  1729. * The contents of buffer is the address of the array of
  1730. * addresses and lengths of discontiguous buffers that hold
  1731. * the message text. The receiver of the send is expected to
  1732. * reply to the message and a buffer is provided into which
  1733. * IUCV moves the reply to this message.
  1734. * Input: pathid - path identification number
  1735. * trgcls - specifies target class
  1736. * srccls - specifies the source message class
  1737. * msgtag - spcifies a tag to be associated with the message
  1738. * flags1 - option for path
  1739. * IPPRTY- specifies if you want to send priority message
  1740. * buffer - address of array of send buffers
  1741. * buflen - total length of send buffers
  1742. * ansbuf - address of buffer to reply with
  1743. * anslen - length of buffer to reply with
  1744. * Output: msgid - specifies the message ID.
  1745. * Return: b2f0_result - return code from CP
  1746. * (-EINVAL) - buffer address is NULL
  1747. */
  1748. int
  1749. iucv_send2way_array (__u16 pathid,
  1750. __u32 * msgid,
  1751. __u32 trgcls,
  1752. __u32 srccls,
  1753. __u32 msgtag,
  1754. int flags1,
  1755. iucv_array_t * buffer,
  1756. ulong buflen, iucv_array_t * ansbuf, ulong anslen)
  1757. {
  1758. iparml_db *parm;
  1759. ulong b2f0_result;
  1760. iucv_debug(2, "entering");
  1761. if (!buffer || !ansbuf)
  1762. return -EINVAL;
  1763. parm = (iparml_db *)grab_param();
  1764. parm->ippathid = pathid;
  1765. parm->iptrgcls = trgcls;
  1766. parm->ipbfadr1 = (__u32) ((ulong) buffer);
  1767. parm->ipbfln1f = (__u32) buflen; /* length of message */
  1768. parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
  1769. parm->ipbfln2f = (__u32) anslen;
  1770. parm->ipsrccls = srccls;
  1771. parm->ipmsgtag = msgtag;
  1772. parm->ipflags1 = (IPBUFLST | IPANSLST | flags1);
  1773. b2f0_result = b2f0(SEND, parm);
  1774. if ((!b2f0_result) && (msgid))
  1775. *msgid = parm->ipmsgid;
  1776. release_param(parm);
  1777. iucv_debug(2, "exiting");
  1778. return b2f0_result;
  1779. }
  1780. /*
  1781. * Name: iucv_send2way_prmmsg
  1782. * Purpose: This function transmits data to another application.
  1783. * Prmmsg specifies that the 8-bytes of data are to be moved
  1784. * into the parameter list. This is a two-way message and the
  1785. * receiver of the message is expected to reply. A buffer
  1786. * is provided into which IUCV moves the reply to this
  1787. * message.
  1788. * Input: pathid - path identification number
  1789. * trgcls - specifies target class
  1790. * srccls - specifies the source message class
  1791. * msgtag - specifies a tag to be associated with the message
  1792. * flags1 - option for path
  1793. * IPPRTY- specifies if you want to send priority message
  1794. * prmmsg - 8-bytes of data to be placed in parameter list
  1795. * ansbuf - address of buffer to reply with
  1796. * anslen - length of buffer to reply with
  1797. * Output: msgid - specifies the message ID.
  1798. * Return: b2f0_result - return code from CP
  1799. * (-EINVAL) - buffer address is NULL
  1800. */
  1801. int
  1802. iucv_send2way_prmmsg (__u16 pathid,
  1803. __u32 * msgid,
  1804. __u32 trgcls,
  1805. __u32 srccls,
  1806. __u32 msgtag,
  1807. ulong flags1, __u8 prmmsg[8], void *ansbuf, ulong anslen)
  1808. {
  1809. iparml_dpl *parm;
  1810. ulong b2f0_result;
  1811. iucv_debug(2, "entering");
  1812. if (!ansbuf)
  1813. return -EINVAL;
  1814. parm = (iparml_dpl *)grab_param();
  1815. parm->ippathid = pathid;
  1816. parm->iptrgcls = trgcls;
  1817. parm->ipsrccls = srccls;
  1818. parm->ipmsgtag = msgtag;
  1819. parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
  1820. parm->ipbfln2f = (__u32) anslen;
  1821. parm->ipflags1 = (IPRMDATA | flags1); /* message in prmlist */
  1822. memcpy(parm->iprmmsg, prmmsg, sizeof(parm->iprmmsg));
  1823. b2f0_result = b2f0(SEND, parm);
  1824. if ((!b2f0_result) && (msgid))
  1825. *msgid = parm->ipmsgid;
  1826. release_param(parm);
  1827. iucv_debug(2, "exiting");
  1828. return b2f0_result;
  1829. }
  1830. /*
  1831. * Name: iucv_send2way_prmmsg_array
  1832. * Purpose: This function transmits data to another application.
  1833. * Prmmsg specifies that the 8-bytes of data are to be moved
  1834. * into the parameter list. This is a two-way message and the
  1835. * receiver of the message is expected to reply. A buffer
  1836. * is provided into which IUCV moves the reply to this
  1837. * message. The contents of ansbuf is the address of the
  1838. * array of addresses and lengths of discontiguous buffers
  1839. * that contain the reply.
  1840. * Input: pathid - path identification number
  1841. * trgcls - specifies target class
  1842. * srccls - specifies the source message class
  1843. * msgtag - specifies a tag to be associated with the message
  1844. * flags1 - option for path
  1845. * IPPRTY- specifies if you want to send priority message
  1846. * prmmsg - 8-bytes of data to be placed into the parameter list
  1847. * ansbuf - address of buffer to reply with
  1848. * anslen - length of buffer to reply with
  1849. * Output: msgid - specifies the message ID.
  1850. * Return: b2f0_result - return code from CP
  1851. * (-EINVAL) - ansbuf address is NULL
  1852. */
  1853. int
  1854. iucv_send2way_prmmsg_array (__u16 pathid,
  1855. __u32 * msgid,
  1856. __u32 trgcls,
  1857. __u32 srccls,
  1858. __u32 msgtag,
  1859. int flags1,
  1860. __u8 prmmsg[8],
  1861. iucv_array_t * ansbuf, ulong anslen)
  1862. {
  1863. iparml_dpl *parm;
  1864. ulong b2f0_result;
  1865. iucv_debug(2, "entering");
  1866. if (!ansbuf)
  1867. return -EINVAL;
  1868. parm = (iparml_dpl *)grab_param();
  1869. parm->ippathid = pathid;
  1870. parm->iptrgcls = trgcls;
  1871. parm->ipsrccls = srccls;
  1872. parm->ipmsgtag = msgtag;
  1873. parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
  1874. parm->ipbfln2f = (__u32) anslen;
  1875. parm->ipflags1 = (IPRMDATA | IPANSLST | flags1);
  1876. memcpy(parm->iprmmsg, prmmsg, sizeof(parm->iprmmsg));
  1877. b2f0_result = b2f0(SEND, parm);
  1878. if ((!b2f0_result) && (msgid))
  1879. *msgid = parm->ipmsgid;
  1880. release_param(parm);
  1881. iucv_debug(2, "exiting");
  1882. return b2f0_result;
  1883. }
  1884. void
  1885. iucv_setmask_cpuid (void *result)
  1886. {
  1887. iparml_set_mask *parm;
  1888. iucv_debug(1, "entering");
  1889. parm = (iparml_set_mask *)grab_param();
  1890. parm->ipmask = *((__u8*)result);
  1891. *((ulong *)result) = b2f0(SETMASK, parm);
  1892. release_param(parm);
  1893. iucv_debug(1, "b2f0_result = %ld", *((ulong *)result));
  1894. iucv_debug(1, "exiting");
  1895. }
  1896. /*
  1897. * Name: iucv_setmask
  1898. * Purpose: This function enables or disables the following IUCV
  1899. * external interruptions: Nonpriority and priority message
  1900. * interrupts, nonpriority and priority reply interrupts.
  1901. * Input: SetMaskFlag - options for interrupts
  1902. * 0x80 - Nonpriority_MessagePendingInterruptsFlag
  1903. * 0x40 - Priority_MessagePendingInterruptsFlag
  1904. * 0x20 - Nonpriority_MessageCompletionInterruptsFlag
  1905. * 0x10 - Priority_MessageCompletionInterruptsFlag
  1906. * 0x08 - IUCVControlInterruptsFlag
  1907. * Output: NA
  1908. * Return: b2f0_result - return code from CP
  1909. */
  1910. int
  1911. iucv_setmask (int SetMaskFlag)
  1912. {
  1913. union {
  1914. ulong result;
  1915. __u8 param;
  1916. } u;
  1917. int cpu;
  1918. u.param = SetMaskFlag;
  1919. cpu = get_cpu();
  1920. smp_call_function_on(iucv_setmask_cpuid, &u, 0, 1, iucv_cpuid);
  1921. put_cpu();
  1922. return u.result;
  1923. }
  1924. /**
  1925. * iucv_sever:
  1926. * @pathid: Path identification number
  1927. * @user_data: 16-byte of user data
  1928. *
  1929. * This function terminates an iucv path.
  1930. * Returns: return code from CP
  1931. */
  1932. int
  1933. iucv_sever(__u16 pathid, __u8 user_data[16])
  1934. {
  1935. iparml_control *parm;
  1936. ulong b2f0_result = 0;
  1937. iucv_debug(1, "entering");
  1938. parm = (iparml_control *)grab_param();
  1939. memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
  1940. parm->ippathid = pathid;
  1941. b2f0_result = b2f0(SEVER, parm);
  1942. if (!b2f0_result)
  1943. iucv_remove_pathid(pathid);
  1944. release_param(parm);
  1945. iucv_debug(1, "exiting");
  1946. return b2f0_result;
  1947. }
  1948. /*
  1949. * Interrupt Handlers
  1950. *******************************************************************************/
  1951. /**
  1952. * iucv_irq_handler:
  1953. * @regs: Current registers
  1954. * @code: irq code
  1955. *
  1956. * Handles external interrupts coming in from CP.
  1957. * Places the interrupt buffer on a queue and schedules iucv_tasklet_handler().
  1958. */
  1959. static void
  1960. iucv_irq_handler(struct pt_regs *regs, __u16 code)
  1961. {
  1962. iucv_irqdata *irqdata;
  1963. irqdata = kmalloc(sizeof(iucv_irqdata), GFP_ATOMIC);
  1964. if (!irqdata) {
  1965. printk(KERN_WARNING "%s: out of memory\n", __FUNCTION__);
  1966. return;
  1967. }
  1968. memcpy(&irqdata->data, iucv_external_int_buffer,
  1969. sizeof(iucv_GeneralInterrupt));
  1970. spin_lock(&iucv_irq_queue_lock);
  1971. list_add_tail(&irqdata->queue, &iucv_irq_queue);
  1972. spin_unlock(&iucv_irq_queue_lock);
  1973. tasklet_schedule(&iucv_tasklet);
  1974. }
  1975. /**
  1976. * iucv_do_int:
  1977. * @int_buf: Pointer to copy of external interrupt buffer
  1978. *
  1979. * The workhorse for handling interrupts queued by iucv_irq_handler().
  1980. * This function is called from the bottom half iucv_tasklet_handler().
  1981. */
  1982. static void
  1983. iucv_do_int(iucv_GeneralInterrupt * int_buf)
  1984. {
  1985. handler *h = NULL;
  1986. struct list_head *lh;
  1987. ulong flags;
  1988. iucv_interrupt_ops_t *interrupt = NULL; /* interrupt addresses */
  1989. __u8 temp_buff1[24], temp_buff2[24]; /* masked handler id. */
  1990. int rc = 0, j = 0;
  1991. __u8 no_listener[16] = "NO LISTENER";
  1992. iucv_debug(2, "entering, pathid %d, type %02X",
  1993. int_buf->ippathid, int_buf->iptype);
  1994. iucv_dumpit("External Interrupt Buffer:",
  1995. int_buf, sizeof(iucv_GeneralInterrupt));
  1996. ASCEBC (no_listener, 16);
  1997. if (int_buf->iptype != 01) {
  1998. if ((int_buf->ippathid) > (max_connections - 1)) {
  1999. printk(KERN_WARNING "%s: Got interrupt with pathid %d"
  2000. " > max_connections (%ld)\n", __FUNCTION__,
  2001. int_buf->ippathid, max_connections - 1);
  2002. } else {
  2003. h = iucv_pathid_table[int_buf->ippathid];
  2004. interrupt = h->interrupt_table;
  2005. iucv_dumpit("Handler:", h, sizeof(handler));
  2006. }
  2007. }
  2008. /* end of if statement */
  2009. switch (int_buf->iptype) {
  2010. case 0x01: /* connection pending */
  2011. if (messagesDisabled) {
  2012. iucv_setmask(~0);
  2013. messagesDisabled = 0;
  2014. }
  2015. spin_lock_irqsave(&iucv_lock, flags);
  2016. list_for_each(lh, &iucv_handler_table) {
  2017. h = list_entry(lh, handler, list);
  2018. memcpy(temp_buff1, &(int_buf->ipvmid), 24);
  2019. memcpy(temp_buff2, &(h->id.userid), 24);
  2020. for (j = 0; j < 24; j++) {
  2021. temp_buff1[j] &= (h->id.mask)[j];
  2022. temp_buff2[j] &= (h->id.mask)[j];
  2023. }
  2024. iucv_dumpit("temp_buff1:",
  2025. temp_buff1, sizeof(temp_buff1));
  2026. iucv_dumpit("temp_buff2",
  2027. temp_buff2, sizeof(temp_buff2));
  2028. if (!memcmp (temp_buff1, temp_buff2, 24)) {
  2029. iucv_debug(2,
  2030. "found a matching handler");
  2031. break;
  2032. } else
  2033. h = NULL;
  2034. }
  2035. spin_unlock_irqrestore (&iucv_lock, flags);
  2036. if (h) {
  2037. /* ADD PATH TO PATHID TABLE */
  2038. rc = iucv_add_pathid(int_buf->ippathid, h);
  2039. if (rc) {
  2040. iucv_sever (int_buf->ippathid,
  2041. no_listener);
  2042. iucv_debug(1,
  2043. "add_pathid failed, rc = %d",
  2044. rc);
  2045. } else {
  2046. interrupt = h->interrupt_table;
  2047. if (interrupt->ConnectionPending) {
  2048. EBCASC (int_buf->ipvmid, 8);
  2049. interrupt->ConnectionPending(
  2050. (iucv_ConnectionPending *)int_buf,
  2051. h->pgm_data);
  2052. } else
  2053. iucv_sever(int_buf->ippathid,
  2054. no_listener);
  2055. }
  2056. } else
  2057. iucv_sever(int_buf->ippathid, no_listener);
  2058. break;
  2059. case 0x02: /*connection complete */
  2060. if (messagesDisabled) {
  2061. iucv_setmask(~0);
  2062. messagesDisabled = 0;
  2063. }
  2064. if (h) {
  2065. if (interrupt->ConnectionComplete)
  2066. {
  2067. interrupt->ConnectionComplete(
  2068. (iucv_ConnectionComplete *)int_buf,
  2069. h->pgm_data);
  2070. }
  2071. else
  2072. iucv_debug(1,
  2073. "ConnectionComplete not called");
  2074. } else
  2075. iucv_sever(int_buf->ippathid, no_listener);
  2076. break;
  2077. case 0x03: /* connection severed */
  2078. if (messagesDisabled) {
  2079. iucv_setmask(~0);
  2080. messagesDisabled = 0;
  2081. }
  2082. if (h) {
  2083. if (interrupt->ConnectionSevered)
  2084. interrupt->ConnectionSevered(
  2085. (iucv_ConnectionSevered *)int_buf,
  2086. h->pgm_data);
  2087. else
  2088. iucv_sever (int_buf->ippathid, no_listener);
  2089. } else
  2090. iucv_sever(int_buf->ippathid, no_listener);
  2091. break;
  2092. case 0x04: /* connection quiesced */
  2093. if (messagesDisabled) {
  2094. iucv_setmask(~0);
  2095. messagesDisabled = 0;
  2096. }
  2097. if (h) {
  2098. if (interrupt->ConnectionQuiesced)
  2099. interrupt->ConnectionQuiesced(
  2100. (iucv_ConnectionQuiesced *)int_buf,
  2101. h->pgm_data);
  2102. else
  2103. iucv_debug(1,
  2104. "ConnectionQuiesced not called");
  2105. }
  2106. break;
  2107. case 0x05: /* connection resumed */
  2108. if (messagesDisabled) {
  2109. iucv_setmask(~0);
  2110. messagesDisabled = 0;
  2111. }
  2112. if (h) {
  2113. if (interrupt->ConnectionResumed)
  2114. interrupt->ConnectionResumed(
  2115. (iucv_ConnectionResumed *)int_buf,
  2116. h->pgm_data);
  2117. else
  2118. iucv_debug(1,
  2119. "ConnectionResumed not called");
  2120. }
  2121. break;
  2122. case 0x06: /* priority message complete */
  2123. case 0x07: /* nonpriority message complete */
  2124. if (h) {
  2125. if (interrupt->MessageComplete)
  2126. interrupt->MessageComplete(
  2127. (iucv_MessageComplete *)int_buf,
  2128. h->pgm_data);
  2129. else
  2130. iucv_debug(2,
  2131. "MessageComplete not called");
  2132. }
  2133. break;
  2134. case 0x08: /* priority message pending */
  2135. case 0x09: /* nonpriority message pending */
  2136. if (h) {
  2137. if (interrupt->MessagePending)
  2138. interrupt->MessagePending(
  2139. (iucv_MessagePending *) int_buf,
  2140. h->pgm_data);
  2141. else
  2142. iucv_debug(2,
  2143. "MessagePending not called");
  2144. }
  2145. break;
  2146. default: /* unknown iucv type */
  2147. printk(KERN_WARNING "%s: unknown iucv interrupt\n",
  2148. __FUNCTION__);
  2149. break;
  2150. } /* end switch */
  2151. iucv_debug(2, "exiting pathid %d, type %02X",
  2152. int_buf->ippathid, int_buf->iptype);
  2153. return;
  2154. }
  2155. /**
  2156. * iucv_tasklet_handler:
  2157. *
  2158. * This function loops over the queue of irq buffers and runs iucv_do_int()
  2159. * on every queue element.
  2160. */
  2161. static void
  2162. iucv_tasklet_handler(unsigned long ignored)
  2163. {
  2164. struct list_head head;
  2165. struct list_head *next;
  2166. ulong flags;
  2167. spin_lock_irqsave(&iucv_irq_queue_lock, flags);
  2168. list_add(&head, &iucv_irq_queue);
  2169. list_del_init(&iucv_irq_queue);
  2170. spin_unlock_irqrestore (&iucv_irq_queue_lock, flags);
  2171. next = head.next;
  2172. while (next != &head) {
  2173. iucv_irqdata *p = list_entry(next, iucv_irqdata, queue);
  2174. next = next->next;
  2175. iucv_do_int(&p->data);
  2176. kfree(p);
  2177. }
  2178. return;
  2179. }
  2180. subsys_initcall(iucv_init);
  2181. module_exit(iucv_exit);
  2182. /**
  2183. * Export all public stuff
  2184. */
  2185. EXPORT_SYMBOL (iucv_bus);
  2186. EXPORT_SYMBOL (iucv_root);
  2187. EXPORT_SYMBOL (iucv_accept);
  2188. EXPORT_SYMBOL (iucv_connect);
  2189. #if 0
  2190. EXPORT_SYMBOL (iucv_purge);
  2191. EXPORT_SYMBOL (iucv_query_maxconn);
  2192. EXPORT_SYMBOL (iucv_query_bufsize);
  2193. EXPORT_SYMBOL (iucv_quiesce);
  2194. #endif
  2195. EXPORT_SYMBOL (iucv_receive);
  2196. #if 0
  2197. EXPORT_SYMBOL (iucv_receive_array);
  2198. #endif
  2199. EXPORT_SYMBOL (iucv_reject);
  2200. #if 0
  2201. EXPORT_SYMBOL (iucv_reply);
  2202. EXPORT_SYMBOL (iucv_reply_array);
  2203. EXPORT_SYMBOL (iucv_resume);
  2204. #endif
  2205. EXPORT_SYMBOL (iucv_reply_prmmsg);
  2206. EXPORT_SYMBOL (iucv_send);
  2207. EXPORT_SYMBOL (iucv_send2way);
  2208. EXPORT_SYMBOL (iucv_send2way_array);
  2209. EXPORT_SYMBOL (iucv_send2way_prmmsg);
  2210. EXPORT_SYMBOL (iucv_send2way_prmmsg_array);
  2211. #if 0
  2212. EXPORT_SYMBOL (iucv_send_array);
  2213. EXPORT_SYMBOL (iucv_send_prmmsg);
  2214. EXPORT_SYMBOL (iucv_setmask);
  2215. #endif
  2216. EXPORT_SYMBOL (iucv_sever);
  2217. EXPORT_SYMBOL (iucv_register_program);
  2218. EXPORT_SYMBOL (iucv_unregister_program);