Beispiel #1
0
/*
功能:改变所有设备的power state
参数:
      newState     设备将要达到的power state
	  context      函数体中木有用到。。。。。?????
返回:0   __flase    失败
      1   __true     成功
*/
static __bool PMC_API _power_callback(int newState, int context)
{
	PDEVICE_INFO dev;
	DEVICE_LIST::iterator it;
	PDRIVER_INFO drv;
	IOSS_STATUS code;
    
	//遍历设备列表中的所有设备
	for(it = g_Devices.begin(); it != g_Devices.end(); it++){
		dev = it->second;//设备信息
		drv = dev->d;//驱动信息
		
		//调用驱动dll导出函数改变power state
		if( (dev->flags & DF_Active) && (drv->dispatch)){
			code = drv->dispatch(dev, DISP_POWER_STATE_CHANGED, newState);
			if(code){
				utils_error(
					"Error : device %s vetoed `power-state-changed' command,"
					"error code 0x%08x.\n"
					"This may cause unpredictable result.\n",
					(char*)CDeviceName(dev->k),
					code
					);
				return __false;
			}
		}
	}

	return __true;
}
void detach_tag_from_device(PRTK_TAG tag)
{
	PDRIVER_INFO drv;

	// TODO: notify the device we're depriving this tag
	
	if(tag->d.DeviceObj){
		drv = tag->d.DeviceObj->d;
		if(drv && drv->dispatch){
			drv->dispatch(tag->d.DeviceObj, DISP_DB_DROP_TAG, (int)tag);
		}
		// detach tag from the old device
		RtkRemoveEntryList(&tag->d.DeviceLink);
		RtkInitializeListHead(&tag->d.DeviceLink);
	}else{
		assert(RtkIsListEmpty(&tag->d.DeviceLink));
	}

	tag->d.DeviceObj = 0;
}