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
1 change: 1 addition & 0 deletions src/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_local_sources(tb_common
schedule.c
edf_schedule.c
ll_schedule.c
panic.c
topology.c
trace.c
)
Expand Down
33 changes: 33 additions & 0 deletions src/host/panic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2019, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Intel Corporation nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Author: Tomasz Lauda <tomasz.lauda@linux.intel.com>
*/

#include <sof/panic.h>

void __panic(uint32_t p, char *filename, uint32_t linenum) { }
30 changes: 22 additions & 8 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp);
*/
static inline void comp_free(struct comp_dev *dev)
{
assert(dev->drv->ops.free);

dev->drv->ops.free(dev);
}

Expand Down Expand Up @@ -369,13 +371,15 @@ void comp_set_period_bytes(struct comp_dev *dev, uint32_t frames,
enum sof_ipc_frame *format, uint32_t *period_bytes);

/**
* Component parameter init - mandatory.
* Component parameter init.
* @param dev Component device.
* @return 0 if succeeded, error code otherwise.
*/
static inline int comp_params(struct comp_dev *dev)
{
return dev->drv->ops.params(dev);
if (dev->drv->ops.params)
return dev->drv->ops.params(dev);
return 0;
}

/**
Expand All @@ -395,7 +399,7 @@ static inline int comp_host_buffer(struct comp_dev *dev,
}

/**
* Send component command (mandatory).
* Send component command.
* @param dev Component device.
* @param cmd Command.
* @param data Command data.
Expand All @@ -416,7 +420,9 @@ static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data,
return -EINVAL;
}

return dev->drv->ops.cmd(dev, cmd, data, max_data_size);
if (dev->drv->ops.cmd)
return dev->drv->ops.cmd(dev, cmd, data, max_data_size);
return -EINVAL;
}

/**
Expand All @@ -427,17 +433,21 @@ static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data,
*/
static inline int comp_trigger(struct comp_dev *dev, int cmd)
{
assert(dev->drv->ops.trigger);

return dev->drv->ops.trigger(dev, cmd);
}

/**
* Prepare component - mandatory.
* Prepare component.
* @param dev Component device.
* @return 0 if succeeded, error code otherwise.
*/
static inline int comp_prepare(struct comp_dev *dev)
{
return dev->drv->ops.prepare(dev);
if (dev->drv->ops.prepare)
return dev->drv->ops.prepare(dev);
return 0;
}

/**
Expand All @@ -447,17 +457,21 @@ static inline int comp_prepare(struct comp_dev *dev)
*/
static inline int comp_copy(struct comp_dev *dev)
{
assert(dev->drv->ops.copy);

return dev->drv->ops.copy(dev);
}

/**
* Component reset and free runtime resources -mandatory.
* Component reset and free runtime resources.
* @param dev Component device.
* @return 0 if succeeded, error code otherwise.
*/
static inline int comp_reset(struct comp_dev *dev)
{
return dev->drv->ops.reset(dev);
if (dev->drv->ops.reset)
return dev->drv->ops.reset(dev);
return 0;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/include/sof/sof.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <stdint.h>
#include <stddef.h>
#include <arch/sof.h>
#include <sof/panic.h>
#include <sof/preproc.h>

struct ipc;
Expand All @@ -56,6 +57,9 @@ struct sa;
__attribute__((unused)) \
typedef char META_CONCAT(assertion_failed_, MESSAGE)[(COND) ? 1 : -1]

/* runtime assertion */
#define assert(cond) (void)((cond) || (panic(SOF_IPC_PANIC_ASSERT), 0))

/* general firmware context */
struct sof {
/* init data */
Expand Down
2 changes: 1 addition & 1 deletion src/include/uapi/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

/** \brief SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
#define SOF_ABI_MINOR 3
#define SOF_ABI_MINOR 4
#define SOF_ABI_PATCH 0

/** \brief SOF ABI version number. Format within 32bit word is MMmmmppp */
Expand Down
1 change: 1 addition & 0 deletions src/include/uapi/ipc/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct sof_ipc_dma_trace_posn {
#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 0x8)
#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 0x9)
#define SOF_IPC_PANIC_WFI (SOF_IPC_PANIC_MAGIC | 0xa)
#define SOF_IPC_PANIC_ASSERT (SOF_IPC_PANIC_MAGIC | 0xb)

/* panic info include filename and line number */
struct sof_ipc_panic_info {
Expand Down
7 changes: 7 additions & 0 deletions test/cmocka/src/audio/pipeline/pipeline_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,10 @@ void heap_trace_all(int force)
{
(void)force;
}

void __panic(uint32_t p, char *filename, uint32_t linenum)
{
(void)p;
(void)filename;
(void)linenum;
}