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

📄 evmisc.c

📁 h内核
💻 C
📖 第 1 页 / 共 2 页
字号:
	/* Signal threads that are waiting for the lock */	if (acpi_gbl_global_lock_thread_count) {		/* Send sufficient units to the semaphore */		status = acpi_os_signal_semaphore (acpi_gbl_global_lock_semaphore,				 acpi_gbl_global_lock_thread_count);		if (ACPI_FAILURE (status)) {			ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n"));		}	}}/******************************************************************************* * * FUNCTION:    acpi_ev_global_lock_handler * * PARAMETERS:  Context         - From thread interface, not used * * RETURN:      ACPI_INTERRUPT_HANDLED or ACPI_INTERRUPT_NOT_HANDLED * * DESCRIPTION: Invoked directly from the SCI handler when a global lock *              release interrupt occurs.  Grab the global lock and queue *              the global lock thread for execution * ******************************************************************************/static u32acpi_ev_global_lock_handler (	void                            *context){	u8                              acquired = FALSE;	acpi_status                     status;	/*	 * Attempt to get the lock	 * If we don't get it now, it will be marked pending and we will	 * take another interrupt when it becomes free.	 */	ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);	if (acquired) {		/* Got the lock, now wake all threads waiting for it */		acpi_gbl_global_lock_acquired = TRUE;		/* Run the Global Lock thread which will signal all waiting threads */		status = acpi_os_queue_for_execution (OSD_PRIORITY_HIGH,				  acpi_ev_global_lock_thread, context);		if (ACPI_FAILURE (status)) {			ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n",				acpi_format_exception (status)));			return (ACPI_INTERRUPT_NOT_HANDLED);		}	}	return (ACPI_INTERRUPT_HANDLED);}/******************************************************************************* * * FUNCTION:    acpi_ev_init_global_lock_handler * * PARAMETERS:  None * * RETURN:      Status * * DESCRIPTION: Install a handler for the global lock release event * ******************************************************************************/acpi_statusacpi_ev_init_global_lock_handler (void){	acpi_status                     status;	ACPI_FUNCTION_TRACE ("ev_init_global_lock_handler");	acpi_gbl_global_lock_present = TRUE;	status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL,			  acpi_ev_global_lock_handler, NULL);	/*	 * If the global lock does not exist on this platform, the attempt	 * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick)	 * Map to AE_OK, but mark global lock as not present.	 * Any attempt to actually use the global lock will be flagged	 * with an error.	 */	if (status == AE_NO_HARDWARE_RESPONSE) {		acpi_gbl_global_lock_present = FALSE;		status = AE_OK;	}	return_ACPI_STATUS (status);}/****************************************************************************** * * FUNCTION:    acpi_ev_acquire_global_lock * * PARAMETERS:  Timeout         - Max time to wait for the lock, in millisec. * * RETURN:      Status * * DESCRIPTION: Attempt to gain ownership of the Global Lock. * *****************************************************************************/acpi_statusacpi_ev_acquire_global_lock (	u16                             timeout){	acpi_status                     status = AE_OK;	u8                              acquired = FALSE;	ACPI_FUNCTION_TRACE ("ev_acquire_global_lock");#ifndef ACPI_APPLICATION	/* Make sure that we actually have a global lock */	if (!acpi_gbl_global_lock_present) {		return_ACPI_STATUS (AE_NO_GLOBAL_LOCK);	}#endif	/* One more thread wants the global lock */	acpi_gbl_global_lock_thread_count++;	/* If we (OS side vs. BIOS side) have the hardware lock already, we are done */	if (acpi_gbl_global_lock_acquired) {		return_ACPI_STATUS (AE_OK);	}	/* We must acquire the actual hardware lock */	ACPI_ACQUIRE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, acquired);	if (acquired) {	   /* We got the lock */		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n"));		acpi_gbl_global_lock_acquired = TRUE;		return_ACPI_STATUS (AE_OK);	}	/*	 * Did not get the lock.  The pending bit was set above, and we must now	 * wait until we get the global lock released interrupt.	 */	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));	/*	 * Acquire the global lock semaphore first.	 * Since this wait will block, we must release the interpreter	 */	status = acpi_ex_system_wait_semaphore (acpi_gbl_global_lock_semaphore,			  timeout);	return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION:    acpi_ev_release_global_lock * * PARAMETERS:  None * * RETURN:      Status * * DESCRIPTION: Releases ownership of the Global Lock. * ******************************************************************************/acpi_statusacpi_ev_release_global_lock (void){	u8                              pending = FALSE;	acpi_status                     status = AE_OK;	ACPI_FUNCTION_TRACE ("ev_release_global_lock");	if (!acpi_gbl_global_lock_thread_count) {		ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));		return_ACPI_STATUS (AE_NOT_ACQUIRED);	}	/* One fewer thread has the global lock */	acpi_gbl_global_lock_thread_count--;	if (acpi_gbl_global_lock_thread_count) {		/* There are still some threads holding the lock, cannot release */		return_ACPI_STATUS (AE_OK);	}	/*	 * No more threads holding lock, we can do the actual hardware	 * release	 */	ACPI_RELEASE_GLOBAL_LOCK (acpi_gbl_common_fACS.global_lock, pending);	acpi_gbl_global_lock_acquired = FALSE;	/*	 * If the pending bit was set, we must write GBL_RLS to the control	 * register	 */	if (pending) {		status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK);	}	return_ACPI_STATUS (status);}/****************************************************************************** * * FUNCTION:    acpi_ev_terminate * * PARAMETERS:  none * * RETURN:      none * * DESCRIPTION: Disable events and free memory allocated for table storage. * ******************************************************************************/voidacpi_ev_terminate (void){	acpi_native_uint                i;	acpi_status                     status;	ACPI_FUNCTION_TRACE ("ev_terminate");	if (acpi_gbl_events_initialized) {		/*		 * Disable all event-related functionality.		 * In all cases, on error, print a message but obviously we don't abort.		 */		/* Disable all fixed events */		for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {			status = acpi_disable_event ((u32) i, 0);			if (ACPI_FAILURE (status)) {				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (u32) i));			}		}		/* Disable all GPEs in all GPE blocks */		status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, ACPI_NOT_ISR);		/* Remove SCI handler */		status = acpi_ev_remove_sci_handler ();		if (ACPI_FAILURE(status)) {			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n"));		}	}	/* Deallocate all handler objects installed within GPE info structs */	status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers, ACPI_NOT_ISR);	/* Return to original mode if necessary */	if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {		status = acpi_disable ();		if (ACPI_FAILURE (status)) {			ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_disable failed\n"));		}	}	return_VOID;}

⌨️ 快捷键说明

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