DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
UDI driver coding basics

Channel operations initialization

Communication channels between regions are initialized with an array of udi_ops_init_t structures, one array element per channel. The udi_ops_init_t structure contains information the environment needs to create channel endpoints for a particular type of operations vector and control block usage. Each channel is initialized according to the specifications in the array element.

Once this array is initialized in the driver code, it's used in an init_info_t structure, which the UDI environment uses to initialize a driver instance (see ``Driver initialization structure'').

The udi_ops_init_t structure has these fields:

   typedef void udi_op_t (void);
   

typedef udi_op_t const udi_ops_vector_t ;

typedef struct { udi_index_t ops_idx ; udi_index_t meta_idx ; udi_index_t meta_ops_num ; udi_size_t chan_context_size ; udi_ops_vector_t *ops_vector ; } udi_ops_init_t ;


ops_idx
a non-zero channel ops index number, assigned by the driver to uniquely identify this set of entry-point related properties for use in other initialization structures and service calls, or zero to terminate the ops_init_list list to which this structure belongs. These are normally defined within the C source code of the driver module, as shown for the sample drivers in ``Channel operations indexes''.

meta_idx
a non-zero metalanguage index number, assigned by the driver to uniquely identify a set of metalanguage related properties for the channel. These are defined for the sample drivers in the build instructions section of each driver's udiprops.txt file (see ``Build instructions'').

meta_ops_num
a metalanguage-specific number, defined in the UDI specification for the metalanguage named by meta_idx, that uniquely identifies an operations vector type defined by that metalanguage.

chan_context_size
the size, in bytes, of a context area that will be automatically allocated, if non-zero, whenever the specified ops_idx is used to bind a child or parent instance to a driver instance or to bind a secondary region to the primary region for this driver. If non-zero, the value must be at least sizeof(udi_chan_context_t) (see udi_chan_context_t(3udi)) and must not exceed UDI_MIN_ALLOC_LIMIT (see the discussion of the init_context structure under ``Region data definitions'').

ops_vector
is a pointer to the metalanguage-specific meta_role__ops_t channel operations vector structure (see Calling Sequence and Naming Conventions in the Core Specification for an overview of UDI function naming conventions). This structure contains pointers to the various entry point routines for this type of channel and must be a constant initialized variable. The address of this structure must be cast to (udi_ops_vector_t *) in order to be used as a value for ops_vector.

The udi_cmos and pseudod drivers define these channel operation initialization arrays:

cmos_udi.c sample code (cont.)
   /*
    * --------------------------------------------------------------------
    * Meta operations init section:
    * --------------------------------------------------------------------
    */
   static udi_ops_init_t udi_cmos_ops_init_list[] = {
   	{
   		GIO_OPS_IDX,
   		CMOS_GIO_META,		/* meta index
   					 * [from udiprops.txt] */
   		UDI_GIO_PROVIDER_OPS_NUM,
   		0,			/* no channel context */
   		(udi_ops_vector_t *)&cmos_gio_provider_ops,
   		cmos_default_op_flags	/* op_flags */
   	},
   	{
   		BUS_DEVICE_OPS_IDX,
   		CMOS_BRIDGE_META,	/* meta index
   					 * [from udiprops.txt] */
   		UDI_BUS_DEVICE_OPS_NUM,
   		0,			/* no channel context */
   		(udi_ops_vector_t *)&cmos_bus_device_ops,
   		cmos_default_op_flags	/* op_flags */
   	},
   #if DO_INTERRUPTS
   	{
   		INTR_HANDLER_OPS_IDX,
   		CMOS_BRIDGE_META,	/* meta index
   					 * [from udiprops.txt] */
   		UDI_INTR_HANDLER_OPS_NUM,
   		0,			/* no channel context */
   		(udi_ops_vector_t *)&cmos_intr_handler_ops,
   		cmos_default_op_flags	/* op_flags */
   	},
   #endif /* DO_INTERRUPTS */
   	{
   		0	/* Terminator */
   	}
   };
pseudod.c sample code (cont.)
   static udi_ops_init_t pseudo_ops_init_list[] = {
   	{
   	 PSEUDO_GIO_INTERFACE,
   	 PSEUDO_GIO_META,		/* meta index */
   	 UDI_GIO_PROVIDER_OPS_NUM,	/* meta ops num */
   	 0,				/* chan context size */
   	 (udi_ops_vector_t *) & pseudo_gio_provider_ops,	/* ops vector */
   	 pseudo_default_op_flags
   	 },
   	{
   	 PSEUDO_BUS_INTERFACE,
   	 PSEUDO_BUS_META,		/* Bus meta index [from udiprops.txt] */
   	 UDI_BUS_DEVICE_OPS_NUM,
   	 0,				/* channel context size */
   	 (udi_ops_vector_t *) & pseudo_bus_device_ops,
   	 pseudo_default_op_flags
   	 },
   	{
   	 0}
   };

The two sample drivers define similar operation vectors for the GIO provider operations defined in ``GIO metalanguage entry points'' and for the bus device role operations defined in ``Bus bridge metalanguage entry points''. The udi_cmos code also provide an optional set of interrupt handling operations. See the element descriptions above.

The chan_context_size is ``0'' for each vector, as required by the UDI Core Specification. A lone ops_idx of ``0'' terminates each list.

For more on how these structures are used during driver initialization, see ``Driver initialization structure''.


Next topic: Channel operation data layouts
Previous topic: Primary region initialization

© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - 19 June 2005