|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <lauxlib.h> |
| 4 | +#include <lua.h> |
| 5 | +#include <lacpi_walk.h> |
| 6 | +#include <contrib/dev/acpica/include/acpi.h> |
| 7 | + |
| 8 | +/***** UTILITY *****/ |
| 9 | + |
| 10 | +/* verifies lua passed over a handle on the stack */ |
| 11 | +ACPI_HANDLE lacpi_check_handle(lua_State *L, int idx); |
| 12 | + |
| 13 | +/* destructor dispatcher */ |
| 14 | +typedef void (*acpi_destructor_t)(ACPI_OBJECT *); |
| 15 | + |
| 16 | +/* safety check -- lua stores integers as 64bit */ |
| 17 | +ACPI_STATUS lacpi_int_to_uint32(lua_State *L, int index, UINT32 *num); |
| 18 | + |
| 19 | +/* to convert ACPI_OBJECT_TYPE from table value */ |
| 20 | +ACPI_STATUS lacpi_infer_type(lua_State *L, int idx, UINT32 *type); |
| 21 | + |
| 22 | +/* build error code and push it onto stack */ |
| 23 | +int lacpi_push_err(lua_State *L, const int push_nil, const char *errmsg, |
| 24 | + const ACPI_STATUS status); |
| 25 | + |
| 26 | +/* extract error message relating to ACPI_STATUS */ |
| 27 | +char *lacpi_extract_status(const ACPI_STATUS status); |
| 28 | + |
| 29 | +/***** FACTORY *****/ |
| 30 | + |
| 31 | +/* create metatable gc */ |
| 32 | +int lacpi_create_mt_gc(lua_State *L, const char *mt, lua_CFunction gc_func); |
| 33 | + |
| 34 | +/*** ACPI_OBJECT ***/ |
| 35 | +/* build ACPI_OBJECTs */ |
| 36 | +ACPI_STATUS build_int(lua_State *L, ACPI_OBJECT *obj, int idx); |
| 37 | +ACPI_STATUS build_str(lua_State *L, ACPI_OBJECT *obj, int idx); |
| 38 | +ACPI_STATUS build_buff(lua_State *L, ACPI_OBJECT *obj, int idx); |
| 39 | +ACPI_STATUS build_pkg(lua_State *L, ACPI_OBJECT *obj, int idx); |
| 40 | +ACPI_STATUS build_acpi_obj(lua_State *L, ACPI_OBJECT *obj, UINT32 obj_type, int idx); |
| 41 | +ACPI_STATUS build_ref(lua_State *L, ACPI_OBJECT *obj, int idx); |
| 42 | +ACPI_STATUS build_proc(lua_State *L, ACPI_OBJECT *obj, int idx); |
| 43 | +ACPI_STATUS build_pow(lua_State *L, ACPI_OBJECT *obj, int idx); |
| 44 | + |
| 45 | +/* push ACPI_OBJECTs onto lua stack */ |
| 46 | +void push_int(lua_State *L, ACPI_OBJECT *obj); |
| 47 | +void push_str(lua_State *L, ACPI_OBJECT *obj); |
| 48 | +void push_buff(lua_State *L, ACPI_OBJECT *obj); |
| 49 | +void push_pkg(lua_State *L, ACPI_OBJECT *obj); |
| 50 | +void push_acpi_obj(lua_State *L, ACPI_OBJECT *obj); |
| 51 | +void push_ref(lua_State *L, ACPI_OBJECT *obj); |
| 52 | +void push_proc(lua_State *L, ACPI_OBJECT *obj); |
| 53 | +void push_pow(lua_State *L, ACPI_OBJECT *obj); |
| 54 | + |
| 55 | +/* free ACPI_OBJECTs */ |
| 56 | +void free_fake(ACPI_OBJECT *obj); |
| 57 | +void free_str(ACPI_OBJECT *obj); |
| 58 | +void free_buff(ACPI_OBJECT *obj); |
| 59 | +void free_pkg(ACPI_OBJECT *obj); |
| 60 | +void free_acpi_obj(ACPI_OBJECT *obj); |
| 61 | +void free_acpi_objs(ACPI_OBJECT **objs, UINT32 init_count); |
| 62 | + |
| 63 | +/*** ACPI Namespace Node ***/ |
| 64 | +void push_path(struct context *curr_ctx, const char *path); |
| 65 | +void push_lvl(struct context *curr_ctx, UINT32 level); |
| 66 | +void push_hid(struct context *curr_ctx, const char *hid); |
| 67 | +void push_uid(struct context *curr_ctx, const char *uid); |
| 68 | +void push_node(struct context *curr_ctx, const char *path, UINT32 level, |
| 69 | + ACPI_HANDLE handle); |
0 commit comments