14
14
#include <stddef.h>
15
15
#include <stdint.h>
16
16
17
+ #include <rtos/panic.h>
18
+ #include <rtos/string.h>
19
+
17
20
/*
18
- * The Window Region on i.MX8 SRAM is organised like this :-
21
+ * The Window Region on i.MX8 SRAM is organized like this :-
19
22
* +--------------------------------------------------------------------------+
20
23
* | Offset | Region | Size |
21
24
* +---------------------+----------------+-----------------------------------+
53
56
#define MAILBOX_STREAM_BASE SRAM_STREAM_BASE
54
57
#define MAILBOX_STREAM_OFFSET SRAM_STREAM_OFFSET
55
58
59
+ #define MAILBOX_SW_REG_SIZE MAILBOX_DEBUG_SIZE
60
+ #define MAILBOX_SW_REG_BASE MAILBOX_DEBUG_BASE
61
+
56
62
static inline void mailbox_sw_reg_write (size_t offset , uint32_t src )
57
63
{
58
64
volatile uint32_t * ptr ;
@@ -61,6 +67,37 @@ static inline void mailbox_sw_reg_write(size_t offset, uint32_t src)
61
67
* ptr = src ;
62
68
}
63
69
70
+ static inline uint32_t mailbox_sw_reg_read (size_t offset )
71
+ {
72
+ volatile uint32_t * ptr ;
73
+ volatile uint32_t __sparse_cache * ptr_c ;
74
+
75
+ ptr_c = (volatile uint32_t __sparse_cache * )(MAILBOX_SW_REG_BASE + offset );
76
+ ptr = cache_to_uncache ((uint32_t __sparse_cache * )ptr_c );
77
+
78
+ return * ptr ;
79
+ }
80
+
81
+ static inline uint64_t mailbox_sw_reg_read64 (size_t offset )
82
+ {
83
+ volatile uint64_t * ptr ;
84
+ volatile uint64_t __sparse_cache * ptr_c ;
85
+
86
+ ptr_c = (volatile uint64_t __sparse_cache * )(MAILBOX_SW_REG_BASE + offset );
87
+ ptr = cache_to_uncache ((uint64_t __sparse_cache * )ptr_c );
88
+
89
+ return * ptr ;
90
+ }
91
+
92
+ static inline void mailbox_sw_regs_write (size_t offset , const void * src , size_t bytes )
93
+ {
94
+ int regs_write_err __unused = memcpy_s ((void * )(MAILBOX_SW_REG_BASE + offset ),
95
+ MAILBOX_SW_REG_SIZE - offset , src , bytes );
96
+
97
+ assert (!regs_write_err );
98
+ dcache_writeback_region ((__sparse_force void __sparse_cache * )(MAILBOX_SW_REG_BASE +
99
+ offset ), bytes );
100
+ }
64
101
#endif /* __PLATFORM_LIB_MAILBOX_H__ */
65
102
66
103
#else
0 commit comments