ReactOS 0.4.17-dev-1190-g4c812f4
opregion.h File Reference
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.

Classes

union  uacpi_opregion_io_data
 

Functions

uacpi_status uacpi_initialize_opregion (void)
 
void uacpi_deinitialize_opregion (void)
 
uacpi_status uacpi_upgrade_to_opregion_lock (void)
 
void uacpi_release_opregion_lock (void)
 
void uacpi_trace_region_error (uacpi_namespace_node *node, uacpi_char *message, uacpi_status ret)
 
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)
 
void uacpi_opregion_uninstall_handler (uacpi_namespace_node *node)
 
uacpi_bool uacpi_address_space_handler_is_default (uacpi_address_space_handler *handler)
 
uacpi_address_space_handlers * uacpi_node_get_address_space_handlers (uacpi_namespace_node *node)
 
uacpi_status uacpi_initialize_opregion_node (uacpi_namespace_node *node)
 
uacpi_status uacpi_opregion_attach (uacpi_namespace_node *node)
 
void uacpi_install_default_address_space_handlers (void)
 
uacpi_bool uacpi_is_buffer_access_address_space (uacpi_address_space space)
 
uacpi_status uacpi_dispatch_opregion_io (uacpi_field_unit *field, uacpi_u32 offset, uacpi_region_op op, union uacpi_opregion_io_data data)
 

Function Documentation

◆ uacpi_address_space_handler_is_default()

uacpi_bool uacpi_address_space_handler_is_default ( uacpi_address_space_handler *  handler)

Definition at line 502 of file opregion.c.

505{
507}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7708
#define UACPI_ADDRESS_SPACE_HANDLER_DEFAULT
Definition: types.h:73

Referenced by uacpi_namespace_initialize().

◆ uacpi_deinitialize_opregion()

void uacpi_deinitialize_opregion ( void  )

Definition at line 20 of file opregion.c.

21{
23}
uacpi_status uacpi_recursive_lock_deinit(struct uacpi_recursive_lock *lock)
Definition: mutex.c:265
struct uacpi_recursive_lock g_opregion_lock
Definition: opregion.c:13

Referenced by uacpi_state_reset().

◆ uacpi_dispatch_opregion_io()

uacpi_status uacpi_dispatch_opregion_io ( uacpi_field_unit *  field,
uacpi_u32  offset,
uacpi_region_op  op,
union uacpi_opregion_io_data  data 
)

Definition at line 1162 of file opregion.c.

1166{
1172 uacpi_u64 abs_offset, offset_end = offset;
1173 uacpi_bool is_oob = UACPI_FALSE;
1174 uacpi_region_op orig_op = op;
1175
1176 union {
1184 } handler_data;
1185
1186 ret = uacpi_opregion_attach(field->region);
1189 field->region, "unable to attach", ret
1190 );
1191 return ret;
1192 }
1193
1196 );
1199
1200 region = obj->op_region;
1201 space = region->space;
1202 handler = region->handler;
1203
1204 abs_offset = region->offset + offset;
1205 offset_end += field->access_width_bytes;
1206
1208 is_oob = region->length < offset_end || abs_offset < offset;
1209 if (uacpi_unlikely(is_oob)) {
1210 const uacpi_char *path;
1211
1214 "out-of-bounds access to opregion %s[0x%"UACPI_PRIX64"->"
1215 "0x%"UACPI_PRIX64"] at 0x%"UACPI_PRIX64" (idx=%u, width=%d)",
1216 path, UACPI_FMT64(region->offset),
1217 UACPI_FMT64(region->offset + region->length),
1218 UACPI_FMT64(abs_offset), offset, field->access_width_bytes
1219 );
1222 }
1223
1224 handler_data.rw.region_context = region->user_context;
1225 handler_data.rw.handler_context = handler->user_context;
1226
1227 switch (region->space) {
1230
1231 cursor = region->internal_buffer + offset;
1232
1233 /*
1234 * Reads from PCC just return the current contents of the internal
1235 * buffer.
1236 */
1237 if (op == UACPI_REGION_OP_READ) {
1239 data.integer, cursor, sizeof(*data.integer),
1240 field->access_width_bytes
1241 );
1242 goto io_done;
1243 }
1244
1245 uacpi_memcpy(cursor, data.integer, field->access_width_bytes);
1246
1247 /*
1248 * Dispatch a PCC send command if this was a write to the command field
1249 *
1250 * ACPI 6.5: 14.3. Extended PCC Subspace Shared Memory Region
1251 *
1252 * Note that a PCC region covers whatever follows the signature that
1253 * the shared memory region starts with, so the offset of every field
1254 * is 4 bytes less than what it is there.
1255 */
1257 uacpi_memzero(&handler_data.pcc.buffer, sizeof(handler_data.pcc.buffer));
1258 handler_data.pcc.buffer.bytes = region->internal_buffer;
1259 handler_data.pcc.buffer.length = region->length;
1260
1262 break;
1263 }
1264
1265 // No dispatch needed, IO is done
1266 goto io_done;
1267 }
1269 handler_data.gpio.pin_offset = field->pin_offset;
1270 handler_data.gpio.num_pins = field->bit_length;
1271 handler_data.gpio.value = *data.integer;
1272
1274 field->connection, &handler_data.gpio.connection
1275 );
1277 goto io_done;
1278
1281 break;
1283 handler_data.ipmi.in_out_message = data.buffer;
1284 handler_data.ipmi.command = abs_offset;
1286 break;
1288 handler_data.ffixedhw.in_out_message = data.buffer;
1289 handler_data.ffixedhw.command = abs_offset;
1291 break;
1293 handler_data.prm.in_out_message = data.buffer;
1295 break;
1299 field->connection, &handler_data.serial.connection
1300 );
1302 goto io_done;
1303
1304 handler_data.serial.command = abs_offset;
1305 handler_data.serial.in_out_buffer = data.buffer;
1306 handler_data.serial.access_attribute = field->attributes;
1307
1308 switch (field->attributes) {
1312 handler_data.serial.access_length = field->access_length;
1313 break;
1314 default:
1315 handler_data.serial.access_length = 0;
1316 }
1317
1320 break;
1321 default:
1322 handler_data.rw.byte_width = field->access_width_bytes;
1323 handler_data.rw.offset = abs_offset;
1324 handler_data.rw.value = *data.integer;
1325 break;
1326 }
1327
1330
1331 ret = handler->callback(op, &handler_data);
1332
1335
1336io_done:
1338 uacpi_trace_region_error(field->region, "unable to perform IO", ret);
1339 return ret;
1340 }
1341
1342 if (orig_op == UACPI_REGION_OP_READ) {
1343 switch (space) {
1350 break;
1352 *data.integer = handler_data.gpio.value;
1353 break;
1354 default:
1355 *data.integer = handler_data.rw.value;
1356 break;
1357 }
1358 }
1359
1360 trace_region_io(field, space, abs_offset, orig_op, data);
1361 return ret;
1362}
UINT op
Definition: effect.c:235
#define uacpi_error(...)
Definition: log.h:36
uacpi_status uacpi_namespace_write_unlock(void)
Definition: namespace.c:51
uacpi_object * uacpi_namespace_node_get_object_typed(const uacpi_namespace_node *node, uacpi_object_type_bits type_mask)
Definition: namespace.c:661
uacpi_status uacpi_namespace_write_lock(void)
Definition: namespace.c:46
#define uacpi_memzero(ptr, size)
Definition: stdlib.h:99
#define uacpi_memcpy
Definition: stdlib.h:34
void uacpi_memcpy_zerout(void *dst, const void *src, uacpi_size dst_size, uacpi_size src_size)
Definition: stdlib.c:112
const uacpi_char * uacpi_namespace_node_generate_absolute_path(const uacpi_namespace_node *node)
Definition: namespace.c:1053
#define uacpi_likely(expr)
Definition: compiler.h:89
#define uacpi_unlikely(expr)
Definition: compiler.h:88
#define UACPI_PRIX64
Definition: types.h:61
bool uacpi_bool
Definition: types.h:31
#define UACPI_FALSE
Definition: types.h:30
uint64_t uacpi_u64
Definition: types.h:22
char uacpi_char
Definition: types.h:44
#define UACPI_NULL
Definition: types.h:33
uint8_t uacpi_u8
Definition: types.h:19
#define UACPI_FMT64(val)
Definition: types.h:62
#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_AML_OUT_OF_BOUNDS_INDEX
Definition: status.h:40
void uacpi_object_ref(uacpi_object *obj)
Definition: types.c:733
@ UACPI_OBJECT_OPERATION_REGION_BIT
Definition: types.h:144
@ UACPI_ACCESS_ATTRIBUTE_RAW_BYTES
Definition: types.h:493
@ UACPI_ACCESS_ATTRIBUTE_RAW_PROCESS_BYTES
Definition: types.h:494
@ UACPI_ACCESS_ATTRIBUTE_BYTES
Definition: types.h:490
uacpi_region_op
Definition: types.h:373
@ UACPI_REGION_OP_FFIXEDHW_COMMAND
Definition: types.h:394
@ UACPI_REGION_OP_PCC_SEND
Definition: types.h:384
@ UACPI_REGION_OP_GPIO_READ
Definition: types.h:387
@ UACPI_REGION_OP_SERIAL_WRITE
Definition: types.h:401
@ UACPI_REGION_OP_PRM_COMMAND
Definition: types.h:397
@ UACPI_REGION_OP_GPIO_WRITE
Definition: types.h:388
@ UACPI_REGION_OP_SERIAL_READ
Definition: types.h:400
@ UACPI_REGION_OP_READ
Definition: types.h:380
@ UACPI_REGION_OP_IPMI_COMMAND
Definition: types.h:391
uacpi_address_space
Definition: types.h:42
@ UACPI_ADDRESS_SPACE_IPMI
Definition: types.h:50
@ UACPI_ADDRESS_SPACE_PRM
Definition: types.h:54
@ UACPI_ADDRESS_SPACE_GENERAL_PURPOSE_IO
Definition: types.h:51
@ UACPI_ADDRESS_SPACE_FFIXEDHW
Definition: types.h:55
@ UACPI_ADDRESS_SPACE_GENERIC_SERIAL_BUS
Definition: types.h:52
@ UACPI_ADDRESS_SPACE_SMBUS
Definition: types.h:47
@ UACPI_ADDRESS_SPACE_PCC
Definition: types.h:53
uacpi_status uacpi_object_get_string_or_buffer(uacpi_object *, uacpi_data_view *out)
Definition: types.c:1058
void uacpi_object_unref(uacpi_object *obj)
Definition: types.c:761
return ret
Definition: mutex.c:147
uint32_t serial
Definition: fsck.fat.h:29
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLintptr offset
Definition: glext.h:5920
const char cursor[]
Definition: icontest.c:13
void uacpi_free_dynamic_string(const uacpi_char *str)
Definition: utilities.c:1148
static void trace_region_io(uacpi_field_unit *field, uacpi_address_space space, uacpi_u64 offset, uacpi_region_op op, union uacpi_opregion_io_data data)
Definition: opregion.c:47
void uacpi_trace_region_error(uacpi_namespace_node *node, uacpi_char *message, uacpi_status ret)
Definition: opregion.c:25
static uacpi_bool space_needs_bounds_checking(uacpi_address_space space)
Definition: opregion.c:1125
uacpi_status uacpi_opregion_attach(uacpi_namespace_node *node)
Definition: opregion.c:240
static uacpi_bool pcc_write_completes_command(uacpi_field_unit *field, uacpi_u32 offset)
Definition: opregion.c:1143
#define rw
Definition: rosglue.h:38
Definition: parser.c:44

Referenced by access_field_unit().

◆ uacpi_initialize_opregion()

uacpi_status uacpi_initialize_opregion ( void  )

Definition at line 15 of file opregion.c.

16{
18}
uacpi_status uacpi_recursive_lock_init(struct uacpi_recursive_lock *lock)
Definition: mutex.c:253

Referenced by uacpi_initialize().

◆ uacpi_initialize_opregion_node()

uacpi_status uacpi_initialize_opregion_node ( uacpi_namespace_node *  node)

Definition at line 1065 of file opregion.c.

1066{
1068 uacpi_namespace_node *parent = node->parent;
1072
1075 return ret;
1076
1079
1080 while (parent) {
1082 if (handlers != UACPI_NULL) {
1084
1085 if (handler != UACPI_NULL) {
1088 break;
1089 }
1090 }
1091
1092 parent = parent->parent;
1093 }
1094
1095 if (ret != UACPI_STATUS_OK)
1096 goto out;
1097 if (!space_needs_reg(region->space))
1098 goto out;
1100 goto out;
1101
1102 if (run_reg(node->parent, region->space, ACPI_REG_CONNECT) !=
1105
1106out:
1108 return ret;
1109}
#define ACPI_REG_CONNECT
Definition: actypes.h:890
uacpi_status uacpi_recursive_lock_release(struct uacpi_recursive_lock *lock)
Definition: mutex.c:305
uacpi_object * uacpi_namespace_node_get_object(const uacpi_namespace_node *node)
Definition: namespace.c:653
#define UACPI_OP_REGION_STATE_REG_EXECUTED
Definition: types.h:111
@ UACPI_STATUS_NOT_FOUND
Definition: status.h:17
@ UACPI_STATUS_OK
Definition: status.h:11
@ UACPI_INIT_LEVEL_NAMESPACE_LOADED
Definition: types.h:78
r parent
Definition: btrfs.c:3010
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
uacpi_status uacpi_upgrade_to_opregion_lock(void)
Definition: opregion.c:472
static uacpi_bool space_needs_reg(enum uacpi_address_space space)
Definition: opregion.c:112
static void region_install_handler(uacpi_operation_region *region, uacpi_address_space_handler *handler)
Definition: opregion.c:356
uacpi_address_space_handlers * uacpi_node_get_address_space_handlers(uacpi_namespace_node *node)
Definition: opregion.c:179
static uacpi_status run_reg(uacpi_namespace_node *scope, uacpi_u16 space, uacpi_u8 connection_code)
Definition: opregion.c:123
uacpi_operation_region * op_region
Definition: types.h:272
uacpi_init_level uacpi_get_current_init_level(void)
Definition: uacpi.c:322
Definition: dlist.c:348
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by handle_create_data_region(), and handle_create_op_region().

◆ uacpi_install_address_space_handler_with_flags()

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 at line 882 of file opregion.c.

887{
890 uacpi_address_space_handler *this_handler, *new_handler;
891 struct opregion_iter_ctx iter_ctx;
892
895 return ret;
896
900 return ret;
901 }
902
903 handlers = extract_handlers(device_node);
906 goto out;
907 }
908
909 this_handler = find_handler(handlers, space);
910 if (this_handler != UACPI_NULL) {
912 goto out;
913 }
914
915 new_handler = uacpi_kernel_alloc(sizeof(*new_handler));
916 if (new_handler == UACPI_NULL) {
918 goto out;
919 }
920 uacpi_shareable_init(new_handler);
921
922 new_handler->next = handlers->head;
923 new_handler->space = space;
924 new_handler->user_context = handler_context;
925 new_handler->callback = handler;
926 new_handler->regions = UACPI_NULL;
927 new_handler->flags = flags;
928 handlers->head = new_handler;
929
930 /*
931 * The handlers that some of the regions already have are invoked as the
932 * regions are taken away from them below, and are free to do whatever they
933 * want in response, which includes uninstalling the handler that we have
934 * just put on the list. Keep it alive until we're done.
935 */
936 uacpi_shareable_ref(new_handler);
937
938 iter_ctx.handler = new_handler;
939 iter_ctx.handlers = handlers;
940 iter_ctx.action = OPREGION_ITER_ACTION_INSTALL;
941
945 UACPI_PERMANENT_ONLY_YES, &iter_ctx
946 );
947
948 if (uacpi_unlikely(!handler_is_installed(&iter_ctx))) {
950 goto out_unref;
951 }
952
954 goto out_unref;
955
956 /*
957 * Installing an early address space handler, obviously not possible to
958 * execute any _REG methods here. Just return and hope that it is either
959 * a global address space handler, or a handler installed by a user who
960 * will run uacpi_reg_all_opregions manually after loading/initializing
961 * the namespace.
962 */
964 goto out_unref;
965
966 // Init level is NAMESPACE_INITIALIZED, so we can safely run _REG now
967 ret = reg_all_opregions(device_node, space);
968
969out_unref:
971out:
974 return ret;
975}
uacpi_status uacpi_recursive_lock_acquire(struct uacpi_recursive_lock *lock)
Definition: mutex.c:285
struct uacpi_runtime_context g_uacpi_rt_ctx
Definition: uacpi.c:18
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_YES
Definition: namespace.h:94
@ 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_OUT_OF_MEMORY
Definition: status.h:13
@ UACPI_STATUS_ALREADY_EXISTS
Definition: status.h:20
@ UACPI_STATUS_NO_HANDLER
Definition: status.h:25
@ UACPI_OBJECT_ANY_BIT
Definition: types.h:152
GLbitfield flags
Definition: glext.h:7161
void * uacpi_kernel_alloc(uacpi_size size)
Definition: uacpiosl.c:111
static uacpi_status reg_all_opregions(uacpi_namespace_node *device_node, enum uacpi_address_space space)
Definition: opregion.c:780
static uacpi_iteration_decision do_install_or_uninstall_handler(uacpi_handle opaque, uacpi_namespace_node *node, uacpi_u32 depth)
Definition: opregion.c:527
static uacpi_bool handler_is_installed(struct opregion_iter_ctx *ctx)
Definition: opregion.c:522
static uacpi_address_space_handlers * extract_handlers(uacpi_namespace_node *node)
Definition: opregion.c:827
@ OPREGION_ITER_ACTION_INSTALL
Definition: opregion.c:511
static uacpi_u32 uacpi_shareable_ref(uacpi_handle handle)
Definition: shareable.h:40
static void uacpi_shareable_init(uacpi_handle handle)
Definition: shareable.h:14
uacpi_region_handler callback
Definition: types.h:67
uacpi_handle user_context
Definition: types.h:68
struct uacpi_address_space_handler * next
Definition: types.h:69
struct uacpi_operation_region * regions
Definition: types.h:70

Referenced by uacpi_install_address_space_handler(), and uacpi_install_default_address_space_handlers().

◆ uacpi_install_default_address_space_handlers()

void uacpi_install_default_address_space_handlers ( void  )

Definition at line 778 of file default_handlers.c.

779{
781
783
788 );
789
794 );
795
800 );
801
806 );
807}
struct _root root
static uacpi_status handle_table_data_region(uacpi_region_op op, uacpi_handle op_data)
static uacpi_status handle_io_region(uacpi_region_op op, uacpi_handle op_data)
static uacpi_status handle_memory_region(uacpi_region_op op, uacpi_handle op_data)
static uacpi_status handle_pci_region(uacpi_region_op op, uacpi_handle op_data)
uacpi_namespace_node * uacpi_namespace_root(void)
Definition: namespace.c:264
@ UACPI_ADDRESS_SPACE_SYSTEM_MEMORY
Definition: types.h:43
@ UACPI_ADDRESS_SPACE_PCI_CONFIG
Definition: types.h:45
@ UACPI_ADDRESS_SPACE_TABLE_DATA
Definition: types.h:58
@ UACPI_ADDRESS_SPACE_SYSTEM_IO
Definition: types.h:44
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

Referenced by uacpi_initialize().

◆ uacpi_is_buffer_access_address_space()

uacpi_bool uacpi_is_buffer_access_address_space ( uacpi_address_space  space)

Definition at line 1111 of file opregion.c.

1112{
1113 switch (space) {
1119 return UACPI_TRUE;
1120 default:
1121 return UACPI_FALSE;
1122 }
1123}
#define UACPI_TRUE
Definition: types.h:29

Referenced by space_needs_bounds_checking(), uacpi_field_unit_get_bit_length(), and uacpi_field_unit_get_read_type().

◆ uacpi_node_get_address_space_handlers()

uacpi_address_space_handlers * uacpi_node_get_address_space_handlers ( uacpi_namespace_node *  node)

Definition at line 179 of file opregion.c.

182{
184
185 if (node == uacpi_namespace_root())
186 return g_uacpi_rt_ctx.root_object->address_space_handlers;
187
189 if (uacpi_unlikely(object == UACPI_NULL))
190 return UACPI_NULL;
191
192 switch (object->type) {
196 return object->address_space_handlers;
197 default:
198 return UACPI_NULL;
199 }
200}
@ UACPI_OBJECT_PROCESSOR
Definition: types.h:123
@ UACPI_OBJECT_DEVICE
Definition: types.h:117
@ UACPI_OBJECT_THERMAL_ZONE
Definition: types.h:124
enum object_type type

Referenced by do_install_or_uninstall_handler(), node_has_handler(), reg_all_opregions(), uacpi_initialize_opregion_node(), and uacpi_namespace_initialize().

◆ uacpi_opregion_attach()

uacpi_status uacpi_opregion_attach ( uacpi_namespace_node *  node)

Definition at line 240 of file opregion.c.

241{
246 uacpi_region_attach_data attach_data = { 0 };
247
250
253 );
256
257 region = obj->op_region;
258
259 if (region->handler == UACPI_NULL)
261 if (region->state_flags & UACPI_OP_REGION_STATE_ATTACHED)
262 return UACPI_STATUS_OK;
263
264 handler = region->handler;
265 attach_data.region_node = node;
266
267 switch (region->space) {
269 if (region->length) {
270 region->internal_buffer = uacpi_kernel_alloc_zeroed(region->length);
271 if (uacpi_unlikely(region->internal_buffer == UACPI_NULL))
273 }
274
275 attach_data.pcc_info.buffer.bytes = region->internal_buffer;
276 attach_data.pcc_info.buffer.length = region->length;
277 attach_data.pcc_info.subspace_id = region->offset;
278 break;
280 attach_data.gpio_info.num_pins = region->length;
281 break;
282 default:
283 attach_data.generic_info.base = region->offset;
284 attach_data.generic_info.length = region->length;
285 break;
286 }
287
288 attach_data.handler_context = handler->user_context;
289
290 /*
291 * The handler is invoked with the namespace unlocked, and is free to do
292 * whatever it wants in the meantime, which includes evaluating a method
293 * that gets rid of the region, as well as uninstalling itself. Keep both
294 * of them alive until we're done.
295 */
298
300 ret = handler->callback(UACPI_REGION_OP_ATTACH, &attach_data);
302
304 goto out;
305
306 if (uacpi_unlikely(region->handler != handler)) {
307 uacpi_region_detach_data detach_data = { 0 };
308
309 /*
310 * The region was taken away from the handler before it was done
311 * attaching it. This is not something that the handler was told
312 * about, as the region was not attached at the time, so do it now:
313 * a region that was attached is always detached as well.
314 */
315 detach_data.region_node = node;
316 detach_data.region_context = attach_data.out_region_context;
317 detach_data.handler_context = handler->user_context;
318
320 handler->callback(UACPI_REGION_OP_DETACH, &detach_data);
322
324 goto out;
325 }
326
328 uacpi_region_detach_data detach_data = { 0 };
329
330 /*
331 * The region was attached once more in the meantime, which is what
332 * happens if the handler ends up accessing the region that it's still
333 * in the middle of attaching. It only gets to be attached once, and
334 * that one was there first, so this is the one to be undone.
335 */
336 detach_data.region_node = node;
337 detach_data.region_context = attach_data.out_region_context;
338 detach_data.handler_context = handler->user_context;
339
341 handler->callback(UACPI_REGION_OP_DETACH, &detach_data);
343
344 goto out;
345 }
346
348 region->user_context = attach_data.out_region_context;
349
350out:
353 return ret;
354}
uacpi_bool uacpi_namespace_node_is_dangling(uacpi_namespace_node *node)
Definition: namespace.c:340
#define uacpi_kernel_alloc_zeroed
Definition: stdlib.h:127
#define UACPI_OP_REGION_STATE_ATTACHED
Definition: types.h:114
@ UACPI_STATUS_NAMESPACE_NODE_DANGLING
Definition: status.h:24
@ UACPI_REGION_OP_DETACH
Definition: types.h:377
@ UACPI_REGION_OP_ATTACH
Definition: types.h:375
uacpi_size length
Definition: types.h:105
uacpi_u8 * bytes
Definition: types.h:96
uacpi_u64 num_pins
Definition: types.h:426
uacpi_data_view buffer
Definition: types.h:420
uacpi_u8 subspace_id
Definition: types.h:421
void * out_region_context
Definition: types.h:437
uacpi_gpio_region_info gpio_info
Definition: types.h:435
uacpi_pcc_region_info pcc_info
Definition: types.h:434
uacpi_namespace_node * region_node
Definition: types.h:431
uacpi_generic_region_info generic_info
Definition: types.h:433
uacpi_namespace_node * region_node
Definition: types.h:517

Referenced by uacpi_dispatch_opregion_io().

◆ uacpi_opregion_uninstall_handler()

void uacpi_opregion_uninstall_handler ( uacpi_namespace_node *  node)

Definition at line 492 of file opregion.c.

493{
495 return;
496
498
500}
static void region_uninstall_handler(uacpi_namespace_node *node, enum unreg unreg)
Definition: opregion.c:372
@ UNREG_YES
Definition: opregion.c:369

Referenced by namespace_node_detach_object(), and opregion_try_detach_from_parent().

◆ uacpi_release_opregion_lock()

void uacpi_release_opregion_lock ( void  )

Definition at line 487 of file opregion.c.

Referenced by unlock_field_unit_transaction().

◆ uacpi_trace_region_error()

void uacpi_trace_region_error ( uacpi_namespace_node *  node,
uacpi_char *  message,
uacpi_status  ret 
)

Definition at line 25 of file opregion.c.

28{
29 const uacpi_char *path, *space_string = "<unknown>";
31
33
36 );
38 space_string = uacpi_address_space_to_string(obj->op_region->space);
39
41 "%s (%s) operation region %s: %s",
42 message, space_string, path, uacpi_status_to_string(ret)
43 );
45}
const uacpi_char * uacpi_status_to_string(uacpi_status)
Definition: uacpi.c:61
const uacpi_char * uacpi_address_space_to_string(uacpi_address_space space)
Definition: types.c:12
Definition: tftpd.h:60

Referenced by do_install_or_uninstall_handler(), find_pci_root(), handle_special_field(), io_region_attach(), memory_region_attach(), pci_region_attach(), region_uninstall_handler(), and uacpi_dispatch_opregion_io().

◆ uacpi_upgrade_to_opregion_lock()

uacpi_status uacpi_upgrade_to_opregion_lock ( void  )

Definition at line 472 of file opregion.c.

473{
475
476 /*
477 * Drop the namespace lock, and reacquire it after the opregion lock
478 * so we keep the ordering with user API.
479 */
481
484 return ret;
485}

Referenced by lock_field_unit_transaction(), uacpi_initialize_opregion_node(), and uacpi_opregion_uninstall_handler().