Skip to content

Commit

Permalink
module: Move system_service header to module directory
Browse files Browse the repository at this point in the history
Move definitions of functions exposed by system_service to the modules
directory so that loadable modules can use them.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
  • Loading branch information
softwarecki committed Aug 20, 2024
1 parent dbc17cb commit db28a6e
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 166 deletions.
28 changes: 2 additions & 26 deletions src/audio/module_adapter/iadk/system_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
#include <rtos/string.h>
#include <utilities/array.h>
#include <module/iadk/adsp_error_code.h>
#include <native_system_service.h>
#include <system_service.h>
#include <system_agent_interface.h>
#include <module_initial_settings_concrete.h>
#include <iadk_module_adapter.h>
#include <system_agent.h>
#include <sof/audio/module_adapter/library/native_system_service.h>

using namespace intel_adsp;
using namespace intel_adsp::system;
Expand All @@ -30,31 +31,6 @@ void* operator new(size_t size, intel_adsp::ModuleHandle *placeholder) throw()
return placeholder;
}

extern "C" {
void native_system_service_log_message (AdspLogPriority log_priority, uint32_t log_entry,
AdspLogHandle const* log_handle, uint32_t param1,
uint32_t param2, uint32_t param3, uint32_t param4);

AdspErrorCode native_system_service_safe_memcpy(void *RESTRICT dst, size_t maxlen,
const void *RESTRICT src, size_t len);

AdspErrorCode native_system_service_safe_memmove(void *dst, size_t maxlen,
const void *src, size_t len);

void *native_system_service_vec_memset(void *dst, int c, size_t len);

AdspErrorCode native_system_service_create_notification(notification_params *params,
uint8_t *notification_buffer,
uint32_t notification_buffer_size,
adsp_notification_handle *handle);

AdspErrorCode native_system_service_send_notif_msg(adsp_notification_target notification_target,
adsp_notification_handle message,
uint32_t actual_payload_size);

AdspErrorCode native_system_service_get_interface(adsp_iface_id id, system_service_iface **iface);
}

namespace intel_adsp
{
namespace system
Expand Down
37 changes: 21 additions & 16 deletions src/audio/module_adapter/library/native_system_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright(c) 2020 Intel Corporation. All rights reserved.
*
* Author: Jaroslaw Stelter <jaroslaw.stelter@linux.intel.com>
* Adrian Warecki <adrian.warecki@intel.com>
*/
/*
* Native System Service interface for ADSP loadable library.
Expand Down Expand Up @@ -50,8 +51,8 @@ static int log_priority_to_sof_level(enum log_priority log_priority)
return log_priority_map[log_priority];
}

void native_system_service_log_message(AdspLogPriority log_priority, uint32_t log_entry,
AdspLogHandle const *log_handle, uint32_t param1,
void native_system_service_log_message(enum log_priority log_priority, uint32_t log_entry,
struct log_handle const *log_handle, uint32_t param1,
uint32_t param2, uint32_t param3, uint32_t param4)
{
log_priority_to_sof_level(log_priority);
Expand Down Expand Up @@ -113,10 +114,10 @@ void *native_system_service_vec_memset(void *dst, int c, size_t len)
return dst;
}

AdspErrorCode native_system_service_create_notification(notification_params *params,
AdspErrorCode native_system_service_create_notification(struct notification_params *params,
uint8_t *notification_buffer,
uint32_t notification_buffer_size,
adsp_notification_handle *handle)
struct notification_handle **handle)
{
if ((params == NULL) || (notification_buffer == NULL)
|| (notification_buffer_size <= 0) || (handle == NULL))
Expand All @@ -132,15 +133,16 @@ AdspErrorCode native_system_service_create_notification(notification_params *par
struct ipc_msg *msg = lib_notif_msg_init((uint32_t)header.dat, notification_buffer_size);

if (msg) {
*handle = (adsp_notification_handle)msg;
*handle = (struct notification_handle *)msg;
params->payload = msg->tx_data;
}

return ADSP_NO_ERROR;
}

AdspErrorCode native_system_service_send_notif_msg(adsp_notification_target notification_target,
adsp_notification_handle message,

AdspErrorCode native_system_service_send_notif_msg(enum notification_target notification_target,
struct notification_handle *message,
uint32_t actual_payload_size)
{
if ((message == NULL) || (actual_payload_size == 0))
Expand All @@ -152,19 +154,22 @@ AdspErrorCode native_system_service_send_notif_msg(adsp_notification_target noti
return ADSP_NO_ERROR;
}

AdspErrorCode native_system_service_get_interface(adsp_iface_id id, system_service_iface **iface)
AdspErrorCode native_system_service_get_interface(enum interface_id id,
struct system_service_iface **iface)
{
if (id < 0)
return ADSP_INVALID_PARAMETERS;
return ADSP_NO_ERROR;
}

const struct native_system_service_api native_system_service = {
.log_message = native_system_service_log_message,
.safe_memcpy = native_system_service_safe_memcpy,
.safe_memmove = native_system_service_safe_memmove,
.vec_memset = native_system_service_vec_memset,
.notification_create = native_system_service_create_notification,
.notification_send = native_system_service_send_notif_msg,
.get_interface = native_system_service_get_interface
const struct native_system_service native_system_service = {
.basic = {
.log_message = native_system_service_log_message,
.safe_memcpy = native_system_service_safe_memcpy,
.safe_memmove = native_system_service_safe_memmove,
.vec_memset = native_system_service_vec_memset,
.notification_create = native_system_service_create_notification,
.notification_send = native_system_service_send_notif_msg,
.get_interface = native_system_service_get_interface
}
};
113 changes: 113 additions & 0 deletions src/include/module/module/system_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright(c) 2024 Intel Corporation. All rights reserved.
*
* Author: Adrian Warecki <adrian.warecki@intel.com>
*/

#ifndef MODULE_MODULE_SYSTEM_SERVICE_H
#define MODULE_MODULE_SYSTEM_SERVICE_H

#include <stdint.h>
#include <stddef.h>

#include "logger.h"
#include "../iadk/adsp_error_code.h"

#ifdef __XTENSA__
#define RESTRICT __restrict
#else
#define RESTRICT
#endif

/*! This struct defines the obfuscating type for notifications. */
struct notification_handle;

/* Defines parameters used by ADSP system during notification creation. */
struct notification_params {
uint32_t type; /*!< Notification type */
uint16_t user_val_1; /*!< 16 bits user value available directly in IPC header
* for some notifications
*/
uint32_t user_val_2; /*!< 30 bits user value available directly in IPC header
* for some notifications
*/
uint32_t max_payload_size; /*!< Data size of payload (NotificationCreate updates this
* value to max possible payload size)
*/
uint8_t *payload; /*!< Pointer on the payload */
};

/* Defines parameters used by ADSP system during Module Event notification creation. */
struct module_event_notification {
uint32_t module_instance_id; /*!< Module ID (MS word) + Module Instance ID (LS word) */
uint32_t event_id; /*!< Module specific event ID. */
uint32_t event_data_size; /*!< Size of event_data array in bytes. May be set to 0
* in case there is no data.
*/
uint32_t event_data[]; /*!< Optional event data (size set to 0 as it is optional
* data)
*/
};

/* Defines notification targets supported by ADSP system
* FW defines only two notification targets, HOST and ISH (Integrated Sensor Hub).
*/
enum notification_target {
NOTIFICATION_TARGET_DSP_TO_HOST = 1, /* Notification target is HOST */
NOTIFICATION_TARGET_DSP_TO_ISH = 2 /* Notification target is ISH */
};

/* Defines notification types supported by ADSP system
* FW use reserved first 20 positions describing types of notifications.
*/
enum notification_type {
/* corresponding to PHRASE_DETECTED notification */
NOTIFICATION_TYPE_VOICE_COMMAND_NOTIFICATION = 4,

/* corresponding to FW_AUD_CLASS_RESULT notification */
NOTIFICATION_TYPE_AUDIO_CLASSIFIER_RESULTS = 9,

/* corresponding to MODULE_NOTIFICATION notification */
NOTIFICATION_TYPE_MODULE_EVENT_NOTIFICATION = 12,
};

/* Defines extended interfaces for IADK modules */
enum interface_id {
INTERFACE_ID_GNA = 0x1000, /* Reserved for ADSP system */
INTERFACE_ID_INFERENCE_SERVICE = 0x1001, /* See InferenceServiceInterface */
INTERFACE_ID_SDCA = 0x1002, /* See SdcaInterface */
INTERFACE_ID_ASYNC_MESSAGE_SERVICE = 0x1003, /* See AsyncMessageInterface */
INTERFACE_ID_AM_SERVICE = 0x1005, /* Reserved for ADSP system */
INTERFACE_ID_KPB_SERVICE = 0x1006 /* See KpbInterface */
};

/* sub interface definition.
* This type may contain generic interface properties like id or struct size if needed.
*/
struct system_service_iface;

struct system_service {
void (*log_message)(enum log_priority log_priority, uint32_t log_entry,
struct log_handle const *log_handle, uint32_t param1,
uint32_t param2, uint32_t param3, uint32_t param4);

AdspErrorCode (*safe_memcpy)(void *RESTRICT dst, size_t maxlen,
const void *RESTRICT src, size_t len);

AdspErrorCode (*safe_memmove)(void *dst, size_t maxlen,
const void *src, size_t len);

void* (*vec_memset)(void *dst, int c, size_t len);

AdspErrorCode (*notification_create)(struct notification_params *params,
uint8_t *notification_buffer,
uint32_t notification_buffer_size,
struct notification_handle **handle);
AdspErrorCode (*notification_send)(enum notification_target notification_target,
struct notification_handle *message,
uint32_t actual_payload_size);

AdspErrorCode (*get_interface)(enum interface_id id, struct system_service_iface **iface);
};
#endif /* MODULE_MODULE_SYSTEM_SERVICE_H */
13 changes: 3 additions & 10 deletions src/include/sof/audio/module_adapter/iadk/adsp_stddef.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2022 Intel Corporation. All rights reserved.
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright(c) 2022 - 2024 Intel Corporation. All rights reserved.
*/

#ifndef _ADSP_STDDEF_H_
Expand All @@ -16,13 +16,6 @@

#include <module/module/logger.h>

#ifdef __XTENSA__
#define RESTRICT __restrict
#else
#define RESTRICT
#endif


/*! Log level priority enumeration. */
typedef enum log_priority AdspLogPriority, log_priority_e;
typedef struct log_handle AdspLogHandle;
Expand Down
23 changes: 7 additions & 16 deletions src/include/sof/audio/module_adapter/iadk/system_service.h
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2022 Intel Corporation. All rights reserved.
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright(c) 2022 - 2024 Intel Corporation. All rights reserved.
*/
/*! \file system_service.h */

#ifndef _ADSP_SYSTEM_SERVICE_H_
#define _ADSP_SYSTEM_SERVICE_H_

#include <stdint.h>
#include "adsp_stddef.h"
#include <module/iadk/adsp_error_code.h>
#include "native_system_service.h"
#include <stdint.h>
#include <native_system_service.h>

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wextern-c-compat"
#endif //__clang__

#ifdef __cplusplus
extern "C" {
#endif

typedef struct native_system_service_api AdspSystemService;

#ifdef __cplusplus

namespace intel_adsp
{
typedef struct system_service AdspSystemService;

/*! \brief Alias type of AdspSystemService which can be used in C++.
*/
struct SystemService : public AdspSystemService {};
}
#endif

#ifdef __cplusplus
}
#endif

#ifdef __clang__
#pragma clang diagnostic pop // ignored "-Wextern-c-compat"
#endif //__clang__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <native_system_service.h>

struct native_system_agent {
struct native_system_service_api system_service;
struct system_service system_service;
uint32_t log_handle;
uint32_t core_id;
uint32_t module_id;
Expand Down
Loading

0 comments on commit db28a6e

Please sign in to comment.