4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
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)
14 * CP Programming Service, IBM document # SC24-5760
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)
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.
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.
34 #include <linux/module.h>
35 #include <linux/moduleparam.h>
36 #include <linux/config.h>
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>
50 #include <asm/s390_ext.h>
51 #include <asm/ebcdic.h>
53 #include <asm/s390_rdev.h>
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
64 * IPBUFLST - Indicates that you are using an address list for
76 iucv_bus_match (struct device
*dev
, struct device_driver
*drv
)
81 struct bus_type iucv_bus
= {
83 .match
= iucv_bus_match
,
86 struct device
*iucv_root
;
88 /* General IUCV interrupt structure */
96 } iucv_GeneralInterrupt
;
98 static iucv_GeneralInterrupt
*iucv_external_int_buffer
= NULL
;
100 /* Spin Lock declaration */
102 static DEFINE_SPINLOCK(iucv_lock
);
104 static int messagesDisabled
= 0;
106 /***************INTERRUPT HANDLING ***************/
109 struct list_head queue
;
110 iucv_GeneralInterrupt data
;
113 static struct list_head iucv_irq_queue
;
114 static DEFINE_SPINLOCK(iucv_irq_queue_lock
);
117 *Internal function prototypes
119 static void iucv_tasklet_handler(unsigned long);
120 static void iucv_irq_handler(struct pt_regs
*, __u16
);
122 static DECLARE_TASKLET(iucv_tasklet
,iucv_tasklet_handler
,0);
124 /************ FUNCTION ID'S ****************************/
128 #define DECLARE_BUFFER 12
136 #define RETRIEVE_BUFFER 2
143 * members: list - list management.
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
152 typedef struct handler_t
{
153 struct list_head list
;
159 iucv_interrupt_ops_t
*interrupt_table
;
164 * iucv_handler_table: List of registered handlers.
166 static struct list_head iucv_handler_table
;
169 * iucv_pathid_table: an array of *handler pointing into
170 * iucv_handler_table for fast indexing by pathid;
172 static handler
**iucv_pathid_table
;
174 static unsigned long max_connections
;
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.
181 static int iucv_cpuid
= -1;
183 * register_flag: is 0 when external interrupt has not been registered
185 static int register_flag
;
187 /****************FIVE 40-BYTE PARAMETER STRUCTURES******************/
188 /* Data struct 1: iparml_control
189 * Used for iucv_accept
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
200 * Data struct 3: iparml_db (data in a buffer)
201 * Used for iucv_receive
209 * iucv_send2way_array
210 * iucv_declare_buffer
211 * Data struct 4: iparml_purge
212 * Used for iucv_purge
214 * Data struct 5: iparml_set_mask
215 * Used for iucv_set_mask
280 iparml_control p_ctrl
;
283 iparml_purge p_purge
;
284 iparml_set_mask p_set_mask
;
288 } __attribute__ ((aligned(8))) iucv_param
;
289 #define PARAM_POOL_SIZE (PAGE_SIZE / sizeof(iucv_param))
291 static iucv_param
* iucv_param_pool
;
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");
299 *******************************************************************************/
303 static int debuglevel
= 0;
305 module_param(debuglevel
, int, 0);
306 MODULE_PARM_DESC(debuglevel
,
307 "Specifies the debug level (0=off ... 3=all)");
310 iucv_dumpit(char *title
, void *buf
, int len
)
313 __u8
*p
= (__u8
*)buf
;
318 printk(KERN_DEBUG
"%s\n", title
);
320 for (i
= 0; i
< len
; i
++) {
321 if (!(i
% 16) && i
!= 0)
323 else if (!(i
% 4) && i
!= 0)
325 printk("%02X", *p
++);
331 #define iucv_debug(lvl, fmt, args...) \
333 if (debuglevel >= lvl) \
334 printk(KERN_DEBUG "%s: " fmt "\n", __FUNCTION__ , ## args); \
339 #define iucv_debug(lvl, fmt, args...)
340 #define iucv_dumpit(title, buf, len)
346 *******************************************************************************/
354 printk(KERN_INFO
"IUCV lowlevel driver initialized\n");
358 * iucv_init - Initialization
360 * Allocates and initializes various data structures.
367 if (iucv_external_int_buffer
)
370 if (!MACHINE_IS_VM
) {
371 printk(KERN_ERR
"IUCV: IUCV connection needs VM as base\n");
372 return -EPROTONOSUPPORT
;
375 ret
= bus_register(&iucv_bus
);
377 printk(KERN_ERR
"IUCV: failed to register bus.\n");
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
);
388 /* Note: GFP_DMA used used to get memory below 2G */
389 iucv_external_int_buffer
= kzalloc(sizeof(iucv_GeneralInterrupt
),
391 if (!iucv_external_int_buffer
) {
393 "%s: Could not allocate external interrupt buffer\n",
395 s390_root_dev_unregister(iucv_root
);
396 bus_unregister(&iucv_bus
);
400 /* Initialize parameter pool */
401 iucv_param_pool
= kzalloc(sizeof(iucv_param
) * PARAM_POOL_SIZE
,
403 if (!iucv_param_pool
) {
404 printk(KERN_WARNING
"%s: Could not allocate param pool\n",
406 kfree(iucv_external_int_buffer
);
407 iucv_external_int_buffer
= NULL
;
408 s390_root_dev_unregister(iucv_root
);
409 bus_unregister(&iucv_bus
);
413 /* Initialize irq queue */
414 INIT_LIST_HEAD(&iucv_irq_queue
);
416 /* Initialize handler table */
417 INIT_LIST_HEAD(&iucv_handler_table
);
424 * iucv_exit - De-Initialization
426 * Frees everything allocated from iucv_init.
428 static int iucv_retrieve_buffer (void);
433 iucv_retrieve_buffer();
434 kfree(iucv_external_int_buffer
);
435 iucv_external_int_buffer
= NULL
;
436 kfree(iucv_param_pool
);
437 iucv_param_pool
= NULL
;
438 s390_root_dev_unregister(iucv_root
);
439 bus_unregister(&iucv_bus
);
440 printk(KERN_INFO
"IUCV lowlevel driver unloaded\n");
444 * grab_param: - Get a parameter buffer from the pre-allocated pool.
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.
451 * Returns: A pointer to iucv_param.
453 static __inline__ iucv_param
*
459 ptr
= iucv_param_pool
+ hint
;
462 if (ptr
>= iucv_param_pool
+ PARAM_POOL_SIZE
)
463 ptr
= iucv_param_pool
;
464 } while (atomic_cmpxchg(&ptr
->in_use
, 0, 1) != 0);
465 hint
= ptr
- iucv_param_pool
;
467 memset(&ptr
->param
, 0, sizeof(ptr
->param
));
472 * release_param - Release a parameter buffer.
473 * @p: A pointer to a struct iucv_param, previously obtained by calling
476 * This function marks the specified parameter buffer "unused".
478 static __inline__
void
479 release_param(void *p
)
481 atomic_set(&((iucv_param
*)p
)->in_use
, 0);
485 * iucv_add_handler: - Add a new handler
486 * @new_handler: handle that is being entered into chain.
488 * Places new handle on iucv_handler_table, if identical handler is not
491 * Returns: 0 on success, !0 on failure (handler already in chain).
494 iucv_add_handler (handler
*new)
498 iucv_debug(1, "entering");
499 iucv_dumpit("handler:", new, sizeof(handler
));
501 spin_lock_irqsave (&iucv_lock
, flags
);
502 if (!list_empty(&iucv_handler_table
)) {
503 struct list_head
*lh
;
506 * Search list for handler with identical id. If one
507 * is found, the new handler is _not_ added.
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
);
519 * If we get here, no handler was found.
521 INIT_LIST_HEAD(&new->list
);
522 list_add(&new->list
, &iucv_handler_table
);
523 spin_unlock_irqrestore (&iucv_lock
, flags
);
525 iucv_debug(1, "exiting");
531 * @code: identifier of IUCV call to CP.
532 * @parm: pointer to 40 byte iparml area passed to CP
534 * Calls CP to execute IUCV commands.
536 * Returns: return code from CP's IUCV call
538 static __inline__ ulong
539 b2f0(__u32 code
, void *parm
)
541 iucv_dumpit("iparml before b2f0 call:", parm
, sizeof(iucv_param
));
548 : "d" (code
), "a" (parm
)
552 iucv_dumpit("iparml after b2f0 call:", parm
, sizeof(iucv_param
));
554 return (unsigned long)*((__u8
*)(parm
+ 3));
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
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
569 __iucv_add_pathid(__u16 pathid
, handler
*handler
)
572 iucv_debug(1, "entering");
574 iucv_debug(1, "handler is pointing to %p", handler
);
576 if (pathid
> (max_connections
- 1))
579 if (iucv_pathid_table
[pathid
]) {
580 iucv_debug(1, "pathid entry is %p", iucv_pathid_table
[pathid
]);
582 "%s: Pathid being used, error.\n", __FUNCTION__
);
585 iucv_pathid_table
[pathid
] = handler
;
587 iucv_debug(1, "exiting");
589 } /* end of add_pathid function */
592 iucv_add_pathid(__u16 pathid
, handler
*handler
)
597 spin_lock_irqsave (&iucv_lock
, flags
);
598 rc
= __iucv_add_pathid(pathid
, handler
);
599 spin_unlock_irqrestore (&iucv_lock
, flags
);
604 iucv_remove_pathid(__u16 pathid
)
608 if (pathid
> (max_connections
- 1))
611 spin_lock_irqsave (&iucv_lock
, flags
);
612 iucv_pathid_table
[pathid
] = NULL
;
613 spin_unlock_irqrestore (&iucv_lock
, flags
);
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().
622 iucv_declare_buffer_cpuid (void *result
)
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
;
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().
640 iucv_retrieve_buffer_cpuid (void *cpu
)
642 iparml_control
*parm
;
644 parm
= (iparml_control
*)grab_param();
645 b2f0(RETRIEVE_BUFFER
, parm
);
650 * Name: iucv_declare_buffer
651 * Purpose: Specifies the guests real address of an external
654 * Output: iprcode - return code from b2f0 call
657 iucv_declare_buffer (void)
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
);
672 smp_put_cpu(iucv_cpuid
);
675 iucv_debug(1, "Address of EIB = %p", iucv_external_int_buffer
);
677 spin_unlock_irqrestore (&iucv_lock
, flags
);
680 iucv_debug(1, "exiting");
685 * iucv_retrieve_buffer:
687 * Terminates all use of IUCV.
688 * Returns: return code from CP
691 iucv_retrieve_buffer (void)
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
);
701 iucv_debug(1, "exiting");
706 * iucv_remove_handler:
707 * @users_handler: handler to be removed
709 * Remove handler when application unregisters.
712 iucv_remove_handler(handler
*handler
)
716 if ((!iucv_pathid_table
) || (!handler
))
719 iucv_debug(1, "entering");
721 spin_lock_irqsave (&iucv_lock
, flags
);
722 list_del(&handler
->list
);
723 if (list_empty(&iucv_handler_table
)) {
725 unregister_external_interrupt(0x4000, iucv_irq_handler
);
729 spin_unlock_irqrestore (&iucv_lock
, flags
);
731 iucv_debug(1, "exiting");
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.
744 * Registers an application with IUCV.
746 * The address of handler, or NULL on failure.
748 * If pgmname, userid and pgmmask are provided, pgmmask is entered into the
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
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.
758 iucv_register_program (__u8 pgmname
[16],
761 iucv_interrupt_ops_t
* ops
, void *pgm_data
)
763 ulong rc
= 0; /* return code from function calls */
764 handler
*new_handler
;
766 iucv_debug(1, "entering");
769 /* interrupt table is not defined */
770 printk(KERN_WARNING
"%s: Interrupt table is not defined, "
771 "exiting\n", __FUNCTION__
);
775 printk(KERN_WARNING
"%s: pgmname not provided\n", __FUNCTION__
);
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__
);
787 if (!iucv_pathid_table
) {
793 max_connections
= iucv_query_maxconn();
794 iucv_pathid_table
= kcalloc(max_connections
, sizeof(handler
*),
796 if (iucv_pathid_table
== NULL
) {
797 printk(KERN_WARNING
"%s: iucv_pathid_table storage "
798 "allocation failed\n", __FUNCTION__
);
803 memset(new_handler
, 0, sizeof (handler
));
804 memcpy(new_handler
->id
.user_data
, pgmname
,
805 sizeof (new_handler
->id
.user_data
));
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
));
815 memcpy (new_handler
->id
.mask
, pgmmask
,
816 sizeof (new_handler
->id
.mask
));
818 memset (new_handler
->id
.mask
, 0xFF,
819 sizeof (new_handler
->id
.mask
));
823 memcpy (new_handler
->id
.mask
, pgmmask
,
824 sizeof (new_handler
->id
.mask
));
826 memset (new_handler
->id
.mask
, 0xFF,
827 sizeof (new_handler
->id
.mask
));
829 memset (new_handler
->id
.userid
, 0x00,
830 sizeof (new_handler
->id
.userid
));
832 /* fill in the rest of handler */
833 new_handler
->pgm_data
= pgm_data
;
834 new_handler
->interrupt_table
= ops
;
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.
843 rc
= iucv_add_handler(new_handler
);
845 printk(KERN_WARNING
"%s: Someone already registered with same "
846 "pgmname, userid, pgmmask\n", __FUNCTION__
);
851 rc
= iucv_declare_buffer();
853 char *err
= "Unknown";
854 iucv_remove_handler(new_handler
);
858 err
= "Directory error";
861 err
= "Invalid length";
864 err
= "Buffer already exists";
867 err
= "Buffer overlap";
870 err
= "Paging or storage error";
873 printk(KERN_WARNING
"%s: iucv_declare_buffer "
874 "returned error 0x%02lx (%s)\n", __FUNCTION__
, rc
, err
);
877 if (!register_flag
) {
878 /* request the 0x4000 external interrupt */
879 rc
= register_external_interrupt (0x4000, iucv_irq_handler
);
881 iucv_remove_handler(new_handler
);
883 printk(KERN_WARNING
"%s: "
884 "register_external_interrupt returned %ld\n",
891 iucv_debug(1, "exiting");
893 } /* end of register function */
896 * iucv_unregister_program:
897 * @handle: address of handler
899 * Unregister application with IUCV.
901 * 0 on success, -EINVAL, if specified handle is invalid.
905 iucv_unregister_program (iucv_handle_t handle
)
908 struct list_head
*lh
;
912 iucv_debug(1, "entering");
913 iucv_debug(1, "address of handler is %p", h
);
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
;
924 spin_unlock_irqrestore (&iucv_lock
, flags
);
927 "%s: Handler not found in iucv_handler_table.\n",
931 "%s: NULL handle passed by application.\n",
937 * First, walk thru iucv_pathid_table and sever any pathid which is
938 * still pointing to the handler to be removed.
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
);
946 spin_unlock_irqrestore (&iucv_lock
, flags
);
948 iucv_remove_handler(h
);
951 iucv_debug(1, "exiting");
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
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
975 * This function is issued after the user receives a Connection Pending external
976 * interrupt and now wishes to complete the IUCV communication path.
978 * return code from CP
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
)
986 ulong b2f0_result
= 0;
988 struct list_head
*lh
;
990 iparml_control
*parm
;
992 iucv_debug(1, "entering");
993 iucv_debug(1, "pathid = %d", pathid
);
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
;
1003 spin_unlock_irqrestore (&iucv_lock
, flags
);
1008 "%s: Handler not found in iucv_handler_table.\n",
1012 "%s: NULL handle passed by application.\n",
1017 parm
= (iparml_control
*)grab_param();
1019 parm
->ippathid
= pathid
;
1020 parm
->ipmsglim
= msglim_reqstd
;
1022 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
1024 parm
->ipflags1
= (__u8
)flags1
;
1025 b2f0_result
= b2f0(ACCEPT
, parm
);
1029 *msglim
= parm
->ipmsglim
;
1031 h
->pgm_data
= pgm_data
;
1033 *flags1_out
= (parm
->ipflags1
& IPPRTY
) ? IPPRTY
: 0;
1035 release_param(parm
);
1037 iucv_debug(1, "exiting");
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
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
1063 * @handle: Address of handler.
1064 * @pgm_data: Application data to be passed to interrupt handlers.
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
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
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
)
1084 iparml_control
*parm
;
1085 iparml_control local_parm
;
1086 struct list_head
*lh
;
1087 ulong b2f0_result
= 0;
1089 int add_pathid_result
= 0;
1091 __u8 no_memory
[16] = "NO MEMORY";
1093 iucv_debug(1, "entering");
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
;
1103 spin_unlock_irqrestore (&iucv_lock
, flags
);
1108 "%s: Handler not found in iucv_handler_table.\n",
1112 "%s: NULL handle passed by application.\n",
1117 if (pathid
== NULL
) {
1118 printk(KERN_WARNING
"%s: NULL pathid pointer\n",
1123 parm
= (iparml_control
*)grab_param();
1125 parm
->ipmsglim
= msglim_reqstd
;
1128 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
1131 memcpy(parm
->ipvmid
, userid
, sizeof(parm
->ipvmid
));
1132 ASCEBC(parm
->ipvmid
, sizeof(parm
->ipvmid
));
1133 EBC_TOUPPER(parm
->ipvmid
, sizeof(parm
->ipvmid
));
1137 memcpy(parm
->iptarget
, system_name
, sizeof(parm
->iptarget
));
1138 ASCEBC(parm
->iptarget
, sizeof(parm
->iptarget
));
1139 EBC_TOUPPER(parm
->iptarget
, sizeof(parm
->iptarget
));
1142 /* In order to establish an IUCV connection, the procedure is:
1145 * take the ippathid from the b2f0 call
1146 * register the handler to the ippathid
1148 * Unfortunately, the ConnectionEstablished message gets sent after the
1149 * b2f0(CONNECT) call but before the register is handled.
1151 * In order for this race condition to be eliminated, the IUCV Control
1152 * Interrupts must be disabled for the above procedure.
1154 * David Kennedy <dkennedy@linuxcare.com>
1157 /* Enable everything but IUCV Control messages */
1158 iucv_setmask(~(AllInterrupts
));
1159 messagesDisabled
= 1;
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
);
1168 add_pathid_result
= __iucv_add_pathid(parm
->ippathid
, h
);
1169 spin_unlock_irqrestore (&iucv_lock
, flags
);
1173 messagesDisabled
= 0;
1177 *pathid
= parm
->ippathid
;
1179 /* Enable everything again */
1180 iucv_setmask(IUCVControlInterruptsFlag
);
1183 *msglim
= parm
->ipmsglim
;
1185 *flags1_out
= (parm
->ipflags1
& IPPRTY
) ? IPPRTY
: 0;
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
);
1194 iucv_debug(1, "exiting");
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.
1207 * Cancels a message you have sent.
1208 * Returns: return code from CP
1211 iucv_purge (__u16 pathid
, __u32 msgid
, __u32 srccls
, __u32
*audit
)
1214 ulong b2f0_result
= 0;
1216 iucv_debug(1, "entering");
1217 iucv_debug(1, "pathid = %d", pathid
);
1219 parm
= (iparml_purge
*)grab_param();
1221 parm
->ipmsgid
= msgid
;
1222 parm
->ippathid
= pathid
;
1223 parm
->ipsrccls
= srccls
;
1224 parm
->ipflags1
|= (IPSRCCLS
| IPFGMID
| IPFGPID
);
1225 b2f0_result
= b2f0(PURGE
, parm
);
1227 if (!b2f0_result
&& audit
) {
1228 memcpy(audit
, parm
->ipaudit
, sizeof(parm
->ipaudit
));
1229 /* parm->ipaudit has only 3 bytes */
1233 release_param(parm
);
1235 iucv_debug(1, "b2f0_result = %ld", b2f0_result
);
1236 iucv_debug(1, "exiting");
1241 * iucv_query_generic:
1242 * @want_maxconn: Flag, describing which value is to be returned.
1244 * Helper function for iucv_query_maxconn() and iucv_query_bufsize().
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.
1250 iucv_query_generic(int want_maxconn
)
1252 iparml_purge
*parm
= (iparml_purge
*)grab_param();
1253 int bufsize
, maxconn
;
1257 * Call b2f0 and store R0 (max buffer size),
1258 * R1 (max connections) and CC.
1263 ".long 0xb2f01000\n\t"
1268 : "=d" (ccode
), "=m" (bufsize
), "=m" (maxconn
)
1269 : "d" (QUERY
), "a" (parm
)
1272 release_param(parm
);
1282 * iucv_query_maxconn:
1284 * Determines the maximum number of connections thay may be established.
1286 * Returns: Maximum number of connections that can be.
1289 iucv_query_maxconn(void)
1291 return iucv_query_generic(1);
1295 * iucv_query_bufsize:
1297 * Determines the size of the external interrupt buffer.
1299 * Returns: Size of external interrupt buffer.
1302 iucv_query_bufsize (void)
1304 return iucv_query_generic(0);
1309 * @pathid: Path identification number
1310 * @user_data: 16-byte user data
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
1317 iucv_quiesce (__u16 pathid
, __u8 user_data
[16])
1319 iparml_control
*parm
;
1320 ulong b2f0_result
= 0;
1322 iucv_debug(1, "entering");
1323 iucv_debug(1, "pathid = %d", pathid
);
1325 parm
= (iparml_control
*)grab_param();
1327 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
1328 parm
->ippathid
= pathid
;
1330 b2f0_result
= b2f0(QUIESCE
, parm
);
1331 release_param(parm
);
1333 iucv_debug(1, "b2f0_result = %ld", b2f0_result
);
1334 iucv_debug(1, "exiting");
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
1355 * - Remaining bytes in buffer If the receive buffer is longer than the
1357 * - Remaining bytes in message If the receive buffer is shorter than the
1360 * This function receives messages that are being sent to you over established
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
1367 iucv_receive (__u16 pathid
, __u32 msgid
, __u32 trgcls
,
1368 void *buffer
, ulong buflen
,
1369 int *flags1_out
, ulong
* residual_buffer
, ulong
* residual_length
)
1373 int moved
= 0; /* number of bytes moved from parmlist to buffer */
1375 iucv_debug(2, "entering");
1380 parm
= (iparml_db
*)grab_param();
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
);
1389 b2f0_result
= b2f0(RECEIVE
, parm
);
1391 if (!b2f0_result
|| b2f0_result
== 5) {
1393 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1394 *flags1_out
= (parm
->ipflags1
& (~0x07));
1395 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1398 if (!(parm
->ipflags1
& IPRMDATA
)) { /*msg not in parmlist */
1399 if (residual_length
)
1400 *residual_length
= parm
->ipbfln1f
;
1402 if (residual_buffer
)
1403 *residual_buffer
= parm
->ipbfadr1
;
1405 moved
= min_t (unsigned long, buflen
, 8);
1407 memcpy ((char *) buffer
,
1408 (char *) &parm
->ipbfadr1
, moved
);
1413 if (residual_length
)
1414 *residual_length
= abs (buflen
- 8);
1416 if (residual_buffer
)
1417 *residual_buffer
= (ulong
) (buffer
+ moved
);
1420 release_param(parm
);
1422 iucv_debug(2, "exiting");
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
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
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
1451 * Return: b2f0_result - return code from CP
1452 * (-EINVAL) - buffer address is NULL
1455 iucv_receive_array (__u16 pathid
,
1456 __u32 msgid
, __u32 trgcls
,
1457 iucv_array_t
* buffer
, ulong buflen
,
1459 ulong
* residual_buffer
, ulong
* residual_length
)
1463 int i
= 0, moved
= 0, need_to_move
= 8, dyn_len
;
1465 iucv_debug(2, "entering");
1470 parm
= (iparml_db
*)grab_param();
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
);
1479 b2f0_result
= b2f0(RECEIVE
, parm
);
1481 if (!b2f0_result
|| b2f0_result
== 5) {
1484 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1485 *flags1_out
= (parm
->ipflags1
& (~0x07));
1486 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1489 if (!(parm
->ipflags1
& IPRMDATA
)) { /*msg not in parmlist */
1491 if (residual_length
)
1492 *residual_length
= parm
->ipbfln1f
;
1494 if (residual_buffer
)
1495 *residual_buffer
= parm
->ipbfadr1
;
1498 /* copy msg from parmlist to users array. */
1500 while ((moved
< 8) && (moved
< buflen
)) {
1502 min_t (unsigned int,
1503 (buffer
+ i
)->length
, need_to_move
);
1505 memcpy ((char *)((ulong
)((buffer
+ i
)->address
)),
1506 ((char *) &parm
->ipbfadr1
) + moved
,
1510 need_to_move
-= dyn_len
;
1512 (buffer
+ i
)->address
=
1514 ((ulong
)(__u8
*) ((ulong
)(buffer
+ i
)->address
)
1517 (buffer
+ i
)->length
-= dyn_len
;
1521 if (need_to_move
) /* buflen < 8 bytes */
1524 if (residual_length
)
1525 *residual_length
= abs (buflen
- 8);
1527 if (residual_buffer
) {
1529 *residual_buffer
= (ulong
) buffer
;
1532 (ulong
) (buffer
+ (i
- 1));
1537 release_param(parm
);
1539 iucv_debug(2, "exiting");
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
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
1555 iucv_reject (__u16 pathid
, __u32 msgid
, __u32 trgcls
)
1558 ulong b2f0_result
= 0;
1560 iucv_debug(1, "entering");
1561 iucv_debug(1, "pathid = %d", pathid
);
1563 parm
= (iparml_db
*)grab_param();
1565 parm
->ippathid
= pathid
;
1566 parm
->ipmsgid
= msgid
;
1567 parm
->iptrgcls
= trgcls
;
1568 parm
->ipflags1
= (IPFGMCL
| IPFGMID
| IPFGPID
);
1570 b2f0_result
= b2f0(REJECT
, parm
);
1571 release_param(parm
);
1573 iucv_debug(1, "b2f0_result = %ld", b2f0_result
);
1574 iucv_debug(1, "exiting");
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
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
1606 iucv_reply (__u16 pathid
,
1607 __u32 msgid
, __u32 trgcls
,
1609 void *buffer
, ulong buflen
, ulong
* ipbfadr2
, ulong
* ipbfln2f
)
1614 iucv_debug(2, "entering");
1619 parm
= (iparml_db
*)grab_param();
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 */
1628 b2f0_result
= b2f0(REPLY
, parm
);
1630 if ((!b2f0_result
) || (b2f0_result
== 5)) {
1632 *ipbfadr2
= parm
->ipbfadr2
;
1634 *ipbfln2f
= parm
->ipbfln2f
;
1636 release_param(parm
);
1638 iucv_debug(2, "exiting");
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
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
1671 iucv_reply_array (__u16 pathid
,
1672 __u32 msgid
, __u32 trgcls
,
1674 iucv_array_t
* buffer
,
1675 ulong buflen
, ulong
* ipbfadr2
, ulong
* ipbfln2f
)
1680 iucv_debug(2, "entering");
1685 parm
= (iparml_db
*)grab_param();
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
);
1694 b2f0_result
= b2f0(REPLY
, parm
);
1696 if ((!b2f0_result
) || (b2f0_result
== 5)) {
1699 *ipbfadr2
= parm
->ipbfadr2
;
1701 *ipbfln2f
= parm
->ipbfln2f
;
1703 release_param(parm
);
1705 iucv_debug(2, "exiting");
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
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
1725 * Return: b2f0_result - return code from CP
1728 iucv_reply_prmmsg (__u16 pathid
,
1729 __u32 msgid
, __u32 trgcls
, int flags1
, __u8 prmmsg
[8])
1734 iucv_debug(2, "entering");
1736 parm
= (iparml_dpl
*)grab_param();
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
);
1744 b2f0_result
= b2f0(REPLY
, parm
);
1745 release_param(parm
);
1747 iucv_debug(2, "exiting");
1754 * @pathid: Path identification number
1755 * @user_data: 16-byte of user data
1757 * This function restores communication over a quiesced path.
1758 * Returns: return code from CP
1761 iucv_resume (__u16 pathid
, __u8 user_data
[16])
1763 iparml_control
*parm
;
1764 ulong b2f0_result
= 0;
1766 iucv_debug(1, "entering");
1767 iucv_debug(1, "pathid = %d", pathid
);
1769 parm
= (iparml_control
*)grab_param();
1771 memcpy (parm
->ipuser
, user_data
, sizeof (*user_data
));
1772 parm
->ippathid
= pathid
;
1774 b2f0_result
= b2f0(RESUME
, parm
);
1775 release_param(parm
);
1777 iucv_debug(1, "exiting");
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
1798 iucv_send (__u16 pathid
, __u32
* msgid
,
1799 __u32 trgcls
, __u32 srccls
,
1800 __u32 msgtag
, int flags1
, void *buffer
, ulong buflen
)
1805 iucv_debug(2, "entering");
1810 parm
= (iparml_db
*)grab_param();
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 */
1820 b2f0_result
= b2f0(SEND
, parm
);
1822 if ((!b2f0_result
) && (msgid
))
1823 *msgid
= parm
->ipmsgid
;
1824 release_param(parm
);
1826 iucv_debug(2, "exiting");
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
1851 iucv_send_array (__u16 pathid
,
1855 __u32 msgtag
, int flags1
, iucv_array_t
* buffer
, ulong buflen
)
1860 iucv_debug(2, "entering");
1865 parm
= (iparml_db
*)grab_param();
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
);
1876 if ((!b2f0_result
) && (msgid
))
1877 *msgid
= parm
->ipmsgid
;
1878 release_param(parm
);
1880 iucv_debug(2, "exiting");
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
1901 iucv_send_prmmsg (__u16 pathid
,
1904 __u32 srccls
, __u32 msgtag
, int flags1
, __u8 prmmsg
[8])
1909 iucv_debug(2, "entering");
1911 parm
= (iparml_dpl
*)grab_param();
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
));
1920 b2f0_result
= b2f0(SEND
, parm
);
1922 if ((!b2f0_result
) && (msgid
))
1923 *msgid
= parm
->ipmsgid
;
1924 release_param(parm
);
1926 iucv_debug(2, "exiting");
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
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
1953 iucv_send2way (__u16 pathid
,
1959 void *buffer
, ulong buflen
, void *ansbuf
, ulong anslen
)
1964 iucv_debug(2, "entering");
1966 if (!buffer
|| !ansbuf
)
1969 parm
= (iparml_db
*)grab_param();
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 */
1981 b2f0_result
= b2f0(SEND
, parm
);
1983 if ((!b2f0_result
) && (msgid
))
1984 *msgid
= parm
->ipmsgid
;
1985 release_param(parm
);
1987 iucv_debug(2, "exiting");
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
2015 iucv_send2way_array (__u16 pathid
,
2021 iucv_array_t
* buffer
,
2022 ulong buflen
, iucv_array_t
* ansbuf
, ulong anslen
)
2027 iucv_debug(2, "entering");
2029 if (!buffer
|| !ansbuf
)
2032 parm
= (iparml_db
*)grab_param();
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
);
2048 iucv_debug(2, "exiting");
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
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
2074 iucv_send2way_prmmsg (__u16 pathid
,
2079 ulong flags1
, __u8 prmmsg
[8], void *ansbuf
, ulong anslen
)
2084 iucv_debug(2, "entering");
2089 parm
= (iparml_dpl
*)grab_param();
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
));
2100 b2f0_result
= b2f0(SEND
, parm
);
2102 if ((!b2f0_result
) && (msgid
))
2103 *msgid
= parm
->ipmsgid
;
2104 release_param(parm
);
2106 iucv_debug(2, "exiting");
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
2135 iucv_send2way_prmmsg_array (__u16 pathid
,
2142 iucv_array_t
* ansbuf
, ulong anslen
)
2147 iucv_debug(2, "entering");
2152 parm
= (iparml_dpl
*)grab_param();
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
);
2167 iucv_debug(2, "exiting");
2172 iucv_setmask_cpuid (void *result
)
2174 iparml_set_mask
*parm
;
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
);
2182 iucv_debug(1, "b2f0_result = %ld", *((ulong
*)result
));
2183 iucv_debug(1, "exiting");
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
2198 * Return: b2f0_result - return code from CP
2201 iucv_setmask (int SetMaskFlag
)
2209 u
.param
= SetMaskFlag
;
2211 smp_call_function_on(iucv_setmask_cpuid
, &u
, 0, 1, iucv_cpuid
);
2219 * @pathid: Path identification number
2220 * @user_data: 16-byte of user data
2222 * This function terminates an iucv path.
2223 * Returns: return code from CP
2226 iucv_sever(__u16 pathid
, __u8 user_data
[16])
2228 iparml_control
*parm
;
2229 ulong b2f0_result
= 0;
2231 iucv_debug(1, "entering");
2232 parm
= (iparml_control
*)grab_param();
2234 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
2235 parm
->ippathid
= pathid
;
2237 b2f0_result
= b2f0(SEVER
, parm
);
2240 iucv_remove_pathid(pathid
);
2241 release_param(parm
);
2243 iucv_debug(1, "exiting");
2248 * Interrupt Handlers
2249 *******************************************************************************/
2253 * @regs: Current registers
2256 * Handles external interrupts coming in from CP.
2257 * Places the interrupt buffer on a queue and schedules iucv_tasklet_handler().
2260 iucv_irq_handler(struct pt_regs
*regs
, __u16 code
)
2262 iucv_irqdata
*irqdata
;
2264 irqdata
= kmalloc(sizeof(iucv_irqdata
), GFP_ATOMIC
);
2266 printk(KERN_WARNING
"%s: out of memory\n", __FUNCTION__
);
2270 memcpy(&irqdata
->data
, iucv_external_int_buffer
,
2271 sizeof(iucv_GeneralInterrupt
));
2273 spin_lock(&iucv_irq_queue_lock
);
2274 list_add_tail(&irqdata
->queue
, &iucv_irq_queue
);
2275 spin_unlock(&iucv_irq_queue_lock
);
2277 tasklet_schedule(&iucv_tasklet
);
2282 * @int_buf: Pointer to copy of external interrupt buffer
2284 * The workhorse for handling interrupts queued by iucv_irq_handler().
2285 * This function is called from the bottom half iucv_tasklet_handler().
2288 iucv_do_int(iucv_GeneralInterrupt
* int_buf
)
2291 struct list_head
*lh
;
2293 iucv_interrupt_ops_t
*interrupt
= NULL
; /* interrupt addresses */
2294 __u8 temp_buff1
[24], temp_buff2
[24]; /* masked handler id. */
2296 __u8 no_listener
[16] = "NO LISTENER";
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
));
2303 ASCEBC (no_listener
, 16);
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);
2311 h
= iucv_pathid_table
[int_buf
->ippathid
];
2312 interrupt
= h
->interrupt_table
;
2313 iucv_dumpit("Handler:", h
, sizeof(handler
));
2317 /* end of if statement */
2318 switch (int_buf
->iptype
) {
2319 case 0x01: /* connection pending */
2320 if (messagesDisabled
) {
2322 messagesDisabled
= 0;
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
];
2334 iucv_dumpit("temp_buff1:",
2335 temp_buff1
, sizeof(temp_buff1
));
2336 iucv_dumpit("temp_buff2",
2337 temp_buff2
, sizeof(temp_buff2
));
2339 if (!memcmp (temp_buff1
, temp_buff2
, 24)) {
2342 "found a matching handler");
2347 spin_unlock_irqrestore (&iucv_lock
, flags
);
2349 /* ADD PATH TO PATHID TABLE */
2350 rc
= iucv_add_pathid(int_buf
->ippathid
, h
);
2352 iucv_sever (int_buf
->ippathid
,
2355 "add_pathid failed, rc = %d",
2358 interrupt
= h
->interrupt_table
;
2359 if (interrupt
->ConnectionPending
) {
2360 EBCASC (int_buf
->ipvmid
, 8);
2361 interrupt
->ConnectionPending(
2362 (iucv_ConnectionPending
*)int_buf
,
2365 iucv_sever(int_buf
->ippathid
,
2369 iucv_sever(int_buf
->ippathid
, no_listener
);
2372 case 0x02: /*connection complete */
2373 if (messagesDisabled
) {
2375 messagesDisabled
= 0;
2378 if (interrupt
->ConnectionComplete
)
2380 interrupt
->ConnectionComplete(
2381 (iucv_ConnectionComplete
*)int_buf
,
2386 "ConnectionComplete not called");
2388 iucv_sever(int_buf
->ippathid
, no_listener
);
2391 case 0x03: /* connection severed */
2392 if (messagesDisabled
) {
2394 messagesDisabled
= 0;
2397 if (interrupt
->ConnectionSevered
)
2398 interrupt
->ConnectionSevered(
2399 (iucv_ConnectionSevered
*)int_buf
,
2403 iucv_sever (int_buf
->ippathid
, no_listener
);
2405 iucv_sever(int_buf
->ippathid
, no_listener
);
2408 case 0x04: /* connection quiesced */
2409 if (messagesDisabled
) {
2411 messagesDisabled
= 0;
2414 if (interrupt
->ConnectionQuiesced
)
2415 interrupt
->ConnectionQuiesced(
2416 (iucv_ConnectionQuiesced
*)int_buf
,
2420 "ConnectionQuiesced not called");
2424 case 0x05: /* connection resumed */
2425 if (messagesDisabled
) {
2427 messagesDisabled
= 0;
2430 if (interrupt
->ConnectionResumed
)
2431 interrupt
->ConnectionResumed(
2432 (iucv_ConnectionResumed
*)int_buf
,
2436 "ConnectionResumed not called");
2440 case 0x06: /* priority message complete */
2441 case 0x07: /* nonpriority message complete */
2443 if (interrupt
->MessageComplete
)
2444 interrupt
->MessageComplete(
2445 (iucv_MessageComplete
*)int_buf
,
2449 "MessageComplete not called");
2453 case 0x08: /* priority message pending */
2454 case 0x09: /* nonpriority message pending */
2456 if (interrupt
->MessagePending
)
2457 interrupt
->MessagePending(
2458 (iucv_MessagePending
*) int_buf
,
2462 "MessagePending not called");
2465 default: /* unknown iucv type */
2466 printk(KERN_WARNING
"%s: unknown iucv interrupt\n",
2471 iucv_debug(2, "exiting pathid %d, type %02X",
2472 int_buf
->ippathid
, int_buf
->iptype
);
2478 * iucv_tasklet_handler:
2480 * This function loops over the queue of irq buffers and runs iucv_do_int()
2481 * on every queue element.
2484 iucv_tasklet_handler(unsigned long ignored
)
2486 struct list_head head
;
2487 struct list_head
*next
;
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
);
2496 while (next
!= &head
) {
2497 iucv_irqdata
*p
= list_entry(next
, iucv_irqdata
, queue
);
2500 iucv_do_int(&p
->data
);
2507 subsys_initcall(iucv_init
);
2508 module_exit(iucv_exit
);
2511 * Export all public stuff
2513 EXPORT_SYMBOL (iucv_bus
);
2514 EXPORT_SYMBOL (iucv_root
);
2515 EXPORT_SYMBOL (iucv_accept
);
2516 EXPORT_SYMBOL (iucv_connect
);
2518 EXPORT_SYMBOL (iucv_purge
);
2519 EXPORT_SYMBOL (iucv_query_maxconn
);
2520 EXPORT_SYMBOL (iucv_query_bufsize
);
2521 EXPORT_SYMBOL (iucv_quiesce
);
2523 EXPORT_SYMBOL (iucv_receive
);
2525 EXPORT_SYMBOL (iucv_receive_array
);
2527 EXPORT_SYMBOL (iucv_reject
);
2529 EXPORT_SYMBOL (iucv_reply
);
2530 EXPORT_SYMBOL (iucv_reply_array
);
2531 EXPORT_SYMBOL (iucv_resume
);
2533 EXPORT_SYMBOL (iucv_reply_prmmsg
);
2534 EXPORT_SYMBOL (iucv_send
);
2535 EXPORT_SYMBOL (iucv_send2way
);
2536 EXPORT_SYMBOL (iucv_send2way_array
);
2537 EXPORT_SYMBOL (iucv_send2way_prmmsg
);
2538 EXPORT_SYMBOL (iucv_send2way_prmmsg_array
);
2540 EXPORT_SYMBOL (iucv_send_array
);
2541 EXPORT_SYMBOL (iucv_send_prmmsg
);
2542 EXPORT_SYMBOL (iucv_setmask
);
2544 EXPORT_SYMBOL (iucv_sever
);
2545 EXPORT_SYMBOL (iucv_register_program
);
2546 EXPORT_SYMBOL (iucv_unregister_program
);