mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-30 00:21:06 +00:00
fa287b1580
This patch adds the ability to load and link ACPI tables provided by QEMU. QEMU tells guests how to load and patch ACPI tables through its fw_cfg interface, by adding a firmware file 'etc/table-loader'. Guests are supposed to parse this file and execute corresponding QEMU commands. Signed-off-by: Miao Yan <yanmiaobest@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
157 lines
3.6 KiB
C
157 lines
3.6 KiB
C
/*
|
|
* (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#ifndef __FW_CFG__
|
|
#define __FW_CFG__
|
|
|
|
#define FW_CONTROL_PORT 0x510
|
|
#define FW_DATA_PORT 0x511
|
|
#define FW_DMA_PORT_LOW 0x514
|
|
#define FW_DMA_PORT_HIGH 0x518
|
|
|
|
#include <linux/list.h>
|
|
|
|
enum qemu_fwcfg_items {
|
|
FW_CFG_SIGNATURE = 0x00,
|
|
FW_CFG_ID = 0x01,
|
|
FW_CFG_UUID = 0x02,
|
|
FW_CFG_RAM_SIZE = 0x03,
|
|
FW_CFG_NOGRAPHIC = 0x04,
|
|
FW_CFG_NB_CPUS = 0x05,
|
|
FW_CFG_MACHINE_ID = 0x06,
|
|
FW_CFG_KERNEL_ADDR = 0x07,
|
|
FW_CFG_KERNEL_SIZE = 0x08,
|
|
FW_CFG_KERNEL_CMDLINE = 0x09,
|
|
FW_CFG_INITRD_ADDR = 0x0a,
|
|
FW_CFG_INITRD_SIZE = 0x0b,
|
|
FW_CFG_BOOT_DEVICE = 0x0c,
|
|
FW_CFG_NUMA = 0x0d,
|
|
FW_CFG_BOOT_MENU = 0x0e,
|
|
FW_CFG_MAX_CPUS = 0x0f,
|
|
FW_CFG_KERNEL_ENTRY = 0x10,
|
|
FW_CFG_KERNEL_DATA = 0x11,
|
|
FW_CFG_INITRD_DATA = 0x12,
|
|
FW_CFG_CMDLINE_ADDR = 0x13,
|
|
FW_CFG_CMDLINE_SIZE = 0x14,
|
|
FW_CFG_CMDLINE_DATA = 0x15,
|
|
FW_CFG_SETUP_ADDR = 0x16,
|
|
FW_CFG_SETUP_SIZE = 0x17,
|
|
FW_CFG_SETUP_DATA = 0x18,
|
|
FW_CFG_FILE_DIR = 0x19,
|
|
FW_CFG_FILE_FIRST = 0x20,
|
|
FW_CFG_WRITE_CHANNEL = 0x4000,
|
|
FW_CFG_ARCH_LOCAL = 0x8000,
|
|
FW_CFG_INVALID = 0xffff,
|
|
};
|
|
|
|
enum {
|
|
BIOS_LINKER_LOADER_COMMAND_ALLOCATE = 0x1,
|
|
BIOS_LINKER_LOADER_COMMAND_ADD_POINTER = 0x2,
|
|
BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM = 0x3,
|
|
};
|
|
|
|
enum {
|
|
BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH = 0x1,
|
|
BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG = 0x2,
|
|
};
|
|
|
|
#define FW_CFG_FILE_SLOTS 0x10
|
|
#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST + FW_CFG_FILE_SLOTS)
|
|
#define FW_CFG_ENTRY_MASK ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)
|
|
|
|
#define FW_CFG_MAX_FILE_PATH 56
|
|
#define BIOS_LINKER_LOADER_FILESZ FW_CFG_MAX_FILE_PATH
|
|
|
|
#define QEMU_FW_CFG_SIGNATURE (('Q' << 24) | ('E' << 16) | ('M' << 8) | 'U')
|
|
|
|
#define FW_CFG_DMA_ERROR (1 << 0)
|
|
#define FW_CFG_DMA_READ (1 << 1)
|
|
#define FW_CFG_DMA_SKIP (1 << 2)
|
|
#define FW_CFG_DMA_SELECT (1 << 3)
|
|
|
|
#define FW_CFG_DMA_ENABLED (1 << 1)
|
|
|
|
struct fw_cfg_file {
|
|
__be32 size;
|
|
__be16 select;
|
|
__be16 reserved;
|
|
char name[FW_CFG_MAX_FILE_PATH];
|
|
};
|
|
|
|
struct fw_file {
|
|
struct fw_cfg_file cfg; /* firmware file information */
|
|
unsigned long addr; /* firmware file in-memory address */
|
|
struct list_head list; /* list node to link to fw_list */
|
|
};
|
|
|
|
struct fw_cfg_dma_access {
|
|
__be32 control;
|
|
__be32 length;
|
|
__be64 address;
|
|
};
|
|
|
|
struct bios_linker_entry {
|
|
__le32 command;
|
|
union {
|
|
/*
|
|
* COMMAND_ALLOCATE - allocate a table from @alloc.file
|
|
* subject to @alloc.align alignment (must be power of 2)
|
|
* and @alloc.zone (can be HIGH or FSEG) requirements.
|
|
*
|
|
* Must appear exactly once for each file, and before
|
|
* this file is referenced by any other command.
|
|
*/
|
|
struct {
|
|
char file[BIOS_LINKER_LOADER_FILESZ];
|
|
__le32 align;
|
|
uint8_t zone;
|
|
} alloc;
|
|
|
|
/*
|
|
* COMMAND_ADD_POINTER - patch the table (originating from
|
|
* @dest_file) at @pointer.offset, by adding a pointer to the
|
|
* table originating from @src_file. 1,2,4 or 8 byte unsigned
|
|
* addition is used depending on @pointer.size.
|
|
*/
|
|
struct {
|
|
char dest_file[BIOS_LINKER_LOADER_FILESZ];
|
|
char src_file[BIOS_LINKER_LOADER_FILESZ];
|
|
__le32 offset;
|
|
uint8_t size;
|
|
} pointer;
|
|
|
|
/*
|
|
* COMMAND_ADD_CHECKSUM - calculate checksum of the range
|
|
* specified by @cksum_start and @cksum_length fields,
|
|
* and then add the value at @cksum.offset.
|
|
* Checksum simply sums -X for each byte X in the range
|
|
* using 8-bit math.
|
|
*/
|
|
struct {
|
|
char file[BIOS_LINKER_LOADER_FILESZ];
|
|
__le32 offset;
|
|
__le32 start;
|
|
__le32 length;
|
|
} cksum;
|
|
|
|
/* padding */
|
|
char pad[124];
|
|
};
|
|
} __packed;
|
|
|
|
/**
|
|
* Initialize QEMU fw_cfg interface
|
|
*/
|
|
void qemu_fwcfg_init(void);
|
|
|
|
/**
|
|
* Get system cpu number
|
|
*
|
|
* @return: cpu number in system
|
|
*/
|
|
int qemu_fwcfg_online_cpus(void);
|
|
|
|
#endif
|