Patchwork acpi: method: Add _HPP (Hot Plug Parameters) sanity check

login
register
mail settings
Submitter Colin King
Date Jan. 9, 2013, 10:58 a.m.
Message ID <1357729115-10404-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/210690/
State Accepted
Headers show

Comments

Colin King - Jan. 9, 2013, 10:58 a.m.
From: Colin Ian King <colin.king@canonical.com>

Test return type from _HPP object

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/method/method.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 2 deletions(-)
Keng-Yu Lin - Jan. 23, 2013, 11:50 a.m.
On Wed, Jan 9, 2013 at 6:58 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Test return type from _HPP object
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/method/method.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index fd7aac0..7b35f62 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -115,7 +115,7 @@
>   * _GWS  9.18.5                Y
>   * _HID  6.1.5         Y
>   * _HOT  11.4.6                Y
> - * _HPP  6.2.7         N
> + * _HPP  6.2.7         Y
>   * _HPX  6.2.8         N
>   * _HRV  6.1.6         Y
>   * _IFT  19.5          N
> @@ -1717,6 +1717,54 @@ static int method_test_GSB(fwts_framework *fw)
>                 "_GSB", NULL, 0, method_test_integer_return, NULL);
>  }
>
> +static void method_test_HPP_return(
> +       fwts_framework *fw,
> +       char *name,
> +       ACPI_BUFFER *buf,
> +       ACPI_OBJECT *obj,
> +       void *private)
> +{
> +       uint32_t i;
> +       bool failed = false;
> +
> +       FWTS_UNUSED(private);
> +
> +       if (method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
> +               return;
> +
> +       /* Must be 4 elements in the package */
> +       if (obj->Package.Count != 4) {
> +               fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +                       "Method_HPPElementCount",
> +                       "%s should return a package of 4 elements, "
> +                       "instead got %" PRIu32 " elements.",
> +                       name, obj->Package.Count);
> +               fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
> +               return;
> +       }
> +
> +       /* All 4 elements in the package must be integers */
> +       for (i = 0; i < obj->Package.Count; i++) {
> +               if (obj->Package.Elements[i].Type != ACPI_TYPE_INTEGER) {
> +                       fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +                               "Method_HPPElementType",
> +                               "%s package element %" PRIu32 " was not an integer.",
> +                               name, i);
> +                       fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
> +                       failed = true;
> +               }
> +       }
> +
> +       if (!failed)
> +               method_passed_sane(fw, name, "package");
> +}
> +
> +static int method_test_HPP(fwts_framework *fw)
> +{
> +       return method_evaluate_method(fw, METHOD_OPTIONAL,
> +               "_HPP", NULL, 0, method_test_HPP_return, NULL);
> +}
> +
>  static int method_test_PXM(fwts_framework *fw)
>  {
>         return method_evaluate_method(fw, METHOD_OPTIONAL,
> @@ -4806,7 +4854,7 @@ static fwts_framework_minor_test method_tests[] = {
>         { method_test_DMA, "Check _DMA (Direct Memory Access)." },
>         { method_test_FIX, "Check _FIX (Fixed Register Resource Provider)." },
>         { method_test_GSB, "Check _GSB (Global System Interrupt Base)." },
> -       /* { method_test_HPP, "Check _HPP (Hot Plug Parameters)." }, */
> +       { method_test_HPP, "Check _HPP (Hot Plug Parameters)." },
>         /* { method_test_HPX, "Check _HPX (Hot Plug Extensions)." }, */
>         /* { method_test_MAT, "Check _MAT (Multiple APIC Table Entry)." }, */
>         /* { method_test_PRS, "Check _PRS (Possible Resource Settings)." }, */
> --
> 1.8.0
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - Jan. 31, 2013, 6:41 a.m.
On 01/09/2013 06:58 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Test return type from _HPP object
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/method/method.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++--
>   1 file changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index fd7aac0..7b35f62 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -115,7 +115,7 @@
>    * _GWS  9.18.5		Y
>    * _HID  6.1.5		Y
>    * _HOT  11.4.6		Y
> - * _HPP  6.2.7		N
> + * _HPP  6.2.7		Y
>    * _HPX  6.2.8		N
>    * _HRV  6.1.6		Y
>    * _IFT  19.5		N
> @@ -1717,6 +1717,54 @@ static int method_test_GSB(fwts_framework *fw)
>   		"_GSB", NULL, 0, method_test_integer_return, NULL);
>   }
>
> +static void method_test_HPP_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	uint32_t i;
> +	bool failed = false;
> +
> +	FWTS_UNUSED(private);
> +
> +	if (method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
> +		return;
> +
> +	/* Must be 4 elements in the package */
> +	if (obj->Package.Count != 4) {
> +		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +			"Method_HPPElementCount",
> +			"%s should return a package of 4 elements, "
> +			"instead got %" PRIu32 " elements.",
> +			name, obj->Package.Count);
> +		fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
> +		return;
> +	}
> +
> +	/* All 4 elements in the package must be integers */
> +	for (i = 0; i < obj->Package.Count; i++) {
> +		if (obj->Package.Elements[i].Type != ACPI_TYPE_INTEGER) {
> +			fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +				"Method_HPPElementType",
> +				"%s package element %" PRIu32 " was not an integer.",
> +				name, i);
> +			fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
> +			failed = true;
> +		}
> +	}
> +
> +	if (!failed)
> +		method_passed_sane(fw, name, "package");
> +}
> +
> +static int method_test_HPP(fwts_framework *fw)
> +{
> +	return method_evaluate_method(fw, METHOD_OPTIONAL,
> +		"_HPP", NULL, 0, method_test_HPP_return, NULL);
> +}
> +
>   static int method_test_PXM(fwts_framework *fw)
>   {
>   	return method_evaluate_method(fw, METHOD_OPTIONAL,
> @@ -4806,7 +4854,7 @@ static fwts_framework_minor_test method_tests[] = {
>   	{ method_test_DMA, "Check _DMA (Direct Memory Access)." },
>   	{ method_test_FIX, "Check _FIX (Fixed Register Resource Provider)." },
>   	{ method_test_GSB, "Check _GSB (Global System Interrupt Base)." },
> -	/* { method_test_HPP, "Check _HPP (Hot Plug Parameters)." }, */
> +	{ method_test_HPP, "Check _HPP (Hot Plug Parameters)." },
>   	/* { method_test_HPX, "Check _HPX (Hot Plug Extensions)." }, */
>   	/* { method_test_MAT, "Check _MAT (Multiple APIC Table Entry)." }, */
>   	/* { method_test_PRS, "Check _PRS (Possible Resource Settings)." }, */
>
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index fd7aac0..7b35f62 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -115,7 +115,7 @@ 
  * _GWS  9.18.5		Y
  * _HID  6.1.5		Y
  * _HOT  11.4.6		Y
- * _HPP  6.2.7		N
+ * _HPP  6.2.7		Y
  * _HPX  6.2.8		N
  * _HRV  6.1.6		Y
  * _IFT  19.5		N
@@ -1717,6 +1717,54 @@  static int method_test_GSB(fwts_framework *fw)
 		"_GSB", NULL, 0, method_test_integer_return, NULL);
 }
 
+static void method_test_HPP_return(
+	fwts_framework *fw,
+	char *name,
+	ACPI_BUFFER *buf,
+	ACPI_OBJECT *obj,
+	void *private)
+{
+	uint32_t i;
+	bool failed = false;
+
+	FWTS_UNUSED(private);
+
+	if (method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
+		return;
+
+	/* Must be 4 elements in the package */
+	if (obj->Package.Count != 4) {
+		fwts_failed(fw, LOG_LEVEL_MEDIUM,
+			"Method_HPPElementCount",
+			"%s should return a package of 4 elements, "
+			"instead got %" PRIu32 " elements.",
+			name, obj->Package.Count);
+		fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
+		return;
+	}
+
+	/* All 4 elements in the package must be integers */
+	for (i = 0; i < obj->Package.Count; i++) {
+		if (obj->Package.Elements[i].Type != ACPI_TYPE_INTEGER) {
+			fwts_failed(fw, LOG_LEVEL_MEDIUM,
+				"Method_HPPElementType",
+				"%s package element %" PRIu32 " was not an integer.",
+				name, i);
+			fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
+			failed = true;
+		}
+	}
+
+	if (!failed)
+		method_passed_sane(fw, name, "package");
+}
+
+static int method_test_HPP(fwts_framework *fw)
+{
+	return method_evaluate_method(fw, METHOD_OPTIONAL,
+		"_HPP", NULL, 0, method_test_HPP_return, NULL);
+}
+
 static int method_test_PXM(fwts_framework *fw)
 {
 	return method_evaluate_method(fw, METHOD_OPTIONAL,
@@ -4806,7 +4854,7 @@  static fwts_framework_minor_test method_tests[] = {
 	{ method_test_DMA, "Check _DMA (Direct Memory Access)." },
 	{ method_test_FIX, "Check _FIX (Fixed Register Resource Provider)." },
 	{ method_test_GSB, "Check _GSB (Global System Interrupt Base)." },
-	/* { method_test_HPP, "Check _HPP (Hot Plug Parameters)." }, */
+	{ method_test_HPP, "Check _HPP (Hot Plug Parameters)." },
 	/* { method_test_HPX, "Check _HPX (Hot Plug Extensions)." }, */
 	/* { method_test_MAT, "Check _MAT (Multiple APIC Table Entry)." }, */
 	/* { method_test_PRS, "Check _PRS (Possible Resource Settings)." }, */