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