diff --git a/rimage/elf.c b/rimage/elf.c index 3796c9fb50d6..1b5420439da7 100644 --- a/rimage/elf.c +++ b/rimage/elf.c @@ -80,6 +80,9 @@ static int elf_read_sections(struct image *image, struct module *module, module->logs_index = -EINVAL; + fprintf(stdout, "info: ignore .static_uuids section for bootloader module\n"); + module->uids_index = -EINVAL; + fprintf(stdout, "info: ignore .fw_ready" " section for bootloader module\n"); @@ -94,6 +97,9 @@ static int elf_read_sections(struct image *image, struct module *module, module->logs_index = elf_find_section(image, module, ".static_log_entries"); + module->uids_index = elf_find_section(image, module, + ".static_uuid_entries"); + module->fw_ready_index = elf_find_section(image, module, ".fw_ready"); if (module->fw_ready_index < 0) diff --git a/rimage/file_format.h b/rimage/file_format.h index b0cea780d6f7..dc43dc9f947f 100644 --- a/rimage/file_format.h +++ b/rimage/file_format.h @@ -18,6 +18,9 @@ #define SND_SOF_LOGS_SIG_SIZE 4 #define SND_SOF_LOGS_SIG "Logs" +#define SND_SOF_UIDS_SIG_SIZE 4 +#define SND_SOF_UIDS_SIG "Uids" + /* * Logs dictionary file header. */ @@ -28,4 +31,11 @@ struct snd_sof_logs_header { uint32_t data_offset; /* offset to first entry in this file */ struct sof_ipc_fw_version version; }; + +struct snd_sof_uids_header { + unsigned char sig[SND_SOF_UIDS_SIG_SIZE]; /* "Uids" */ + uint32_t base_address; + uint32_t data_length; + uint32_t data_offset; +}; #endif diff --git a/rimage/file_simple.c b/rimage/file_simple.c index 63fba607bcde..b68483f2ebab 100644 --- a/rimage/file_simple.c +++ b/rimage/file_simple.c @@ -442,7 +442,7 @@ static int simple_write_firmware(struct image *image) return 0; } -int write_logs_dictionary(struct image *image) +static int write_logs_dictionary(struct image *image) { struct snd_sof_logs_header header; int i, ret = 0; @@ -497,7 +497,7 @@ int write_logs_dictionary(struct image *image) fprintf(stdout, "logs dictionary: size %u\n", header.data_length + header.data_offset); - fprintf(stdout, "including fw version of size: %lu\n\n", + fprintf(stdout, "including fw version of size: %lu\n", (unsigned long)sizeof(header.version)); } } @@ -508,6 +508,69 @@ int write_logs_dictionary(struct image *image) return ret; } +static int write_uids_dictionary(struct image *image) +{ + struct snd_sof_uids_header header; + Elf32_Shdr *section; + int i, ret = 0; + void *buffer = NULL; + + memcpy(header.sig, SND_SOF_UIDS_SIG, SND_SOF_UIDS_SIG_SIZE); + header.data_offset = sizeof(struct snd_sof_uids_header); + + for (i = 0; i < image->num_modules; i++) { + struct module *module = &image->module[i]; + + if (module->uids_index <= 0) + continue; + section = &module->section[module->uids_index]; + + header.base_address = section->vaddr; + header.data_length = section->size; + + fwrite(&header, sizeof(struct snd_sof_uids_header), 1, + image->ldc_out_fd); + + buffer = calloc(1, section->size); + if (!buffer) + return -ENOMEM; + fseek(module->fd, section->off, SEEK_SET); + if (fread(buffer, 1, section->size, module->fd) != + section->size) { + fprintf(stderr, "error: can't read uids section %d\n", + -errno); + ret = -errno; + goto out; + } + if (fwrite(buffer, 1, section->size, image->ldc_out_fd) != + section->size) { + fprintf(stderr, "error: cant't write section %d\n", + -errno); + ret = -errno; + goto out; + } + fprintf(stdout, "uids dictionary: size %u\n", + header.data_length + header.data_offset); + } +out: + free(buffer); + return ret; +} + +int write_dictionaries(struct image *image) +{ + int ret = 0; + + ret = write_logs_dictionary(image); + if (ret) + goto out; + + ret = write_uids_dictionary(image); + +out: + return ret; +} + const struct adsp machine_byt = { .name = "byt", .mem_zones = { diff --git a/rimage/rimage.c b/rimage/rimage.c index 8413c073d537..6f94a2fd33d0 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -166,7 +166,7 @@ int main(int argc, char *argv[]) ret = -EINVAL; goto out; } - ret = write_logs_dictionary(&image); + ret = write_dictionaries(&image); out: /* close files */ if (image.out_fd) diff --git a/rimage/rimage.h b/rimage/rimage.h index fb6ce8bebe6a..72992a0cbae5 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -68,6 +68,7 @@ struct module { int fw_size; int bss_index; int logs_index; + int uids_index; int fw_ready_index; /* sizes do not include any gaps */ @@ -151,7 +152,7 @@ struct adsp { int exec_boot_ldr; }; -int write_logs_dictionary(struct image *image); +int write_dictionaries(struct image *image); void module_sha256_create(struct image *image); void module_sha_update(struct image *image, uint8_t *data, size_t bytes); diff --git a/src/audio/asrc/asrc.c b/src/audio/asrc/asrc.c index b924ebf399db..55e5db2592ae 100644 --- a/src/audio/asrc/asrc.c +++ b/src/audio/asrc/asrc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,10 @@ typedef void (*asrc_proc_func)(struct comp_dev *dev, static const struct comp_driver comp_asrc; +/* c8ec72f6-8526-4faf-9d39-a23d0b541de2 */ +DECLARE_SOF_UUID("asrc", asrc_uuid, 0xc8ec72f6, 0x8526, 0x4faf, + 0x9d, 0x39, 0xa2, 0x3d, 0x0b, 0x54, 0x1d, 0xe2); + /* asrc component private data */ struct comp_data { struct asrc_farrow *asrc_obj; /* ASRC core data */ @@ -892,6 +897,7 @@ static int asrc_reset(struct comp_dev *dev) static const struct comp_driver comp_asrc = { .type = SOF_COMP_ASRC, + .uid = SOF_UUID(asrc_uuid), .ops = { .new = asrc_new, .free = asrc_free, diff --git a/src/audio/dai.c b/src/audio/dai.c index d5bd0c7e970f..9ab1bae6468e 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,10 @@ static const struct comp_driver comp_dai; +/* c2b00d27-ffbc-4150-a51a-245c79c5e54b */ +DECLARE_SOF_UUID("dai", dai_comp_uuid, 0xc2b00d27, 0xffbc, 0x4150, + 0xa5, 0x1a, 0x24, 0x5c, 0x79, 0xc5, 0xe5, 0x4b); + struct dai_data { /* local DMA config */ struct dma_chan_data *chan; @@ -878,6 +883,7 @@ static int dai_ts_get(struct comp_dev *dev, struct timestamp_data *tsd) static const struct comp_driver comp_dai = { .type = SOF_COMP_DAI, + .uid = SOF_UUID(dai_comp_uuid), .ops = { .new = dai_new, .free = dai_free, diff --git a/src/audio/detect_test.c b/src/audio/detect_test.c index f1ddb82573b9..827e49b95cba 100644 --- a/src/audio/detect_test.c +++ b/src/audio/detect_test.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,10 @@ static const struct comp_driver comp_keyword; +/* eba8d51f-7827-47b5-82ee-de6e7743af67 */ +DECLARE_SOF_UUID("kd-test", keyword_uuid, 0xeba8d51f, 0x7827, 0x47b5, + 0x82, 0xee, 0xde, 0x6e, 0x77, 0x43, 0xaf, 0x67); + struct model_data { uint32_t data_size; void *data; @@ -782,6 +787,7 @@ static int test_keyword_prepare(struct comp_dev *dev) static const struct comp_driver comp_keyword = { .type = SOF_COMP_KEYWORD_DETECT, + .uid = SOF_UUID(keyword_uuid), .ops = { .new = test_keyword_new, .free = test_keyword_free, diff --git a/src/audio/eq_fir/eq_fir.c b/src/audio/eq_fir/eq_fir.c index fb5e4677f426..55d4874bd09f 100644 --- a/src/audio/eq_fir/eq_fir.c +++ b/src/audio/eq_fir/eq_fir.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,10 @@ static const struct comp_driver comp_eq_fir; +/* 43a90ce7-f3a5-41df-ac06-ba98651ae6a3 */ +DECLARE_SOF_UUID("eq-fir", eq_fir_uuid, 0x43a90ce7, 0xf3a5, 0x41df, + 0xac, 0x06, 0xba, 0x98, 0x65, 0x1a, 0xe6, 0xa3); + /* src component private data */ struct comp_data { struct fir_state_32x16 fir[PLATFORM_MAX_CHANNELS]; /**< filters state */ @@ -842,6 +847,7 @@ static int eq_fir_reset(struct comp_dev *dev) static const struct comp_driver comp_eq_fir = { .type = SOF_COMP_EQ_FIR, + .uid = SOF_UUID(eq_fir_uuid), .ops = { .new = eq_fir_new, .free = eq_fir_free, diff --git a/src/audio/eq_iir/eq_iir.c b/src/audio/eq_iir/eq_iir.c index 79a012225a01..1d86ae01d2dd 100644 --- a/src/audio/eq_iir/eq_iir.c +++ b/src/audio/eq_iir/eq_iir.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,10 @@ static const struct comp_driver comp_eq_iir; +/* 5150c0e6-27f9-4ec8-8351-c705b642d12f */ +DECLARE_SOF_UUID("eq-iir", eq_iir_uuid, 0x5150c0e6, 0x27f9, 0x4ec8, + 0x83, 0x51, 0xc7, 0x05, 0xb6, 0x42, 0xd1, 0x2f); + /* IIR component private data */ struct comp_data { struct iir_state_df2t iir[PLATFORM_MAX_CHANNELS]; /**< filters state */ @@ -937,6 +942,7 @@ static int eq_iir_reset(struct comp_dev *dev) static const struct comp_driver comp_eq_iir = { .type = SOF_COMP_EQ_IIR, + .uid = SOF_UUID(eq_iir_uuid), .ops = { .new = eq_iir_new, .free = eq_iir_free, diff --git a/src/audio/host.c b/src/audio/host.c index 34b7df1e5acb..028f4da1ab4f 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,10 @@ static const struct comp_driver comp_host; +/* 8b9d100c-6d78-418f-90a3-e0e805d0852b */ +DECLARE_SOF_UUID("host", host_uuid, 0x8b9d100c, 0x6d78, 0x418f, + 0x90, 0xa3, 0xe0, 0xe8, 0x05, 0xd0, 0x85, 0x2b); + /** * \brief Host buffer info. */ @@ -819,6 +824,7 @@ static int host_set_attribute(struct comp_dev *dev, uint32_t type, static const struct comp_driver comp_host = { .type = SOF_COMP_HOST, + .uid = SOF_UUID(host_uuid), .ops = { .new = host_new, .free = host_free, diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 2b8064b046e9..a5b227ad0f1c 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,10 @@ static const struct comp_driver comp_kpb; +/* d8218443-5ff3-4a4c-b388-6cfe07b9562e */ +DECLARE_SOF_UUID("kpb", kpb_uuid, 0xd8218443, 0x5ff3, 0x4a4c, + 0xb3, 0x88, 0x6c, 0xfe, 0x07, 0xb9, 0x56, 0x2e); + /* KPB private data, runtime data */ struct comp_data { uint64_t state_log; /**< keeps record of KPB recent states */ @@ -1527,6 +1532,7 @@ static inline void kpb_change_state(struct comp_data *kpb, static const struct comp_driver comp_kpb = { .type = SOF_COMP_KPB, + .uid = SOF_UUID(kpb_uuid), .ops = { .new = kpb_new, .free = kpb_free, diff --git a/src/audio/mixer.c b/src/audio/mixer.c index b262905c3c04..5192fc5275fc 100644 --- a/src/audio/mixer.c +++ b/src/audio/mixer.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,10 @@ static const struct comp_driver comp_mixer; +/* bc06c037-12aa-417c-9a97-89282e321a76 */ +DECLARE_SOF_UUID("mixer", mixer_uuid, 0xbc06c037, 0x12aa, 0x417c, + 0x9a, 0x97, 0x89, 0x28, 0x2e, 0x32, 0x1a, 0x76); + /* mixer component private data */ struct mixer_data { void (*mix_func)(struct comp_dev *dev, struct audio_stream *sink, @@ -436,6 +441,7 @@ static int mixer_prepare(struct comp_dev *dev) static const struct comp_driver comp_mixer = { .type = SOF_COMP_MIXER, + .uid = SOF_UUID(mixer_uuid), .ops = { .new = mixer_new, .free = mixer_free, diff --git a/src/audio/mux/mux.c b/src/audio/mux/mux.c index 09c543fcce67..efe84c669231 100644 --- a/src/audio/mux/mux.c +++ b/src/audio/mux/mux.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,10 @@ static const struct comp_driver comp_mux; +/* c4b26868-1430-470e-a089-15d1c77f851a */ +DECLARE_SOF_UUID("mux", mux_uuid, 0xc4b26868, 0x1430, 0x470e, + 0xa0, 0x89, 0x15, 0xd1, 0xc7, 0x7f, 0x85, 0x1a); + static int mux_set_values(struct comp_dev *dev, struct comp_data *cd, struct sof_mux_config *cfg) { @@ -502,6 +507,7 @@ static SHARED_DATA struct comp_driver_info comp_mux_info = { static const struct comp_driver comp_demux = { .type = SOF_COMP_DEMUX, + .uid = SOF_UUID(mux_uuid), .ops = { .new = mux_new, .free = mux_free, diff --git a/src/audio/selector/selector.c b/src/audio/selector/selector.c index 3a361833756b..7052a1cbb663 100644 --- a/src/audio/selector/selector.c +++ b/src/audio/selector/selector.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,10 @@ static const struct comp_driver comp_selector; +/* 55a88ed5-3d18-46ca-88f1-0ee6eae9930f */ +DECLARE_SOF_UUID("selector", selector_uuid, 0x55a88ed5, 0x3d18, 0x46ca, + 0x88, 0xf1, 0x0e, 0xe6, 0xea, 0xe9, 0x93, 0x0f); + /** * \brief Creates selector component. * \param[in,out] data Selector base component device. @@ -515,6 +520,7 @@ static int selector_reset(struct comp_dev *dev) /** \brief Selector component definition. */ static const struct comp_driver comp_selector = { .type = SOF_COMP_SELECTOR, + .uid = SOF_UUID(selector_uuid), .ops = { .new = selector_new, .free = selector_free, diff --git a/src/audio/src/src.c b/src/audio/src/src.c index 4bc559b1ecb2..abc58f954407 100644 --- a/src/audio/src/src.c +++ b/src/audio/src/src.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,10 @@ static const struct comp_driver comp_src; +/* c1c5326d-8390-46b4-aa47-95c3beca6550 */ +DECLARE_SOF_UUID("src", src_uuid, 0xc1c5326d, 0x8390, 0x46b4, + 0xaa, 0x47, 0x95, 0xc3, 0xbe, 0xca, 0x65, 0x50); + /* src component private data */ struct comp_data { struct polyphase_src src; @@ -910,6 +915,7 @@ static int src_reset(struct comp_dev *dev) static const struct comp_driver comp_src = { .type = SOF_COMP_SRC, + .uid = SOF_UUID(src_uuid), .ops = { .new = src_new, .free = src_free, diff --git a/src/audio/switch.c b/src/audio/switch.c index ff8f9bda3920..175143be82e4 100644 --- a/src/audio/switch.c +++ b/src/audio/switch.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,10 @@ static const struct comp_driver comp_switch; +/* 385cc44b-f34e-4b9b-8be0-535c5f43a825 */ +DECLARE_SOF_UUID("switch", switch_uuid, 0x385cc44b, 0xf34e, 0x4b9b, + 0x8b, 0xe0, 0x53, 0x5c, 0x5f, 0x43, 0xa8, 0x25); + static struct comp_dev *switch_new(const struct comp_driver *drv, struct sof_ipc_comp *comp) { @@ -59,6 +64,7 @@ static int switch_prepare(struct comp_dev *dev) static const struct comp_driver comp_switch = { .type = SOF_COMP_SWITCH, + .uid = SOF_UUID(switch_uuid), .ops = { .new = switch_new, .free = switch_free, diff --git a/src/audio/tone.c b/src/audio/tone.c index 2f5ddf519355..250351215262 100644 --- a/src/audio/tone.c +++ b/src/audio/tone.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,10 @@ static const struct comp_driver comp_tone; +/* 04e3f894-2c5c-4f2e-8dc1-694eeaab53fa */ +DECLARE_SOF_UUID("tone", tone_uuid, 0x04e3f894, 0x2c5c, 0x4f2e, + 0x8d, 0xc1, 0x69, 0x4e, 0xea, 0xab, 0x53, 0xfa); + /* 2*pi/Fs lookup tables in Q1.31 for each Fs */ static const int32_t tone_fs_list[TONE_NUM_FS] = { 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, @@ -702,6 +707,7 @@ static int tone_reset(struct comp_dev *dev) static const struct comp_driver comp_tone = { .type = SOF_COMP_TONE, + .uid = SOF_UUID(tone_uuid), .ops = { .new = tone_new, .free = tone_free, diff --git a/src/audio/volume/volume.c b/src/audio/volume/volume.c index 9a49d075d8b7..e75f5b483322 100644 --- a/src/audio/volume/volume.c +++ b/src/audio/volume/volume.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,10 @@ static const struct comp_driver comp_volume; +/* b77e677e-5ff4-4188-af14-fba8bdbf8682 */ +DECLARE_SOF_UUID("volume", volume_uuid, 0xb77e677e, 0x5ff4, 0x4188, + 0xaf, 0x14, 0xfb, 0xa8, 0xbd, 0xbf, 0x86, 0x82); + /** * \brief Synchronize host mmap() volume with real value. * \param[in,out] cd Volume component private data. @@ -771,6 +776,7 @@ static int volume_reset(struct comp_dev *dev) /** \brief Volume component definition. */ static const struct comp_driver comp_volume = { .type = SOF_COMP_VOLUME, + .uid = SOF_UUID(volume_uuid), .ops = { .new = volume_new, .free = volume_free, diff --git a/src/drivers/intel/cavs/alh.c b/src/drivers/intel/cavs/alh.c index 22c4eaebb095..9fa2ad3f5467 100644 --- a/src/drivers/intel/cavs/alh.c +++ b/src/drivers/intel/cavs/alh.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -15,6 +16,10 @@ #include #include +/* a8e4218c-e863-4c93-84e7-5c27d2504501 */ +DECLARE_SOF_UUID("alh-dai", alh_uuid, 0xa8e4218c, 0xe863, 0x4c93, + 0x84, 0xe7, 0x5c, 0x27, 0xd2, 0x50, 0x45, 0x01); + static int alh_trigger(struct dai *dai, int cmd, int direction) { dai_info(dai, "alh_trigger() cmd %d", cmd); @@ -93,6 +98,7 @@ static int alh_get_fifo(struct dai *dai, int direction, int stream_id) const struct dai_driver alh_driver = { .type = SOF_DAI_INTEL_ALH, + .uid = SOF_UUID(alh_uuid), .dma_caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP, .dma_dev = DMA_DEV_ALH, .ops = { diff --git a/src/drivers/intel/cavs/dmic.c b/src/drivers/intel/cavs/dmic.c index 0351bf6f4720..0fc9e214582b 100644 --- a/src/drivers/intel/cavs/dmic.c +++ b/src/drivers/intel/cavs/dmic.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,10 @@ #include #include +/* aafc26fe-3b8d-498d-8bd6-248fc72efa31 */ +DECLARE_SOF_UUID("dmic-dai", dmic_uuid, 0xaafc26fe, 0x3b8d, 0x498d, + 0x8b, 0xd6, 0x24, 0x8f, 0xc7, 0x2e, 0xfa, 0x31); + #define DMIC_MAX_MODES 50 /* HW FIR pipeline needs 5 additional cycles per channel for internal @@ -1710,6 +1715,7 @@ static int dmic_ts_get(struct dai *dai, struct timestamp_cfg *cfg, const struct dai_driver dmic_driver = { .type = SOF_DAI_INTEL_DMIC, + .uid = SOF_UUID(dmic_uuid), .dma_caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP, .dma_dev = DMA_DEV_DMIC, .ops = { diff --git a/src/drivers/intel/cavs/hda.c b/src/drivers/intel/cavs/hda.c index 666de5ba2aa6..c25beb378816 100644 --- a/src/drivers/intel/cavs/hda.c +++ b/src/drivers/intel/cavs/hda.c @@ -9,9 +9,14 @@ #include #include #include +#include #include #include +/* bc9ebe20-4577-41bb-9eed-d0cb236328da */ +DECLARE_SOF_UUID("hda-dai", hda_uuid, 0xbc9ebe20, 0x4577, 0x41bb, + 0x9e, 0xed, 0xd0, 0xcb, 0x23, 0x63, 0x28, 0xda); + static int hda_trigger(struct dai *dai, int cmd, int direction) { return 0; @@ -159,6 +164,7 @@ static int hda_ts_get(struct dai *dai, struct timestamp_cfg *cfg, const struct dai_driver hda_driver = { .type = SOF_DAI_INTEL_HDA, + .uid = SOF_UUID(hda_uuid), .dma_caps = DMA_CAP_HDA, .dma_dev = DMA_DEV_HDA, .ops = { diff --git a/src/drivers/intel/cavs/ssp.c b/src/drivers/intel/cavs/ssp.c index ec56f28f82d6..8cf435f753e1 100644 --- a/src/drivers/intel/cavs/ssp.c +++ b/src/drivers/intel/cavs/ssp.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,10 @@ #include #include +/* 31458125-95c4-4085-8f3f-497434cb2daf */ +DECLARE_SOF_UUID("ssp-dai", ssp_uuid, 0x31458125, 0x95c4, 0x4085, + 0x8f, 0x3f, 0x49, 0x74, 0x34, 0xcb, 0x2d, 0xaf); + /* empty SSP transmit FIFO */ static void ssp_empty_tx_fifo(struct dai *dai) { @@ -980,6 +985,7 @@ static int ssp_ts_get(struct dai *dai, struct timestamp_cfg *cfg, const struct dai_driver ssp_driver = { .type = SOF_DAI_INTEL_SSP, + .uid = SOF_UUID(ssp_uuid), .dma_caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP, .dma_dev = DMA_DEV_SSP, .ops = { diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index 2caaaa332b44..b8db66aef97a 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -35,13 +35,13 @@ struct comp_dev; #define trace_buffer(__e, ...) \ trace_event(TRACE_CLASS_BUFFER, __e, ##__VA_ARGS__) #define trace_buffer_with_ids(buf_ptr, __e, ...) \ - trace_event_with_ids(TRACE_CLASS_BUFFER, (buf_ptr)->pipeline_id, \ + trace_event_with_ids(TRACE_CLASS_BUFFER, 0, (buf_ptr)->pipeline_id, \ (buf_ptr)->id, __e, ##__VA_ARGS__) #define tracev_buffer(__e, ...) \ tracev_event(TRACE_CLASS_BUFFER, __e, ##__VA_ARGS__) #define tracev_buffer_with_ids(buf_ptr, __e, ...) \ - tracev_event_with_ids(TRACE_CLASS_BUFFER, (buf_ptr)->pipeline_id, \ + tracev_event_with_ids(TRACE_CLASS_BUFFER, 0, (buf_ptr)->pipeline_id, \ (buf_ptr)->id, __e, ##__VA_ARGS__) #define trace_buffer_error(__e, ...) \ @@ -49,7 +49,7 @@ struct comp_dev; #define trace_buffer_error_atomic(__e, ...) \ trace_error_atomic(TRACE_CLASS_BUFFER, __e, ##__VA_ARGS__) #define trace_buffer_error_with_ids(buf_ptr, __e, ...) \ - trace_error_with_ids(TRACE_CLASS_BUFFER, (buf_ptr)->pipeline_id, \ + trace_error_with_ids(TRACE_CLASS_BUFFER, 0, (buf_ptr)->pipeline_id, \ (buf_ptr)->id, __e, ##__VA_ARGS__) /* buffer callback types */ diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 8e4848efbe08..a52d344a28cf 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -150,31 +150,64 @@ struct dai_hw_params; /** \name Trace macros * @{ */ +#define trace_comp_drv_get_uid(drv_p) ((drv_p)->uid) +#define trace_comp_drv_get_id(drv_p) (-1) +#define trace_comp_drv_get_subid(drv_p) (-1) + +#define trace_comp_get_uid(comp_p) ((comp_p)->drv->uid) #define trace_comp_get_id(comp_p) ((comp_p)->comp.pipeline_id) #define trace_comp_get_subid(comp_p) ((comp_p)->comp.id) /* class (driver) level (no device object) tracing */ -#define comp_cl_err(drv_p, __e, ...) \ - trace_error(TRACE_CLASS_COMP, __e, ##__VA_ARGS__) - -#define comp_cl_info(drv_p, __e, ...) \ - trace_event(TRACE_CLASS_COMP, __e, ##__VA_ARGS__) +#define comp_cl_err(drv_p, __e, ...) \ + trace_dev_err(TRACE_CLASS_COMP, \ + trace_comp_drv_get_uid, \ + trace_comp_drv_get_id, \ + trace_comp_drv_get_subid, \ + drv_p, \ + __e, ##__VA_ARGS__) + +#define comp_cl_warn(drv_p, __e, ...) \ + trace_dev_warn(TRACE_CLASS_COMP, \ + trace_comp_drv_get_uid, \ + trace_comp_drv_get_id, \ + trace_comp_drv_get_subid,\ + drv_p, \ + __e, ##__VA_ARGS__) + +#define comp_cl_info(drv_p, __e, ...) \ + trace_dev_info(TRACE_CLASS_COMP, \ + trace_comp_drv_get_uid, \ + trace_comp_drv_get_id, \ + trace_comp_drv_get_subid,\ + drv_p, \ + __e, ##__VA_ARGS__) + +#define comp_cl_dbg(drv_p, __e, ...) \ + trace_dev_dbg(TRACE_CLASS_COMP, \ + trace_comp_drv_get_uid, \ + trace_comp_drv_get_id, \ + trace_comp_drv_get_subid, \ + drv_p, \ + __e, ##__VA_ARGS__) -#define comp_cl_dbg(drv_p, __e, ...) \ - tracev_event(TRACE_CLASS_COMP, __e, ##__VA_ARGS__) /* device tracing */ #define comp_err(comp_p, __e, ...) \ - trace_dev_err(TRACE_CLASS_COMP, trace_comp_get_id, \ + trace_dev_err(TRACE_CLASS_COMP, trace_comp_get_uid, trace_comp_get_id, \ trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__) +#define comp_warn(comp_p, __e, ...) \ + trace_dev_warn(TRACE_CLASS_COMP, trace_comp_get_uid, trace_comp_get_id,\ + trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__) + #define comp_info(comp_p, __e, ...) \ - trace_dev_info(TRACE_CLASS_COMP, trace_comp_get_id, \ + trace_dev_info(TRACE_CLASS_COMP, trace_comp_get_uid, trace_comp_get_id,\ trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__) #define comp_dbg(comp_p, __e, ...) \ - trace_dev_dbg(TRACE_CLASS_COMP, trace_comp_get_id, \ + trace_dev_dbg(TRACE_CLASS_COMP, trace_comp_get_uid, trace_comp_get_id, \ trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__) @@ -267,6 +300,7 @@ struct comp_ops { */ struct comp_driver { uint32_t type; /**< SOF_COMP_ for driver */ + uint32_t uid; /**< Address of uuid_entry */ struct comp_ops ops; /**< component operations */ }; diff --git a/src/include/sof/audio/pipeline.h b/src/include/sof/audio/pipeline.h index d81d15c30997..593b7b0574b8 100644 --- a/src/include/sof/audio/pipeline.h +++ b/src/include/sof/audio/pipeline.h @@ -32,6 +32,7 @@ struct task; #define NO_XRUN_RECOVERY 1 /* pipeline tracing */ +#define trace_pipe_get_uid(pipe_p) (0) #define trace_pipe_get_id(pipe_p) ((pipe_p)->ipc_pipe.pipeline_id) #define trace_pipe_get_subid(pipe_p) ((pipe_p)->ipc_pipe.comp_id) @@ -40,6 +41,9 @@ struct task; #define pipe_cl_err(__e, ...) \ trace_error(TRACE_CLASS_PIPE, __e, ##__VA_ARGS__) +#define pipe_cl_warn(__e, ...) \ + trace_warn(TRACE_CLASS_PIPE, __e, ##__VA_ARGS__) + #define pipe_cl_info(__e, ...) \ trace_event(TRACE_CLASS_PIPE, __e, ##__VA_ARGS__) @@ -49,15 +53,19 @@ struct task; /* device tracing */ #define pipe_err(pipe_p, __e, ...) \ - trace_dev_err(TRACE_CLASS_PIPE, trace_pipe_get_id, \ + trace_dev_err(TRACE_CLASS_PIPE, trace_pipe_get_uid, trace_pipe_get_id,\ trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__) +#define pipe_warn(pipe_p, __e, ...) \ + trace_dev_warn(TRACE_CLASS_PIPE, trace_pipe_get_uid, trace_pipe_get_id,\ + trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__) + #define pipe_info(pipe_p, __e, ...) \ - trace_dev_info(TRACE_CLASS_PIPE, trace_pipe_get_id, \ + trace_dev_info(TRACE_CLASS_PIPE, trace_pipe_get_uid, trace_pipe_get_id,\ trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__) #define pipe_dbg(pipe_p, __e, ...) \ - trace_dev_dbg(TRACE_CLASS_PIPE, trace_pipe_get_id, \ + trace_dev_dbg(TRACE_CLASS_PIPE, trace_pipe_get_uid, trace_pipe_get_id,\ trace_pipe_get_subid, pipe_p, __e, ##__VA_ARGS__) /* Pipeline status to stop execution of current path */ diff --git a/src/include/sof/lib/dai.h b/src/include/sof/lib/dai.h index 128764455fb0..8aedc9941cdc 100644 --- a/src/include/sof/lib/dai.h +++ b/src/include/sof/lib/dai.h @@ -100,6 +100,7 @@ struct timestamp_ops { struct dai_driver { uint32_t type; /**< type, one of SOF_DAI_... */ + uint32_t uid; uint32_t dma_caps; uint32_t dma_dev; struct dai_ops ops; @@ -152,32 +153,64 @@ struct dai_type_info { }; /* dai tracing */ +#define trace_dai_drv_get_uid(drv_p) ((drv_p)->uid) +#define trace_dai_drv_get_id(drv_p) (-1) +#define trace_dai_drv_get_subid(drv_p) (-1) + +#define trace_dai_get_uid(dai_p) ((dai_p)->drv->uid) #define trace_dai_get_id(dai_p) ((dai_p)->drv->type) #define trace_dai_get_subid(dai_p) ((dai_p)->index) /* class (driver) level (no device object) tracing */ -#define dai_cl_err(drv_p, __e, ...) \ - trace_error(TRACE_CLASS_DAI, __e, ##__VA_ARGS__) - -#define dai_cl_info(drv_p, __e, ...) \ - trace_event(TRACE_CLASS_DAI, __e, ##__VA_ARGS__) - -#define dai_cl_dbg(drv_p, __e, ...) \ - tracev_event(TRACE_CLASS_DAI, __e, ##__VA_ARGS__) +#define dai_cl_err(drv_p, __e, ...) \ + trace_dev_err(TRACE_CLASS_DAI, \ + trace_dai_drv_get_uid, \ + trace_dai_drv_get_id, \ + trace_dai_drv_get_subid, \ + drv_p, __e, ##__VA_ARGS__) + +#define dai_cl_warn(drv_p, __e, ...) \ + trace_dev_warn(TRACE_CLASS_DAI, \ + trace_dai_drv_get_uid, \ + trace_dai_drv_get_id, \ + trace_dai_drv_get_subid, \ + drv_p, __e, ##__VA_ARGS__) + +#define dai_cl_info(drv_p, __e, ...) \ + trace_dev_info(TRACE_CLASS_DAI, \ + trace_dai_drv_get_uid, \ + trace_dai_drv_get_id, \ + trace_dai_drv_get_subid, \ + drv_p, __e, ##__VA_ARGS__) + +#define dai_cl_dbg(drv_p, __e, ...) \ + trace_dev_dbg(TRACE_CLASS_DAI, \ + trace_dai_drv_get_uid, \ + trace_dai_drv_get_id, \ + trace_dai_drv_get_subid, \ + drv_p, __e, ##__VA_ARGS__) /* device tracing */ #define dai_err(dai_p, __e, ...) \ - trace_dev_err(TRACE_CLASS_DAI, trace_dai_get_id, \ + trace_dev_err(TRACE_CLASS_DAI, trace_dai_get_uid, \ + trace_dai_get_id, \ trace_dai_get_subid, dai_p, __e, ##__VA_ARGS__) +#define dai_warn(dai_p, __e, ...) \ + trace_dev_warn(TRACE_CLASS_DAI, trace_dai_get_uid, \ + trace_dai_get_id, \ + trace_dai_get_subid, dai_p, __e, ##__VA_ARGS__) + #define dai_info(dai_p, __e, ...) \ - trace_dev_info(TRACE_CLASS_DAI, trace_dai_get_id, \ + trace_dev_info(TRACE_CLASS_DAI, trace_dai_get_uid, \ + trace_dai_get_id, \ trace_dai_get_subid, dai_p, __e, ##__VA_ARGS__) #define dai_dbg(dai_p, __e, ...) \ - trace_dev_dbg(TRACE_CLASS_DAI, trace_dai_get_id, \ + trace_dev_dbg(TRACE_CLASS_DAI, trace_dai_get_uid, \ + trace_dai_get_id, \ trace_dai_get_subid, dai_p, __e, ##__VA_ARGS__) /** diff --git a/src/include/sof/lib/uuid.h b/src/include/sof/lib/uuid.h new file mode 100644 index 000000000000..a227930decc4 --- /dev/null +++ b/src/include/sof/lib/uuid.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2020 Intel Corporation. All rights reserved. + * + * Author: Marcin Maka + */ + +#ifndef __SOF_LIB_UUID_H__ +#define __SOF_LIB_UUID_H__ + +#include + +#define UUID_SIZE 16 + +/** + * \brief UUID (universally unique identifier) structure. + * + * Use DECLARE_SOF_UUID() to assigned UUID to the fw part (component + * implementation, dai implementation, ...). + * + * Use SOF_UUID() to store an address of declared UUID. + * + * See existing implementation of components and dais for examples how to + * UUIDs are declared and assigned to the drivers to provide identification + * of the source for their log entries. + */ +struct sof_uuid { + uint32_t a; + uint16_t b; + uint16_t c; + uint8_t d[8]; +}; + +#if CONFIG_LIBRARY +#define DECLARE_SOF_UUID(entity_name, uuid_name, \ + va, vb, vc, \ + vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7) + +#define SOF_UUID(uuid_name) 0 +#else +#define DECLARE_SOF_UUID(entity_name, uuid_name, \ + va, vb, vc, \ + vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7) \ + __attribute__((section(".static_uuids"))) \ + static const struct { \ + struct sof_uuid id; \ + uint32_t name_len; \ + const char name[sizeof(entity_name)]; \ + } uuid_name = { \ + {.a = va, .b = vb, .c = vc, \ + .d = {vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7}}, \ + sizeof(entity_name), \ + entity_name \ + } + +#define SOF_UUID(uuid_name) ((uintptr_t)&(uuid_name)) +#endif +#endif /* __SOF_LIB_UUID_H__ */ diff --git a/src/include/sof/trace/trace.h b/src/include/sof/trace/trace.h index 31b9a5088501..5da6b3c95db5 100644 --- a/src/include/sof/trace/trace.h +++ b/src/include/sof/trace/trace.h @@ -84,11 +84,12 @@ struct trace { extern int test_bench_trace; char *get_trace_class(uint32_t trace_class); -#define _log_message(mbox, atomic, level, comp_class, id_0, id_1, \ - has_ids, format, ...) \ +#define _log_message(mbox, atomic, level, comp_class, id_0, id_1, id_2, \ + format, ...) \ do { \ (void)id_0; \ (void)id_1; \ + (void)id_2; \ if (test_bench_trace) { \ char *msg = "%s " format; \ fprintf(stderr, msg, get_trace_class(comp_class), \ @@ -107,7 +108,7 @@ do { \ #define _TRACE_EVENT_NTH(postfix, param_count) \ META_FUNC_WITH_VARARGS( \ _trace_event, META_CONCAT(postfix, param_count),\ - void, _TRACE_EVENT_NTH_PARAMS(2, param_count) \ + void, _TRACE_EVENT_NTH_PARAMS(3, param_count) \ ) #define _TRACE_EVENT_NTH_DECLARE_GROUP(arg_count) \ @@ -184,8 +185,8 @@ static inline struct trace *trace_get(void) return sof_get()->trace; } -#define trace_unused(class, id_0, id_1, format, ...) \ - UNUSED(id_0, id_1, ##__VA_ARGS__) +#define trace_unused(class, id_0, id_1, id_2, format, ...) \ + UNUSED(id_0, id_1, id_2, ##__VA_ARGS__) #if CONFIG_TRACE @@ -208,16 +209,38 @@ static inline struct trace *trace_get(void) * image size. This way more elaborate log messages are possible and encouraged, * for better debugging experience, without worrying about runtime performance. */ -#define trace_event(class, format, ...) \ - _trace_event_with_ids(class, -1, -1, 0, format, ##__VA_ARGS__) -#define trace_event_atomic(class, format, ...) \ - _trace_event_atomic_with_ids(class, -1, -1, 0, format, ##__VA_ARGS__) +#define trace_event(class, format, ...) \ + _trace_event_with_ids(LOG_LEVEL_INFO, class, 0, -1, -1, \ + format, ##__VA_ARGS__) -#define trace_event_with_ids(class, id_0, id_1, format, ...) \ - _trace_event_with_ids(class, id_0, id_1, 1, format, ##__VA_ARGS__) -#define trace_event_atomic_with_ids(class, id_0, id_1, format, ...) \ - _trace_event_atomic_with_ids(class, id_0, id_1, 1, format, \ - ##__VA_ARGS__) +#define trace_event_atomic(class, format, ...) \ + _trace_event_atomic_with_ids(LOG_LEVEL_INFO, class, 0, -1, -1, \ + format, ##__VA_ARGS__) + +#define trace_event_with_ids(class, id_0, id_1, id_2, format, ...) \ + _trace_event_with_ids(LOG_LEVEL_INFO, class, id_0, id_1, id_2, \ + format, ##__VA_ARGS__) + +#define trace_event_atomic_with_ids(class, id_0, id_1, id_2, format, ...) \ + _trace_event_atomic_with_ids(LOG_LEVEL_INFO, class, id_0, id_1, id_2, \ + format, ##__VA_ARGS__) + +#define trace_warn(class, format, ...) \ + _trace_event_with_ids(LOG_LEVEL_WARNING, class, 0, -1, -1, \ + format, ##__VA_ARGS__) + +#define trace_warn_atomic(class, format, ...) \ + _trace_event_atomic_with_ids(LOG_LEVEL_WARNING, class, 0, -1, -1, \ + format, ##__VA_ARGS__) + +#define trace_warn_with_ids(class, id_0, id_1, id_2, format, ...) \ + _trace_event_with_ids(LOG_LEVEL_WARNING, class, id_0, id_1, id_2, \ + format, ##__VA_ARGS__) + +#define trace_warn_atomic_with_ids(class, id_0, id_1, id_2, format, ...) \ + _trace_event_atomic_with_ids(LOG_LEVEL_WARNING, class, \ + id_0, id_1, id_2, \ + format, ##__VA_ARGS__) #if CONFIG_TRACEM /* send all trace to mbox and local trace buffer */ @@ -226,23 +249,24 @@ static inline struct trace *trace_get(void) /* send trace events only to the local trace buffer */ #define __mbox #endif -#define _trace_event_with_ids(class, id_0, id_1, has_ids, format, ...) \ - _log_message(__mbox,, LOG_LEVEL_VERBOSE, class, id_0, id_1, \ - has_ids, format, ##__VA_ARGS__) -#define _trace_event_atomic_with_ids(class, id_0, id_1, has_ids, format, ...)\ - _log_message(__mbox, _atomic, LOG_LEVEL_VERBOSE, class, id_0, id_1, \ - has_ids, format, ##__VA_ARGS__) + +#define _trace_event_with_ids(lvl, class, id_0, id_1, id_2, format, ...) \ + _log_message(__mbox,, lvl, class, id_0, id_1, id_2, \ + format, ##__VA_ARGS__) + +#define _trace_event_atomic_with_ids(lvl, class, id_0, id_1, id_2, format, ...)\ + _log_message(__mbox, _atomic, lvl, class, id_0, id_1, \ + id_2, format, ##__VA_ARGS__) #define trace_point(x) platform_trace_point(x) #ifndef CONFIG_LIBRARY -#define _DECLARE_LOG_ENTRY(lvl, format, comp_class, params, ids)\ +#define _DECLARE_LOG_ENTRY(lvl, format, comp_class, params) \ __section(".static_log." #lvl) \ static const struct { \ uint32_t level; \ uint32_t component_class; \ - uint32_t has_ids; \ uint32_t params_num; \ uint32_t line_idx; \ uint32_t file_name_len; \ @@ -252,7 +276,6 @@ static inline struct trace *trace_get(void) } log_entry = { \ lvl, \ comp_class, \ - ids, \ params, \ __LINE__, \ sizeof(RELATIVE_FILE), \ @@ -265,47 +288,45 @@ static inline struct trace *trace_get(void) unsupported_amount_of_params_in_trace_event\ _thrown_from_macro_BASE_LOG_in_trace_h -#define BASE_LOG(function_name, id_0, id_1, entry, ...) \ -{ \ - STATIC_ASSERT( \ - _TRACE_EVENT_MAX_ARGUMENT_COUNT >= \ - META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ - BASE_LOG_ASSERT_FAIL_MSG \ - ); \ - META_CONCAT(function_name, \ - META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__)) \ - ((uint32_t)entry, id_0, id_1, ##__VA_ARGS__); \ +#define BASE_LOG(function_name, id_0, id_1, id_2, entry, ...) \ +{ \ + STATIC_ASSERT( \ + _TRACE_EVENT_MAX_ARGUMENT_COUNT >= \ + META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ + BASE_LOG_ASSERT_FAIL_MSG \ + ); \ + META_CONCAT(function_name, \ + META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__)) \ + ((uint32_t)entry, id_0, id_1, id_2, ##__VA_ARGS__); \ } -#define __log_message(func_name, lvl, comp_class, id_0, id_1, has_ids, \ - format, ...) \ -do { \ - _DECLARE_LOG_ENTRY(lvl, format, comp_class, \ - PP_NARG(__VA_ARGS__), has_ids); \ - BASE_LOG(func_name, id_0, id_1, &log_entry, ##__VA_ARGS__) \ +#define __log_message(func_name, lvl, comp_class, id_0, id_1, id_2, \ + format, ...) \ +do { \ + _DECLARE_LOG_ENTRY(lvl, format, comp_class, \ + PP_NARG(__VA_ARGS__)); \ + BASE_LOG(func_name, id_0, id_1, id_2, &log_entry, ##__VA_ARGS__) \ } while (0) -#define _log_message(mbox, atomic, level, comp_class, id_0, id_1, \ - has_ids, format, ...) \ - __log_message(META_CONCAT_SEQ(_trace_event, mbox, atomic), \ - level, comp_class, id_0, id_1, has_ids, format, \ +#define _log_message(mbox, atomic, level, comp_class, id_0, id_1, id_2, \ + format, ...) \ + __log_message(META_CONCAT_SEQ(_trace_event, mbox, atomic), \ + level, comp_class, id_0, id_1, id_2, format, \ ##__VA_ARGS__) #else -#define _DECLARE_LOG_ENTRY(lvl, format, comp_class, params, ids)\ +#define _DECLARE_LOG_ENTRY(lvl, format, comp_class, params) \ static const struct { \ uint32_t level; \ uint32_t component_class; \ - uint32_t has_ids; \ uint32_t params_num; \ uint32_t line_idx; \ uint32_t file_name_len; \ uint32_t text_len; \ - const char file_name[sizeof(RELATIVE_FILE)]; \ + const char file_name[sizeof(RELATIVE_FILE)]; \ const char text[sizeof(format)]; \ } log_entry = { \ lvl, \ comp_class, \ - ids, \ params, \ __LINE__, \ sizeof(RELATIVE_FILE), \ @@ -317,13 +338,22 @@ do { \ #else #define trace_event(class, format, ...) \ - trace_unused(class, -1, -1, format, ##__VA_ARGS__) -#define trace_event_with_ids(class, id_0, id_1, format, ...) \ - trace_unused(class, id_0, id_1, format, ##__VA_ARGS__) + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define trace_event_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) #define trace_event_atomic(class, format, ...) \ - trace_unused(class, -1, -1, format, ##__VA_ARGS__) -#define trace_event_atomic_with_ids(class, id_0, id_1, format, ...) \ - trace_unused(class, id_0, id_1, format, ##__VA_ARGS__) + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define trace_event_atomic_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) + +#define trace_warn(class, format, ...) \ + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define trace_warn_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) +#define trace_warn_atomic(class, format, ...) \ + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define trace_warn_atomic_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) #define trace_point(x) do {} while (0) @@ -331,32 +361,44 @@ do { \ /* verbose tracing */ #if CONFIG_TRACEV -#define tracev_event(...) trace_event(__VA_ARGS__) -#define tracev_event_with_ids(...) trace_event_with_ids(__VA_ARGS__) -#define tracev_event_atomic(...) trace_event_atomic(__VA_ARGS__) -#define tracev_event_atomic_with_ids(...) \ - trace_event_atomic_with_ids(__VA_ARGS__) +#define tracev_event(class, format, ...) \ + _trace_event_with_ids(LOG_LEVEL_VERBOSE, class, 0, -1, -1, \ + format, ##__VA_ARGS__) + +#define tracev_event_atomic(class, format, ...) \ + _trace_event_atomic_with_ids(LOG_LEVEL_VERBOSE, class, 0, -1, -1, \ + format, ##__VA_ARGS__) + +#define tracev_event_with_ids(class, id_0, id_1, id_2, format, ...) \ + _trace_event_with_ids(LOG_LEVEL_VERBOSE, class, id_0, id_1, id_2, \ + format, ##__VA_ARGS__) + +#define tracev_event_atomic_with_ids(class, id_0, id_1, id_2, format, ...) \ + _trace_event_atomic_with_ids(LOG_LEVEL_VERBOSE, class, \ + id_0, id_1, id_2, \ + format, ##__VA_ARGS__) + #else #define tracev_event(class, format, ...) \ - trace_unused(class, -1, -1, format, ##__VA_ARGS__) -#define tracev_event_with_ids(class, id_0, id_1, format, ...) \ - trace_unused(class, id_0, id_1, format, ##__VA_ARGS__) + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define tracev_event_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) #define tracev_event_atomic(class, format, ...) \ - trace_unused(class, -1, -1, format, ##__VA_ARGS__) -#define tracev_event_atomic_with_ids(class, id_0, id_1, format, ...) \ - trace_unused(class, id_0, id_1, format, ##__VA_ARGS__) + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define tracev_event_atomic_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) #endif /* error tracing */ #if CONFIG_TRACEE -#define _trace_error_with_ids(class, id_0, id_1, has_ids, format, ...) \ - _log_message(_mbox, _atomic, LOG_LEVEL_CRITICAL, class, id_0, \ - id_1, has_ids, format, ##__VA_ARGS__) +#define _trace_error_with_ids(class, id_0, id_1, id_2, format, ...) \ + _log_message(_mbox, _atomic, LOG_LEVEL_CRITICAL, class, id_0, id_1, \ + id_2, format, ##__VA_ARGS__) #define trace_error(class, format, ...) \ - _trace_error_with_ids(class, -1, -1, 0, format, ##__VA_ARGS__) -#define trace_error_with_ids(class, id_0, id_1, format, ...) \ - _trace_error_with_ids(class, id_0, id_1, 1, format, ##__VA_ARGS__) + _trace_error_with_ids(class, 0, -1, -1, format, ##__VA_ARGS__) +#define trace_error_with_ids(class, id_0, id_1, id_2, format, ...) \ + _trace_error_with_ids(class, id_0, id_1, id_2, format, ##__VA_ARGS__) #define trace_error_atomic(...) trace_error(__VA_ARGS__) #define trace_error_atomic_with_ids(...) trace_error_with_ids(__VA_ARGS__) #elif CONFIG_TRACE @@ -367,13 +409,13 @@ do { \ trace_event_atomic_with_ids(__VA_ARGS__) #else #define trace_error(class, format, ...) \ - trace_unused(class, -1, -1, format, ##__VA_ARGS__) -#define trace_error_with_ids(class, id_0, id_1, format, ...) \ - trace_unused(class, id_0, id_1, format, ##__VA_ARGS__) + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define trace_error_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) #define trace_error_atomic(class, format, ...) \ - trace_unused(class, -1, -1, format, ##__VA_ARGS__) -#define trace_error_atomic_with_ids(class, id_0, id_1, format, ...) \ - trace_unused(class, id_0, id_1, format, ##__VA_ARGS__) + trace_unused(class, 0, -1, -1, format, ##__VA_ARGS__) +#define trace_error_atomic_with_ids(class, id_0, id_1, id_2, format, ...) \ + trace_unused(class, id_0, id_1, id_2, format, ##__VA_ARGS__) #endif /* tracing from device (component, pipeline, dai, ...) */ @@ -386,18 +428,23 @@ do { \ * \param dev Device * \param fmt Format followed by parameters */ -#define trace_dev_err(class, get_id_m, get_subid_m, dev, fmt, ...) \ - trace_error_with_ids(class, get_id_m(dev), get_subid_m(dev), fmt, \ - ##__VA_ARGS__) +#define trace_dev_err(class, get_uid_m, get_id_m, get_subid_m, dev, fmt, ...) \ + trace_error_with_ids(class, get_uid_m(dev), get_id_m(dev), \ + get_subid_m(dev), fmt, ##__VA_ARGS__) + +/** \brief Trace from a device on warning level. */ +#define trace_dev_warn(class, get_uid_m, get_id_m, get_subid_m, dev, fmt, ...) \ + trace_warn_with_ids(class, get_uid_m(dev), get_id_m(dev), \ + get_subid_m(dev), fmt, ##__VA_ARGS__) /** \brief Trace from a device on info level. */ -#define trace_dev_info(class, get_id_m, get_subid_m, dev, fmt, ...) \ - trace_event_with_ids(class, get_id_m(dev), get_subid_m(dev), fmt, \ - ##__VA_ARGS__) +#define trace_dev_info(class, get_uid_m, get_id_m, get_subid_m, dev, fmt, ...) \ + trace_event_with_ids(class, get_uid_m(dev), get_id_m(dev), \ + get_subid_m(dev), fmt, ##__VA_ARGS__) /** \brief Trace from a device on dbg level. */ -#define trace_dev_dbg(class, get_id_m, get_subid_m, dev, fmt, ...) \ - tracev_event_with_ids(class, get_id_m(dev), get_subid_m(dev), fmt, \ - ##__VA_ARGS__) +#define trace_dev_dbg(class, get_uid_m, get_id_m, get_subid_m, dev, fmt, ...) \ + tracev_event_with_ids(class, get_uid_m(dev), get_id_m(dev), \ + get_subid_m(dev), fmt, ##__VA_ARGS__) #endif /* __SOF_TRACE_TRACE_H__ */ diff --git a/src/include/user/abi_dbg.h b/src/include/user/abi_dbg.h index 8c44ad5f7c7b..1563410c3edf 100644 --- a/src/include/user/abi_dbg.h +++ b/src/include/user/abi_dbg.h @@ -18,8 +18,8 @@ #ifndef __USER_ABI_DBG_H__ #define __USER_ABI_DBG_H__ -#define SOF_ABI_DBG_MAJOR 3 -#define SOF_ABI_DBG_MINOR 14 +#define SOF_ABI_DBG_MAJOR 4 +#define SOF_ABI_DBG_MINOR 2 #define SOF_ABI_DBG_PATCH 0 #define SOF_ABI_DBG_VERSION SOF_ABI_VER(SOF_ABI_DBG_MAJOR, \ diff --git a/src/include/user/trace.h b/src/include/user/trace.h index dc9c19901db9..b04996ab45d7 100644 --- a/src/include/user/trace.h +++ b/src/include/user/trace.h @@ -30,38 +30,38 @@ struct system_time { #define TRACE_CLASS_IRQ (1 << 24) #define TRACE_CLASS_IPC (2 << 24) #define TRACE_CLASS_PIPE (3 << 24) -#define TRACE_CLASS_HOST (4 << 24) +#define _TRACE_UNUSED_4 (4 << 24) #define TRACE_CLASS_DAI (5 << 24) #define TRACE_CLASS_DMA (6 << 24) -#define TRACE_CLASS_SSP (7 << 24) +#define _TRACE_UNUSED_7 (7 << 24) #define TRACE_CLASS_COMP (8 << 24) #define TRACE_CLASS_WAIT (9 << 24) #define TRACE_CLASS_LOCK (10 << 24) #define TRACE_CLASS_MEM (11 << 24) -#define TRACE_CLASS_MIXER (12 << 24) +#define _TRACE_UNUSED_12 (12 << 24) #define TRACE_CLASS_BUFFER (13 << 24) -#define TRACE_CLASS_VOLUME (14 << 24) -#define TRACE_CLASS_SWITCH (15 << 24) -#define TRACE_CLASS_MUX (16 << 24) -#define TRACE_CLASS_SRC (17 << 24) -#define TRACE_CLASS_TONE (18 << 24) -#define TRACE_CLASS_EQ_FIR (19 << 24) -#define TRACE_CLASS_EQ_IIR (20 << 24) +#define _TRACE_UNUSED_14 (14 << 24) +#define _TRACE_UNUSED_15 (15 << 24) +#define _TRACE_UNUSED_16 (16 << 24) +#define _TRACE_UNUSED_17 (17 << 24) +#define _TRACE_UNUSED_18 (18 << 24) +#define _TRACE_UNUSED_19 (19 << 24) +#define _TRACE_UNUSED_20 (20 << 24) #define TRACE_CLASS_SA (21 << 24) -#define TRACE_CLASS_DMIC (22 << 24) +#define _TRACE_UNUSED_22 (22 << 24) #define TRACE_CLASS_POWER (23 << 24) #define TRACE_CLASS_IDC (24 << 24) #define TRACE_CLASS_CPU (25 << 24) #define TRACE_CLASS_CLK (26 << 24) #define TRACE_CLASS_EDF (27 << 24) -#define TRACE_CLASS_KPB (28 << 24) -#define TRACE_CLASS_SELECTOR (29 << 24) +#define _TRACE_UNUSED_28 (28 << 24) +#define _TRACE_UNUSED_29 (29 << 24) #define TRACE_CLASS_SCHEDULE (30 << 24) #define TRACE_CLASS_SCHEDULE_LL (31 << 24) -#define TRACE_CLASS_ALH (32 << 24) -#define TRACE_CLASS_KEYWORD (33 << 24) +#define _TRACE_UNUSED_32 (32 << 24) +#define _TRACE_UNUSED_33 (33 << 24) #define TRACE_CLASS_CHMAP (34 << 24) -#define TRACE_CLASS_ASRC (35 << 24) +#define _TRACE_UNUSED_35 (35 << 24) #define TRACE_CLASS_NOTIFIER (36 << 24) #define TRACE_CLASS_MN (37 << 24) #define TRACE_CLASS_PROBE (38 << 24) @@ -70,7 +70,11 @@ struct system_time { #define LOG_DISABLE 0 /* Disable logging */ #define LOG_LEVEL_CRITICAL 1 /* (FDK fatal) */ -#define LOG_LEVEL_VERBOSE 2 +#define LOG_LEVEL_ERROR LOG_LEVEL_CRITICAL +#define LOG_LEVEL_WARNING 2 +#define LOG_LEVEL_INFO 3 +#define LOG_LEVEL_DEBUG 4 +#define LOG_LEVEL_VERBOSE LOG_LEVEL_DEBUG /* * Layout of a log fifo. @@ -97,12 +101,13 @@ struct log_buffer_status { * Number of arguments is specified by the params_num field of log_entry */ struct log_entry_header { - uint32_t id_0 : TRACE_ID_LENGTH; /* e.g. Pipeline ID */ - uint32_t id_1 : TRACE_ID_LENGTH; /* e.g. Component ID */ - uint32_t core_id : 8; /* Reporting core's id */ + uint32_t uid; + uint32_t id_0 : TRACE_ID_LENGTH; /* e.g. Pipeline ID */ + uint32_t id_1 : TRACE_ID_LENGTH; /* e.g. Component ID */ + uint32_t core_id : 8; /* Reporting core's id */ - uint64_t timestamp; /* Timestamp (in dsp ticks) */ - uint32_t log_entry_address; /* Address of log entry in ELF */ + uint64_t timestamp; /* Timestamp (in dsp ticks) */ + uint32_t log_entry_address; /* Address of log entry in ELF */ } __attribute__((packed)); #endif /* __USER_TRACE_H__ */ diff --git a/src/platform/apollolake/apollolake.x.in b/src/platform/apollolake/apollolake.x.in index 24e24bdbf6b3..e7ebbd14b613 100644 --- a/src/platform/apollolake/apollolake.x.in +++ b/src/platform/apollolake/apollolake.x.in @@ -101,7 +101,9 @@ MEMORY wnd3 : org = HP_SRAM_WIN3_BASE, len = HP_SRAM_WIN3_SIZE - + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -138,6 +140,7 @@ PHDRS wnd2_phdr PT_LOAD; wnd3_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; } @@ -578,6 +581,11 @@ SECTIONS KEEP (*(.gnu.linkonce.xt.profile_files.*)) } + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/apollolake/include/platform/lib/memory.h b/src/platform/apollolake/include/platform/lib/memory.h index 0b60b81be175..0f670df53ba6 100644 --- a/src/platform/apollolake/include/platform/lib/memory.h +++ b/src/platform/apollolake/include/platform/lib/memory.h @@ -116,6 +116,9 @@ #define L2_VECTOR_SIZE 0x1000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/baytrail/baytrail.x.in b/src/platform/baytrail/baytrail.x.in index 96cf98e6d4db..996b739114bd 100644 --- a/src/platform/baytrail/baytrail.x.in +++ b/src/platform/baytrail/baytrail.x.in @@ -102,6 +102,9 @@ MEMORY sof_stack : org = SOF_STACK_END, len = SOF_STACK_BASE - SOF_STACK_END + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -140,6 +143,7 @@ PHDRS runtime_heap_phdr PT_LOAD; buffer_heap_phdr PT_LOAD; sof_stack_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; } @@ -529,6 +533,11 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); } >sof_stack :sof_stack_phdr + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/baytrail/include/platform/lib/memory.h b/src/platform/baytrail/include/platform/lib/memory.h index aaeb9c4e79a4..e5c8ca0931f1 100644 --- a/src/platform/baytrail/include/platform/lib/memory.h +++ b/src/platform/baytrail/include/platform/lib/memory.h @@ -89,6 +89,9 @@ static inline void *platform_rfree_prepare(void *ptr) #define SSP5_BASE 0xFF2A6000 #define SSP5_SIZE 0x00001000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/cannonlake/cannonlake.x.in b/src/platform/cannonlake/cannonlake.x.in index 97513677ec33..54a9e3bc81b7 100644 --- a/src/platform/cannonlake/cannonlake.x.in +++ b/src/platform/cannonlake/cannonlake.x.in @@ -93,6 +93,9 @@ MEMORY wnd3 : org = HP_SRAM_WIN3_BASE, len = HP_SRAM_WIN3_SIZE + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -126,6 +129,7 @@ PHDRS wnd1_phdr PT_LOAD; wnd2_phdr PT_LOAD; wnd3_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; } @@ -542,6 +546,11 @@ SECTIONS KEEP (*(.gnu.linkonce.xt.profile_files.*)) } + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/cannonlake/include/platform/lib/memory.h b/src/platform/cannonlake/include/platform/lib/memory.h index 3cc3067c7739..830bc05a6dc2 100644 --- a/src/platform/cannonlake/include/platform/lib/memory.h +++ b/src/platform/cannonlake/include/platform/lib/memory.h @@ -124,6 +124,9 @@ #define L2_VECTOR_SIZE 0x1000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/haswell/haswell.x.in b/src/platform/haswell/haswell.x.in index e500115b68f9..3f9adaea9c95 100644 --- a/src/platform/haswell/haswell.x.in +++ b/src/platform/haswell/haswell.x.in @@ -108,6 +108,9 @@ MEMORY virtual_thread : org = SOF_VIRTUAL_THREAD_BASE, len = SOF_VIRTUAL_THREAD_SIZE + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -148,6 +151,7 @@ PHDRS mailbox_phdr PT_LOAD; virtual_thread_phdr PT_LOAD; sof_stack_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; } @@ -554,6 +558,11 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); } >sof_stack :sof_stack_phdr + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/haswell/include/platform/lib/memory.h b/src/platform/haswell/include/platform/lib/memory.h index e401b0dbca6c..6e66c75ab527 100644 --- a/src/platform/haswell/include/platform/lib/memory.h +++ b/src/platform/haswell/include/platform/lib/memory.h @@ -82,6 +82,9 @@ static inline void *platform_rfree_prepare(void *ptr) #endif +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/icelake/icelake.x.in b/src/platform/icelake/icelake.x.in index c865976ecd2e..bcf2243ae255 100644 --- a/src/platform/icelake/icelake.x.in +++ b/src/platform/icelake/icelake.x.in @@ -93,6 +93,9 @@ MEMORY wnd3 : org = HP_SRAM_WIN3_BASE, len = HP_SRAM_WIN3_SIZE + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -129,6 +132,7 @@ PHDRS wnd1_phdr PT_LOAD; wnd2_phdr PT_LOAD; wnd3_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; lpsram_mem_phdr PT_LOAD; } @@ -545,6 +549,11 @@ SECTIONS KEEP (*(.gnu.linkonce.xt.profile_files.*)) } + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/icelake/include/platform/lib/memory.h b/src/platform/icelake/include/platform/lib/memory.h index 723ac96750fd..9f01d2adbb04 100644 --- a/src/platform/icelake/include/platform/lib/memory.h +++ b/src/platform/icelake/include/platform/lib/memory.h @@ -124,6 +124,9 @@ #define L2_VECTOR_SIZE 0x1000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/imx8/imx8.x.in b/src/platform/imx8/imx8.x.in index bc8d412fac9c..b8ae0bd21ec0 100644 --- a/src/platform/imx8/imx8.x.in +++ b/src/platform/imx8/imx8.x.in @@ -90,6 +90,9 @@ MEMORY sof_sdram1 : org = SDRAM1_BASE, len = SDRAM1_SIZE + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -122,6 +125,7 @@ PHDRS runtime_heap_phdr PT_LOAD; buffer_heap_phdr PT_LOAD; sof_stack_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; } @@ -493,6 +497,11 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); } >sof_stack :sof_stack_phdr + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/imx8/include/platform/lib/memory.h b/src/platform/imx8/include/platform/lib/memory.h index ea72b4ffcc8c..09ab629b3b9c 100644 --- a/src/platform/imx8/include/platform/lib/memory.h +++ b/src/platform/imx8/include/platform/lib/memory.h @@ -45,6 +45,9 @@ #define SAI_1_BASE 0x59050000 #define SAI_1_SIZE 0x00010000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/imx8m/imx8m.x.in b/src/platform/imx8m/imx8m.x.in index c40e9fbde244..5652d28bb637 100644 --- a/src/platform/imx8m/imx8m.x.in +++ b/src/platform/imx8m/imx8m.x.in @@ -90,6 +90,9 @@ MEMORY sof_sdram1 : org = SDRAM1_BASE, len = SDRAM1_SIZE + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -122,6 +125,7 @@ PHDRS runtime_heap_phdr PT_LOAD; buffer_heap_phdr PT_LOAD; sof_stack_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; } @@ -493,6 +497,11 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); } >sof_stack :sof_stack_phdr + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/imx8m/include/platform/lib/memory.h b/src/platform/imx8m/include/platform/lib/memory.h index ab1be9781daf..0e2a30e6601a 100644 --- a/src/platform/imx8m/include/platform/lib/memory.h +++ b/src/platform/imx8m/include/platform/lib/memory.h @@ -42,6 +42,9 @@ #define SAI_3_BASE 0x30c30000 #define SAI_3_SIZE 0x00010000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/suecreek/include/platform/lib/memory.h b/src/platform/suecreek/include/platform/lib/memory.h index fe677ac309ca..53c12c049c12 100644 --- a/src/platform/suecreek/include/platform/lib/memory.h +++ b/src/platform/suecreek/include/platform/lib/memory.h @@ -148,6 +148,9 @@ #define L2_VECTOR_SIZE 0x2000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/suecreek/suecreek.x.in b/src/platform/suecreek/suecreek.x.in index 19ae3c7f1e62..4dc70396f48d 100644 --- a/src/platform/suecreek/suecreek.x.in +++ b/src/platform/suecreek/suecreek.x.in @@ -87,6 +87,9 @@ MEMORY sof_fw : org = SOF_FW_BASE, len = SOF_FW_MAX_SIZE, + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -118,6 +121,7 @@ PHDRS vector_double_lit_phdr PT_LOAD; vector_double_text_phdr PT_LOAD; sof_fw_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; } @@ -544,6 +548,11 @@ SECTIONS KEEP (*(.gnu.linkonce.xt.profile_files.*)) } + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index f9f60c888c71..f12d480555b3 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -124,6 +124,9 @@ #define L2_VECTOR_SIZE 0x1000 +#define UUID_ENTRY_ELF_BASE 0x1FFFA000 +#define UUID_ENTRY_ELF_SIZE 0x6000 + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 diff --git a/src/platform/tigerlake/tigerlake.x.in b/src/platform/tigerlake/tigerlake.x.in index dc0f31fab9f5..9880728ab384 100644 --- a/src/platform/tigerlake/tigerlake.x.in +++ b/src/platform/tigerlake/tigerlake.x.in @@ -96,6 +96,9 @@ MEMORY wnd3 : org = HP_SRAM_WIN3_BASE, len = HP_SRAM_WIN3_SIZE + static_uuid_entries_seg (!ari) : + org = UUID_ENTRY_ELF_BASE, + len = UUID_ENTRY_ELF_SIZE static_log_entries_seg (!ari) : org = LOG_ENTRY_ELF_BASE, len = LOG_ENTRY_ELF_SIZE @@ -133,6 +136,7 @@ PHDRS wnd1_phdr PT_LOAD; wnd2_phdr PT_LOAD; wnd3_phdr PT_LOAD; + static_uuid_entries_phdr PT_NOTE; static_log_entries_phdr PT_NOTE; lpsram_mem_phdr PT_LOAD; } @@ -557,6 +561,11 @@ SECTIONS KEEP (*(.gnu.linkonce.xt.profile_files.*)) } + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } > static_uuid_entries_seg :static_uuid_entries_phdr + .static_log_entries (COPY) : ALIGN(1024) { *(*.static_log*) diff --git a/src/trace/trace.c b/src/trace/trace.c index 144f8edabf9e..e2625090592a 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -37,15 +37,17 @@ #define TRACE_ID_MASK ((1 << TRACE_ID_LENGTH) - 1) -static void put_header(uint32_t *dst, uint32_t id_0, uint32_t id_1, +static void put_header(uint32_t *dst, uint32_t id_0, + uint32_t id_1, uint32_t id_2, uint32_t entry, uint64_t timestamp) { struct timer *timer = timer_get(); struct log_entry_header header; int ret; - header.id_0 = id_0 & TRACE_ID_MASK; - header.id_1 = id_1 & TRACE_ID_MASK; + header.uid = id_0; + header.id_0 = id_1 & TRACE_ID_MASK; + header.id_1 = id_2 & TRACE_ID_MASK; header.core_id = cpu_get_id(); header.timestamp = timestamp + timer->delta; header.log_entry_address = entry; @@ -112,7 +114,7 @@ META_IF_ELSE(is_atomic)(_atomic)() \ return; \ } \ \ - put_header(dt, id_0, id_1, log_entry, \ + put_header(dt, id_0, id_1, id_2, log_entry, \ platform_timer_get(timer_get())); \ \ _TRACE_EVENT_NTH_PAYLOAD_IMPL(arg_count) \ diff --git a/test/cmocka/include/mock_trace.h b/test/cmocka/include/mock_trace.h index de214819c07b..e59b7ad1386d 100644 --- a/test/cmocka/include/mock_trace.h +++ b/test/cmocka/include/mock_trace.h @@ -16,7 +16,7 @@ #define _TRACE_EVENT_NTH(postfix, param_count) \ META_FUNC_WITH_VARARGS( \ _trace_event, META_CONCAT(postfix, param_count),\ - void, _TRACE_EVENT_NTH_PARAMS(2, param_count) \ + void, _TRACE_EVENT_NTH_PARAMS(3, param_count) \ ) #define META_SEQ_STEP_void_param(i, _) (void)META_CONCAT(param,i); @@ -28,6 +28,7 @@ (void)log_entry; \ (void)id_0; \ (void)id_1; \ + (void)id_2; \ META_SEQ_FROM_0_TO(N, META_SEQ_STEP_void_param) \ } diff --git a/test/cmocka/memory_mock.x.in b/test/cmocka/memory_mock.x.in index fedd277e5608..8c70d5d14979 100644 --- a/test/cmocka/memory_mock.x.in +++ b/test/cmocka/memory_mock.x.in @@ -2,6 +2,10 @@ SECTIONS { + .static_uuid_entries (COPY) : ALIGN(1024) + { + *(*.static_uuids) + } .static_log_entries (COPY) : ALIGN(1024) { diff --git a/test/cmocka/src/debugability/macros.c b/test/cmocka/src/debugability/macros.c index 383277148e5e..e4f7af3c7c55 100644 --- a/test/cmocka/src/debugability/macros.c +++ b/test/cmocka/src/debugability/macros.c @@ -27,7 +27,6 @@ static void test_debugability_macros_declare_log_entry(void **state) LOG_LEVEL_CRITICAL, "Message", TRACE_CLASS_DMA, - 1, 1 )); const char *should_be_eq = @@ -37,7 +36,6 @@ static void test_debugability_macros_declare_log_entry(void **state) "{ " "uint32_t level; " "uint32_t component_class; " - "uint32_t has_ids; " "uint32_t params_num; " "uint32_t line_idx; " "uint32_t file_name_len; " @@ -48,8 +46,7 @@ static void test_debugability_macros_declare_log_entry(void **state) "1" "(6 << 24)" "1" - "1" - "32" + "31" "sizeof(\"" RELATIVE_FILE "\")" "sizeof(\"Message\")" "\"" RELATIVE_FILE "\"" @@ -89,7 +86,7 @@ static char *get_should_be(const int param_count) /*3*/param_count, /*4*/") ? 1 : -1]; _trace_event", /*5*/param_count, - /*6*/" ((uint32_t)&log_entry, 1, 1", + /*6*/" ((uint32_t)&log_entry, 0, 1, 1", /*7*/paramlist, /*8*/"); }" ); @@ -105,11 +102,11 @@ do { \ LOG_LEVEL_CRITICAL, \ "Message", \ TRACE_CLASS_DMA, \ - META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ - 1 \ + META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__) \ ); \ const char *macro_result = CAPTURE(BASE_LOG( \ _trace_event, \ + 0, \ 1, \ 1, \ &log_entry, \ diff --git a/tools/logger/convert.c b/tools/logger/convert.c index efb465dc7b3c..2733e725f45e 100644 --- a/tools/logger/convert.c +++ b/tools/logger/convert.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include "convert.h" @@ -22,11 +23,11 @@ #define TRACE_MAX_FILENAME_LEN 128 #define TRACE_MAX_IDS_STR 10 #define TRACE_IDS_MASK ((1 << TRACE_ID_LENGTH) - 1) +#define INVALID_TRACE_ID (-1 & TRACE_IDS_MASK) struct ldc_entry_header { uint32_t level; uint32_t component_class; - uint32_t has_ids; uint32_t params_num; uint32_t line_idx; uint32_t file_name_len; @@ -40,6 +41,89 @@ struct ldc_entry { uint32_t *params; }; +struct proc_ldc_entry { + int subst_mask; + struct ldc_entry_header header; + char *file_name; + char *text; + uintptr_t params[TRACE_MAX_PARAMS_COUNT]; +}; + +static const char *BAD_PTR_STR = ""; + +const char *format_uid(const struct snd_sof_uids_header *uids_dict, + uint32_t uid_ptr, + int use_colors) +{ + char *str; + + if (uid_ptr < uids_dict->base_address || + uid_ptr >= uids_dict->base_address + uids_dict->data_length) { + str = calloc(1, strlen(BAD_PTR_STR) + 1 + 6); + sprintf(str, BAD_PTR_STR, uid_ptr); + } else { + const struct sof_uuid *uid_val = (const struct sof_uuid *) + ((uint8_t *)uids_dict + uids_dict->data_offset + + uid_ptr - uids_dict->base_address); + + str = calloc(1, (use_colors ? strlen(KBLU) : 0) + 1 + + 36 + 1 + *(uint32_t *)(uid_val + 1) + 1 + + (use_colors ? strlen(KNRM) : 0)); + sprintf(str, "%s%s <%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x>%s", + use_colors ? KBLU : "", + (const char *)(uid_val + 1) + 4, + uid_val->a, uid_val->b, uid_val->c, + uid_val->d[0], uid_val->d[1], uid_val->d[2], + uid_val->d[3], uid_val->d[4], uid_val->d[5], + uid_val->d[6], uid_val->d[7], + use_colors ? KNRM : ""); + } + return str; +} + +static void process_params(struct proc_ldc_entry *pe, + const struct ldc_entry *e, + const struct snd_sof_uids_header *uids_dict, + int use_colors) +{ + const char *p = e->text; + const char *t_end = p + strlen(e->text); + unsigned int par_bit = 1; + int i; + + pe->subst_mask = 0; + pe->header = e->header; + pe->file_name = e->file_name; + pe->text = e->text; + + /* scan the text for possible replacements */ + while ((p = strchr(p, '%'))) { + if (p < t_end - 1 && *(p + 1) == 's') + pe->subst_mask += par_bit; + par_bit <<= 1; + ++p; + } + + for (i = 0; i < e->header.params_num; i++) { + pe->params[i] = e->params[i]; + if (pe->subst_mask & (1 << i)) + pe->params[i] = (uintptr_t)format_uid(uids_dict, + e->params[i], + use_colors); + } +} + +static void free_proc_ldc_entry(struct proc_ldc_entry *pe) +{ + int i; + + for (i = 0; i < TRACE_MAX_PARAMS_COUNT; i++) { + if (pe->subst_mask & (1 << i)) + free((void *)pe->params[i]); + pe->params[i] = 0; + } +} + static double to_usecs(uint64_t time, double clk) { /* trace timestamp uses CPU system clock at default 25MHz ticks */ @@ -50,14 +134,8 @@ static double to_usecs(uint64_t time, double clk) static inline void print_table_header(FILE *out_fd) { - fprintf(out_fd, "%5s %6s %12s %7s %16s %16s %24s\t%s\n", - "CORE", - "LEVEL", - "COMP_ID", - "", - "TIMESTAMP", - "DELTA", - "FILE_NAME", + fprintf(out_fd, "%18s %18s %2s %-18s %-29s %s\n", + "TIMESTAMP", "DELTA", "C#", "COMPONENT", "LOCATION", "CONTENT"); fflush(out_fd); } @@ -65,43 +143,68 @@ static inline void print_table_header(FILE *out_fd) #define CASE(x) \ case(TRACE_CLASS_##x): return #x -static const char * get_component_name(uint32_t component_id) { - switch (component_id) { +static const char *get_level_color(uint32_t level) +{ + switch (level) { + case LOG_LEVEL_CRITICAL: + return KRED; + case LOG_LEVEL_WARNING: + return KYEL; + default: + return KNRM; + } +} + +static const char *get_level_name(uint32_t level) +{ + switch (level) { + case LOG_LEVEL_CRITICAL: + return "ERROR "; + case LOG_LEVEL_WARNING: + return "WARN "; + default: + return ""; /* info is usual, do not print anything */ + } +} + +static +const char *get_component_name(const struct snd_sof_uids_header *uids_dict, + uint32_t trace_class, uint32_t uid_ptr) +{ + /* if uid_ptr is non-zero, find name in the ldc file */ + if (uid_ptr) { + if (uid_ptr < uids_dict->base_address || + uid_ptr >= uids_dict->base_address + + uids_dict->data_length) + return ""; + const struct sof_uuid *uid_val = (const struct sof_uuid *) + ((uint8_t *)uids_dict + uids_dict->data_offset + + uid_ptr - uids_dict->base_address); + + return (const char *)(uid_val + 1) + sizeof(uint32_t); + } + + /* otherwise print legacy trace class name */ + switch (trace_class) { CASE(IRQ); CASE(IPC); CASE(PIPE); - CASE(HOST); CASE(DAI); CASE(DMA); - CASE(SSP); CASE(COMP); CASE(WAIT); CASE(LOCK); CASE(MEM); - CASE(MIXER); CASE(BUFFER); - CASE(VOLUME); - CASE(SWITCH); - CASE(MUX); - CASE(SRC); - CASE(TONE); - CASE(EQ_FIR); - CASE(EQ_IIR); CASE(SA); - CASE(DMIC); CASE(POWER); CASE(IDC); CASE(CPU); CASE(CLK); CASE(EDF); - CASE(KPB); - CASE(SELECTOR); CASE(SCHEDULE); CASE(SCHEDULE_LL); - CASE(ALH); - CASE(KEYWORD); CASE(CHMAP); - CASE(ASRC); CASE(NOTIFIER); CASE(MN); CASE(PROBE); @@ -120,63 +223,116 @@ static char *format_file_name(char *file_name_raw, int full_name) if (!name) name = file_name_raw; - /* keep the last 20 chars */ - if (!full_name) { - len = strlen(name); - if (len > 20) - name += (len - 20); + if (full_name) + return name; + /* keep the last 24 chars */ + len = strlen(name); + if (len > 24) { + char *sep_pos = NULL; + + name += (len - 24); + sep_pos = strchr(name, '/'); + if (!sep_pos) + return name; + while (--sep_pos >= name) + *sep_pos = '.'; } return name; } static void print_entry_params(FILE *out_fd, + const struct snd_sof_uids_header *uids_dict, const struct log_entry_header *dma_log, const struct ldc_entry *entry, uint64_t last_timestamp, double clock, int use_colors, int raw_output) { char ids[TRACE_MAX_IDS_STR]; float dt = to_usecs(dma_log->timestamp - last_timestamp, clock); - const char *entry_fmt = raw_output ? - "%s%u %u %s%s%s %.6f %.6f (%s:%u) " : - "%s%5u %6u %12s%s %-7s %16.6f %16.6f %20s:%-4u\t"; + struct proc_ldc_entry proc_entry; + + if (raw_output) + use_colors = 0; if (dt < 0 || dt > 1000.0 * 1000.0 * 1000.0) dt = NAN; - if (entry->header.has_ids) + if (dma_log->id_0 != INVALID_TRACE_ID && + dma_log->id_1 != INVALID_TRACE_ID) sprintf(ids, "%d.%d", (dma_log->id_0 & TRACE_IDS_MASK), (dma_log->id_1 & TRACE_IDS_MASK)); - fprintf(out_fd, entry_fmt, - entry->header.level == use_colors ? - (LOG_LEVEL_CRITICAL ? KRED : KNRM) : "", - dma_log->core_id, - entry->header.level, - get_component_name(entry->header.component_class), - raw_output && entry->header.has_ids ? "-" : "", - entry->header.has_ids ? ids : "", - to_usecs(dma_log->timestamp, clock), - dt, - format_file_name(entry->file_name, raw_output), - entry->header.line_idx); - - switch (entry->header.params_num) { + else + ids[0] = '\0'; + + if (raw_output) { + const char *entry_fmt = "%s%u %u %s%s%s %.6f %.6f (%s:%u) "; + + fprintf(out_fd, entry_fmt, + entry->header.level == use_colors ? + (LOG_LEVEL_CRITICAL ? KRED : KNRM) : "", + dma_log->core_id, + entry->header.level, + get_component_name(uids_dict, + entry->header.component_class, + dma_log->uid), + raw_output && strlen(ids) ? "-" : "", + ids, + to_usecs(dma_log->timestamp, clock), + dt, + format_file_name(entry->file_name, raw_output), + entry->header.line_idx); + } else { + /* timestamp */ + fprintf(out_fd, "%s[%16.6f] (%16.6f)%s ", + use_colors ? KGRN : "", + to_usecs(dma_log->timestamp, clock), dt, + use_colors ? KNRM : ""); + + /* core id */ + fprintf(out_fd, "c%d ", dma_log->core_id); + + /* component name and id */ + fprintf(out_fd, "%s%-12s %-5s%s ", + use_colors ? KYEL : "", + get_component_name(uids_dict, + entry->header.component_class, + dma_log->uid), + ids, + use_colors ? KNRM : ""); + + /* location */ + fprintf(out_fd, "%24s:%-4u ", + format_file_name(entry->file_name, raw_output), + entry->header.line_idx); + + /* level name */ + fprintf(out_fd, "%s%s", + use_colors ? get_level_color(entry->header.level) : "", + get_level_name(entry->header.level)); + } + + process_params(&proc_entry, entry, uids_dict, use_colors); + + switch (proc_entry.header.params_num) { case 0: - fprintf(out_fd, "%s", entry->text); + fprintf(out_fd, "%s", proc_entry.text); break; case 1: - fprintf(out_fd, entry->text, entry->params[0]); + fprintf(out_fd, proc_entry.text, proc_entry.params[0]); break; case 2: - fprintf(out_fd, entry->text, entry->params[0], entry->params[1]); + fprintf(out_fd, proc_entry.text, proc_entry.params[0], + proc_entry.params[1]); break; case 3: - fprintf(out_fd, entry->text, entry->params[0], entry->params[1], - entry->params[2]); + fprintf(out_fd, proc_entry.text, proc_entry.params[0], + proc_entry.params[1], proc_entry.params[2]); break; case 4: - fprintf(out_fd, entry->text, entry->params[0], entry->params[1], - entry->params[2], entry->params[3]); + fprintf(out_fd, proc_entry.text, proc_entry.params[0], + proc_entry.params[1], proc_entry.params[2], + proc_entry.params[3]); break; } + free_proc_ldc_entry(&proc_entry); fprintf(out_fd, "%s\n", use_colors ? KNRM : ""); fflush(out_fd); } @@ -288,8 +444,11 @@ static int fetch_entry(const struct convert_config *config, } /* printing entry content */ - print_entry_params(config->out_fd, dma_log, &entry, *last_timestamp, - config->clock, config->use_colors, config->raw_output); + print_entry_params(config->out_fd, + config->uids_dict, + dma_log, &entry, *last_timestamp, + config->clock, config->use_colors, + config->raw_output); *last_timestamp = dma_log->timestamp; /* set f_ldc file position to the beginning */ @@ -411,8 +570,53 @@ static int logger_read(const struct convert_config *config, return ret; } -int convert(const struct convert_config *config) { +/* fw verification */ +static int verify_fw_ver(const struct convert_config *config, + const struct snd_sof_logs_header *snd) +{ + struct sof_ipc_fw_version ver; + int count, ret = 0; + + if (!config->version_fd) + return 0; + + /* here fw verification should be exploited */ + count = fread(&ver, sizeof(ver), 1, config->version_fd); + if (!count) { + fprintf(stderr, "Error while reading %s.\n", + config->version_file); + return -ferror(config->version_fd); + } + + ret = memcmp(&ver, &snd->version, sizeof(struct sof_ipc_fw_version)); + if (ret) { + fprintf(stderr, "Error: fw version in %s file does not coincide with fw version in %s file.\n", + config->ldc_file, config->version_file); + return -EINVAL; + } + + /* logger and version_file abi dbg verification */ + if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_DBG_VERSION, + ver.abi_version)) { + fprintf(stderr, "Error: abi version in %s file does not coincide with abi version used by logger.\n", + config->version_file); + fprintf(stderr, "logger ABI Version is %d:%d:%d\n", + SOF_ABI_VERSION_MAJOR(SOF_ABI_DBG_VERSION), + SOF_ABI_VERSION_MINOR(SOF_ABI_DBG_VERSION), + SOF_ABI_VERSION_PATCH(SOF_ABI_DBG_VERSION)); + fprintf(stderr, "version_file ABI Version is %d:%d:%d\n", + SOF_ABI_VERSION_MAJOR(ver.abi_version), + SOF_ABI_VERSION_MINOR(ver.abi_version), + SOF_ABI_VERSION_PATCH(ver.abi_version)); + return -EINVAL; + } + return 0; +} + +int convert(struct convert_config *config) +{ struct snd_sof_logs_header snd; + struct snd_sof_uids_header uids_hdr; int count, ret = 0; count = fread(&snd, sizeof(snd), 1, config->ldc_fd); @@ -426,42 +630,9 @@ int convert(const struct convert_config *config) { return -EINVAL; } - /* fw verification */ - if (config->version_fd) { - struct sof_ipc_fw_version ver; - - /* here fw verification should be exploited */ - count = fread(&ver, sizeof(ver), 1, config->version_fd); - if (!count) { - fprintf(stderr, "Error while reading %s. \n", config->version_file); - return -ferror(config->version_fd); - } - - ret = memcmp(&ver, &snd.version, sizeof(struct sof_ipc_fw_version)); - if (ret) { - fprintf(stderr, "Error: fw version in %s file " - "does not coincide with fw version in " - "%s file. \n", config->ldc_file, config->version_file); - return -EINVAL; - } - - /* logger and version_file abi dbg verification */ - if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_DBG_VERSION, - ver.abi_version)) { - fprintf(stderr, "Error: abi version in %s file " - "does not coincide with abi version used " - "by logger.\n", config->version_file); - fprintf(stderr, "logger ABI Version is %d:%d:%d\n", - SOF_ABI_VERSION_MAJOR(SOF_ABI_DBG_VERSION), - SOF_ABI_VERSION_MINOR(SOF_ABI_DBG_VERSION), - SOF_ABI_VERSION_PATCH(SOF_ABI_DBG_VERSION)); - fprintf(stderr, "version_file ABI Version is %d:%d:%d\n", - SOF_ABI_VERSION_MAJOR(ver.abi_version), - SOF_ABI_VERSION_MINOR(ver.abi_version), - SOF_ABI_VERSION_PATCH(ver.abi_version)); - return -EINVAL; - } - } + ret = verify_fw_ver(config, &snd); + if (ret) + return ret; /* default logger and ldc_file abi verification */ if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_DBG_VERSION, @@ -479,5 +650,32 @@ int convert(const struct convert_config *config) { SOF_ABI_VERSION_PATCH(snd.version.abi_version)); return -EINVAL; } + + /* read uuid section header */ + fseek(config->ldc_fd, snd.data_offset + snd.data_length, SEEK_SET); + count = fread(&uids_hdr, sizeof(uids_hdr), 1, config->ldc_fd); + if (!count) { + fprintf(stderr, "Error while reading uuids header from %s.\n", + config->ldc_file); + return -ferror(config->ldc_fd); + } + if (strncmp((char *)uids_hdr.sig, SND_SOF_UIDS_SIG, + SND_SOF_UIDS_SIG_SIZE)) { + fprintf(stderr, "Error: invalid uuid section signature.\n"); + return -EINVAL; + } + config->uids_dict = calloc(1, sizeof(uids_hdr) + uids_hdr.data_length); + if (!config->uids_dict) { + fprintf(stderr, "Error: failed to alloc memory for uuids.\n"); + return -ENOMEM; + } + memcpy(config->uids_dict, &uids_hdr, sizeof(uids_hdr)); + count = fread(config->uids_dict + 1, uids_hdr.data_length, 1, + config->ldc_fd); + if (!count) { + fprintf(stderr, "Error: failed to read uuid section data.\n"); + return -ferror(config->ldc_fd); + } + return logger_read(config, &snd); } diff --git a/tools/logger/convert.h b/tools/logger/convert.h index 52d07b39cf27..bd82d5add3e9 100644 --- a/tools/logger/convert.h +++ b/tools/logger/convert.h @@ -16,6 +16,9 @@ #define KNRM "\x1B[0m" #define KRED "\x1B[31m" +#define KGRN "\x1B[32m" +#define KYEL "\x1B[33m" +#define KBLU "\x1B[34m" struct convert_config { const char *out_file; @@ -33,6 +36,7 @@ struct convert_config { int use_colors; int serial_fd; int raw_output; + struct snd_sof_uids_header *uids_dict; }; -int convert(const struct convert_config *config); +int convert(struct convert_config *config); diff --git a/tools/testbench/trace.c b/tools/testbench/trace.c index 12f767600da3..9e07432db5b4 100644 --- a/tools/testbench/trace.c +++ b/tools/testbench/trace.c @@ -24,38 +24,22 @@ char *get_trace_class(uint32_t trace_class) CASE(IRQ); CASE(IPC); CASE(PIPE); - CASE(HOST); CASE(DAI); CASE(DMA); - CASE(SSP); CASE(COMP); CASE(WAIT); CASE(LOCK); CASE(MEM); - CASE(MIXER); CASE(BUFFER); - CASE(VOLUME); - CASE(SWITCH); - CASE(MUX); - CASE(SRC); - CASE(TONE); - CASE(EQ_FIR); - CASE(EQ_IIR); CASE(SA); - CASE(DMIC); CASE(POWER); CASE(IDC); CASE(CPU); CASE(CLK); CASE(EDF); - CASE(KPB); - CASE(SELECTOR); CASE(SCHEDULE); CASE(SCHEDULE_LL); - CASE(ALH); - CASE(KEYWORD); CASE(CHMAP); - CASE(ASRC); CASE(NOTIFIER); CASE(MN); CASE(PROBE);