📄 sources.htm
字号:
/***************************************************
* The bus number is wildcarded to *
* deregister on all instances of the tc *
* bus. The controller name and number are *
* wildcarded. This causes all instances *
* that match the specified driver structure *
* to be deregistered. Through the *
* bus-specific code, this interface results *
* in a call to the none_ctlr_unattach *
* interface for each instance of the *
* controller. *
***************************************************/
</p><p>
</p><p>
</p><p>
</p><p>
if (unconfigure_driver(DN_BUSNAME1,
DRIVER_WILDNUM, &nonedriver,
DN_BUSNAME1, DRIVER_WILDNUM) != 0) {
</p><p>
</p><p>
</p><p>
</p><p>
/***************************************************
* DEBUG STATEMENT *
***************************************************/
#ifdef NONE_DEBUG
printf("none_configure:unconfigure_driver failed.\n");
#endif /* NONE_DEBUG */
</p><p>
</p><p>
</p><p>
</p><p>
return(ESRCH);
}
}
<br>
none_is_dynamic = 0;
none_config = FALSE;
break;
</p></pre>
<p>
</p><p>
</p><pre><p>
</p><p>
</p><p>
</p><p>
/**************************************************
* Requests to query a loadable subsystem will *
* only succeed if the CFG_OP_QUERY: entry *
* returns success. *
**************************************************/
</p><p>
</p><p>
</p><p>
</p><p>
case CFG_OP_QUERY:
break;
</p></pre>
<p>
</p><p>
</p><pre><p>
</p><p>
</p><p>
</p><p>
/**************************************************
* Code to perform the tasks associated with a *
* system manager request to reconfigure the *
* currently loaded device driver. *
**************************************************/
</p><p>
</p><p>
</p><p>
</p><p>
case CFG_OP_RECONFIGURE:
break;
</p></pre>
<p>
</p><p>
</p><pre> default: /* Unknown operation type */
return(ENOTSUP);
}
<p>
</p><p>
</p><p>
</p><p>
/***************************************************
* The driver's configure interface has *
* completed successfully. Return a success *
* status. *
***************************************************/
</p><p>
</p><p>
</p><p>
</p><p>
return(ESUCCESS);
}
</p></pre>
<p>
</p><p>
</p><pre>/***************************************************
* register_configuration() *
***************************************************
* Name: register_configuration *
* *
* Arguments: None *
* *
* Kernel support interface calls: *
* *
* o create_controller_struct *
* o create_device_struct *
* *
* Called by: *
* *
* o During dynamic configuration *
* - none_configure *
* *
* o During static Configuration *
* - cfgmgr framework callback *
* Specifically, the /dev/none driver *
* registers an interface called *
* callback_register_configuration. *
* The cfgmgr framework calls *
* callback_register_configuration, *
* which contains a call to the *
* register_configuration interface. *
* *
* Return Codes: *
* *
* Failure: ENOMEM *
* *
* Description: *
* *
* The register_configuration interface is *
* responsible for registering the controller and *
* device information for the /dev/none driver. *
* The dynamically configured /dev/none driver *
* directly calls the register_configuration *
* interface. The statically configured /dev/none *
* driver calls register_configuration through a *
* register callback called *
* callback_register_configuration. (The *
* none_configure interface calls the *
* register_callback interface to register the *
* register_configuration interface so that it can *
* be called at some later time. *
* *
* Writing an interface similar to *
* register_configuration is the method for *
* specifying the controller and device *
* information associated with a device driver. *
* *
* The register_configuration interface causes the *
* appropriate controller and device structures *
* to be created and integrated into the system *
* (hardware) configuration tree for statically *
* and dynamically configured drivers. *
* *
* This method requires device driver writers to *
* determine how much operator control should be *
* allowed over the system's topology creation *
* support code. If appropriate, driver writers *
* can define sysconfigtab database fields that *
* will allow the operator to control what *
* hardware-related information that this *
* interface passes to the appropriate structures. *
***************************************************/
int
register_configuration()
{
/***************************************************
* Declare controller_config and device_config *
* structures and structure pointers. These *
* structures are the storage mechanism for *
* populating the controller and device *
* associated with a specific device driver. *
***************************************************/
struct controller_config ctlr_register;
struct controller_config * ctlr_register_ptr = &ctlr_register;
struct device_config device_register;
struct device_config * device_register_ptr = &device_register;
int status;
/***************************************************
* Register a controller structure for the *
* /dev/none driver. The system manager can *
* specify attribute fields for the none: entry in *
* etc/sysconfigtab database that determine the *
* number of controller structures to be created. *
* It is here that the user-configurable attribute *
* NNONE would be used to regulate the number of *
* controller structures to be created up to the *
* MAX_NNONE value defined in the driver. *
***************************************************/
ctlr_register_ptr->revision = CTLR_CONFIG_REVISION;
strcpy(ctlr_register_ptr->subsystem_name, mcfgname);
strcpy(ctlr_register_ptr->bus_name,DN_BUSNAME1);
ctlr_register_ptr->devdriver = &nonedriver;
/***************************************************
* Call the create_controller_struct to create the *
* controller structure associated with the *
* /dev/none driver. *
***************************************************/
status = create_controller_struct(ctlr_register_ptr);
if(status != ESUCCESS)
return (status);
/***************************************************
* Register a device structure for the /dev/none *
* driver. *
***************************************************/
device_register_ptr->revision = DEVICE_CONFIG_REVISION;
strcpy(device_register_ptr->device_type,"disk");
strcpy(device_register_ptr->device_name,"nonedev");
strcpy(device_register_ptr->controller_name,"none");
device_register_ptr->controller_num = 0;
/***************************************************
* Call the create_device_struct to create the *
* device structure associated with the /dev/none *
* driver. *
***************************************************/
status = create_device_struct(device_register_ptr);
if(status != ESUCCESS)
return(status);
return(ESUCCESS);
}
</pre>
<p>
</p><p>
</p><pre>/***************************************************
* register_major_number() *
***************************************************
* Name: register_major_number *
* *
* Arguments: *
* *
* *
* Kernel support interface calls: *
* *
* o devsw_add *
* *
* Called by: *
* *
* o cfgmgr framework *
* *
* Return Codes: *
* *
* Success: ESUCCESS *
* *
* Failure: ENODEV *
* *
* Description: *
* *
* The register_major_number interface registers *
* a driver's I/O services interfaces (and other *
* information) and reserves a major number. It *
* accomplishes these tasks by calling the *
* devsw_add interface. *
***************************************************/
int
register_major_number()
{
/***************************************************
* If there are no devices present in the system *
* after driver configuration completes, set the *
* cfgmgr framework status to unconfigured and *
* exit the callback. *
***************************************************/
if (num_none == 0) {
return (ENODEV);
}
/***************************************************
* Call the devsw_add interface to register the *
* driver's I/O services interfaces (and other *
* information) and to reserve a major number in *
* the device switch table. Each allocation *
* provides a block and character device entry. *
***************************************************/
majnum = devsw_add(mcfgname, MAJOR_INSTANCE,
majnum, &none_devsw_entry);
/***************************************************
* The call to devsw_add could fail if the driver *
* requests a specific major number and that major *
* number is
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -