未验证 提交 ae7a374e 编写于 作者: O openharmony_ci 提交者: Gitee

!573 M核安全隔离

Merge pull request !573 from Zhaotianyu/0117sec_init
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
......@@ -600,7 +600,6 @@ endmenu
######################## config options os security #######################
menu "Security"
osource "security/Kconfig"
config SECURE_TRUSTZONE
bool "Enable ARM TrustZone"
default n
......@@ -615,6 +614,13 @@ config SECURE_STACK_DEFAULT_SIZE
depends on SECURE_TRUSTZONE
help
The secure stack must be allocated before the task calls non-secure functions.
config SECURE
bool "Enable Security"
default n
select MPU_ENABLE
config MPU_ENABLE
bool "Enable MPU"
default n
endmenu
menu "Test"
......
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
......@@ -121,6 +121,29 @@ typedef struct TagTskContext {
*/
extern VOID HalStartToRun(VOID);
#if (LOSCFG_SECURE == 1)
/**
* @ingroup los_config
* @brief: User Task Stack Initialize.
*
* @par Description:
* This API is used to init a user task stack.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: context [IN] Task context.
* @param: taskEntry [IN] Task entry function address.
* @param: stack [IN] Task stack address.
*
* @retval None.
*
* @par Dependency: <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
#endif
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -148,6 +148,15 @@ VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandl
return (VOID *)context;
}
#if (LOSCFG_SECURE == 1)
VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
{
context->uwR0 = stack;
context->uwPC = (UINT32)taskEntry;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
}
#endif
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
......
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
......@@ -40,6 +40,12 @@
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
.equ OS_NVIC_PENDSVSET, 0x10000000
.equ OS_TASK_STATUS_RUNNING, 0x0010
.equ OS_CONTROL_FPCA_ENABLE, 0x4
.equ OS_CONTROL_KERNEL_MODE, 0x2
#if (LOSCFG_SECURE == 1)
.equ OS_CONTROL_USER_MODE, 0x3
.equ OS_TASK_FLAG_USER_TASK, 0x0200
#endif
.section .text
.thumb
......@@ -63,7 +69,7 @@ HalStartToRun:
ldr r5, =OS_NVIC_PENDSV_PRI
str r5, [r4]
mov r0, #2
mov r0, #OS_CONTROL_KERNEL_MODE
msr CONTROL, r0
ldr r1, =g_losTask
......@@ -141,7 +147,7 @@ ArchTaskSchedule:
bx lr
dsb
isb
.fnend
.fnend
.type HalPendSV, %function
.global HalPendSV
......@@ -194,6 +200,14 @@ SignalContextRestore:
vldmia r1!, {d8-d15}
__DisabledFPU2:
#if (LOSCFG_SECURE == 1)
ldrh r7, [r0, #4]
tst r7, #OS_TASK_FLAG_USER_TASK
ite eq
moveq r3, #OS_CONTROL_KERNEL_MODE
movne r3, #OS_CONTROL_USER_MODE
msr CONTROL, r3
#endif
ldmfd r1!, {r4-r12}
msr psp, r1
......
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
......@@ -57,15 +57,15 @@
.equ FLAG_ADDR_VALID, 0x10000
.equ FLAG_HWI_ACTIVE, 0x20000
.equ FLAG_NO_FLOAT, 0x10000000
.equ FLAG_NO_FLOAT, 0x10000000
.equ OS_NVIC_FSR , 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
.equ OS_NVIC_HFSR , 0xE000ED2C //HardFault State Register
.equ OS_NVIC_BFAR , 0xE000ED38
.equ OS_NVIC_MMAR , 0xE000ED34
.equ OS_NVIC_ACT_BASE , 0xE000E300
.equ OS_NVIC_SHCSRS , 0xE000ED24
.equ OS_NVIC_SHCSR_MASK , 0xC00
.equ OS_NVIC_FSR, 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
.equ OS_NVIC_HFSR, 0xE000ED2C //HardFault State Register
.equ OS_NVIC_BFAR, 0xE000ED38
.equ OS_NVIC_MMAR, 0xE000ED34
.equ OS_NVIC_ACT_BASE, 0xE000E300
.equ OS_NVIC_SHCSRS, 0xE000ED24
.equ OS_NVIC_SHCSR_MASK, 0xC00
.type HalExcNMI, %function
.global HalExcNMI
......@@ -155,10 +155,25 @@ HalExcSvcCall:
.cantunwind
TST LR, #0x4
ITE EQ
MRSEQ R0, MSP
MRSNE R0, PSP
LDR R1, [R0,#24]
LDRB R0, [R1,#-2]
MRSEQ R1, MSP
BNE _svcCallFromPsp
B _svcCall
_svcCallFromPsp:
#ifdef LOSCFG_SECURE
PUSH {R0-R12, LR}
MOV R0, SP
CPSIE I
BL OsSyscallHandle
CPSID I
MRS R12, PSP
STM R12, {R0-R1}
POP {R0-R12, LR}
BX LR
#endif
MRS R1, PSP
_svcCall:
LDR R0, [R1,#24]
LDRB R0, [R0,#-2]
MOV R1, #0
B osExcDispatch
.fnend
......@@ -284,7 +299,7 @@ _ExcInMSP:
PUSH {R4-R12} // store message-->exc: {R4-R12}
VPUSH {D8-D15} // FPU
B _handleEntry
.fnend
.fnend
.type _NoFloatInMsp, %function
.global _NoFloatInMsp
......@@ -298,7 +313,7 @@ _NoFloatInMsp:
PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
.fnend
.type _hwiActiveCheckNext, %function
.global _hwiActiveCheckNext
......@@ -347,7 +362,7 @@ _hwiActiveCheckNext:
VSTMDB R2!, {D8-D15} // FPU
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
.fnend
.type _NoFloatInPsp, %function
.global _NoFloatInPsp
......@@ -367,7 +382,7 @@ _NoFloatInPsp:
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
STMFD R2!, {R4-R11}
ORR R0, R0, #FLAG_NO_FLOAT
.fnend
.fnend
.type _handleEntry, %function
.global _handleEntry
......@@ -380,4 +395,4 @@ _handleEntry:
B HalExcHandleEntry
NOP
.fnend
.fnend
......@@ -137,7 +137,7 @@ ArchTaskSchedule:
dsb
isb
bx lr
.fnend
.fnend
.type HalPendSV, %function
.global HalPendSV
......@@ -178,7 +178,7 @@ TaskContextSwitch:
str r0, [r5]
ldr r1, [r0]
SignalContextRestore:
SignalContextRestore:
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
vldmia r1!, {d8-d15}
......
......@@ -29,9 +29,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
.syntax unified
.arch armv7e-m
.thumb
.syntax unified
.arch armv7e-m
.thumb
.fpu fpv5-d16
.section .text
......@@ -284,7 +284,7 @@ _ExcInMSP:
PUSH {R4-R12} // store message-->exc: {R4-R12}
VPUSH {D8-D15}
B _handleEntry
.fnend
.fnend
.type _NoFloatInMsp, %function
.global _NoFloatInMsp
......@@ -298,7 +298,7 @@ _NoFloatInMsp:
PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
.fnend
.type _hwiActiveCheckNext, %function
.global _hwiActiveCheckNext
......@@ -347,7 +347,7 @@ _hwiActiveCheckNext:
VSTMDB R2!, {D8-D15}
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
.fnend
.type _NoFloatInPsp, %function
.global _NoFloatInPsp
......@@ -367,7 +367,7 @@ _NoFloatInPsp:
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
STMFD R2!, {R4-R11}
ORR R0, R0, #FLAG_NO_FLOAT
.fnend
.fnend
.type _handleEntry, %function
.global _handleEntry
......@@ -380,5 +380,5 @@ _handleEntry:
B HalExcHandleEntry
NOP
.fnend
.fnend
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
......@@ -41,6 +41,7 @@ group("components") {
"lms",
"net",
"power",
"security",
"shell",
"signal",
"trace",
......@@ -57,6 +58,7 @@ config("public") {
"fs:public",
"net:public",
"power:public",
"security:public",
"shell:public",
"trace:public",
"lmk:public",
......
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
module_group(module_name) {
modules = [
"box",
"syscall",
"userlib",
]
}
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_switch = defined(LOSCFG_SECURE)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [ "los_box.c" ]
}
config("public") {
include_dirs = [ "./" ]
}
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_box.h"
#include "los_task.h"
#include "los_context.h"
#include "los_arch_context.h"
#include "los_debug.h"
static UserTaskCB g_UserTaskCBArray[LOSCFG_BASE_CORE_TSK_LIMIT] = { 0 };
static LosBoxCB g_boxCB[1];
VOID OsUserTaskInit(UINT32 taskID, UINTPTR entry, UINTPTR userArea, UINTPTR userSp)
{
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
taskCB->taskStatus |= OS_TASK_FLAG_USER_TASK;
HalUserTaskStackInit(taskCB->stackPointer, entry, userSp);
g_UserTaskCBArray[taskID].userArea = userArea;
g_UserTaskCBArray[taskID].userSp = userSp;
g_UserTaskCBArray[taskID].boxID = g_UserTaskCBArray[g_losTask.runTask->taskID].boxID;
}
VOID OsUserTaskDelete(UINT32 taskID)
{
memset_s(&g_UserTaskCBArray[taskID], sizeof(UserTaskCB), 0, sizeof(UserTaskCB));
}
UserTaskCB *OsGetUserTaskCB(UINT32 taskID)
{
return &g_UserTaskCBArray[taskID];
}
static UINT32 BoxInit(VOID)
{
UINT32 count = sizeof(g_boxCB) / sizeof(LosBoxCB);
for (UINT32 i = 0; i < count; i++) {
LosBoxCB *box = &g_boxCB[i];
box->boxStackAddr = box->boxStartAddr + box->boxSize - box->boxStackSize;
}
return LOS_OK;
}
VOID OsBoxStart(VOID)
{
UINT32 ret, taskID;
UINT32 count = sizeof(g_boxCB) / sizeof(LosBoxCB);
TSK_INIT_PARAM_S taskInitParam = { 0 };
for (UINT32 i = 0; i < count; i++) {
LosBoxCB *box = &g_boxCB[i];
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)box->boxStartAddr;
taskInitParam.uwStackSize = 0x1000;
taskInitParam.pcName = "BoxMainTask";
taskInitParam.usTaskPrio = LOSCFG_BOX_PRIO;
taskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
ret = LOS_TaskCreateOnly(&taskID, &taskInitParam);
if (ret != LOS_OK) {
PRINT_ERR("Create box %u main task failed, Error 0x%x\n", i, ret);
return;
}
OsUserTaskInit(taskID, (UINTPTR)_ulibc_start, 0, box->boxStackAddr + box->boxStackSize);
g_UserTaskCBArray[taskID].boxID = i;
ret = LOS_TaskResume(taskID);
if (ret != LOS_OK) {
PRINT_ERR("Box(%u) resume task %u failed, Error 0x%x\n", i, taskID, ret);
return;
}
}
}
UINT32 LOS_BoxStart(VOID)
{
UINT32 ret, taskID;
TSK_INIT_PARAM_S taskInitParam = { 0 };
ret = BoxInit();
if (ret != LOS_OK) {
PRINT_ERR("Box init failed! Error 0x%x\n", ret);
return ret;
}
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsBoxStart;
taskInitParam.uwStackSize = 0x1000;
taskInitParam.pcName = "BoxStart";
taskInitParam.usTaskPrio = LOSCFG_BOX_START_PRIO;
taskInitParam.uwResved = 0;
return LOS_TaskCreate(&taskID, &taskInitParam);
}
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_BOX_H
#define _LOS_BOX_H
#include "los_compiler.h"
#define LOSCFG_BOX_START_PRIO 5
#define LOSCFG_BOX_PRIO 10
/*
* -------------------- boxStartAddr(main)
* | .text |
* | -----------------
* | .data |
* | ----------------- boxHeapAddr
* | .heap |
* | ----------------- boxStackAddr
* | boxStackSize |
* --------------------
*/
typedef struct {
UINTPTR boxStartAddr;
UINTPTR boxSize;
UINTPTR boxHeapAddr;
UINTPTR boxHeapSize;
UINTPTR boxStackAddr; /* box main task stack addr */
UINTPTR boxStackSize;
} LosBoxCB;
typedef struct {
unsigned long userArea;
unsigned long userSp;
unsigned int boxID;
} UserTaskCB;
VOID OsUserTaskInit(UINT32 taskID, UINTPTR entry, UINTPTR userArea, UINTPTR userSp);
VOID OsUserTaskDelete(UINT32 taskID);
UserTaskCB *OsGetUserTaskCB(UINT32 taskID);
UINT32 LOS_BoxStart(VOID);
extern INT32 _ulibc_start(UINTPTR main);
#endif
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_switch = defined(LOSCFG_SECURE)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"los_syscall.c",
"pthread_syscall.c",
]
}
config("public") {
include_dirs = [ "./" ]
}
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define GNU_SOURCE
#include "los_syscall.h"
#include "los_context.h"
#include "los_task.h"
#include "los_debug.h"
#include "unistd.h"
#include "errno.h"
#define SYS_CALL_NUM_LIMIT (__NR_syscallend + 1)
#define SYS_CALL_NUM_REG_OFFSET 7
#define NARG_BITS 4
#define NARG_MASK 0x0F
#define NARG_PER_BYTE 2
typedef UINT32 (*SyscallFun1)(UINT32);
typedef UINT32 (*SyscallFun2)(UINT32, UINT32);
typedef UINT32 (*SyscallFun3)(UINT32, UINT32, UINT32);
typedef UINT32 (*SyscallFun4)(UINT32, UINT32, UINT32, UINT32);
typedef UINT32 (*SyscallFun5)(UINT32, UINT32, UINT32, UINT32, UINT32);
typedef UINT32 (*SyscallFun7)(UINT32, UINT32, UINT32, UINT32, UINT32, UINT32, UINT32);
static UINTPTR g_syscallHandle[SYS_CALL_NUM_LIMIT] = {0};
static UINT8 g_syscallNArgs[(SYS_CALL_NUM_LIMIT + 1) / NARG_PER_BYTE] = {0};
void OsSyscallHandleInit(void)
{
#define SYSCALL_HAND_DEF(id, fun, rType, nArg) \
if ((id) < SYS_CALL_NUM_LIMIT) { \
g_syscallHandle[(id)] = (UINTPTR)(fun); \
g_syscallNArgs[(id) / NARG_PER_BYTE] |= ((id) & 1) ? (nArg) << NARG_BITS : (nArg); \
} \
#include "syscall_lookup.h"
#undef SYSCALL_HAND_DEF
}
/* The SYSCALL ID is in R7 on entry. Parameters follow in R0..R6 */
VOID OsSyscallHandle(UINT32 *args)
{
UINT32 ret;
UINT8 nArgs;
UINTPTR handle;
UINT32 svcNum = (UINT32)args[SYS_CALL_NUM_REG_OFFSET];
if (svcNum >= SYS_CALL_NUM_LIMIT) {
PRINT_ERR("Syscall ID: error %d !!!\n", svcNum);
return;
}
handle = g_syscallHandle[svcNum];
nArgs = g_syscallNArgs[svcNum / NARG_PER_BYTE]; /* 4bit per nargs */
nArgs = (svcNum & 1) ? (nArgs >> NARG_BITS) : (nArgs & NARG_MASK);
if ((handle == 0) || (nArgs > ARG_NUM_7)) {
PRINT_ERR("Unsupported syscall ID: %d nArgs: %d\n", svcNum, nArgs);
args[ARG_NUM_0] = -ENOSYS;
return;
}
switch (nArgs) {
case ARG_NUM_0:
case ARG_NUM_1:
ret = (*(SyscallFun1)handle)(args[ARG_NUM_0]);
break;
case ARG_NUM_2:
ret = (*(SyscallFun2)handle)(args[ARG_NUM_0], args[ARG_NUM_1]);
break;
case ARG_NUM_3:
ret = (*(SyscallFun3)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2]);
break;
case ARG_NUM_4:
ret = (*(SyscallFun4)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2], args[ARG_NUM_3]);
break;
case ARG_NUM_5:
ret = (*(SyscallFun5)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2], args[ARG_NUM_3], \
args[ARG_NUM_4]);
break;
default:
ret = (*(SyscallFun7)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2], args[ARG_NUM_3], \
args[ARG_NUM_4], args[ARG_NUM_5], args[ARG_NUM_6]);
}
args[ARG_NUM_0] = ret;
return;
}
\ No newline at end of file
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_SYSCALL_H
#define _LOS_SYSCALL_H
#include "los_arch_context.h"
#include "los_task.h"
#include "syscall.h"
void OsSyscallHandleInit(void);
void OsSyscallHandle(UINT32 *regs);
/* pthread */
int SysUserTaskCreate(unsigned long entry, unsigned long userArea, unsigned long userSp, BOOL joinable);
int SysSchedSetScheduler(unsigned int tid, int policy, int priority);
int *SysSchedGetArea(unsigned int tid);
int SysSetThreadArea(const char *area);
char *SysGetThreadArea(void);
int SysFutex(const unsigned int *uAddr, unsigned int flags, int val,
unsigned int absTime, const unsigned int *newUserAddr);
#endif /* _LOS_SYSCALL_H */
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_task.h"
#include "securec.h"
#include "los_config.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_interrupt.h"
#include "los_memory.h"
#include "los_mpu.h"
#include "los_sched.h"
#include "los_mux.h"
#include "los_sem.h"
#include "los_timer.h"
#include "los_arch_context.h"
#include "los_box.h"
#include "los_syscall.h"
int SysUserTaskCreate(unsigned long entry, unsigned long userArea, unsigned long userSp, BOOL joinable)
{
UINT32 ret, taskID;
TSK_INIT_PARAM_S taskInitParam = { 0 };
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
taskInitParam.uwStackSize = 0x1000;
taskInitParam.pcName = "UserTask";
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
taskInitParam.stackAddr = userSp;
if (joinable) {
taskInitParam.uwResved |= LOS_TASK_ATTR_JOINABLE;
}
ret = LOS_TaskCreateOnly(&taskID, &taskInitParam);
if (ret != LOS_OK) {
return -EINVAL;
}
OsUserTaskInit(taskID, entry, userArea, userSp);
return taskID;
}
int SysSchedSetScheduler(unsigned int tid, int policy, int priority)
{
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
return EINVAL;
}
if (policy != 0) {
return EINVAL;
}
if ((priority <= 0) || (priority > OS_TASK_PRIORITY_LOWEST)) {
return EINVAL;
}
UINT32 ret = LOS_TaskPriSet((UINT32)tid, (UINT16)priority);
if (ret != LOS_OK) {
return EINVAL;
}
return 0;
}
int *SysSchedGetArea(unsigned int tid)
{
unsigned int intSave;
int *area = NULL;
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
return NULL;
}
intSave = LOS_IntLock();
area = (int *)OsGetUserTaskCB(tid)->userArea;
LOS_IntRestore(intSave);
return area;
}
int SysSetThreadArea(const char *area)
{
unsigned int intSave;
intSave = LOS_IntLock();
LosTaskCB *runTask = g_losTask.runTask;
OsGetUserTaskCB(runTask->taskID)->userArea = (unsigned long)(uintptr_t)area;
LOS_IntRestore(intSave);
return 0;
}
char *SysGetThreadArea(void)
{
unsigned int intSave;
char *area = NULL;
intSave = LOS_IntLock();
LosTaskCB *runTask = g_losTask.runTask;
area = (char *)OsGetUserTaskCB(runTask->taskID)->userArea;
LOS_IntRestore(intSave);
return area;
}
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SYSCALL_HAND_DEF must be defined before including this file. */
/* SYSCALL_HAND_DEF(id, fun, rtype, narg); note if we have 64bit arg, narg should be ARG_NUM_7 */
// #ifdef LOSCFG_FS_VFS
// SYSCALL_HAND_DEF(__NR_read, SysRead, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_write, SysWrite, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_open, SysOpen, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_close, SysClose, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_creat, SysCreat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_link, SysLink, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_readlink, SysReadlink, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_symlink, SysSymlink, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_unlink, SysUnlink, int, ARG_NUM_1)
// #ifdef LOSCFG_KERNEL_DYNLOAD
// SYSCALL_HAND_DEF(__NR_execve, SysExecve, int, ARG_NUM_3)
// #endif
// SYSCALL_HAND_DEF(__NR_sysinfo, SysInfo, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_fchdir, SysFchdir, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_chdir, SysChdir, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_utimensat, SysUtimensat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_fchmodat, SysFchmodat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_fchmod, SysFchmod, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_utimensat, SysUtimensat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_chmod, SysChmod, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_lseek, SysLseek, off_t, ARG_NUM_7) /* current only support 32bit max 4G file */
// SYSCALL_HAND_DEF(__NR_mount, SysMount, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_umount, SysUmount, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_access, SysAccess, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_faccessat, SysFaccessat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_sync, SysSync, void, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_rename, SysRename, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_mkdir, SysMkdir, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_rmdir, SysRmdir, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_dup, SysDup, int, ARG_NUM_1)
// #ifdef LOSCFG_KERNEL_PIPE
// SYSCALL_HAND_DEF(__NR_pipe, SysPipe, int, ARG_NUM_1)
// #endif
// SYSCALL_HAND_DEF(__NR_umount2, SysUmount2, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_ioctl, SysIoctl, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_fcntl, SysFcntl, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_dup2, SysDup2, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_truncate, SysTruncate, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_ftruncate, SysFtruncate, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_statfs, SysStatfs, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstatfs, SysFstatfs, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstatfs64, SysFstatfs64, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_stat, SysStat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_lstat, SysLstat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstat, SysFstat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstatat64, SysFstatat64, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_fsync, SysFsync, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR__llseek, SysLseek64, off64_t, ARG_NUM_5) /* current only support 32bit max 4G file */
// SYSCALL_HAND_DEF(__NR__newselect, SysSelect, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_pselect6, SysPselect6, int, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_readv, SysReadv, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_writev, SysWritev, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_poll, SysPoll, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_ppoll, SysPpoll, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_prctl, SysPrctl, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_pread64, SysPread64, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_pwrite64, SysPwrite64, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_epoll_create, SysEpollCreate, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_epoll_create1, SysEpollCreate1, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_epoll_ctl, SysEpollCtl, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_epoll_wait, SysEpollWait, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_epoll_pwait, SysEpollPwait, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_getcwd, SysGetcwd, char *, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_sendfile, SysSendFile, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_truncate64, SysTruncate64, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_ftruncate64, SysFtruncate64, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_stat64, SysStat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_lstat64, SysLstat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstat64, SysFstat64, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fcntl64, SysFcntl64, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sendfile64, SysSendFile, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_preadv, SysPreadv, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_pwritev, SysPwritev, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_fallocate, SysFallocate64, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_getdents64, SysGetdents64, int, ARG_NUM_3)
// #ifdef LOSCFG_FS_FAT
// SYSCALL_HAND_DEF(__NR_format, SysFormat, int, ARG_NUM_3)
// #endif
// SYSCALL_HAND_DEF(__NR_linkat, SysLinkat, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_symlinkat, SysSymlinkat, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_readlinkat, SysReadlinkat, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_unlinkat, SysUnlinkat, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_renameat, SysRenameat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_openat, SysOpenat, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_mkdirat, SysMkdirat, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_statfs64, SysStatfs64, int, ARG_NUM_3)
// #ifdef LOSCFG_DEBUG_VERSION
// SYSCALL_HAND_DEF(__NR_dumpmemory, LOS_DumpMemRegion, void, ARG_NUM_1)
// #endif
// #ifdef LOSCFG_KERNEL_PIPE
// SYSCALL_HAND_DEF(__NR_mkfifo, SysMkFifo, int, ARG_NUM_2)
// #endif
// SYSCALL_HAND_DEF(__NR_mqclose, SysMqClose, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_realpath, SysRealpath, char *, ARG_NUM_2)
// #ifdef LOSCFG_SHELL
// SYSCALL_HAND_DEF(__NR_shellexec, SysShellExec, UINT32, ARG_NUM_2)
// #endif
// #endif
// SYSCALL_HAND_DEF(__NR_exit, SysThreadExit, void, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_fork, SysFork, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_vfork, SysVfork, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getpid, SysGetPID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_pause, SysPause, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_kill, SysKill, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_reboot, SysReboot, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_times, SysTimes, clock_t, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_brk, SysBrk, void *, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_setgid, SysSetGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_getgid, SysGetGroupID, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_setpgid, SysSetProcessGroupID, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_getppid, SysGetPPID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getpgrp, SysGetProcessGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_munmap, SysMunmap, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_getpriority, SysGetProcessPriority, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setpriority, SysSetProcessPriority, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setitimer, SysSetiTimer, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getitimer, SysGetiTimer, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_wait4, SysWait, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_waitid, SysWaitid, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_uname, SysUname, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_mprotect, SysMprotect, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getpgid, SysGetProcessGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_setparam, SysSchedSetParam, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_getparam, SysSchedGetParam, int, ARG_NUM_2)
SYSCALL_HAND_DEF(__NR_sched_setscheduler, SysSchedSetScheduler, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_getscheduler, SysSchedGetScheduler, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_sched_yield, SysSchedYield, void, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_get_priority_max, SysSchedGetPriorityMax, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_get_priority_min, SysSchedGetPriorityMin, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_setaffinity, SysSchedSetAffinity, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_getaffinity, SysSchedGetAffinity, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_rr_get_interval, SysSchedRRGetInterval, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_nanosleep, SysNanoSleep, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_mremap, SysMremap, void *, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_umask, SysUmask, mode_t, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_rt_sigaction, SysSigAction, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_rt_sigprocmask, SysSigprocMask, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_rt_sigpending, SysSigPending, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_rt_sigtimedwait, SysSigTimedWait, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_rt_sigsuspend, SysSigSuspend, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_fchownat, SysFchownat, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_fchown32, SysFchown, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_chown, SysChown, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_chown32, SysChown, int, ARG_NUM_3)
// #ifdef LOSCFG_SECURITY_CAPABILITY
// SYSCALL_HAND_DEF(__NR_ohoscapget, SysCapGet, UINT32, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_ohoscapset, SysCapSet, UINT32, ARG_NUM_1)
// #endif
// SYSCALL_HAND_DEF(__NR_mmap2, SysMmap, void*, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_getuid32, SysGetUserID, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getgid32, SysGetGroupID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_geteuid32, SysGetEffUserID, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getegid32, SysGetEffGID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getresuid32, SysGetRealEffSaveUserID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getresgid32, SysGetRealEffSaveGroupID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setresuid32, SysSetRealEffSaveUserID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setresgid32, SysSetRealEffSaveGroupID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setreuid32, SysSetRealEffUserID, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setregid32, SysSetRealEffGroupID, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setgroups32, SysSetGroups, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_getgroups32, SysGetGroups, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setuid32, SysSetUserID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_setgid32, SysSetGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_gettid, SysGetTid, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_tkill, SysPthreadKill, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_futex, SysFutex, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_exit_group, SysUserExitGroup, void, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_set_thread_area, SysSetThreadArea, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_get_thread_area, SysGetThreadArea, char *, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_timer_create, SysTimerCreate, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_timer_settime32, SysTimerSettime, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_timer_gettime32, SysTimerGettime, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_timer_getoverrun, SysTimerGetoverrun, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_timer_delete, SysTimerDelete, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_clock_settime32, SysClockSettime, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_clock_gettime32, SysClockGettime, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_clock_getres_time32, SysClockGetres, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_clock_nanosleep_time32, SysClockNanoSleep, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_mq_open, SysMqOpen, mqd_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_mq_unlink, SysMqUnlink, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_mq_timedsend, SysMqTimedSend, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_mq_timedreceive, SysMqTimedReceive, ssize_t, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_mq_notify, SysMqNotify, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_mq_getsetattr, SysMqGetSetAttr, int, ARG_NUM_3)
// #ifdef LOSCFG_NET_LWIP_SACK
// SYSCALL_HAND_DEF(__NR_socket, SysSocket, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_bind, SysBind, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_connect, SysConnect, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_listen, SysListen, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_accept, SysAccept, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getsockname, SysGetSockName, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getpeername, SysGetPeerName, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_send, SysSend, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_sendto, SysSendTo, ssize_t, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_recv, SysRecv, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_recvfrom, SysRecvFrom, ssize_t, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_shutdown, SysShutdown, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setsockopt, SysSetSockOpt, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_getsockopt, SysGetSockOpt, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_sendmsg, SysSendMsg, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_recvmsg, SysRecvMsg, ssize_t, ARG_NUM_3)
// #endif
// #ifdef LOSCFG_KERNEL_SHM
// SYSCALL_HAND_DEF(__NR_shmat, SysShmAt, void *, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_shmdt, SysShmDt, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_shmget, SysShmGet, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_shmctl, SysShmCtl, int, ARG_NUM_3)
// #endif
// SYSCALL_HAND_DEF(__NR_statx, SysStatx, int, ARG_NUM_5)
// /* LiteOS customized syscalls, not compatible with ARM EABI */
// SYSCALL_HAND_DEF(__NR_pthread_set_detach, SysUserThreadSetDetach, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_pthread_join, SysThreadJoin, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_pthread_deatch, SysUserThreadDetach, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_creat_user_thread, SysUserTaskCreate, unsigned int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_getrusage, SysGetrusage, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_sysconf, SysSysconf, long, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_ugetrlimit, SysUgetrlimit, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setrlimit, SysSetrlimit, int, ARG_NUM_2)
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_switch = defined(LOSCFG_SECURE)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = []
deps = [ "//third_party/musl/porting/liteos_m/user" ]
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
......@@ -1277,6 +1277,16 @@ extern UINT32 LOS_TaskDetach(UINT32 taskID);
*/
#define OS_TASK_STATUS_EXIT 0x0100
#if (LOSCFG_SECURE == 1)
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
*
* This task is a user mode task.
*/
#define OS_TASK_FLAG_USER_TASK 0x0200
#endif
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
......
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
......@@ -82,6 +82,11 @@
#include "los_signal.h"
#endif
#if (LOSCFG_SECURE == 1)
#include "los_syscall.h"
#include "los_box.h"
#endif
/*****************************************************************************
Function : LOS_Reboot
Description : system exception, die in here, wait for watchdog.
......@@ -262,6 +267,11 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
#if (LOSCFG_SECURE == 1)
OsSyscallHandleInit();
LOS_BoxStart();
#endif
return LOS_OK;
}
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
......@@ -164,7 +164,7 @@ STATIC VOID OsRecyleFinishedTask(VOID)
stackPtr = 0;
OsRecycleTaskResources(taskCB, &stackPtr);
LOS_IntRestore(intSave);
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
intSave = LOS_IntLock();
}
......
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
......@@ -2288,7 +2288,7 @@ UINT32 OsMemSystemInit(VOID)
#endif
ret = LOS_MemInit(m_aucSysMem0, LOSCFG_SYS_HEAP_SIZE);
PRINT_INFO("LiteOS heap memory address:%p, size:0x%lx\n", m_aucSysMem0, LOSCFG_SYS_HEAP_SIZE);
PRINT_INFO("LiteOS heap memory address:%p, size:0x%lx\n", m_aucSysMem0, (unsigned long int)LOSCFG_SYS_HEAP_SIZE);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册