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
100 lines (79 loc) · 2.37 KB
/
mailbox.h
File metadata and controls
100 lines (79 loc) · 2.37 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
/* 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 <platform/lib/mailbox.h>
#include <sof/debug/panic.h>
#include <sof/lib/cache.h>
#include <sof/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 ret = memcpy_s((void *)(MAILBOX_DSPBOX_BASE + offset),
MAILBOX_DSPBOX_SIZE - offset, src, bytes);
assert(!ret);
dcache_writeback_region((void *)(MAILBOX_DSPBOX_BASE + offset), bytes);
}
static inline
void mailbox_dspbox_read(void *dest, size_t dest_size,
size_t offset, size_t bytes)
{
int ret;
dcache_invalidate_region((void *)(MAILBOX_DSPBOX_BASE + offset),
bytes);
ret = memcpy_s(dest, dest_size,
(void *)(MAILBOX_DSPBOX_BASE + offset), bytes);
assert(!ret);
}
static inline
void mailbox_hostbox_write(size_t offset, const void *src, size_t bytes)
{
int ret = memcpy_s((void *)(MAILBOX_HOSTBOX_BASE + offset),
MAILBOX_HOSTBOX_SIZE - offset, src, bytes);
assert(!ret);
dcache_writeback_region((void *)(MAILBOX_HOSTBOX_BASE + offset), bytes);
}
static inline
void mailbox_hostbox_read(void *dest, size_t dest_size,
size_t offset, size_t bytes)
{
int ret;
dcache_invalidate_region((void *)(MAILBOX_HOSTBOX_BASE + offset),
bytes);
ret = memcpy_s(dest, dest_size,
(void *)(MAILBOX_HOSTBOX_BASE + offset), bytes);
assert(!ret);
}
static inline
void mailbox_stream_write(size_t offset, const void *src, size_t bytes)
{
int ret = memcpy_s((void *)(MAILBOX_STREAM_BASE + offset),
MAILBOX_STREAM_SIZE - offset, src, bytes);
assert(!ret);
dcache_writeback_region((void *)(MAILBOX_STREAM_BASE + offset),
bytes);
}
#endif /* __SOF_LIB_MAILBOX_H__ */