forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailbox.h
More file actions
123 lines (98 loc) · 3.14 KB
/
mailbox.h
File metadata and controls
123 lines (98 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Xiuli Pan <xiuli.pan@linux.intel.com>
*/
#ifndef __SOF_LIB_MAILBOX_H__
#define __SOF_LIB_MAILBOX_H__
#include <sof/common.h>
#include <kernel/mailbox.h>
#include <platform/lib/mailbox.h>
#include <rtos/panic.h>
#include <rtos/cache.h>
#include <sof/lib/memory.h>
#include <rtos/string.h>
#include <stddef.h>
#include <stdint.h>
#define mailbox_get_exception_base() \
MAILBOX_EXCEPTION_BASE
#define mailbox_get_exception_size() \
MAILBOX_EXCEPTION_SIZE
#define mailbox_get_dspbox_base() \
MAILBOX_DSPBOX_BASE
#define mailbox_get_dspbox_size() \
MAILBOX_DSPBOX_SIZE
#define mailbox_get_hostbox_base() \
MAILBOX_HOSTBOX_BASE
#define mailbox_get_hostbox_size() \
MAILBOX_HOSTBOX_SIZE
#define mailbox_get_debug_base() \
MAILBOX_DEBUG_BASE
#define mailbox_get_debug_size() \
MAILBOX_DEBUG_SIZE
static inline
void mailbox_dspbox_write(size_t offset, const void *src, size_t bytes)
{
int dsp_write_err __unused = memcpy_s((void *)(MAILBOX_DSPBOX_BASE + offset),
MAILBOX_DSPBOX_SIZE - offset, src, bytes);
assert(!dsp_write_err);
dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_DSPBOX_BASE +
offset), bytes);
}
static inline
void mailbox_dspbox_read(void *dest, size_t dest_size,
size_t offset, size_t bytes)
{
int dsp_read_err __unused;
dcache_invalidate_region((__sparse_force void __sparse_cache *)(MAILBOX_DSPBOX_BASE +
offset), bytes);
dsp_read_err = memcpy_s(dest, dest_size,
(void *)(MAILBOX_DSPBOX_BASE + offset), bytes);
assert(!dsp_read_err);
}
#if CONFIG_LIBRARY
#define mailbox_hostbox_write(_offset, _src, _bytes) \
memcpy((char *)ipc->comp_data + _offset, _src, _bytes)
#else
static inline
void mailbox_hostbox_write(size_t offset, const void *src, size_t bytes)
{
int host_write_err __unused = memcpy_s((void *)(MAILBOX_HOSTBOX_BASE + offset),
MAILBOX_HOSTBOX_SIZE - offset, src, bytes);
assert(!host_write_err);
dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_HOSTBOX_BASE +
offset), bytes);
}
#endif
static inline
void mailbox_hostbox_read(void *dest, size_t dest_size,
size_t offset, size_t bytes)
{
int host_read_err __unused;
dcache_invalidate_region((__sparse_force void __sparse_cache *)(MAILBOX_HOSTBOX_BASE +
offset), bytes);
host_read_err = memcpy_s(dest, dest_size,
(void *)(MAILBOX_HOSTBOX_BASE + offset), bytes);
assert(!host_read_err);
}
#if CONFIG_IPC_MAJOR_4
static inline
void mailbox_stream_write(size_t offset, const void *src, size_t bytes)
{
/* in IPC4, the stream mailbox must not be used */
assert(false);
}
#else
static inline
void mailbox_stream_write(size_t offset, const void *src, size_t bytes)
{
int stream_write_err __unused = memcpy_s((void *)(MAILBOX_STREAM_BASE + offset),
MAILBOX_STREAM_SIZE - offset, src, bytes);
assert(!stream_write_err);
dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_STREAM_BASE +
offset), bytes);
}
#endif
#endif /* __SOF_LIB_MAILBOX_H__ */