OsdSynch.c (167814) | OsdSynch.c (167908) |
---|---|
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: --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28/* 29 * 6.1 : Mutual Exclusion and Synchronisation 30 */ 31 32#include <sys/cdefs.h> | 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: --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28/* 29 * 6.1 : Mutual Exclusion and Synchronisation 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/acpica/Osd/OsdSynch.c 167814 2007-03-22 18:16:43Z jkim $"); | 33__FBSDID("$FreeBSD: head/sys/dev/acpica/Osd/OsdSynch.c 167908 2007-03-26 19:38:28Z njl $"); |
34 35#include <contrib/dev/acpica/acpi.h> 36 37#include "opt_acpi.h" 38#include <sys/kernel.h> 39#include <sys/malloc.h> 40#include <sys/sysctl.h> 41#include <sys/lock.h> --- 275 unchanged lines hidden (view full) --- 317 318 wakeup(as); 319 AS_UNLOCK(as); 320#endif /* !ACPI_NO_SEMAPHORES */ 321 322 return_ACPI_STATUS (AE_OK); 323} 324 | 34 35#include <contrib/dev/acpica/acpi.h> 36 37#include "opt_acpi.h" 38#include <sys/kernel.h> 39#include <sys/malloc.h> 40#include <sys/sysctl.h> 41#include <sys/lock.h> --- 275 unchanged lines hidden (view full) --- 317 318 wakeup(as); 319 AS_UNLOCK(as); 320#endif /* !ACPI_NO_SEMAPHORES */ 321 322 return_ACPI_STATUS (AE_OK); 323} 324 |
325/* Combined mutex + mutex name storage since the latter must persist. */ 326struct acpi_mtx_msg { 327 struct mtx mtx; 328 char msg[32]; 329}; 330 |
|
325ACPI_STATUS 326AcpiOsCreateLock (ACPI_HANDLE *OutHandle) 327{ | 331ACPI_STATUS 332AcpiOsCreateLock (ACPI_HANDLE *OutHandle) 333{ |
328 struct mtx *m; | 334 struct acpi_mtx_msg *m; |
329 330 if (OutHandle == NULL) 331 return (AE_BAD_PARAMETER); 332 m = malloc(sizeof(*m), M_ACPISEM, M_NOWAIT | M_ZERO); 333 if (m == NULL) 334 return (AE_NO_MEMORY); 335 | 335 336 if (OutHandle == NULL) 337 return (AE_BAD_PARAMETER); 338 m = malloc(sizeof(*m), M_ACPISEM, M_NOWAIT | M_ZERO); 339 if (m == NULL) 340 return (AE_NO_MEMORY); 341 |
336 mtx_init(m, "acpica subsystem lock", NULL, MTX_DEF); | 342 /* Build a unique name based on the address of the handle. */ 343 snprintf(m->msg, sizeof(m->msg), "acpi subsys %p", OutHandle); 344 mtx_init(&m->mtx, m->msg, NULL, MTX_DEF); |
337 *OutHandle = (ACPI_HANDLE)m; 338 return (AE_OK); 339} 340 341void 342AcpiOsDeleteLock (ACPI_HANDLE Handle) 343{ 344 struct mtx *m = (struct mtx *)Handle; 345 346 if (Handle == NULL) 347 return; 348 mtx_destroy(m); | 345 *OutHandle = (ACPI_HANDLE)m; 346 return (AE_OK); 347} 348 349void 350AcpiOsDeleteLock (ACPI_HANDLE Handle) 351{ 352 struct mtx *m = (struct mtx *)Handle; 353 354 if (Handle == NULL) 355 return; 356 mtx_destroy(m); |
357 free(m, M_ACPISEM); |
|
349} 350 351/* 352 * The Flags parameter seems to state whether or not caller is an ISR 353 * (and thus can't block) but since we have ithreads, we don't worry 354 * about potentially blocking. 355 */ 356ACPI_NATIVE_UINT --- 63 unchanged lines hidden --- | 358} 359 360/* 361 * The Flags parameter seems to state whether or not caller is an ISR 362 * (and thus can't block) but since we have ithreads, we don't worry 363 * about potentially blocking. 364 */ 365ACPI_NATIVE_UINT --- 63 unchanged lines hidden --- |