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>
37 #include <linux/spinlock.h>
38 #include <linux/kernel.h>
39 #include <linux/slab.h>
40 #include <linux/init.h>
41 #include <linux/interrupt.h>
42 #include <linux/list.h>
43 #include <linux/errno.h>
44 #include <linux/err.h>
45 #include <linux/device.h>
46 #include <asm/atomic.h>
49 #include <asm/s390_ext.h>
50 #include <asm/ebcdic.h>
52 #include <asm/s390_rdev.h>
55 * All flags are defined in the field IPFLAGS1 of each function
56 * and can be found in CP Programming Services.
57 * IPSRCCLS - Indicates you have specified a source class
58 * IPFGMCL - Indicates you have specified a target class
59 * IPFGPID - Indicates you have specified a pathid
60 * IPFGMID - Indicates you have specified a message ID
61 * IPANSLST - Indicates that you are using an address list for
63 * IPBUFLST - Indicates that you are using an address list for
75 iucv_bus_match (struct device
*dev
, struct device_driver
*drv
)
80 struct bus_type iucv_bus
= {
82 .match
= iucv_bus_match
,
85 struct device
*iucv_root
;
87 /* General IUCV interrupt structure */
95 } iucv_GeneralInterrupt
;
97 static iucv_GeneralInterrupt
*iucv_external_int_buffer
= NULL
;
99 /* Spin Lock declaration */
101 static DEFINE_SPINLOCK(iucv_lock
);
103 static int messagesDisabled
= 0;
105 /***************INTERRUPT HANDLING ***************/
108 struct list_head queue
;
109 iucv_GeneralInterrupt data
;
112 static struct list_head iucv_irq_queue
;
113 static DEFINE_SPINLOCK(iucv_irq_queue_lock
);
116 *Internal function prototypes
118 static void iucv_tasklet_handler(unsigned long);
119 static void iucv_irq_handler(struct pt_regs
*, __u16
);
121 static DECLARE_TASKLET(iucv_tasklet
,iucv_tasklet_handler
,0);
123 /************ FUNCTION ID'S ****************************/
127 #define DECLARE_BUFFER 12
135 #define RETRIEVE_BUFFER 2
142 * members: list - list management.
144 * userid - 8 char array of machine identification
145 * user_data - 16 char array for user identification
146 * mask - 24 char array used to compare the 2 previous
147 * interrupt_table - vector of interrupt functions.
148 * pgm_data - ulong, application data that is passed
149 * to the interrupt handlers
151 typedef struct handler_t
{
152 struct list_head list
;
158 iucv_interrupt_ops_t
*interrupt_table
;
163 * iucv_handler_table: List of registered handlers.
165 static struct list_head iucv_handler_table
;
168 * iucv_pathid_table: an array of *handler pointing into
169 * iucv_handler_table for fast indexing by pathid;
171 static handler
**iucv_pathid_table
;
173 static unsigned long max_connections
;
176 * iucv_cpuid: contains the logical cpu number of the cpu which
177 * has declared the iucv buffer by issuing DECLARE_BUFFER.
178 * If no cpu has done the initialization iucv_cpuid contains -1.
180 static int iucv_cpuid
= -1;
182 * register_flag: is 0 when external interrupt has not been registered
184 static int register_flag
;
186 /****************FIVE 40-BYTE PARAMETER STRUCTURES******************/
187 /* Data struct 1: iparml_control
188 * Used for iucv_accept
193 * iucv_retrieve_buffer
194 * Data struct 2: iparml_dpl (data in parameter list)
195 * Used for iucv_send_prmmsg
196 * iucv_send2way_prmmsg
197 * iucv_send2way_prmmsg_array
199 * Data struct 3: iparml_db (data in a buffer)
200 * Used for iucv_receive
208 * iucv_send2way_array
209 * iucv_declare_buffer
210 * Data struct 4: iparml_purge
211 * Used for iucv_purge
213 * Data struct 5: iparml_set_mask
214 * Used for iucv_set_mask
279 iparml_control p_ctrl
;
282 iparml_purge p_purge
;
283 iparml_set_mask p_set_mask
;
287 } __attribute__ ((aligned(8))) iucv_param
;
288 #define PARAM_POOL_SIZE (PAGE_SIZE / sizeof(iucv_param))
290 static iucv_param
* iucv_param_pool
;
292 MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
293 MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
294 MODULE_LICENSE("GPL");
298 *******************************************************************************/
302 static int debuglevel
= 0;
304 module_param(debuglevel
, int, 0);
305 MODULE_PARM_DESC(debuglevel
,
306 "Specifies the debug level (0=off ... 3=all)");
309 iucv_dumpit(char *title
, void *buf
, int len
)
312 __u8
*p
= (__u8
*)buf
;
317 printk(KERN_DEBUG
"%s\n", title
);
319 for (i
= 0; i
< len
; i
++) {
320 if (!(i
% 16) && i
!= 0)
322 else if (!(i
% 4) && i
!= 0)
324 printk("%02X", *p
++);
330 #define iucv_debug(lvl, fmt, args...) \
332 if (debuglevel >= lvl) \
333 printk(KERN_DEBUG "%s: " fmt "\n", __FUNCTION__ , ## args); \
338 #define iucv_debug(lvl, fmt, args...) do { } while (0)
339 #define iucv_dumpit(title, buf, len) do { } while (0)
345 *******************************************************************************/
353 printk(KERN_INFO
"IUCV lowlevel driver initialized\n");
357 * iucv_init - Initialization
359 * Allocates and initializes various data structures.
366 if (iucv_external_int_buffer
)
369 if (!MACHINE_IS_VM
) {
370 printk(KERN_ERR
"IUCV: IUCV connection needs VM as base\n");
371 return -EPROTONOSUPPORT
;
374 ret
= bus_register(&iucv_bus
);
376 printk(KERN_ERR
"IUCV: failed to register bus.\n");
380 iucv_root
= s390_root_dev_register("iucv");
381 if (IS_ERR(iucv_root
)) {
382 printk(KERN_ERR
"IUCV: failed to register iucv root.\n");
383 bus_unregister(&iucv_bus
);
384 return PTR_ERR(iucv_root
);
387 /* Note: GFP_DMA used used to get memory below 2G */
388 iucv_external_int_buffer
= kzalloc(sizeof(iucv_GeneralInterrupt
),
390 if (!iucv_external_int_buffer
) {
392 "%s: Could not allocate external interrupt buffer\n",
394 s390_root_dev_unregister(iucv_root
);
395 bus_unregister(&iucv_bus
);
399 /* Initialize parameter pool */
400 iucv_param_pool
= kzalloc(sizeof(iucv_param
) * PARAM_POOL_SIZE
,
402 if (!iucv_param_pool
) {
403 printk(KERN_WARNING
"%s: Could not allocate param pool\n",
405 kfree(iucv_external_int_buffer
);
406 iucv_external_int_buffer
= NULL
;
407 s390_root_dev_unregister(iucv_root
);
408 bus_unregister(&iucv_bus
);
412 /* Initialize irq queue */
413 INIT_LIST_HEAD(&iucv_irq_queue
);
415 /* Initialize handler table */
416 INIT_LIST_HEAD(&iucv_handler_table
);
423 * iucv_exit - De-Initialization
425 * Frees everything allocated from iucv_init.
427 static int iucv_retrieve_buffer (void);
432 iucv_retrieve_buffer();
433 kfree(iucv_external_int_buffer
);
434 iucv_external_int_buffer
= NULL
;
435 kfree(iucv_param_pool
);
436 iucv_param_pool
= NULL
;
437 s390_root_dev_unregister(iucv_root
);
438 bus_unregister(&iucv_bus
);
439 printk(KERN_INFO
"IUCV lowlevel driver unloaded\n");
443 * grab_param: - Get a parameter buffer from the pre-allocated pool.
445 * This function searches for an unused element in the pre-allocated pool
446 * of parameter buffers. If one is found, it marks it "in use" and returns
447 * a pointer to it. The calling function is responsible for releasing it
448 * when it has finished its usage.
450 * Returns: A pointer to iucv_param.
452 static __inline__ iucv_param
*
458 ptr
= iucv_param_pool
+ hint
;
461 if (ptr
>= iucv_param_pool
+ PARAM_POOL_SIZE
)
462 ptr
= iucv_param_pool
;
463 } while (atomic_cmpxchg(&ptr
->in_use
, 0, 1) != 0);
464 hint
= ptr
- iucv_param_pool
;
466 memset(&ptr
->param
, 0, sizeof(ptr
->param
));
471 * release_param - Release a parameter buffer.
472 * @p: A pointer to a struct iucv_param, previously obtained by calling
475 * This function marks the specified parameter buffer "unused".
477 static __inline__
void
478 release_param(void *p
)
480 atomic_set(&((iucv_param
*)p
)->in_use
, 0);
484 * iucv_add_handler: - Add a new handler
485 * @new_handler: handle that is being entered into chain.
487 * Places new handle on iucv_handler_table, if identical handler is not
490 * Returns: 0 on success, !0 on failure (handler already in chain).
493 iucv_add_handler (handler
*new)
497 iucv_debug(1, "entering");
498 iucv_dumpit("handler:", new, sizeof(handler
));
500 spin_lock_irqsave (&iucv_lock
, flags
);
501 if (!list_empty(&iucv_handler_table
)) {
502 struct list_head
*lh
;
505 * Search list for handler with identical id. If one
506 * is found, the new handler is _not_ added.
508 list_for_each(lh
, &iucv_handler_table
) {
509 handler
*h
= list_entry(lh
, handler
, list
);
510 if (!memcmp(&new->id
, &h
->id
, sizeof(h
->id
))) {
511 iucv_debug(1, "ret 1");
512 spin_unlock_irqrestore (&iucv_lock
, flags
);
518 * If we get here, no handler was found.
520 INIT_LIST_HEAD(&new->list
);
521 list_add(&new->list
, &iucv_handler_table
);
522 spin_unlock_irqrestore (&iucv_lock
, flags
);
524 iucv_debug(1, "exiting");
530 * @code: identifier of IUCV call to CP.
531 * @parm: pointer to 40 byte iparml area passed to CP
533 * Calls CP to execute IUCV commands.
535 * Returns: return code from CP's IUCV call
537 static inline ulong
b2f0(__u32 code
, void *parm
)
539 register unsigned long reg0
asm ("0");
540 register unsigned long reg1
asm ("1");
541 iucv_dumpit("iparml before b2f0 call:", parm
, sizeof(iucv_param
));
544 reg1
= virt_to_phys(parm
);
545 asm volatile(".long 0xb2f01000" : : "d" (reg0
), "a" (reg1
));
547 iucv_dumpit("iparml after b2f0 call:", parm
, sizeof(iucv_param
));
549 return (unsigned long)*((__u8
*)(parm
+ 3));
553 * Name: iucv_add_pathid
554 * Purpose: Adds a path id to the system.
555 * Input: pathid - pathid that is going to be entered into system
556 * handle - address of handler that the pathid will be associated
558 * pgm_data - token passed in by application.
559 * Output: 0: successful addition of pathid
560 * - EINVAL - pathid entry is being used by another application
561 * - ENOMEM - storage allocation for a new pathid table failed
564 __iucv_add_pathid(__u16 pathid
, handler
*handler
)
567 iucv_debug(1, "entering");
569 iucv_debug(1, "handler is pointing to %p", handler
);
571 if (pathid
> (max_connections
- 1))
574 if (iucv_pathid_table
[pathid
]) {
575 iucv_debug(1, "pathid entry is %p", iucv_pathid_table
[pathid
]);
577 "%s: Pathid being used, error.\n", __FUNCTION__
);
580 iucv_pathid_table
[pathid
] = handler
;
582 iucv_debug(1, "exiting");
584 } /* end of add_pathid function */
587 iucv_add_pathid(__u16 pathid
, handler
*handler
)
592 spin_lock_irqsave (&iucv_lock
, flags
);
593 rc
= __iucv_add_pathid(pathid
, handler
);
594 spin_unlock_irqrestore (&iucv_lock
, flags
);
599 iucv_remove_pathid(__u16 pathid
)
603 if (pathid
> (max_connections
- 1))
606 spin_lock_irqsave (&iucv_lock
, flags
);
607 iucv_pathid_table
[pathid
] = NULL
;
608 spin_unlock_irqrestore (&iucv_lock
, flags
);
612 * iucv_declare_buffer_cpuid
613 * Register at VM for subsequent IUCV operations. This is executed
614 * on the reserved CPU iucv_cpuid. Called from iucv_declare_buffer().
617 iucv_declare_buffer_cpuid (void *result
)
621 parm
= (iparml_db
*)grab_param();
622 parm
->ipbfadr1
= virt_to_phys(iucv_external_int_buffer
);
623 if ((*((ulong
*)result
) = b2f0(DECLARE_BUFFER
, parm
)) == 1)
624 *((ulong
*)result
) = parm
->iprcode
;
629 * iucv_retrieve_buffer_cpuid:
630 * Unregister IUCV usage at VM. This is always executed on the same
631 * cpu that registered the buffer to VM.
632 * Called from iucv_retrieve_buffer().
635 iucv_retrieve_buffer_cpuid (void *cpu
)
637 iparml_control
*parm
;
639 parm
= (iparml_control
*)grab_param();
640 b2f0(RETRIEVE_BUFFER
, parm
);
645 * Name: iucv_declare_buffer
646 * Purpose: Specifies the guests real address of an external
649 * Output: iprcode - return code from b2f0 call
652 iucv_declare_buffer (void)
657 iucv_debug(1, "entering");
658 b2f0_result
= -ENODEV
;
659 spin_lock_irqsave (&iucv_lock
, flags
);
660 if (iucv_cpuid
== -1) {
661 /* Reserve any cpu for use by iucv. */
662 iucv_cpuid
= smp_get_cpu(CPU_MASK_ALL
);
663 spin_unlock_irqrestore (&iucv_lock
, flags
);
664 smp_call_function_on(iucv_declare_buffer_cpuid
,
665 &b2f0_result
, 0, 1, iucv_cpuid
);
667 smp_put_cpu(iucv_cpuid
);
670 iucv_debug(1, "Address of EIB = %p", iucv_external_int_buffer
);
672 spin_unlock_irqrestore (&iucv_lock
, flags
);
675 iucv_debug(1, "exiting");
680 * iucv_retrieve_buffer:
682 * Terminates all use of IUCV.
683 * Returns: return code from CP
686 iucv_retrieve_buffer (void)
688 iucv_debug(1, "entering");
689 if (iucv_cpuid
!= -1) {
690 smp_call_function_on(iucv_retrieve_buffer_cpuid
,
691 NULL
, 0, 1, iucv_cpuid
);
692 /* Release the cpu reserved by iucv_declare_buffer. */
693 smp_put_cpu(iucv_cpuid
);
696 iucv_debug(1, "exiting");
701 * iucv_remove_handler:
702 * @users_handler: handler to be removed
704 * Remove handler when application unregisters.
707 iucv_remove_handler(handler
*handler
)
711 if ((!iucv_pathid_table
) || (!handler
))
714 iucv_debug(1, "entering");
716 spin_lock_irqsave (&iucv_lock
, flags
);
717 list_del(&handler
->list
);
718 if (list_empty(&iucv_handler_table
)) {
720 unregister_external_interrupt(0x4000, iucv_irq_handler
);
724 spin_unlock_irqrestore (&iucv_lock
, flags
);
726 iucv_debug(1, "exiting");
731 * iucv_register_program:
732 * @pgmname: user identification
733 * @userid: machine identification
734 * @pgmmask: Indicates which bits in the pgmname and userid combined will be
735 * used to determine who is given control.
736 * @ops: Address of interrupt handler table.
737 * @pgm_data: Application data to be passed to interrupt handlers.
739 * Registers an application with IUCV.
741 * The address of handler, or NULL on failure.
743 * If pgmname, userid and pgmmask are provided, pgmmask is entered into the
745 * If pgmmask is NULL, the internal mask is set to all 0xff's
746 * When userid is NULL, the first 8 bytes of the internal mask are forced
748 * If pgmmask and userid are NULL, the first 8 bytes of the internal mask
749 * are forced to 0x00 and the last 16 bytes to 0xff.
753 iucv_register_program (__u8 pgmname
[16],
756 iucv_interrupt_ops_t
* ops
, void *pgm_data
)
758 ulong rc
= 0; /* return code from function calls */
759 handler
*new_handler
;
761 iucv_debug(1, "entering");
764 /* interrupt table is not defined */
765 printk(KERN_WARNING
"%s: Interrupt table is not defined, "
766 "exiting\n", __FUNCTION__
);
770 printk(KERN_WARNING
"%s: pgmname not provided\n", __FUNCTION__
);
774 /* Allocate handler entry */
775 new_handler
= (handler
*)kmalloc(sizeof(handler
), GFP_ATOMIC
);
776 if (new_handler
== NULL
) {
777 printk(KERN_WARNING
"%s: storage allocation for new handler "
778 "failed.\n", __FUNCTION__
);
782 if (!iucv_pathid_table
) {
788 max_connections
= iucv_query_maxconn();
789 iucv_pathid_table
= kcalloc(max_connections
, sizeof(handler
*),
791 if (iucv_pathid_table
== NULL
) {
792 printk(KERN_WARNING
"%s: iucv_pathid_table storage "
793 "allocation failed\n", __FUNCTION__
);
798 memset(new_handler
, 0, sizeof (handler
));
799 memcpy(new_handler
->id
.user_data
, pgmname
,
800 sizeof (new_handler
->id
.user_data
));
802 memcpy (new_handler
->id
.userid
, userid
,
803 sizeof (new_handler
->id
.userid
));
804 ASCEBC (new_handler
->id
.userid
,
805 sizeof (new_handler
->id
.userid
));
806 EBC_TOUPPER (new_handler
->id
.userid
,
807 sizeof (new_handler
->id
.userid
));
810 memcpy (new_handler
->id
.mask
, pgmmask
,
811 sizeof (new_handler
->id
.mask
));
813 memset (new_handler
->id
.mask
, 0xFF,
814 sizeof (new_handler
->id
.mask
));
818 memcpy (new_handler
->id
.mask
, pgmmask
,
819 sizeof (new_handler
->id
.mask
));
821 memset (new_handler
->id
.mask
, 0xFF,
822 sizeof (new_handler
->id
.mask
));
824 memset (new_handler
->id
.userid
, 0x00,
825 sizeof (new_handler
->id
.userid
));
827 /* fill in the rest of handler */
828 new_handler
->pgm_data
= pgm_data
;
829 new_handler
->interrupt_table
= ops
;
832 * Check if someone else is registered with same pgmname, userid
833 * and mask. If someone is already registered with same pgmname,
834 * userid and mask, registration will fail and NULL will be returned
835 * to the application.
836 * If identical handler not found, then handler is added to list.
838 rc
= iucv_add_handler(new_handler
);
840 printk(KERN_WARNING
"%s: Someone already registered with same "
841 "pgmname, userid, pgmmask\n", __FUNCTION__
);
846 rc
= iucv_declare_buffer();
848 char *err
= "Unknown";
849 iucv_remove_handler(new_handler
);
853 err
= "Directory error";
856 err
= "Invalid length";
859 err
= "Buffer already exists";
862 err
= "Buffer overlap";
865 err
= "Paging or storage error";
868 printk(KERN_WARNING
"%s: iucv_declare_buffer "
869 "returned error 0x%02lx (%s)\n", __FUNCTION__
, rc
, err
);
872 if (!register_flag
) {
873 /* request the 0x4000 external interrupt */
874 rc
= register_external_interrupt (0x4000, iucv_irq_handler
);
876 iucv_remove_handler(new_handler
);
878 printk(KERN_WARNING
"%s: "
879 "register_external_interrupt returned %ld\n",
886 iucv_debug(1, "exiting");
888 } /* end of register function */
891 * iucv_unregister_program:
892 * @handle: address of handler
894 * Unregister application with IUCV.
896 * 0 on success, -EINVAL, if specified handle is invalid.
900 iucv_unregister_program (iucv_handle_t handle
)
903 struct list_head
*lh
;
907 iucv_debug(1, "entering");
908 iucv_debug(1, "address of handler is %p", h
);
910 /* Checking if handle is valid */
911 spin_lock_irqsave (&iucv_lock
, flags
);
912 list_for_each(lh
, &iucv_handler_table
) {
913 if ((handler
*)handle
== list_entry(lh
, handler
, list
)) {
914 h
= (handler
*)handle
;
919 spin_unlock_irqrestore (&iucv_lock
, flags
);
922 "%s: Handler not found in iucv_handler_table.\n",
926 "%s: NULL handle passed by application.\n",
932 * First, walk thru iucv_pathid_table and sever any pathid which is
933 * still pointing to the handler to be removed.
935 for (i
= 0; i
< max_connections
; i
++)
936 if (iucv_pathid_table
[i
] == h
) {
937 spin_unlock_irqrestore (&iucv_lock
, flags
);
938 iucv_sever(i
, h
->id
.user_data
);
939 spin_lock_irqsave(&iucv_lock
, flags
);
941 spin_unlock_irqrestore (&iucv_lock
, flags
);
943 iucv_remove_handler(h
);
946 iucv_debug(1, "exiting");
952 * @pathid: Path identification number
953 * @msglim_reqstd: The number of outstanding messages requested.
954 * @user_data: Data specified by the iucv_connect function.
955 * @flags1: Contains options for this path.
956 * - IPPRTY (0x20) Specifies if you want to send priority message.
957 * - IPRMDATA (0x80) Specifies whether your program can handle a message
958 * in the parameter list.
959 * - IPQUSCE (0x40) Specifies whether you want to quiesce the path being
961 * @handle: Address of handler.
962 * @pgm_data: Application data passed to interrupt handlers.
963 * @flags1_out: Pointer to an int. If not NULL, on return the options for
964 * the path are stored at the given location:
965 * - IPPRTY (0x20) Indicates you may send a priority message.
966 * @msglim: Pointer to an __u16. If not NULL, on return the maximum
967 * number of outstanding messages is stored at the given
970 * This function is issued after the user receives a Connection Pending external
971 * interrupt and now wishes to complete the IUCV communication path.
973 * return code from CP
976 iucv_accept(__u16 pathid
, __u16 msglim_reqstd
,
977 __u8 user_data
[16], int flags1
,
978 iucv_handle_t handle
, void *pgm_data
,
979 int *flags1_out
, __u16
* msglim
)
981 ulong b2f0_result
= 0;
983 struct list_head
*lh
;
985 iparml_control
*parm
;
987 iucv_debug(1, "entering");
988 iucv_debug(1, "pathid = %d", pathid
);
990 /* Checking if handle is valid */
991 spin_lock_irqsave (&iucv_lock
, flags
);
992 list_for_each(lh
, &iucv_handler_table
) {
993 if ((handler
*)handle
== list_entry(lh
, handler
, list
)) {
994 h
= (handler
*)handle
;
998 spin_unlock_irqrestore (&iucv_lock
, flags
);
1003 "%s: Handler not found in iucv_handler_table.\n",
1007 "%s: NULL handle passed by application.\n",
1012 parm
= (iparml_control
*)grab_param();
1014 parm
->ippathid
= pathid
;
1015 parm
->ipmsglim
= msglim_reqstd
;
1017 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
1019 parm
->ipflags1
= (__u8
)flags1
;
1020 b2f0_result
= b2f0(ACCEPT
, parm
);
1024 *msglim
= parm
->ipmsglim
;
1026 h
->pgm_data
= pgm_data
;
1028 *flags1_out
= (parm
->ipflags1
& IPPRTY
) ? IPPRTY
: 0;
1030 release_param(parm
);
1032 iucv_debug(1, "exiting");
1038 * @pathid: Path identification number
1039 * @msglim_reqstd: Number of outstanding messages requested
1040 * @user_data: 16-byte user data
1041 * @userid: 8-byte of user identification
1042 * @system_name: 8-byte identifying the system name
1043 * @flags1: Specifies options for this path:
1044 * - IPPRTY (0x20) Specifies if you want to send priority message.
1045 * - IPRMDATA (0x80) Specifies whether your program can handle a message
1046 * in the parameter list.
1047 * - IPQUSCE (0x40) Specifies whether you want to quiesce the path being
1049 * - IPLOCAL (0x01) Allows an application to force the partner to be on the
1050 * local system. If local is specified then target class
1051 * cannot be specified.
1052 * @flags1_out: Pointer to an int. If not NULL, on return the options for
1053 * the path are stored at the given location:
1054 * - IPPRTY (0x20) Indicates you may send a priority message.
1055 * @msglim: Pointer to an __u16. If not NULL, on return the maximum
1056 * number of outstanding messages is stored at the given
1058 * @handle: Address of handler.
1059 * @pgm_data: Application data to be passed to interrupt handlers.
1061 * This function establishes an IUCV path. Although the connect may complete
1062 * successfully, you are not able to use the path until you receive an IUCV
1063 * Connection Complete external interrupt.
1064 * Returns: return code from CP, or one of the following
1066 * - return code from iucv_declare_buffer
1067 * - EINVAL - invalid handle passed by application
1068 * - EINVAL - pathid address is NULL
1069 * - ENOMEM - pathid table storage allocation failed
1070 * - return code from internal function add_pathid
1073 iucv_connect (__u16
*pathid
, __u16 msglim_reqstd
,
1074 __u8 user_data
[16], __u8 userid
[8],
1075 __u8 system_name
[8], int flags1
,
1076 int *flags1_out
, __u16
* msglim
,
1077 iucv_handle_t handle
, void *pgm_data
)
1079 iparml_control
*parm
;
1080 iparml_control local_parm
;
1081 struct list_head
*lh
;
1082 ulong b2f0_result
= 0;
1084 int add_pathid_result
= 0;
1086 __u8 no_memory
[16] = "NO MEMORY";
1088 iucv_debug(1, "entering");
1090 /* Checking if handle is valid */
1091 spin_lock_irqsave (&iucv_lock
, flags
);
1092 list_for_each(lh
, &iucv_handler_table
) {
1093 if ((handler
*)handle
== list_entry(lh
, handler
, list
)) {
1094 h
= (handler
*)handle
;
1098 spin_unlock_irqrestore (&iucv_lock
, flags
);
1103 "%s: Handler not found in iucv_handler_table.\n",
1107 "%s: NULL handle passed by application.\n",
1112 if (pathid
== NULL
) {
1113 printk(KERN_WARNING
"%s: NULL pathid pointer\n",
1118 parm
= (iparml_control
*)grab_param();
1120 parm
->ipmsglim
= msglim_reqstd
;
1123 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
1126 memcpy(parm
->ipvmid
, userid
, sizeof(parm
->ipvmid
));
1127 ASCEBC(parm
->ipvmid
, sizeof(parm
->ipvmid
));
1128 EBC_TOUPPER(parm
->ipvmid
, sizeof(parm
->ipvmid
));
1132 memcpy(parm
->iptarget
, system_name
, sizeof(parm
->iptarget
));
1133 ASCEBC(parm
->iptarget
, sizeof(parm
->iptarget
));
1134 EBC_TOUPPER(parm
->iptarget
, sizeof(parm
->iptarget
));
1137 /* In order to establish an IUCV connection, the procedure is:
1140 * take the ippathid from the b2f0 call
1141 * register the handler to the ippathid
1143 * Unfortunately, the ConnectionEstablished message gets sent after the
1144 * b2f0(CONNECT) call but before the register is handled.
1146 * In order for this race condition to be eliminated, the IUCV Control
1147 * Interrupts must be disabled for the above procedure.
1149 * David Kennedy <dkennedy@linuxcare.com>
1152 /* Enable everything but IUCV Control messages */
1153 iucv_setmask(~(AllInterrupts
));
1154 messagesDisabled
= 1;
1156 spin_lock_irqsave (&iucv_lock
, flags
);
1157 parm
->ipflags1
= (__u8
)flags1
;
1158 b2f0_result
= b2f0(CONNECT
, parm
);
1159 memcpy(&local_parm
, parm
, sizeof(local_parm
));
1160 release_param(parm
);
1163 add_pathid_result
= __iucv_add_pathid(parm
->ippathid
, h
);
1164 spin_unlock_irqrestore (&iucv_lock
, flags
);
1168 messagesDisabled
= 0;
1172 *pathid
= parm
->ippathid
;
1174 /* Enable everything again */
1175 iucv_setmask(IUCVControlInterruptsFlag
);
1178 *msglim
= parm
->ipmsglim
;
1180 *flags1_out
= (parm
->ipflags1
& IPPRTY
) ? IPPRTY
: 0;
1182 if (add_pathid_result
) {
1183 iucv_sever(*pathid
, no_memory
);
1184 printk(KERN_WARNING
"%s: add_pathid failed with rc ="
1185 " %d\n", __FUNCTION__
, add_pathid_result
);
1186 return(add_pathid_result
);
1189 iucv_debug(1, "exiting");
1195 * @pathid: Path identification number
1196 * @msgid: Message ID of message to purge.
1197 * @srccls: Message class of the message to purge.
1198 * @audit: Pointer to an __u32. If not NULL, on return, information about
1199 * asynchronous errors that may have affected the normal completion
1200 * of this message ist stored at the given location.
1202 * Cancels a message you have sent.
1203 * Returns: return code from CP
1206 iucv_purge (__u16 pathid
, __u32 msgid
, __u32 srccls
, __u32
*audit
)
1209 ulong b2f0_result
= 0;
1211 iucv_debug(1, "entering");
1212 iucv_debug(1, "pathid = %d", pathid
);
1214 parm
= (iparml_purge
*)grab_param();
1216 parm
->ipmsgid
= msgid
;
1217 parm
->ippathid
= pathid
;
1218 parm
->ipsrccls
= srccls
;
1219 parm
->ipflags1
|= (IPSRCCLS
| IPFGMID
| IPFGPID
);
1220 b2f0_result
= b2f0(PURGE
, parm
);
1222 if (!b2f0_result
&& audit
) {
1223 memcpy(audit
, parm
->ipaudit
, sizeof(parm
->ipaudit
));
1224 /* parm->ipaudit has only 3 bytes */
1228 release_param(parm
);
1230 iucv_debug(1, "b2f0_result = %ld", b2f0_result
);
1231 iucv_debug(1, "exiting");
1236 * iucv_query_generic:
1237 * @want_maxconn: Flag, describing which value is to be returned.
1239 * Helper function for iucv_query_maxconn() and iucv_query_bufsize().
1241 * Returns: The buffersize, if want_maxconn is 0; the maximum number of
1242 * connections, if want_maxconn is 1 or an error-code < 0 on failure.
1245 iucv_query_generic(int want_maxconn
)
1247 register unsigned long reg0
asm ("0");
1248 register unsigned long reg1
asm ("1");
1249 iparml_purge
*parm
= (iparml_purge
*)grab_param();
1250 int bufsize
, maxconn
;
1254 * Call b2f0 and store R0 (max buffer size),
1255 * R1 (max connections) and CC.
1258 reg1
= virt_to_phys(parm
);
1260 " .long 0xb2f01000\n"
1263 : "=d" (ccode
), "+d" (reg0
), "+d" (reg1
) : : "cc");
1266 release_param(parm
);
1276 * iucv_query_maxconn:
1278 * Determines the maximum number of connections thay may be established.
1280 * Returns: Maximum number of connections that can be.
1283 iucv_query_maxconn(void)
1285 return iucv_query_generic(1);
1289 * iucv_query_bufsize:
1291 * Determines the size of the external interrupt buffer.
1293 * Returns: Size of external interrupt buffer.
1296 iucv_query_bufsize (void)
1298 return iucv_query_generic(0);
1303 * @pathid: Path identification number
1304 * @user_data: 16-byte user data
1306 * Temporarily suspends incoming messages on an IUCV path.
1307 * You can later reactivate the path by invoking the iucv_resume function.
1308 * Returns: return code from CP
1311 iucv_quiesce (__u16 pathid
, __u8 user_data
[16])
1313 iparml_control
*parm
;
1314 ulong b2f0_result
= 0;
1316 iucv_debug(1, "entering");
1317 iucv_debug(1, "pathid = %d", pathid
);
1319 parm
= (iparml_control
*)grab_param();
1321 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
1322 parm
->ippathid
= pathid
;
1324 b2f0_result
= b2f0(QUIESCE
, parm
);
1325 release_param(parm
);
1327 iucv_debug(1, "b2f0_result = %ld", b2f0_result
);
1328 iucv_debug(1, "exiting");
1335 * @pathid: Path identification number.
1336 * @buffer: Address of buffer to receive. Must be below 2G.
1337 * @buflen: Length of buffer to receive.
1338 * @msgid: Specifies the message ID.
1339 * @trgcls: Specifies target class.
1340 * @flags1_out: Receives options for path on return.
1341 * - IPNORPY (0x10) Specifies whether a reply is required
1342 * - IPPRTY (0x20) Specifies if you want to send priority message
1343 * - IPRMDATA (0x80) Specifies the data is contained in the parameter list
1344 * @residual_buffer: Receives the address of buffer updated by the number
1345 * of bytes you have received on return.
1346 * @residual_length: On return, receives one of the following values:
1347 * - 0 If the receive buffer is the same length as
1349 * - Remaining bytes in buffer If the receive buffer is longer than the
1351 * - Remaining bytes in message If the receive buffer is shorter than the
1354 * This function receives messages that are being sent to you over established
1356 * Returns: return code from CP IUCV call; If the receive buffer is shorter
1357 * than the message, always 5
1358 * -EINVAL - buffer address is pointing to NULL
1361 iucv_receive (__u16 pathid
, __u32 msgid
, __u32 trgcls
,
1362 void *buffer
, ulong buflen
,
1363 int *flags1_out
, ulong
* residual_buffer
, ulong
* residual_length
)
1367 int moved
= 0; /* number of bytes moved from parmlist to buffer */
1369 iucv_debug(2, "entering");
1374 parm
= (iparml_db
*)grab_param();
1376 parm
->ipbfadr1
= (__u32
) (addr_t
) buffer
;
1377 parm
->ipbfln1f
= (__u32
) ((ulong
) buflen
);
1378 parm
->ipmsgid
= msgid
;
1379 parm
->ippathid
= pathid
;
1380 parm
->iptrgcls
= trgcls
;
1381 parm
->ipflags1
= (IPFGPID
| IPFGMID
| IPFGMCL
);
1383 b2f0_result
= b2f0(RECEIVE
, parm
);
1385 if (!b2f0_result
|| b2f0_result
== 5) {
1387 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1388 *flags1_out
= (parm
->ipflags1
& (~0x07));
1389 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1392 if (!(parm
->ipflags1
& IPRMDATA
)) { /*msg not in parmlist */
1393 if (residual_length
)
1394 *residual_length
= parm
->ipbfln1f
;
1396 if (residual_buffer
)
1397 *residual_buffer
= parm
->ipbfadr1
;
1399 moved
= min_t (unsigned long, buflen
, 8);
1401 memcpy ((char *) buffer
,
1402 (char *) &parm
->ipbfadr1
, moved
);
1407 if (residual_length
)
1408 *residual_length
= abs (buflen
- 8);
1410 if (residual_buffer
)
1411 *residual_buffer
= (ulong
) (buffer
+ moved
);
1414 release_param(parm
);
1416 iucv_debug(2, "exiting");
1421 * Name: iucv_receive_array
1422 * Purpose: This function receives messages that are being sent to you
1423 * over established paths.
1424 * Input: pathid - path identification number
1425 * buffer - address of array of buffers
1426 * buflen - total length of buffers
1427 * msgid - specifies the message ID.
1428 * trgcls - specifies target class
1430 * flags1_out: Options for path.
1431 * IPNORPY - 0x10 specifies whether a reply is required
1432 * IPPRTY - 0x20 specifies if you want to send priority message
1433 * IPRMDATA - 0x80 specifies the data is contained in the parameter list
1434 * residual_buffer - address points to the current list entry IUCV
1437 * Contains one of the following values, if the receive buffer is:
1438 * The same length as the message, this field is zero.
1439 * Longer than the message, this field contains the number of
1440 * bytes remaining in the buffer.
1441 * Shorter than the message, this field contains the residual
1442 * count (that is, the number of bytes remaining in the
1443 * message that does not fit into the buffer. In this case
1445 * Return: b2f0_result - return code from CP
1446 * (-EINVAL) - buffer address is NULL
1449 iucv_receive_array (__u16 pathid
,
1450 __u32 msgid
, __u32 trgcls
,
1451 iucv_array_t
* buffer
, ulong buflen
,
1453 ulong
* residual_buffer
, ulong
* residual_length
)
1457 int i
= 0, moved
= 0, need_to_move
= 8, dyn_len
;
1459 iucv_debug(2, "entering");
1464 parm
= (iparml_db
*)grab_param();
1466 parm
->ipbfadr1
= (__u32
) ((ulong
) buffer
);
1467 parm
->ipbfln1f
= (__u32
) buflen
;
1468 parm
->ipmsgid
= msgid
;
1469 parm
->ippathid
= pathid
;
1470 parm
->iptrgcls
= trgcls
;
1471 parm
->ipflags1
= (IPBUFLST
| IPFGPID
| IPFGMID
| IPFGMCL
);
1473 b2f0_result
= b2f0(RECEIVE
, parm
);
1475 if (!b2f0_result
|| b2f0_result
== 5) {
1478 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1479 *flags1_out
= (parm
->ipflags1
& (~0x07));
1480 iucv_debug(2, "*flags1_out = %d", *flags1_out
);
1483 if (!(parm
->ipflags1
& IPRMDATA
)) { /*msg not in parmlist */
1485 if (residual_length
)
1486 *residual_length
= parm
->ipbfln1f
;
1488 if (residual_buffer
)
1489 *residual_buffer
= parm
->ipbfadr1
;
1492 /* copy msg from parmlist to users array. */
1494 while ((moved
< 8) && (moved
< buflen
)) {
1496 min_t (unsigned int,
1497 (buffer
+ i
)->length
, need_to_move
);
1499 memcpy ((char *)((ulong
)((buffer
+ i
)->address
)),
1500 ((char *) &parm
->ipbfadr1
) + moved
,
1504 need_to_move
-= dyn_len
;
1506 (buffer
+ i
)->address
=
1508 ((ulong
)(__u8
*) ((ulong
)(buffer
+ i
)->address
)
1511 (buffer
+ i
)->length
-= dyn_len
;
1515 if (need_to_move
) /* buflen < 8 bytes */
1518 if (residual_length
)
1519 *residual_length
= abs (buflen
- 8);
1521 if (residual_buffer
) {
1523 *residual_buffer
= (ulong
) buffer
;
1526 (ulong
) (buffer
+ (i
- 1));
1531 release_param(parm
);
1533 iucv_debug(2, "exiting");
1539 * @pathid: Path identification number.
1540 * @msgid: Message ID of the message to reject.
1541 * @trgcls: Target class of the message to reject.
1542 * Returns: return code from CP
1544 * Refuses a specified message. Between the time you are notified of a
1545 * message and the time that you complete the message, the message may
1549 iucv_reject (__u16 pathid
, __u32 msgid
, __u32 trgcls
)
1552 ulong b2f0_result
= 0;
1554 iucv_debug(1, "entering");
1555 iucv_debug(1, "pathid = %d", pathid
);
1557 parm
= (iparml_db
*)grab_param();
1559 parm
->ippathid
= pathid
;
1560 parm
->ipmsgid
= msgid
;
1561 parm
->iptrgcls
= trgcls
;
1562 parm
->ipflags1
= (IPFGMCL
| IPFGMID
| IPFGPID
);
1564 b2f0_result
= b2f0(REJECT
, parm
);
1565 release_param(parm
);
1567 iucv_debug(1, "b2f0_result = %ld", b2f0_result
);
1568 iucv_debug(1, "exiting");
1575 * Purpose: This function responds to the two-way messages that you
1576 * receive. You must identify completely the message to
1577 * which you wish to reply. ie, pathid, msgid, and trgcls.
1578 * Input: pathid - path identification number
1579 * msgid - specifies the message ID.
1580 * trgcls - specifies target class
1581 * flags1 - option for path
1582 * IPPRTY- 0x20 - specifies if you want to send priority message
1583 * buffer - address of reply buffer
1584 * buflen - length of reply buffer
1585 * Output: ipbfadr2 - Address of buffer updated by the number
1586 * of bytes you have moved.
1587 * ipbfln2f - Contains one of the following values:
1588 * If the answer buffer is the same length as the reply, this field
1590 * If the answer buffer is longer than the reply, this field contains
1591 * the number of bytes remaining in the buffer.
1592 * If the answer buffer is shorter than the reply, this field contains
1593 * a residual count (that is, the number of bytes remianing in the
1594 * reply that does not fit into the buffer. In this
1595 * case b2f0_result = 5.
1596 * Return: b2f0_result - return code from CP
1597 * (-EINVAL) - buffer address is NULL
1600 iucv_reply (__u16 pathid
,
1601 __u32 msgid
, __u32 trgcls
,
1603 void *buffer
, ulong buflen
, ulong
* ipbfadr2
, ulong
* ipbfln2f
)
1608 iucv_debug(2, "entering");
1613 parm
= (iparml_db
*)grab_param();
1615 parm
->ipbfadr2
= (__u32
) ((ulong
) buffer
);
1616 parm
->ipbfln2f
= (__u32
) buflen
; /* length of message */
1617 parm
->ippathid
= pathid
;
1618 parm
->ipmsgid
= msgid
;
1619 parm
->iptrgcls
= trgcls
;
1620 parm
->ipflags1
= (__u8
) flags1
; /* priority message */
1622 b2f0_result
= b2f0(REPLY
, parm
);
1624 if ((!b2f0_result
) || (b2f0_result
== 5)) {
1626 *ipbfadr2
= parm
->ipbfadr2
;
1628 *ipbfln2f
= parm
->ipbfln2f
;
1630 release_param(parm
);
1632 iucv_debug(2, "exiting");
1638 * Name: iucv_reply_array
1639 * Purpose: This function responds to the two-way messages that you
1640 * receive. You must identify completely the message to
1641 * which you wish to reply. ie, pathid, msgid, and trgcls.
1642 * The array identifies a list of addresses and lengths of
1643 * discontiguous buffers that contains the reply data.
1644 * Input: pathid - path identification number
1645 * msgid - specifies the message ID.
1646 * trgcls - specifies target class
1647 * flags1 - option for path
1648 * IPPRTY- specifies if you want to send priority message
1649 * buffer - address of array of reply buffers
1650 * buflen - total length of reply buffers
1651 * Output: ipbfadr2 - Address of buffer which IUCV is currently working on.
1652 * ipbfln2f - Contains one of the following values:
1653 * If the answer buffer is the same length as the reply, this field
1655 * If the answer buffer is longer than the reply, this field contains
1656 * the number of bytes remaining in the buffer.
1657 * If the answer buffer is shorter than the reply, this field contains
1658 * a residual count (that is, the number of bytes remianing in the
1659 * reply that does not fit into the buffer. In this
1660 * case b2f0_result = 5.
1661 * Return: b2f0_result - return code from CP
1662 * (-EINVAL) - buffer address is NULL
1665 iucv_reply_array (__u16 pathid
,
1666 __u32 msgid
, __u32 trgcls
,
1668 iucv_array_t
* buffer
,
1669 ulong buflen
, ulong
* ipbfadr2
, ulong
* ipbfln2f
)
1674 iucv_debug(2, "entering");
1679 parm
= (iparml_db
*)grab_param();
1681 parm
->ipbfadr2
= (__u32
) ((ulong
) buffer
);
1682 parm
->ipbfln2f
= buflen
; /* length of message */
1683 parm
->ippathid
= pathid
;
1684 parm
->ipmsgid
= msgid
;
1685 parm
->iptrgcls
= trgcls
;
1686 parm
->ipflags1
= (IPANSLST
| flags1
);
1688 b2f0_result
= b2f0(REPLY
, parm
);
1690 if ((!b2f0_result
) || (b2f0_result
== 5)) {
1693 *ipbfadr2
= parm
->ipbfadr2
;
1695 *ipbfln2f
= parm
->ipbfln2f
;
1697 release_param(parm
);
1699 iucv_debug(2, "exiting");
1705 * Name: iucv_reply_prmmsg
1706 * Purpose: This function responds to the two-way messages that you
1707 * receive. You must identify completely the message to
1708 * which you wish to reply. ie, pathid, msgid, and trgcls.
1709 * Prmmsg signifies the data is moved into the
1711 * Input: pathid - path identification number
1712 * msgid - specifies the message ID.
1713 * trgcls - specifies target class
1714 * flags1 - option for path
1715 * IPPRTY- specifies if you want to send priority message
1716 * prmmsg - 8-bytes of data to be placed into the parameter
1719 * Return: b2f0_result - return code from CP
1722 iucv_reply_prmmsg (__u16 pathid
,
1723 __u32 msgid
, __u32 trgcls
, int flags1
, __u8 prmmsg
[8])
1728 iucv_debug(2, "entering");
1730 parm
= (iparml_dpl
*)grab_param();
1732 parm
->ippathid
= pathid
;
1733 parm
->ipmsgid
= msgid
;
1734 parm
->iptrgcls
= trgcls
;
1735 memcpy(parm
->iprmmsg
, prmmsg
, sizeof (parm
->iprmmsg
));
1736 parm
->ipflags1
= (IPRMDATA
| flags1
);
1738 b2f0_result
= b2f0(REPLY
, parm
);
1739 release_param(parm
);
1741 iucv_debug(2, "exiting");
1748 * @pathid: Path identification number
1749 * @user_data: 16-byte of user data
1751 * This function restores communication over a quiesced path.
1752 * Returns: return code from CP
1755 iucv_resume (__u16 pathid
, __u8 user_data
[16])
1757 iparml_control
*parm
;
1758 ulong b2f0_result
= 0;
1760 iucv_debug(1, "entering");
1761 iucv_debug(1, "pathid = %d", pathid
);
1763 parm
= (iparml_control
*)grab_param();
1765 memcpy (parm
->ipuser
, user_data
, sizeof (*user_data
));
1766 parm
->ippathid
= pathid
;
1768 b2f0_result
= b2f0(RESUME
, parm
);
1769 release_param(parm
);
1771 iucv_debug(1, "exiting");
1778 * Purpose: sends messages
1779 * Input: pathid - ushort, pathid
1780 * msgid - ulong *, id of message returned to caller
1781 * trgcls - ulong, target message class
1782 * srccls - ulong, source message class
1783 * msgtag - ulong, message tag
1784 * flags1 - Contains options for this path.
1785 * IPPRTY - Ox20 - specifies if you want to send a priority message.
1786 * buffer - pointer to buffer
1787 * buflen - ulong, length of buffer
1788 * Output: b2f0_result - return code from b2f0 call
1789 * msgid - returns message id
1792 iucv_send (__u16 pathid
, __u32
* msgid
,
1793 __u32 trgcls
, __u32 srccls
,
1794 __u32 msgtag
, int flags1
, void *buffer
, ulong buflen
)
1799 iucv_debug(2, "entering");
1804 parm
= (iparml_db
*)grab_param();
1806 parm
->ipbfadr1
= (__u32
) ((ulong
) buffer
);
1807 parm
->ippathid
= pathid
;
1808 parm
->iptrgcls
= trgcls
;
1809 parm
->ipbfln1f
= (__u32
) buflen
; /* length of message */
1810 parm
->ipsrccls
= srccls
;
1811 parm
->ipmsgtag
= msgtag
;
1812 parm
->ipflags1
= (IPNORPY
| flags1
); /* one way priority message */
1814 b2f0_result
= b2f0(SEND
, parm
);
1816 if ((!b2f0_result
) && (msgid
))
1817 *msgid
= parm
->ipmsgid
;
1818 release_param(parm
);
1820 iucv_debug(2, "exiting");
1826 * Name: iucv_send_array
1827 * Purpose: This function transmits data to another application.
1828 * The contents of buffer is the address of the array of
1829 * addresses and lengths of discontiguous buffers that hold
1830 * the message text. This is a one-way message and the
1831 * receiver will not reply to the message.
1832 * Input: pathid - path identification number
1833 * trgcls - specifies target class
1834 * srccls - specifies the source message class
1835 * msgtag - specifies a tag to be associated witht the message
1836 * flags1 - option for path
1837 * IPPRTY- specifies if you want to send priority message
1838 * buffer - address of array of send buffers
1839 * buflen - total length of send buffers
1840 * Output: msgid - specifies the message ID.
1841 * Return: b2f0_result - return code from CP
1842 * (-EINVAL) - buffer address is NULL
1845 iucv_send_array (__u16 pathid
,
1849 __u32 msgtag
, int flags1
, iucv_array_t
* buffer
, ulong buflen
)
1854 iucv_debug(2, "entering");
1859 parm
= (iparml_db
*)grab_param();
1861 parm
->ippathid
= pathid
;
1862 parm
->iptrgcls
= trgcls
;
1863 parm
->ipbfadr1
= (__u32
) ((ulong
) buffer
);
1864 parm
->ipbfln1f
= (__u32
) buflen
; /* length of message */
1865 parm
->ipsrccls
= srccls
;
1866 parm
->ipmsgtag
= msgtag
;
1867 parm
->ipflags1
= (IPNORPY
| IPBUFLST
| flags1
);
1868 b2f0_result
= b2f0(SEND
, parm
);
1870 if ((!b2f0_result
) && (msgid
))
1871 *msgid
= parm
->ipmsgid
;
1872 release_param(parm
);
1874 iucv_debug(2, "exiting");
1879 * Name: iucv_send_prmmsg
1880 * Purpose: This function transmits data to another application.
1881 * Prmmsg specifies that the 8-bytes of data are to be moved
1882 * into the parameter list. This is a one-way message and the
1883 * receiver will not reply to the message.
1884 * Input: pathid - path identification number
1885 * trgcls - specifies target class
1886 * srccls - specifies the source message class
1887 * msgtag - specifies a tag to be associated with the message
1888 * flags1 - option for path
1889 * IPPRTY- specifies if you want to send priority message
1890 * prmmsg - 8-bytes of data to be placed into parameter list
1891 * Output: msgid - specifies the message ID.
1892 * Return: b2f0_result - return code from CP
1895 iucv_send_prmmsg (__u16 pathid
,
1898 __u32 srccls
, __u32 msgtag
, int flags1
, __u8 prmmsg
[8])
1903 iucv_debug(2, "entering");
1905 parm
= (iparml_dpl
*)grab_param();
1907 parm
->ippathid
= pathid
;
1908 parm
->iptrgcls
= trgcls
;
1909 parm
->ipsrccls
= srccls
;
1910 parm
->ipmsgtag
= msgtag
;
1911 parm
->ipflags1
= (IPRMDATA
| IPNORPY
| flags1
);
1912 memcpy(parm
->iprmmsg
, prmmsg
, sizeof(parm
->iprmmsg
));
1914 b2f0_result
= b2f0(SEND
, parm
);
1916 if ((!b2f0_result
) && (msgid
))
1917 *msgid
= parm
->ipmsgid
;
1918 release_param(parm
);
1920 iucv_debug(2, "exiting");
1926 * Name: iucv_send2way
1927 * Purpose: This function transmits data to another application.
1928 * Data to be transmitted is in a buffer. The receiver
1929 * of the send is expected to reply to the message and
1930 * a buffer is provided into which IUCV moves the reply
1932 * Input: pathid - path identification number
1933 * trgcls - specifies target class
1934 * srccls - specifies the source message class
1935 * msgtag - specifies a tag associated with the message
1936 * flags1 - option for path
1937 * IPPRTY- specifies if you want to send priority message
1938 * buffer - address of send buffer
1939 * buflen - length of send buffer
1940 * ansbuf - address of buffer to reply with
1941 * anslen - length of buffer to reply with
1942 * Output: msgid - specifies the message ID.
1943 * Return: b2f0_result - return code from CP
1944 * (-EINVAL) - buffer or ansbuf address is NULL
1947 iucv_send2way (__u16 pathid
,
1953 void *buffer
, ulong buflen
, void *ansbuf
, ulong anslen
)
1958 iucv_debug(2, "entering");
1960 if (!buffer
|| !ansbuf
)
1963 parm
= (iparml_db
*)grab_param();
1965 parm
->ippathid
= pathid
;
1966 parm
->iptrgcls
= trgcls
;
1967 parm
->ipbfadr1
= (__u32
) ((ulong
) buffer
);
1968 parm
->ipbfln1f
= (__u32
) buflen
; /* length of message */
1969 parm
->ipbfadr2
= (__u32
) ((ulong
) ansbuf
);
1970 parm
->ipbfln2f
= (__u32
) anslen
;
1971 parm
->ipsrccls
= srccls
;
1972 parm
->ipmsgtag
= msgtag
;
1973 parm
->ipflags1
= flags1
; /* priority message */
1975 b2f0_result
= b2f0(SEND
, parm
);
1977 if ((!b2f0_result
) && (msgid
))
1978 *msgid
= parm
->ipmsgid
;
1979 release_param(parm
);
1981 iucv_debug(2, "exiting");
1987 * Name: iucv_send2way_array
1988 * Purpose: This function transmits data to another application.
1989 * The contents of buffer is the address of the array of
1990 * addresses and lengths of discontiguous buffers that hold
1991 * the message text. The receiver of the send is expected to
1992 * reply to the message and a buffer is provided into which
1993 * IUCV moves the reply to this message.
1994 * Input: pathid - path identification number
1995 * trgcls - specifies target class
1996 * srccls - specifies the source message class
1997 * msgtag - spcifies a tag to be associated with the message
1998 * flags1 - option for path
1999 * IPPRTY- specifies if you want to send priority message
2000 * buffer - address of array of send buffers
2001 * buflen - total length of send buffers
2002 * ansbuf - address of buffer to reply with
2003 * anslen - length of buffer to reply with
2004 * Output: msgid - specifies the message ID.
2005 * Return: b2f0_result - return code from CP
2006 * (-EINVAL) - buffer address is NULL
2009 iucv_send2way_array (__u16 pathid
,
2015 iucv_array_t
* buffer
,
2016 ulong buflen
, iucv_array_t
* ansbuf
, ulong anslen
)
2021 iucv_debug(2, "entering");
2023 if (!buffer
|| !ansbuf
)
2026 parm
= (iparml_db
*)grab_param();
2028 parm
->ippathid
= pathid
;
2029 parm
->iptrgcls
= trgcls
;
2030 parm
->ipbfadr1
= (__u32
) ((ulong
) buffer
);
2031 parm
->ipbfln1f
= (__u32
) buflen
; /* length of message */
2032 parm
->ipbfadr2
= (__u32
) ((ulong
) ansbuf
);
2033 parm
->ipbfln2f
= (__u32
) anslen
;
2034 parm
->ipsrccls
= srccls
;
2035 parm
->ipmsgtag
= msgtag
;
2036 parm
->ipflags1
= (IPBUFLST
| IPANSLST
| flags1
);
2037 b2f0_result
= b2f0(SEND
, parm
);
2038 if ((!b2f0_result
) && (msgid
))
2039 *msgid
= parm
->ipmsgid
;
2040 release_param(parm
);
2042 iucv_debug(2, "exiting");
2047 * Name: iucv_send2way_prmmsg
2048 * Purpose: This function transmits data to another application.
2049 * Prmmsg specifies that the 8-bytes of data are to be moved
2050 * into the parameter list. This is a two-way message and the
2051 * receiver of the message is expected to reply. A buffer
2052 * is provided into which IUCV moves the reply to this
2054 * Input: pathid - path identification number
2055 * trgcls - specifies target class
2056 * srccls - specifies the source message class
2057 * msgtag - specifies a tag to be associated with the message
2058 * flags1 - option for path
2059 * IPPRTY- specifies if you want to send priority message
2060 * prmmsg - 8-bytes of data to be placed in parameter list
2061 * ansbuf - address of buffer to reply with
2062 * anslen - length of buffer to reply with
2063 * Output: msgid - specifies the message ID.
2064 * Return: b2f0_result - return code from CP
2065 * (-EINVAL) - buffer address is NULL
2068 iucv_send2way_prmmsg (__u16 pathid
,
2073 ulong flags1
, __u8 prmmsg
[8], void *ansbuf
, ulong anslen
)
2078 iucv_debug(2, "entering");
2083 parm
= (iparml_dpl
*)grab_param();
2085 parm
->ippathid
= pathid
;
2086 parm
->iptrgcls
= trgcls
;
2087 parm
->ipsrccls
= srccls
;
2088 parm
->ipmsgtag
= msgtag
;
2089 parm
->ipbfadr2
= (__u32
) ((ulong
) ansbuf
);
2090 parm
->ipbfln2f
= (__u32
) anslen
;
2091 parm
->ipflags1
= (IPRMDATA
| flags1
); /* message in prmlist */
2092 memcpy(parm
->iprmmsg
, prmmsg
, sizeof(parm
->iprmmsg
));
2094 b2f0_result
= b2f0(SEND
, parm
);
2096 if ((!b2f0_result
) && (msgid
))
2097 *msgid
= parm
->ipmsgid
;
2098 release_param(parm
);
2100 iucv_debug(2, "exiting");
2106 * Name: iucv_send2way_prmmsg_array
2107 * Purpose: This function transmits data to another application.
2108 * Prmmsg specifies that the 8-bytes of data are to be moved
2109 * into the parameter list. This is a two-way message and the
2110 * receiver of the message is expected to reply. A buffer
2111 * is provided into which IUCV moves the reply to this
2112 * message. The contents of ansbuf is the address of the
2113 * array of addresses and lengths of discontiguous buffers
2114 * that contain the reply.
2115 * Input: pathid - path identification number
2116 * trgcls - specifies target class
2117 * srccls - specifies the source message class
2118 * msgtag - specifies a tag to be associated with the message
2119 * flags1 - option for path
2120 * IPPRTY- specifies if you want to send priority message
2121 * prmmsg - 8-bytes of data to be placed into the parameter list
2122 * ansbuf - address of buffer to reply with
2123 * anslen - length of buffer to reply with
2124 * Output: msgid - specifies the message ID.
2125 * Return: b2f0_result - return code from CP
2126 * (-EINVAL) - ansbuf address is NULL
2129 iucv_send2way_prmmsg_array (__u16 pathid
,
2136 iucv_array_t
* ansbuf
, ulong anslen
)
2141 iucv_debug(2, "entering");
2146 parm
= (iparml_dpl
*)grab_param();
2148 parm
->ippathid
= pathid
;
2149 parm
->iptrgcls
= trgcls
;
2150 parm
->ipsrccls
= srccls
;
2151 parm
->ipmsgtag
= msgtag
;
2152 parm
->ipbfadr2
= (__u32
) ((ulong
) ansbuf
);
2153 parm
->ipbfln2f
= (__u32
) anslen
;
2154 parm
->ipflags1
= (IPRMDATA
| IPANSLST
| flags1
);
2155 memcpy(parm
->iprmmsg
, prmmsg
, sizeof(parm
->iprmmsg
));
2156 b2f0_result
= b2f0(SEND
, parm
);
2157 if ((!b2f0_result
) && (msgid
))
2158 *msgid
= parm
->ipmsgid
;
2159 release_param(parm
);
2161 iucv_debug(2, "exiting");
2166 iucv_setmask_cpuid (void *result
)
2168 iparml_set_mask
*parm
;
2170 iucv_debug(1, "entering");
2171 parm
= (iparml_set_mask
*)grab_param();
2172 parm
->ipmask
= *((__u8
*)result
);
2173 *((ulong
*)result
) = b2f0(SETMASK
, parm
);
2174 release_param(parm
);
2176 iucv_debug(1, "b2f0_result = %ld", *((ulong
*)result
));
2177 iucv_debug(1, "exiting");
2181 * Name: iucv_setmask
2182 * Purpose: This function enables or disables the following IUCV
2183 * external interruptions: Nonpriority and priority message
2184 * interrupts, nonpriority and priority reply interrupts.
2185 * Input: SetMaskFlag - options for interrupts
2186 * 0x80 - Nonpriority_MessagePendingInterruptsFlag
2187 * 0x40 - Priority_MessagePendingInterruptsFlag
2188 * 0x20 - Nonpriority_MessageCompletionInterruptsFlag
2189 * 0x10 - Priority_MessageCompletionInterruptsFlag
2190 * 0x08 - IUCVControlInterruptsFlag
2192 * Return: b2f0_result - return code from CP
2195 iucv_setmask (int SetMaskFlag
)
2203 u
.param
= SetMaskFlag
;
2205 smp_call_function_on(iucv_setmask_cpuid
, &u
, 0, 1, iucv_cpuid
);
2213 * @pathid: Path identification number
2214 * @user_data: 16-byte of user data
2216 * This function terminates an iucv path.
2217 * Returns: return code from CP
2220 iucv_sever(__u16 pathid
, __u8 user_data
[16])
2222 iparml_control
*parm
;
2223 ulong b2f0_result
= 0;
2225 iucv_debug(1, "entering");
2226 parm
= (iparml_control
*)grab_param();
2228 memcpy(parm
->ipuser
, user_data
, sizeof(parm
->ipuser
));
2229 parm
->ippathid
= pathid
;
2231 b2f0_result
= b2f0(SEVER
, parm
);
2234 iucv_remove_pathid(pathid
);
2235 release_param(parm
);
2237 iucv_debug(1, "exiting");
2242 * Interrupt Handlers
2243 *******************************************************************************/
2247 * @regs: Current registers
2250 * Handles external interrupts coming in from CP.
2251 * Places the interrupt buffer on a queue and schedules iucv_tasklet_handler().
2254 iucv_irq_handler(struct pt_regs
*regs
, __u16 code
)
2256 iucv_irqdata
*irqdata
;
2258 irqdata
= kmalloc(sizeof(iucv_irqdata
), GFP_ATOMIC
);
2260 printk(KERN_WARNING
"%s: out of memory\n", __FUNCTION__
);
2264 memcpy(&irqdata
->data
, iucv_external_int_buffer
,
2265 sizeof(iucv_GeneralInterrupt
));
2267 spin_lock(&iucv_irq_queue_lock
);
2268 list_add_tail(&irqdata
->queue
, &iucv_irq_queue
);
2269 spin_unlock(&iucv_irq_queue_lock
);
2271 tasklet_schedule(&iucv_tasklet
);
2276 * @int_buf: Pointer to copy of external interrupt buffer
2278 * The workhorse for handling interrupts queued by iucv_irq_handler().
2279 * This function is called from the bottom half iucv_tasklet_handler().
2282 iucv_do_int(iucv_GeneralInterrupt
* int_buf
)
2285 struct list_head
*lh
;
2287 iucv_interrupt_ops_t
*interrupt
= NULL
; /* interrupt addresses */
2288 __u8 temp_buff1
[24], temp_buff2
[24]; /* masked handler id. */
2290 __u8 no_listener
[16] = "NO LISTENER";
2292 iucv_debug(2, "entering, pathid %d, type %02X",
2293 int_buf
->ippathid
, int_buf
->iptype
);
2294 iucv_dumpit("External Interrupt Buffer:",
2295 int_buf
, sizeof(iucv_GeneralInterrupt
));
2297 ASCEBC (no_listener
, 16);
2299 if (int_buf
->iptype
!= 01) {
2300 if ((int_buf
->ippathid
) > (max_connections
- 1)) {
2301 printk(KERN_WARNING
"%s: Got interrupt with pathid %d"
2302 " > max_connections (%ld)\n", __FUNCTION__
,
2303 int_buf
->ippathid
, max_connections
- 1);
2305 h
= iucv_pathid_table
[int_buf
->ippathid
];
2306 interrupt
= h
->interrupt_table
;
2307 iucv_dumpit("Handler:", h
, sizeof(handler
));
2311 /* end of if statement */
2312 switch (int_buf
->iptype
) {
2313 case 0x01: /* connection pending */
2314 if (messagesDisabled
) {
2316 messagesDisabled
= 0;
2318 spin_lock_irqsave(&iucv_lock
, flags
);
2319 list_for_each(lh
, &iucv_handler_table
) {
2320 h
= list_entry(lh
, handler
, list
);
2321 memcpy(temp_buff1
, &(int_buf
->ipvmid
), 24);
2322 memcpy(temp_buff2
, &(h
->id
.userid
), 24);
2323 for (j
= 0; j
< 24; j
++) {
2324 temp_buff1
[j
] &= (h
->id
.mask
)[j
];
2325 temp_buff2
[j
] &= (h
->id
.mask
)[j
];
2328 iucv_dumpit("temp_buff1:",
2329 temp_buff1
, sizeof(temp_buff1
));
2330 iucv_dumpit("temp_buff2",
2331 temp_buff2
, sizeof(temp_buff2
));
2333 if (!memcmp (temp_buff1
, temp_buff2
, 24)) {
2336 "found a matching handler");
2341 spin_unlock_irqrestore (&iucv_lock
, flags
);
2343 /* ADD PATH TO PATHID TABLE */
2344 rc
= iucv_add_pathid(int_buf
->ippathid
, h
);
2346 iucv_sever (int_buf
->ippathid
,
2349 "add_pathid failed, rc = %d",
2352 interrupt
= h
->interrupt_table
;
2353 if (interrupt
->ConnectionPending
) {
2354 EBCASC (int_buf
->ipvmid
, 8);
2355 interrupt
->ConnectionPending(
2356 (iucv_ConnectionPending
*)int_buf
,
2359 iucv_sever(int_buf
->ippathid
,
2363 iucv_sever(int_buf
->ippathid
, no_listener
);
2366 case 0x02: /*connection complete */
2367 if (messagesDisabled
) {
2369 messagesDisabled
= 0;
2372 if (interrupt
->ConnectionComplete
)
2374 interrupt
->ConnectionComplete(
2375 (iucv_ConnectionComplete
*)int_buf
,
2380 "ConnectionComplete not called");
2382 iucv_sever(int_buf
->ippathid
, no_listener
);
2385 case 0x03: /* connection severed */
2386 if (messagesDisabled
) {
2388 messagesDisabled
= 0;
2391 if (interrupt
->ConnectionSevered
)
2392 interrupt
->ConnectionSevered(
2393 (iucv_ConnectionSevered
*)int_buf
,
2397 iucv_sever (int_buf
->ippathid
, no_listener
);
2399 iucv_sever(int_buf
->ippathid
, no_listener
);
2402 case 0x04: /* connection quiesced */
2403 if (messagesDisabled
) {
2405 messagesDisabled
= 0;
2408 if (interrupt
->ConnectionQuiesced
)
2409 interrupt
->ConnectionQuiesced(
2410 (iucv_ConnectionQuiesced
*)int_buf
,
2414 "ConnectionQuiesced not called");
2418 case 0x05: /* connection resumed */
2419 if (messagesDisabled
) {
2421 messagesDisabled
= 0;
2424 if (interrupt
->ConnectionResumed
)
2425 interrupt
->ConnectionResumed(
2426 (iucv_ConnectionResumed
*)int_buf
,
2430 "ConnectionResumed not called");
2434 case 0x06: /* priority message complete */
2435 case 0x07: /* nonpriority message complete */
2437 if (interrupt
->MessageComplete
)
2438 interrupt
->MessageComplete(
2439 (iucv_MessageComplete
*)int_buf
,
2443 "MessageComplete not called");
2447 case 0x08: /* priority message pending */
2448 case 0x09: /* nonpriority message pending */
2450 if (interrupt
->MessagePending
)
2451 interrupt
->MessagePending(
2452 (iucv_MessagePending
*) int_buf
,
2456 "MessagePending not called");
2459 default: /* unknown iucv type */
2460 printk(KERN_WARNING
"%s: unknown iucv interrupt\n",
2465 iucv_debug(2, "exiting pathid %d, type %02X",
2466 int_buf
->ippathid
, int_buf
->iptype
);
2472 * iucv_tasklet_handler:
2474 * This function loops over the queue of irq buffers and runs iucv_do_int()
2475 * on every queue element.
2478 iucv_tasklet_handler(unsigned long ignored
)
2480 struct list_head head
;
2481 struct list_head
*next
;
2484 spin_lock_irqsave(&iucv_irq_queue_lock
, flags
);
2485 list_add(&head
, &iucv_irq_queue
);
2486 list_del_init(&iucv_irq_queue
);
2487 spin_unlock_irqrestore (&iucv_irq_queue_lock
, flags
);
2490 while (next
!= &head
) {
2491 iucv_irqdata
*p
= list_entry(next
, iucv_irqdata
, queue
);
2494 iucv_do_int(&p
->data
);
2501 subsys_initcall(iucv_init
);
2502 module_exit(iucv_exit
);
2505 * Export all public stuff
2507 EXPORT_SYMBOL (iucv_bus
);
2508 EXPORT_SYMBOL (iucv_root
);
2509 EXPORT_SYMBOL (iucv_accept
);
2510 EXPORT_SYMBOL (iucv_connect
);
2512 EXPORT_SYMBOL (iucv_purge
);
2513 EXPORT_SYMBOL (iucv_query_maxconn
);
2514 EXPORT_SYMBOL (iucv_query_bufsize
);
2515 EXPORT_SYMBOL (iucv_quiesce
);
2517 EXPORT_SYMBOL (iucv_receive
);
2519 EXPORT_SYMBOL (iucv_receive_array
);
2521 EXPORT_SYMBOL (iucv_reject
);
2523 EXPORT_SYMBOL (iucv_reply
);
2524 EXPORT_SYMBOL (iucv_reply_array
);
2525 EXPORT_SYMBOL (iucv_resume
);
2527 EXPORT_SYMBOL (iucv_reply_prmmsg
);
2528 EXPORT_SYMBOL (iucv_send
);
2529 EXPORT_SYMBOL (iucv_send2way
);
2530 EXPORT_SYMBOL (iucv_send2way_array
);
2531 EXPORT_SYMBOL (iucv_send2way_prmmsg
);
2532 EXPORT_SYMBOL (iucv_send2way_prmmsg_array
);
2534 EXPORT_SYMBOL (iucv_send_array
);
2535 EXPORT_SYMBOL (iucv_send_prmmsg
);
2536 EXPORT_SYMBOL (iucv_setmask
);
2538 EXPORT_SYMBOL (iucv_sever
);
2539 EXPORT_SYMBOL (iucv_register_program
);
2540 EXPORT_SYMBOL (iucv_unregister_program
);