On Fri, May 18, 2018 at 08:53:41PM +0200, Mark Kettenis wrote:
> Turns out there is an alternate way to encode
> AttribBytes/AttribRawBytes (and AttribRawProcessBytes) that I didn't
> implement.  In fact our parsing of fields has always been wrong when
> this alternative encoding is present.  But for some reason we lucked
> out the parser didn't go fully off the rails.
> 
> Diff below fixes this issue and makes the battery status on my Asus
> Transformerr Book T100HA work.
> 
> ok?
> 

See below...

-ml

> 
> Index: dev/acpi/dsdt.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
> retrieving revision 1.238
> diff -u -p -r1.238 dsdt.c
> --- dev/acpi/dsdt.c   17 May 2018 20:21:15 -0000      1.238
> +++ dev/acpi/dsdt.c   18 May 2018 18:51:36 -0000
> @@ -2293,7 +2293,7 @@ aml_register_regionspace(struct aml_node
>  
>  void aml_rwgen(struct aml_value *, int, int, struct aml_value *, int, int);
>  void aml_rwgpio(struct aml_value *, int, int, struct aml_value *, int, int);
> -void aml_rwgsb(struct aml_value *, int, int, struct aml_value *, int, int);
> +void aml_rwgsb(struct aml_value *, int, int, int, struct aml_value *, int, 
> int);
>  void aml_rwindexfield(struct aml_value *, struct aml_value *val, int);
>  void aml_rwfield(struct aml_value *, int, int, struct aml_value *, int);
>  
> @@ -2518,8 +2518,8 @@ aml_rwgpio(struct aml_value *conn, int b
>  }
>  
>  void
> -aml_rwgsb(struct aml_value *conn, int bpos, int blen, struct aml_value *val,
> -    int mode, int flag)
> +aml_rwgsb(struct aml_value *conn, int alen, int bpos, int blen,
> +    struct aml_value *val, int mode, int flag)
>  {
>       union acpi_resource *crs = (union acpi_resource *)conn->v_buffer;
>       struct aml_node *node;
> @@ -2564,6 +2564,14 @@ aml_rwgsb(struct aml_value *conn, int bp
>                       cmdlen = 1;
>                       buflen = 2;
>                       break;
> +             case 0x0b:      /* AttribBytes */
> +                     cmdlen = 1;
> +                     buflen = alen;
> +                     break;
> +             case 0x0e:      /* AttribRawBytes */
> +                     cmdlen = 1;
> +                     cmdlen = alen;

The previous two lines don't look right...

> +                     break;
>               default:
>                       aml_die("unsupported access type 0x%x", flag);
>                       break;
> @@ -2709,7 +2717,8 @@ aml_rwfield(struct aml_value *fld, int b
>                           fld->v_field.flags);
>                       break;
>               case ACPI_OPREG_GSB:
> -                     aml_rwgsb(ref2, fld->v_field.bitpos + bpos, blen,
> +                     aml_rwgsb(ref2, fld->v_field.ref3,
> +                         fld->v_field.bitpos + bpos, blen,
>                           val, mode, fld->v_field.flags);
>                       break;
>               default:
> @@ -2795,17 +2804,17 @@ aml_parsefieldlist(struct aml_scope *msc
>       bpos = 0;
>       while (mscope->pos < mscope->end) {
>               switch (*mscope->pos) {
> -             case 0x00: /* reserved, length */
> +             case 0x00: /* ReservedField */
>                       mscope->pos++;
>                       blen = aml_parselength(mscope);
>                       break;
> -             case 0x01: /* attrib */
> +             case 0x01: /* AccessField */
>                       mscope->pos++;
>                       blen = 0;
>                       flags = aml_get8(mscope->pos++);
>                       flags |= aml_get8(mscope->pos++) << 8;
>                       break;
> -             case 0x02: /* connection */
> +             case 0x02: /* ConnectionField */
>                       mscope->pos++;
>                       blen = 0;
>                       conn = aml_parse(mscope, 'o', "Connection");
> @@ -2813,7 +2822,14 @@ aml_parsefieldlist(struct aml_scope *msc
>                               aml_die("Could not parse connection");
>                       conn->node = mscope->node;
>                       break;
> -             default: /* 4-byte name, length */
> +             case 0x03: /* ExtendedAccessField */
> +                     mscope->pos++;
> +                     blen = 0;
> +                     flags = aml_get8(mscope->pos++);
> +                     flags |= aml_get8(mscope->pos++) << 8;
> +                     indexval = aml_get8(mscope->pos++);
> +                     break;
> +             default: /* NamedField */
>                       mscope->pos = aml_parsename(mscope->node, mscope->pos,
>                           &rv, 1);
>                       blen = aml_parselength(mscope);
> 

Reply via email to