Lines Matching defs:scope

768 aml_lockfield(struct aml_scope *scope, struct aml_value *field)
777 aml_unlockfield(struct aml_scope *scope, struct aml_value *field)
1287 uint8_t *aml_parseend(struct aml_scope *scope);
1293 aml_parseopcode(struct aml_scope *scope)
1295 int opcode = (scope->pos[0]);
1296 int twocode = (scope->pos[0]<<8) + scope->pos[1];
1311 scope->pos += 2;
1314 scope->pos += 1;
1392 aml_parselength(struct aml_scope *scope)
1397 lcode = *(scope->pos++);
1403 len += *(scope->pos++) << 4L;
1405 len += *(scope->pos++) << 12L;
1407 len += *(scope->pos++) << 20L;
1411 /* Get address of end of scope; based on current address */
1413 aml_parseend(struct aml_scope *scope)
1415 uint8_t *pos = scope->pos;
1418 len = aml_parselength(scope);
1419 if (pos+len > scope->end) {
1421 "Bad scope... runover pos:%.4x new end:%.4x scope "
1423 aml_pc(scope->end));
1424 return scope->end;
1495 aml_callosi(struct aml_scope *scope, struct aml_value *val)
1500 fa = aml_getstack(scope, AMLOP_ARG0);
1811 aml_findscope(struct aml_scope *scope, int type, int endscope)
1813 while (scope) {
1816 scope->pos = scope->end;
1817 if (scope->type == AMLOP_WHILE)
1818 scope->pos = NULL;
1821 scope->pos = scope->end;
1824 scope->pos = scope->end;
1825 if (scope->type == type)
1826 scope->parent->pos = scope->end;
1829 if (scope->type == type)
1831 scope = scope->parent;
1833 return scope;
1837 aml_getstack(struct aml_scope *scope, int opcode)
1842 scope = aml_findscope(scope, AMLOP_METHOD, 0);
1843 if (scope == NULL)
1846 if (scope->locals == NULL)
1847 scope->locals = aml_allocvalue(AML_OBJTYPE_PACKAGE, 8, NULL);
1848 sp = scope->locals->v_package[opcode - AMLOP_LOCAL0];
1851 if (scope->args == NULL)
1852 scope->args = aml_allocvalue(AML_OBJTYPE_PACKAGE, 7, NULL);
1853 sp = scope->args->v_package[opcode - AMLOP_ARG0];
1863 aml_showstack(struct aml_scope *scope)
1868 dnprintf(10, "===== Stack %s:%s\n", aml_nodename(scope->node),
1869 aml_mnem(scope->type, 0));
1870 for (idx=0; scope->args && idx<7; idx++) {
1871 sp = aml_getstack(scope, AMLOP_ARG0+idx);
1877 for (idx=0; scope->locals && idx<8; idx++) {
1878 sp = aml_getstack(scope, AMLOP_LOCAL0+idx);
1887 /* Create a new scope object */
1892 struct aml_scope *scope;
1904 scope = acpi_os_malloc(sizeof(struct aml_scope));
1905 if (scope == NULL)
1908 scope->node = node;
1909 scope->start = start;
1910 scope->end = end;
1911 scope->pos = scope->start;
1912 scope->parent = parent;
1913 scope->type = type;
1914 scope->sc = acpi_softc;
1917 scope->depth = parent->depth+1;
1919 aml_lastscope = scope;
1921 return scope;
1924 /* Free a scope object and any children */
1926 aml_popscope(struct aml_scope *scope)
1930 if (scope == NULL)
1933 nscope = scope->parent;
1935 if (scope->type == AMLOP_METHOD)
1936 aml_delchildren(scope->node);
1937 if (scope->locals) {
1938 aml_freevalue(scope->locals);
1939 acpi_os_free(scope->locals);
1940 scope->locals = NULL;
1942 if (scope->args) {
1943 aml_freevalue(scope->args);
1944 acpi_os_free(scope->args);
1945 scope->args = NULL;
1947 acpi_os_free(scope);
2878 /* Parse Field/IndexField/BankField scope */
2941 acpi_mutex_acquire(struct aml_scope *scope, struct aml_value *mtx,
2944 if (mtx->v_mtx.owner == NULL || scope == mtx->v_mtx.owner) {
2946 mtx->v_mtx.owner = scope;
2951 dnprintf(5,"%s acquires mutex %s\n", scope->node->name,
2962 acpi_mutex_release(struct aml_scope *scope, struct aml_value *mtx)
2968 dnprintf(5, "%s releases mutex %s\n", scope->node->name,
2975 acpi_event_wait(struct aml_scope *scope, struct aml_value *evt, int timeout)
3000 acpi_event_signal(struct aml_scope *scope, struct aml_value *evt)
3008 acpi_event_reset(struct aml_scope *scope, struct aml_value *evt)
3015 aml_store(struct aml_scope *scope, struct aml_value *lhs , int64_t ival,
3083 node = __aml_searchname(scope->node,
3121 aml_disasm(struct aml_scope *scope, int lvl,
3138 pc = aml_pc(scope->pos);
3139 opcode = aml_parseopcode(scope);
3152 scope->pos = aml_parsename(scope->node, scope->pos, &rv, 0);
3319 end = aml_parseend(scope);
3323 end = aml_parseend(scope);
3327 end = aml_parseend(scope);
3331 end = aml_parseend(scope);
3335 end = aml_parseend(scope);
3339 end = aml_parseend(scope);
3343 end = aml_parseend(scope);
3347 end = aml_parseend(scope);
3351 end = aml_parseend(scope);
3355 end = aml_parseend(scope);
3359 end = aml_parseend(scope);
3388 aml_parsesimple(scope, c, &tmp);
3392 dbprintf(arg, "\'%s\'", scope->pos);
3393 scope->pos += strlen(scope->pos)+1;
3397 rv = aml_parsesimple(scope, c, NULL);
3406 printf("%s", aml_getname(scope->pos));
3407 scope->pos = aml_parsename(scope->node, scope->pos,
3414 aml_disasm(scope, lvl | 0x8000, dbprintf, arg);
3418 scope->pos = end;
3423 ms.node = scope->node;
3424 ms.start = scope->pos;
3446 dbprintf(arg,"%.4x ", aml_pc(scope->pos));
3450 scope->pos = end;
3455 ms.node = scope->node;
3456 ms.start = scope->pos;
3467 dbprintf(arg,"%.4x ", aml_pc(scope->pos));
3471 scope->pos = end;
3486 aml_eval(struct aml_scope *scope, struct aml_value *my_ret, int ret_type,
3495 my_ret = aml_seterror(scope, "Undefined name: %s",
3503 ms = aml_pushscope(scope, tmp, tmp->node, AMLOP_METHOD);
3514 sp->v_objref.ref = aml_parse(scope, 't', "ARGX");
3521 /* Evaluate method scope */
3664 aml_parsesimple(struct aml_scope *scope, char ch, struct aml_value *rv)
3677 aml_get8(scope->pos), NULL);
3678 scope->pos += 1;
3682 aml_get16(scope->pos), NULL);
3683 scope->pos += 2;
3687 aml_get32(scope->pos), NULL);
3688 scope->pos += 4;
3692 aml_get64(scope->pos), NULL);
3693 scope->pos += 8;
3696 _aml_setvalue(rv, AML_OBJTYPE_STRING, -1, scope->pos);
3697 scope->pos += rv->length+1;
3728 aml_seterror(struct aml_scope *scope, const char *fmt, ...)
3733 printf("### AML PARSE ERROR (0x%x): ", aml_pc(scope->pos));
3738 while (scope) {
3739 scope->pos = scope->end;
3740 scope = scope->parent;
3775 /* Load new SSDT scope from memory address */
3777 aml_load(struct acpi_softc *sc, struct aml_scope *scope,
3805 return aml_pushscope(scope, &tmp, scope->node,
3814 aml_parse(struct aml_scope *scope, int ret_type, const char *stype)
3826 if (scope == NULL || scope->pos >= scope->end) {
3836 iscope = scope;
3839 start = scope->pos;
3840 pc = aml_pc(scope->pos);
3841 aml_debugger(scope);
3843 opcode = aml_parseopcode(scope);
3849 dnprintf(18,"%.4x %s\n", pc, aml_mnem(opcode, scope->pos));
3858 end = aml_parseend(scope);
3862 ch = (*end == AMLOP_ELSE && end < scope->end) ?
3872 if (*ch == 'r' && *scope->pos == AMLOP_ZERO) {
3875 scope->pos++;
3878 rv = aml_parse(scope, *ch, htab->mnem);
3890 rv->v_buffer = scope->pos;
3891 rv->length = end - scope->pos;
3892 scope->pos = end;
3899 scope->pos = aml_parsename(scope->node, scope->pos,
3903 scope->pos = aml_parsename(scope->node, scope->pos,
3913 rv = aml_parsesimple(scope, *ch, NULL);
3917 rv = aml_getstack(scope, opcode);
3956 if (scope->type == AMLOP_PACKAGE && my_ret->node) {
3968 my_ret = aml_eval(scope, my_ret, ret_type, 0, NULL);
4001 mscope = aml_pushscope(scope, opargs[1], scope->node,
4031 aml_store(scope, opargs[2], ival, NULL);
4036 my_ret = aml_seterror(scope, "Divide by Zero!");
4041 aml_store(scope, opargs[2], ival, NULL);
4045 aml_store(scope, opargs[3], ival, NULL);
4054 aml_store(scope, opargs[1], ival, NULL);
4059 my_ret = aml_eval(scope, opargs[0], AML_ARG_INTEGER, 0, NULL);
4061 aml_store(scope, opargs[0], ival, NULL);
4092 aml_store(scope, opargs[1], 0, rv);
4143 aml_store(scope, opargs[2], ival, my_ret);
4164 aml_store(scope, opargs[1], 0, opargs[0]);
4171 aml_store(scope, opargs[1], 0, my_ret);
4176 aml_store(scope, opargs[1], 0, my_ret);
4181 aml_store(scope, opargs[1], 0, my_ret);
4186 aml_store(scope, opargs[1], 0, my_ret);
4192 aml_store(scope, opargs[2], 0, my_ret);
4197 aml_store(scope, opargs[2], 0, my_ret);
4202 aml_store(scope, opargs[2], 0, my_ret);
4208 aml_store(scope, opargs[3], 0, my_ret);
4231 ival = acpi_mutex_acquire(scope, rv,
4237 acpi_mutex_release(scope, rv);
4242 ival = acpi_event_wait(scope, rv,
4248 acpi_event_reset(scope, rv);
4253 acpi_event_signal(scope, rv);
4299 printf("Undefined scope: %s\n", aml_getname(rv->v_nameref));
4302 mscope = aml_pushscope(scope, opargs[1], rv->node, opcode);
4307 mscope = aml_pushscope(scope, opargs[1], rv->node, opcode);
4312 mscope = aml_pushscope(scope, opargs[1], rv->node, opcode);
4319 mscope = aml_pushscope(scope, opargs[3], rv->node, opcode);
4327 mscope = aml_pushscope(scope, opargs[4], rv->node, opcode);
4377 mscope = aml_pushscope(scope, opargs[2], scope->node, opcode);
4384 mscope = aml_pushscope(scope, opargs[3], scope->node, opcode);
4391 mscope = aml_pushscope(scope, opargs[4], scope->node, opcode);
4434 mscope = aml_load(acpi_softc, scope, opargs[0], opargs[1]);
4446 mscope = aml_pushscope(scope, opargs[1], scope->node,
4450 mscope = aml_pushscope(scope, opargs[3], scope->node,
4457 scope->pos = start;
4458 mscope = aml_pushscope(scope, opargs[1], scope->node,
4464 aml_findscope(scope, AMLOP_WHILE, AMLOP_BREAK);
4468 aml_findscope(scope, AMLOP_WHILE, AMLOP_CONTINUE);
4471 mscope = aml_findscope(scope, AMLOP_METHOD, AMLOP_RETURN);
4485 /* Change our scope to new scope */
4486 scope = mscope;
4512 /* If parsing whole scope and not done, start again */
4514 aml_delref(&my_ret, "scope.loop");
4515 while (scope->pos >= scope->end && scope != iscope) {
4516 /* Pop intermediate scope */
4517 scope = aml_popscope(scope);
4519 if (scope->pos && scope->pos < scope->end)
4524 dnprintf(50, ">>return [%s] %s %c %p\n", aml_nodename(scope->node),
4535 struct aml_scope *scope;
4550 /* Push toplevel scope, parse AML */
4552 scope = aml_pushscope(NULL, &res, &aml_root, AMLOP_SCOPE);
4554 aml_parse(scope, 'T', "TopLevel");
4556 aml_popscope(scope);