|
|
The pseudo_devmgmt_req routine performs the same operations as the cmos_devmgmt_req routine defined for the udi_cmos driver.
static void pseudo_devmgmt_req(udi_mgmt_cb_t * cb, udi_ubit8_t mgmt_op, udi_ubit8_t parent_id) { pseudo_region_data_t *rdata = UDI_GCB(cb)->context;switch (mgmt_op) { case UDI_DMGMT_UNBIND: /* * Keep a link back to this CB for use in the ack. */ rdata->bus_bind_cb->gcb.initiator_context = cb;
/* * Do the metalanguage-specific unbind */ udi_bus_unbind_req(rdata->bus_bind_cb); break; default: udi_devmgmt_ack(cb, 0, UDI_OK); } }
See ``udi_cmos Management Agent channel operations'' for a description.
Final cleanup for the pseudod driver is different from the final cleanup for the udi_cmos driver, in that the pseudod driver writes a log entry before final cleanup. Although logging is not required (the udi_cmos driver, for example, does no logging), it is an important means by which driver errors can be traced.
static udi_log_write_call_t cleanup_req_logged_cb;static void pseudo_final_cleanup_req(udi_mgmt_cb_t * cb) { udi_log_write(cleanup_req_logged_cb, UDI_GCB(cb), UDI_TREVENT_LOCAL_PROC_ENTRY, UDI_LOG_INFORMATION, 0, UDI_OK, 1500); }
static void cleanup_req_logged_cb(udi_cb_t *gcb, udi_status_t correlated_status) { udi_mgmt_cb_t *cb = UDI_MCB(gcb, udi_mgmt_cb_t);
/* * TODO: Release any data which was allocated and not freed by other * tear-down processing */ udi_final_cleanup_ack(cb); }
When the UDI environment issues the udi_final_cleanup_req(3udi) call, the driver responds with pseudo_final_cleanup_req, which (instead of issuing the call to udi_final_cleanup_ack(3udi) as the cmos_final_cleanup_req routine does) calls udi_log_write(3udi). The callback routine for udi_log_write, cleanup_req_logged_cb, then issues the udi_final_cleanup_ack (after udi_log_write completes).
The udi_log_write records the shutdown of the driver. The first argument is the callback routine. The second argument is the saem control block passed to the driver from the environment, which includes the context of the operation. UDI_TREVENT_LOCAL_PROC_ENTRY and UDI_LOG_INFORMATION indicate that the log is recording entry into a local driver routine, and that this event is an expected driver operation (see udi_trevent_t(3udi) and udi_log_write(3udi)).
The ``0'' argument indicates theat this event applies to the Management Metalanguage; other events might use other metalanguage numbers as defined by the driver in a meta declaration in the driver's udiprops.txt (see ``Module and region declarations''.
Also see Tracing and Logging in the UDI Core Specification for other event codes and information on tracing events.