OsdSynch.c (236424) | OsdSynch.c (254300) |
---|---|
1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * Copyright (c) 2007-2009 Jung-uk Kim <jkim@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * SUCH DAMAGE. 27 */ 28 29/* 30 * 6.1 : Mutual Exclusion and Synchronisation 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * Copyright (c) 2007-2009 Jung-uk Kim <jkim@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * SUCH DAMAGE. 27 */ 28 29/* 30 * 6.1 : Mutual Exclusion and Synchronisation 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/dev/acpica/Osd/OsdSynch.c 236424 2012-06-01 21:33:33Z jkim $"); | 34__FBSDID("$FreeBSD: head/sys/dev/acpica/Osd/OsdSynch.c 254300 2013-08-13 21:34:03Z jkim $"); |
35 36#include <contrib/dev/acpica/include/acpi.h> 37#include <contrib/dev/acpica/include/accommon.h> 38 39#include <sys/condvar.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/malloc.h> --- 518 unchanged lines hidden (view full) --- 561 } else 562 mtx_unlock_spin(&al->al_lock); 563 } else 564 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 565 "cannot release unowned %s\n", al->al_name)); 566} 567 568/* Section 5.2.10.1: global lock acquire/release functions */ | 35 36#include <contrib/dev/acpica/include/acpi.h> 37#include <contrib/dev/acpica/include/accommon.h> 38 39#include <sys/condvar.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/malloc.h> --- 518 unchanged lines hidden (view full) --- 561 } else 562 mtx_unlock_spin(&al->al_lock); 563 } else 564 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 565 "cannot release unowned %s\n", al->al_name)); 566} 567 568/* Section 5.2.10.1: global lock acquire/release functions */ |
569#define GL_BIT_PENDING 0x01 570#define GL_BIT_OWNED 0x02 | |
571 572/* 573 * Acquire the global lock. If busy, set the pending bit. The caller 574 * will wait for notification from the BIOS that the lock is available 575 * and then attempt to acquire it again. 576 */ 577int | 569 570/* 571 * Acquire the global lock. If busy, set the pending bit. The caller 572 * will wait for notification from the BIOS that the lock is available 573 * and then attempt to acquire it again. 574 */ 575int |
578acpi_acquire_global_lock(uint32_t *lock) | 576acpi_acquire_global_lock(volatile uint32_t *lock) |
579{ 580 uint32_t new, old; 581 582 do { 583 old = *lock; | 577{ 578 uint32_t new, old; 579 580 do { 581 old = *lock; |
584 new = (old & ~GL_BIT_PENDING) | GL_BIT_OWNED; 585 if ((old & GL_BIT_OWNED) != 0) 586 new |= GL_BIT_PENDING; 587 } while (atomic_cmpset_acq_int(lock, old, new) == 0); | 582 new = (old & ~ACPI_GLOCK_PENDING) | ACPI_GLOCK_OWNED; 583 if ((old & ACPI_GLOCK_OWNED) != 0) 584 new |= ACPI_GLOCK_PENDING; 585 } while (atomic_cmpset_32(lock, old, new) == 0); |
588 | 586 |
589 return ((new & GL_BIT_PENDING) == 0); | 587 return ((new & ACPI_GLOCK_PENDING) == 0); |
590} 591 592/* 593 * Release the global lock, returning whether there is a waiter pending. 594 * If the BIOS set the pending bit, OSPM must notify the BIOS when it 595 * releases the lock. 596 */ 597int | 588} 589 590/* 591 * Release the global lock, returning whether there is a waiter pending. 592 * If the BIOS set the pending bit, OSPM must notify the BIOS when it 593 * releases the lock. 594 */ 595int |
598acpi_release_global_lock(uint32_t *lock) | 596acpi_release_global_lock(volatile uint32_t *lock) |
599{ 600 uint32_t new, old; 601 602 do { 603 old = *lock; | 597{ 598 uint32_t new, old; 599 600 do { 601 old = *lock; |
604 new = old & ~(GL_BIT_PENDING | GL_BIT_OWNED); 605 } while (atomic_cmpset_rel_int(lock, old, new) == 0); | 602 new = old & ~(ACPI_GLOCK_PENDING | ACPI_GLOCK_OWNED); 603 } while (atomic_cmpset_32(lock, old, new) == 0); |
606 | 604 |
607 return ((old & GL_BIT_PENDING) != 0); | 605 return ((old & ACPI_GLOCK_PENDING) != 0); |
608} | 606} |