Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
4b6a6e80
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
461
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4b6a6e80
编写于
3月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!846 fix: 编码规范修复
Merge pull request !846 from zhushengle/xxx
上级
e26d969c
216c1248
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
259 addition
and
209 deletion
+259
-209
apps/lms/src/sample_usr_lms.c
apps/lms/src/sample_usr_lms.c
+51
-49
apps/perf/src/main.c
apps/perf/src/main.c
+5
-0
apps/perf/src/perf_record.c
apps/perf/src/perf_record.c
+0
-1
apps/trace/src/trace.c
apps/trace/src/trace.c
+4
-0
arch/arm/gic/gic_v2.c
arch/arm/gic/gic_v2.c
+11
-11
arch/arm/gic/gic_v3.c
arch/arm/gic/gic_v3.c
+24
-24
compat/posix/src/malloc.c
compat/posix/src/malloc.c
+4
-4
kernel/base/core/los_swtmr.c
kernel/base/core/los_swtmr.c
+46
-40
kernel/base/core/los_task.c
kernel/base/core/los_task.c
+3
-3
kernel/base/include/los_memory_pri.h
kernel/base/include/los_memory_pri.h
+1
-1
kernel/base/include/los_vm_phys.h
kernel/base/include/los_vm_phys.h
+1
-1
kernel/base/include/los_vm_zone.h
kernel/base/include/los_vm_zone.h
+9
-9
kernel/base/mem/tlsf/los_memory.c
kernel/base/mem/tlsf/los_memory.c
+54
-45
kernel/base/sched/sched_sq/los_sched.c
kernel/base/sched/sched_sq/los_sched.c
+24
-19
kernel/extended/trace/pipeline/serial/trace_pipeline_serial.c
...el/extended/trace/pipeline/serial/trace_pipeline_serial.c
+3
-0
net/lwip-2.1/enhancement/src/fixme.c
net/lwip-2.1/enhancement/src/fixme.c
+14
-1
net/lwip-2.1/porting/src/sockets.c
net/lwip-2.1/porting/src/sockets.c
+1
-1
testsuites/unittest/basic/exc/full/it_test_fexecve_001.cpp
testsuites/unittest/basic/exc/full/it_test_fexecve_001.cpp
+4
-0
未找到文件。
apps/lms/src/sample_usr_lms.c
浏览文件 @
4b6a6e80
...
...
@@ -50,14 +50,14 @@ static void BufReadTest(void *buf, int start, int end)
static
void
LmsMallocTest
(
void
)
{
#define TEST_SIZE 16
printf
(
"
\n
-------- LmsMallocTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
16
);
printf
(
"[LmsMallocTest] malloc addr:%p size:%d
\n
"
,
buf
,
16
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
printf
(
"[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1,
16
]
\n
"
);
BufReadTest
(
buf
,
-
1
,
16
);
printf
(
"[LmsMallocTest] write overflow error should be triggered, write range[0,
16
]
\n
"
);
BufWriteTest
(
buf
,
0
,
16
);
printf
(
"[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1,
TEST_SIZE
]
\n
"
);
BufReadTest
(
buf
,
-
1
,
TEST_SIZE
);
printf
(
"[LmsMallocTest] write overflow error should be triggered, write range[0,
TEST_SIZE
]
\n
"
);
BufWriteTest
(
buf
,
0
,
TEST_SIZE
);
free
(
buf
);
printf
(
"
\n
-------- LmsMallocTest End --------
\n
"
);
...
...
@@ -65,51 +65,52 @@ static void LmsMallocTest(void)
static
void
LmsReallocTest
(
void
)
{
#define TEST_SIZE 64
#define TEST_SIZE_MIN 32
printf
(
"
\n
-------- LmsReallocTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
64
);
printf
(
"[LmsReallocTest] malloc addr:%p size:%d
\n
"
,
buf
,
64
);
printf
(
"[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,64]
\n
"
);
BufReadTest
(
buf
,
-
1
,
64
);
char
*
buf1
=
(
char
*
)
realloc
(
buf
,
32
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
printf
(
"[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]
\n
"
);
BufReadTest
(
buf
,
-
1
,
TEST_SIZE
);
char
*
buf1
=
(
char
*
)
realloc
(
buf
,
TEST_SIZE_MIN
);
if
(
buf1
==
NULL
)
{
free
(
buf
);
return
;
}
buf
=
NULL
;
printf
(
"[LmsReallocTest] realloc addr:%p size:%d
\n
"
,
buf1
,
32
);
printf
(
"[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,32]
\n
"
);
BufReadTest
(
buf1
,
-
1
,
32
);
printf
(
"[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE_MIN]
\n
"
);
BufReadTest
(
buf1
,
-
1
,
TEST_SIZE_MIN
);
free
(
buf1
);
printf
(
"
\n
-------- LmsReallocTest End --------
\n
"
);
}
static
void
LmsCallocTest
(
void
)
{
#define TEST_SIZE 16
printf
(
"
\n
-------- LmsCallocTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
calloc
(
4
,
4
);
printf
(
"[LmsCallocTest] calloc addr:%p size:%d
\n
"
,
buf
,
16
);
printf
(
"[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1,16]
\n
"
);
BufReadTest
(
buf
,
-
1
,
16
);
char
*
buf
=
(
char
*
)
calloc
(
4
,
4
);
/* 4: test size */
printf
(
"[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]
\n
"
);
BufReadTest
(
buf
,
-
1
,
TEST_SIZE
);
free
(
buf
);
printf
(
"
\n
-------- LmsCallocTest End --------
\n
"
);
}
static
void
LmsVallocTest
(
void
)
{
#define TEST_SIZE 4096
printf
(
"
\n
-------- LmsVallocTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
valloc
(
4096
);
printf
(
"[LmsVallocTest] valloc addr:%p size:%d
\n
"
,
buf
,
4096
);
printf
(
"[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1,4096]
\n
"
);
BufReadTest
(
buf
,
-
1
,
4096
);
char
*
buf
=
(
char
*
)
valloc
(
TEST_SIZE
);
printf
(
"[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]
\n
"
);
BufReadTest
(
buf
,
-
1
,
TEST_SIZE
);
free
(
buf
);
printf
(
"
\n
-------- LmsVallocTest End --------
\n
"
);
}
static
void
LmsAlignedAllocTest
(
void
)
{
#define TEST_ALIGN_SIZE 64
#define TEST_SIZE 128
printf
(
"
\n
-------- LmsAlignedAllocTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
aligned_alloc
(
64
,
128
);
printf
(
"[LmsAlignedAllocTest] aligned_alloc boundsize:%d addr:%p size:%d
\n
"
,
64
,
buf
,
128
);
char
*
buf
=
(
char
*
)
aligned_alloc
(
TEST_ALIGN_SIZE
,
TEST_SIZE
);
printf
(
"[LmsAlignedAllocTest] read overflow & underflow error should be triggered, read range[-1,128]
\n
"
);
BufReadTest
(
buf
,
-
1
,
128
);
free
(
buf
);
...
...
@@ -118,44 +119,43 @@ static void LmsAlignedAllocTest(void)
static
void
LmsMemsetTest
(
void
)
{
#define TEST_SIZE 32
printf
(
"
\n
-------- LmsMemsetTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
32
);
printf
(
"[LmsMemsetTest] malloc addr:%p size:%d
\n
"
,
buf
,
32
);
printf
(
"[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d
\n
"
,
33
);
memset
(
buf
,
0
,
33
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
printf
(
"[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d
\n
"
,
TEST_SIZE
+
1
);
memset
(
buf
,
0
,
TEST_SIZE
+
1
);
free
(
buf
);
printf
(
"
\n
-------- LmsMemsetTest End --------
\n
"
);
}
static
void
LmsMemcpyTest
(
void
)
{
#define TEST_SIZE 20
printf
(
"
\n
-------- LmsMemcpyTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
20
);
printf
(
"[LmsMemcpyTest] malloc addr:%p size:%d
\n
"
,
buf
,
20
);
char
localBuf
[
32
]
=
{
0
};
printf
(
"[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d
\n
"
,
21
);
memcpy
(
buf
,
localBuf
,
21
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
char
localBuf
[
32
]
=
{
0
};
/* 32: test size */
printf
(
"[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d
\n
"
,
TEST_SIZE
+
1
);
memcpy
(
buf
,
localBuf
,
TEST_SIZE
+
1
);
free
(
buf
);
printf
(
"
\n
-------- LmsMemcpyTest End --------
\n
"
);
}
static
void
LmsMemmoveTest
(
void
)
{
#define TEST_SIZE 20
printf
(
"
\n
-------- LmsMemmoveTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
20
);
printf
(
"[LmsMemmoveTest] malloc addr:%p size:%d
\n
"
,
buf
,
20
);
printf
(
"[LmsMemmoveTest] memmove overflow error should be triggered, dest addr:%p src addr:%p size:%d
\n
"
,
buf
+
12
,
buf
,
10
);
memmove
(
buf
+
12
,
buf
,
10
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
printf
(
"[LmsMemmoveTest] memmove overflow error should be triggered
\n
"
);
memmove
(
buf
+
12
,
buf
,
10
);
/* 12 and 10: test size */
free
(
buf
);
printf
(
"
\n
-------- LmsMemmoveTest End --------
\n
"
);
}
static
void
LmsStrcpyTest
(
void
)
{
#define TEST_SIZE 16
printf
(
"
\n
-------- LmsStrcpyTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
16
);
printf
(
"[LmsStrcpyTest] malloc addr:%p size:%d
\n
"
,
buf
,
16
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
char
*
testStr
=
"bbbbbbbbbbbbbbbbb"
;
printf
(
"[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d
\n
"
,
strlen
(
testStr
)
+
1
);
strcpy
(
buf
,
testStr
);
...
...
@@ -165,9 +165,9 @@ static void LmsStrcpyTest(void)
static
void
LmsStrcatTest
(
void
)
{
#define TEST_SIZE 16
printf
(
"
\n
-------- LmsStrcatTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
16
);
printf
(
"[LmsStrcatTest] malloc addr:%p size:%d
\n
"
,
buf
,
16
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
buf
[
0
]
=
'a'
;
buf
[
1
]
=
'b'
;
buf
[
2
]
=
0
;
...
...
@@ -182,22 +182,24 @@ static void LmsStrcatTest(void)
static
void
LmsFreeTest
(
void
)
{
#define TEST_SIZE 16
printf
(
"
\n
-------- LmsFreeTest Start --------
\n
"
);
char
*
buf
=
(
char
*
)
malloc
(
16
);
printf
(
"[LmsFreeTest] malloc addr:%p size:%d
\n
"
,
buf
,
16
);
printf
(
"[LmsFreeTest] free addr:%p size:%d
\n
"
,
buf
,
16
);
char
*
buf
=
(
char
*
)
malloc
(
TEST_SIZE
);
printf
(
"[LmsFreeTest] free size:%d
\n
"
,
TEST_SIZE
);
free
(
buf
);
printf
(
"[LmsFreeTest] Use after free error should be triggered, read
addr:%p range[1,1]
\n
"
,
buf
);
printf
(
"[LmsFreeTest] Use after free error should be triggered, read
range[1,1]
\n
"
);
BufReadTest
(
buf
,
1
,
1
);
printf
(
"[LmsFreeTest] double free error should be triggered
, free addr:%p
\n
"
,
buf
);
printf
(
"[LmsFreeTest] double free error should be triggered
\n
"
);
free
(
buf
);
printf
(
"
\n
-------- LmsFreeTest End --------
\n
"
);
}
int
main
(
int
argc
,
char
*
const
*
argv
)
int
main
(
int
argc
,
char
*
const
*
argv
)
{
(
void
)
argc
;
(
void
)
argv
;
printf
(
"
\n
############### Lms Test start ###############
\n
"
);
char
*
tmp
=
(
char
*
)
malloc
(
5000
);
char
*
tmp
=
(
char
*
)
malloc
(
5000
);
/* 5000: test mem size */
LmsMallocTest
();
LmsReallocTest
();
LmsCallocTest
();
...
...
apps/perf/src/main.c
浏览文件 @
4b6a6e80
...
...
@@ -62,6 +62,10 @@ int main(int argc, char **argv)
PerfStop
(
fd
);
}
else
if
((
argc
==
THREE_ARGS
)
&&
strcmp
(
argv
[
1
],
"read"
)
==
0
)
{
size_t
size
=
strtoul
(
argv
[
THREE_ARGS
-
1
],
NULL
,
0
);
if
(
size
<=
0
)
{
goto
EXIT
:
}
char
*
buf
=
(
char
*
)
malloc
(
size
);
if
(
buf
!=
NULL
)
{
int
len
=
PerfRead
(
fd
,
buf
,
size
);
...
...
@@ -80,6 +84,7 @@ int main(int argc, char **argv)
PerfUsage
();
}
EXIT:
close
(
fd
);
return
0
;
}
apps/perf/src/perf_record.c
浏览文件 @
4b6a6e80
...
...
@@ -113,7 +113,6 @@ ssize_t PerfWriteFile(const char *filePath, const char *buf, ssize_t bufSize)
ssize_t
totalWrite
=
0
;
if
(
filePath
==
NULL
||
buf
==
NULL
||
bufSize
==
0
)
{
printf
(
"filePath: %p, buf: %p, bufSize: %u!
\n
"
,
filePath
,
buf
,
bufSize
);
return
-
1
;
}
...
...
apps/trace/src/trace.c
浏览文件 @
4b6a6e80
...
...
@@ -70,6 +70,10 @@ static void TraceRead(int fd, size_t size)
{
ssize_t
i
;
ssize_t
len
;
if
(
size
<=
0
)
{
return
;
}
char
*
buffer
=
(
char
*
)
malloc
(
size
);
if
(
buffer
==
NULL
)
{
printf
(
"Read buffer malloc failed.
\n
"
);
...
...
arch/arm/gic/gic_v2.c
浏览文件 @
4b6a6e80
...
...
@@ -49,7 +49,7 @@ STATIC UINT32 g_curIrqNum = 0;
*/
STATIC
VOID
GicWriteSgi
(
UINT32
vector
,
UINT32
cpuMask
,
UINT32
filter
)
{
UINT32
val
=
((
filter
&
0x3
)
<<
24
)
|
((
cpuMask
&
0xFF
)
<<
16
)
|
UINT32
val
=
((
filter
&
0x3
)
<<
24
)
|
((
cpuMask
&
0xFF
)
<<
16
)
|
/* 24, 16: Register bit offset */
(
vector
&
0xF
);
GIC_REG_32
(
GICD_SGIR
)
=
val
;
...
...
@@ -62,7 +62,7 @@ VOID HalIrqSendIpi(UINT32 target, UINT32 ipi)
VOID
HalIrqSetAffinity
(
UINT32
vector
,
UINT32
cpuMask
)
{
UINT32
offset
=
vector
/
4
;
UINT32
offset
=
vector
/
4
;
/* 4: Interrupt bit width */
UINT32
index
=
vector
&
0x3
;
GIC_REG_8
(
GICD_ITARGETSR
(
offset
)
+
index
)
=
cpuMask
;
...
...
@@ -80,7 +80,7 @@ VOID HalIrqMask(UINT32 vector)
return
;
}
GIC_REG_32
(
GICD_ICENABLER
(
vector
/
32
))
=
1U
<<
(
vector
%
32
);
GIC_REG_32
(
GICD_ICENABLER
(
vector
/
32
))
=
1U
<<
(
vector
%
32
);
/* 32: Interrupt bit width */
}
VOID
HalIrqUnmask
(
UINT32
vector
)
...
...
@@ -89,7 +89,7 @@ VOID HalIrqUnmask(UINT32 vector)
return
;
}
GIC_REG_32
(
GICD_ISENABLER
(
vector
>>
5
))
=
1U
<<
(
vector
%
32
);
GIC_REG_32
(
GICD_ISENABLER
(
vector
>>
5
))
=
1U
<<
(
vector
%
32
);
/* 5, 32: Register bit offset */
}
VOID
HalIrqPending
(
UINT32
vector
)
...
...
@@ -98,7 +98,7 @@ VOID HalIrqPending(UINT32 vector)
return
;
}
GIC_REG_32
(
GICD_ISPENDR
(
vector
>>
5
))
=
1U
<<
(
vector
%
32
);
GIC_REG_32
(
GICD_ISPENDR
(
vector
>>
5
))
=
1U
<<
(
vector
%
32
);
/* 5, 32: Register bit offset */
}
VOID
HalIrqClear
(
UINT32
vector
)
...
...
@@ -120,23 +120,23 @@ VOID HalIrqInit(VOID)
UINT32
i
;
/* set external interrupts to be level triggered, active low. */
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
16
)
{
GIC_REG_32
(
GICD_ICFGR
(
i
/
16
))
=
0
;
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
16
)
{
/* 32: Start interrupt number, 16: Interrupt bit width */
GIC_REG_32
(
GICD_ICFGR
(
i
/
16
))
=
0
;
/* 16: Register bit offset */
}
/* set external interrupts to CPU 0 */
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
4
)
{
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
4
)
{
/* 32: Start interrupt number, 4: Interrupt bit width */
GIC_REG_32
(
GICD_ITARGETSR
(
i
/
4
))
=
0x01010101
;
}
/* set priority on all interrupts */
for
(
i
=
0
;
i
<
OS_HWI_MAX_NUM
;
i
+=
4
)
{
for
(
i
=
0
;
i
<
OS_HWI_MAX_NUM
;
i
+=
4
)
{
/* 4: Interrupt bit width */
GIC_REG_32
(
GICD_IPRIORITYR
(
i
/
4
))
=
GICD_INT_DEF_PRI_X4
;
}
/* disable all interrupts. */
for
(
i
=
0
;
i
<
OS_HWI_MAX_NUM
;
i
+=
32
)
{
GIC_REG_32
(
GICD_ICENABLER
(
i
/
32
))
=
~
0
;
for
(
i
=
0
;
i
<
OS_HWI_MAX_NUM
;
i
+=
32
)
{
/* 32: Interrupt bit width */
GIC_REG_32
(
GICD_ICENABLER
(
i
/
32
))
=
~
0
;
/* 32: Interrupt bit width */
}
HalIrqInitPercpu
();
...
...
arch/arm/gic/gic_v3.c
浏览文件 @
4b6a6e80
...
...
@@ -42,9 +42,9 @@ STATIC UINT32 g_curIrqNum = 0;
STATIC
INLINE
UINT64
MpidrToAffinity
(
UINT64
mpidr
)
{
return
((
MPIDR_AFF_LEVEL
(
mpidr
,
3
)
<<
32
)
|
(
MPIDR_AFF_LEVEL
(
mpidr
,
2
)
<<
16
)
|
(
MPIDR_AFF_LEVEL
(
mpidr
,
1
)
<<
8
)
|
return
((
MPIDR_AFF_LEVEL
(
mpidr
,
3
)
<<
32
)
|
/* 3: Serial number, 32: Register bit offset */
(
MPIDR_AFF_LEVEL
(
mpidr
,
2
)
<<
16
)
|
/* 2: Serial number, 16: Register bit offset */
(
MPIDR_AFF_LEVEL
(
mpidr
,
1
)
<<
8
)
|
/* 1: Serial number, 8: Register bit offset */
(
MPIDR_AFF_LEVEL
(
mpidr
,
0
)));
}
...
...
@@ -106,10 +106,10 @@ STATIC VOID GicSgi(UINT32 irq, UINT32 cpuMask)
tList
=
GicTargetList
(
&
cpu
,
cpuMask
,
cluster
);
/* Generates a Group 1 interrupt for the current security state */
val
=
((
MPIDR_AFF_LEVEL
(
cluster
,
3
)
<<
48
)
|
(
MPIDR_AFF_LEVEL
(
cluster
,
2
)
<<
32
)
|
(
MPIDR_AFF_LEVEL
(
cluster
,
1
)
<<
16
)
|
(
irq
<<
24
)
|
tList
);
val
=
((
MPIDR_AFF_LEVEL
(
cluster
,
3
)
<<
48
)
|
/* 3: Serial number, 48: Register bit offset */
(
MPIDR_AFF_LEVEL
(
cluster
,
2
)
<<
32
)
|
/* 2: Serial number, 32: Register bit offset */
(
MPIDR_AFF_LEVEL
(
cluster
,
1
)
<<
16
)
|
/* 1: Serial number, 16: Register bit offset */
(
irq
<<
24
)
|
tList
);
/* 24: Register bit offset */
GiccSetSgi1r
(
val
);
}
...
...
@@ -150,9 +150,9 @@ STATIC INLINE VOID GicdSetGroup(UINT32 irq)
{
/* configure spi as group 0 on secure mode and group 1 on unsecure mode */
#ifdef LOSCFG_ARCH_SECURE_MONITOR_MODE
GIC_REG_32
(
GICD_IGROUPR
(
irq
/
32
))
=
0
;
GIC_REG_32
(
GICD_IGROUPR
(
irq
/
32
))
=
0
;
/* 32: Interrupt bit width */
#else
GIC_REG_32
(
GICD_IGROUPR
(
irq
/
32
))
=
0xffffffff
;
GIC_REG_32
(
GICD_IGROUPR
(
irq
/
32
))
=
0xffffffff
;
/* 32: Interrupt bit width */
#endif
}
...
...
@@ -248,13 +248,13 @@ UINT32 HalCurIrqGet(VOID)
VOID
HalIrqMask
(
UINT32
vector
)
{
INT32
i
;
const
UINT32
mask
=
1U
<<
(
vector
%
32
);
const
UINT32
mask
=
1U
<<
(
vector
%
32
);
/* 32: Interrupt bit width */
if
((
vector
>
OS_USER_HWI_MAX
)
||
(
vector
<
OS_USER_HWI_MIN
))
{
return
;
}
if
(
vector
<
32
)
{
if
(
vector
<
32
)
{
/* 32: Interrupt bit width */
for
(
i
=
0
;
i
<
LOSCFG_KERNEL_CORE_NUM
;
i
++
)
{
GIC_REG_32
(
GICR_ICENABLER0
(
i
))
=
mask
;
GicWaitForRwp
(
GICR_CTLR
(
i
));
...
...
@@ -268,19 +268,19 @@ VOID HalIrqMask(UINT32 vector)
VOID
HalIrqUnmask
(
UINT32
vector
)
{
INT32
i
;
const
UINT32
mask
=
1U
<<
(
vector
%
32
);
const
UINT32
mask
=
1U
<<
(
vector
%
32
);
/* 32: Interrupt bit width */
if
((
vector
>
OS_USER_HWI_MAX
)
||
(
vector
<
OS_USER_HWI_MIN
))
{
return
;
}
if
(
vector
<
32
)
{
if
(
vector
<
32
)
{
/* 32: Interrupt bit width */
for
(
i
=
0
;
i
<
LOSCFG_KERNEL_CORE_NUM
;
i
++
)
{
GIC_REG_32
(
GICR_ISENABLER0
(
i
))
=
mask
;
GicWaitForRwp
(
GICR_CTLR
(
i
));
}
}
else
{
GIC_REG_32
(
GICD_ISENABLER
(
vector
>>
5
))
=
mask
;
GIC_REG_32
(
GICD_ISENABLER
(
vector
>>
5
))
=
mask
;
/* 5: Register bit offset */
GicWaitForRwp
(
GICD_CTLR
);
}
}
...
...
@@ -291,7 +291,7 @@ VOID HalIrqPending(UINT32 vector)
return
;
}
GIC_REG_32
(
GICD_ISPENDR
(
vector
>>
5
))
=
1U
<<
(
vector
%
32
);
GIC_REG_32
(
GICD_ISPENDR
(
vector
>>
5
))
=
1U
<<
(
vector
%
32
);
/* 5: Register bit offset, 32: Interrupt bit width */
}
VOID
HalIrqClear
(
UINT32
vector
)
...
...
@@ -363,29 +363,29 @@ VOID HalIrqInit(VOID)
ISB
;
/* set external interrupts to be level triggered, active low. */
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
16
)
{
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
16
)
{
/* 32: Start interrupt number, 16: Interrupt bit width */
GIC_REG_32
(
GICD_ICFGR
(
i
/
16
))
=
0
;
}
/* config distributer, mask and clear all spis, set group x */
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
32
)
{
GIC_REG_32
(
GICD_ICENABLER
(
i
/
32
))
=
0xffffffff
;
GIC_REG_32
(
GICD_ICPENDR
(
i
/
32
))
=
0xffffffff
;
GIC_REG_32
(
GICD_IGRPMODR
(
i
/
32
))
=
0
;
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
+=
32
)
{
/* 32: Start interrupt number, 32: Interrupt bit width */
GIC_REG_32
(
GICD_ICENABLER
(
i
/
32
))
=
0xffffffff
;
/* 32: Interrupt bit width */
GIC_REG_32
(
GICD_ICPENDR
(
i
/
32
))
=
0xffffffff
;
/* 32: Interrupt bit width */
GIC_REG_32
(
GICD_IGRPMODR
(
i
/
32
))
=
0
;
/* 32: Interrupt bit width */
GicdSetGroup
(
i
);
}
/* set spi priority as default */
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
++
)
{
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
++
)
{
/* 32: Start interrupt number */
GicdSetPmr
(
i
,
MIN_INTERRUPT_PRIORITY
);
}
GicWaitForRwp
(
GICD_CTLR
);
/* disable all interrupts. */
for
(
i
=
0
;
i
<
OS_HWI_MAX_NUM
;
i
+=
32
)
{
GIC_REG_32
(
GICD_ICENABLER
(
i
/
32
))
=
0xffffffff
;
for
(
i
=
0
;
i
<
OS_HWI_MAX_NUM
;
i
+=
32
)
{
/* 32: Interrupt bit width */
GIC_REG_32
(
GICD_ICENABLER
(
i
/
32
))
=
0xffffffff
;
/* 32: Interrupt bit width */
}
/* enable distributor with ARE, group 1 enabled */
...
...
@@ -393,7 +393,7 @@ VOID HalIrqInit(VOID)
/* set spi to boot cpu only. ARE must be enabled */
affinity
=
MpidrToAffinity
(
AARCH64_SYSREG_READ
(
mpidr_el1
));
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
++
)
{
for
(
i
=
32
;
i
<
OS_HWI_MAX_NUM
;
i
++
)
{
/* 32: Start interrupt number */
GIC_REG_64
(
GICD_IROUTER
(
i
))
=
affinity
;
}
...
...
compat/posix/src/malloc.c
浏览文件 @
4b6a6e80
...
...
@@ -40,7 +40,7 @@
*/
void
*
calloc
(
size_t
nitems
,
size_t
size
)
{
/*lint !e578*/
{
size_t
real_size
;
void
*
ptr
=
NULL
;
...
...
@@ -78,7 +78,7 @@ void free(void *ptr)
*/
void
*
malloc
(
size_t
size
)
{
/*lint !e31 !e10*/
{
if
(
size
==
0
)
{
return
NULL
;
}
...
...
@@ -87,7 +87,7 @@ void *malloc(size_t size)
}
void
*
zalloc
(
size_t
size
)
{
/*lint !e10*/
{
void
*
ptr
=
NULL
;
if
(
size
==
0
)
{
...
...
@@ -142,4 +142,4 @@ void *realloc(void *ptr, size_t size)
}
return
LOS_KernelRealloc
(
ptr
,
(
UINT32
)
size
);
}
\ No newline at end of file
}
kernel/base/core/los_swtmr.c
浏览文件 @
4b6a6e80
...
...
@@ -329,56 +329,58 @@ LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle(UINT32 processID)
}
}
LITE_OS_SEC_TEXT_INIT
UINT32
OsSwtmr
Init
(
VOID
)
STATIC
UINT32
SwtmrBase
Init
(
VOID
)
{
UINT32
size
;
UINT16
index
;
UINT32
ret
;
SWTMR_CTRL_S
*
swtmr
=
NULL
;
UINT32
swtmrHandlePoolSize
;
UINT32
cpuid
=
ArchCurrCpuid
();
UINT32
swtmrTaskID
;
UINT32
size
=
sizeof
(
SWTMR_CTRL_S
)
*
LOSCFG_BASE_CORE_SWTMR_LIMIT
;
SWTMR_CTRL_S
*
swtmr
=
(
SWTMR_CTRL_S
*
)
LOS_MemAlloc
(
m_aucSysMem0
,
size
);
/* system resident resource */
if
(
swtmr
==
NULL
)
{
return
LOS_ERRNO_SWTMR_NO_MEMORY
;
}
if
(
cpuid
==
0
)
{
size
=
sizeof
(
SWTMR_CTRL_S
)
*
LOSCFG_BASE_CORE_SWTMR_LIMIT
;
swtmr
=
(
SWTMR_CTRL_S
*
)
LOS_MemAlloc
(
m_aucSysMem0
,
size
);
/* system resident resource */
if
(
swtmr
==
NULL
)
{
ret
=
LOS_ERRNO_SWTMR_NO_MEMORY
;
goto
ERROR
;
}
(
VOID
)
memset_s
(
swtmr
,
size
,
0
,
size
);
g_swtmrCBArray
=
swtmr
;
LOS_ListInit
(
&
g_swtmrFreeList
);
for
(
UINT16
index
=
0
;
index
<
LOSCFG_BASE_CORE_SWTMR_LIMIT
;
index
++
,
swtmr
++
)
{
swtmr
->
usTimerID
=
index
;
LOS_ListTailInsert
(
&
g_swtmrFreeList
,
&
swtmr
->
stSortList
.
sortLinkNode
)
;
}
(
VOID
)
memset_s
(
swtmr
,
size
,
0
,
size
);
g_swtmrCBArray
=
swtmr
;
LOS_ListInit
(
&
g_swtmrFreeList
);
for
(
index
=
0
;
index
<
LOSCFG_BASE_CORE_SWTMR_LIMIT
;
index
++
,
swtmr
++
)
{
swtmr
->
usTimerID
=
index
;
LOS_ListTailInsert
(
&
g_swtmrFreeList
,
&
swtmr
->
stSortList
.
sortLinkNode
);
}
size
=
LOS_MEMBOX_SIZE
(
sizeof
(
SwtmrHandlerItem
),
OS_SWTMR_HANDLE_QUEUE_SIZE
);
g_swtmrHandlerPool
=
(
UINT8
*
)
LOS_MemAlloc
(
m_aucSysMem1
,
size
);
/* system resident resource */
if
(
g_swtmrHandlerPool
==
NULL
)
{
return
LOS_ERRNO_SWTMR_NO_MEMORY
;
}
swtmrHandlePoolSize
=
LOS_MEMBOX_SIZE
(
sizeof
(
SwtmrHandlerItem
),
OS_SWTMR_HANDLE_QUEUE_SIZE
);
ret
=
LOS_MemboxInit
(
g_swtmrHandlerPool
,
size
,
sizeof
(
SwtmrHandlerItem
));
if
(
ret
!=
LOS_OK
)
{
return
LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM
;
}
g_swtmrHandlerPool
=
(
UINT8
*
)
LOS_MemAlloc
(
m_aucSysMem1
,
swtmrHandlePoolSize
);
/* system resident resource */
if
(
g_swtmrHandlerPool
==
NULL
)
{
ret
=
LOS_ERRNO_SWTMR_NO_MEMORY
;
goto
ERROR
;
}
for
(
UINT16
index
=
0
;
index
<
LOSCFG_KERNEL_CORE_NUM
;
index
++
)
{
SwtmrRunQue
*
srq
=
&
g_swtmrRunQue
[
index
];
/* The linked list of all cores must be initialized at core 0 startup for load balancing */
OsSortLinkInit
(
&
srq
->
swtmrSortLink
);
LOS_ListInit
(
&
srq
->
swtmrHandlerQueue
);
srq
->
swtmrTask
=
NULL
;
}
SwtmrDebugDataInit
();
return
LOS_OK
;
}
ret
=
LOS_MemboxInit
(
g_swtmrHandlerPool
,
swtmrHandlePoolSize
,
sizeof
(
SwtmrHandlerItem
));
LITE_OS_SEC_TEXT_INIT
UINT32
OsSwtmrInit
(
VOID
)
{
UINT32
ret
;
UINT32
cpuid
=
ArchCurrCpuid
();
UINT32
swtmrTaskID
;
if
(
cpuid
==
0
)
{
ret
=
SwtmrBaseInit
();
if
(
ret
!=
LOS_OK
)
{
(
VOID
)
LOS_MemFree
(
m_aucSysMem1
,
g_swtmrHandlerPool
);
ret
=
LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM
;
goto
ERROR
;
}
for
(
UINT16
index
=
0
;
index
<
LOSCFG_KERNEL_CORE_NUM
;
index
++
)
{
SwtmrRunQue
*
srq
=
&
g_swtmrRunQue
[
index
];
/* The linked list of all cores must be initialized at core 0 startup for load balancing */
OsSortLinkInit
(
&
srq
->
swtmrSortLink
);
LOS_ListInit
(
&
srq
->
swtmrHandlerQueue
);
srq
->
swtmrTask
=
NULL
;
}
SwtmrDebugDataInit
();
}
ret
=
SwtmrTaskCreate
(
cpuid
,
&
swtmrTaskID
);
...
...
@@ -393,6 +395,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
ERROR:
PRINT_ERR
(
"OsSwtmrInit error! ret = %u
\n
"
,
ret
);
(
VOID
)
LOS_MemFree
(
m_aucSysMem0
,
g_swtmrCBArray
);
g_swtmrCBArray
=
NULL
;
(
VOID
)
LOS_MemFree
(
m_aucSysMem1
,
g_swtmrHandlerPool
);
g_swtmrHandlerPool
=
NULL
;
return
ret
;
}
...
...
kernel/base/core/los_task.c
浏览文件 @
4b6a6e80
...
...
@@ -277,7 +277,7 @@ STATIC INLINE UINT32 OsTaskSyncWait(const LosTaskCB *taskCB)
* triggered right at the timeout has reached, we set the timeout as double
* of the gc period.
*/
if
(
LOS_SemPend
(
taskCB
->
syncSignal
,
OS_MP_GC_PERIOD
*
2
)
!=
LOS_OK
)
{
if
(
LOS_SemPend
(
taskCB
->
syncSignal
,
OS_MP_GC_PERIOD
*
2
)
!=
LOS_OK
)
{
/* 2: Wait 200 ms */
ret
=
LOS_ERRNO_TSK_MP_SYNC_FAILED
;
}
...
...
@@ -1383,8 +1383,8 @@ LITE_OS_SEC_TEXT INT32 LOS_SetTaskScheduler(INT32 taskID, UINT16 policy, UINT16
SCHEDULER_LOCK
(
intSave
);
if
(
taskCB
->
taskStatus
&
OS_TASK_STATUS_UNUSED
)
{
SCHEDULER_UNLOCK
(
intSave
);
return
LOS_EINVAL
;
SCHEDULER_UNLOCK
(
intSave
);
return
LOS_EINVAL
;
}
needSched
=
OsSchedModifyTaskSchedParam
(
taskCB
,
policy
,
priority
);
...
...
kernel/base/include/los_memory_pri.h
浏览文件 @
4b6a6e80
...
...
@@ -54,7 +54,7 @@ extern BOOL OsMemIsHeapNode(const VOID *ptr);
extern
UINT32
OsShellCmdMemCheck
(
INT32
argc
,
const
CHAR
*
argv
[]);
/* memory expand size at least 1/8 of pool size if we can */
#define MEM_EXPAND_SIZE(poolSize) (
poolSize
>> 3)
#define MEM_EXPAND_SIZE(poolSize) (
(poolSize)
>> 3)
#ifdef __cplusplus
#if __cplusplus
...
...
kernel/base/include/los_vm_phys.h
浏览文件 @
4b6a6e80
...
...
@@ -50,7 +50,7 @@ extern "C" {
#define min(x, y) ((x) < (y) ? (x) : (y))
#endif
#define VM_PAGE_TO_PHYS(page) (
page
->physAddr)
#define VM_PAGE_TO_PHYS(page) (
(page)
->physAddr)
#define VM_ORDER_TO_PAGES(order) (1 << (order))
#define VM_ORDER_TO_PHYS(order) (1 << (PAGE_SHIFT + (order)))
#define VM_PHYS_TO_ORDER(phys) (min(LOS_LowBitGet((phys) >> PAGE_SHIFT), VM_LIST_ORDER_MAX - 1))
...
...
kernel/base/include/los_vm_zone.h
浏览文件 @
4b6a6e80
...
...
@@ -86,18 +86,18 @@ extern "C" {
#define PERIPH_UNCACHED_SIZE U32_C(PERIPH_PMM_SIZE)
#endif
#define IO_DEVICE_ADDR(paddr) (
paddr
- PERIPH_PMM_BASE + PERIPH_DEVICE_BASE)
#define IO_CACHED_ADDR(paddr) (
paddr
- PERIPH_PMM_BASE + PERIPH_CACHED_BASE)
#define IO_UNCACHED_ADDR(paddr) (
paddr
- PERIPH_PMM_BASE + PERIPH_UNCACHED_BASE)
#define IO_DEVICE_ADDR(paddr) (
(paddr)
- PERIPH_PMM_BASE + PERIPH_DEVICE_BASE)
#define IO_CACHED_ADDR(paddr) (
(paddr)
- PERIPH_PMM_BASE + PERIPH_CACHED_BASE)
#define IO_UNCACHED_ADDR(paddr) (
(paddr)
- PERIPH_PMM_BASE + PERIPH_UNCACHED_BASE)
#define MEM_CACHED_ADDR(paddr) (
paddr
- DDR_MEM_ADDR + KERNEL_VMM_BASE)
#define MEM_UNCACHED_ADDR(paddr) (
paddr
- DDR_MEM_ADDR + UNCACHED_VMM_BASE)
#define MEM_CACHED_ADDR(paddr) (
(paddr)
- DDR_MEM_ADDR + KERNEL_VMM_BASE)
#define MEM_UNCACHED_ADDR(paddr) (
(paddr)
- DDR_MEM_ADDR + UNCACHED_VMM_BASE)
#define VMM_TO_UNCACHED_ADDR(vaddr) (
vaddr
- KERNEL_VMM_BASE + UNCACHED_VMM_BASE)
#define UNCACHED_TO_VMM_ADDR(vaddr) (
vaddr
- UNCACHED_VMM_BASE + KERNEL_VMM_BASE)
#define VMM_TO_UNCACHED_ADDR(vaddr) (
(vaddr)
- KERNEL_VMM_BASE + UNCACHED_VMM_BASE)
#define UNCACHED_TO_VMM_ADDR(vaddr) (
(vaddr)
- UNCACHED_VMM_BASE + KERNEL_VMM_BASE)
#define VMM_TO_DMA_ADDR(vaddr) (
vaddr
- KERNEL_VMM_BASE + SYS_MEM_BASE)
#define DMA_TO_VMM_ADDR(vaddr) (
vaddr
- SYS_MEM_BASE + KERNEL_VMM_BASE)
#define VMM_TO_DMA_ADDR(vaddr) (
(vaddr)
- KERNEL_VMM_BASE + SYS_MEM_BASE)
#define DMA_TO_VMM_ADDR(vaddr) (
(vaddr)
- SYS_MEM_BASE + KERNEL_VMM_BASE)
#if (PERIPH_UNCACHED_BASE >= (0xFFFFFFFFU - PERIPH_UNCACHED_SIZE))
#error "Kernel virtual memory space has overflowed!"
...
...
kernel/base/mem/tlsf/los_memory.c
浏览文件 @
4b6a6e80
...
...
@@ -636,7 +636,7 @@ STATIC INLINE UINT32 OsMemFreeListIndexGet(UINT32 size)
}
STATIC
INLINE
struct
OsMemFreeNodeHead
*
OsMemFindCurSuitableBlock
(
struct
OsMemPoolHead
*
poolHead
,
UINT32
index
,
UINT32
size
)
UINT32
index
,
UINT32
size
)
{
struct
OsMemFreeNodeHead
*
node
=
NULL
;
...
...
@@ -649,9 +649,12 @@ STATIC INLINE struct OsMemFreeNodeHead *OsMemFindCurSuitableBlock(struct OsMemPo
return
NULL
;
}
#define BITMAP_INDEX(index) ((index) >> 5)
STATIC
INLINE
UINT32
OsMemNotEmptyIndexGet
(
struct
OsMemPoolHead
*
poolHead
,
UINT32
index
)
{
UINT32
mask
=
poolHead
->
freeListBitmap
[
index
>>
5
];
/* 5: Divide by 32 to calculate the index of the bitmap array. */
UINT32
mask
;
mask
=
poolHead
->
freeListBitmap
[
BITMAP_INDEX
(
index
)];
mask
&=
~
((
1
<<
(
index
&
OS_MEM_BITMAP_MASK
))
-
1
);
if
(
mask
!=
0
)
{
index
=
OsMemFFS
(
mask
)
+
(
index
&
~
OS_MEM_BITMAP_MASK
);
...
...
@@ -685,8 +688,8 @@ STATIC INLINE struct OsMemFreeNodeHead *OsMemFindNextSuitableBlock(VOID *pool, U
goto
DONE
;
}
for
(
index
=
LOS_Align
(
index
+
1
,
32
);
index
<
OS_MEM_FREE_LIST_COUNT
;
index
+=
32
)
{
mask
=
poolHead
->
freeListBitmap
[
index
>>
5
];
/* 5: Divide by 32 to calculate the index of the bitmap array. */
for
(
index
=
LOS_Align
(
index
+
1
,
32
);
index
<
OS_MEM_FREE_LIST_COUNT
;
index
+=
32
)
{
/* 32: align size */
mask
=
poolHead
->
freeListBitmap
[
BITMAP_INDEX
(
index
)];
if
(
mask
!=
0
)
{
index
=
OsMemFFS
(
mask
)
+
index
;
goto
DONE
;
...
...
@@ -707,12 +710,12 @@ DONE:
STATIC
INLINE
VOID
OsMemSetFreeListBit
(
struct
OsMemPoolHead
*
head
,
UINT32
index
)
{
head
->
freeListBitmap
[
index
>>
5
]
|=
1U
<<
(
index
&
0x1f
);
/* 5: Divide by 32 to calculate the index of the bitmap array. */
head
->
freeListBitmap
[
BITMAP_INDEX
(
index
)]
|=
1U
<<
(
index
&
0x1f
);
}
STATIC
INLINE
VOID
OsMemClearFreeListBit
(
struct
OsMemPoolHead
*
head
,
UINT32
index
)
{
head
->
freeListBitmap
[
index
>>
5
]
&=
~
(
1U
<<
(
index
&
0x1f
));
/* 5: Divide by 32 to calculate the index of the bitmap array. */
head
->
freeListBitmap
[
BITMAP_INDEX
(
index
)]
&=
~
(
1U
<<
(
index
&
0x1f
));
}
STATIC
INLINE
VOID
OsMemListAdd
(
struct
OsMemPoolHead
*
pool
,
UINT32
listIndex
,
struct
OsMemFreeNodeHead
*
node
)
...
...
@@ -1183,42 +1186,45 @@ STATIC INLINE BOOL OsMemIsNodeValid(const struct OsMemNodeHead *node, const stru
return
TRUE
;
}
STATIC
UINT32
OsMemCheckUsedNode
(
const
struct
OsMemPoolHead
*
pool
,
const
struct
OsMemNodeHead
*
node
)
STATIC
BOOL
MemCheckUsedNode
(
const
struct
OsMemPoolHead
*
pool
,
const
struct
OsMemNodeHead
*
node
,
const
struct
OsMemNodeHead
*
startNode
,
const
struct
OsMemNodeHead
*
endNode
)
{
struct
OsMemNodeHead
*
startNode
=
(
struct
OsMemNodeHead
*
)
OS_MEM_FIRST_NODE
(
pool
);
struct
OsMemNodeHead
*
endNode
=
(
struct
OsMemNodeHead
*
)
OS_MEM_END_NODE
(
pool
,
pool
->
info
.
totalSize
);
struct
OsMemNodeHead
*
nextNode
=
NULL
;
BOOL
doneFlag
=
FALSE
;
if
(
!
OsMemIsNodeValid
(
node
,
startNode
,
endNode
,
pool
))
{
return
FALSE
;
}
do
{
do
{
if
(
!
OsMemIsNodeValid
(
node
,
startNode
,
endNode
,
pool
))
{
break
;
}
if
(
!
OS_MEM_NODE_GET_USED_FLAG
(
node
->
sizeAndFlag
))
{
return
FALSE
;
}
if
(
!
OS_MEM_NODE_GET_USED_FLAG
(
node
->
sizeAndFlag
))
{
break
;
}
const
struct
OsMemNodeHead
*
nextNode
=
OS_MEM_NEXT_NODE
(
node
);
if
(
!
OsMemIsNodeValid
(
nextNode
,
startNode
,
endNode
,
pool
))
{
return
FALSE
;
}
nextNode
=
OS_MEM_NEXT_NODE
(
node
);
if
(
!
OsMemIsNodeValid
(
nextNode
,
startNode
,
endNode
,
pool
))
{
break
;
}
if
(
!
OS_MEM_NODE_GET_LAST_FLAG
(
nextNode
->
sizeAndFlag
))
{
if
(
nextNode
->
ptr
.
prev
!=
node
)
{
return
FALSE
;
}
}
if
(
!
OS_MEM_NODE_GET_LAST_FLAG
(
nextNode
->
sizeAndFlag
))
{
if
(
nextNode
->
ptr
.
prev
!=
node
)
{
break
;
}
}
if
((
node
!=
startNode
)
&&
((
!
OsMemIsNodeValid
(
node
->
ptr
.
prev
,
startNode
,
endNode
,
pool
))
||
(
OS_MEM_NEXT_NODE
(
node
->
ptr
.
prev
)
!=
node
)))
{
return
FALSE
;
}
if
((
node
!=
startNode
)
&&
((
!
OsMemIsNodeValid
(
node
->
ptr
.
prev
,
startNode
,
endNode
,
pool
))
||
(
OS_MEM_NEXT_NODE
(
node
->
ptr
.
prev
)
!=
node
)))
{
break
;
}
doneFlag
=
TRUE
;
}
while
(
0
);
return
TRUE
;
}
STATIC
UINT32
OsMemCheckUsedNode
(
const
struct
OsMemPoolHead
*
pool
,
const
struct
OsMemNodeHead
*
node
)
{
struct
OsMemNodeHead
*
startNode
=
(
struct
OsMemNodeHead
*
)
OS_MEM_FIRST_NODE
(
pool
);
struct
OsMemNodeHead
*
endNode
=
(
struct
OsMemNodeHead
*
)
OS_MEM_END_NODE
(
pool
,
pool
->
info
.
totalSize
);
BOOL
doneFlag
=
FALSE
;
do
{
doneFlag
=
MemCheckUsedNode
(
pool
,
node
,
startNode
,
endNode
);
if
(
!
doneFlag
)
{
#if OS_MEM_EXPAND_ENABLE
if
(
OsMemIsLastSentinelNode
(
endNode
)
==
FALSE
)
{
...
...
@@ -1291,16 +1297,17 @@ STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead
UINT32
LOS_MemFree
(
VOID
*
pool
,
VOID
*
ptr
)
{
UINT32
intSave
;
UINT32
ret
=
LOS_NOK
;
if
((
pool
==
NULL
)
||
(
ptr
==
NULL
)
||
!
OS_MEM_IS_ALIGNED
(
pool
,
sizeof
(
VOID
*
))
||
!
OS_MEM_IS_ALIGNED
(
ptr
,
sizeof
(
VOID
*
)))
{
return
LOS_NOK
;
return
ret
;
}
OsHookCall
(
LOS_HOOK_TYPE_MEM_FREE
,
pool
,
ptr
);
UINT32
ret
=
LOS_NOK
;
struct
OsMemPoolHead
*
poolHead
=
(
struct
OsMemPoolHead
*
)
pool
;
struct
OsMemNodeHead
*
node
=
NULL
;
UINT32
intSave
;
do
{
UINT32
gapSize
=
*
(
UINT32
*
)((
UINTPTR
)
ptr
-
sizeof
(
UINT32
));
...
...
@@ -1397,7 +1404,7 @@ STATIC INLINE VOID *OsGetRealPtr(const VOID *pool, VOID *ptr)
}
STATIC
INLINE
VOID
*
OsMemRealloc
(
struct
OsMemPoolHead
*
pool
,
const
VOID
*
ptr
,
struct
OsMemNodeHead
*
node
,
UINT32
size
,
UINT32
intSave
)
struct
OsMemNodeHead
*
node
,
UINT32
size
,
UINT32
intSave
)
{
struct
OsMemNodeHead
*
nextNode
=
NULL
;
UINT32
allocSize
=
OS_MEM_ALIGN
(
size
+
OS_MEM_NODE_HEAD_SIZE
,
OS_MEM_ALIGN_SIZE
);
...
...
@@ -1619,7 +1626,7 @@ STATIC UINT32 OsMemAddrValidCheckPrint(const VOID *pool, struct OsMemFreeNodeHea
}
STATIC
UINT32
OsMemIntegrityCheckSub
(
struct
OsMemNodeHead
**
tmpNode
,
const
VOID
*
pool
,
const
struct
OsMemNodeHead
*
endNode
)
const
struct
OsMemNodeHead
*
endNode
)
{
if
(
!
OS_MEM_MAGIC_VALID
(
*
tmpNode
))
{
OsMemMagicCheckPrint
(
tmpNode
);
...
...
@@ -1635,7 +1642,7 @@ STATIC UINT32 OsMemIntegrityCheckSub(struct OsMemNodeHead **tmpNode, const VOID
}
STATIC
UINT32
OsMemFreeListNodeCheck
(
const
struct
OsMemPoolHead
*
pool
,
const
struct
OsMemFreeNodeHead
*
node
)
const
struct
OsMemFreeNodeHead
*
node
)
{
if
(
!
OsMemAddrValidCheck
(
pool
,
node
)
||
!
OsMemAddrValidCheck
(
pool
,
node
->
prev
)
||
...
...
@@ -1698,7 +1705,7 @@ OUT:
}
STATIC
UINT32
OsMemIntegrityCheck
(
const
struct
OsMemPoolHead
*
pool
,
struct
OsMemNodeHead
**
tmpNode
,
struct
OsMemNodeHead
**
preNode
)
struct
OsMemNodeHead
**
preNode
)
{
struct
OsMemNodeHead
*
endNode
=
OS_MEM_END_NODE
(
pool
,
pool
->
info
.
totalSize
);
...
...
@@ -1846,7 +1853,7 @@ ERROR_OUT:
}
STATIC
INLINE
VOID
OsMemInfoGet
(
struct
OsMemPoolHead
*
poolInfo
,
struct
OsMemNodeHead
*
node
,
LOS_MEM_POOL_STATUS
*
poolStatus
)
LOS_MEM_POOL_STATUS
*
poolStatus
)
{
UINT32
totalUsedSize
=
0
;
UINT32
totalFreeSize
=
0
;
...
...
@@ -1994,8 +2001,10 @@ UINT32 LOS_MemFreeNodeShow(VOID *pool)
}
else
{
UINT32
val
=
1
<<
(((
index
-
OS_MEM_SMALL_BUCKET_COUNT
)
>>
OS_MEM_SLI
)
+
OS_MEM_LARGE_START_BUCKET
);
UINT32
offset
=
val
>>
OS_MEM_SLI
;
PRINTK
(
"size: [%#x, %#x], num: %u
\n
"
,
(
offset
*
((
index
-
OS_MEM_SMALL_BUCKET_COUNT
)
%
(
1
<<
OS_MEM_SLI
)))
+
val
,
((
offset
*
(((
index
-
OS_MEM_SMALL_BUCKET_COUNT
)
%
(
1
<<
OS_MEM_SLI
))
+
1
))
+
val
-
1
),
countNum
[
index
]);
PRINTK
(
"size: [%#x, %#x], num: %u
\n
"
,
(
offset
*
((
index
-
OS_MEM_SMALL_BUCKET_COUNT
)
%
(
1
<<
OS_MEM_SLI
)))
+
val
,
((
offset
*
(((
index
-
OS_MEM_SMALL_BUCKET_COUNT
)
%
(
1
<<
OS_MEM_SLI
))
+
1
))
+
val
-
1
),
countNum
[
index
]);
}
}
PRINTK
(
"
\n
********************************************************************
\n\n
"
);
...
...
kernel/base/sched/sched_sq/los_sched.c
浏览文件 @
4b6a6e80
...
...
@@ -161,6 +161,29 @@ UINT32 OsShellShowTickRespo(VOID)
#endif
#ifdef LOSCFG_SCHED_DEBUG
STATIC
VOID
SchedDataGet
(
LosTaskCB
*
taskCB
,
UINT64
*
runTime
,
UINT64
*
timeSlice
,
UINT64
*
pendTime
,
UINT64
*
schedWait
)
{
if
(
taskCB
->
schedStat
.
switchCount
>=
1
)
{
UINT64
averRunTime
=
taskCB
->
schedStat
.
runTime
/
taskCB
->
schedStat
.
switchCount
;
*
runTime
=
(
averRunTime
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
if
(
taskCB
->
schedStat
.
timeSliceCount
>
1
)
{
UINT64
averTimeSlice
=
taskCB
->
schedStat
.
timeSliceTime
/
(
taskCB
->
schedStat
.
timeSliceCount
-
1
);
*
timeSlice
=
(
averTimeSlice
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
if
(
taskCB
->
schedStat
.
pendCount
>
1
)
{
UINT64
averPendTime
=
taskCB
->
schedStat
.
pendTime
/
taskCB
->
schedStat
.
pendCount
;
*
pendTime
=
(
averPendTime
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
if
(
taskCB
->
schedStat
.
waitSchedCount
>
0
)
{
UINT64
averSchedWait
=
taskCB
->
schedStat
.
waitSchedTime
/
taskCB
->
schedStat
.
waitSchedCount
;
*
schedWait
=
(
averSchedWait
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
}
UINT32
OsShellShowSchedParam
(
VOID
)
{
UINT64
averRunTime
;
...
...
@@ -200,25 +223,7 @@ UINT32 OsShellShowSchedParam(VOID)
averPendTime
=
0
;
averSchedWait
=
0
;
if
(
taskCB
->
schedStat
.
switchCount
>=
1
)
{
averRunTime
=
taskCB
->
schedStat
.
runTime
/
taskCB
->
schedStat
.
switchCount
;
averRunTime
=
(
averRunTime
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
if
(
taskCB
->
schedStat
.
timeSliceCount
>
1
)
{
averTimeSlice
=
taskCB
->
schedStat
.
timeSliceTime
/
(
taskCB
->
schedStat
.
timeSliceCount
-
1
);
averTimeSlice
=
(
averTimeSlice
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
if
(
taskCB
->
schedStat
.
pendCount
>
1
)
{
averPendTime
=
taskCB
->
schedStat
.
pendTime
/
taskCB
->
schedStat
.
pendCount
;
averPendTime
=
(
averPendTime
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
if
(
taskCB
->
schedStat
.
waitSchedCount
>
0
)
{
averSchedWait
=
taskCB
->
schedStat
.
waitSchedTime
/
taskCB
->
schedStat
.
waitSchedCount
;
averSchedWait
=
(
averSchedWait
*
OS_NS_PER_CYCLE
)
/
OS_SYS_NS_PER_US
;
}
SchedDataGet
(
taskCB
,
&
averRunTime
,
&
averTimeSlice
,
&
averPendTime
,
&
averSchedWait
);
PRINTK
(
"%5u%19llu%15llu%19llu%18llu%19llu%18llu %-32s
\n
"
,
taskCB
->
taskID
,
averRunTime
,
taskCB
->
schedStat
.
switchCount
,
...
...
kernel/extended/trace/pipeline/serial/trace_pipeline_serial.c
浏览文件 @
4b6a6e80
...
...
@@ -57,6 +57,9 @@ UINT32 SerialPipelineInit(VOID)
UINT32
SerialDataReceive
(
UINT8
*
data
,
UINT32
size
,
UINT32
timeout
)
{
(
VOID
)
data
;
(
VOID
)
size
;
(
VOID
)
timeout
;
return
LOS_OK
;
}
...
...
net/lwip-2.1/enhancement/src/fixme.c
浏览文件 @
4b6a6e80
...
...
@@ -144,7 +144,7 @@ err_t netifapi_dhcps_stop(struct netif *netif)
*/
static
void
tcp_unlock_accept
(
ip6_addr_t
*
ipaddr
)
{
(
void
)
ipaddr
;
}
static
void
netif_ip6_addr_setinvalid
(
struct
netif
*
netif
,
const
ip6_addr_t
*
addr6
)
...
...
@@ -327,22 +327,32 @@ err_t netif_set_hwaddr(struct netif *netif, const unsigned char *hw_addr, int hw
err_t
etharp_update_arp_entry
(
struct
netif
*
netif
,
const
ip4_addr_t
*
ipaddr
,
struct
eth_addr
*
ethaddr
,
u8_t
flags
)
{
(
void
)
netif
;
(
void
)
ipaddr
;
(
void
)
ethaddr
;
(
void
)
flags
;
return
0
;
}
err_t
etharp_delete_arp_entry
(
struct
netif
*
netif
,
ip4_addr_t
*
ipaddr
)
{
(
void
)
netif
;
(
void
)
ipaddr
;
return
0
;
}
err_t
lwip_dns_setserver
(
u8_t
numdns
,
ip_addr_t
*
dnsserver
)
{
(
void
)
numdns
;
(
void
)
dnsserver
;
return
0
;
}
err_t
lwip_dns_getserver
(
u8_t
numdns
,
ip_addr_t
*
dnsserver
)
{
(
void
)
numdns
;
(
void
)
dnsserver
;
return
0
;
}
...
...
@@ -368,6 +378,9 @@ sys_sem_t dup_addr_detect;
int
lwip_sntp_start
(
int
server_num
,
char
**
sntp_server
,
struct
timeval
*
time
)
{
(
void
)
server_num
;
(
void
)
sntp_server
;
(
void
)
time
;
return
0
;
}
...
...
net/lwip-2.1/porting/src/sockets.c
浏览文件 @
4b6a6e80
...
...
@@ -1506,7 +1506,7 @@ static int do_ioctl_SIOCGIFCONF(int sockfd, long cmd, void *argp)
return
-
1
;
}
nbytes
=
ifc
.
ifc_len
;
if
(
nbytes
<
0
)
{
if
(
nbytes
<
=
0
)
{
set_errno
(
EINVAL
);
return
-
1
;
}
...
...
testsuites/unittest/basic/exc/full/it_test_fexecve_001.cpp
浏览文件 @
4b6a6e80
...
...
@@ -62,6 +62,7 @@ static int TestCase(void)
rc
=
stat
(
"/bin/shell"
,
&
st
);
if
(
rc
==
-
1
)
{
perror
(
"stat"
);
close
(
shmFd
);
return
-
1
;
}
...
...
@@ -69,12 +70,14 @@ static int TestCase(void)
rc
=
ftruncate
(
shmFd
,
st
.
st_size
);
if
(
rc
==
-
1
)
{
perror
(
"ftruncate"
);
close
(
shmFd
);
return
-
1
;
}
p
=
mmap
(
nullptr
,
st
.
st_size
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
shmFd
,
0
);
if
(
p
==
MAP_FAILED
)
{
perror
(
"mmap"
);
close
(
shmFd
);
return
-
1
;
}
...
...
@@ -83,6 +86,7 @@ static int TestCase(void)
if
(
fd
==
-
1
)
{
perror
(
"openls"
);
munmap
(
p
,
st
.
st_size
);
close
(
shmFd
);
return
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录