mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-26 07:17:10 +00:00
acpi: Support generation of a scope
Add a function to write a scope to the generated ACPI code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: Fix build failures on Sandbox] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
fea9651084
commit
82659cc910
5 changed files with 51 additions and 2 deletions
|
@ -31,6 +31,7 @@ enum {
|
||||||
DWORD_PREFIX = 0x0c,
|
DWORD_PREFIX = 0x0c,
|
||||||
STRING_PREFIX = 0x0d,
|
STRING_PREFIX = 0x0d,
|
||||||
QWORD_PREFIX = 0x0e,
|
QWORD_PREFIX = 0x0e,
|
||||||
|
SCOPE_OP = 0x10,
|
||||||
BUFFER_OP = 0x11,
|
BUFFER_OP = 0x11,
|
||||||
PACKAGE_OP = 0x12,
|
PACKAGE_OP = 0x12,
|
||||||
METHOD_OP = 0x14,
|
METHOD_OP = 0x14,
|
||||||
|
@ -261,6 +262,14 @@ void acpigen_emit_namestring(struct acpi_ctx *ctx, const char *namepath);
|
||||||
*/
|
*/
|
||||||
void acpigen_write_name(struct acpi_ctx *ctx, const char *namepath);
|
void acpigen_write_name(struct acpi_ctx *ctx, const char *namepath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* acpigen_write_scope() - Write a scope
|
||||||
|
*
|
||||||
|
* @ctx: ACPI context pointer
|
||||||
|
* @scope: Scope to write (e.g. "\\_SB.ABCD")
|
||||||
|
*/
|
||||||
|
void acpigen_write_scope(struct acpi_ctx *ctx, const char *scope);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpigen_write_uuid() - Write a UUID
|
* acpigen_write_uuid() - Write a UUID
|
||||||
*
|
*
|
||||||
|
|
|
@ -258,6 +258,13 @@ void acpigen_write_name(struct acpi_ctx *ctx, const char *namepath)
|
||||||
acpigen_emit_namestring(ctx, namepath);
|
acpigen_emit_namestring(ctx, namepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void acpigen_write_scope(struct acpi_ctx *ctx, const char *scope)
|
||||||
|
{
|
||||||
|
acpigen_emit_byte(ctx, SCOPE_OP);
|
||||||
|
acpigen_write_len_f(ctx);
|
||||||
|
acpigen_emit_namestring(ctx, scope);
|
||||||
|
}
|
||||||
|
|
||||||
static void acpigen_write_method_internal(struct acpi_ctx *ctx,
|
static void acpigen_write_method_internal(struct acpi_ctx *ctx,
|
||||||
const char *name, uint flags)
|
const char *name, uint flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
#include <dm/acpi.h>
|
#include <dm/acpi.h>
|
||||||
#include <dm/test.h>
|
#include <dm/test.h>
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
#include "acpi.h"
|
||||||
|
|
||||||
#define ACPI_TEST_DEV_NAME "ABCD"
|
|
||||||
#define ACPI_TEST_CHILD_NAME "EFGH"
|
|
||||||
#define BUF_SIZE 4096
|
#define BUF_SIZE 4096
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#ifndef __TEST_DM_ACPI_H
|
#ifndef __TEST_DM_ACPI_H
|
||||||
#define __TEST_DM_ACPI_H
|
#define __TEST_DM_ACPI_H
|
||||||
|
|
||||||
|
#define ACPI_TEST_DEV_NAME "ABCD"
|
||||||
|
#define ACPI_TEST_CHILD_NAME "EFGH"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpi_test_alloc_context_size() - Allocate an ACPI context of a given size
|
* acpi_test_alloc_context_size() - Allocate an ACPI context of a given size
|
||||||
*
|
*
|
||||||
|
|
|
@ -916,3 +916,34 @@ static int dm_test_acpi_write_values(struct unit_test_state *uts)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DM_TEST(dm_test_acpi_write_values, 0);
|
DM_TEST(dm_test_acpi_write_values, 0);
|
||||||
|
|
||||||
|
/* Test writing a scope */
|
||||||
|
static int dm_test_acpi_scope(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
char buf[ACPI_PATH_MAX];
|
||||||
|
struct acpi_ctx *ctx;
|
||||||
|
struct udevice *dev;
|
||||||
|
u8 *ptr;
|
||||||
|
|
||||||
|
ut_assertok(alloc_context(&ctx));
|
||||||
|
ptr = acpigen_get_current(ctx);
|
||||||
|
|
||||||
|
ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
|
||||||
|
ut_assertok(acpi_device_path(dev, buf, sizeof(buf)));
|
||||||
|
acpigen_write_scope(ctx, buf);
|
||||||
|
acpigen_pop_len(ctx);
|
||||||
|
|
||||||
|
ut_asserteq(SCOPE_OP, *ptr++);
|
||||||
|
ut_asserteq(13, acpi_test_get_length(ptr));
|
||||||
|
ptr += 3;
|
||||||
|
ut_asserteq(ROOT_PREFIX, *ptr++);
|
||||||
|
ut_asserteq(DUAL_NAME_PREFIX, *ptr++);
|
||||||
|
ut_asserteq_strn("_SB_" ACPI_TEST_DEV_NAME, (char *)ptr);
|
||||||
|
ptr += 8;
|
||||||
|
ut_asserteq_ptr(ptr, ctx->current);
|
||||||
|
|
||||||
|
free_context(&ctx);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DM_TEST(dm_test_acpi_scope, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||||
|
|
Loading…
Add table
Reference in a new issue