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
|
/*
* Copyright : (C) 2023 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: fdrivers_port.c
* Created Date: 2023-10-17 08:29:18
* Last Modified: 2023-10-26 10:49:19
* Description: This file is for drive layer code decoupling
*
* Modify History:
* Ver Who Date Changes
* ----- ---------- -------- ---------------------------------
* 1.0 huanghe 2023/10/17 first release
*/
#include "fdrivers_port.h"
#include "cache.h"
#include "rtthread.h"
#ifdef __aarch64__
/* cache */
void FDriverDCacheRangeFlush(uintptr_t adr, size_t len)
{
rt_hw_cpu_dcache_clean((void *)adr, len);
}
void FDriverDCacheRangeInvalidate(uintptr_t adr, size_t len)
{
rt_hw_cpu_dcache_invalidate((void *)adr, len);
}
void FDriverICacheRangeInvalidate(uintptr_t adr, size_t len)
{
__asm_invalidate_icache_all();
}
void FDriverICacheInvalidate(void)
{
__asm_invalidate_icache_all();
}
void FDriverDCacheInvalidate(void)
{
__asm_invalidate_dcache_all();
}
#else
#include "rthw.h"
/* cache */
void FDriverDCacheRangeFlush(uintptr_t adr, size_t len)
{
rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, (void *)adr, len);
}
void FDriverDCacheRangeInvalidate(uintptr_t adr, size_t len)
{
rt_hw_cpu_dcache_ops(RT_HW_CACHE_INVALIDATE, (void *)adr, len);
}
void FDriverICacheRangeInvalidate(uintptr_t adr, size_t len)
{
rt_hw_cpu_icache_ops(RT_HW_CACHE_INVALIDATE, (void *)adr, len);
}
#endif
/* time delay */
void FDriverUdelay(u32 usec)
{
rt_thread_delay(usec);
}
void FDriverSdelay(u32 sec)
{
u32 msec = sec * 1000;
rt_thread_mdelay(msec);
}
void FDriverMdelay(u32 msec)
{
rt_thread_mdelay(msec);
}
|