Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party FreeBSD
提交
55690493
T
Third Party FreeBSD
项目概览
OpenHarmony
/
Third Party FreeBSD
1 年多 前同步成功
通知
3
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party FreeBSD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
55690493
编写于
4月 19, 2021
作者:
C
Caoruihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code optimization
Change-Id: I1c7d822d255f5b1ab54ca05a4a120695e4d3b0c8
上级
ae93d7f2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
116 addition
and
2 deletion
+116
-2
sys/compat/linuxkpi/common/src/adp.c
sys/compat/linuxkpi/common/src/adp.c
+116
-2
未找到文件。
sys/compat/linuxkpi/common/src/adp.c
浏览文件 @
55690493
...
...
@@ -45,6 +45,8 @@
#include "lwip/netdb.h"
#endif
#include "linux/rbtree.h"
#include "los_vm_zone.h"
#include "los_vm_lock.h"
#ifdef __cplusplus
#if __cplusplus
...
...
@@ -195,8 +197,7 @@ void *__dso_handle = NULL;
#undef RB_ROOT
#define RB_ROOT(head) (head)->rbh_root
int
panic_cmp
(
struct
rb_node
*
one
,
struct
rb_node
*
two
)
int
panic_cmp
(
struct
rb_node
*
one
,
struct
rb_node
*
two
)
{
LOS_Panic
(
"no cmp"
);
return
0
;
...
...
@@ -204,6 +205,119 @@ panic_cmp(struct rb_node *one, struct rb_node *two)
RB_GENERATE
(
linux_root
,
rb_node
,
__entry
,
panic_cmp
);
#define IS_PERIPH_ADDR(addr) \
(((addr) >= U32_C(PERIPH_PMM_BASE)) && ((addr) <= U32_C(PERIPH_PMM_BASE) + U32_C(PERIPH_PMM_SIZE)))
#define IS_MEMORY_ADDR(addr) \
(((addr) >= U32_C(DDR_MEM_ADDR)) && ((addr) <= U32_C(DDR_MEM_ADDR) + U32_C(DDR_MEM_SIZE)))
VOID
*
ioremap
(
PADDR_T
paddr
,
unsigned
long
size
)
{
if
(
IS_PERIPH_ADDR
(
paddr
)
&&
IS_PERIPH_ADDR
(
paddr
+
size
))
{
return
(
VOID
*
)(
UINTPTR
)
IO_DEVICE_ADDR
(
paddr
);
}
VM_ERR
(
"ioremap failed invalid addr or size %p %d"
,
paddr
,
size
);
return
(
VOID
*
)(
UINTPTR
)
paddr
;
}
VOID
iounmap
(
VOID
*
vaddr
)
{}
VOID
*
ioremap_nocache
(
PADDR_T
paddr
,
unsigned
long
size
)
{
if
(
IS_PERIPH_ADDR
(
paddr
)
&&
IS_PERIPH_ADDR
(
paddr
+
size
))
{
return
(
VOID
*
)(
UINTPTR
)
IO_UNCACHED_ADDR
(
paddr
);
}
if
(
IS_MEMORY_ADDR
(
paddr
)
&&
IS_MEMORY_ADDR
(
paddr
+
size
))
{
return
(
VOID
*
)(
UINTPTR
)
MEM_UNCACHED_ADDR
(
paddr
);
}
VM_ERR
(
"ioremap_nocache failed invalid addr or size %p %d"
,
paddr
,
size
);
return
(
VOID
*
)(
UINTPTR
)
paddr
;
}
VOID
*
ioremap_cached
(
PADDR_T
paddr
,
unsigned
long
size
)
{
if
(
IS_PERIPH_ADDR
(
paddr
)
&&
IS_PERIPH_ADDR
(
paddr
+
size
))
{
return
(
VOID
*
)(
UINTPTR
)
IO_CACHED_ADDR
(
paddr
);
}
if
(
IS_MEMORY_ADDR
(
paddr
)
&&
IS_MEMORY_ADDR
(
paddr
+
size
))
{
return
(
VOID
*
)(
UINTPTR
)
MEM_CACHED_ADDR
(
paddr
);
}
VM_ERR
(
"ioremap_cached failed invalid addr or size %p %d"
,
paddr
,
size
);
return
(
VOID
*
)(
UINTPTR
)
paddr
;
}
#ifdef LOSCFG_KERNEL_VM
int
remap_pfn_range
(
VADDR_T
vaddr
,
unsigned
long
pfn
,
unsigned
long
size
,
unsigned
long
prot
)
{
STATUS_T
status
=
LOS_OK
;
int
ret
;
LosVmMapRegion
*
region
=
NULL
;
unsigned
long
vpos
;
unsigned
long
end
;
unsigned
long
paddr
=
pfn
<<
PAGE_SHIFT
;
LosVmSpace
*
space
=
LOS_SpaceGet
(
vaddr
);
if
(
size
==
0
)
{
VM_ERR
(
"invalid map size %u"
,
size
);
return
LOS_ERRNO_VM_INVALID_ARGS
;
}
size
=
ROUNDUP
(
size
,
PAGE_SIZE
);
if
(
!
IS_PAGE_ALIGNED
(
vaddr
)
||
pfn
==
0
)
{
VM_ERR
(
"invalid map map vaddr %x or pfn %x"
,
vaddr
,
pfn
);
return
LOS_ERRNO_VM_INVALID_ARGS
;
}
if
(
space
==
NULL
)
{
VM_ERR
(
"aspace not exists"
);
return
LOS_ERRNO_VM_NOT_FOUND
;
}
(
VOID
)
LOS_MuxAcquire
(
&
space
->
regionMux
);
region
=
LOS_RegionFind
(
space
,
vaddr
);
if
(
region
==
NULL
)
{
VM_ERR
(
"region not exists"
);
status
=
LOS_ERRNO_VM_NOT_FOUND
;
goto
OUT
;
}
end
=
vaddr
+
size
;
if
(
region
->
range
.
base
+
region
->
range
.
size
<
end
)
{
VM_ERR
(
"out of range:base=%x size=%d vaddr=%x len=%u"
,
region
->
range
.
base
,
region
->
range
.
size
,
vaddr
,
size
);
status
=
LOS_ERRNO_VM_INVALID_ARGS
;
goto
OUT
;
}
/* check */
for
(
vpos
=
vaddr
;
vpos
<
end
;
vpos
+=
PAGE_SIZE
)
{
status
=
LOS_ArchMmuQuery
(
&
space
->
archMmu
,
(
VADDR_T
)
vpos
,
NULL
,
NULL
);
if
(
status
==
LOS_OK
)
{
VM_ERR
(
"remap_pfn_range, address mapping already exist"
);
status
=
LOS_ERRNO_VM_INVALID_ARGS
;
goto
OUT
;
}
}
/* map all */
ret
=
LOS_ArchMmuMap
(
&
space
->
archMmu
,
vaddr
,
paddr
,
size
>>
PAGE_SHIFT
,
prot
);
if
(
ret
<=
0
)
{
VM_ERR
(
"ioremap LOS_ArchMmuMap failed err = %d"
,
ret
);
goto
OUT
;
}
status
=
LOS_OK
;
OUT:
(
VOID
)
LOS_MuxRelease
(
&
space
->
regionMux
);
return
status
;
}
#endif
#ifdef __cplusplus
#if __cplusplus
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录