⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bus.c

📁 Linux Kernel 2.6.9 for OMAP1710
💻 C
📖 第 1 页 / 共 2 页
字号:
	if (status_changed)		*status_changed = 0;	old_status = device->status;	/*	 * Make sure this device's parent is present before we go about	 * messing with the device.	 */	if (device->parent && !device->parent->status.present) {		device->status = device->parent->status;		if (STRUCT_TO_INT(old_status) != STRUCT_TO_INT(device->status)) {			if (status_changed)				*status_changed = 1;		}		return_VALUE(0);	}	status = acpi_bus_get_status(device);	if (ACPI_FAILURE(status))		return_VALUE(-ENODEV);	if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))		return_VALUE(0);	if (status_changed)		*status_changed = 1;		/*	 * Device Insertion/Removal	 */	if ((device->status.present) && !(old_status.present)) {		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));		/* TBD: Handle device insertion */	}	else if (!(device->status.present) && (old_status.present)) {		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));		/* TBD: Handle device removal */	}	return_VALUE(0);}static intacpi_bus_check_scope (	struct acpi_device	*device){	int			result = 0;	int			status_changed = 0;	ACPI_FUNCTION_TRACE("acpi_bus_check_scope");	if (!device)		return_VALUE(-EINVAL);	/* Status Change? */	result = acpi_bus_check_device(device, &status_changed);	if (result)		return_VALUE(result);	if (!status_changed)		return_VALUE(0);	/*	 * TBD: Enumerate child devices within this device's scope and	 *       run acpi_bus_check_device()'s on them.	 */	return_VALUE(0);}/** * acpi_bus_notify * --------------- * Callback for all 'system-level' device notifications (values 0x00-0x7F). */static void acpi_bus_notify (	acpi_handle             handle,	u32                     type,	void                    *data){	int			result = 0;	struct acpi_device	*device = NULL;	ACPI_FUNCTION_TRACE("acpi_bus_notify");	if (acpi_bus_get_device(handle, &device))		return_VOID;	switch (type) {	case ACPI_NOTIFY_BUS_CHECK:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS CHECK notification for device [%s]\n", 			device->pnp.bus_id));		result = acpi_bus_check_scope(device);		/* 		 * TBD: We'll need to outsource certain events to non-ACPI		 *	drivers via the device manager (device.c).		 */		break;	case ACPI_NOTIFY_DEVICE_CHECK:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK notification for device [%s]\n", 			device->pnp.bus_id));		result = acpi_bus_check_device(device, NULL);		/* 		 * TBD: We'll need to outsource certain events to non-ACPI		 *	drivers via the device manager (device.c).		 */		break;	case ACPI_NOTIFY_DEVICE_WAKE:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE WAKE notification for device [%s]\n", 			device->pnp.bus_id));		/* TBD */		break;	case ACPI_NOTIFY_EJECT_REQUEST:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received EJECT REQUEST notification for device [%s]\n", 			device->pnp.bus_id));		/* TBD */		break;	case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK LIGHT notification for device [%s]\n", 			device->pnp.bus_id));		/* TBD: Exactly what does 'light' mean? */		break;	case ACPI_NOTIFY_FREQUENCY_MISMATCH:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received FREQUENCY MISMATCH notification for device [%s]\n", 			device->pnp.bus_id));		/* TBD */		break;	case ACPI_NOTIFY_BUS_MODE_MISMATCH:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS MODE MISMATCH notification for device [%s]\n", 			device->pnp.bus_id));		/* TBD */		break;	case ACPI_NOTIFY_POWER_FAULT:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received POWER FAULT notification for device [%s]\n", 			device->pnp.bus_id));		/* TBD */		break;	default:		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received unknown/unsupported notification [%08x]\n", 			type));		break;	}	return_VOID;}/* --------------------------------------------------------------------------                             Initialization/Cleanup   -------------------------------------------------------------------------- */static int __initacpi_bus_init_irq (void){	acpi_status		status = AE_OK;	union acpi_object	arg = {ACPI_TYPE_INTEGER};	struct acpi_object_list	arg_list = {1, &arg};	char			*message = NULL;	ACPI_FUNCTION_TRACE("acpi_bus_init_irq");	/* 	 * Let the system know what interrupt model we are using by	 * evaluating the \_PIC object, if exists.	 */	switch (acpi_irq_model) {	case ACPI_IRQ_MODEL_PIC:		message = "PIC";		break;	case ACPI_IRQ_MODEL_IOAPIC:		message = "IOAPIC";		break;	case ACPI_IRQ_MODEL_IOSAPIC:		message = "IOSAPIC";		break;	default:		printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");		return_VALUE(-ENODEV);	}	printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);	arg.integer.value = acpi_irq_model;	status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);	if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n"));		return_VALUE(-ENODEV);	}	return_VALUE(0);}void __initacpi_early_init (void){	acpi_status		status = AE_OK;	struct acpi_buffer	buffer = {sizeof(acpi_fadt), &acpi_fadt};	ACPI_FUNCTION_TRACE("acpi_early_init");	if (acpi_disabled)		return;	/* enable workarounds, unless strict ACPI spec. compliance */	if (!acpi_strict)		acpi_gbl_enable_interpreter_slack = TRUE;	status = acpi_initialize_subsystem();	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to initialize the ACPI Interpreter\n");		goto error0;	}	status = acpi_load_tables();	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to load the System Description Tables\n");		goto error0;	}	/*	 * Get a separate copy of the FADT for use by other drivers.	 */	status = acpi_get_table(ACPI_TABLE_FADT, 1, &buffer);	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to get the FADT\n");		goto error0;	}#ifdef CONFIG_X86	if (!acpi_ioapic) {		extern acpi_interrupt_flags acpi_sci_flags;		/* compatible (0) means level (3) */		if (acpi_sci_flags.trigger == 0)			acpi_sci_flags.trigger = 3;		/* Set PIC-mode SCI trigger type */		acpi_pic_sci_set_trigger(acpi_fadt.sci_int, acpi_sci_flags.trigger);	} else {		extern int acpi_sci_override_gsi;		/*		 * now that acpi_fadt is initialized,		 * update it with result from INT_SRC_OVR parsing		 */		acpi_fadt.sci_int = acpi_sci_override_gsi;	}#endif	status = acpi_enable_subsystem(~(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE));	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to enable ACPI\n");		goto error0;	}	return;error0:	disable_acpi();	return;}static int __initacpi_bus_init (void){	int			result = 0;	acpi_status		status = AE_OK;	extern acpi_status	acpi_os_initialize1(void);	ACPI_FUNCTION_TRACE("acpi_bus_init");	status = acpi_os_initialize1();	status = acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to start the ACPI Interpreter\n");		goto error1;	}	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to initialize ACPI OS objects\n");		goto error1;	}#ifdef CONFIG_ACPI_EC	/*	 * ACPI 2.0 requires the EC driver to be loaded and work before	 * the EC device is found in the namespace (i.e. before acpi_initialize_objects()	 * is called).	 *	 * This is accomplished by looking for the ECDT table, and getting 	 * the EC parameters out of that.	 */	status = acpi_ec_ecdt_probe();	/* Ignore result. Not having an ECDT is not fatal. */#endif	status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");		goto error1;	}	printk(KERN_INFO PREFIX "Interpreter enabled\n");	/*	 * Get the system interrupt model and evaluate \_PIC.	 */	result = acpi_bus_init_irq();	if (result)		goto error1;	/*	 * Register the for all standard device notifications.	 */	status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL);	if (ACPI_FAILURE(status)) {		printk(KERN_ERR PREFIX "Unable to register for device notifications\n");		goto error1;	}	/*	 * Create the top ACPI proc directory	 */	acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);	return_VALUE(0);	/* Mimic structured exception handling */error1:	acpi_terminate();	return_VALUE(-ENODEV);}decl_subsys(acpi,NULL,NULL);static int __init acpi_init (void){	int			result = 0;	ACPI_FUNCTION_TRACE("acpi_init");	printk(KERN_INFO PREFIX "Subsystem revision %08x\n",		ACPI_CA_VERSION);	if (acpi_disabled) {		printk(KERN_INFO PREFIX "Interpreter disabled.\n");		return -ENODEV;	}	firmware_register(&acpi_subsys);	result = acpi_bus_init();	if (!result) {#ifdef CONFIG_PM		if (!PM_IS_ACTIVE())			pm_active = 1;		else {			printk(KERN_INFO PREFIX "APM is already active, exiting\n");			disable_acpi();			result = -ENODEV;		}#endif	} else		disable_acpi();	return_VALUE(result);}subsys_initcall(acpi_init);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -