PatchworkOS
Loading...
Searching...
No Matches
Mutex

Mutex. More...

Typedefs

typedef uint64_t aml_mutex_id_t
 Mutex id.
 

Functions

void aml_mutex_id_init (aml_mutex_id_t *mutex)
 Create a new mutex and return its id.
 
void aml_mutex_id_deinit (aml_mutex_id_t *mutex)
 Destroy the mutex with the given id.
 
uint64_t aml_mutex_acquire (aml_mutex_id_t *mutex, aml_sync_level_t syncLevel, clock_t timeout)
 Acquire a mutex, blocking until it is available or the timeout is reached.
 
uint64_t aml_mutex_release (aml_mutex_id_t *mutex)
 Release a mutex.
 

Detailed Description

Mutex.

This module provides functionality for acquiring and releasing AML mutexes.

Note that mutexes currently do... nothing. Instead we just use one big mutex for the entire parser, but we still implement their behaviour to check for invalid code or errors. This really shouldent matter as AML should only be getting executed by one thread at a time anyway.

See also
Section 19.6.89 of the ACPI specification for more details.

Typedef Documentation

◆ aml_mutex_id_t

Mutex id.

Definition at line 28 of file mutex.h.

Function Documentation

◆ aml_mutex_acquire()

uint64_t aml_mutex_acquire ( aml_mutex_id_t mutex,
aml_sync_level_t  syncLevel,
clock_t  timeout 
)

Acquire a mutex, blocking until it is available or the timeout is reached.

If the mutex is already owned by the current thread, this function will return immediately. If the mutex has a lower SyncLevel than the current SyncLevel, this function will fail.

Parameters
mutexThe mutex to acquire.
syncLevelThe SyncLevel at which to acquire the mutex.
timeoutThe timeout in clock ticks to wait for the mutex, or CLOCKS_NEVER to wait indefinitely.
Returns
On success, 0. If timed out, 1. On failure, ERR and errno is set.

Definition at line 94 of file mutex.c.

References aml_mutex_stack_push(), EINVAL, ERR, errno, mutex, and NULL.

Referenced by aml_def_acquire_read(), aml_field_unit_access(), and aml_method_evaluate().

◆ aml_mutex_id_deinit()

void aml_mutex_id_deinit ( aml_mutex_id_t mutex)

Destroy the mutex with the given id.

Parameters
mutexThe mutex id to destroy.

Definition at line 89 of file mutex.c.

References mutex.

Referenced by aml_object_clear().

◆ aml_mutex_id_init()

void aml_mutex_id_init ( aml_mutex_id_t mutex)

Create a new mutex and return its id.

Parameters
mutexThe mutex id to initialize.

Definition at line 84 of file mutex.c.

References atomic_fetch_add, mutex, and newMutexId.

Referenced by aml_method_set(), and aml_mutex_set().

◆ aml_mutex_release()

uint64_t aml_mutex_release ( aml_mutex_id_t mutex)

Release a mutex.

The mutex must have a SyncLevel equal to the current SyncLevel and must be owned by the current thread.

Parameters
mutexThe mutex to release.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 114 of file mutex.c.

References aml_mutex_stack_pop(), EINVAL, ERR, errno, mutex, and NULL.

Referenced by aml_def_release_read(), aml_field_unit_access(), and aml_method_evaluate().