优化多arch支持
This commit is contained in:
5
.vscode/launch.json
vendored
5
.vscode/launch.json
vendored
@@ -50,12 +50,13 @@
|
||||
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
|
||||
// "miDebuggerPath": "/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/aarch64-none-elf-gdb",
|
||||
// "miDebuggerPath": "/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerPath": "/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",
|
||||
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerPath": "/home/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
|
||||
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
|
||||
// "miDebuggerPath": "/home/mkrtos-smart/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
|
||||
// "miDebuggerPath": "/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
|
||||
// "miDebuggerPath": "/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerServerAddress": "127.0.0.1:33333",
|
||||
"miDebuggerServerAddress": "127.0.0.1:3333",
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
|
||||
@@ -3,19 +3,19 @@ message("========use armv7_8.cmake")
|
||||
set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mno-thumb-interwork -D=MKRTOS \
|
||||
-std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -u=_printf_float \
|
||||
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
|
||||
-fno-stack-protector -Wl,--gc-sections \
|
||||
-fno-stack-protector -Wl,--gc-sections -D__ARM_ARCH_7M__ \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
" CACHE STRING "" FORCE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mno-thumb-interwork -D=MKRTOS -std=c++11 \
|
||||
-fmessage-length=0 -Xlinker --print-map -Wall -W -fno-stack-protector -g \
|
||||
-u=_printf_float \
|
||||
-u=_printf_float -D__ARM_ARCH_7M__ \
|
||||
-ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
" CACHE STRING "" FORCE)
|
||||
|
||||
set(CMAKE_ASM_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mno-thumb-interwork -D=MKRTOS \
|
||||
-u=_printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \
|
||||
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector \
|
||||
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector -D__ARM_ARCH_7M__ \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
" CACHE STRING "" FORCE)
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
|
||||
file(GLOB_RECURSE deps **/*.S *.S **/*.C *.c)
|
||||
file(GLOB_RECURSE deps **/*.S *.S **/*.s *.s **/*.C *.c)
|
||||
|
||||
add_library(boot_bsp STATIC ${deps})
|
||||
target_include_directories(
|
||||
|
||||
@@ -4,7 +4,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_STDPERIPH_DRIVER=1 ")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
|
||||
-fPIC -n -pie -fpie -fpic -msingle-pic-base -mno-pic-data-is-text-relative \
|
||||
-D__dietlibc__ -D__arm__ -D__WORDSIZE=32 -D__ARM_ARCH_7M__ \
|
||||
-D__dietlibc__ -D__arm__ -D__WORDSIZE=32 \
|
||||
" )
|
||||
set(CMAKE_ASM_FLAGS ${CMAKE_ASM_FLAGS})
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
#
|
||||
CONFIG_KNL_INFO=y
|
||||
CONFIG_KNL_TEXT_ADDR=0x8000000
|
||||
CONFIG_KNL_TEXT_SIZE=0x100000
|
||||
CONFIG_KNL_TEXT_SIZE=0x800000
|
||||
CONFIG_KNL_DATA_ADDR=0x20000000
|
||||
CONFIG_KNL_DATA_SIZE=0x10000
|
||||
CONFIG_KNL_DATA_SIZE=0x800000
|
||||
CONFIG_KNL_OFFSET=0x2000
|
||||
CONFIG_INIT_TASK_OFFSET=0x10000
|
||||
CONFIG_BOOTFS_OFFSET=0x22000
|
||||
CONFIG_BOOTFS_OFFSET=0x30000
|
||||
CONFIG_MK_MPU_CFG=y
|
||||
CONFIG_FT_ADDR_NR=16
|
||||
CONFIG_SYS_SCHE_HZ=1000
|
||||
CONFIG_USER_ISR_START_NO=16
|
||||
CONFIG_IRQ_REG_TAB_SIZE=80
|
||||
CONFIG_REGION_NUM=8
|
||||
CONFIG_OBJ_MAP_TAB_SIZE=4
|
||||
CONFIG_OBJ_MAP_ENTRY_SIZE=8
|
||||
CONFIG_OBJ_MAP_TAB_SIZE=32
|
||||
CONFIG_OBJ_MAP_ENTRY_SIZE=32
|
||||
CONFIG_PRINTK_CACHE_SIZE=128
|
||||
# end of Knl config
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@ CONFIG_KNL_DATA_ADDR=0x20000000
|
||||
CONFIG_KNL_DATA_SIZE=0x800000
|
||||
CONFIG_KNL_OFFSET=0x2000
|
||||
CONFIG_INIT_TASK_OFFSET=0x10000
|
||||
CONFIG_BOOTFS_OFFSET=0x22000
|
||||
CONFIG_BOOTFS_OFFSET=0x30000
|
||||
CONFIG_MK_MPU_CFG=y
|
||||
CONFIG_FT_ADDR_NR=16
|
||||
CONFIG_SYS_SCHE_HZ=1000
|
||||
CONFIG_USER_ISR_START_NO=16
|
||||
CONFIG_IRQ_REG_TAB_SIZE=80
|
||||
CONFIG_REGION_NUM=8
|
||||
CONFIG_OBJ_MAP_TAB_SIZE=4
|
||||
CONFIG_OBJ_MAP_ENTRY_SIZE=8
|
||||
CONFIG_OBJ_MAP_TAB_SIZE=32
|
||||
CONFIG_OBJ_MAP_ENTRY_SIZE=32
|
||||
CONFIG_PRINTK_CACHE_SIZE=128
|
||||
# end of Knl config
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ CONFIG_SYS_SCHE_HZ=1000
|
||||
CONFIG_USER_ISR_START_NO=16
|
||||
CONFIG_IRQ_REG_TAB_SIZE=100
|
||||
CONFIG_REGION_NUM=8
|
||||
CONFIG_OBJ_MAP_TAB_SIZE=4
|
||||
CONFIG_OBJ_MAP_ENTRY_SIZE=8
|
||||
CONFIG_OBJ_MAP_TAB_SIZE=16
|
||||
CONFIG_OBJ_MAP_ENTRY_SIZE=16
|
||||
CONFIG_PRINTK_CACHE_SIZE=128
|
||||
# end of Knl config
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "arch.h"
|
||||
|
||||
#define PAGE_SIZE 512
|
||||
#define LOG_INTR_NO 38 // USART2_IRQn
|
||||
#define LOG_INTR_NO 37 // USART1_IRQn
|
||||
|
||||
/// @brief 线程信息
|
||||
typedef struct
|
||||
|
||||
@@ -25,11 +25,11 @@ void mpu_enable(void)
|
||||
{
|
||||
ARM_MPU_Enable(4);
|
||||
}
|
||||
void mpu_calc_regs(region_info_t *region, umword_t addr, umword_t ffs_val, uint8_t attrs, uint8_t regions_bits)
|
||||
void mpu_calc_regs(region_info_t *region, umword_t addr, umword_t size, uint8_t attrs, uint8_t regions_bits)
|
||||
{
|
||||
region->rbar = ARM_MPU_RBAR(region->region_inx, addr);
|
||||
region->rasr = ARM_MPU_RASR(0, attrs, 0UL, 0UL,
|
||||
1UL, 1UL, regions_bits, ffs(ffs_val) - 1);
|
||||
1UL, 1UL, regions_bits, ffs(size) - 1);
|
||||
}
|
||||
void mpu_region_set(int inx, umword_t rbar, umword_t rasr)
|
||||
{
|
||||
@@ -46,10 +46,10 @@ void mpu_switch_to_task(struct task *tk)
|
||||
mpu_disable();
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
if (tk->mm_space.pt_regions[i].region_inx >= 0)
|
||||
region_info_t *ri = &tk->mm_space.mem_vma.pt_regions[i];
|
||||
if (ri->region_inx >= 0)
|
||||
{
|
||||
ARM_MPU_SetRegionEx(tk->mm_space.pt_regions[i].region_inx, tk->mm_space.pt_regions[i].rbar,
|
||||
tk->mm_space.pt_regions[i].rasr);
|
||||
ARM_MPU_SetRegionEx(ri->region_inx, ri->rbar, ri->rasr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -13,73 +13,12 @@
|
||||
#include "mm_space.h"
|
||||
#include "mpu.h"
|
||||
#include "assert.h"
|
||||
#if CONFIG_MK_MPU_CFG
|
||||
void mm_space_init(mm_space_t *mm_space, int is_knl)
|
||||
|
||||
int mm_space_init(mm_space_t *mm_space, int is_knl)
|
||||
{
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
mm_space->pt_regions[i].region_inx = -1;
|
||||
}
|
||||
}
|
||||
region_info_t *mm_space_alloc_pt_region(mm_space_t *m_space)
|
||||
{
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
/*TODO:原子操作*/
|
||||
if (m_space->pt_regions[i].region_inx < 0)
|
||||
{
|
||||
m_space->pt_regions[i].region_inx = (int16_t)i;
|
||||
return &m_space->pt_regions[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void mm_space_free_pt_region(mm_space_t *m_space, region_info_t *ri)
|
||||
{
|
||||
ri->region_inx = -1;
|
||||
int ret = 0;
|
||||
|
||||
ret = task_vma_init(&mm_space->mem_vma);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool_t mm_space_add(mm_space_t *m_space,
|
||||
umword_t addr,
|
||||
umword_t size,
|
||||
uint8_t attrs)
|
||||
{
|
||||
region_info_t *ri = mm_space_alloc_pt_region(m_space);
|
||||
|
||||
if (!ri)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#if CONFIG_MPU_VERSION == 1
|
||||
if (!is_power_of_2(size) || (addr & (!(size - 1))) != 0)
|
||||
{
|
||||
//!< 申请的大小必须是2的整数倍,而且地址也必须是2的整数倍
|
||||
mm_space_free_pt_region(m_space, ri);
|
||||
return FALSE;
|
||||
}
|
||||
#elif CONFIG_MPU_VERSION == 2
|
||||
if ((size & (MPU_ALIGN_SIZE - 1)) == 0 && (addr & (MPU_ALIGN_SIZE - 1)) == 0)
|
||||
{
|
||||
mm_space_free_pt_region(m_space, ri);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
mpu_calc_regs(ri, addr, size, attrs, 0);
|
||||
ri->start_addr = addr;
|
||||
ri->size = size;
|
||||
return TRUE;
|
||||
}
|
||||
void mm_space_del(mm_space_t *m_space, umword_t addr)
|
||||
{
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
if (m_space->pt_regions[i].region_inx >= 0 &&
|
||||
m_space->pt_regions[i].start_addr == addr)
|
||||
{
|
||||
m_space->pt_regions[i].region_inx = -1;
|
||||
m_space->pt_regions[i].start_addr = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,74 +13,12 @@
|
||||
#include "mm_space.h"
|
||||
#include "mpu.h"
|
||||
#include "assert.h"
|
||||
#if CONFIG_MK_MPU_CFG
|
||||
|
||||
int mm_space_init(mm_space_t *mm_space, int is_knl)
|
||||
{
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
mm_space->pt_regions[i].region_inx = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
region_info_t *mm_space_alloc_pt_region(mm_space_t *m_space)
|
||||
{
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
/*TODO:原子操作*/
|
||||
if (m_space->pt_regions[i].region_inx < 0)
|
||||
{
|
||||
m_space->pt_regions[i].region_inx = (int16_t)i;
|
||||
return &m_space->pt_regions[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void mm_space_free_pt_region(mm_space_t *m_space, region_info_t *ri)
|
||||
{
|
||||
ri->region_inx = -1;
|
||||
int ret = 0;
|
||||
|
||||
ret = task_vma_init(&mm_space->mem_vma);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool_t mm_space_add(mm_space_t *m_space,
|
||||
umword_t addr,
|
||||
umword_t size,
|
||||
uint8_t attrs)
|
||||
{
|
||||
region_info_t *ri = mm_space_alloc_pt_region(m_space);
|
||||
|
||||
if (!ri)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#if CONFIG_MPU_VERSION == 1
|
||||
if (!is_power_of_2(size) || (addr & (!(size - 1))) != 0)
|
||||
{
|
||||
//!< 申请的大小必须是2的整数倍,而且地址也必须是2的整数倍
|
||||
mm_space_free_pt_region(m_space, ri);
|
||||
return FALSE;
|
||||
}
|
||||
#elif CONFIG_MPU_VERSION == 2
|
||||
if ((size & (MPU_ALIGN_SIZE - 1)) == 0 && (addr & (MPU_ALIGN_SIZE - 1)) == 0)
|
||||
{
|
||||
mm_space_free_pt_region(m_space, ri);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
mpu_calc_regs(ri, addr, size, attrs, 0);
|
||||
ri->start_addr = addr;
|
||||
ri->size = size;
|
||||
return TRUE;
|
||||
}
|
||||
void mm_space_del(mm_space_t *m_space, umword_t addr)
|
||||
{
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
if (m_space->pt_regions[i].region_inx >= 0 &&
|
||||
m_space->pt_regions[i].start_addr == addr)
|
||||
{
|
||||
m_space->pt_regions[i].region_inx = -1;
|
||||
m_space->pt_regions[i].start_addr = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
* Created on: ATShining
|
||||
* Author: Administrator
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
#include "assert.h"
|
||||
#include "mpu.h"
|
||||
#include <mk_sys.h>
|
||||
#include <mpu_armv7.h>
|
||||
#include "thread.h"
|
||||
#include "task.h"
|
||||
#if CONFIG_MK_MPU_CFG
|
||||
static volatile umword_t *MPUCR = (umword_t *)0xE000ED94;
|
||||
|
||||
void mpu_init(void)
|
||||
@@ -26,11 +25,11 @@ void mpu_enable(void)
|
||||
{
|
||||
ARM_MPU_Enable(4);
|
||||
}
|
||||
void mpu_calc_regs(region_info_t *region, umword_t addr, umword_t ffs_val, uint8_t attrs, uint8_t regions_bits)
|
||||
void mpu_calc_regs(region_info_t *region, umword_t addr, umword_t size, uint8_t attrs, uint8_t regions_bits)
|
||||
{
|
||||
region->rbar = ARM_MPU_RBAR(region->region_inx, addr);
|
||||
region->rasr = ARM_MPU_RASR(0, attrs, 0UL, 0UL,
|
||||
1UL, 1UL, regions_bits, ffs(ffs_val) - 1);
|
||||
1UL, 1UL, regions_bits, ffs(size) - 1);
|
||||
}
|
||||
void mpu_region_set(int inx, umword_t rbar, umword_t rasr)
|
||||
{
|
||||
@@ -47,10 +46,10 @@ void mpu_switch_to_task(struct task *tk)
|
||||
mpu_disable();
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
if (tk->mm_space.pt_regions[i].region_inx >= 0)
|
||||
region_info_t *ri = &tk->mm_space.mem_vma.pt_regions[i];
|
||||
if (ri->region_inx >= 0)
|
||||
{
|
||||
ARM_MPU_SetRegionEx(tk->mm_space.pt_regions[i].region_inx, tk->mm_space.pt_regions[i].rbar,
|
||||
tk->mm_space.pt_regions[i].rasr);
|
||||
ARM_MPU_SetRegionEx(ri->region_inx, ri->rbar, ri->rasr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -65,3 +64,11 @@ void mpu_switch_to(void)
|
||||
|
||||
mpu_switch_to_task(tk);
|
||||
}
|
||||
#else
|
||||
void mpu_switch_to(void)
|
||||
{
|
||||
}
|
||||
void mpu_switch_to_task(struct task *tk)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,9 +17,20 @@
|
||||
#include "mm_wrap.h"
|
||||
#include "arch.h"
|
||||
#include "string.h"
|
||||
typedef struct entry_frame_tmp
|
||||
{
|
||||
umword_t r[8];
|
||||
} entry_frame_tmp_t;
|
||||
|
||||
static void syscall_entry_raw(entry_frame_tmp_t entry);
|
||||
|
||||
syscall_entry_func syscall_handler_get(void)
|
||||
{
|
||||
return syscall_entry;
|
||||
return (void *)syscall_entry_raw;
|
||||
}
|
||||
static void syscall_entry_raw(entry_frame_tmp_t entry)
|
||||
{
|
||||
syscall_entry((entry_frame_t *)&entry);
|
||||
}
|
||||
void thread_knl_pf_set(thread_t *cur_th, void *pc)
|
||||
{
|
||||
@@ -39,7 +50,6 @@ void thread_user_pf_set(thread_t *cur_th, void *pc, void *user_sp, void *ram, um
|
||||
// assert((((umword_t)user_sp) & 0x7UL) == 0);
|
||||
umword_t usp = ((umword_t)(user_sp) & ~0x7UL);
|
||||
|
||||
|
||||
pf_t *cur_pf = (pf_t *)(usp)-1; // thread_get_pf(cur_th);
|
||||
|
||||
cur_pf->pf_s.xpsr = 0x01000000L;
|
||||
|
||||
@@ -58,6 +58,10 @@ static inline void mpu_region_clr(int inx)
|
||||
}
|
||||
void mpu_switch_to(void);
|
||||
void mpu_switch_to_task(struct task *tk);
|
||||
static inline umword_t vpage_attrs_to_page_attrs(enum vpage_prot_attrs attrs)
|
||||
{
|
||||
return 0xff;
|
||||
}
|
||||
#else
|
||||
static inline void mpu_switch_to_task(struct task *tk)
|
||||
{
|
||||
|
||||
@@ -125,18 +125,18 @@ typedef struct region_info
|
||||
{
|
||||
umword_t start_addr; //!< 内存申请的开始地址
|
||||
umword_t size; //!< 实际申请的内存大小
|
||||
#if IS_ENABLED(CONFIG_MK_MPU_CFG)
|
||||
umword_t block_start_addr; //!< 块申请的开始地址
|
||||
umword_t block_size; //!< 保护的块大小
|
||||
umword_t rbar; //!< mpu保护寄存器信息
|
||||
umword_t rasr; //!< mpu保护寄存器信息
|
||||
int16_t region_inx; //!< 区域索引
|
||||
uint8_t region; //!< 区域禁止信息
|
||||
#endif
|
||||
int16_t region_inx; //!< 区域索引
|
||||
} region_info_t;
|
||||
typedef struct task_vma
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_MK_MPU_CFG)
|
||||
region_info_t pt_regions[CONFIG_REGION_NUM]; //!< mpu内存保护块
|
||||
#endif
|
||||
} task_vma_t;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <task.h>
|
||||
#include <thread.h>
|
||||
#include <string.h>
|
||||
|
||||
static region_info_t *vma_alloc_pt_region(task_vma_t *vma)
|
||||
{
|
||||
assert(vma != NULL);
|
||||
@@ -46,7 +47,6 @@ static void vma_free_pt_region(task_vma_t *vma, region_info_t *ri)
|
||||
memset(ri, 0, sizeof(*ri));
|
||||
ri->region_inx = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化vma
|
||||
*
|
||||
@@ -55,11 +55,13 @@ static void vma_free_pt_region(task_vma_t *vma, region_info_t *ri)
|
||||
*/
|
||||
int task_vma_init(task_vma_t *vma)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_MK_MPU_CFG)
|
||||
assert(vma != NULL);
|
||||
for (int i = 0; i < CONFIG_REGION_NUM; i++)
|
||||
{
|
||||
vma->pt_regions[i].region_inx = -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -86,6 +88,7 @@ int task_vma_alloc(task_vma_t *task_vma, vma_addr_t vaddr, size_t size,
|
||||
mm_space);
|
||||
|
||||
assert(task_vma != NULL);
|
||||
#if IS_ENABLED(CONFIG_MK_MPU_CFG)
|
||||
#if CONFIG_MPU_VERSION == 1
|
||||
if (!is_power_of_2(size))
|
||||
{
|
||||
@@ -98,6 +101,7 @@ int task_vma_alloc(task_vma_t *task_vma, vma_addr_t vaddr, size_t size,
|
||||
// 不是MPU_ALIGN_SIZE字节对齐的
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
vma_addr = vma_addr_get_addr(vaddr);
|
||||
if (vma_addr != 0)
|
||||
@@ -105,7 +109,7 @@ int task_vma_alloc(task_vma_t *task_vma, vma_addr_t vaddr, size_t size,
|
||||
// 必须让内核自己分配地址
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_MK_MPU_CFG)
|
||||
#if CONFIG_MPU_VERSION == 1
|
||||
if (paddr == 0)
|
||||
{
|
||||
@@ -128,7 +132,7 @@ int task_vma_alloc(task_vma_t *task_vma, vma_addr_t vaddr, size_t size,
|
||||
goto err_end;
|
||||
}
|
||||
#elif CONFIG_MPU_VERSION == 2
|
||||
vma_addr = (addr_t)mm_limit_alloc_align(pt_task, size, MPU_ALIGN_SIZE);
|
||||
vma_addr = (addr_t)mm_limit_alloc_align(pt_task->lim, size, MPU_ALIGN_SIZE);
|
||||
if (vma_addr == 0)
|
||||
{
|
||||
return -ENOMEM;
|
||||
@@ -139,6 +143,19 @@ int task_vma_alloc(task_vma_t *task_vma, vma_addr_t vaddr, size_t size,
|
||||
ret = -EINVAL;
|
||||
goto err_end;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
vma_addr = (addr_t)mm_limit_alloc_align(pt_task->lim, size, sizeof(void *) * 2);
|
||||
if (vma_addr == 0)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (vma_addr & (sizeof(void *) * 2 - 1))
|
||||
{
|
||||
// 不是对齐的
|
||||
ret = -EINVAL;
|
||||
goto err_end;
|
||||
}
|
||||
#endif
|
||||
// 找到一个合适的区域
|
||||
region_info_t *ri = NULL;
|
||||
@@ -174,11 +191,15 @@ int task_vma_alloc(task_vma_t *task_vma, vma_addr_t vaddr, size_t size,
|
||||
}
|
||||
goto end;
|
||||
err_end:
|
||||
#if IS_ENABLED(CONFIG_MK_MPU_CFG)
|
||||
#if CONFIG_MPU_VERSION == 1
|
||||
mm_limit_free_align(pt_task->lim, (void *)vma_addr, size);
|
||||
#elif CONFIG_MPU_VERSION == 2
|
||||
mm_limit_free_align(pt_task->lim, (void *)vma_addr, MPU_ALIGN_SIZE);
|
||||
#endif
|
||||
#else
|
||||
mm_limit_free_align(pt_task->lim, (void *)vma_addr, sizeof(void *) * 2);
|
||||
#endif
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
@@ -219,13 +240,18 @@ static int task_vma_free_inner(task_vma_t *task_vma, vaddr_t vaddr, size_t size,
|
||||
vma_free_pt_region(task_vma, ri);
|
||||
if (is_free_mem)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_MK_MPU_CFG)
|
||||
#if CONFIG_MPU_VERSION == 1
|
||||
mm_limit_free_align(pt_task->lim, (void *)vma_addr, size);
|
||||
#elif CONFIG_MPU_VERSION == 2
|
||||
mm_limit_free_align(pt_task->lim, (void *)vma_addr, MPU_ALIGN_SIZE);
|
||||
#endif
|
||||
#else
|
||||
mm_limit_free_align(pt_task->lim, (void *)vma_addr, sizeof(void *) * 2);
|
||||
#endif
|
||||
}
|
||||
if (pt_task==thread_get_current_task()){
|
||||
if (pt_task == thread_get_current_task())
|
||||
{
|
||||
mpu_switch_to_task(pt_task);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m
|
||||
# export TOOLCHAIN=/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||
export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
|
||||
# export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||
export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
|
||||
export BOARD=STM32F103ZET6
|
||||
export CROSS_COMPILE_NAME=arm-none-eabi-
|
||||
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
# export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||
export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
|
||||
|
||||
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
|
||||
|
||||
export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||
|
||||
export BOARD=STM32F205
|
||||
export CROSS_COMPILE_NAME=arm-none-eabi-
|
||||
|
||||
|
||||
@@ -2,13 +2,22 @@
|
||||
|
||||
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu
|
||||
export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/hard
|
||||
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu
|
||||
# export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/hard
|
||||
|
||||
export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+fp/hard
|
||||
|
||||
|
||||
export BOARD=STM32F407VET6
|
||||
export CROSS_COMPILE_NAME=arm-none-eabi-
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
export MKRTOS_TEST_MODE="normal"
|
||||
else
|
||||
export MKRTOS_TEST_MODE=$1
|
||||
fi
|
||||
|
||||
set -e
|
||||
cmake -G Ninja -B build/$KNL .
|
||||
cd build/$KNL && ninja
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
# export TOOLCHAIN=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/
|
||||
# export TOOLCHAIN_LIB=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/lib/gcc/aarch64-none-elf/11.3.1
|
||||
export TOOLCHAIN=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
|
||||
export TOOLCHAIN_LIB=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
|
||||
# export TOOLCHAIN=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
|
||||
# export TOOLCHAIN_LIB=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
|
||||
|
||||
export TOOLCHAIN=/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
|
||||
export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
|
||||
|
||||
export BOARD=aarch64_qemu
|
||||
export CROSS_COMPILE_NAME=aarch64-none-elf-
|
||||
if [ -z "$1" ]; then
|
||||
|
||||
@@ -2,10 +2,22 @@
|
||||
|
||||
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv8-m.main/fpu/fpv5-d16/
|
||||
export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v8-m.main+fp/hard
|
||||
# export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v8-m.main+fp/hard
|
||||
|
||||
export TOOLCHAIN=/home/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v8-m.main+fp/hard
|
||||
|
||||
|
||||
export BOARD=SWM34
|
||||
export CROSS_COMPILE_NAME=arm-none-eabi-
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
export MKRTOS_TEST_MODE="normal"
|
||||
else
|
||||
export MKRTOS_TEST_MODE=$1
|
||||
fi
|
||||
|
||||
set -e
|
||||
cmake -G Ninja -B build/$KNL .
|
||||
cd build/$KNL && ninja
|
||||
|
||||
@@ -36,14 +36,18 @@ run_and_check() {
|
||||
# 清理
|
||||
./mkrtos_script/clean.sh
|
||||
./mkrtos_script/build_qemu_aarch64.sh test
|
||||
# 运行测试
|
||||
run_and_check "./mkrtos_script/run_aarch64_qemu.sh" "$TIMEOUT"
|
||||
./mkrtos_script/clean.sh
|
||||
run_and_check "./mkrtos_script/run_aarch64_qemu.sh" "$TIMEOUT"# 运行测试
|
||||
|
||||
./mkrtos_script/clean.sh
|
||||
./mkrtos_script/build_f2.sh test
|
||||
run_and_check "./mkrtos_script/run_m3.sh" "$TIMEOUT"
|
||||
# ./mkrtos_script/clean.sh
|
||||
|
||||
./mkrtos_script/clean.sh
|
||||
./mkrtos_script/build_f4.sh test
|
||||
run_and_check "./mkrtos_script/run_m4.sh" "$TIMEOUT"
|
||||
|
||||
./mkrtos_script/clean.sh
|
||||
./mkrtos_script/build_swm34s.sh test
|
||||
# run_and_check "./mkrtos_script/build_swm34s.sh test" "$TIMEOUT"
|
||||
|
||||
echo "All tests completed."
|
||||
Binary file not shown.
Binary file not shown.
@@ -42,8 +42,11 @@ long be_set_thread_area(void *p)
|
||||
ipc_msg_t *i_msg;
|
||||
|
||||
thread_msg_buf_get(-1, &msg, &len);
|
||||
|
||||
i_msg = (ipc_msg_t *)msg;
|
||||
if (!i_msg)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
i_msg->user[0] = (umword_t)p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ elseif(${CONFIG_ARCH} STREQUAL "aarch64" )
|
||||
${CMAKE_SOURCE_DIR}/build/libc/output/lib/crtn.o
|
||||
)
|
||||
|
||||
add_subdirectory(uvmm)
|
||||
# add_subdirectory(uvmm)
|
||||
# add_subdirectory(test)
|
||||
endif()
|
||||
add_subdirectory(init)
|
||||
add_subdirectory(shell)
|
||||
# add_subdirectory(tinycc-arm-thumb)
|
||||
add_subdirectory(tinycc-arm-thumb)
|
||||
add_subdirectory(fs)
|
||||
# add_subdirectory(drv)
|
||||
# add_subdirectory(net)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#一次读取一行,每行代表启动的应用程序,暂时不支持参数
|
||||
|
||||
cpiofs -m /bin
|
||||
# fatfs
|
||||
# dm9000_drv
|
||||
# net
|
||||
# lcd_drv
|
||||
# fatfs.elf
|
||||
# hello.elf
|
||||
cpiofs -m /bin
|
||||
sh
|
||||
@@ -210,10 +210,10 @@ int pm_rpc_run_app(const char *path, int flags)
|
||||
int ret;
|
||||
printf("pm run %s.\n", path);
|
||||
char *args[] = {
|
||||
"xx",/*TODO:*修正参数传递*/
|
||||
"-t",
|
||||
(char *)path,
|
||||
NULL, /*TODO:支持传递参数*/
|
||||
};
|
||||
ret = app_load(path, u_get_global_env(), &pid, args, 2, NULL, 0);
|
||||
ret = app_load(path, u_get_global_env(), &pid, args, 1, NULL, 0);
|
||||
if (ret > 0)
|
||||
{
|
||||
if (!(flags & PM_APP_BG_RUN))
|
||||
|
||||
Reference in New Issue
Block a user