Sunday June 19, 2005
Continuing my discussion of the Solaris 1394 Software Framework, in this post I'm going to go into some detail on the methods by which a 1394 target driver can register and deregister itself with the core framework. And, in the process, I will also touch on the Solaris event notification mechanisms leveraged by the framework.
All 1394 target drivers must register themselves with the framework in order to operate properly. The 1394 framework will make an association with the device driver instance for the target and the corresponding HAL driver instance (called the 'parent') for the adapter to which it is attached.
In addition, the 1394 framework will allocate resources (internally) to track the target driver state (in the target driver 'handle') and return useful information about the current state of the target device on the 1394 bus and DMA and/or interrupt properties of the parent HAL.[1]
/*
* Function: t1394_attach()
* Input(s): dip The dip given to the target driver
* in it's attach() routine
* version The version of the target driver -
* T1394_VERSION_V1
* flags The flags parameter is unused (for now)
*
* Output(s): attachinfo Used to pass info back to target,
* including bus generation, local
* node ID, dma attribute, etc.
* t1394_hdl The target "handle" to be used for
* all subsequent calls into the
* 1394 Software Framework
*
* Description: t1394_attach() registers the target (based on its dip) with
* the 1394 Software Framework. It returns the bus_generation,
* local_nodeID, iblock_cookie and other useful information to
* the target, as well as a handle (t1394_hdl) that will be used
* in all subsequent calls into this framework.
*/
/* ARGSUSED */
int
t1394_attach(
dev_info_t *dip, /* supplied by the target */
int version, /* supplied by the target */
uint_t flags, /* supplied by the target */
t1394_attachinfo_t *attachinfo, /* filled in by the framework */
t1394_handle_t *t1394_hdl) /* returned to the target */
During a target driver's attach processing, it calls t1394_attach() to register with the 1394 Software Framework. The Framework initializes any necessary internal data structures and returns a t1394_hdl which the target driver uses with all other calls into the Framework. The Framework also returns additional information in attachinfo, which is needed by some target driver implementations.
/*
* t1394_attachinfo_t
* is filled in and returned by the 1394 Framework at attach time
* (returned from the call to t1394_attach()). This structure contains
* the t1394_localinfo_t structure described above, as well as the
* iblock cookie and the attributes necessary for DMA allocations, etc.
*/
typedef struct t1394_attachinfo_s {
ddi_iblock_cookie_t iblock_cookie;
ddi_device_acc_attr_t acc_attr;
ddi_dma_attr_t dma_attr;
t1394_localinfo_t localinfo;
} t1394_attachinfo_t;
/*
* t1394_localinfo_t
* is filled in and returned by the 1394 Framework at attach time
* (in the t1394_attachinfo_t structure returned from t1394_attach())
* to provide the local host nodeID and the current bus generation.
*/
typedef struct t1394_localinfo_s {
uint_t bus_generation;
uint_t local_nodeID;
} t1394_localinfo_t;
/* * Function: t1394_detach() * Input(s): t1394_hdl The target "handle" returned by * t1394_attach() * flags The flags parameter is unused (for now) * * Output(s): DDI_SUCCESS Target successfully detached * DDI_FAILURE Target failed to detach * * Description: t1394_detach() unregisters the target from the 1394 Software * Framework. t1394_detach() can fail if the target has any * allocated commands that haven't been freed. */ /* ARGSUSED */ int t1394_detach(t1394_handle_t *t1394_hdl, uint_t flags)
The target driver calls t1394_detach() to deregister from the 1394 Software Framework. Typically the target calls this from its detach(9E) routine.
Target drivers may register callbacks for general 1394 Software Framework events by using the Solaris Event Framework. All calls to the Event Framework must be performed before the call to t1394_attach() is performed. For details about the Solaris Event Framework, see:
The following events are supported by the 1394 Framework:
void (*handler)(dev_info_t *dip, ddi_eventcookie_t cookie, void *arg,
void *impl_data);
The callback impl_data provided to the eventcalls associated with each of these events is a t1394_localinfo_t *, as described above.
Note: Within an event callback function, a target driver shouldn't invoke any procedure that blocks or sleeps. For example, an event callback function shouldn't issue any outgoing asynch request that has the CMD1394_BLOCKING flag set. (Yep, again... more on this in a later blog entry).
OK. So obviously there's more I could say here about the details of Framework's implementation for tracking and coordinating target drivers and their events, but as I've said before that I want to first go through the Framework at a high-level.
Next time, I'm going to go over the outgoing asynch interfaces: command structure allocation, command completion mechanisms (event-driver, blocking, polling), command types (read, write, lock), quadlet requests, block requests, etc. That's a ton of stuff to cover, so maybe it won't all get into a single blog entry, but anyway that's where I'm headed next.