Lines Matching refs:scope

759 aml_lockfield(struct aml_scope *scope, struct aml_value *field)
768 aml_unlockfield(struct aml_scope *scope, struct aml_value *field)
1278 uint8_t *aml_parseend(struct aml_scope *scope);
1284 aml_parseopcode(struct aml_scope *scope)
1286 int opcode = (scope->pos[0]);
1287 int twocode = (scope->pos[0]<<8) + scope->pos[1];
1302 scope->pos += 2;
1305 scope->pos += 1;
1383 aml_parselength(struct aml_scope *scope)
1388 lcode = *(scope->pos++);
1394 len += *(scope->pos++) << 4L;
1396 len += *(scope->pos++) << 12L;
1398 len += *(scope->pos++) << 20L;
1402 /* Get address of end of scope; based on current address */
1404 aml_parseend(struct aml_scope *scope)
1406 uint8_t *pos = scope->pos;
1409 len = aml_parselength(scope);
1410 if (pos+len > scope->end) {
1412 "Bad scope... runover pos:%.4x new end:%.4x scope "
1414 aml_pc(scope->end));
1415 return scope->end;
1486 aml_callosi(struct aml_scope *scope, struct aml_value *val)
1491 fa = aml_getstack(scope, AMLOP_ARG0);
1801 aml_findscope(struct aml_scope *scope, int type, int endscope)
1803 while (scope) {
1806 scope->pos = scope->end;
1807 if (scope->type == AMLOP_WHILE)
1808 scope->pos = NULL;
1811 scope->pos = scope->end;
1814 scope->pos = scope->end;
1815 if (scope->type == type)
1816 scope->parent->pos = scope->end;
1819 if (scope->type == type)
1821 scope = scope->parent;
1823 return scope;
1827 aml_getstack(struct aml_scope *scope, int opcode)
1832 scope = aml_findscope(scope, AMLOP_METHOD, 0);
1833 if (scope == NULL)
1836 if (scope->locals == NULL)
1837 scope->locals = aml_allocvalue(AML_OBJTYPE_PACKAGE, 8, NULL);
1838 sp = scope->locals->v_package[opcode - AMLOP_LOCAL0];
1841 if (scope->args == NULL)
1842 scope->args = aml_allocvalue(AML_OBJTYPE_PACKAGE, 7, NULL);
1843 sp = scope->args->v_package[opcode - AMLOP_ARG0];
1853 aml_showstack(struct aml_scope *scope)
1858 dnprintf(10, "===== Stack %s:%s\n", aml_nodename(scope->node),
1859 aml_mnem(scope->type, 0));
1860 for (idx=0; scope->args && idx<7; idx++) {
1861 sp = aml_getstack(scope, AMLOP_ARG0+idx);
1867 for (idx=0; scope->locals && idx<8; idx++) {
1868 sp = aml_getstack(scope, AMLOP_LOCAL0+idx);
1877 /* Create a new scope object */
1882 struct aml_scope *scope;
1894 scope = acpi_os_malloc(sizeof(struct aml_scope));
1895 if (scope == NULL)
1898 scope->node = node;
1899 scope->start = start;
1900 scope->end = end;
1901 scope->pos = scope->start;
1902 scope->parent = parent;
1903 scope->type = type;
1904 scope->sc = acpi_softc;
1907 scope->depth = parent->depth+1;
1909 aml_lastscope = scope;
1911 return scope;
1914 /* Free a scope object and any children */
1916 aml_popscope(struct aml_scope *scope)
1920 if (scope == NULL)
1923 nscope = scope->parent;
1925 if (scope->type == AMLOP_METHOD)
1926 aml_delchildren(scope->node);
1927 if (scope->locals) {
1928 aml_freevalue(scope->locals);
1929 acpi_os_free(scope->locals);
1930 scope->locals = NULL;
1932 if (scope->args) {
1933 aml_freevalue(scope->args);
1934 acpi_os_free(scope->args);
1935 scope->args = NULL;
1937 acpi_os_free(scope);
2857 /* Parse Field/IndexField/BankField scope */
2920 acpi_mutex_acquire(struct aml_scope *scope, struct aml_value *mtx,
2923 if (mtx->v_mtx.owner == NULL || scope == mtx->v_mtx.owner) {
2925 mtx->v_mtx.owner = scope;
2930 dnprintf(5,"%s acquires mutex %s\n", scope->node->name,
2941 acpi_mutex_release(struct aml_scope *scope, struct aml_value *mtx)
2947 dnprintf(5, "%s releases mutex %s\n", scope->node->name,
2954 acpi_event_wait(struct aml_scope *scope, struct aml_value *evt, int timeout)
2979 acpi_event_signal(struct aml_scope *scope, struct aml_value *evt)
2987 acpi_event_reset(struct aml_scope *scope, struct aml_value *evt)
2994 aml_store(struct aml_scope *scope, struct aml_value *lhs , int64_t ival,
3062 node = __aml_searchname(scope->node,
3100 aml_disasm(struct aml_scope *scope, int lvl,
3117 pc = aml_pc(scope->pos);
3118 opcode = aml_parseopcode(scope);
3131 scope->pos = aml_parsename(scope->node, scope->pos, &rv, 0);
3298 end = aml_parseend(scope);
3302 end = aml_parseend(scope);
3306 end = aml_parseend(scope);
3310 end = aml_parseend(scope);
3314 end = aml_parseend(scope);
3318 end = aml_parseend(scope);
3322 end = aml_parseend(scope);
3326 end = aml_parseend(scope);
3330 end = aml_parseend(scope);
3334 end = aml_parseend(scope);
3338 end = aml_parseend(scope);
3367 aml_parsesimple(scope, c, &tmp);
3371 dbprintf(arg, "\'%s\'", scope->pos);
3372 scope->pos += strlen(scope->pos)+1;
3376 rv = aml_parsesimple(scope, c, NULL);
3385 printf("%s", aml_getname(scope->pos));
3386 scope->pos = aml_parsename(scope->node, scope->pos,
3393 aml_disasm(scope, lvl | 0x8000, dbprintf, arg);
3397 scope->pos = end;
3402 ms.node = scope->node;
3403 ms.start = scope->pos;
3425 dbprintf(arg,"%.4x ", aml_pc(scope->pos));
3429 scope->pos = end;
3434 ms.node = scope->node;
3435 ms.start = scope->pos;
3446 dbprintf(arg,"%.4x ", aml_pc(scope->pos));
3450 scope->pos = end;
3465 aml_eval(struct aml_scope *scope, struct aml_value *my_ret, int ret_type,
3474 my_ret = aml_seterror(scope, "Undefined name: %s",
3482 ms = aml_pushscope(scope, tmp, tmp->node, AMLOP_METHOD);
3493 sp->v_objref.ref = aml_parse(scope, 't', "ARGX");
3500 /* Evaluate method scope */
3643 aml_parsesimple(struct aml_scope *scope, char ch, struct aml_value *rv)
3656 aml_get8(scope->pos), NULL);
3657 scope->pos += 1;
3661 aml_get16(scope->pos), NULL);
3662 scope->pos += 2;
3666 aml_get32(scope->pos), NULL);
3667 scope->pos += 4;
3671 aml_get64(scope->pos), NULL);
3672 scope->pos += 8;
3675 _aml_setvalue(rv, AML_OBJTYPE_STRING, -1, scope->pos);
3676 scope->pos += rv->length+1;
3707 aml_seterror(struct aml_scope *scope, const char *fmt, ...)
3712 printf("### AML PARSE ERROR (0x%x): ", aml_pc(scope->pos));
3717 while (scope) {
3718 scope->pos = scope->end;
3719 scope = scope->parent;
3754 /* Load new SSDT scope from memory address */
3756 aml_load(struct acpi_softc *sc, struct aml_scope *scope,
3784 return aml_pushscope(scope, &tmp, scope->node,
3793 aml_parse(struct aml_scope *scope, int ret_type, const char *stype)
3805 if (scope == NULL || scope->pos >= scope->end) {
3815 iscope = scope;
3818 start = scope->pos;
3819 pc = aml_pc(scope->pos);
3820 aml_debugger(scope);
3822 opcode = aml_parseopcode(scope);
3828 dnprintf(18,"%.4x %s\n", pc, aml_mnem(opcode, scope->pos));
3837 end = aml_parseend(scope);
3841 ch = (*end == AMLOP_ELSE && end < scope->end) ?
3851 if (*ch == 'r' && *scope->pos == AMLOP_ZERO) {
3854 scope->pos++;
3857 rv = aml_parse(scope, *ch, htab->mnem);
3869 rv->v_buffer = scope->pos;
3870 rv->length = end - scope->pos;
3871 scope->pos = end;
3878 scope->pos = aml_parsename(scope->node, scope->pos,
3882 scope->pos = aml_parsename(scope->node, scope->pos,
3892 rv = aml_parsesimple(scope, *ch, NULL);
3896 rv = aml_getstack(scope, opcode);
3935 if (scope->type == AMLOP_PACKAGE && my_ret->node) {
3947 my_ret = aml_eval(scope, my_ret, ret_type, 0, NULL);
3980 mscope = aml_pushscope(scope, opargs[1], scope->node,
4010 aml_store(scope, opargs[2], ival, NULL);
4015 my_ret = aml_seterror(scope, "Divide by Zero!");
4020 aml_store(scope, opargs[2], ival, NULL);
4024 aml_store(scope, opargs[3], ival, NULL);
4033 aml_store(scope, opargs[1], ival, NULL);
4038 my_ret = aml_eval(scope, opargs[0], AML_ARG_INTEGER, 0, NULL);
4040 aml_store(scope, opargs[0], ival, NULL);
4071 aml_store(scope, opargs[1], 0, rv);
4122 aml_store(scope, opargs[2], ival, my_ret);
4143 aml_store(scope, opargs[1], 0, opargs[0]);
4150 aml_store(scope, opargs[1], 0, my_ret);
4155 aml_store(scope, opargs[1], 0, my_ret);
4160 aml_store(scope, opargs[1], 0, my_ret);
4165 aml_store(scope, opargs[1], 0, my_ret);
4171 aml_store(scope, opargs[2], 0, my_ret);
4176 aml_store(scope, opargs[2], 0, my_ret);
4181 aml_store(scope, opargs[2], 0, my_ret);
4187 aml_store(scope, opargs[3], 0, my_ret);
4210 ival = acpi_mutex_acquire(scope, rv,
4216 acpi_mutex_release(scope, rv);
4221 ival = acpi_event_wait(scope, rv,
4227 acpi_event_reset(scope, rv);
4232 acpi_event_signal(scope, rv);
4278 printf("Undefined scope: %s\n", aml_getname(rv->v_nameref));
4281 mscope = aml_pushscope(scope, opargs[1], rv->node, opcode);
4286 mscope = aml_pushscope(scope, opargs[1], rv->node, opcode);
4291 mscope = aml_pushscope(scope, opargs[1], rv->node, opcode);
4298 mscope = aml_pushscope(scope, opargs[3], rv->node, opcode);
4306 mscope = aml_pushscope(scope, opargs[4], rv->node, opcode);
4356 mscope = aml_pushscope(scope, opargs[2], scope->node, opcode);
4363 mscope = aml_pushscope(scope, opargs[3], scope->node, opcode);
4370 mscope = aml_pushscope(scope, opargs[4], scope->node, opcode);
4413 mscope = aml_load(acpi_softc, scope, opargs[0], opargs[1]);
4425 mscope = aml_pushscope(scope, opargs[1], scope->node,
4429 mscope = aml_pushscope(scope, opargs[3], scope->node,
4436 scope->pos = start;
4437 mscope = aml_pushscope(scope, opargs[1], scope->node,
4443 aml_findscope(scope, AMLOP_WHILE, AMLOP_BREAK);
4447 aml_findscope(scope, AMLOP_WHILE, AMLOP_CONTINUE);
4450 mscope = aml_findscope(scope, AMLOP_METHOD, AMLOP_RETURN);
4464 /* Change our scope to new scope */
4465 scope = mscope;
4491 /* If parsing whole scope and not done, start again */
4493 aml_delref(&my_ret, "scope.loop");
4494 while (scope->pos >= scope->end && scope != iscope) {
4495 /* Pop intermediate scope */
4496 scope = aml_popscope(scope);
4498 if (scope->pos && scope->pos < scope->end)
4503 dnprintf(50, ">>return [%s] %s %c %p\n", aml_nodename(scope->node),
4514 struct aml_scope *scope;
4529 /* Push toplevel scope, parse AML */
4531 scope = aml_pushscope(NULL, &res, &aml_root, AMLOP_SCOPE);
4533 aml_parse(scope, 'T', "TopLevel");
4535 aml_popscope(scope);