[PATCH 1/2] fwts_acpi_object_eval: add a function to check package elements
Alex Hung
alex.hung at canonical.com
Mon May 25 08:45:34 UTC 2020
On Mon, May 25, 2020 at 2:01 AM ivanhu <ivan.hu at canonical.com> wrote:
>
>
> On 5/22/20 12:47 PM, Alex Hung wrote:
> >
> >
> > On Thu, May 21, 2020 at 9:01 PM ivanhu <ivan.hu at canonical.com
> > <mailto:ivan.hu at canonical.com>> wrote:
> >
> >
> >
> > On 5/16/20 2:00 AM, Alex Hung wrote:
> > > This function checks if all elements are integers in a returned
> > package.
> > > This is one of common forms returned by ACPI methods.
> > >
> > > Signed-off-by: Alex Hung <alex.hung at canonical.com
> > <mailto:alex.hung at canonical.com>>
> > > ---
> > > src/lib/include/fwts_acpi_object_eval.h | 1 +
> > > src/lib/src/fwts_acpi_object_eval.c | 28
> > +++++++++++++++++++++++++
> > > 2 files changed, 29 insertions(+)
> > >
> > > diff --git a/src/lib/include/fwts_acpi_object_eval.h
> > b/src/lib/include/fwts_acpi_object_eval.h
> > > index 09f3f754..92177857 100644
> > > --- a/src/lib/include/fwts_acpi_object_eval.h
> > > +++ b/src/lib/include/fwts_acpi_object_eval.h
> > > @@ -128,6 +128,7 @@ void
> > fwts_method_test_buffer_return(fwts_framework *fw, char *name,
> > ACPI_BUFFER
> > > void fwts_method_test_all_reference_package_return(fwts_framework
> > *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > > void fwts_method_test_integer_reserved_bits_return(fwts_framework
> > *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > > void fwts_method_test_integer_max_return(fwts_framework *fw, char
> > *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > > +void fwts_method_test_package_integer_return(fwts_framework *fw,
> > char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > > void fwts_method_test_passed_failed_return(fwts_framework *fw,
> > char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > > void fwts_method_test_polling_return( fwts_framework *fw, char
> > *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> > >
> > > diff --git a/src/lib/src/fwts_acpi_object_eval.c
> > b/src/lib/src/fwts_acpi_object_eval.c
> > > index 1e3575c9..613a6fd3 100644
> > > --- a/src/lib/src/fwts_acpi_object_eval.c
> > > +++ b/src/lib/src/fwts_acpi_object_eval.c
> > > @@ -881,6 +881,34 @@ void fwts_method_test_integer_max_return(
> > > fwts_passed(fw, "%s correctly returned an integer.",
> > name);
> > > }
> > >
> > > +/*
> > > + * fwts_method_test_package_integer_return
> > > + * check if all integers in a returned package
> > > + */
> > > +void fwts_method_test_package_integer_return(
> > > + fwts_framework *fw,
> > > + char *name,
> > > + ACPI_BUFFER *buf,
> > > + ACPI_OBJECT *obj,
> > > + void *private)
> > > +{
> > > + char method[4];
> >
> > Should this be method[5], include the null-terminated?
> >
> >
> > It seems ACPI names aren't exactly strings. I checked acpica code and it
> > uses 4 chars like below:
> >
> /*******************************************************************************
> > *
> > * FUNCTION: AcpiDmDumpName
> > *
> > * PARAMETERS: Name - 4 character ACPI name
> > *
> > * RETURN: Final length of name
> > *
> > * DESCRIPTION: Dump an ACPI name, minus any trailing underscores.
> > *
> >
> ******************************************************************************/
> >
> > UINT32
> > AcpiDmDumpName (
> > UINT32 Name)
> > {
> > UINT32 i;
> > UINT32 Length;
> > char NewName[4];
> >
> > // ... skipped
> >
> > In other cases, it can also use 5 chars like "AcpiName" variable in the
> > function "AcpiDbFindNameInNamespace" (although its parameter takes a
> > 4-char string)
> >
> > I think both would work when passing to AML parser.
> >
> >
> OK. but I think we should make sure if those non null-terminated string
> have any potential issue, since they will be passed to the result log
> functions.
>
V2 was sent for reviews.
>
> >
> >
> > > + uint32_t *element_size = (uint32_t *) private;
> > > +
> > > + memcpy(method, &name[strlen(name) - 4], 4);
> > > +
> > > + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE)
> > != FWTS_OK)
> > > + return;
> > > +
> > > + if (fwts_method_package_count_equal(fw, name, method, obj,
> > *element_size) != FWTS_OK)
> > > + return;
> > > +
> > > + if (fwts_method_package_elements_all_type(fw, name, method,
> > obj, ACPI_TYPE_INTEGER) != FWTS_OK)
> > > + return;
> > > +
> > > + fwts_method_passed_sane(fw, name, "package");
> > > +}
> > > +
> > > /*
> > > * fwts_method_test_passed_failed_return
> > > * check if 0 or 1 (false/true) integer is returned
> > >
> >
> > --
> > fwts-devel mailing list
> > fwts-devel at lists.ubuntu.com <mailto:fwts-devel at lists.ubuntu.com>
> > Modify settings or unsubscribe at:
> > https://lists.ubuntu.com/mailman/listinfo/fwts-devel
> >
> >
> >
> > --
> > Cheers,
> > Alex Hung
>
--
Cheers,
Alex Hung
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20200525/1d1d5960/attachment.html>
More information about the fwts-devel
mailing list