OsdSynch.c (88420) | OsdSynch.c (91128) |
---|---|
1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdSynch.c 88420 2001-12-22 16:05:41Z iwasaki $ | 27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdSynch.c 91128 2002-02-23 05:31:38Z msmith $ |
28 */ 29 30/* 31 * 6.1 : Mutual Exclusion and Synchronisation 32 */ 33 34#include "acpi.h" 35 36#include "opt_acpi.h" 37#include <sys/kernel.h> 38#include <sys/lock.h> 39#include <sys/malloc.h> 40#include <sys/mutex.h> 41#include <sys/sysctl.h> 42 43#define _COMPONENT ACPI_OS_SERVICES | 28 */ 29 30/* 31 * 6.1 : Mutual Exclusion and Synchronisation 32 */ 33 34#include "acpi.h" 35 36#include "opt_acpi.h" 37#include <sys/kernel.h> 38#include <sys/lock.h> 39#include <sys/malloc.h> 40#include <sys/mutex.h> 41#include <sys/sysctl.h> 42 43#define _COMPONENT ACPI_OS_SERVICES |
44MODULE_NAME("SYNCH") | 44ACPI_MODULE_NAME("SYNCH") |
45 46static MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore"); 47 48/* 49 * Simple counting semaphore implemented using a mutex. (Subsequently used 50 * in the OSI code to implement a mutex. Go figure.) 51 */ 52struct acpi_semaphore { --- 16 unchanged lines hidden (view full) --- 69#endif 70 71ACPI_STATUS 72AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_HANDLE *OutHandle) 73{ 74#ifndef ACPI_NO_SEMAPHORES 75 struct acpi_semaphore *as; 76 | 45 46static MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore"); 47 48/* 49 * Simple counting semaphore implemented using a mutex. (Subsequently used 50 * in the OSI code to implement a mutex. Go figure.) 51 */ 52struct acpi_semaphore { --- 16 unchanged lines hidden (view full) --- 69#endif 70 71ACPI_STATUS 72AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_HANDLE *OutHandle) 73{ 74#ifndef ACPI_NO_SEMAPHORES 75 struct acpi_semaphore *as; 76 |
77 FUNCTION_TRACE(__func__); | 77 ACPI_FUNCTION_TRACE(__func__); |
78 79 if (OutHandle == NULL) 80 return(AE_BAD_PARAMETER); 81 if (InitialUnits > MaxUnits) 82 return_ACPI_STATUS(AE_BAD_PARAMETER); 83 84 if ((as = malloc(sizeof(*as), M_ACPISEM, M_NOWAIT)) == NULL) 85 return_ACPI_STATUS(AE_NO_MEMORY); --- 17 unchanged lines hidden (view full) --- 103} 104 105ACPI_STATUS 106AcpiOsDeleteSemaphore (ACPI_HANDLE Handle) 107{ 108#ifndef ACPI_NO_SEMAPHORES 109 struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; 110 | 78 79 if (OutHandle == NULL) 80 return(AE_BAD_PARAMETER); 81 if (InitialUnits > MaxUnits) 82 return_ACPI_STATUS(AE_BAD_PARAMETER); 83 84 if ((as = malloc(sizeof(*as), M_ACPISEM, M_NOWAIT)) == NULL) 85 return_ACPI_STATUS(AE_NO_MEMORY); --- 17 unchanged lines hidden (view full) --- 103} 104 105ACPI_STATUS 106AcpiOsDeleteSemaphore (ACPI_HANDLE Handle) 107{ 108#ifndef ACPI_NO_SEMAPHORES 109 struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; 110 |
111 FUNCTION_TRACE(__func__); | 111 ACPI_FUNCTION_TRACE(__func__); |
112 113 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "destroyed semaphore %p\n", as)); 114 mtx_destroy(&as->as_mtx); 115 free(Handle, M_ACPISEM); 116 return_ACPI_STATUS(AE_OK); 117#else 118 return(AE_OK); 119#endif --- 8 unchanged lines hidden (view full) --- 128AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout) 129{ 130#ifndef ACPI_NO_SEMAPHORES 131 struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; 132 ACPI_STATUS result; 133 int rv, tmo; 134 struct timeval timeouttv, currenttv, timelefttv; 135 | 112 113 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "destroyed semaphore %p\n", as)); 114 mtx_destroy(&as->as_mtx); 115 free(Handle, M_ACPISEM); 116 return_ACPI_STATUS(AE_OK); 117#else 118 return(AE_OK); 119#endif --- 8 unchanged lines hidden (view full) --- 128AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout) 129{ 130#ifndef ACPI_NO_SEMAPHORES 131 struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; 132 ACPI_STATUS result; 133 int rv, tmo; 134 struct timeval timeouttv, currenttv, timelefttv; 135 |
136 FUNCTION_TRACE(__func__); | 136 ACPI_FUNCTION_TRACE(__func__); |
137 138 if (as == NULL) 139 return_ACPI_STATUS(AE_BAD_PARAMETER); 140 141 if (cold) 142 return_ACPI_STATUS(AE_OK); 143 144#if 0 --- 138 unchanged lines hidden (view full) --- 283} 284 285ACPI_STATUS 286AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units) 287{ 288#ifndef ACPI_NO_SEMAPHORES 289 struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; 290 | 137 138 if (as == NULL) 139 return_ACPI_STATUS(AE_BAD_PARAMETER); 140 141 if (cold) 142 return_ACPI_STATUS(AE_OK); 143 144#if 0 --- 138 unchanged lines hidden (view full) --- 283} 284 285ACPI_STATUS 286AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units) 287{ 288#ifndef ACPI_NO_SEMAPHORES 289 struct acpi_semaphore *as = (struct acpi_semaphore *)Handle; 290 |
291 FUNCTION_TRACE(__func__); | 291 ACPI_FUNCTION_TRACE(__func__); |
292 293 if (as == NULL) 294 return_ACPI_STATUS(AE_BAD_PARAMETER); 295 296 mtx_lock(&as->as_mtx); 297 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 298 "return %d units to semaphore %p (has %d)\n", 299 Units, as, as->as_units)); --- 18 unchanged lines hidden --- | 292 293 if (as == NULL) 294 return_ACPI_STATUS(AE_BAD_PARAMETER); 295 296 mtx_lock(&as->as_mtx); 297 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 298 "return %d units to semaphore %p (has %d)\n", 299 Units, as, as->as_units)); --- 18 unchanged lines hidden --- |