ReactOS 0.4.17-dev-1190-g4c812f4
opregion.h File Reference
#include <uacpi/types.h>
#include <uacpi/status.h>
Include dependency graph for opregion.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uacpi_status uacpi_install_address_space_handler (uacpi_namespace_node *device_node, enum uacpi_address_space space, uacpi_region_handler handler, uacpi_handle handler_context)
 
uacpi_status uacpi_uninstall_address_space_handler (uacpi_namespace_node *device_node, enum uacpi_address_space space, uacpi_region_handler handler)
 
uacpi_status uacpi_reg_all_opregions (uacpi_namespace_node *device_node, enum uacpi_address_space space)
 

Function Documentation

◆ uacpi_install_address_space_handler()

uacpi_status uacpi_install_address_space_handler ( uacpi_namespace_node *  device_node,
enum uacpi_address_space  space,
uacpi_region_handler  handler,
uacpi_handle  handler_context 
)

Install an address space handler to a device node. The handler is recursively connected to all of the operation regions of type 'space' underneath 'device_node'. Note that this recursion stops as soon as another device node that already has an address space handler of this type installed is encountered.

Definition at line 977 of file opregion.c.

981{
983 device_node, space, handler, handler_context, 0
984 );
985}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7708
uacpi_status uacpi_install_address_space_handler_with_flags(uacpi_namespace_node *device_node, enum uacpi_address_space space, uacpi_region_handler handler, uacpi_handle handler_context, uacpi_u16 flags)
Definition: opregion.c:882

◆ uacpi_reg_all_opregions()

uacpi_status uacpi_reg_all_opregions ( uacpi_namespace_node *  device_node,
enum uacpi_address_space  space 
)

Execute _REG(space, ACPI_REG_CONNECT) for all of the opregions with this address space underneath this device. This should only be called manually if you want to register an early handler that must be available before the call to uacpi_namespace_initialize().

Definition at line 847 of file opregion.c.

851{
853
855
857 return UACPI_STATUS_OK;
858
861 return ret;
862
866 return ret;
867 }
868
869 if (uacpi_unlikely(extract_handlers(device_node) == UACPI_NULL)) {
871 goto out;
872 }
873
874 ret = reg_all_opregions(device_node, space);
875
876out:
879 return ret;
880}
uacpi_status uacpi_recursive_lock_acquire(struct uacpi_recursive_lock *lock)
Definition: mutex.c:285
uacpi_status uacpi_recursive_lock_release(struct uacpi_recursive_lock *lock)
Definition: mutex.c:305
#define UACPI_ENSURE_INIT_LEVEL_AT_LEAST(lvl)
Definition: context.h:127
uacpi_status uacpi_namespace_write_unlock(void)
Definition: namespace.c:51
uacpi_status uacpi_namespace_write_lock(void)
Definition: namespace.c:46
#define uacpi_unlikely(expr)
Definition: compiler.h:88
#define UACPI_NULL
Definition: types.h:33
#define uacpi_unlikely_error(expr)
Definition: status.h:50
uacpi_status
Definition: status.h:10
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_STATUS_OK
Definition: status.h:11
@ UACPI_INIT_LEVEL_NAMESPACE_LOADED
Definition: types.h:78
return ret
Definition: mutex.c:147
static uacpi_status reg_all_opregions(uacpi_namespace_node *device_node, enum uacpi_address_space space)
Definition: opregion.c:780
static uacpi_bool space_needs_reg(enum uacpi_address_space space)
Definition: opregion.c:112
static uacpi_address_space_handlers * extract_handlers(uacpi_namespace_node *node)
Definition: opregion.c:827
struct uacpi_recursive_lock g_opregion_lock
Definition: opregion.c:13
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by uacpi_namespace_initialize().

◆ uacpi_uninstall_address_space_handler()

uacpi_status uacpi_uninstall_address_space_handler ( uacpi_namespace_node *  device_node,
enum uacpi_address_space  space,
uacpi_region_handler  handler 
)

Uninstall a handler of type 'space' previously installed to a device node.

'handler' must be the handler that is currently installed there, otherwise nothing is uninstalled, and UACPI_STATUS_INVALID_ARGUMENT is returned. This makes sure that a handler that was installed by somebody else in the meantime is not uninstalled by mistake.

Definition at line 987 of file opregion.c.

991{
994 uacpi_address_space_handler *this_handler, *prev_handler;
995 struct opregion_iter_ctx iter_ctx;
996
999 return ret;
1000
1004 return ret;
1005 }
1006
1007 handlers = extract_handlers(device_node);
1010 goto out;
1011 }
1012
1013 this_handler = find_handler(handlers, space);
1014 if (uacpi_unlikely(this_handler == UACPI_NULL)) {
1016 goto out;
1017 }
1018
1019 // This is somebody else's handler, and is thus not ours to uninstall
1020 if (uacpi_unlikely(this_handler->callback != handler)) {
1022 goto out;
1023 }
1024
1025 /*
1026 * Both the handler and the _REG methods are invoked as the regions are
1027 * taken away below, and are free to do whatever they want in response.
1028 * Make sure that the handler is no longer there to be found by then, be
1029 * it by a region that is created in the meantime, or by the handler
1030 * itself in case it decides to uninstall itself as it's told to detach
1031 * a region. The reference that the device had is now ours, which is what
1032 * keeps the handler alive until we're done.
1033 */
1034 prev_handler = handlers->head;
1035
1036 // Are we the last linked handler?
1037 if (prev_handler == this_handler) {
1038 handlers->head = this_handler->next;
1039 } else {
1040 // Nope, we're somewhere in the middle. Do a search.
1041 while (prev_handler->next != this_handler)
1042 prev_handler = prev_handler->next;
1043
1044 prev_handler->next = this_handler->next;
1045 }
1046
1047 iter_ctx.handler = this_handler;
1048 iter_ctx.handlers = handlers;
1049 iter_ctx.action = OPREGION_ITER_ACTION_UNINSTALL;
1050
1054 UACPI_PERMANENT_ONLY_NO, &iter_ctx
1055 );
1056
1058
1059out:
1062 return ret;
1063}
uacpi_status uacpi_namespace_do_for_each_child(uacpi_namespace_node *parent, uacpi_iteration_callback descending_callback, uacpi_iteration_callback ascending_callback, uacpi_object_type_bits, uacpi_u32 max_depth, enum uacpi_should_lock, enum uacpi_permanent_only, void *user)
Definition: namespace.c:841
@ UACPI_PERMANENT_ONLY_NO
Definition: namespace.h:93
@ UACPI_SHOULD_LOCK_NO
Definition: namespace.h:98
void uacpi_address_space_handler_unref(uacpi_address_space_handler *handler)
Definition: types.c:552
#define UACPI_MAX_DEPTH_ANY
Definition: namespace.h:102
@ UACPI_STATUS_NO_HANDLER
Definition: status.h:25
@ UACPI_OBJECT_ANY_BIT
Definition: types.h:152
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1380
static uacpi_address_space_handler * find_handler(uacpi_address_space_handlers *handlers, enum uacpi_address_space space)
Definition: opregion.c:202
static uacpi_iteration_decision do_install_or_uninstall_handler(uacpi_handle opaque, uacpi_namespace_node *node, uacpi_u32 depth)
Definition: opregion.c:527
@ OPREGION_ITER_ACTION_UNINSTALL
Definition: opregion.c:510
uacpi_region_handler callback
Definition: types.h:67
struct uacpi_address_space_handler * next
Definition: types.h:69