Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions src/include/kernel/ext_manifest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2020 Intel Corporation. All rights reserved.
*
* Author: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
*/

/*
* Extended manifest is a place to store metadata about firmware, known during
* compilation time - for example firmware version or used compiler.
* Given information are read on host side before firmware startup.
* This part of output binary is not signed.
*
* To add new content to ext_man, in firmware code define struct which starts
* with ext_man_elem_head followed by usage dependent content and place whole
* struct in "fw_metadata" section. Moreover kernel code should be modified to
* properly read new packet.
*
* Extended manifest is designed to be extensible. In header there is a field
* which describe header length, so after appending some data to header then it
* can be easily skipped by device with older version of this header.
* Unknown ext_man elements should be just skipped by host,
* to be backward compatible. Field `ext_man_elem_header.elem_size` should be
* used in such a situation.
*/

#ifndef __KERNEL_EXT_MANIFEST_H__
#define __KERNEL_EXT_MANIFEST_H__

#include <ipc/info.h>
#include <sof/compiler_attributes.h>
#include <stdint.h>

/* In ASCII `XMan` */
#define EXT_MAN_MAGIC_NUMBER 0x6e614d58

/* Build u32 number in format MMmmmppp */
#define EXT_MAN_BUILD_VERSION(MAJOR, MINOR, PATH) ( \
((uint32_t)(MAJOR) << 24) | \
((uint32_t)(MINOR) << 12) | \
(uint32_t)(PATH))

/* check extended manifest version consistency */
#define EXT_MAN_VERSION_INCOMPATIBLE(host_ver, cli_ver) ( \
((host_ver) & GENMASK(31, 24)) != \
((cli_ver) & GENMASK(31, 24)))

/* used extended manifest header version */
#define EXT_MAN_VERSION EXT_MAN_BUILD_VERSION(1, 0, 0)

/* struct size alignment for ext_man elements */
#define EXT_MAN_ALIGN 16

/* extended manifest header, deleting any field breaks backward compatibility */
struct ext_man_header {
uint32_t magic; /**< identification number, */
/**< EXT_MAN_MAGIC_NUMBER */
uint32_t full_size; /**< [bytes] full size of ext_man, */
/**< (header + content + padding) */
uint32_t header_size; /**< [bytes] makes header extensionable, */
/**< after append new field to ext_man header */
/**< then backward compatible won't be lost */
uint32_t header_version; /**< value of EXT_MAN_VERSION */
/**< not related with following content */

/* just after this header should be list of ext_man_elem_* elements */
} __packed;

/* Now define extended manifest elements */

/* Extended manifest elements identificators */
enum ext_man_elem_type {
EXT_MAN_ELEM_FW_VERSION = 0,
EXT_MAN_ELEM_CC_VERSION = SOF_IPC_EXT_CC_INFO,
EXT_MAN_ELEM_PROBE_INFO = SOF_IPC_EXT_PROBE_INFO,
};

/* extended manifest element header */
struct ext_man_elem_header {
uint32_t type; /**< EXT_MAN_ELEM_* */
uint32_t elem_size; /**< in bytes, including header size */

/* just after this header should be type dependent content */
} __packed;

/* FW version */
struct ext_man_fw_version {
struct ext_man_elem_header hdr;
/* use sof_ipc struct because of code re-use */
struct sof_ipc_fw_version version;
uint32_t flags;
} __packed;

/* Used C compiler description */
struct ext_man_cc_version {
struct ext_man_elem_header hdr;
/* use sof_ipc struct because of code re-use */
struct sof_ipc_cc_version cc_version;
} __packed;

struct ext_man_probe_support {
struct ext_man_elem_header hdr;
/* use sof_ipc struct because of code re-use */
struct sof_ipc_probe_support probe;
} __packed;

#endif /* __KERNEL_EXT_MANIFEST_H__ */
20 changes: 20 additions & 0 deletions src/init/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# SPDX-License-Identifier: BSD-3-Clause

add_local_sources(sof init.c)

add_library(ext_manifest STATIC "")

# define compiler version
set_property(TARGET ext_manifest APPEND
PROPERTY COMPILE_DEFINITIONS
XCC_TOOLS_VERSION="${XCC_TOOLS_VERSION}")

# and optimization settings
get_optimization_flag(optimization_flag)
set_property(TARGET ext_manifest APPEND
PROPERTY COMPILE_DEFINITIONS
CC_OPTIMIZE_FLAGS="${optimization_flag}")

add_local_sources(ext_manifest
ext_manifest.c)
sof_append_relative_path_definitions(ext_manifest)

target_link_libraries(ext_manifest sof_options)
target_link_libraries(sof_static_libraries INTERFACE ext_manifest)
72 changes: 72 additions & 0 deletions src/init/ext_manifest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
//

#include <sof/bit.h>
#include <sof/common.h>
#include <sof/compiler_info.h>
#include <sof/debug/debug.h>
#include <kernel/abi.h>
#include <kernel/ext_manifest.h>
#include <config.h>
#include <version.h>

const struct ext_man_fw_version ext_man_fw_ver
__aligned(EXT_MAN_ALIGN) __section(".fw_metadata") = {
.hdr.type = EXT_MAN_ELEM_FW_VERSION,
.hdr.elem_size = ALIGN_UP(sizeof(struct ext_man_fw_version),
EXT_MAN_ALIGN),
.version = {
.hdr.size = sizeof(struct sof_ipc_fw_version),
.micro = SOF_MICRO,
.minor = SOF_MINOR,
.major = SOF_MAJOR,
#if CONFIG_DEBUG
/* only added in debug for reproducibility in releases */
.build = SOF_BUILD,
.date = __DATE__,
.time = __TIME__,
#endif
.tag = SOF_TAG,
.abi_version = SOF_ABI_VERSION,
},
.flags = DEBUG_SET_FW_READY_FLAGS,
};

const struct ext_man_cc_version ext_man_cc_ver
__aligned(EXT_MAN_ALIGN) __section(".fw_metadata") = {
.hdr.type = EXT_MAN_ELEM_CC_VERSION,
.hdr.elem_size = ALIGN_UP(sizeof(struct ext_man_cc_version),
EXT_MAN_ALIGN),
.cc_version = {
.ext_hdr.hdr.size = sizeof(struct sof_ipc_cc_version),
.ext_hdr.hdr.cmd = SOF_IPC_FW_READY,
.ext_hdr.type = SOF_IPC_EXT_CC_INFO,
.micro = CC_MICRO,
.minor = CC_MINOR,
.major = CC_MAJOR,
.name = CC_NAME "\0", ///< eg. "XCC", "\0" is needed when
///< sizeof(CC_NAME)-1 == sizeof(.name)
.optim = CC_OPTIMIZE_FLAGS "\0", ///< eg. "O2"
.desc = CC_DESC "\0", ///< eg. " RG-2017.8-linux"
},
};

const struct ext_man_probe_support ext_man_probe
__aligned(EXT_MAN_ALIGN) __section(".fw_metadata") = {
.hdr.type = EXT_MAN_ELEM_PROBE_INFO,
.hdr.elem_size = ALIGN_UP(sizeof(struct ext_man_probe_support),
EXT_MAN_ALIGN),
.probe = {
.ext_hdr.hdr.size = sizeof(struct sof_ipc_probe_support),
.ext_hdr.hdr.cmd = SOF_IPC_FW_READY,
.ext_hdr.type = SOF_IPC_EXT_PROBE_INFO,
#if CONFIG_PROBE
.probe_points_max = CONFIG_PROBE_POINTS_MAX,
.injection_dmas_max = CONFIG_PROBE_DMA_MAX
#endif
},
};
13 changes: 13 additions & 0 deletions src/platform/apollolake/apollolake.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ MEMORY
static_log_entries_seg (!ari) :
org = LOG_ENTRY_ELF_BASE,
len = LOG_ENTRY_ELF_SIZE
fw_metadata_seg (!ari) :
org = EXT_MANIFEST_ELF_BASE,
len = EXT_MANIFEST_ELF_SIZE
}

PHDRS
Expand Down Expand Up @@ -142,6 +145,7 @@ PHDRS

static_uuid_entries_phdr PT_NOTE;
static_log_entries_phdr PT_NOTE;
metadata_entries_phdr PT_NOTE;
}

/* Default entry point: */
Expand All @@ -157,6 +161,9 @@ PROVIDE(_memmap_vecbase_reset = SOF_MEM_VECBASE);
_memmap_cacheattr_wbna_trapnull = 0xFF42FFF2;
PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wbna_trapnull);

_EXT_MAN_ALIGN_ = 16;
EXTERN(ext_man_fw_ver)

SECTIONS
{
.MemoryExceptionVector.literal : ALIGN(4)
Expand Down Expand Up @@ -590,4 +597,10 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr

.fw_metadata (COPY) : ALIGN(1024)
{
KEEP (*(.fw_metadata))
. = ALIGN(_EXT_MAN_ALIGN_);
} >fw_metadata_seg :metadata_entries_phdr
}
3 changes: 3 additions & 0 deletions src/platform/apollolake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
#define LOG_ENTRY_ELF_BASE 0x20000000
#define LOG_ENTRY_ELF_SIZE 0x2000000

#define EXT_MANIFEST_ELF_BASE (LOG_ENTRY_ELF_BASE + LOG_ENTRY_ELF_SIZE)
#define EXT_MANIFEST_ELF_SIZE 0x2000000

/*
* The HP SRAM Region Apollolake is organised like this :-
* +--------------------------------------------------------------------------+
Expand Down
12 changes: 12 additions & 0 deletions src/platform/baytrail/baytrail.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ MEMORY
static_log_entries_seg (!ari) :
org = LOG_ENTRY_ELF_BASE,
len = LOG_ENTRY_ELF_SIZE
fw_metadata_seg (!ari) :
org = EXT_MANIFEST_ELF_BASE,
len = EXT_MANIFEST_ELF_SIZE
}

PHDRS
Expand Down Expand Up @@ -145,6 +148,7 @@ PHDRS
sof_stack_phdr PT_LOAD;
static_uuid_entries_phdr PT_NOTE;
static_log_entries_phdr PT_NOTE;
metadata_entries_phdr PT_NOTE;
}

/* Default entry point: */
Expand Down Expand Up @@ -172,6 +176,9 @@ _memmap_cacheattr_wt_allvalid = 0x11221222;
_memmap_cacheattr_bp_allvalid = 0x22222222;
PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wbna_trapnull);

_EXT_MAN_ALIGN_ = 16;
EXTERN(ext_man_fw_ver)

SECTIONS
{
.ResetVector.text : ALIGN(4)
Expand Down Expand Up @@ -543,6 +550,11 @@ SECTIONS
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr

.fw_metadata (COPY) : ALIGN(1024)
{
KEEP (*(.fw_metadata))
} >fw_metadata_seg :metadata_entries_phdr

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
Expand Down
3 changes: 3 additions & 0 deletions src/platform/baytrail/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ static inline void *platform_rfree_prepare(void *ptr)
#define LOG_ENTRY_ELF_BASE 0x20000000
#define LOG_ENTRY_ELF_SIZE 0x2000000

#define EXT_MANIFEST_ELF_BASE (LOG_ENTRY_ELF_BASE + LOG_ENTRY_ELF_SIZE)
#define EXT_MANIFEST_ELF_SIZE 0x2000000

/*
* The Heap and Stack on Baytrail are organised like this :-
*
Expand Down
13 changes: 13 additions & 0 deletions src/platform/cannonlake/cannonlake.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ MEMORY
static_log_entries_seg (!ari) :
org = LOG_ENTRY_ELF_BASE,
len = LOG_ENTRY_ELF_SIZE
fw_metadata_seg (!ari) :
org = EXT_MANIFEST_ELF_BASE,
len = EXT_MANIFEST_ELF_SIZE
}

PHDRS
Expand Down Expand Up @@ -131,6 +134,7 @@ PHDRS
wnd3_phdr PT_LOAD;
static_uuid_entries_phdr PT_NOTE;
static_log_entries_phdr PT_NOTE;
metadata_entries_phdr PT_NOTE;
}

/* Default entry point: */
Expand All @@ -144,6 +148,9 @@ PROVIDE(_memmap_vecbase_reset = HP_SRAM_VECBASE_RESET);
_memmap_cacheattr_wbna_trapnull = 0xFF42FFF2;
PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wbna_trapnull);

_EXT_MAN_ALIGN_ = 16;
EXTERN(ext_man_fw_ver)

SECTIONS
{
.MemoryExceptionVector.text : ALIGN(4)
Expand Down Expand Up @@ -555,4 +562,10 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr

.fw_metadata (COPY) : ALIGN(1024)
{
KEEP (*(.fw_metadata))
. = ALIGN(_EXT_MAN_ALIGN_);
} >fw_metadata_seg :metadata_entries_phdr
}
3 changes: 3 additions & 0 deletions src/platform/cannonlake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
#define LOG_ENTRY_ELF_BASE 0x20000000
#define LOG_ENTRY_ELF_SIZE 0x2000000

#define EXT_MANIFEST_ELF_BASE (LOG_ENTRY_ELF_BASE + LOG_ENTRY_ELF_SIZE)
#define EXT_MANIFEST_ELF_SIZE 0x2000000

/*
* The HP SRAM Region on Cannonlake is organised like this :-
* +--------------------------------------------------------------------------+
Expand Down
13 changes: 13 additions & 0 deletions src/platform/haswell/haswell.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ MEMORY
static_log_entries_seg (!ari) :
org = LOG_ENTRY_ELF_BASE,
len = LOG_ENTRY_ELF_SIZE
fw_metadata_seg (!ari) :
org = EXT_MANIFEST_ELF_BASE,
len = EXT_MANIFEST_ELF_SIZE
}

PHDRS
Expand Down Expand Up @@ -153,6 +156,7 @@ PHDRS
sof_stack_phdr PT_LOAD;
static_uuid_entries_phdr PT_NOTE;
static_log_entries_phdr PT_NOTE;
metadata_entries_phdr PT_NOTE;
}

/* Default entry point: */
Expand Down Expand Up @@ -180,6 +184,9 @@ _memmap_cacheattr_wt_allvalid = 0x11221222;
_memmap_cacheattr_bp_allvalid = 0x22222222;
PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wbna_trapnull);

_EXT_MAN_ALIGN_ = 16;
EXTERN(ext_man_fw_ver)

SECTIONS
{
.ResetVector.text : ALIGN(4)
Expand Down Expand Up @@ -573,4 +580,10 @@ SECTIONS
KEEP (*(.fw_ready))
KEEP (*(.fw_ready_metadata))
} >sof_data :sof_data_phdr

.fw_metadata (COPY) : ALIGN(1024)
{
KEEP (*(.fw_metadata))
. = ALIGN(_EXT_MAN_ALIGN_);
} >fw_metadata_seg :metadata_entries_phdr
}
Loading