[rt-smart] 弱化 RT_USING_LWP,使用 RT_USING_SMART 作为宏配置 (#6740)
* [dfs] sync cromfs * [rt-smart]Weaken RT_USING_LWP, use RT_USING_SMART as macro configuration * [format] fix some format issue.
This commit is contained in:
parent
3ea5166376
commit
68ca9f07a6
|
@ -27,10 +27,6 @@ config BOARD_allwinnerd1
|
|||
select ARCH_MM_MMU
|
||||
default y
|
||||
|
||||
config RT_USING_USERSPACE
|
||||
bool
|
||||
default y
|
||||
|
||||
config ENABLE_FPU
|
||||
bool "Enable FPU"
|
||||
default y
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "hal_uart.h"
|
||||
#include "hal_dma.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include "riscv_mmu.h"
|
||||
#include "mmu.h"
|
||||
#include "page.h"
|
||||
|
@ -82,7 +82,7 @@ void primary_cpu_entry(void)
|
|||
//这个初始化程序由内核主动调用,此时调度器还未启动,因此在此不能使用依赖线程上下文的函数
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_page_init(init_page_region);
|
||||
rt_hw_mmu_map_init(&mmu_info,(void *)USER_VADDR_START, USER_VADDR_TOP - USER_VADDR_START, (rt_size_t *)MMUTable, 0);
|
||||
rt_hw_mmu_kernel_map_init(&mmu_info, 0x00000000UL, USER_VADDR_START - 1);
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#define ARCH_CPU_64BIT
|
||||
#define RT_USING_CACHE
|
||||
#define ARCH_MM_MMU
|
||||
#define RT_USING_USERSPACE
|
||||
#define KERNEL_VADDR_START 0x150000000
|
||||
#define PV_OFFSET 0x0
|
||||
#define ARCH_RISCV
|
||||
|
@ -214,7 +213,7 @@
|
|||
|
||||
/* Utilities */
|
||||
|
||||
#define RT_USING_LWP
|
||||
#define RT_USING_SMART
|
||||
#define RT_LWP_MAX_NR 30
|
||||
#define LWP_TASK_STACK_SIZE 16384
|
||||
#define RT_CH_MSG_MAX_NR 1024
|
||||
|
|
|
@ -27,10 +27,6 @@ config BOARD_allwinnerd1s
|
|||
select ARCH_MM_MMU
|
||||
default y
|
||||
|
||||
config RT_USING_USERSPACE
|
||||
bool
|
||||
default y
|
||||
|
||||
config ENABLE_FPU
|
||||
bool "Enable FPU"
|
||||
default y
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "hal_uart.h"
|
||||
#include "hal_dma.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include "riscv_mmu.h"
|
||||
#include "mmu.h"
|
||||
#include "page.h"
|
||||
|
@ -81,7 +81,7 @@ void primary_cpu_entry(void)
|
|||
// 这个初始化程序由内核主动调用,此时调度器还未启动,因此在此不能使用依赖线程上下文的函数
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_page_init(init_page_region);
|
||||
rt_hw_mmu_map_init(&mmu_info, (void *)USER_VADDR_START, USER_VADDR_TOP - USER_VADDR_START, (rt_size_t *)MMUTable, 0);
|
||||
rt_hw_mmu_kernel_map_init(&mmu_info, 0x00000000UL, USER_VADDR_START - 1);
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
#define ARCH_CPU_64BIT
|
||||
#define RT_USING_CACHE
|
||||
#define ARCH_MM_MMU
|
||||
#define RT_USING_USERSPACE
|
||||
#define KERNEL_VADDR_START 0x150000000
|
||||
#define PV_OFFSET 0
|
||||
#define ARCH_RISCV
|
||||
|
@ -104,7 +103,7 @@
|
|||
#define FAL_DEBUG_CONFIG
|
||||
#define FAL_DEBUG 1
|
||||
#define FAL_PART_HAS_TABLE_CFG
|
||||
#define RT_USING_LWP
|
||||
#define RT_USING_SMART
|
||||
#define RT_LWP_MAX_NR 30
|
||||
#define LWP_TASK_STACK_SIZE 16384
|
||||
#define RT_CH_MSG_MAX_NR 1024
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "drv_lcd.h"
|
||||
#include "lcd_cfg.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <page.h>
|
||||
#include <lwp_user_mm.h>
|
||||
#endif
|
||||
|
@ -218,7 +218,7 @@ static int _lcd_drv_init(lcd_device_t lcd_drv)
|
|||
|
||||
/* allocate the framebuffer, the front buffer and the back buffer */
|
||||
/* framebuffer */
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
framebuffer = rt_pages_alloc(rt_page_bits(LCD_DRV_FB_SZ));
|
||||
#else
|
||||
framebuffer = rt_malloc(LCD_DRV_FB_SZ);
|
||||
|
@ -233,7 +233,7 @@ static int _lcd_drv_init(lcd_device_t lcd_drv)
|
|||
lcd_drv->framebuffer_phy = (void *)((size_t)framebuffer + PV_OFFSET);
|
||||
memset(framebuffer, 0, LCD_DRV_FB_SZ);
|
||||
rt_hw_cpu_dcache_clean(lcd_drv->framebuffer, LCD_DRV_FB_SZ);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
frontbuf = rt_pages_alloc(rt_page_bits(LCD_DRV_FB_SZ));
|
||||
#else
|
||||
frontbuf = rt_malloc(LCD_DRV_FB_SZ);
|
||||
|
@ -251,7 +251,7 @@ static int _lcd_drv_init(lcd_device_t lcd_drv)
|
|||
if ((lcd_drv->panel) && (lcd_drv->panel->swap_flag != 0))
|
||||
{
|
||||
/* backbuf */
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
backbuf = rt_pages_alloc(rt_page_bits(LCD_DRV_FB_SZ));
|
||||
#else
|
||||
backbuf = rt_malloc(LCD_DRV_FB_SZ);
|
||||
|
@ -271,7 +271,7 @@ static int _lcd_drv_init(lcd_device_t lcd_drv)
|
|||
out:
|
||||
if (framebuffer)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_free_align(framebuffer);
|
||||
#else
|
||||
rt_free(framebuffer);
|
||||
|
@ -280,7 +280,7 @@ out:
|
|||
|
||||
if (frontbuf)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_free_align(frontbuf);
|
||||
#else
|
||||
rt_free(frontbuf);
|
||||
|
@ -289,7 +289,7 @@ out:
|
|||
|
||||
if (backbuf)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_free_align(backbuf);
|
||||
#else
|
||||
rt_free(backbuf);
|
||||
|
@ -596,7 +596,7 @@ static rt_err_t rt_lcd_control(rt_device_t dev, int cmd, void *args)
|
|||
struct fb_fix_screeninfo *info = (struct fb_fix_screeninfo *)args;
|
||||
strncpy(info->id, "lcd", sizeof(info->id));
|
||||
info->smem_len = LCD_DRV_FB_SZ;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
info->smem_start = (size_t)lwp_map_user_phy(lwp_self(), RT_NULL, lcd_drv->framebuffer_phy, info->smem_len, 1);
|
||||
#else
|
||||
info->smem_start = (size_t)lcd_drv->framebuffer_phy;
|
||||
|
@ -633,9 +633,7 @@ int rt_hw_lcd_init(void)
|
|||
/* register lcd device to RT-Thread */
|
||||
rt_device_register(&lcd_drv->lcd, "lcd", RT_DEVICE_FLAG_RDWR);
|
||||
|
||||
// #if !defined(RT_USING_USERSPACE) && !defined(PKG_USING_JS_PERSIMMON)
|
||||
rt_lcd_init((rt_device_t)lcd_drv);
|
||||
// #endif
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <rtthread.h>
|
||||
|
||||
#include <rthw.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <mmu.h>
|
||||
#include <lwp_arch.h>
|
||||
#endif
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <sunxi_hal_miiphy.h>
|
||||
#include <rtthread.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <page.h>
|
||||
#include <ioremap.h>
|
||||
#endif
|
||||
|
@ -565,7 +565,7 @@ static int geth_dma_desc_init(void)
|
|||
{
|
||||
void *temp = RT_NULL;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_geth_dev.get_buffer_config.rx_buff_addr = rt_pages_alloc(RX_BUFFER_INDEX_NUM);
|
||||
#else
|
||||
rt_geth_dev.get_buffer_config.rx_buff_addr = rt_malloc(DMA_MEM_ALIGN_SIZE * DMA_DESC_RX_NUM);
|
||||
|
@ -577,7 +577,7 @@ static int geth_dma_desc_init(void)
|
|||
}
|
||||
//temp = (void *)rt_ioremap_nocache((void *)awos_arch_virt_to_phys((unsigned long)rt_geth_dev.get_buffer_config.rx_buff_addr), (SYS_PAGE_SIZE<<RX_BUFFER_INDEX_NUM));
|
||||
rt_geth_dev.get_buffer_config.phy_rx_buff_addr = (void *)awos_arch_virt_to_phys((unsigned long)rt_geth_dev.get_buffer_config.rx_buff_addr);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_geth_dev.get_buffer_config.tx_buff_addr = rt_pages_alloc(TX_BUFFER_INDEX_NUM);
|
||||
#else
|
||||
rt_geth_dev.get_buffer_config.tx_buff_addr = rt_malloc(DMA_MEM_ALIGN_SIZE * DMA_DESC_TX_NUM);
|
||||
|
@ -590,7 +590,7 @@ static int geth_dma_desc_init(void)
|
|||
//temp = (void *)rt_ioremap_nocache((void *)awos_arch_virt_to_phys((unsigned long)rt_geth_dev.get_buffer_config.tx_buff_addr), (SYS_PAGE_SIZE<<TX_BUFFER_INDEX_NUM));
|
||||
rt_geth_dev.get_buffer_config.phy_tx_buff_addr = (void *)awos_arch_virt_to_phys((unsigned long)rt_geth_dev.get_buffer_config.tx_buff_addr);
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_geth_dev.get_buffer_config.dma_desc_rx = (hal_geth_dma_desc_t *)rt_pages_alloc(RX_BD_INDEX_NUM);
|
||||
#else
|
||||
rt_geth_dev.get_buffer_config.dma_desc_rx = (hal_geth_dma_desc_t *)rt_malloc(sizeof(hal_geth_dma_desc_t) * DMA_DESC_RX_NUM);
|
||||
|
@ -603,7 +603,7 @@ static int geth_dma_desc_init(void)
|
|||
|
||||
//temp = (void *)rt_ioremap_nocache((void *)awos_arch_virt_to_phys((unsigned long)rt_geth_dev.get_buffer_config.dma_desc_rx), (SYS_PAGE_SIZE<<RX_BD_INDEX_NUM));
|
||||
rt_geth_dev.get_buffer_config.phy_dma_desc_rx = (hal_geth_dma_desc_t *)awos_arch_virt_to_phys((unsigned long)rt_geth_dev.get_buffer_config.dma_desc_rx);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_geth_dev.get_buffer_config.dma_desc_tx = (hal_geth_dma_desc_t *)rt_pages_alloc(TX_BD_INDEX_NUM);
|
||||
#else
|
||||
rt_geth_dev.get_buffer_config.dma_desc_tx = (hal_geth_dma_desc_t *)rt_malloc(sizeof(hal_geth_dma_desc_t) * DMA_DESC_TX_NUM);
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
#include "drv_timer.h"
|
||||
|
||||
#include <mmu.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <page.h>
|
||||
#include <lwp_arch.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
struct mem_desc platform_mem_desc[] = {
|
||||
{KERNEL_VADDR_START, KERNEL_VADDR_START + 0x0fffffff, KERNEL_VADDR_START + PV_OFFSET, NORMAL_MEM}
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ rt_mmu_info mmu_info;
|
|||
|
||||
extern size_t MMUTable[];
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_region_t init_page_region = {
|
||||
(uint32_t)PAGE_START,
|
||||
(uint32_t)PAGE_END,
|
||||
|
@ -62,7 +62,7 @@ rt_region_t init_page_region = {
|
|||
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_hw_mmu_map_init(&mmu_info, (void*)0xf0000000, 0x10000000, MMUTable, PV_OFFSET);
|
||||
|
||||
rt_page_init(init_page_region);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "vexpress_a9.h"
|
||||
|
||||
#include "mmu.h"
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include "ioremap.h"
|
||||
#endif
|
||||
|
||||
|
@ -28,7 +28,7 @@ extern int __bss_end;
|
|||
#define HEAP_BEGIN ((void*)&__bss_end)
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#define HEAP_END (void*)(KERNEL_VADDR_START + 16 * 1024 * 1024)
|
||||
#define PAGE_START HEAP_END
|
||||
#define PAGE_END (void*)(KERNEL_VADDR_START + 128 * 1024 * 1024)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#include <lwp_user_mm.h>
|
||||
#endif
|
||||
|
@ -91,7 +91,7 @@ static rt_err_t drv_clcd_control(struct rt_device *device, int cmd, void *args)
|
|||
|
||||
case FBIOGET_FSCREENINFO:
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
struct fb_fix_screeninfo *info = (struct fb_fix_screeninfo *)args;
|
||||
strncpy(info->id, "lcd", sizeof(info->id));
|
||||
info->smem_len = lcd->width * lcd->height * 2;
|
||||
|
@ -141,7 +141,7 @@ int drv_clcd_hw_init(void)
|
|||
_lcd.width = CLCD_WIDTH;
|
||||
_lcd.height = CLCD_HEIGHT;
|
||||
rt_kprintf("try to allocate fb... | w - %d, h - %d | ", _lcd.width, _lcd.height);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
_lcd.fb = rt_pages_alloc(rt_page_bits(_lcd.width * _lcd.height * 2));
|
||||
#else
|
||||
_lcd.fb = rt_malloc(_lcd.width * _lcd.height * 2);
|
||||
|
@ -156,14 +156,14 @@ int drv_clcd_hw_init(void)
|
|||
memset(_lcd.fb, 0xff, _lcd.width * _lcd.height * 2);
|
||||
|
||||
plio = (PL111MMIO*)PL111_IOBASE;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
plio = (PL111MMIO *)rt_ioremap((void*)PL111_IOBASE, 0x1000);
|
||||
#endif
|
||||
plio->tim0 = 0x3F1F3C00 | ((CLCD_WIDTH / 16 - 1) << 2);
|
||||
plio->tim1 = 0x080B6000 | (CLCD_HEIGHT - 1);
|
||||
|
||||
plio->upbase = (uint32_t)_lcd.fb;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
plio->upbase += PV_OFFSET;
|
||||
#endif
|
||||
/* 16-bit 565 color */
|
||||
|
|
|
@ -267,7 +267,7 @@ int rt_hw_mouse_init(void)
|
|||
virtual_addr_t virt = MOUSE_ADDRESS;
|
||||
int irq = MOUSE_IRQ_NUM;
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
virt = (virtual_addr_t)rt_ioremap((void*)MOUSE_ADDRESS, 0x1000);
|
||||
#endif
|
||||
id = (((read32(virt + 0xfec) & 0xff) << 24) |
|
||||
|
|
|
@ -420,7 +420,7 @@ int pl180_init(void)
|
|||
}
|
||||
rt_memset(sdhci, 0, sizeof(struct sdhci_t));
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
virt = (rt_uint32_t)rt_ioremap((void*)MMC_BASE_ADDR, 0x1000);
|
||||
#else
|
||||
virt = MMC_BASE_ADDR;
|
||||
|
|
|
@ -501,7 +501,7 @@ int smc911x_emac_hw_init(void)
|
|||
rt_memset(&_emac, 0x0, sizeof(_emac));
|
||||
|
||||
_emac.iobase = VEXPRESS_ETH_BASE;
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
_emac.iobase = (uint32_t)rt_ioremap((void*)VEXPRESS_ETH_BASE, 0x1000);
|
||||
#endif
|
||||
_emac.irqno = IRQ_VEXPRESS_A9_ETH;
|
||||
|
|
|
@ -74,7 +74,7 @@ int rt_hw_timer_init(void)
|
|||
{
|
||||
rt_uint32_t val;
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
sys_ctrl = (void*)rt_ioremap((void*)REALVIEW_SCTL_BASE, 0x1000);
|
||||
timer_hw_base = (void*)rt_ioremap((void*)REALVIEW_TIMER2_3_BASE, 0x1000);
|
||||
#else
|
||||
|
@ -108,7 +108,7 @@ void timer_init(int timer, unsigned int preload)
|
|||
|
||||
if (timer == 0)
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
timer01_hw_base = (void*)rt_ioremap((void*)TIMER01_HW_BASE_PHY, 0x1000);
|
||||
#else
|
||||
timer01_hw_base = (void*)TIMER01_HW_BASE_PHY;
|
||||
|
@ -126,7 +126,7 @@ void timer_init(int timer, unsigned int preload)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
timer23_hw_base = (void*)rt_ioremap((void*)TIMER23_HW_BASE_PHY, 0x1000);
|
||||
#else
|
||||
timer01_hw_base = (void*)TIMER23_HW_BASE_PHY;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifdef RT_USING_SMP
|
||||
#include <interrupt.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <mmu.h>
|
||||
#endif
|
||||
|
||||
|
@ -35,7 +35,7 @@ void rt_hw_secondary_cpu_up(void)
|
|||
volatile void **plat_boot_reg = (volatile void **)0x10000034;
|
||||
char *entry = (char *)rt_secondary_cpu_entry;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
plat_boot_reg = (volatile void **)rt_hw_mmu_map(&mmu_info, 0, (void *)plat_boot_reg, 0x1000, MMU_MAP_K_RW);
|
||||
if (!plat_boot_reg)
|
||||
{
|
||||
|
|
|
@ -134,7 +134,7 @@ int rt_hw_uart_init(void)
|
|||
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
||||
|
||||
#ifdef RT_USING_UART0
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
_uart0_device.hw_base = (uint32_t)rt_ioremap((void*)_uart0_device.hw_base, 0x1000);
|
||||
#endif
|
||||
uart = &_uart0_device;
|
||||
|
@ -152,7 +152,7 @@ int rt_hw_uart_init(void)
|
|||
#endif
|
||||
|
||||
#ifdef RT_USING_UART1
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
_uart1_device.hw_base = (uint32_t)rt_ioremap((void*)_uart1_device.hw_base, 0x1000);
|
||||
#endif
|
||||
uart = &_uart1_device;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "plic.h"
|
||||
#include "stack.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include "riscv_mmu.h"
|
||||
#include "mmu.h"
|
||||
#include "page.h"
|
||||
|
@ -68,7 +68,7 @@ void primary_cpu_entry(void)
|
|||
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_page_init(init_page_region);
|
||||
/* init mmu_info structure */
|
||||
rt_hw_mmu_map_init(&mmu_info, (void *)(USER_VADDR_START - IOREMAP_SIZE), IOREMAP_SIZE, (rt_size_t *)MMUTable, 0);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "drv_uart.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <ioremap.h>
|
||||
#endif
|
||||
#include "sbi.h"
|
||||
|
@ -138,7 +138,7 @@ int rt_hw_uart_init(void)
|
|||
struct rt_serial_device *serial;
|
||||
struct device_uart *uart;
|
||||
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
uart0_base = rt_ioremap(uart0_base, 4096);
|
||||
#endif
|
||||
// register device
|
||||
|
|
|
@ -66,7 +66,7 @@ int rt_virtio_devices_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mmio_base = (rt_ubase_t)rt_ioremap((void *)mmio_base, VIRTIO_MMIO_SIZE * VIRTIO_MAX_NR);
|
||||
|
||||
if (mmio_base == RT_NULL)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <rtdef.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <mmu.h>
|
||||
#include <ioremap.h>
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ rt_hw_context_switch:
|
|||
|
||||
stmfd sp!, {r4} @ push cpsr
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
stmfd sp, {r13, r14}^ @ push usr_sp usr_lr
|
||||
sub sp, #8
|
||||
#endif
|
||||
|
@ -173,7 +173,7 @@ rt_hw_context_switch_exit:
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
ldmfd sp, {r13, r14}^ /* usr_sp, usr_lr */
|
||||
add sp, #8
|
||||
#endif
|
||||
|
|
|
@ -57,7 +57,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
|
|||
else
|
||||
*(--stk) = SVCMODE; /* arm mode */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
*(--stk) = 0; /* user lr */
|
||||
*(--stk) = 0; /* user sp*/
|
||||
#endif
|
||||
|
|
|
@ -231,7 +231,7 @@ vector_irq:
|
|||
mrs r1, spsr /* original mode */
|
||||
stmfd r0!, {r1}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
stmfd r0, {r13, r14}^ /* usr_sp, usr_lr */
|
||||
sub r0, #8
|
||||
#endif
|
||||
|
@ -299,7 +299,7 @@ rt_hw_context_switch_interrupt_do:
|
|||
stmfd sp!, {r1-r4} @ push old task's r0-r3
|
||||
stmfd sp!, {r0} @ push old task's cpsr
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
stmfd sp, {r13, r14}^ @push usr_sp, usr_lr
|
||||
sub sp, #8
|
||||
#endif
|
||||
|
@ -337,7 +337,7 @@ rt_hw_context_switch_interrupt_do:
|
|||
1:
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
ldmfd sp, {r13, r14}^ @pop usr_sp, usr_lr
|
||||
add sp, #8
|
||||
#endif
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <dfs_fs.h>
|
||||
#include <dfs_file.h>
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#include <lwp_user_mm.h>
|
||||
#endif
|
||||
|
@ -173,8 +173,8 @@ int dfs_tmpfs_ioctl(struct dfs_fd *file, int cmd, void *args)
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
case RT_FIOMMAP2:
|
||||
#ifdef RT_USING_SMART
|
||||
case RT_FIOMMAP2:
|
||||
{
|
||||
struct dfs_mmap2_args *mmap2 = (struct dfs_mmap2_args *)args;
|
||||
if (mmap2)
|
||||
|
@ -394,7 +394,7 @@ int dfs_tmpfs_open(struct dfs_fd *file)
|
|||
p_file = dfs_tmpfs_lookup(superblock, parent_path, &size);
|
||||
if (p_file == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
|
||||
/* create a file entry */
|
||||
d_file = (struct tmpfs_file *)rt_calloc(1, sizeof(struct tmpfs_file));
|
||||
if (d_file == NULL)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <dfs_fs.h>
|
||||
#include <dfs_file.h>
|
||||
#include "dfs_private.h"
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
|
||||
|
@ -644,7 +644,7 @@ char *dfs_normalize_path(const char *directory, const char *filename)
|
|||
#ifdef DFS_USING_WORKDIR
|
||||
if (directory == NULL) /* shall use working directory */
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
directory = lwp_getcwd();
|
||||
#else
|
||||
directory = &working_directory[0];
|
||||
|
@ -775,7 +775,7 @@ RTM_EXPORT(dfs_normalize_path);
|
|||
struct dfs_fdtable *dfs_fdtable_get(void)
|
||||
{
|
||||
struct dfs_fdtable *fdt;
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
struct rt_lwp *lwp;
|
||||
|
||||
lwp = (struct rt_lwp *)rt_thread_self()->lwp;
|
||||
|
@ -790,7 +790,7 @@ struct dfs_fdtable *dfs_fdtable_get(void)
|
|||
return fdt;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
struct dfs_fdtable *dfs_fdtable_get_pid(int pid)
|
||||
{
|
||||
struct rt_lwp *lwp = RT_NULL;
|
||||
|
@ -854,7 +854,7 @@ int list_fd(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
static int lsofp(int pid)
|
||||
{
|
||||
int index;
|
||||
|
@ -964,7 +964,7 @@ int lsof(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(lsof, list open files);
|
||||
#endif /* RT_USING_LWP */
|
||||
#endif /* RT_USING_SMART */
|
||||
|
||||
#endif
|
||||
/*@}*/
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <dfs_private.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
|
||||
|
@ -866,7 +866,7 @@ int chdir(const char *path)
|
|||
|
||||
/* close directory stream */
|
||||
closedir(d);
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
/* copy full path to working directory */
|
||||
lwp_setcwd(fullpath);
|
||||
#else
|
||||
|
@ -916,7 +916,7 @@ void setcwd(char *buf)
|
|||
{
|
||||
#ifdef DFS_USING_WORKDIR
|
||||
dfs_lock();
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
lwp_setcwd(buf);
|
||||
#else
|
||||
rt_strncpy(working_directory, buf, DFS_PATH_MAX);
|
||||
|
@ -946,7 +946,7 @@ char *getcwd(char *buf, size_t size)
|
|||
|
||||
dfs_lock();
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
dir_buf = lwp_getcwd();
|
||||
#else
|
||||
dir_buf = &working_directory[0];
|
||||
|
|
|
@ -51,7 +51,7 @@ menuconfig RT_USING_SERIAL
|
|||
|
||||
config RT_USING_TTY
|
||||
bool "Using TTY SYSTEM"
|
||||
depends on RT_USING_LWP
|
||||
depends on RT_USING_SMART
|
||||
default y
|
||||
|
||||
if RT_USING_TTY
|
||||
|
@ -567,8 +567,8 @@ endif
|
|||
|
||||
config RT_USING_DEV_BUS
|
||||
bool "Using Device Bus device drivers"
|
||||
default y if RT_USING_LWP
|
||||
default n if !RT_USING_LWP
|
||||
default y if RT_USING_SMART
|
||||
default n if !RT_USING_SMART
|
||||
|
||||
menuconfig RT_USING_WIFI
|
||||
bool "Using Wi-Fi framework"
|
||||
|
|
|
@ -5,6 +5,6 @@ src = Glob('*.c')
|
|||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd + "/include"]
|
||||
|
||||
group = DefineGroup('tty', src, depend = ['RT_USING_LWP', 'RT_USING_TTY'], CPPPATH = CPPPATH)
|
||||
group = DefineGroup('tty', src, depend = ['RT_USING_SMART', 'RT_USING_TTY'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <tty_ldisc.h>
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
#if defined(RT_USING_POSIX_TERMIOS)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <rthw.h>
|
||||
#include <rtdef.h>
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <mmu.h>
|
||||
#include <ioremap.h>
|
||||
#endif
|
||||
|
@ -47,14 +47,14 @@
|
|||
#define VIRTIO_F_VERSION_1 32
|
||||
#define VIRTIO_F_RING_PACKED 34
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
extern rt_mmu_info mmu_info;
|
||||
#define VIRTIO_VA2PA(vaddr) ((rt_ubase_t)rt_hw_mmu_v2p(&mmu_info, vaddr))
|
||||
#define VIRTIO_PA2VA(paddr) ((rt_ubase_t)rt_ioremap((void *)paddr, ARCH_PAGE_SIZE))
|
||||
#else
|
||||
#define VIRTIO_VA2PA(vaddr) ((rt_ubase_t)vaddr)
|
||||
#define VIRTIO_PA2VA(paddr) ((rt_ubase_t)paddr)
|
||||
#endif /* RT_USING_LWP */
|
||||
#endif /* RT_USING_SMART */
|
||||
#define VIRTIO_PAGE_SHIFT 12
|
||||
#define VIRTIO_PAGE_SIZE (1 << VIRTIO_PAGE_SHIFT)
|
||||
#define VIRTIO_PAGE_ALIGN(addr) (RT_ALIGN(addr, VIRTIO_PAGE_SIZE))
|
||||
|
|
|
@ -294,7 +294,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(RT_USING_LWP) && defined(DFS_USING_POSIX)
|
||||
#if defined(RT_USING_SMART) && defined(DFS_USING_POSIX)
|
||||
pid_t exec(char*, int, int, char**);
|
||||
|
||||
/* check whether a file of the given path exits */
|
||||
|
@ -518,14 +518,14 @@ int msh_exec(char *cmd, rt_size_t length)
|
|||
}
|
||||
#endif /* RT_USING_MODULE */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
/* exec from msh_exec , debug = 0*/
|
||||
/* _msh_exec_lwp return is pid , <= 0 means failed */
|
||||
if (_msh_exec_lwp(0, cmd, length) > 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* RT_USING_LWP */
|
||||
#endif /* RT_USING_SMART */
|
||||
#endif /* DFS_USING_POSIX */
|
||||
|
||||
/* truncate the cmd at the first space. */
|
||||
|
@ -721,7 +721,7 @@ void msh_auto_complete(char *prefix)
|
|||
|
||||
ptr --;
|
||||
}
|
||||
#if defined(RT_USING_MODULE) || defined(RT_USING_LWP)
|
||||
#if defined(RT_USING_MODULE) || defined(RT_USING_SMART)
|
||||
/* There is a chance that the user want to run the module directly. So
|
||||
* try to complete the file names. If the completed path is not a
|
||||
* module, the system won't crash anyway. */
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <unistd.h>
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include "lwp.h"
|
||||
#endif
|
||||
#ifdef RT_USING_POSIX_DELAY
|
||||
|
@ -886,7 +886,7 @@ struct timer_obj
|
|||
rt_uint32_t reload; /* Reload value in ms */
|
||||
rt_uint32_t status;
|
||||
int sigev_signo;
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
pid_t pid;
|
||||
#endif
|
||||
};
|
||||
|
@ -906,7 +906,7 @@ static void rtthread_timer_wrapper(void *timerobj)
|
|||
if (timer->reload)
|
||||
rt_timer_control(&timer->timer, RT_TIMER_CTRL_SET_TIME, &(timer->reload));
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
sys_kill(timer->pid, timer->sigev_signo);
|
||||
#else
|
||||
if(timer->sigev_notify_function != RT_NULL)
|
||||
|
@ -948,7 +948,7 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
|
|||
rt_snprintf(timername, RT_NAME_MAX, "psx_tm%02d", num++);
|
||||
num %= 100;
|
||||
timer->sigev_signo = evp->sigev_signo;
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
timer->pid = lwp_self()->pid;
|
||||
#endif
|
||||
timer->sigev_notify_function = evp->sigev_notify_function;
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
menuconfig RT_USING_LWP
|
||||
bool "light-weight process"
|
||||
select RT_USING_DFS
|
||||
select RT_USING_LIBC
|
||||
select RT_USING_POSIX_CLOCKTIME
|
||||
select RT_USING_TTY
|
||||
select RT_USING_NULL
|
||||
select RT_USING_ZERO
|
||||
select RT_USING_RANDOM
|
||||
select RT_USING_RTC
|
||||
depends on ARCH_ARM_CORTEX_M || ARCH_ARM_ARM9 || ARCH_ARM_CORTEX_A || ARCH_RISCV64
|
||||
default n
|
||||
depends on RT_USING_SMART
|
||||
default y
|
||||
help
|
||||
The lwP is a light weight process running in user mode.
|
||||
|
||||
|
|
|
@ -40,6 +40,6 @@ if platform in platform_file.keys(): # support platforms
|
|||
CPPPATH = [cwd]
|
||||
CPPPATH += [cwd + '/arch/' + arch + '/' + cpu]
|
||||
|
||||
group = DefineGroup('lwP', src, depend = ['RT_USING_LWP'], CPPPATH = CPPPATH)
|
||||
group = DefineGroup('lwP', src, depend = ['RT_USING_SMART'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <lwp.h>
|
||||
#include <lwp_arch_comm.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#define USER_VADDR_TOP 0x0001000000000000UL
|
||||
#define USER_HEAP_VEND 0x0000ffffB0000000UL
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <lwp_elf.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
#endif
|
||||
|
@ -17,7 +17,7 @@ typedef struct
|
|||
Elf32_Half st_shndx;
|
||||
} Elf32_sym;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
void arch_elf_reloc(rt_mmu_info *m_info, void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, Elf32_sym *dynsym)
|
||||
{
|
||||
size_t rel_off;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <lwp.h>
|
||||
#include <lwp_arch_comm.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#define USER_VADDR_TOP 0xC0000000UL
|
||||
#define USER_HEAP_VEND 0xB0000000UL
|
||||
|
|
|
@ -215,7 +215,7 @@ arch_ret_to_user:
|
|||
2:
|
||||
movs pc, lr
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
.global lwp_check_debug
|
||||
lwp_check_debug:
|
||||
ldr r0, =rt_dbg_ops
|
||||
|
|
|
@ -6,6 +6,6 @@ cwd = GetCurrentDir()
|
|||
src = Glob('*.c') + Glob('*.S')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('lwp-riscv', src, depend = ['RT_USING_LWP'], CPPPATH = CPPPATH)
|
||||
group = DefineGroup('lwp-riscv', src, depend = ['RT_USING_SMART'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <rthw.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
|
@ -261,4 +261,4 @@ void *arch_get_usp_from_uctx(struct rt_user_context *uctx)
|
|||
return uctx->sp;
|
||||
}
|
||||
|
||||
#endif /* RT_USING_USERSPACE */
|
||||
#endif /* ARCH_MM_MMU */
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
#include <lwp_arch_comm.h>
|
||||
#include <riscv_mmu.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#ifdef RT_USING_USERSPACE_32BIT_LIMIT
|
||||
#ifdef ARCH_MM_MMU_32BIT_LIMIT
|
||||
#define USER_HEAP_VADDR 0xF0000000UL
|
||||
#define USER_HEAP_VEND 0xFE000000UL
|
||||
#define USER_STACK_VSTART 0xE0000000UL
|
||||
|
|
|
@ -299,7 +299,7 @@ copy_context_loop:
|
|||
addi a7, a7, -0xfe
|
||||
beqz a7, arch_signal_quit
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
/* save setting when syscall enter */
|
||||
call rt_thread_self
|
||||
call lwp_user_setting_save
|
||||
|
@ -314,7 +314,7 @@ copy_context_loop:
|
|||
arch_syscall_exit:
|
||||
CLOSE_INTERRUPT
|
||||
|
||||
#if defined(RT_USING_USERSPACE)
|
||||
#if defined(ARCH_MM_MMU)
|
||||
LOAD s0, 2 * REGBYTES(sp)
|
||||
andi s0, s0, 0x100
|
||||
bnez s0, dont_ret_to_user
|
||||
|
@ -322,7 +322,7 @@ arch_syscall_exit:
|
|||
#endif
|
||||
dont_ret_to_user:
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
/* restore setting when syscall exit */
|
||||
call rt_thread_self
|
||||
call lwp_user_setting_restore
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
#endif
|
||||
|
@ -17,7 +17,7 @@ typedef struct
|
|||
Elf64_Half st_shndx;
|
||||
} Elf64_sym;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
void arch_elf_reloc(rt_mmu_info *m_info, void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, Elf64_sym *dynsym)
|
||||
{
|
||||
size_t rel_off;
|
||||
|
|
|
@ -6,6 +6,6 @@ cwd = GetCurrentDir()
|
|||
src = Glob('*.c') + Glob('*.S')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('lwp-x86-i386', src, depend = ['RT_USING_LWP'], CPPPATH = CPPPATH)
|
||||
group = DefineGroup('lwp-x86-i386', src, depend = ['RT_USING_SMART'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <rtconfig.h>
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#include <stackframe.h>
|
||||
#include <interrupt.h>
|
||||
|
@ -368,4 +368,4 @@ void lwp_signal_do_return(rt_hw_stack_frame_t *frame)
|
|||
}
|
||||
#endif /* RT_USING_SIGNALS */
|
||||
|
||||
#endif /* RT_USING_USERSPACE */
|
||||
#endif /* ARCH_MM_MMU */
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <lwp_arch_comm.h>
|
||||
#include <stackframe.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#define USER_VADDR_TOP 0xFFFFF000UL
|
||||
#define USER_HEAP_VEND 0xE0000000UL
|
||||
#define USER_HEAP_VADDR 0x90000000UL
|
||||
|
@ -34,7 +34,7 @@ extern "C" {
|
|||
rt_thread_t rt_thread_sp_to_thread(void *spmember_addr);
|
||||
|
||||
void lwp_signal_do_return(rt_hw_stack_frame_t *frame);
|
||||
|
||||
|
||||
rt_inline unsigned long rt_hw_ffz(unsigned long x)
|
||||
{
|
||||
return __builtin_ffsl(~x) - 1;
|
||||
|
@ -44,6 +44,6 @@ rt_inline unsigned long rt_hw_ffz(unsigned long x)
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* RT_USING_USERSPACE */
|
||||
#endif /* ARCH_MM_MMU */
|
||||
|
||||
#endif /*LWP_ARCH_H__*/
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
#endif
|
||||
|
@ -27,7 +27,7 @@ typedef struct
|
|||
Elf32_Half st_shndx;
|
||||
} Elf32_sym;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
void arch_elf_reloc(rt_mmu_info *m_info, void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, Elf32_sym *dynsym)
|
||||
{
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <ioremap.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <mmu.h>
|
||||
#include <lwp_mm_area.h>
|
||||
#include <lwp_mm.h>
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
#define DBG_LVL DBG_WARNING
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <lwp_mm_area.h>
|
||||
#include <lwp_user_mm.h>
|
||||
#endif /* end of RT_USING_USERSPACE */
|
||||
#endif /* end of ARCH_MM_MMU */
|
||||
|
||||
|
||||
#ifndef O_DIRECTORY
|
||||
|
@ -120,7 +120,7 @@ void lwp_set_kernel_sp(uint32_t *sp)
|
|||
|
||||
uint32_t *lwp_get_kernel_sp(void)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
return (uint32_t *)rt_thread_self()->sp;
|
||||
#else
|
||||
uint32_t* kernel_sp;
|
||||
|
@ -138,7 +138,7 @@ uint32_t *lwp_get_kernel_sp(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct process_aux *lwp_argscopy(struct rt_lwp *lwp, int argc, char **argv, char **envp)
|
||||
{
|
||||
int size = sizeof(size_t) * 5; /* store argc, argv, envp, aux, NULL */
|
||||
|
@ -389,7 +389,7 @@ typedef struct
|
|||
Elf_Half st_shndx;
|
||||
} Elf_sym;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct map_range
|
||||
{
|
||||
void *start;
|
||||
|
@ -506,7 +506,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
size_t rel_dyn_size = 0;
|
||||
size_t dynsym_off = 0;
|
||||
size_t dynsym_size = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct map_range user_area[2] = {{NULL, 0}, {NULL, 0}}; /* 0 is text, 1 is data */
|
||||
void *pa, *va;
|
||||
void *va_self;
|
||||
|
@ -555,7 +555,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
}
|
||||
|
||||
if ((eheader.e_type != ET_DYN)
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
&& (eheader.e_type != ET_EXEC)
|
||||
#endif
|
||||
)
|
||||
|
@ -565,7 +565,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
{
|
||||
off = eheader.e_phoff;
|
||||
for (i = 0; i < eheader.e_phnum; i++, off += sizeof pheader)
|
||||
|
@ -601,7 +601,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
|
||||
off = eheader.e_phoff;
|
||||
process_header_size = eheader.e_phnum * sizeof pheader;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (process_header_size > ARCH_PAGE_SIZE - sizeof(char[16]))
|
||||
{
|
||||
LOG_E("process_header_size too big, size:0x%x!", process_header_size);
|
||||
|
@ -627,12 +627,12 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
lseek(fd, off, SEEK_SET);
|
||||
read_len = load_fread(process_header, 1, process_header_size, fd);
|
||||
check_read(read_len, process_header_size);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, process_header, process_header_size);
|
||||
#endif
|
||||
|
||||
aux->item[1].key = AT_PAGESZ;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
aux->item[1].value = ARCH_PAGE_SIZE;
|
||||
#else
|
||||
aux->item[1].value = RT_MM_PAGE_SIZE;
|
||||
|
@ -641,7 +641,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
{
|
||||
uint32_t random_value = rt_tick_get();
|
||||
uint8_t *random;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
uint8_t *krandom;
|
||||
|
||||
random = (uint8_t *)(USER_VADDR_TOP - ARCH_PAGE_SIZE - sizeof(char[16]));
|
||||
|
@ -656,7 +656,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
aux->item[2].value = (size_t)random;
|
||||
}
|
||||
aux->item[3].key = AT_PHDR;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
aux->item[3].value = (size_t)va;
|
||||
#else
|
||||
aux->item[3].value = (size_t)process_header;
|
||||
|
@ -665,7 +665,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
aux->item[4].value = eheader.e_phnum;
|
||||
aux->item[5].key = AT_PHENT;
|
||||
aux->item[5].value = sizeof pheader;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, aux, sizeof *aux);
|
||||
#endif
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
{
|
||||
load_off = (size_t)load_addr;
|
||||
}
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
else
|
||||
{
|
||||
/* map user */
|
||||
|
@ -827,7 +827,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
|
||||
check_off(pheader.p_offset, len);
|
||||
lseek(fd, pheader.p_offset, SEEK_SET);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
{
|
||||
uint32_t size = pheader.p_filesz;
|
||||
size_t tmp_len = 0;
|
||||
|
@ -854,7 +854,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
|
||||
if (pheader.p_filesz < pheader.p_memsz)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
uint32_t size = pheader.p_memsz - pheader.p_filesz;
|
||||
uint32_t size_s;
|
||||
uint32_t off;
|
||||
|
@ -941,7 +941,7 @@ static int load_elf(int fd, int len, struct rt_lwp *lwp, uint8_t *load_addr, str
|
|||
read_len = load_fread(dynsym, 1, dynsym_size, fd);
|
||||
check_read(read_len, dynsym_size);
|
||||
}
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
arch_elf_reloc(m_info, (void *)load_off, rel_dyn_start, rel_dyn_size, got_start, got_size, dynsym);
|
||||
#else
|
||||
arch_elf_reloc((void *)load_off, rel_dyn_start, rel_dyn_size, got_start, got_size, dynsym);
|
||||
|
@ -1055,7 +1055,7 @@ void lwp_cleanup(struct rt_thread *tid)
|
|||
tty_pop(&tty_head, lwp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1150,7 +1150,7 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp)
|
|||
lwp_ref_dec(lwp);
|
||||
return -ENOMEM;
|
||||
}
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (lwp_user_space_init(lwp) != 0)
|
||||
{
|
||||
lwp_tid_put(tid);
|
||||
|
@ -1247,7 +1247,7 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp)
|
|||
LOG_E("malloc fail!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
lwp->tty = tty;
|
||||
lwp->tty->pgrp = lwp->__pgrp;
|
||||
lwp->tty->session = lwp->session;
|
||||
|
@ -1271,7 +1271,7 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp)
|
|||
LOG_E("malloc fail!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
lwp->tty = self_lwp->tty;
|
||||
lwp->tty->pgrp = lwp->__pgrp;
|
||||
lwp->tty->session = lwp->session;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "lwp_syscall.h"
|
||||
#include "lwp_avl.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include "lwp_shm.h"
|
||||
|
||||
#include "mmu.h"
|
||||
|
@ -59,7 +59,7 @@ extern "C" {
|
|||
|
||||
struct rt_lwp
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
rt_mmu_info mmu_info;
|
||||
struct lwp_avl_struct *map_area;
|
||||
size_t end_heap;
|
||||
|
@ -153,14 +153,14 @@ int lwp_execve(char *filename, int debug, int argc, char **argv, char **envp);
|
|||
|
||||
/*create by lwp_setsid.c*/
|
||||
int setsid(void);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
void lwp_mmu_switch(struct rt_thread *thread);
|
||||
#endif
|
||||
void lwp_user_setting_save(rt_thread_t thread);
|
||||
void lwp_user_setting_restore(rt_thread_t thread);
|
||||
int lwp_setaffinity(pid_t pid, int cpu);
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct __pthread {
|
||||
/* Part 1 -- these fields may be external or
|
||||
* * internal (accessed via asm) ABI. Do not change. */
|
||||
|
|
|
@ -23,7 +23,7 @@ void arch_syscall_exit();
|
|||
void arch_ret_to_user();
|
||||
|
||||
/* ELF relocation */
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
void arch_elf_reloc(rt_mmu_info *m_info, void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, void *dynsym);
|
||||
#else
|
||||
void arch_elf_reloc(void *text_start, void *rel_dyn_start, size_t rel_dyn_size, void *got_start, size_t got_size, void *dynsym);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <rtthread.h>
|
||||
#include <lwp.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <lwp_user_mm.h>
|
||||
#endif
|
||||
#include "sys/time.h"
|
||||
|
@ -188,7 +188,7 @@ int sys_futex(int *uaddr, int op, int val, const struct timespec *timeout,
|
|||
return -RT_EINVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* if (op & (FUTEX_WAKE|FUTEX_FD|FUTEX_WAKE_BITSET|FUTEX_TRYLOCK_PI|FUTEX_UNLOCK_PI)) was TRUE
|
||||
* `timeout` should be ignored by implementation, according to POSIX futex(2) manual.
|
||||
* since only FUTEX_WAKE is implemented in rt-smart, only FUTEX_WAKE was omitted currently
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <lwp_mm_area.h>
|
||||
|
||||
int lwp_map_area_insert(struct lwp_avl_struct **avl_tree, size_t addr, size_t size, int ma_type)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <lwp_avl.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "lwp_pid.h"
|
||||
#include "tty.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include "lwp_user_mm.h"
|
||||
#endif
|
||||
|
||||
|
@ -46,7 +46,7 @@ static pid_t current_pid = 0;
|
|||
|
||||
struct lwp_avl_struct *lwp_get_pid_ary(void)
|
||||
{
|
||||
return lwp_pid_ary;
|
||||
return lwp_pid_ary;
|
||||
}
|
||||
|
||||
static pid_t lwp_pid_get(void)
|
||||
|
@ -418,7 +418,7 @@ void lwp_free(struct rt_lwp* lwp)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
lwp_unmap_user_space(lwp);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <rtthread.h>
|
||||
#include <lwp.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <lwp_user_mm.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <lwp.h>
|
||||
#include <lwp_shm.h>
|
||||
#include <lwp_mm.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <board.h>
|
||||
|
||||
#include <lwp.h>
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <lwp_user_mm.h>
|
||||
#include <lwp_arch.h>
|
||||
#endif
|
||||
|
@ -44,7 +44,7 @@
|
|||
#define SYSCALL_NET(f) SYSCALL_SIGN(sys_notimpl)
|
||||
#endif
|
||||
|
||||
#if defined(RT_USING_DFS) && defined(RT_USING_USERSPACE)
|
||||
#if defined(RT_USING_DFS) && defined(ARCH_MM_MMU)
|
||||
#define SYSCALL_USPACE(f) f
|
||||
#else
|
||||
#define SYSCALL_USPACE(f) SYSCALL_SIGN(sys_notimpl)
|
||||
|
@ -451,7 +451,7 @@ void sys_exit_group(int status)
|
|||
/* syscall: "read" ret: "ssize_t" args: "int" "void *" "size_t" */
|
||||
ssize_t sys_read(int fd, void *buf, size_t nbyte)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
void *kmem = RT_NULL;
|
||||
ssize_t ret = -1;
|
||||
|
||||
|
@ -492,7 +492,7 @@ ssize_t sys_read(int fd, void *buf, size_t nbyte)
|
|||
/* syscall: "write" ret: "ssize_t" args: "int" "const void *" "size_t" */
|
||||
ssize_t sys_write(int fd, const void *buf, size_t nbyte)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
void *kmem = RT_NULL;
|
||||
ssize_t ret = -1;
|
||||
|
||||
|
@ -537,7 +537,7 @@ off_t sys_lseek(int fd, off_t offset, int whence)
|
|||
/* syscall: "open" ret: "int" args: "const char *" "int" "..." */
|
||||
int sys_open(const char *name, int flag, ...)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int ret = -1;
|
||||
rt_size_t len = 0;
|
||||
char *kname = RT_NULL;
|
||||
|
@ -590,7 +590,7 @@ int sys_ioctl(int fd, unsigned long cmd, void* data)
|
|||
|
||||
int sys_fstat(int file, struct stat *buf)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int ret = -1;
|
||||
struct stat statbuff;
|
||||
|
||||
|
@ -718,7 +718,7 @@ int sys_poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
|||
{
|
||||
int ret = -1;
|
||||
int i = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct pollfd *kfds = RT_NULL;
|
||||
|
||||
if (!lwp_user_accessable((void *)fds, nfds * sizeof *fds))
|
||||
|
@ -772,12 +772,12 @@ int sys_poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
|||
}
|
||||
#endif /* RT_USING_MUSL */
|
||||
return ret;
|
||||
#endif /* RT_USING_USERSPACE */
|
||||
#endif /* ARCH_MM_MMU */
|
||||
}
|
||||
|
||||
int sys_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int ret = -1;
|
||||
fd_set *kreadfds = RT_NULL, *kwritefds = RT_NULL, *kexceptfds = RT_NULL;
|
||||
|
||||
|
@ -876,7 +876,7 @@ quit:
|
|||
|
||||
int sys_unlink(const char *pathname)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int ret = -1;
|
||||
rt_size_t len = 0;
|
||||
char *kname = RT_NULL;
|
||||
|
@ -920,10 +920,10 @@ int sys_nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
|||
if (!lwp_user_accessable((void *)rqtp, sizeof *rqtp))
|
||||
return -EFAULT;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct timespec rqtp_k;
|
||||
struct timespec rmtp_k;
|
||||
|
||||
|
||||
lwp_get_from_user(&rqtp_k, (void *)rqtp, sizeof rqtp_k);
|
||||
ret = nanosleep(&rqtp_k, &rmtp_k);
|
||||
if ((ret != -1 || rt_get_errno() == EINTR) && rmtp && lwp_user_accessable((void *)rmtp, sizeof *rmtp))
|
||||
|
@ -946,7 +946,7 @@ int sys_nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
|||
/* syscall: "gettimeofday" ret: "int" args: "struct timeval *" "struct timezone *" */
|
||||
int sys_gettimeofday(struct timeval *tp, struct timezone *tzp)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct timeval t_k;
|
||||
|
||||
if (tp)
|
||||
|
@ -1085,7 +1085,7 @@ rt_err_t sys_mutex_release(rt_mutex_t mutex)
|
|||
return rt_mutex_release(mutex);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
/* memory allocation */
|
||||
rt_base_t sys_brk(void *addr)
|
||||
{
|
||||
|
@ -1278,7 +1278,7 @@ rt_err_t sys_rt_timer_control(rt_timer_t timer, int cmd, void *arg)
|
|||
rt_err_t sys_timer_create(clockid_t clockid, struct sigevent *restrict sevp, timer_t *restrict timerid)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct sigevent sevp_k;
|
||||
timer_t timerid_k;
|
||||
struct sigevent evp_default;
|
||||
|
@ -1313,7 +1313,7 @@ rt_err_t sys_timer_settime(timer_t timerid, int flags,
|
|||
struct itimerspec *restrict old_value)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct itimerspec new_value_k;
|
||||
struct itimerspec old_value_k;
|
||||
|
||||
|
@ -1331,7 +1331,7 @@ rt_err_t sys_timer_settime(timer_t timerid, int flags,
|
|||
rt_err_t sys_timer_gettime(timer_t timerid, struct itimerspec *curr_value)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
struct itimerspec curr_value_k;
|
||||
lwp_get_from_user(&curr_value_k, (void *)curr_value, sizeof curr_value_k);
|
||||
|
@ -1360,7 +1360,7 @@ rt_thread_t sys_thread_create(void *arg[])
|
|||
|
||||
lwp = rt_thread_self()->lwp;
|
||||
lwp_ref_inc(lwp);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
user_stack = lwp_map_user(lwp, 0, (size_t)arg[3], 0);
|
||||
if (!user_stack)
|
||||
{
|
||||
|
@ -1421,7 +1421,7 @@ rt_thread_t sys_thread_create(void *arg[])
|
|||
thread->user_stack = (void *)user_stack;
|
||||
thread->user_stack_size = (uint32_t)arg[4];
|
||||
rt_memset(thread->user_stack, '#', thread->user_stack_size);
|
||||
#endif /* RT_USING_USERSPACE */
|
||||
#endif /* ARCH_MM_MMU */
|
||||
|
||||
thread->lwp = (void*)lwp;
|
||||
thread->tid = tid;
|
||||
|
@ -1613,7 +1613,7 @@ static int _copy_process(struct rt_lwp *dest_lwp, struct rt_lwp *src_lwp)
|
|||
|
||||
static void lwp_struct_copy(struct rt_lwp *dst, struct rt_lwp *src)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
dst->end_heap = src->end_heap;
|
||||
#endif
|
||||
dst->lwp_type = src->lwp_type;
|
||||
|
@ -1783,7 +1783,7 @@ int _sys_fork(void)
|
|||
LOG_E("malloc fail!\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
lwp->tty->foreground = lwp;
|
||||
}
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
@ -2369,7 +2369,7 @@ int sys_execve(const char *path, char *const argv[], char *const envp[])
|
|||
|
||||
rt_pages_free(page, 0);
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
_swap_lwp_data(lwp, new_lwp, rt_mmu_info, mmu_info);
|
||||
_swap_lwp_data(lwp, new_lwp, struct lwp_avl_struct *, map_area);
|
||||
_swap_lwp_data(lwp, new_lwp, size_t, end_heap);
|
||||
|
@ -2554,7 +2554,7 @@ void sys_hw_interrupt_enable(uint32_t level)
|
|||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int sys_shmget(size_t key, size_t size, int create)
|
||||
{
|
||||
return lwp_shmget(key, size, create);
|
||||
|
@ -2891,13 +2891,13 @@ int sys_recvfrom(int socket, void *mem, size_t len, int flags,
|
|||
struct musl_sockaddr *from, socklen_t *fromlen)
|
||||
{
|
||||
int flgs = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int ret = -1;
|
||||
void *kmem = RT_NULL;
|
||||
#endif
|
||||
|
||||
flgs = netflags_muslc_2_lwip(flags);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!len)
|
||||
{
|
||||
return -EINVAL;
|
||||
|
@ -2969,13 +2969,13 @@ int sys_sendto(int socket, const void *dataptr, size_t size, int flags,
|
|||
const struct musl_sockaddr *to, socklen_t tolen)
|
||||
{
|
||||
int flgs = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int ret = -1;
|
||||
void *kmem = RT_NULL;
|
||||
#endif
|
||||
|
||||
flgs = netflags_muslc_2_lwip(flags);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!size)
|
||||
{
|
||||
return -EINVAL;
|
||||
|
@ -3329,7 +3329,7 @@ int sys_thread_sighandler_set(int sig, lwp_sighandler_t func)
|
|||
int32_t sys_waitpid(int32_t pid, int *status, int options)
|
||||
{
|
||||
int ret = -1;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!lwp_user_accessable((void *)status, sizeof(int)))
|
||||
{
|
||||
return -EFAULT;
|
||||
|
@ -3373,11 +3373,11 @@ int sys_getaddrinfo(const char *nodename,
|
|||
char *k_nodename = NULL;
|
||||
char *k_servname = NULL;
|
||||
struct addrinfo *k_hints = NULL;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int err;
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!lwp_user_accessable((void *)res, sizeof(*res)))
|
||||
{
|
||||
SET_ERRNO(EFAULT);
|
||||
|
@ -3386,7 +3386,7 @@ int sys_getaddrinfo(const char *nodename,
|
|||
#endif
|
||||
if (nodename)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
lwp_user_strlen(nodename, &err);
|
||||
if (err)
|
||||
{
|
||||
|
@ -3403,7 +3403,7 @@ int sys_getaddrinfo(const char *nodename,
|
|||
}
|
||||
if (servname)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
lwp_user_strlen(servname, &err);
|
||||
if (err)
|
||||
{
|
||||
|
@ -3421,7 +3421,7 @@ int sys_getaddrinfo(const char *nodename,
|
|||
|
||||
if (hints)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!lwp_user_accessable((void *)hints, sizeof(*hints)))
|
||||
{
|
||||
SET_ERRNO(EFAULT);
|
||||
|
@ -3496,7 +3496,7 @@ int sys_gethostbyname2_r(const char *name, int af, struct hostent *ret,
|
|||
char *k_name = NULL;
|
||||
int a_err = 0;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!lwp_user_accessable((void *)err, sizeof(*err)))
|
||||
{
|
||||
SET_ERRNO(EFAULT);
|
||||
|
@ -3605,7 +3605,7 @@ char *sys_getcwd(char *buf, size_t size)
|
|||
|
||||
int sys_chdir(const char *path)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int err = 0;
|
||||
|
||||
lwp_user_strlen(path, &err);
|
||||
|
@ -3623,7 +3623,7 @@ int sys_chdir(const char *path)
|
|||
|
||||
int sys_mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int err = 0;
|
||||
|
||||
lwp_user_strlen(path, &err);
|
||||
|
@ -3641,7 +3641,7 @@ int sys_mkdir(const char *path, mode_t mode)
|
|||
|
||||
int sys_rmdir(const char *path)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int err = 0;
|
||||
|
||||
lwp_user_strlen(path, &err);
|
||||
|
@ -3675,7 +3675,7 @@ int sys_getdents(int fd, struct libc_dirent *dirp, size_t nbytes)
|
|||
size_t rtt_nbytes = 0;
|
||||
struct dirent *rtt_dirp;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!lwp_user_accessable((void *)dirp, sizeof(struct libc_dirent)))
|
||||
{
|
||||
return -EFAULT;
|
||||
|
@ -3732,7 +3732,7 @@ int sys_set_tid_address(int *tidptr)
|
|||
{
|
||||
rt_thread_t thread;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
if (!lwp_user_accessable((void *)tidptr, sizeof(int)))
|
||||
{
|
||||
return -EFAULT;
|
||||
|
@ -3752,7 +3752,7 @@ int sys_gettid(void)
|
|||
int sys_access(const char *filename, int mode)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
rt_size_t len = 0;
|
||||
char *kname = RT_NULL;
|
||||
int a_err = 0;
|
||||
|
@ -3802,7 +3802,7 @@ int sys_pipe(int fd[2])
|
|||
int sys_clock_settime(clockid_t clk, const struct timespec *ts)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
size_t size = sizeof(struct timespec);
|
||||
struct timespec *kts = NULL;
|
||||
|
||||
|
@ -3833,7 +3833,7 @@ int sys_clock_settime(clockid_t clk, const struct timespec *ts)
|
|||
int sys_clock_gettime(clockid_t clk, struct timespec *ts)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
size_t size = sizeof(struct timespec);
|
||||
struct timespec *kts = NULL;
|
||||
|
||||
|
@ -3870,7 +3870,7 @@ int sys_clock_nanosleep(clockid_t clk, int flags, const struct timespec *rqtp, s
|
|||
if (!lwp_user_accessable((void *)rqtp, sizeof *rqtp))
|
||||
return -EFAULT;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct timespec rqtp_k;
|
||||
struct timespec rmtp_k;
|
||||
|
||||
|
@ -3896,7 +3896,7 @@ int sys_clock_nanosleep(clockid_t clk, int flags, const struct timespec *rqtp, s
|
|||
int sys_clock_getres(clockid_t clk, struct timespec *ts)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
struct timespec kts;
|
||||
size_t size = sizeof(struct timespec);
|
||||
|
||||
|
@ -3922,7 +3922,7 @@ int sys_clock_getres(clockid_t clk, struct timespec *ts)
|
|||
int sys_rename(const char *oldpath, const char *newpath)
|
||||
{
|
||||
int ret = -1;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
int err;
|
||||
|
||||
lwp_user_strlen(oldpath, &err);
|
||||
|
@ -4035,7 +4035,7 @@ int sys_getrandom(void *buf, size_t buflen, unsigned int flags)
|
|||
return -EFAULT;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
kmem = kmem_get(buflen);
|
||||
if (!kmem)
|
||||
{
|
||||
|
@ -4147,7 +4147,7 @@ int sys_sched_get_priority_max(int policy)
|
|||
{
|
||||
rt_set_errno(EINVAL);
|
||||
return -rt_get_errno();
|
||||
}
|
||||
}
|
||||
return RT_THREAD_PRIORITY_MAX;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "lwp.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include "lwp_user_mm.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#include <mmu.h>
|
||||
#include <page.h>
|
||||
|
@ -390,7 +390,7 @@ void* lwp_mmap2(void *addr, size_t length, int prot,
|
|||
if (d && d->vnode->type == FT_DEVICE)
|
||||
{
|
||||
struct dfs_mmap2_args mmap2;
|
||||
|
||||
|
||||
mmap2.addr = addr;
|
||||
mmap2.length = length;
|
||||
mmap2.prot = prot;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
#include <lwp.h>
|
||||
#include <lwp_mm_area.h>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
#include <page.h>
|
||||
#include <mmu.h>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#ifndef __PAGE_H__
|
||||
#define __PAGE_H__
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef ARCH_MM_MMU
|
||||
|
||||
typedef struct tag_region
|
||||
{
|
||||
|
|
|
@ -420,9 +420,9 @@ struct rt_object
|
|||
void *module_id; /**< id of application module */
|
||||
#endif /* RT_USING_MODULE */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
int lwp_ref_count; /**< ref count for lwp */
|
||||
#endif /* RT_USING_LWP */
|
||||
#endif /* RT_USING_SMART */
|
||||
|
||||
rt_list_t list; /**< list node of kernel object */
|
||||
};
|
||||
|
@ -573,7 +573,7 @@ typedef void (*rt_sighandler_t)(int signo);
|
|||
|
||||
#else
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
|
||||
|
@ -676,7 +676,7 @@ struct rt_cpu
|
|||
|
||||
struct rt_thread;
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
typedef rt_err_t (*rt_wakeup_func_t)(void *object, struct rt_thread *thread);
|
||||
|
||||
struct rt_wakeup
|
||||
|
@ -733,9 +733,9 @@ struct rt_thread
|
|||
void *module_id; /**< id of application module */
|
||||
#endif /* RT_USING_MODULE */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
int lwp_ref_count; /**< ref count for lwp */
|
||||
#endif /* RT_USING_LWP */
|
||||
#endif /* RT_USING_SMART */
|
||||
|
||||
rt_list_t list; /**< the object list */
|
||||
rt_list_t tlist; /**< the thread list */
|
||||
|
@ -793,7 +793,7 @@ struct rt_thread
|
|||
void *si_list; /**< the signal infor list */
|
||||
#endif /* RT_USING_SIGNALS */
|
||||
|
||||
#if defined(RT_USING_LWP)
|
||||
#ifdef RT_USING_SMART
|
||||
void *msg_ret; /**< the return msg */
|
||||
#endif
|
||||
|
||||
|
@ -813,7 +813,7 @@ struct rt_thread
|
|||
void (*cleanup)(struct rt_thread *tid); /**< cleanup function when thread exit */
|
||||
|
||||
/* light weight process if present */
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
void *lwp;
|
||||
/* for user create */
|
||||
void *user_entry;
|
||||
|
@ -833,7 +833,7 @@ struct rt_thread
|
|||
|
||||
struct rt_wakeup wakeup; /**< wakeup data */
|
||||
int exit_request;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#if defined(ARCH_MM_MMU)
|
||||
int step_exec;
|
||||
int debug_attach_req;
|
||||
int debug_ret_user;
|
||||
|
@ -1226,10 +1226,10 @@ typedef struct rt_wqueue rt_wqueue_t;
|
|||
struct rt_device
|
||||
{
|
||||
struct rt_object parent; /**< inherit from rt_object */
|
||||
#ifdef RT_USING_DM
|
||||
#ifdef RT_USING_DM
|
||||
struct rt_driver *drv;
|
||||
void *dtb_node;
|
||||
#endif
|
||||
void *dtb_node;
|
||||
#endif
|
||||
enum rt_device_class_type type; /**< device type */
|
||||
rt_uint16_t flag; /**< device flag */
|
||||
rt_uint16_t open_flag; /**< device open flag */
|
||||
|
@ -1262,7 +1262,7 @@ struct rt_device
|
|||
};
|
||||
|
||||
#define RT_DRIVER_MATCH_DTS (1<<0)
|
||||
struct rt_device_id
|
||||
struct rt_device_id
|
||||
{
|
||||
const char *compatible;
|
||||
void *data;
|
||||
|
@ -1270,7 +1270,7 @@ struct rt_device_id
|
|||
|
||||
struct rt_driver
|
||||
{
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const struct rt_device_ops *dev_ops;
|
||||
#else
|
||||
/* common device interface */
|
||||
|
@ -1279,7 +1279,7 @@ struct rt_driver
|
|||
rt_err_t (*close) (rt_device_t dev);
|
||||
rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
|
||||
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
|
||||
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
|
||||
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
|
||||
#endif
|
||||
const struct filesystem_ops *fops;
|
||||
const char *name;
|
||||
|
@ -1304,7 +1304,7 @@ struct rt_device_notify
|
|||
struct rt_device *dev;
|
||||
};
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
struct rt_channel
|
||||
{
|
||||
struct rt_ipc_object parent; /**< inherit from object */
|
||||
|
|
|
@ -166,7 +166,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg);
|
|||
rt_err_t rt_thread_suspend(rt_thread_t thread);
|
||||
rt_err_t rt_thread_suspend_with_flag(rt_thread_t thread, int suspend_flag);
|
||||
rt_err_t rt_thread_resume(rt_thread_t thread);
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
rt_err_t rt_thread_wakeup(rt_thread_t thread);
|
||||
void rt_thread_wakeup_set(struct rt_thread *thread, rt_wakeup_func_t func, void* user_data);
|
||||
#endif
|
||||
|
|
|
@ -79,28 +79,25 @@ config ARCH_ARM_MMU
|
|||
select ARCH_MM_MMU
|
||||
depends on ARCH_ARM
|
||||
|
||||
config RT_USING_USERSPACE
|
||||
bool "Isolated user space"
|
||||
default n
|
||||
depends on ARCH_MM_MMU
|
||||
|
||||
if RT_USING_SMART
|
||||
config KERNEL_VADDR_START
|
||||
hex "The virtural address of kernel start"
|
||||
default 0xc0000000 if ARCH_ARM
|
||||
default 0x80000000 if ARCH_RISCV
|
||||
depends on RT_USING_USERSPACE
|
||||
depends on ARCH_MM_MMU
|
||||
|
||||
config PV_OFFSET
|
||||
hex "The offset of kernel physical address and virtural address"
|
||||
default 0xa0000000 if ARCH_ARM
|
||||
default 0x0 if ARCH_RISCV
|
||||
depends on RT_USING_USERSPACE
|
||||
depends on ARCH_MM_MMU
|
||||
|
||||
config RT_IOREMAP_LATE
|
||||
bool "Support to create IO mapping in the kernel address space after system initlalization."
|
||||
default n
|
||||
depends on ARCH_ARM_CORTEX_A
|
||||
depends on RT_USING_USERSPACE
|
||||
depends on ARCH_MM_MMU
|
||||
endif
|
||||
|
||||
config ARCH_ARM_ARM9
|
||||
bool
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#include <lwp_user_mm.h>
|
||||
#include <lwp_arch.h>
|
||||
|
@ -520,7 +520,7 @@ void rt_unwind(struct rt_hw_exp_stack *regs, unsigned int pc_adj)
|
|||
e_regs.ARM_sp = regs->sp;
|
||||
e_regs.ARM_lr = regs->lr;
|
||||
e_regs.ARM_pc = regs->pc - pc_adj;
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
if (!lwp_user_accessable((void *)e_regs.ARM_pc, sizeof (void *)))
|
||||
{
|
||||
e_regs.ARM_pc = regs->lr - sizeof(void *);
|
||||
|
|
|
@ -154,7 +154,7 @@ rt_base_t rt_hw_cpu_dcache_status(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#define ICACHE (1<<0)
|
||||
#define DCACHE (1<<1)
|
||||
#define BCACHE (ICACHE|DCACHE)
|
||||
|
|
|
@ -45,12 +45,12 @@ rt_hw_context_switch_to:
|
|||
#ifdef RT_USING_SMP
|
||||
mov r0, r1
|
||||
bl rt_cpus_lock_status_restore
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
bl rt_thread_self
|
||||
bl lwp_user_setting_restore
|
||||
#endif
|
||||
#else
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
bl rt_thread_self
|
||||
mov r4, r0
|
||||
bl lwp_mmu_switch
|
||||
|
@ -85,7 +85,7 @@ rt_hw_context_switch:
|
|||
|
||||
stmfd sp!, {r4} @ push cpsr
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
stmfd sp, {r13, r14}^ @ push usr_sp usr_lr
|
||||
sub sp, #8
|
||||
#endif
|
||||
|
@ -108,12 +108,12 @@ rt_hw_context_switch:
|
|||
#ifdef RT_USING_SMP
|
||||
mov r0, r2
|
||||
bl rt_cpus_lock_status_restore
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
bl rt_thread_self
|
||||
bl lwp_user_setting_restore
|
||||
#endif
|
||||
#else
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
bl rt_thread_self
|
||||
mov r4, r0
|
||||
bl lwp_mmu_switch
|
||||
|
@ -149,9 +149,9 @@ rt_hw_context_switch_interrupt:
|
|||
* r2 :addr of to_thread's sp
|
||||
* r3 :to_thread's tcb
|
||||
*/
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
push {r0 - r3, lr}
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
bl rt_thread_self
|
||||
bl lwp_user_setting_save
|
||||
#endif
|
||||
|
@ -161,11 +161,11 @@ rt_hw_context_switch_interrupt:
|
|||
|
||||
ldr sp, [r2]
|
||||
mov r0, r3
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mov r4, r0
|
||||
#endif
|
||||
bl rt_cpus_lock_status_restore
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mov r0, r4
|
||||
bl lwp_user_setting_restore
|
||||
#endif
|
||||
|
@ -177,7 +177,7 @@ rt_hw_context_switch_interrupt:
|
|||
* r2 :from_thread's tcb
|
||||
* r3 :to_thread's tcb
|
||||
*/
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
/* now to_thread(r3) not used */
|
||||
ldr ip, =rt_thread_switch_interrupt_flag
|
||||
ldr r3, [ip]
|
||||
|
@ -187,7 +187,7 @@ rt_hw_context_switch_interrupt:
|
|||
str r0, [r3]
|
||||
mov r3, #1 @ set rt_thread_switch_interrupt_flag to 1
|
||||
str r3, [ip]
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
push {r1, lr}
|
||||
mov r0, r2
|
||||
bl lwp_user_setting_save
|
||||
|
@ -239,14 +239,14 @@ rt_hw_context_switch_exit:
|
|||
1:
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
ldmfd sp, {r13, r14}^ /* usr_sp, usr_lr */
|
||||
add sp, #8
|
||||
#endif
|
||||
ldmfd sp!, {r1}
|
||||
msr spsr_cxsf, r1 /* original mode */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
and r1, #0x1f
|
||||
cmp r1, #0x10
|
||||
bne 1f
|
||||
|
|
|
@ -69,7 +69,7 @@ void rt_hw_interrupt_init(void)
|
|||
rt_memset(isr_table, 0x00, sizeof(isr_table));
|
||||
|
||||
/* initialize ARM GIC */
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
gic_dist_base = (uint32_t)rt_hw_mmu_map(&mmu_info, 0, (void*)platform_get_gic_dist_base(), 0x2000, MMU_MAP_K_RW);
|
||||
gic_cpu_base = (uint32_t)rt_hw_mmu_map(&mmu_info, 0, (void*)platform_get_gic_cpu_base(), 0x1000, MMU_MAP_K_RW);
|
||||
#else
|
||||
|
@ -99,7 +99,7 @@ void rt_hw_interrupt_init(void)
|
|||
rt_memset(isr_table, 0x00, sizeof(isr_table));
|
||||
|
||||
/* initialize ARM GIC */
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
gic_dist_base = (uint32_t)rt_hw_mmu_map(&mmu_info, 0, (void*)platform_get_gic_dist_base(), 0x2000, MMU_MAP_K_RW);
|
||||
#else
|
||||
gic_dist_base = platform_get_gic_dist_base();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "cp15.h"
|
||||
#include "mmu.h"
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp_mm.h>
|
||||
#include "page.h"
|
||||
#endif
|
||||
|
@ -24,7 +24,7 @@
|
|||
/* level1 page table, each entry for 1MB memory. */
|
||||
volatile unsigned long MMUTable[4*1024] __attribute__((aligned(16*1024)));
|
||||
|
||||
#ifndef RT_USING_LWP
|
||||
#ifndef RT_USING_SMART
|
||||
static rt_mutex_t mm_lock = RT_NULL;
|
||||
|
||||
void rt_mm_lock(void)
|
||||
|
@ -323,7 +323,7 @@ int rt_hw_mmu_ioremap_init(rt_mmu_info *mmu_info, void* v_address, size_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
static size_t find_vaddr(rt_mmu_info *mmu_info, int pages)
|
||||
{
|
||||
size_t l1_off, l2_off;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define SHAREDEVICE (1<<2) /* shared device */
|
||||
#define STRONGORDER (0<<2) /* strong ordered */
|
||||
#define XN (1<<4) /* eXecute Never */
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#define AP_RW (1<<10) /* supervisor=RW, user=No */
|
||||
#define AP_RO ((1<<10) |(1 << 15)) /* supervisor=RW, user=No */
|
||||
#else
|
||||
|
@ -100,7 +100,7 @@ int rt_hw_mmu_map_init(rt_mmu_info *mmu_info, void* v_address, size_t size, size
|
|||
int rt_hw_mmu_ioremap_init(rt_mmu_info *mmu_info, void* v_address, size_t size);
|
||||
void rt_hw_init_mmu_table(struct mem_desc *mdesc, rt_uint32_t size);
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
void *rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr);
|
||||
void *rt_hw_mmu_map_auto(rt_mmu_info *mmu_info, void *v_addr, size_t size, size_t attr);
|
||||
#else
|
||||
|
|
|
@ -56,7 +56,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
|
|||
else
|
||||
*(--stk) = SVCMODE; /* arm mode */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
*(--stk) = 0; /* user lr */
|
||||
*(--stk) = 0; /* user sp*/
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
.equ I_Bit, 0x80 /* when I bit is set, IRQ is disabled */
|
||||
.equ F_Bit, 0x40 /* when F bit is set, FIQ is disabled */
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
.data
|
||||
.align 14
|
||||
init_mtbl:
|
||||
|
@ -101,7 +101,7 @@ continue:
|
|||
dsb
|
||||
isb
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
ldr r5, =PV_OFFSET
|
||||
|
||||
mov r7, #0x100000
|
||||
|
@ -179,7 +179,7 @@ bss_loop:
|
|||
ldr r1, [r1]
|
||||
bl rt_hw_init_mmu_table
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
ldr r0, =MMUTable /* vaddr */
|
||||
add r0, r5 /* to paddr */
|
||||
bl rt_hw_mmu_switch
|
||||
|
@ -225,7 +225,7 @@ stack_setup:
|
|||
|
||||
bx lr
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
.align 2
|
||||
.global enable_mmu
|
||||
enable_mmu:
|
||||
|
@ -331,7 +331,7 @@ vector_irq:
|
|||
mrs r1, spsr /* original mode */
|
||||
stmfd r0!, {r1}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
stmfd r0, {r13, r14}^ /* usr_sp, usr_lr */
|
||||
sub r0, #8
|
||||
#endif
|
||||
|
@ -379,7 +379,7 @@ vector_irq:
|
|||
cmp r1, #1
|
||||
beq rt_hw_context_switch_interrupt_do
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
ldmfd sp!, {r0-r12,lr}
|
||||
cps #Mode_SVC
|
||||
push {r0-r12}
|
||||
|
@ -430,7 +430,7 @@ rt_hw_context_switch_interrupt_do:
|
|||
stmfd sp!, {r1-r4} /* push old task's r0-r3 */
|
||||
stmfd sp!, {r0} /* push old task's cpsr */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
stmfd sp, {r13, r14}^ /*push usr_sp, usr_lr */
|
||||
sub sp, #8
|
||||
#endif
|
||||
|
@ -457,7 +457,7 @@ rt_hw_context_switch_interrupt_do:
|
|||
ldr sp, [r6] /* get new task's stack pointer */
|
||||
|
||||
bl rt_thread_self
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mov r4, r0
|
||||
bl lwp_mmu_switch
|
||||
mov r0, r4
|
||||
|
@ -477,7 +477,7 @@ rt_hw_context_switch_interrupt_do:
|
|||
1:
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
ldmfd sp, {r13, r14}^ /*pop usr_sp, usr_lr */
|
||||
add sp, #8
|
||||
#endif
|
||||
|
@ -485,7 +485,7 @@ rt_hw_context_switch_interrupt_do:
|
|||
ldmfd sp!, {r4} /* pop new task's cpsr to spsr */
|
||||
msr spsr_cxsf, r4
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
and r4, #0x1f
|
||||
cmp r4, #0x10
|
||||
bne 1f
|
||||
|
@ -543,7 +543,7 @@ vector_undef:
|
|||
.globl vector_pabt
|
||||
vector_pabt:
|
||||
push_svc_reg
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
/* cp Mode_ABT stack to SVC */
|
||||
sub sp, sp, #17 * 4 /* Sizeof(struct rt_hw_exp_stack) */
|
||||
mov lr, r0
|
||||
|
@ -571,7 +571,7 @@ vector_pabt:
|
|||
.globl vector_dabt
|
||||
vector_dabt:
|
||||
push_svc_reg
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
/* cp Mode_ABT stack to SVC */
|
||||
sub sp, sp, #17 * 4 /* Sizeof(struct rt_hw_exp_stack) */
|
||||
mov lr, r0
|
||||
|
@ -610,7 +610,7 @@ rt_hw_clz:
|
|||
|
||||
.global rt_secondary_cpu_entry
|
||||
rt_secondary_cpu_entry:
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
ldr r5, =PV_OFFSET
|
||||
|
||||
ldr lr, =after_enable_mmu_n
|
||||
|
@ -641,7 +641,7 @@ after_enable_mmu_n:
|
|||
bl stack_setup
|
||||
|
||||
/* initialize the mmu table and enable mmu */
|
||||
#ifndef RT_USING_USERSPACE
|
||||
#ifndef RT_USING_SMART
|
||||
bl rt_hw_mmu_init
|
||||
#endif
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
extern long list_thread(void);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#include <lwp_arch.h>
|
||||
|
||||
|
@ -70,7 +70,7 @@ void rt_hw_show_register(struct rt_hw_exp_stack *regs)
|
|||
rt_kprintf("fp :0x%08x ip :0x%08x\n", regs->fp, regs->ip);
|
||||
rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc);
|
||||
rt_kprintf("cpsr:0x%08x\n", regs->cpsr);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
{
|
||||
uint32_t v;
|
||||
asm volatile ("MRC p15, 0, %0, c5, c0, 0":"=r"(v));
|
||||
|
@ -128,7 +128,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
check_user_fault(regs, 4, "User undefined instruction");
|
||||
#endif
|
||||
rt_unwind(regs, 4);
|
||||
|
@ -169,7 +169,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs)
|
|||
*/
|
||||
void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs)
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
if (dbg_check_event(regs, 4))
|
||||
{
|
||||
return;
|
||||
|
@ -195,7 +195,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs)
|
|||
*/
|
||||
void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs)
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
if (dbg_check_event(regs, 8))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
.globl system_vectors
|
||||
system_vectors:
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
b _reset
|
||||
#else
|
||||
ldr pc, _vector_reset
|
||||
|
|
|
@ -319,7 +319,7 @@ static size_t find_vaddr(rt_mmu_info *mmu_info, int pages)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
static int check_vaddr(rt_mmu_info *mmu_info, void *va, int pages)
|
||||
{
|
||||
size_t loop_va = (size_t)va & ~ARCH_PAGE_MASK;
|
||||
|
@ -398,7 +398,7 @@ static void __rt_hw_mmu_unmap(rt_mmu_info *mmu_info, void* v_addr, size_t npages
|
|||
(*ref_cnt)--;
|
||||
if (!*ref_cnt)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_pages_free(mmu_l2, 0);
|
||||
#else
|
||||
rt_free_align(mmu_l2);
|
||||
|
@ -438,7 +438,7 @@ static int __rt_hw_mmu_map(rt_mmu_info *mmu_info, void* v_addr, void* p_addr, si
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mmu_l2 = (size_t*)rt_pages_alloc(0);
|
||||
#else
|
||||
mmu_l2 = (size_t*)rt_malloc_align(ARCH_PAGE_TBL_SIZE * 2, ARCH_PAGE_TBL_SIZE);
|
||||
|
@ -480,7 +480,7 @@ static void rt_hw_cpu_tlb_invalidate(void)
|
|||
mmu_clear_itlb();
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
void *_rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr)
|
||||
{
|
||||
size_t pa_s, pa_e;
|
||||
|
@ -551,7 +551,7 @@ void *_rt_hw_mmu_map(rt_mmu_info *mmu_info, void* p_addr, size_t size, size_t at
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
static int __rt_hw_mmu_map_auto(rt_mmu_info *mmu_info, void* v_addr, size_t npages, size_t attr)
|
||||
{
|
||||
size_t loop_va = (size_t)v_addr & ~ARCH_PAGE_MASK;
|
||||
|
@ -695,7 +695,7 @@ void *rt_hw_kernel_phys_to_virt(void *p_addr, size_t size)
|
|||
{
|
||||
void *v_addr = 0;
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
extern rt_mmu_info mmu_info;
|
||||
v_addr = rt_hw_mmu_map(&mmu_info, 0, p_addr, size, MMU_MAP_K_RW);
|
||||
#else
|
||||
|
@ -705,7 +705,7 @@ void *rt_hw_kernel_phys_to_virt(void *p_addr, size_t size)
|
|||
return v_addr;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
void *rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr)
|
||||
{
|
||||
void *ret;
|
||||
|
@ -802,7 +802,7 @@ void *rt_hw_mmu_v2p(rt_mmu_info *mmu_info, void* v_addr)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
void init_mm_setup(unsigned int *mtbl, unsigned int size, unsigned int pv_off)
|
||||
{
|
||||
unsigned int va;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define SHAREDEVICE (1<<2) /* shared device */
|
||||
#define STRONGORDER (0<<2) /* strong ordered */
|
||||
#define XN (1<<4) /* execute Never */
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#define AP_RW (1<<10) /* supervisor=RW, user=No */
|
||||
#define AP_RO ((1<<10) |(1 << 15)) /* supervisor=RW, user=No */
|
||||
#else
|
||||
|
@ -98,7 +98,7 @@ void *mmu_table_get();
|
|||
void switch_mmu(void *mmu_table);
|
||||
|
||||
int rt_hw_mmu_map_init(rt_mmu_info *mmu_info, void* v_address, size_t size, size_t *vtable, size_t pv_off);
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
void *rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr);
|
||||
void *rt_hw_mmu_map_auto(rt_mmu_info *mmu_info, void *v_addr, size_t size, size_t attr);
|
||||
#else
|
||||
|
|
|
@ -128,7 +128,7 @@ void rt_hw_sync_cache_local(void *addr, int size)
|
|||
rt_hw_cpu_icache_invalidate_local(addr, size);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp_arch.h>
|
||||
#define ICACHE (1 << 0)
|
||||
#define DCACHE (1 << 1)
|
||||
|
|
|
@ -21,7 +21,7 @@ rt_hw_context_switch_to:
|
|||
la s0, rt_current_thread
|
||||
LOAD s1, (s0)
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mv a0, s1
|
||||
jal lwp_mmu_switch
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ rt_hw_context_switch:
|
|||
la s0, rt_current_thread
|
||||
LOAD s1, (s0)
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mv a0, s1
|
||||
jal lwp_mmu_switch
|
||||
#endif
|
||||
|
|
|
@ -93,7 +93,7 @@ copy_context_loop_interrupt:
|
|||
LOAD s1, 0(s0)
|
||||
LOAD sp, 0(s1)
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mv a0, s1
|
||||
jal rt_thread_sp_to_thread
|
||||
jal lwp_mmu_switch
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "rt_interrupt.h"
|
||||
#include "plic.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include "riscv_mmu.h"
|
||||
#include "mmu.h"
|
||||
#include "page.h"
|
||||
|
@ -112,7 +112,7 @@ void dump_regs(struct rt_hw_stack_frame *regs)
|
|||
rt_size_t satp_v = read_csr(satp);
|
||||
rt_kprintf("satp = 0x%p\n",satp_v);
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
rt_kprintf("\tCurrent Page Table(Physical) = 0x%p\n",__MASKVALUE(satp_v,__MASK(44)) << PAGE_OFFSET_BIT);
|
||||
rt_kprintf("\tCurrent ASID = 0x%p\n",__MASKVALUE(satp_v >> 44,__MASK(16)) << PAGE_OFFSET_BIT);
|
||||
#endif
|
||||
|
@ -238,7 +238,7 @@ void handle_trap(rt_size_t scause,rt_size_t stval,rt_size_t sepc,struct rt_hw_st
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
/* page fault */
|
||||
if (id == EP_LOAD_PAGE_FAULT ||
|
||||
id == EP_STORE_PAGE_FAULT)
|
||||
|
|
|
@ -78,7 +78,7 @@ rt_hw_context_switch_to:
|
|||
la s0, rt_current_thread
|
||||
LOAD s1, (s0)
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mv a0, s1
|
||||
jal lwp_mmu_switch
|
||||
#endif
|
||||
|
@ -106,7 +106,7 @@ rt_hw_context_switch:
|
|||
la s0, rt_current_thread
|
||||
LOAD s1, (s0)
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
mv a0, s1
|
||||
jal lwp_mmu_switch
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,15 @@ config RT_USING_SMART
|
|||
bool "Enable RT-Thread Smart (microkernel on kernel/userland)"
|
||||
default n
|
||||
select RT_USING_LWP
|
||||
select RT_USING_DFS
|
||||
select RT_USING_LIBC
|
||||
select RT_USING_POSIX_CLOCKTIME
|
||||
select RT_USING_TTY
|
||||
select RT_USING_NULL
|
||||
select RT_USING_ZERO
|
||||
select RT_USING_RANDOM
|
||||
select RT_USING_RTC
|
||||
depends on ARCH_ARM_CORTEX_M || ARCH_ARM_ARM9 || ARCH_ARM_CORTEX_A || ARCH_RISCV64
|
||||
help
|
||||
RT-Thread Smart is a microkernel based operating system on RT-Thread.
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
|
||||
|
@ -246,7 +246,7 @@ void rt_cpus_lock_status_restore(struct rt_thread *thread)
|
|||
{
|
||||
struct rt_cpu* pcpu = rt_cpu_self();
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#if defined(ARCH_MM_MMU) && defined(RT_USING_SMART)
|
||||
lwp_mmu_switch(thread);
|
||||
#endif
|
||||
pcpu->current_thread = thread;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <dlmodule.h>
|
||||
#endif /* RT_USING_MODULE */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#include <lwp_user_mm.h>
|
||||
#include <console.h>
|
||||
|
@ -420,7 +420,7 @@ char *rt_strstr(const char *s1, const char *s2)
|
|||
l2 = rt_strlen(s2);
|
||||
if (!l2)
|
||||
{
|
||||
return (char *)s1;
|
||||
return (char *)s1;
|
||||
}
|
||||
|
||||
l1 = rt_strlen(s1);
|
||||
|
@ -429,7 +429,7 @@ char *rt_strstr(const char *s1, const char *s2)
|
|||
l1 --;
|
||||
if (!rt_memcmp(s1, s2, l2))
|
||||
{
|
||||
return (char *)s1;
|
||||
return (char *)s1;
|
||||
}
|
||||
|
||||
s1 ++;
|
||||
|
@ -495,7 +495,7 @@ char *rt_strncpy(char *dst, const char *src, rt_size_t n)
|
|||
/* NUL pad the remaining n-1 bytes */
|
||||
while (--n != 0)
|
||||
{
|
||||
*d++ = 0;
|
||||
*d++ = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -554,7 +554,7 @@ rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_size_t count)
|
|||
{
|
||||
if ((__res = *cs - *ct++) != 0 || !*cs++)
|
||||
{
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
count --;
|
||||
|
@ -648,7 +648,7 @@ char *rt_strdup(const char *s)
|
|||
|
||||
if (!tmp)
|
||||
{
|
||||
return RT_NULL;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
rt_memcpy(tmp, s, len);
|
||||
|
@ -1256,7 +1256,7 @@ RTM_EXPORT(rt_console_get_device);
|
|||
*/
|
||||
rt_device_t rt_console_set_device(const char *name)
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
rt_device_t new_iodev = RT_NULL, old_iodev = RT_NULL;
|
||||
extern void console_init();
|
||||
console_init(); /*add line discipline*/
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <dlmodule.h>
|
||||
#endif /* RT_USING_MODULE */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
|
||||
|
@ -71,7 +71,7 @@ enum rt_object_info_type
|
|||
#ifdef RT_USING_HEAP
|
||||
RT_Object_Info_Memory, /**< The object is a memory. */
|
||||
#endif
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
RT_Object_Info_Channel, /**< The object is a IPC channel */
|
||||
#endif
|
||||
#ifdef RT_USING_HEAP
|
||||
|
@ -129,7 +129,7 @@ static struct rt_object_information _object_container[RT_Object_Info_Unknown] =
|
|||
/* initialize object container - small memory */
|
||||
{RT_Object_Class_Memory, _OBJ_CONTAINER_LIST_INIT(RT_Object_Info_Memory), sizeof(struct rt_memory)},
|
||||
#endif
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
/* initialize object container - module */
|
||||
{RT_Object_Class_Channel, _OBJ_CONTAINER_LIST_INIT(RT_Object_Info_Channel), sizeof(struct rt_channel)},
|
||||
{RT_Object_Class_Custom, _OBJ_CONTAINER_LIST_INIT(RT_Object_Info_Custom), sizeof(struct rt_custom_object)},
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#include <lwp.h>
|
||||
#endif /* RT_USING_LWP */
|
||||
#endif /* RT_USING_SMART */
|
||||
|
||||
rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
|
||||
rt_uint32_t rt_thread_ready_priority_group;
|
||||
|
@ -98,7 +98,7 @@ static void _scheduler_stack_check(struct rt_thread *thread)
|
|||
{
|
||||
RT_ASSERT(thread != RT_NULL);
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
#ifndef ARCH_MM_MMU
|
||||
struct rt_lwp *lwp = thread ? (struct rt_lwp *)thread->lwp : 0;
|
||||
|
||||
|
@ -109,7 +109,7 @@ static void _scheduler_stack_check(struct rt_thread *thread)
|
|||
return;
|
||||
}
|
||||
#endif /* not defined ARCH_MM_MMU */
|
||||
#endif /* RT_USING_LWP */
|
||||
#endif /* RT_USING_SMART */
|
||||
|
||||
#ifdef ARCH_CPU_STACK_GROWS_UPWARD
|
||||
if (*((rt_uint8_t *)((rt_ubase_t)thread->stack_addr + thread->stack_size - 1)) != '#' ||
|
||||
|
@ -345,7 +345,7 @@ void rt_schedule(void)
|
|||
|
||||
if ((current_thread->stat & RT_THREAD_STAT_SIGNAL_MASK) & RT_THREAD_STAT_SIGNAL_PENDING)
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
rt_thread_wakeup(current_thread);
|
||||
#else
|
||||
rt_thread_resume(current_thread);
|
||||
|
@ -600,7 +600,7 @@ void rt_scheduler_do_irq_switch(void *context)
|
|||
|
||||
if ((current_thread->stat & RT_THREAD_STAT_SIGNAL_MASK) & RT_THREAD_STAT_SIGNAL_PENDING)
|
||||
{
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
rt_thread_wakeup(current_thread);
|
||||
#else
|
||||
rt_thread_resume(current_thread);
|
||||
|
|
|
@ -105,7 +105,7 @@ static void _signal_deliver(rt_thread_t tid)
|
|||
if ((tid->stat & RT_THREAD_SUSPEND_MASK) == RT_THREAD_SUSPEND_MASK)
|
||||
{
|
||||
/* resume thread to handle signal */
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
rt_thread_wakeup(tid);
|
||||
#else
|
||||
rt_thread_resume(tid);
|
||||
|
|
14
src/thread.c
14
src/thread.c
|
@ -167,7 +167,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
|
|||
/* init thread list */
|
||||
rt_list_init(&(thread->tlist));
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
thread->wakeup.func = RT_NULL;
|
||||
#endif
|
||||
|
||||
|
@ -255,7 +255,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
|
|||
thread->si_list = RT_NULL;
|
||||
#endif /* RT_USING_SIGNALS */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
thread->lwp = RT_NULL;
|
||||
rt_list_init(&(thread->sibling));
|
||||
rt_memset(&thread->signal, 0, sizeof(lwp_sigset_t));
|
||||
|
@ -642,7 +642,7 @@ rt_err_t rt_thread_sleep(rt_tick_t tick)
|
|||
rt_hw_interrupt_enable(level);
|
||||
|
||||
thread->error = -RT_EINTR;
|
||||
|
||||
|
||||
rt_schedule();
|
||||
|
||||
/* clear error number of this thread to RT_EOK */
|
||||
|
@ -930,7 +930,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
|
|||
}
|
||||
RTM_EXPORT(rt_thread_control);
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
int lwp_suspend_sigcheck(rt_thread_t thread, int suspend_flag);
|
||||
#endif
|
||||
|
||||
|
@ -998,7 +998,7 @@ rt_err_t rt_thread_suspend_with_flag(rt_thread_t thread, int suspend_flag)
|
|||
/* not suspend running status thread on other core */
|
||||
RT_ASSERT(thread == rt_thread_self());
|
||||
}
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
if (lwp_suspend_sigcheck(thread, suspend_flag) == 0)
|
||||
{
|
||||
/* not to suspend */
|
||||
|
@ -1063,7 +1063,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
|
|||
|
||||
rt_timer_stop(&thread->thread_timer);
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
thread->wakeup.func = RT_NULL;
|
||||
#endif
|
||||
|
||||
|
@ -1078,7 +1078,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
|
|||
}
|
||||
RTM_EXPORT(rt_thread_resume);
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
#ifdef RT_USING_SMART
|
||||
/**
|
||||
* This function will wakeup a thread with customized operation.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue