]> Git Repo - J-u-boot.git/blame - lib/acpi/acpigen.c
acpi: Support generation of SPI descriptor
[J-u-boot.git] / lib / acpi / acpigen.c
CommitLineData
61cc9339
SG
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Generation of ACPI (Advanced Configuration and Power Interface) tables
4 *
5 * Copyright 2019 Google LLC
6 * Mostly taken from coreboot
7 */
8
9#define LOG_CATEGORY LOGC_ACPI
10
11#include <common.h>
12#include <dm.h>
13#include <acpi/acpigen.h>
14#include <dm/acpi.h>
15
16u8 *acpigen_get_current(struct acpi_ctx *ctx)
17{
18 return ctx->current;
19}
20
21void acpigen_emit_byte(struct acpi_ctx *ctx, uint data)
22{
23 *(u8 *)ctx->current++ = data;
24}
25
26void acpigen_emit_word(struct acpi_ctx *ctx, uint data)
27{
28 acpigen_emit_byte(ctx, data & 0xff);
29 acpigen_emit_byte(ctx, (data >> 8) & 0xff);
30}
31
32void acpigen_emit_dword(struct acpi_ctx *ctx, uint data)
33{
34 /* Output the value in little-endian format */
35 acpigen_emit_byte(ctx, data & 0xff);
36 acpigen_emit_byte(ctx, (data >> 8) & 0xff);
37 acpigen_emit_byte(ctx, (data >> 16) & 0xff);
38 acpigen_emit_byte(ctx, (data >> 24) & 0xff);
39}
7fb8da4c
SG
40
41void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size)
42{
43 int i;
44
45 for (i = 0; i < size; i++)
46 acpigen_emit_byte(ctx, data[i]);
47}
48
49void acpigen_emit_string(struct acpi_ctx *ctx, const char *str)
50{
51 acpigen_emit_stream(ctx, str, str ? strlen(str) : 0);
52 acpigen_emit_byte(ctx, '\0');
53}
This page took 0.028218 seconds and 4 git commands to generate.