ReactOS 0.4.16-dev-2604-g747b3c0
types.c File Reference
Include dependency graph for types.c:

Go to the source code of this file.

Classes

struct  pkg_copy_req
 

Macros

#define TYPE_CHECK_USER_OBJ_RET(obj, type_bits, ret)
 
#define TYPE_CHECK_USER_OBJ(obj, type_bits)    TYPE_CHECK_USER_OBJ_RET(obj, type_bits, UACPI_STATUS_INVALID_ARGUMENT)
 
#define ENSURE_VALID_USER_OBJ_RET(obj, ret)
 
#define ENSURE_VALID_USER_OBJ(obj)    ENSURE_VALID_USER_OBJ_RET(obj, UACPI_STATUS_INVALID_ARGUMENT)
 

Typedefs

typedef uacpi_bool(* object_ctor) (uacpi_object *obj)
 

Functions

const uacpi_charuacpi_address_space_to_string (enum uacpi_address_space space)
 
const uacpi_charuacpi_object_type_to_string (uacpi_object_type type)
 
static uacpi_bool buffer_alloc (uacpi_object *obj, uacpi_size initial_size)
 
static uacpi_bool empty_buffer_or_string_alloc (uacpi_object *object)
 
uacpi_bool uacpi_package_fill (uacpi_package *pkg, uacpi_size num_elements, enum uacpi_prealloc_objects prealloc_objects)
 
static uacpi_bool package_alloc (uacpi_object *obj, uacpi_size initial_size, enum uacpi_prealloc_objects prealloc)
 
static uacpi_bool empty_package_alloc (uacpi_object *object)
 
uacpi_mutexuacpi_create_mutex (void)
 
static uacpi_bool mutex_alloc (uacpi_object *obj)
 
static uacpi_bool event_alloc (uacpi_object *obj)
 
static uacpi_bool method_alloc (uacpi_object *obj)
 
static uacpi_bool op_region_alloc (uacpi_object *obj)
 
static uacpi_bool field_unit_alloc (uacpi_object *obj)
 
static uacpi_bool processor_alloc (uacpi_object *obj)
 
static uacpi_bool device_alloc (uacpi_object *obj)
 
static uacpi_bool thermal_zone_alloc (uacpi_object *obj)
 
uacpi_objectuacpi_create_object (uacpi_object_type type)
 
static void free_buffer (uacpi_handle handle)
 
static uacpi_bool free_queue_push (struct free_queue *queue, uacpi_package *pkg)
 
static void free_object (uacpi_object *obj)
 
static void free_plain_no_recurse (uacpi_object *obj, struct free_queue *queue)
 
static void unref_plain_no_recurse (uacpi_object *obj, struct free_queue *queue)
 
static void unref_chain_no_recurse (uacpi_object *obj, struct free_queue *queue)
 
static void unref_object_no_recurse (uacpi_object *obj, struct free_queue *queue)
 
static void free_package (uacpi_handle handle)
 
static void free_mutex (uacpi_handle handle)
 
void uacpi_mutex_unref (uacpi_mutex *mutex)
 
static void free_event (uacpi_handle handle)
 
static void free_address_space_handler (uacpi_handle handle)
 
static void free_address_space_handlers (uacpi_address_space_handler *handler)
 
static void free_device_notify_handlers (uacpi_device_notify_handler *handler)
 
static void free_handlers (uacpi_handle handle)
 
void uacpi_address_space_handler_unref (uacpi_address_space_handler *handler)
 
static void free_op_region (uacpi_handle handle)
 
static void free_device (uacpi_handle handle)
 
static void free_processor (uacpi_handle handle)
 
static void free_thermal_zone (uacpi_handle handle)
 
static void free_field_unit (uacpi_handle handle)
 
static void free_method (uacpi_handle handle)
 
void uacpi_method_unref (uacpi_control_method *method)
 
static void free_object_storage (uacpi_object *obj)
 
static void make_chain_bugged (uacpi_object *obj)
 
void uacpi_object_ref (uacpi_object *obj)
 
static void free_chain (uacpi_object *obj)
 
void uacpi_object_unref (uacpi_object *obj)
 
static uacpi_status buffer_alloc_and_store (uacpi_object *obj, uacpi_size buf_size, const void *src, uacpi_size src_size)
 
static uacpi_status assign_buffer (uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
 
 DYNAMIC_ARRAY_WITH_INLINE_STORAGE_IMPL (pkg_copy_reqs, struct pkg_copy_req, static)
 
static uacpi_status deep_copy_package_no_recurse (uacpi_object *dst, uacpi_package *src, struct pkg_copy_reqs *reqs)
 
static uacpi_status deep_copy_package (uacpi_object *dst, uacpi_object *src)
 
static uacpi_status assign_mutex (uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
 
static uacpi_status assign_event (uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
 
static uacpi_status assign_package (uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
 
void uacpi_object_attach_child (uacpi_object *parent, uacpi_object *child)
 
void uacpi_object_detach_child (uacpi_object *parent)
 
uacpi_object_type uacpi_object_get_type (uacpi_object *obj)
 
uacpi_object_type_bits uacpi_object_get_type_bit (uacpi_object *obj)
 
uacpi_bool uacpi_object_is (uacpi_object *obj, uacpi_object_type type)
 
uacpi_bool uacpi_object_is_one_of (uacpi_object *obj, uacpi_object_type_bits type_mask)
 
uacpi_status uacpi_object_get_integer (uacpi_object *obj, uacpi_u64 *out)
 
uacpi_status uacpi_object_assign_integer (uacpi_object *obj, uacpi_u64 value)
 
void uacpi_buffer_to_view (uacpi_buffer *buf, uacpi_data_view *out_view)
 
static uacpi_status uacpi_object_do_get_string_or_buffer (uacpi_object *obj, uacpi_data_view *out, uacpi_u32 mask)
 
uacpi_status uacpi_object_get_string_or_buffer (uacpi_object *obj, uacpi_data_view *out)
 
uacpi_status uacpi_object_get_string (uacpi_object *obj, uacpi_data_view *out)
 
uacpi_status uacpi_object_get_buffer (uacpi_object *obj, uacpi_data_view *out)
 
uacpi_bool uacpi_object_is_aml_namepath (uacpi_object *obj)
 
uacpi_status uacpi_object_resolve_as_aml_namepath (uacpi_object *obj, uacpi_namespace_node *scope, uacpi_namespace_node **out_node)
 
static uacpi_status uacpi_object_do_assign_buffer (uacpi_object *obj, uacpi_data_view in, uacpi_object_type type)
 
uacpi_status uacpi_object_assign_string (uacpi_object *obj, uacpi_data_view in)
 
uacpi_status uacpi_object_assign_buffer (uacpi_object *obj, uacpi_data_view in)
 
uacpi_objectuacpi_object_create_uninitialized (void)
 
uacpi_status uacpi_object_create_integer_safe (uacpi_u64 value, uacpi_overflow_behavior behavior, uacpi_object **out_obj)
 
uacpi_objectuacpi_object_create_integer (uacpi_u64 value)
 
static uacpi_objectuacpi_object_do_create_string_or_buffer (uacpi_data_view view, uacpi_object_type type)
 
uacpi_objectuacpi_object_create_string (uacpi_data_view view)
 
uacpi_objectuacpi_object_create_buffer (uacpi_data_view view)
 
uacpi_objectuacpi_object_create_cstring (const uacpi_char *str)
 
uacpi_status uacpi_object_get_package (uacpi_object *obj, uacpi_object_array *out)
 
uacpi_objectuacpi_object_create_reference (uacpi_object *child)
 
uacpi_status uacpi_object_assign_reference (uacpi_object *obj, uacpi_object *child)
 
uacpi_status uacpi_object_get_dereferenced (uacpi_object *obj, uacpi_object **out)
 
uacpi_status uacpi_object_get_processor_info (uacpi_object *obj, uacpi_processor_info *out)
 
uacpi_status uacpi_object_get_power_resource_info (uacpi_object *obj, uacpi_power_resource_info *out)
 
uacpi_status uacpi_object_assign_package (uacpi_object *obj, uacpi_object_array in)
 
uacpi_objectuacpi_object_create_package (uacpi_object_array in)
 
uacpi_status uacpi_object_assign (uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
 
struct uacpi_objectuacpi_create_internal_reference (enum uacpi_reference_kind kind, uacpi_object *child)
 
uacpi_objectuacpi_unwrap_internal_reference (uacpi_object *object)
 

Variables

static object_ctor object_constructor_table [UACPI_OBJECT_MAX_TYPE_VALUE+1]
 

Macro Definition Documentation

◆ ENSURE_VALID_USER_OBJ

#define ENSURE_VALID_USER_OBJ (   obj)     ENSURE_VALID_USER_OBJ_RET(obj, UACPI_STATUS_INVALID_ARGUMENT)

Definition at line 1013 of file types.c.

◆ ENSURE_VALID_USER_OBJ_RET

#define ENSURE_VALID_USER_OBJ_RET (   obj,
  ret 
)
Value:
do { \
return ret; \
} while (0)
#define uacpi_unlikely(expr)
Definition: compiler.h:58
#define UACPI_NULL
Definition: types.h:33
return ret
Definition: mutex.c:146

Definition at line 1007 of file types.c.

◆ TYPE_CHECK_USER_OBJ

#define TYPE_CHECK_USER_OBJ (   obj,
  type_bits 
)     TYPE_CHECK_USER_OBJ_RET(obj, type_bits, UACPI_STATUS_INVALID_ARGUMENT)

Definition at line 1004 of file types.c.

◆ TYPE_CHECK_USER_OBJ_RET

#define TYPE_CHECK_USER_OBJ_RET (   obj,
  type_bits,
  ret 
)
Value:
do { \
!uacpi_object_is_one_of(obj, type_bits))) \
return ret; \
} while (0)
uacpi_bool uacpi_object_is_one_of(uacpi_object *obj, uacpi_object_type_bits type_mask)
Definition: types.c:990

Definition at line 997 of file types.c.

Typedef Documentation

◆ object_ctor

typedef uacpi_bool(* object_ctor) (uacpi_object *obj)

Definition at line 311 of file types.c.

Function Documentation

◆ assign_buffer()

static uacpi_status assign_buffer ( uacpi_object dst,
uacpi_object src,
enum uacpi_assign_behavior  behavior 
)
static

Definition at line 791 of file types.c.

793{
794 if (behavior == UACPI_ASSIGN_BEHAVIOR_SHALLOW_COPY) {
795 dst->buffer = src->buffer;
796 uacpi_shareable_ref(dst->buffer);
797 return UACPI_STATUS_OK;
798 }
799
800 return buffer_alloc_and_store(dst, src->buffer->size,
801 src->buffer->data, src->buffer->size);
802}
@ UACPI_ASSIGN_BEHAVIOR_SHALLOW_COPY
Definition: types.h:277
@ UACPI_STATUS_OK
Definition: status.h:11
static uacpi_status buffer_alloc_and_store(uacpi_object *obj, uacpi_size buf_size, const void *src, uacpi_size src_size)
Definition: types.c:779
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
uacpi_u32 uacpi_shareable_ref(uacpi_handle)
Definition: shareable.c:31

Referenced by uacpi_object_assign().

◆ assign_event()

static uacpi_status assign_event ( uacpi_object dst,
uacpi_object src,
enum uacpi_assign_behavior  behavior 
)
static

Definition at line 915 of file types.c.

917{
918 if (behavior == UACPI_ASSIGN_BEHAVIOR_DEEP_COPY) {
920 return UACPI_STATUS_OK;
921
923 }
924
925 dst->event = src->event;
926 uacpi_shareable_ref(dst->event);
927
928 return UACPI_STATUS_OK;
929}
@ UACPI_ASSIGN_BEHAVIOR_DEEP_COPY
Definition: types.h:276
#define uacpi_likely(expr)
Definition: compiler.h:59
@ UACPI_STATUS_OUT_OF_MEMORY
Definition: status.h:13
static uacpi_bool event_alloc(uacpi_object *obj)
Definition: types.c:207

Referenced by uacpi_object_assign().

◆ assign_mutex()

static uacpi_status assign_mutex ( uacpi_object dst,
uacpi_object src,
enum uacpi_assign_behavior  behavior 
)
static

Definition at line 897 of file types.c.

899{
900 if (behavior == UACPI_ASSIGN_BEHAVIOR_DEEP_COPY) {
902 dst->mutex->sync_level = src->mutex->sync_level;
903 return UACPI_STATUS_OK;
904 }
905
907 }
908
909 dst->mutex = src->mutex;
910 uacpi_shareable_ref(dst->mutex);
911
912 return UACPI_STATUS_OK;
913}
static uacpi_bool mutex_alloc(uacpi_object *obj)
Definition: types.c:201

Referenced by uacpi_object_assign().

◆ assign_package()

static uacpi_status assign_package ( uacpi_object dst,
uacpi_object src,
enum uacpi_assign_behavior  behavior 
)
static

Definition at line 931 of file types.c.

933{
934 if (behavior == UACPI_ASSIGN_BEHAVIOR_SHALLOW_COPY) {
935 dst->package = src->package;
936 uacpi_shareable_ref(dst->package);
937 return UACPI_STATUS_OK;
938 }
939
940 return deep_copy_package(dst, src);
941}
static uacpi_status deep_copy_package(uacpi_object *dst, uacpi_object *src)
Definition: types.c:875

Referenced by uacpi_object_assign().

◆ buffer_alloc()

static uacpi_bool buffer_alloc ( uacpi_object obj,
uacpi_size  initial_size 
)
static

Definition at line 95 of file types.c.

96{
98
101 return UACPI_FALSE;
102
104
105 if (initial_size) {
106 buf->data = uacpi_kernel_alloc(initial_size);
107 if (uacpi_unlikely(buf->data == UACPI_NULL)) {
108 uacpi_free(buf, sizeof(*buf));
109 return UACPI_FALSE;
110 }
111
112 buf->size = initial_size;
113 }
114
115 obj->buffer = buf;
116 return UACPI_TRUE;
117}
#define uacpi_kernel_alloc_zeroed
Definition: stdlib.h:127
#define uacpi_free(mem, _)
Definition: stdlib.h:96
#define UACPI_FALSE
Definition: types.h:30
#define UACPI_TRUE
Definition: types.h:29
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
void * uacpi_kernel_alloc(uacpi_size size)
Definition: uacpiosl.c:111
void uacpi_shareable_init(uacpi_handle)
Definition: shareable.c:9

Referenced by buffer_alloc_and_store(), and empty_buffer_or_string_alloc().

◆ buffer_alloc_and_store()

static uacpi_status buffer_alloc_and_store ( uacpi_object obj,
uacpi_size  buf_size,
const void src,
uacpi_size  src_size 
)
static

Definition at line 779 of file types.c.

783{
784 if (uacpi_unlikely(!buffer_alloc(obj, buf_size)))
786
787 uacpi_memcpy_zerout(obj->buffer->data, src, buf_size, src_size);
788 return UACPI_STATUS_OK;
789}
void uacpi_memcpy_zerout(void *dst, const void *src, uacpi_size dst_size, uacpi_size src_size)
Definition: stdlib.c:112
static uacpi_bool buffer_alloc(uacpi_object *obj, uacpi_size initial_size)
Definition: types.c:95

Referenced by assign_buffer(), and uacpi_object_do_assign_buffer().

◆ deep_copy_package()

static uacpi_status deep_copy_package ( uacpi_object dst,
uacpi_object src 
)
static

Definition at line 875 of file types.c.

876{
878 struct pkg_copy_reqs reqs = { 0 };
879
880 pkg_copy_reqs_push(&reqs, dst, src->package);
881
882 while (pkg_copy_reqs_size(&reqs) != 0) {
883 struct pkg_copy_req req;
884
885 req = *pkg_copy_reqs_last(&reqs);
886 pkg_copy_reqs_pop(&reqs);
887
888 ret = deep_copy_package_no_recurse(req.dst, req.src, &reqs);
890 break;
891 }
892
893 pkg_copy_reqs_clear(&reqs);
894 return ret;
895}
#define uacpi_unlikely_error(expr)
Definition: status.h:49
uacpi_status
Definition: status.h:10
static uacpi_status deep_copy_package_no_recurse(uacpi_object *dst, uacpi_package *src, struct pkg_copy_reqs *reqs)
Definition: types.c:831

Referenced by assign_package().

◆ deep_copy_package_no_recurse()

static uacpi_status deep_copy_package_no_recurse ( uacpi_object dst,
uacpi_package src,
struct pkg_copy_reqs *  reqs 
)
static

Definition at line 831 of file types.c.

835{
837 uacpi_package *dst_package;
838
839 if (uacpi_unlikely(!package_alloc(dst, src->count,
842
844 dst_package = dst->package;
845
846 for (i = 0; i < src->count; ++i) {
847 uacpi_status st;
848 uacpi_object *src_obj = src->objects[i];
849 uacpi_object *dst_obj = dst_package->objects[i];
850
851 // Don't copy the internal package index reference
852 if (src_obj->type == UACPI_OBJECT_REFERENCE &&
854 src_obj = src_obj->inner_object;
855
856 if (src_obj->type == UACPI_OBJECT_PACKAGE) {
858
859 ret = pkg_copy_reqs_push(reqs, dst_obj, src_obj->package);
860 if (uacpi_unlikely(!ret))
862
863 continue;
864 }
865
866 st = uacpi_object_assign(dst_obj, src_obj,
868 if (uacpi_unlikely_error(st))
869 return st;
870 }
871
872 return UACPI_STATUS_OK;
873}
@ UACPI_PREALLOC_OBJECTS_YES
Definition: types.h:293
@ UACPI_REFERENCE_KIND_PKG_INDEX
Definition: types.h:15
size_t uacpi_size
Definition: types.h:37
bool uacpi_bool
Definition: types.h:31
@ UACPI_OBJECT_PACKAGE
Definition: types.h:109
@ UACPI_OBJECT_REFERENCE
Definition: types.h:122
static uacpi_bool package_alloc(uacpi_object *obj, uacpi_size initial_size, enum uacpi_prealloc_objects prealloc)
Definition: types.c:154
uacpi_status uacpi_object_assign(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
Definition: types.c:1360
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uacpi_u8 flags
Definition: types.h:250
uacpi_u8 type
Definition: types.h:249
uacpi_package * package
Definition: types.h:254
uacpi_object * inner_object
Definition: types.h:256
uacpi_object ** objects
Definition: types.h:36

Referenced by deep_copy_package().

◆ device_alloc()

static uacpi_bool device_alloc ( uacpi_object obj)
static

Definition at line 283 of file types.c.

284{
286
289 return UACPI_FALSE;
290
292 obj->device = device;
293
294 return UACPI_TRUE;
295}
Definition: devices.h:37

◆ DYNAMIC_ARRAY_WITH_INLINE_STORAGE_IMPL()

DYNAMIC_ARRAY_WITH_INLINE_STORAGE_IMPL ( pkg_copy_reqs  ,
struct pkg_copy_req  ,
static   
)

Definition at line 810 of file types.c.

818{
819 struct pkg_copy_req *req;
820
821 req = pkg_copy_reqs_alloc(reqs);
822 if (uacpi_unlikely(req == UACPI_NULL))
823 return UACPI_FALSE;
824
825 req->dst = dst;
826 req->src = pkg;
827
828 return UACPI_TRUE;
829}
uacpi_package * src
Definition: types.c:806
uacpi_object * dst
Definition: types.c:805

◆ empty_buffer_or_string_alloc()

static uacpi_bool empty_buffer_or_string_alloc ( uacpi_object object)
static

Definition at line 119 of file types.c.

120{
121 return buffer_alloc(object, 0);
122}

◆ empty_package_alloc()

static uacpi_bool empty_package_alloc ( uacpi_object object)
static

Definition at line 176 of file types.c.

177{
178 return package_alloc(object, 0, UACPI_PREALLOC_OBJECTS_NO);
179}
@ UACPI_PREALLOC_OBJECTS_NO
Definition: types.h:292

◆ event_alloc()

static uacpi_bool event_alloc ( uacpi_object obj)
static

Definition at line 207 of file types.c.

208{
210
211 event = uacpi_kernel_alloc_zeroed(sizeof(uacpi_event));
213 return UACPI_FALSE;
214
215 event->handle = uacpi_kernel_create_event();
216 if (event->handle == UACPI_NULL) {
217 uacpi_free(event, sizeof(*event));
218 return UACPI_FALSE;
219 }
220
222 obj->event = event;
223
224 return UACPI_TRUE;
225}
struct _cl_event * event
Definition: glext.h:7739
uacpi_handle uacpi_kernel_create_event(void)
Definition: uacpiosl.c:53

Referenced by assign_event().

◆ field_unit_alloc()

static uacpi_bool field_unit_alloc ( uacpi_object obj)
static

Definition at line 255 of file types.c.

256{
257 uacpi_field_unit *field_unit;
258
259 field_unit = uacpi_kernel_alloc_zeroed(sizeof(*field_unit));
260 if (uacpi_unlikely(field_unit == UACPI_NULL))
261 return UACPI_FALSE;
262
263 uacpi_shareable_init(field_unit);
264 obj->field_unit = field_unit;
265
266 return UACPI_TRUE;
267}

◆ free_address_space_handler()

static void free_address_space_handler ( uacpi_handle  handle)
static

Definition at line 508 of file types.c.

509{
511 uacpi_free(handler, sizeof(*handler));
512}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512

Referenced by free_address_space_handlers(), and uacpi_address_space_handler_unref().

◆ free_address_space_handlers()

static void free_address_space_handlers ( uacpi_address_space_handler handler)
static

Definition at line 514 of file types.c.

517{
518 uacpi_address_space_handler *next_handler;
519
520 while (handler) {
521 next_handler = handler->next;
524 );
525 handler = next_handler;
526 }
527}
static void free_address_space_handler(uacpi_handle handle)
Definition: types.c:508
void uacpi_shareable_unref_and_delete_if_last(uacpi_handle, void(*do_free)(uacpi_handle))
Definition: shareable.c:51

Referenced by free_handlers().

◆ free_buffer()

static void free_buffer ( uacpi_handle  handle)
static

Definition at line 351 of file types.c.

352{
354
355 if (buf->data != UACPI_NULL)
356 /*
357 * If buffer has a size of 0 but a valid data pointer it's probably an
358 * "empty" buffer allocated by the interpreter in make_null_buffer
359 * and its real size is actually 1.
360 */
361 uacpi_free(buf->data, UACPI_MAX(buf->size, 1));
362
363 uacpi_free(buf, sizeof(*buf));
364}
#define UACPI_MAX(x, y)
Definition: stdlib.h:103

Referenced by free_object_storage(), and uacpi_object_do_assign_buffer().

◆ free_chain()

static void free_chain ( uacpi_object obj)
static

Definition at line 739 of file types.c.

740{
741 uacpi_object *next_obj = UACPI_NULL;
742
743 while (obj) {
744 if (obj->type == UACPI_OBJECT_REFERENCE)
745 next_obj = obj->inner_object;
746
749
750 obj = next_obj;
751 next_obj = UACPI_NULL;
752 }
753}
static void free_object(uacpi_object *obj)
Definition: types.c:707
uacpi_u32 uacpi_shareable_refcount(uacpi_handle)
Definition: shareable.c:65

Referenced by uacpi_object_unref().

◆ free_device()

static void free_device ( uacpi_handle  handle)
static

Definition at line 582 of file types.c.

583{
586 uacpi_free(device, sizeof(*device));
587}
static void free_handlers(uacpi_handle handle)
Definition: types.c:540

Referenced by free_object_storage().

◆ free_device_notify_handlers()

static void free_device_notify_handlers ( uacpi_device_notify_handler handler)
static

Definition at line 529 of file types.c.

530{
531 uacpi_device_notify_handler *next_handler;
532
533 while (handler) {
534 next_handler = handler->next;
535 uacpi_free(handler, sizeof(*handler));
536 handler = next_handler;
537 }
538}

Referenced by free_handlers().

◆ free_event()

static void free_event ( uacpi_handle  handle)
static

Definition at line 500 of file types.c.

501{
502 uacpi_event *event = handle;
503
505 uacpi_free(event, sizeof(*event));
506}
void uacpi_kernel_free_event(uacpi_handle)
Definition: uacpiosl.c:60

Referenced by free_object_storage().

◆ free_field_unit()

static void free_field_unit ( uacpi_handle  handle)
static

Definition at line 603 of file types.c.

604{
605 uacpi_field_unit *field_unit = handle;
606
607 if (field_unit->connection)
608 uacpi_object_unref(field_unit->connection);
609
610 switch (field_unit->kind) {
613 break;
618 );
619 break;
622 field_unit->index, free_field_unit
623 );
625 field_unit->data, free_field_unit
626 );
627 break;
628 default:
629 break;
630 }
631
632 uacpi_free(field_unit, sizeof(*field_unit));
633}
void uacpi_namespace_node_unref(uacpi_namespace_node *node)
Definition: namespace.c:297
@ UACPI_FIELD_UNIT_KIND_NORMAL
Definition: types.h:204
@ UACPI_FIELD_UNIT_KIND_BANK
Definition: types.h:206
@ UACPI_FIELD_UNIT_KIND_INDEX
Definition: types.h:205
static void free_field_unit(uacpi_handle handle)
Definition: types.c:603
void uacpi_object_unref(uacpi_object *obj)
Definition: types.c:755
struct uacpi_field_unit * bank_selection
Definition: types.h:227
uacpi_namespace_node * region
Definition: types.h:215
uacpi_namespace_node * bank_region
Definition: types.h:226
uacpi_u8 kind
Definition: types.h:243
uacpi_object * connection
Definition: types.h:232
struct uacpi_field_unit * index
Definition: types.h:220
struct uacpi_field_unit * data
Definition: types.h:221

Referenced by free_field_unit(), and free_object_storage().

◆ free_handlers()

static void free_handlers ( uacpi_handle  handle)
static

Definition at line 540 of file types.c.

541{
543
544 free_address_space_handlers(handlers->address_space_head);
546}
static void free_device_notify_handlers(uacpi_device_notify_handler *handler)
Definition: types.c:529
static void free_address_space_handlers(uacpi_address_space_handler *handler)
Definition: types.c:514
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1380

Referenced by free_device(), free_processor(), and free_thermal_zone().

◆ free_method()

static void free_method ( uacpi_handle  handle)
static

Definition at line 635 of file types.c.

636{
638
640 method->mutex, free_mutex
641 );
642
643 if (!method->native_call && method->owns_code)
644 uacpi_free(method->code, method->size);
645 uacpi_free(method, sizeof(*method));
646}
method
Definition: dragdrop.c:54
static void free_mutex(uacpi_handle handle)
Definition: types.c:484

Referenced by uacpi_method_unref().

◆ free_mutex()

static void free_mutex ( uacpi_handle  handle)
static

Definition at line 484 of file types.c.

485{
487
489 uacpi_free(mutex, sizeof(*mutex));
490}
void uacpi_kernel_free_mutex(uacpi_handle)
Definition: uacpiosl.c:146
Definition: module.h:456

Referenced by free_method(), and uacpi_mutex_unref().

◆ free_object()

static void free_object ( uacpi_object obj)
static

Definition at line 707 of file types.c.

708{
710 uacpi_free(obj, sizeof(*obj));
711}
static void free_object_storage(uacpi_object *obj)
Definition: types.c:653

Referenced by free_chain(), and free_plain_no_recurse().

◆ free_object_storage()

static void free_object_storage ( uacpi_object obj)
static

Definition at line 653 of file types.c.

654{
655 switch (obj->type) {
659 break;
661 uacpi_shareable_unref_and_delete_if_last(obj->buffer_field.backing,
663 break;
667 break;
669 uacpi_method_unref(obj->method);
670 break;
674 break;
678 break;
680 uacpi_mutex_unref(obj->mutex);
681 break;
684 free_event);
685 break;
689 break;
693 break;
697 break;
701 break;
702 default:
703 break;
704 }
705}
@ UACPI_OBJECT_EVENT
Definition: types.h:112
@ UACPI_OBJECT_METHOD
Definition: types.h:113
@ UACPI_OBJECT_BUFFER
Definition: types.h:108
@ UACPI_OBJECT_STRING
Definition: types.h:107
@ UACPI_OBJECT_PROCESSOR
Definition: types.h:117
@ UACPI_OBJECT_DEVICE
Definition: types.h:111
@ UACPI_OBJECT_MUTEX
Definition: types.h:114
@ UACPI_OBJECT_BUFFER_FIELD
Definition: types.h:119
@ UACPI_OBJECT_OPERATION_REGION
Definition: types.h:115
@ UACPI_OBJECT_FIELD_UNIT
Definition: types.h:110
@ UACPI_OBJECT_THERMAL_ZONE
Definition: types.h:118
@ UACPI_OBJECT_BUFFER_INDEX
Definition: types.h:123
static void free_event(uacpi_handle handle)
Definition: types.c:500
static void free_buffer(uacpi_handle handle)
Definition: types.c:351
static void free_thermal_zone(uacpi_handle handle)
Definition: types.c:596
static void free_device(uacpi_handle handle)
Definition: types.c:582
void uacpi_mutex_unref(uacpi_mutex *mutex)
Definition: types.c:492
static void free_op_region(uacpi_handle handle)
Definition: types.c:555
void uacpi_method_unref(uacpi_control_method *method)
Definition: types.c:648
static void free_package(uacpi_handle handle)
Definition: types.c:452
static void free_processor(uacpi_handle handle)
Definition: types.c:589

Referenced by free_object(), and uacpi_object_assign().

◆ free_op_region()

static void free_op_region ( uacpi_handle  handle)
static

Definition at line 555 of file types.c.

556{
557 uacpi_operation_region *op_region = handle;
558
559 if (uacpi_unlikely(op_region->handler != UACPI_NULL)) {
561 "BUG: attempting to free an opregion@%p with a handler attached\n",
562 op_region
563 );
564 }
565
566 switch (op_region->space) {
568 uacpi_free(op_region->internal_buffer, op_region->length);
569 break;
572 &(struct uacpi_table) { .index = op_region->table_idx }
573 );
574 break;
575 default:
576 break;
577 }
578
579 uacpi_free(op_region, sizeof(*op_region));
580}
#define uacpi_warn(...)
Definition: log.h:20
@ UACPI_ADDRESS_SPACE_TABLE_DATA
Definition: types.h:52
@ UACPI_ADDRESS_SPACE_PCC
Definition: types.h:47
uacpi_u8 * internal_buffer
Definition: types.h:130
uacpi_u64 table_idx
Definition: types.h:127
uacpi_u16 space
Definition: types.h:120
uacpi_u64 length
Definition: types.h:123
uacpi_address_space_handler * handler
Definition: types.h:118
uacpi_status uacpi_table_unref(uacpi_table *)
Definition: tables.c:1158

Referenced by free_object_storage().

◆ free_package()

static void free_package ( uacpi_handle  handle)
static

Definition at line 452 of file types.c.

453{
454 struct free_queue queue = { 0 };
455 uacpi_package *pkg = handle;
458
459 free_queue_push(&queue, pkg);
460
461 while (free_queue_size(&queue) != 0) {
462 pkg = *free_queue_last(&queue);
463 free_queue_pop(&queue);
464
465 /*
466 * 1. Unref/free every object in the package. Note that this might add
467 * even more packages into the free queue.
468 */
469 for (i = 0; i < pkg->count; ++i) {
470 obj = pkg->objects[i];
472 }
473
474 // 2. Release the object array
475 uacpi_free(pkg->objects, sizeof(*pkg->objects) * pkg->count);
476
477 // 3. Release the package itself
478 uacpi_free(pkg, sizeof(*pkg));
479 }
480
481 free_queue_clear(&queue);
482}
static uacpi_bool free_queue_push(struct free_queue *queue, uacpi_package *pkg)
Definition: types.c:369
static void unref_object_no_recurse(uacpi_object *obj, struct free_queue *queue)
Definition: types.c:442
uacpi_size count
Definition: types.h:37

Referenced by free_object_storage(), and uacpi_object_assign_package().

◆ free_plain_no_recurse()

static void free_plain_no_recurse ( uacpi_object obj,
struct free_queue *  queue 
)
static

Definition at line 384 of file types.c.

385{
386 switch (obj->type) {
388 if (uacpi_shareable_unref(obj->package) > 1)
389 break;
390
392 obj->package))) {
394 "unable to free nested package @%p: not enough memory\n",
395 obj->package
396 );
397 }
398
399 // Don't call free_object here as that will recurse
400 uacpi_free(obj, sizeof(*obj));
401 break;
402 default:
403 /*
404 * This call is guaranteed to not recurse further as we handle
405 * recursive cases elsewhere explicitly.
406 */
408 }
409}
uacpi_u32 uacpi_shareable_unref(uacpi_handle)
Definition: shareable.c:41

Referenced by unref_chain_no_recurse(), and unref_plain_no_recurse().

◆ free_processor()

static void free_processor ( uacpi_handle  handle)
static

Definition at line 589 of file types.c.

590{
591 uacpi_processor *processor = handle;
592 free_handlers(processor);
593 uacpi_free(processor, sizeof(*processor));
594}

Referenced by free_object_storage().

◆ free_queue_push()

static uacpi_bool free_queue_push ( struct free_queue *  queue,
uacpi_package pkg 
)
static

Definition at line 369 of file types.c.

370{
372
373 slot = free_queue_alloc(queue);
375 return UACPI_FALSE;
376
377 *slot = pkg;
378 return UACPI_TRUE;
379}
Definition: vfat.h:185
struct _slot slot
Definition: vfat.h:196

Referenced by free_package(), and free_plain_no_recurse().

◆ free_thermal_zone()

static void free_thermal_zone ( uacpi_handle  handle)
static

Definition at line 596 of file types.c.

597{
598 uacpi_thermal_zone *thermal_zone = handle;
599 free_handlers(thermal_zone);
600 uacpi_free(thermal_zone, sizeof(*thermal_zone));
601}

Referenced by free_object_storage().

◆ make_chain_bugged()

static void make_chain_bugged ( uacpi_object obj)
static

Definition at line 713 of file types.c.

714{
715 uacpi_warn("object refcount bug, marking chain @%p as bugged\n", obj);
716
717 while (obj) {
719
720 if (obj->type == UACPI_OBJECT_REFERENCE)
721 obj = obj->inner_object;
722 else
723 obj = UACPI_NULL;
724 }
725}
void uacpi_make_shareable_bugged(uacpi_handle)
Definition: shareable.c:25

Referenced by uacpi_object_attach_child().

◆ method_alloc()

static uacpi_bool method_alloc ( uacpi_object obj)
static

Definition at line 227 of file types.c.

228{
230
233 return UACPI_FALSE;
234
236 obj->method = method;
237
238 return UACPI_TRUE;
239}

◆ mutex_alloc()

static uacpi_bool mutex_alloc ( uacpi_object obj)
static

Definition at line 201 of file types.c.

202{
203 obj->mutex = uacpi_create_mutex();
204 return obj->mutex != UACPI_NULL;
205}
uacpi_mutex * uacpi_create_mutex(void)
Definition: types.c:181

Referenced by assign_mutex().

◆ op_region_alloc()

static uacpi_bool op_region_alloc ( uacpi_object obj)
static

Definition at line 241 of file types.c.

242{
243 uacpi_operation_region *op_region;
244
245 op_region = uacpi_kernel_alloc_zeroed(sizeof(*op_region));
246 if (uacpi_unlikely(op_region == UACPI_NULL))
247 return UACPI_FALSE;
248
249 uacpi_shareable_init(op_region);
250 obj->op_region = op_region;
251
252 return UACPI_TRUE;
253}

◆ package_alloc()

static uacpi_bool package_alloc ( uacpi_object obj,
uacpi_size  initial_size,
enum uacpi_prealloc_objects  prealloc 
)
static

Definition at line 154 of file types.c.

158{
159 uacpi_package *pkg;
160
162 if (uacpi_unlikely(pkg == UACPI_NULL))
163 return UACPI_FALSE;
164
166
167 if (uacpi_unlikely(!uacpi_package_fill(pkg, initial_size, prealloc))) {
168 uacpi_free(pkg, sizeof(*pkg));
169 return UACPI_FALSE;
170 }
171
172 obj->package = pkg;
173 return UACPI_TRUE;
174}
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool prealloc
Definition: btrfs_drv.h:1364
uacpi_bool uacpi_package_fill(uacpi_package *pkg, uacpi_size num_elements, enum uacpi_prealloc_objects prealloc_objects)
Definition: types.c:124

Referenced by deep_copy_package_no_recurse(), empty_package_alloc(), and uacpi_object_assign_package().

◆ processor_alloc()

static uacpi_bool processor_alloc ( uacpi_object obj)
static

Definition at line 269 of file types.c.

270{
271 uacpi_processor *processor;
272
273 processor = uacpi_kernel_alloc_zeroed(sizeof(*processor));
274 if (uacpi_unlikely(processor == UACPI_NULL))
275 return UACPI_FALSE;
276
277 uacpi_shareable_init(processor);
278 obj->processor = processor;
279
280 return UACPI_TRUE;
281}

◆ thermal_zone_alloc()

static uacpi_bool thermal_zone_alloc ( uacpi_object obj)
static

Definition at line 297 of file types.c.

298{
299 uacpi_thermal_zone *thermal_zone;
300
301 thermal_zone = uacpi_kernel_alloc_zeroed(sizeof(*thermal_zone));
302 if (uacpi_unlikely(thermal_zone == UACPI_NULL))
303 return UACPI_FALSE;
304
305 uacpi_shareable_init(thermal_zone);
306 obj->thermal_zone = thermal_zone;
307
308 return UACPI_TRUE;
309}

◆ uacpi_address_space_handler_unref()

void uacpi_address_space_handler_unref ( uacpi_address_space_handler handler)

◆ uacpi_address_space_to_string()

const uacpi_char * uacpi_address_space_to_string ( enum uacpi_address_space  space)

Definition at line 11 of file types.c.

14{
15 switch (space) {
17 return "SystemMemory";
19 return "SystemIO";
21 return "PCI_Config";
23 return "EmbeddedControl";
25 return "SMBus";
27 return "SystemCMOS";
29 return "PciBarTarget";
31 return "IPMI";
33 return "GeneralPurposeIO";
35 return "GenericSerialBus";
37 return "PCC";
39 return "PlatformRtMechanism";
41 return "FFixedHW";
43 return "TableData";
44 default:
45 return "<vendor specific>";
46 }
47}
@ UACPI_ADDRESS_SPACE_IPMI
Definition: types.h:44
@ UACPI_ADDRESS_SPACE_PRM
Definition: types.h:48
@ UACPI_ADDRESS_SPACE_SYSTEM_MEMORY
Definition: types.h:37
@ UACPI_ADDRESS_SPACE_GENERAL_PURPOSE_IO
Definition: types.h:45
@ UACPI_ADDRESS_SPACE_FFIXEDHW
Definition: types.h:49
@ UACPI_ADDRESS_SPACE_PCI_CONFIG
Definition: types.h:39
@ UACPI_ADDRESS_SPACE_EMBEDDED_CONTROLLER
Definition: types.h:40
@ UACPI_ADDRESS_SPACE_SYSTEM_CMOS
Definition: types.h:42
@ UACPI_ADDRESS_SPACE_GENERIC_SERIAL_BUS
Definition: types.h:46
@ UACPI_ADDRESS_SPACE_SYSTEM_IO
Definition: types.h:38
@ UACPI_ADDRESS_SPACE_SMBUS
Definition: types.h:41
@ UACPI_ADDRESS_SPACE_PCI_BAR_TARGET
Definition: types.h:43

Referenced by gas_validate(), reg_or_unreg_all_opregions(), trace_region_io(), uacpi_reboot(), and uacpi_trace_region_error().

◆ uacpi_buffer_to_view()

void uacpi_buffer_to_view ( uacpi_buffer buf,
uacpi_data_view out_view 
)

Definition at line 1034 of file types.c.

1035{
1036 out_view->bytes = buf->byte_data;
1037 out_view->length = buf->size;
1038}
uacpi_size length
Definition: types.h:99
uacpi_u8 * bytes
Definition: types.h:90

Referenced by extract_native_resources_from_method(), handle_concatenate_res(), and uacpi_object_do_get_string_or_buffer().

◆ uacpi_create_internal_reference()

struct uacpi_object * uacpi_create_internal_reference ( enum uacpi_reference_kind  kind,
uacpi_object child 
)

Definition at line 1453 of file types.c.

1456{
1458
1461 return ret;
1462
1463 ret->flags = kind;
1465 return ret;
1466}
uacpi_object * uacpi_create_object(uacpi_object_type type)
Definition: types.c:327
void uacpi_object_attach_child(uacpi_object *parent, uacpi_object *child)
Definition: types.c:943
static HWND child
Definition: cursoricon.c:298

Referenced by create_named_scope(), frame_push_args(), handle_arg_or_local(), handle_create_buffer_field(), handle_create_data_region(), handle_create_field(), handle_create_method(), handle_create_mutex_or_event(), handle_create_named(), handle_create_op_region(), handle_index(), and uacpi_initialize_namespace().

◆ uacpi_create_mutex()

uacpi_mutex * uacpi_create_mutex ( void  )

Definition at line 181 of file types.c.

182{
184
187 return UACPI_NULL;
188
190
192 if (mutex->handle == UACPI_NULL) {
193 uacpi_free(mutex, sizeof(*mutex));
194 return UACPI_NULL;
195 }
196
198 return mutex;
199}
#define UACPI_THREAD_ID_NONE
Definition: arch_helpers.h:35
uacpi_handle uacpi_kernel_create_mutex(void)
Definition: uacpiosl.c:139

Referenced by enter_method(), and mutex_alloc().

◆ uacpi_create_object()

uacpi_object * uacpi_create_object ( uacpi_object_type  type)

◆ uacpi_method_unref()

void uacpi_method_unref ( uacpi_control_method method)

Definition at line 648 of file types.c.

649{
651}
static void free_method(uacpi_handle handle)
Definition: types.c:635

Referenced by call_frame_clear(), free_object_storage(), and uacpi_eval().

◆ uacpi_mutex_unref()

void uacpi_mutex_unref ( uacpi_mutex mutex)

◆ uacpi_object_assign()

uacpi_status uacpi_object_assign ( uacpi_object dst,
uacpi_object src,
enum uacpi_assign_behavior  behavior 
)

Definition at line 1360 of file types.c.

1362{
1364
1365 if (src == dst)
1366 return ret;
1367
1368 switch (dst->type) {
1371 break;
1376 case UACPI_OBJECT_MUTEX:
1377 case UACPI_OBJECT_EVENT:
1382 break;
1383 default:
1384 break;
1385 }
1386
1387 switch (src->type) {
1389 case UACPI_OBJECT_DEBUG:
1390 break;
1393 dst->flags = src->flags;
1394 ret = assign_buffer(dst, src, behavior);
1395 break;
1397 dst->buffer_field = src->buffer_field;
1398 uacpi_shareable_ref(dst->buffer_field.backing);
1399 break;
1401 dst->buffer_index = src->buffer_index;
1402 uacpi_shareable_ref(dst->buffer_index.buffer);
1403 break;
1405 dst->integer = src->integer;
1406 break;
1408 dst->method = src->method;
1409 uacpi_shareable_ref(dst->method);
1410 break;
1411 case UACPI_OBJECT_MUTEX:
1412 ret = assign_mutex(dst, src, behavior);
1413 break;
1414 case UACPI_OBJECT_EVENT:
1415 ret = assign_event(dst, src, behavior);
1416 break;
1418 dst->op_region = src->op_region;
1419 uacpi_shareable_ref(dst->op_region);
1420 break;
1422 ret = assign_package(dst, src, behavior);
1423 break;
1425 dst->field_unit = src->field_unit;
1426 uacpi_shareable_ref(dst->field_unit);
1427 break;
1429 uacpi_object_attach_child(dst, src->inner_object);
1430 break;
1432 dst->processor = src->processor;
1433 uacpi_shareable_ref(dst->processor);
1434 break;
1436 dst->device = src->device;
1437 uacpi_shareable_ref(dst->device);
1438 break;
1440 dst->thermal_zone = src->thermal_zone;
1441 uacpi_shareable_ref(dst->thermal_zone);
1442 break;
1443 default:
1445 }
1446
1447 if (ret == UACPI_STATUS_OK)
1448 dst->type = src->type;
1449
1450 return ret;
1451}
@ UACPI_STATUS_UNIMPLEMENTED
Definition: status.h:19
@ UACPI_OBJECT_UNINITIALIZED
Definition: types.h:105
@ UACPI_OBJECT_DEBUG
Definition: types.h:120
@ UACPI_OBJECT_INTEGER
Definition: types.h:106
static uacpi_status assign_event(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
Definition: types.c:915
static uacpi_status assign_package(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
Definition: types.c:931
void uacpi_object_detach_child(uacpi_object *parent)
Definition: types.c:959
static uacpi_status assign_buffer(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
Definition: types.c:791
static uacpi_status assign_mutex(uacpi_object *dst, uacpi_object *src, enum uacpi_assign_behavior behavior)
Definition: types.c:897

Referenced by copy_object_to_reference(), deep_copy_package_no_recurse(), exec_op(), handle_package(), handle_ref_or_deref_of(), handle_return(), store_to_reference(), uacpi_eval(), uacpi_object_assign_integer(), uacpi_object_assign_package(), uacpi_object_assign_reference(), and uacpi_object_do_assign_buffer().

◆ uacpi_object_assign_buffer()

uacpi_status uacpi_object_assign_buffer ( uacpi_object obj,
uacpi_data_view  in 
)

Definition at line 1133 of file types.c.

1134{
1136}
static uacpi_status uacpi_object_do_assign_buffer(uacpi_object *obj, uacpi_data_view in, uacpi_object_type type)
Definition: types.c:1098
GLuint in
Definition: glext.h:9616

◆ uacpi_object_assign_integer()

uacpi_status uacpi_object_assign_integer ( uacpi_object obj,
uacpi_u64  value 
)

Definition at line 1024 of file types.c.

1025{
1027
1029 .type = UACPI_OBJECT_INTEGER,
1030 .integer = value,
1032}
#define ENSURE_VALID_USER_OBJ(obj)
Definition: types.c:1013
Definition: pdh_main.c:96

◆ uacpi_object_assign_package()

uacpi_status uacpi_object_assign_package ( uacpi_object obj,
uacpi_object_array  in 
)

Definition at line 1313 of file types.c.

1316{
1318 uacpi_size i;
1319 uacpi_object tmp_obj = {
1321 };
1322
1324
1325 if (uacpi_unlikely(!package_alloc(&tmp_obj, in.count,
1328
1329 obj->type = UACPI_OBJECT_PACKAGE;
1330
1331 for (i = 0; i < in.count; ++i) {
1332 tmp_obj.package->objects[i] = in.objects[i];
1333 uacpi_object_ref(tmp_obj.package->objects[i]);
1334 }
1335
1338
1339 return ret;
1340}
void uacpi_object_ref(uacpi_object *obj)
Definition: types.c:727

Referenced by uacpi_object_create_package().

◆ uacpi_object_assign_reference()

uacpi_status uacpi_object_assign_reference ( uacpi_object obj,
uacpi_object child 
)

Definition at line 1254 of file types.c.

1257{
1259
1262
1263 // First clear out the object
1267 );
1269 return ret;
1270
1274
1275 return UACPI_STATUS_OK;
1276}
@ UACPI_REFERENCE_KIND_ARG
Definition: types.h:13

◆ uacpi_object_assign_string()

uacpi_status uacpi_object_assign_string ( uacpi_object obj,
uacpi_data_view  in 
)

Definition at line 1128 of file types.c.

◆ uacpi_object_attach_child()

void uacpi_object_attach_child ( uacpi_object parent,
uacpi_object child 
)

Definition at line 943 of file types.c.

944{
945 uacpi_u32 refs_to_add;
946
947 parent->inner_object = child;
948
951 return;
952 }
953
954 refs_to_add = uacpi_shareable_refcount(parent);
955 while (refs_to_add--)
957}
uint32_t uacpi_u32
Definition: types.h:21
static void make_chain_bugged(uacpi_object *obj)
Definition: types.c:713
r parent
Definition: btrfs.c:3010
uacpi_bool uacpi_bugged_shareable(uacpi_handle)
Definition: shareable.c:15

Referenced by object_replace_child(), uacpi_create_internal_reference(), uacpi_object_assign(), uacpi_object_assign_reference(), and uacpi_object_create_reference().

◆ uacpi_object_create_buffer()

uacpi_object * uacpi_object_create_buffer ( uacpi_data_view  view)

Definition at line 1214 of file types.c.

1215{
1217}
static uacpi_object * uacpi_object_do_create_string_or_buffer(uacpi_data_view view, uacpi_object_type type)
Definition: types.c:1189

◆ uacpi_object_create_cstring()

uacpi_object * uacpi_object_create_cstring ( const uacpi_char str)

Definition at line 1219 of file types.c.

1220{
1222 .const_text = str,
1223 .length = uacpi_strlen(str) + 1,
1224 });
1225}
uacpi_size uacpi_strlen(const uacpi_char *str)
Definition: stdlib.c:72
uacpi_object * uacpi_object_create_string(uacpi_data_view view)
Definition: types.c:1209
const WCHAR * str

◆ uacpi_object_create_integer()

uacpi_object * uacpi_object_create_integer ( uacpi_u64  value)

Definition at line 1177 of file types.c.

1178{
1180
1183 return obj;
1184
1185 obj->integer = value;
1186 return obj;
1187}

Referenced by uacpi_object_create_integer_safe().

◆ uacpi_object_create_integer_safe()

uacpi_status uacpi_object_create_integer_safe ( uacpi_u64  value,
uacpi_overflow_behavior  behavior,
uacpi_object **  out_obj 
)

Definition at line 1143 of file types.c.

1146{
1148 uacpi_u8 bitness;
1150
1151 ret = uacpi_get_aml_bitness(&bitness);
1153 return ret;
1154
1155 switch (behavior) {
1158 if (bitness == 32 && value > 0xFFFFFFFF) {
1159 if (behavior == UACPI_OVERFLOW_DISALLOW)
1161
1162 value &= 0xFFFFFFFF;
1163 }
1169
1170 *out_obj = obj;
1171 return ret;
1172 default:
1174 }
1175}
#define UACPI_FALLTHROUGH
Definition: compiler.h:70
uint8_t uacpi_u8
Definition: types.h:19
@ UACPI_STATUS_INVALID_ARGUMENT
Definition: status.h:18
@ UACPI_OVERFLOW_TRUNCATE
Definition: types.h:185
@ UACPI_OVERFLOW_ALLOW
Definition: types.h:184
@ UACPI_OVERFLOW_DISALLOW
Definition: types.h:186
uacpi_object * uacpi_object_create_integer(uacpi_u64 value)
Definition: types.c:1177
uacpi_status uacpi_get_aml_bitness(uacpi_u8 *out_bitness)
Definition: uacpi.c:989

◆ uacpi_object_create_package()

uacpi_object * uacpi_object_create_package ( uacpi_object_array  in)

Definition at line 1342 of file types.c.

1343{
1346
1349 return obj;
1350
1354 return UACPI_NULL;
1355 }
1356
1357 return obj;
1358}
uacpi_status uacpi_object_assign_package(uacpi_object *obj, uacpi_object_array in)
Definition: types.c:1313
uacpi_object * uacpi_object_create_uninitialized(void)
Definition: types.c:1138

◆ uacpi_object_create_reference()

uacpi_object * uacpi_object_create_reference ( uacpi_object child)

Definition at line 1238 of file types.c.

1239{
1241
1243
1246 return UACPI_NULL;
1247
1250
1251 return obj;
1252}
#define ENSURE_VALID_USER_OBJ_RET(obj, ret)
Definition: types.c:1007

◆ uacpi_object_create_string()

uacpi_object * uacpi_object_create_string ( uacpi_data_view  view)

Definition at line 1209 of file types.c.

Referenced by uacpi_object_create_cstring().

◆ uacpi_object_create_uninitialized()

uacpi_object * uacpi_object_create_uninitialized ( void  )

Definition at line 1138 of file types.c.

Referenced by uacpi_object_create_package().

◆ uacpi_object_detach_child()

void uacpi_object_detach_child ( uacpi_object parent)

Definition at line 959 of file types.c.

960{
961 uacpi_u32 refs_to_remove;
963
964 child = parent->inner_object;
965 parent->inner_object = UACPI_NULL;
966
968 return;
969
970 refs_to_remove = uacpi_shareable_refcount(parent);
971 while (refs_to_remove--)
973}

Referenced by object_replace_child(), and uacpi_object_assign().

◆ uacpi_object_do_assign_buffer()

static uacpi_status uacpi_object_do_assign_buffer ( uacpi_object obj,
uacpi_data_view  in,
uacpi_object_type  type 
)
static

Definition at line 1098 of file types.c.

1101{
1103 uacpi_object tmp_obj = {
1104 .type = type,
1105 };
1106 uacpi_size dst_buf_size = in.length;
1107
1109
1110 if (type == UACPI_OBJECT_STRING && (in.length == 0 ||
1111 in.const_bytes[in.length - 1] != 0x00))
1112 dst_buf_size++;
1113
1115 &tmp_obj, dst_buf_size, in.const_bytes, in.length
1116 );
1118 return ret;
1119
1122 );
1124
1125 return ret;
1126}
uacpi_buffer * buffer
Definition: types.h:258

Referenced by uacpi_object_assign_buffer(), uacpi_object_assign_string(), and uacpi_object_do_create_string_or_buffer().

◆ uacpi_object_do_create_string_or_buffer()

static uacpi_object * uacpi_object_do_create_string_or_buffer ( uacpi_data_view  view,
uacpi_object_type  type 
)
static

Definition at line 1189 of file types.c.

1192{
1195
1198 return UACPI_NULL;
1199
1203 return UACPI_NULL;
1204 }
1205
1206 return obj;
1207}

Referenced by uacpi_object_create_buffer(), and uacpi_object_create_string().

◆ uacpi_object_do_get_string_or_buffer()

static uacpi_status uacpi_object_do_get_string_or_buffer ( uacpi_object obj,
uacpi_data_view out,
uacpi_u32  mask 
)
static

Definition at line 1040 of file types.c.

1043{
1045
1046 uacpi_buffer_to_view(obj->buffer, out);
1047 return UACPI_STATUS_OK;
1048}
#define TYPE_CHECK_USER_OBJ(obj, type_bits)
Definition: types.c:1004
void uacpi_buffer_to_view(uacpi_buffer *buf, uacpi_data_view *out_view)
Definition: types.c:1034
GLenum GLint GLuint mask
Definition: glext.h:6028
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by uacpi_object_get_buffer(), uacpi_object_get_string(), and uacpi_object_get_string_or_buffer().

◆ uacpi_object_get_buffer()

uacpi_status uacpi_object_get_buffer ( uacpi_object obj,
uacpi_data_view out 
)

Definition at line 1066 of file types.c.

1067{
1070 );
1071}
@ UACPI_OBJECT_BUFFER_BIT
Definition: types.h:131
static uacpi_status uacpi_object_do_get_string_or_buffer(uacpi_object *obj, uacpi_data_view *out, uacpi_u32 mask)
Definition: types.c:1040

◆ uacpi_object_get_dereferenced()

uacpi_status uacpi_object_get_dereferenced ( uacpi_object obj,
uacpi_object **  out 
)

Definition at line 1278 of file types.c.

1281{
1283
1284 *out = obj->inner_object;
1286
1287 return UACPI_STATUS_OK;
1288}
@ UACPI_OBJECT_REFERENCE_BIT
Definition: types.h:144

◆ uacpi_object_get_integer()

uacpi_status uacpi_object_get_integer ( uacpi_object obj,
uacpi_u64 out 
)

Definition at line 1016 of file types.c.

1017{
1019
1020 *out = obj->integer;
1021 return UACPI_STATUS_OK;
1022}
@ UACPI_OBJECT_INTEGER_BIT
Definition: types.h:129

◆ uacpi_object_get_package()

uacpi_status uacpi_object_get_package ( uacpi_object obj,
uacpi_object_array out 
)

Definition at line 1227 of file types.c.

1230{
1232
1233 out->objects = obj->package->objects;
1234 out->count = obj->package->count;
1235 return UACPI_STATUS_OK;
1236}
@ UACPI_OBJECT_PACKAGE_BIT
Definition: types.h:132

◆ uacpi_object_get_power_resource_info()

uacpi_status uacpi_object_get_power_resource_info ( uacpi_object obj,
uacpi_power_resource_info out 
)

Definition at line 1302 of file types.c.

1305{
1307
1308 out->system_level = obj->power_resource.system_level;
1309 out->resource_order = obj->power_resource.resource_order;
1310 return UACPI_STATUS_OK;
1311}
@ UACPI_OBJECT_POWER_RESOURCE_BIT
Definition: types.h:139

◆ uacpi_object_get_processor_info()

uacpi_status uacpi_object_get_processor_info ( uacpi_object obj,
uacpi_processor_info out 
)

Definition at line 1290 of file types.c.

1293{
1295
1296 out->id = obj->processor->id;
1297 out->block_address = obj->processor->block_address;
1298 out->block_length = obj->processor->block_length;
1299 return UACPI_STATUS_OK;
1300}
@ UACPI_OBJECT_PROCESSOR_BIT
Definition: types.h:140

◆ uacpi_object_get_string()

uacpi_status uacpi_object_get_string ( uacpi_object obj,
uacpi_data_view out 
)

Definition at line 1059 of file types.c.

1060{
1063 );
1064}
@ UACPI_OBJECT_STRING_BIT
Definition: types.h:130

◆ uacpi_object_get_string_or_buffer()

uacpi_status uacpi_object_get_string_or_buffer ( uacpi_object obj,
uacpi_data_view out 
)

Definition at line 1050 of file types.c.

Referenced by uacpi_dispatch_opregion_io().

◆ uacpi_object_get_type()

uacpi_object_type uacpi_object_get_type ( uacpi_object obj)

Definition at line 975 of file types.c.

976{
977 return obj->type;
978}

◆ uacpi_object_get_type_bit()

uacpi_object_type_bits uacpi_object_get_type_bit ( uacpi_object obj)

Definition at line 980 of file types.c.

981{
982 return (1u << obj->type);
983}

Referenced by uacpi_object_is_one_of().

◆ uacpi_object_is()

uacpi_bool uacpi_object_is ( uacpi_object obj,
uacpi_object_type  type 
)

Definition at line 985 of file types.c.

986{
987 return obj->type == type;
988}

Referenced by object_mutate_refcount(), and object_replace_child().

◆ uacpi_object_is_aml_namepath()

uacpi_bool uacpi_object_is_aml_namepath ( uacpi_object obj)

Definition at line 1073 of file types.c.

1074{
1076 return obj->flags == UACPI_STRING_KIND_PATH;
1077}
@ UACPI_STRING_KIND_PATH
Definition: types.h:21
#define TYPE_CHECK_USER_OBJ_RET(obj, type_bits, ret)
Definition: types.c:997

Referenced by uacpi_object_resolve_as_aml_namepath().

◆ uacpi_object_is_one_of()

uacpi_bool uacpi_object_is_one_of ( uacpi_object obj,
uacpi_object_type_bits  type_mask 
)

Definition at line 990 of file types.c.

993{
994 return (uacpi_object_get_type_bit(obj) & type_mask) != 0;
995}
uacpi_object_type_bits uacpi_object_get_type_bit(uacpi_object *obj)
Definition: types.c:980

Referenced by uacpi_namespace_node_acquire_object_typed(), uacpi_namespace_node_get_object_typed(), and uacpi_namespace_node_is_one_of_unlocked().

◆ uacpi_object_ref()

◆ uacpi_object_resolve_as_aml_namepath()

uacpi_status uacpi_object_resolve_as_aml_namepath ( uacpi_object obj,
uacpi_namespace_node scope,
uacpi_namespace_node **  out_node 
)

Definition at line 1079 of file types.c.

1083{
1086
1089
1091 scope, obj->buffer->text, &node
1092 );
1094 *out_node = node;
1095 return ret;
1096}
uacpi_status uacpi_namespace_node_resolve_from_aml_namepath(uacpi_namespace_node *scope, const uacpi_char *path, uacpi_namespace_node **out_node)
Definition: namespace.c:634
#define uacpi_likely_success(expr)
Definition: status.h:53
uacpi_bool uacpi_object_is_aml_namepath(uacpi_object *obj)
Definition: types.c:1073
Definition: dlist.c:348

Referenced by uacpi_get_pci_routing_table().

◆ uacpi_object_type_to_string()

const uacpi_char * uacpi_object_type_to_string ( uacpi_object_type  type)

Definition at line 51 of file types.c.

52{
53 switch (type) {
55 return "Uninitialized";
57 return "Integer";
59 return "String";
61 return "Buffer";
63 return "Package";
65 return "Field Unit";
67 return "Device";
69 return "Event";
71 return "Reference";
73 return "Buffer Index";
75 return "Method";
77 return "Mutex";
79 return "Operation Region";
81 return "Power Resource";
83 return "Processor";
85 return "Thermal Zone";
87 return "Buffer Field";
89 return "Debug";
90 default:
91 return "<Invalid type>";
92 }
93}
@ UACPI_OBJECT_POWER_RESOURCE
Definition: types.h:116

Referenced by debug_store_no_recurse(), ensure_is_a_field_unit(), ensure_is_an_op_region(), ensure_valid_idx(), exec_op(), get_slp_type_for_state(), handle_binary_logic(), handle_event_ctl(), handle_inc_dec(), handle_index(), handle_load(), handle_mid(), handle_mutex_ctl(), handle_ref_or_deref_of(), handle_sizeof(), object_assign_with_implicit_cast(), store_to_target(), typecheck_computational_data(), typecheck_obj(), uacpi_eval_cid(), uacpi_get_pci_routing_table(), and uacpi_osi().

◆ uacpi_object_unref()

void uacpi_object_unref ( uacpi_object obj)

Definition at line 755 of file types.c.

756{
757 uacpi_object *this_obj = obj;
758
759 if (!obj)
760 return;
761
762 while (obj) {
764 return;
765
767
768 if (obj->type == UACPI_OBJECT_REFERENCE) {
769 obj = obj->inner_object;
770 } else {
771 obj = UACPI_NULL;
772 }
773 }
774
775 if (uacpi_shareable_refcount(this_obj) == 0)
776 free_chain(this_obj);
777}
static void free_chain(uacpi_object *obj)
Definition: types.c:739

Referenced by call_frame_clear(), copy_object_to_reference(), eval_sleep_helper(), exec_op(), execution_context_release(), extract_native_resources_from_method(), free_field_unit(), get_slp_type_for_state(), handle_arg_or_local(), handle_copy_object_or_store(), handle_index(), handle_load_table(), handle_package(), make_object_for_predefined(), namespace_node_detach_object(), pop_item(), region_run_reg(), store_to_reference(), uacpi_deinitialize_namespace(), uacpi_dispatch_opregion_io(), uacpi_eval(), uacpi_eval_cid(), uacpi_eval_cls(), uacpi_eval_dstate_method_template(), uacpi_eval_hid(), uacpi_eval_integer(), uacpi_eval_typed(), uacpi_eval_uid(), uacpi_get_pci_routing_table(), uacpi_initialize_namespace(), uacpi_install_notify_handler(), uacpi_namespace_node_release_object(), uacpi_native_resources_to_aml(), uacpi_object_create_package(), uacpi_object_detach_child(), uacpi_object_do_create_string_or_buffer(), uacpi_opregion_attach(), uacpi_set_interrupt_model(), uacpi_set_resources(), and uacpi_uninstall_notify_handler().

◆ uacpi_package_fill()

uacpi_bool uacpi_package_fill ( uacpi_package pkg,
uacpi_size  num_elements,
enum uacpi_prealloc_objects  prealloc_objects 
)

Definition at line 124 of file types.c.

128{
130
131 if (uacpi_unlikely(num_elements == 0))
132 return UACPI_TRUE;
133
135 num_elements * sizeof(uacpi_handle)
136 );
137 if (uacpi_unlikely(pkg->objects == UACPI_NULL))
138 return UACPI_FALSE;
139
140 pkg->count = num_elements;
141
142 if (prealloc_objects == UACPI_PREALLOC_OBJECTS_YES) {
143 for (i = 0; i < num_elements; ++i) {
145
146 if (uacpi_unlikely(pkg->objects[i] == UACPI_NULL))
147 return UACPI_FALSE;
148 }
149 }
150
151 return UACPI_TRUE;
152}

Referenced by handle_package(), and package_alloc().

◆ uacpi_unwrap_internal_reference()

uacpi_object * uacpi_unwrap_internal_reference ( uacpi_object object)

Definition at line 1468 of file types.c.

1469{
1470 for (;;) {
1471 if (object->type != UACPI_OBJECT_REFERENCE ||
1474 return object;
1475
1476 object = object->inner_object;
1477 }
1478}
@ UACPI_REFERENCE_KIND_REFOF
Definition: types.h:11

Referenced by copy_object_to_reference(), debug_store(), exec_op(), handle_event_ctl(), handle_mutex_ctl(), handle_package(), method_get_ret_object(), store_to_reference(), store_to_target(), uacpi_namespace_node_get_object(), and uacpi_osi().

◆ unref_chain_no_recurse()

static void unref_chain_no_recurse ( uacpi_object obj,
struct free_queue *  queue 
)
static

Definition at line 419 of file types.c.

420{
421 uacpi_object *next_obj = UACPI_NULL;
422
423 while (obj) {
424 if (obj->type == UACPI_OBJECT_REFERENCE)
425 next_obj = obj->inner_object;
426
427 if (uacpi_shareable_unref(obj) > 1)
428 goto do_next;
429
430 if (obj->type == UACPI_OBJECT_REFERENCE) {
431 uacpi_free(obj, sizeof(*obj));
432 } else {
434 }
435
436 do_next:
437 obj = next_obj;
438 next_obj = UACPI_NULL;
439 }
440}
static void free_plain_no_recurse(uacpi_object *obj, struct free_queue *queue)
Definition: types.c:384

Referenced by unref_object_no_recurse().

◆ unref_object_no_recurse()

static void unref_object_no_recurse ( uacpi_object obj,
struct free_queue *  queue 
)
static

Definition at line 442 of file types.c.

443{
444 if (obj->type == UACPI_OBJECT_REFERENCE) {
446 return;
447 }
448
450}
static void unref_chain_no_recurse(uacpi_object *obj, struct free_queue *queue)
Definition: types.c:419
static void unref_plain_no_recurse(uacpi_object *obj, struct free_queue *queue)
Definition: types.c:411

Referenced by free_package().

◆ unref_plain_no_recurse()

static void unref_plain_no_recurse ( uacpi_object obj,
struct free_queue *  queue 
)
static

Definition at line 411 of file types.c.

412{
413 if (uacpi_shareable_unref(obj) > 1)
414 return;
415
417}

Referenced by unref_object_no_recurse().

Variable Documentation

◆ object_constructor_table

object_ctor object_constructor_table[UACPI_OBJECT_MAX_TYPE_VALUE+1]
static
Initial value:
= {
}
static uacpi_bool field_unit_alloc(uacpi_object *obj)
Definition: types.c:255
static uacpi_bool thermal_zone_alloc(uacpi_object *obj)
Definition: types.c:297
static uacpi_bool device_alloc(uacpi_object *obj)
Definition: types.c:283
static uacpi_bool processor_alloc(uacpi_object *obj)
Definition: types.c:269
static uacpi_bool empty_package_alloc(uacpi_object *object)
Definition: types.c:176
static uacpi_bool method_alloc(uacpi_object *obj)
Definition: types.c:227
static uacpi_bool op_region_alloc(uacpi_object *obj)
Definition: types.c:241
static uacpi_bool empty_buffer_or_string_alloc(uacpi_object *object)
Definition: types.c:119

Definition at line 313 of file types.c.

Referenced by uacpi_create_object().