Merge branch 'smp' of https://gitlink.org.cn/tuyuyang/xiuos into lwip
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
SRC_DIR := fs shell lib boards drivers semaphore tools net app
|
||||
SRC_DIR := fs shell lib boards drivers semaphore drivers tools net app
|
||||
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
@@ -10,6 +10,12 @@ cflags = -std=c11 -O2 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -
|
||||
board_specs = stub.o
|
||||
#cflags = -Wall -g -std=c11
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
board_specs = stub.o
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
@@ -37,9 +43,9 @@ INC_DIR = -I$(KERNEL_ROOT)/services/shell/letter-shell \
|
||||
-I$(KERNEL_ROOT)/services/app
|
||||
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
all: init test_fs simple_client simple_server shell fs_server semaphore_server test_thread test_irq_hdlr test_irq_block test_irq_send eth_driver epit_server test_net lwip readme.txt | bin
|
||||
all: init test_fault simple_client simple_server shell fs_server semaphore_server test_semaphore test_ipc_null test_thread test_irq_hdlr test_irq_block test_irq_send eth_driver epit_server readme.txt | bin
|
||||
else
|
||||
all: init test_fs simple_client simple_server shell fs_server test_irq_hdlr readme.txt | bin
|
||||
all: init test_fault simple_client simple_server shell fs_server test_ipc_null test_thread test_semaphore readme.txt | bin
|
||||
endif
|
||||
../tools/mkfs/mkfs ./fs.img $^
|
||||
@mv $(filter-out readme.txt, $^) bin
|
||||
@@ -63,6 +69,14 @@ epit_server: timer.o epit.o ccm_pll.o usyscall.o arch_usyscall.o libserial.o pri
|
||||
@${objdump} -S $@ > $@.asm
|
||||
endif
|
||||
|
||||
test_semaphore: test_semaphore.o libserial.o printf.o usyscall.o arch_usyscall.o
|
||||
@${ld} ${user_ldflags} -e main -o $@ $^ ${board_specs}
|
||||
@${objdump} -S $@ > $@.asm
|
||||
|
||||
test_ipc_null: test_ipc_null.o libserial.o printf.o usyscall.o arch_usyscall.o libipc.o session.o
|
||||
@${ld} ${user_ldflags} -e main -o $@ $^ ${board_specs}
|
||||
@${objdump} -S $@ > $@.asm
|
||||
|
||||
semaphore_server: semaphore_server.o libserial.o printf.o usyscall.o arch_usyscall.o libipc.o session.o
|
||||
@${ld} ${user_ldflags} -e main -o $@ $^ ${board_specs}
|
||||
@${objdump} -S $@ > $@.asm
|
||||
@@ -87,7 +101,7 @@ init: init.o libfs.o libipc.o session.o libserial.o printf.o usyscall.o arch_usy
|
||||
@${ld} ${user_ldflags} -e main -o $@ $^ ${board_specs}
|
||||
@${objdump} -S $@ > $@.asm
|
||||
|
||||
test_fs: test_fs.o libfs.o libipc.o session.o libserial.o printf.o usyscall.o arch_usyscall.o libmem.o
|
||||
test_fault: test_fault.o libserial.o printf.o usyscall.o arch_usyscall.o
|
||||
@${ld} ${user_ldflags} -e main -o $@ $^ ${board_specs}
|
||||
@${objdump} -S $@ > $@.asm
|
||||
|
||||
|
||||
@@ -56,10 +56,10 @@ int main(void)
|
||||
printf("session connect faield\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
shellTask(&shell);
|
||||
|
||||
free_session(&session_fs);
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ int main(int argc, char** argv)
|
||||
if (argc >= 2) {
|
||||
id = string_to_integer(argv[1]);
|
||||
}
|
||||
// printf("This is Simple Client %d, size is 0x%x\n", id, task_heap_base());
|
||||
|
||||
struct Session session_wait;
|
||||
struct Session session_nowait;
|
||||
@@ -94,37 +93,39 @@ int main(int argc, char** argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// test no wait ipc
|
||||
char *buf1 = NULL, *buf2 = NULL;
|
||||
struct IpcMsg* msg1 = hello_string_nowait(&session_nowait, &buf1, 32);
|
||||
struct IpcMsg* msg2 = hello_string_nowait(&session_nowait, &buf2, 128);
|
||||
|
||||
int ret = add(&session_wait, 17, 22);
|
||||
// test ipc add(wait version)
|
||||
int ret = 0;
|
||||
ret = add(&session_wait, 17, 22);
|
||||
printf("ipc_add 17 + 22 = %d\n", ret);
|
||||
char buf[32];
|
||||
ret = add(&session_wait, 9, 9);
|
||||
printf("ipc_add 9 + 9 = %d\n", ret);
|
||||
|
||||
struct Session session;
|
||||
struct Session fs_session;
|
||||
static char id_buf[33] = { 0 };
|
||||
if (id > 1) {
|
||||
if (connect_session(&session, "MemFS", 8092) < 0) {
|
||||
printf("connect session failed\n");
|
||||
if (connect_session(&fs_session, "MemFS", 8192) < 0) {
|
||||
printf("connect fs_session failed\n");
|
||||
} else {
|
||||
int fd;
|
||||
itoa(id - 1, id_buf, 10);
|
||||
char* shell_task_param[3] = { "/simple_client", id_buf, 0 };
|
||||
if ((fd = open(&session, shell_task_param[0])) >= 0) {
|
||||
if (spawn(&session, fd, read, fsize, shell_task_param[0], shell_task_param) < 0) {
|
||||
if ((fd = open(&fs_session, shell_task_param[0])) >= 0) {
|
||||
if (spawn(&fs_session, fd, read, fsize, shell_task_param[0], shell_task_param) < 0) {
|
||||
printf("Syscall Spawn simple_client failed\n");
|
||||
}
|
||||
if (spawn(&session, fd, read, fsize, shell_task_param[0], shell_task_param) < 0) {
|
||||
if (spawn(&fs_session, fd, read, fsize, shell_task_param[0], shell_task_param) < 0) {
|
||||
printf("Syscall Spawn simple_client failed\n");
|
||||
}
|
||||
close(&session, fd);
|
||||
close(&fs_session, fd);
|
||||
} else {
|
||||
printf("Open %s failed\n", shell_task_param[0]);
|
||||
}
|
||||
free_session(&session);
|
||||
free_session(&fs_session);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,4 +44,5 @@ int main(int argc, char* argv[])
|
||||
|
||||
// never reached
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+4
-20
@@ -10,34 +10,18 @@
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
// test_priority: Test the priority scheduler of task
|
||||
// test_fs: Test the file io control of fs
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libserial.h"
|
||||
#include "usyscall.h"
|
||||
|
||||
static void count_down()
|
||||
{
|
||||
int time = 500000000;
|
||||
while (time >= 0) {
|
||||
if (time % 10000000 == 0) {
|
||||
printf("Priority-based preempting, time remained %d\n", time);
|
||||
}
|
||||
time--;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// set priority
|
||||
sys_state_info info;
|
||||
info.priority = 0;
|
||||
set_priority(&info);
|
||||
|
||||
// test function
|
||||
count_down();
|
||||
printf("Test memry error %s.\n", 0x50000000);
|
||||
printf("After error computing.\n");
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
// test_fs: Test the file io control of fs
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libfs.h"
|
||||
#include "libserial.h"
|
||||
#include "usyscall.h"
|
||||
|
||||
#define BLOCK_SIZE 256
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
printf("file system test\n");
|
||||
|
||||
struct Session session;
|
||||
connect_session(&session, "MemFS", 4096);
|
||||
|
||||
int fd;
|
||||
char* fd_path = "/readme.txt";
|
||||
fd = open(&session, fd_path);
|
||||
/// @todo support malloc for user
|
||||
char buffer[BLOCK_SIZE] = { 0 };
|
||||
read(&session, fd, buffer, 0, BLOCK_SIZE);
|
||||
printf("file content: %s\n", buffer);
|
||||
|
||||
char* write_data = "hello world\n";
|
||||
write(&session, fd, write_data, 0, strlen(write_data) + 1);
|
||||
memset(buffer, 0, BLOCK_SIZE);
|
||||
read(&session, fd, buffer, 0, BLOCK_SIZE);
|
||||
printf("file content: %s\n", buffer);
|
||||
|
||||
close(&session, fd);
|
||||
free_session(&session);
|
||||
|
||||
printf("file test done.\n");
|
||||
printf("Test memry error %s.\n", 0x50000000);
|
||||
printf("After error computing.\n");
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libipc.h"
|
||||
#include "libserial.h"
|
||||
#include "usyscall.h"
|
||||
|
||||
IPC_SERVICES(IpcTestNull, Ipc_test_null);
|
||||
#define TEST_BUF_SIZE 32
|
||||
|
||||
static char test_null_server_name[] = "TestNullServer";
|
||||
static char test_null_client_name[] = "TestNullClient";
|
||||
|
||||
// client side
|
||||
static char buf[TEST_BUF_SIZE];
|
||||
|
||||
IPC_INTERFACE(Ipc_test_null, 1, ptr, sizeof(buf));
|
||||
int test_null(struct Session* session, char* ptr)
|
||||
{
|
||||
return IPC_CALL(Ipc_test_null)(session, ptr);
|
||||
}
|
||||
|
||||
// client thread
|
||||
int server_thread(int argc, char** argv);
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct Session session;
|
||||
bool server_enabled = false;
|
||||
while (connect_session(&session, test_null_server_name, 4096) < 0) {
|
||||
if (!server_enabled) {
|
||||
char* server_param[] = { test_null_server_name, NULL };
|
||||
if (thread(server_thread, test_null_server_name, server_param) >= 0) {
|
||||
server_enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("[%s] Call using NULL ptr.\n", test_null_client_name);
|
||||
test_null(&session, NULL);
|
||||
printf("[%s] Call using non-NULL ptr.\n", test_null_client_name);
|
||||
test_null(&session, buf);
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// server side
|
||||
int IPC_DO_SERVE_FUNC(Ipc_test_null)(void* ptr)
|
||||
{
|
||||
if (ptr == NULL) {
|
||||
printf("[%s]: A NULL ptr ipc call.\n", test_null_server_name);
|
||||
} else {
|
||||
printf("[%s]: A non-NULL ptr ipc call.\n", test_null_server_name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
IPC_SERVER_INTERFACE(Ipc_test_null, 1);
|
||||
IPC_SERVER_REGISTER_INTERFACES(IpcTestNull, 1, Ipc_test_null);
|
||||
|
||||
// server threads
|
||||
int server_thread(int argc, char** argv)
|
||||
{
|
||||
if (register_server(test_null_server_name) < 0) {
|
||||
printf("[%s] Register %s server failed.\n", test_null_server_name, test_null_server_name);
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
ipc_server_loop(&IpcTestNull);
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
@@ -52,4 +52,5 @@ int main()
|
||||
ipc_server_loop(&IpcSwIntrHandler);
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libserial.h"
|
||||
#include "usyscall.h"
|
||||
|
||||
enum {
|
||||
NR_THREADS = 16,
|
||||
LOOP_TIMES = 0x1000000,
|
||||
};
|
||||
|
||||
static int sem_id = -1;
|
||||
static uint32_t sum = 0;
|
||||
static int nr_thds = NR_THREADS;
|
||||
|
||||
int do_calculation(int argc, char** argv)
|
||||
{
|
||||
for (uint32_t i = 0; i < LOOP_TIMES; i++) {
|
||||
sum++;
|
||||
}
|
||||
|
||||
printf("test semaphore thd signal.\n");
|
||||
semaphore_signal(sem_id);
|
||||
|
||||
char* params[] = { "do_cal", NULL };
|
||||
if (nr_thds != 0) {
|
||||
int tid = thread(do_calculation, "test_sem_thd", params);
|
||||
nr_thds--;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
printf("Test Semaphore.\n");
|
||||
sem_id = semaphore_new(0);
|
||||
if (sem_id < 0) {
|
||||
printf("new a kernel sem failed.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sum = 0;
|
||||
|
||||
nr_thds = NR_THREADS;
|
||||
char* params[] = { "do_cal", NULL };
|
||||
if (nr_thds != 0) {
|
||||
int tid = thread(do_calculation, "test_sem_thd", params);
|
||||
nr_thds--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < NR_THREADS; i++) {
|
||||
semaphore_wait(sem_id);
|
||||
}
|
||||
|
||||
printf("test thread sum after %d signal: 0x%x\n", NR_THREADS, sum);
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
@@ -25,6 +25,8 @@ int sub_thread_entry(int argc, char** argv)
|
||||
global_value++;
|
||||
}
|
||||
|
||||
/// @warning session is single threaded, so that each thread cannot share a common session.
|
||||
// sub thread connect to semaphore server
|
||||
struct Session sem_session;
|
||||
while (connect_session(&sem_session, sem_server_name, 4096) < 0) {
|
||||
yield(SYS_TASK_YIELD_NO_REASON);
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -march=armv7-a -std=c11 -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -march=armv7-a -std=c11 -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
user_ldflags = -N -Ttext 0
|
||||
|
||||
cflags = -march=armv7-a -std=c11 -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/fs/libfs \
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -march=armv7-a -std=c11 -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -march=armv7-a -std=c11 -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/fs/libfs \
|
||||
-I$(KERNEL_ROOT)/services/lib/ipc \
|
||||
-I$(KERNEL_ROOT)/services/lib/memory \
|
||||
-I$(KERNEL_ROOT)/services/lib/serial \
|
||||
-I$(KERNEL_ROOT)/services/lib/usyscall \
|
||||
-I$(KERNEL_ROOT)/services/boards/$(BOARD) \
|
||||
-I$(KERNEL_ROOT)/services/app
|
||||
|
||||
board: libserial.o arch_usyscall.o stub.o
|
||||
@mv $^ $(KERNEL_ROOT)/services/app
|
||||
|
||||
%.o: %.c
|
||||
@echo "cc $^"
|
||||
@${cc} ${cflags} ${c_useropts} ${INC_DIR} -o $@ -c $^
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "usyscall.h"
|
||||
|
||||
int syscall(int sys_num, intptr_t a1, intptr_t a2, intptr_t a3, intptr_t a4)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
__asm__ volatile(
|
||||
"mov x0, %1;\
|
||||
mov x1, %2;\
|
||||
mov x2, %3;\
|
||||
mov x3, %4;\
|
||||
mov x4, %5;\
|
||||
svc #0;\
|
||||
dsb ish;\
|
||||
isb;\
|
||||
mov %0, x0"
|
||||
: "=r"(ret)
|
||||
: "r"(sys_num), "r"(a1), "r"(a2), "r"(a3), "r"(a4)
|
||||
: "memory", "r0", "r1", "r2", "r3", "r4");
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/// this file is only used for debug
|
||||
#include "libserial.h"
|
||||
#include "usyscall.h"
|
||||
|
||||
#define USER_UART_BASE 0x6FFFF000
|
||||
|
||||
#define UART0_BASE (0x09000000ULL)
|
||||
#define UART0_REG(reg) ((volatile uint32_t*)(USER_UART_BASE + reg))
|
||||
|
||||
// the UART control registers.
|
||||
// pl011
|
||||
#define DR 0x00
|
||||
#define FR 0x18
|
||||
#define FR_RXFE (1 << 4) // recieve fifo empty
|
||||
#define FR_TXFF (1 << 5) // transmit fifo full
|
||||
#define FR_RXFF (1 << 6) // recieve fifo full
|
||||
#define FR_TXFE (1 << 7) // transmit fifo empty
|
||||
#define IBRD 0x24
|
||||
#define FBRD 0x28
|
||||
#define LCRH 0x2c
|
||||
#define LCRH_FEN (1 << 4)
|
||||
#define LCRH_WLEN_8BIT (3 << 5)
|
||||
#define CR 0x30
|
||||
#define IMSC 0x38
|
||||
#define INT_RX_ENABLE (1 << 4)
|
||||
#define INT_TX_ENABLE (1 << 5)
|
||||
#define ICR 0x44
|
||||
|
||||
#define UART_READ_REG(reg) (*(UART0_REG(reg)))
|
||||
#define UART_WRITE_REG(reg, v) (*(UART0_REG(reg)) = (v))
|
||||
|
||||
#define UART_TX_BUF_SIZE 32
|
||||
static char uart_tx_buf[UART_TX_BUF_SIZE];
|
||||
uint64_t uart_tx_w; // write next to uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE]
|
||||
uint64_t uart_tx_r; // read next from uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE]
|
||||
|
||||
bool init_uart_mmio()
|
||||
{
|
||||
static int mapped = 0;
|
||||
if (mapped == 0) {
|
||||
if (-1 == mmap(USER_UART_BASE, UART0_BASE, 4096, true)) {
|
||||
return false;
|
||||
}
|
||||
mapped = 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// if the UART is idle, and a character is waiting
|
||||
// in the transmit buffer, send it.
|
||||
// caller must hold uart_tx_lock.
|
||||
// called from both the top- and bottom-half.
|
||||
void uartstart()
|
||||
{
|
||||
while (1) {
|
||||
if (uart_tx_w == uart_tx_r) {
|
||||
// transmit buffer is empty.
|
||||
return;
|
||||
}
|
||||
|
||||
if (UART_READ_REG(FR) & FR_TXFF) {
|
||||
// the UART transmit holding register is full,
|
||||
// so we cannot give it another byte.
|
||||
// it will interrupt when it's ready for a new byte.
|
||||
return;
|
||||
}
|
||||
|
||||
int c = uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE];
|
||||
uart_tx_r += 1;
|
||||
|
||||
// maybe uartputc() is waiting for space in the buffer.
|
||||
|
||||
UART_WRITE_REG(DR, c);
|
||||
}
|
||||
}
|
||||
|
||||
// add a character to the output buffer and tell the
|
||||
// UART to start sending if it isn't already.
|
||||
// blocks if the output buffer is full.
|
||||
// because it may block, it can't be called
|
||||
// from interrupts; it's only suitable for use
|
||||
// by write().
|
||||
void putc(char c)
|
||||
{
|
||||
while (uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE)
|
||||
;
|
||||
uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
|
||||
uart_tx_w += 1;
|
||||
uartstart();
|
||||
return;
|
||||
}
|
||||
|
||||
// read one input character from the UART.
|
||||
// return -1 if none is waiting.
|
||||
char getc(void)
|
||||
{
|
||||
if (UART_READ_REG(FR) & FR_RXFE)
|
||||
return 0xFF;
|
||||
else
|
||||
return UART_READ_REG(DR);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// _exit: 用于退出程序
|
||||
void _exit(int status)
|
||||
{
|
||||
while (1) { }
|
||||
}
|
||||
|
||||
// _sbrk: 用于增加程序的数据空间
|
||||
void* _sbrk(ptrdiff_t incr)
|
||||
{
|
||||
extern char end; /* Defined by the linker */
|
||||
static char* heap_end;
|
||||
char* prev_heap_end;
|
||||
|
||||
if (heap_end == 0) {
|
||||
heap_end = &end;
|
||||
}
|
||||
prev_heap_end = heap_end;
|
||||
|
||||
// 在这里,你应该添加一些检查来确保堆不会与栈或其他内存区域冲突
|
||||
// 例如,检查 incr 是否会导致堆超出预定的内存区域
|
||||
|
||||
heap_end += incr;
|
||||
return (void*)prev_heap_end;
|
||||
}
|
||||
|
||||
// _write: 用于将数据写入文件描述符
|
||||
ssize_t _write(int file, const void* ptr, size_t len)
|
||||
{
|
||||
// 在这里,你需要实现将数据写入文件描述符的逻辑
|
||||
// 如果你的系统不支持文件系统,你可以将数据发送到串口或其他输出
|
||||
|
||||
return len; // 假设所有数据都被写入
|
||||
}
|
||||
|
||||
// _close: 用于关闭文件描述符
|
||||
int _close(int file)
|
||||
{
|
||||
return -1; // 表示失败,因为没有实际关闭文件的功能
|
||||
}
|
||||
|
||||
// _fstat: 用于获取文件状态
|
||||
int _fstat(int file, struct stat* st)
|
||||
{
|
||||
return 0; // 表示成功
|
||||
}
|
||||
|
||||
// _isatty: 检查文件描述符是否指向TTY设备
|
||||
int _isatty(int file)
|
||||
{
|
||||
return 1; // 表示是TTY设备
|
||||
}
|
||||
|
||||
// _lseek: 用于重新定位文件读/写的位置
|
||||
off_t _lseek(int file, off_t offset, int whence)
|
||||
{
|
||||
return -1; // 表示失败,因为不支持文件定位
|
||||
}
|
||||
|
||||
// _read: 用于从文件描述符读取数据
|
||||
ssize_t _read(int file, void* ptr, size_t len)
|
||||
{
|
||||
return 0; // 表示没有数据被读取
|
||||
}
|
||||
|
||||
// _kill: 发送信号给进程
|
||||
int _kill(int pid, int sig)
|
||||
{
|
||||
return -1; // 表示失败,因为不支持信号
|
||||
}
|
||||
|
||||
// _getpid: 获取进程ID
|
||||
int _getpid()
|
||||
{
|
||||
return 1; // 返回假设的进程ID
|
||||
}
|
||||
@@ -9,6 +9,12 @@ user_ldflags = --start-group,-lgcc,-lc,--end-group
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
#cflags = -Wall -g -std=c11
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
user_ldflags = -N -Ttext 0
|
||||
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/app \
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
user_ldflags = -N -Ttext 0
|
||||
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/app \
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
user_ldflags = -N -Ttext 0
|
||||
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/app \
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
SRC_DIR :=
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -9,6 +9,12 @@ user_ldflags = --start-group,-lgcc,-lc,--end-group
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
#cflags = -Wall -g -std=c11
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
|
||||
@@ -63,7 +63,8 @@ uint32_t BlockAlloc()
|
||||
}
|
||||
}
|
||||
|
||||
Error("BlockAlloc: out of blocks");
|
||||
printf("BlockAlloc: out of blocks, bit idx: %d, total size: %d\n", bit_index, sb.size);
|
||||
Error("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,9 +119,7 @@ struct Inode* InodeCreate(struct Inode* parent_inode, char* name, int type)
|
||||
/// @brief Delete a file Inode or a dir Inode
|
||||
int InodeDelete(struct Inode* parent_inode, char* name)
|
||||
{
|
||||
uint32_t offset;
|
||||
struct Inode* inode;
|
||||
struct DirectEntry de;
|
||||
|
||||
if ((inode = DirInodeLookup(parent_inode, name)) == 0) {
|
||||
printf("Inode delete failed, file not exsit");
|
||||
|
||||
@@ -63,11 +63,12 @@ int IPC_DO_SERVE_FUNC(Ipc_ls)(char* path)
|
||||
}
|
||||
|
||||
if (!(ip = InodeSeek(dp, path))) {
|
||||
printf("ls: find target Inode failed, ip: %x(%d), dp: %x(%d)\n", ip, ip->inum, dp, dp->inum);
|
||||
printf("ls: find target Inode failed, dp: %p(%d), path: %s\n", dp, dp->inum, path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ip->type != FS_DIRECTORY) {
|
||||
printf("ls: not a dir\n");
|
||||
printf("ls: not a dir, ip: %d\n", ip->inum);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -364,4 +365,5 @@ int main(int argc, char* argv[])
|
||||
|
||||
// never reached
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
user_ldflags = --start-group,-lgcc,-lc,--end-group
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
#cflags = -Wall -g -std=c11
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
|
||||
@@ -9,6 +9,12 @@ user_ldflags = --start-group,-lgcc,-lc,--end-group
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
#cflags = -Wall -g -std=c11
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
|
||||
@@ -79,15 +79,26 @@ struct IpcMsg* new_ipc_msg(struct Session* session, const int argc, const int* a
|
||||
bool ipc_msg_set_nth_arg(struct IpcMsg* msg, const int arg_num, const void* const data, const int len)
|
||||
{
|
||||
if (arg_num >= msg->header.nr_args) {
|
||||
printf("[%s] IPC: arg_num out of msg range, arg_num: %d, nr_args: %d\n", __func__, arg_num, msg->header.nr_args);
|
||||
printf("[%s] IPC: arg_num out of msg range, arg_num: %d, nr_args: %u\n", __func__, arg_num, msg->header.nr_args);
|
||||
return false;
|
||||
}
|
||||
struct IpcArgInfo* nth_arg_info = IPCMSG_ARG_INFO(msg, arg_num);
|
||||
if (len > nth_arg_info->len) {
|
||||
printf("[%s] IPC: size of arg out of buffer range, given len: %d, len %d\n", __func__, len, nth_arg_info->len);
|
||||
if (len < 0 || (uint32_t)len > (uint32_t)nth_arg_info->len) {
|
||||
printf("[%s] IPC: size of arg out of buffer range, given len: %d, len %u\n", __func__, len, nth_arg_info->len);
|
||||
return false;
|
||||
}
|
||||
|
||||
void* buf = ipc_msg_get_nth_arg_buf(msg, arg_num);
|
||||
|
||||
// handle attributes of different params
|
||||
if (data == NULL) {
|
||||
nth_arg_info->null_ptr = 1;
|
||||
memset(buf, 0x0, len);
|
||||
return true;
|
||||
} else {
|
||||
nth_arg_info->null_ptr = 0;
|
||||
}
|
||||
|
||||
memmove(buf, data, len);
|
||||
return true;
|
||||
}
|
||||
@@ -109,6 +120,12 @@ bool ipc_msg_get_nth_arg(struct IpcMsg* msg, const int arg_num, void* data, cons
|
||||
printf("[%s] IPC: size of arg out of buffer range", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// handle null ptr: do nothing
|
||||
if (nth_arg_info->null_ptr == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void* buf = ipc_msg_get_nth_arg_buf(msg, arg_num);
|
||||
memmove(data, buf, len);
|
||||
return true;
|
||||
@@ -170,12 +187,6 @@ bool is_cur_handler_been_delayed()
|
||||
return ipc_server_loop_cur_msg->header.delayed == 1;
|
||||
}
|
||||
|
||||
bool server_set_cycle_handler(struct IpcNode* ipc_node, void (*handler)())
|
||||
{
|
||||
ipc_node->cycle_handler = handler;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ipc_server_loop(struct IpcNode* ipc_node)
|
||||
{
|
||||
struct Session session_list[NR_MAX_SESSION];
|
||||
@@ -204,7 +215,6 @@ void ipc_server_loop(struct IpcNode* ipc_node)
|
||||
interfaces[opcode] should explicitly call delay_session() and return to delay this session
|
||||
*/
|
||||
while (ipc_server_loop_cur_msg->header.magic == IPC_MSG_MAGIC && ipc_server_loop_cur_msg->header.valid == 1 && ipc_server_loop_cur_msg->header.done == 0) {
|
||||
// printf("session %d [%d, %d]\n", session_list[i].id, session_list[i].head, session_list[i].tail);
|
||||
if (session_used_size(&session_list[i]) == 0 && session_forward_tail(&session_list[i], ipc_server_loop_cur_msg->header.len) < 0) {
|
||||
break;
|
||||
}
|
||||
@@ -213,13 +223,13 @@ void ipc_server_loop(struct IpcNode* ipc_node)
|
||||
if (ipc_node->interfaces[ipc_server_loop_cur_msg->header.opcode]) {
|
||||
ipc_node->interfaces[ipc_server_loop_cur_msg->header.opcode](ipc_server_loop_cur_msg);
|
||||
// check if this session is delayed by op handler, all messages after the delayed message in current session is blocked.
|
||||
if (is_cur_session_delayed()) {
|
||||
if (ipc_server_loop_cur_msg->header.done == 0) {
|
||||
ipc_server_loop_cur_msg->header.delayed = 1;
|
||||
has_delayed = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
printf("Unsupport opcode(%d) for server: %s\n", ipc_server_loop_cur_msg->header.opcode, ipc_node->name);
|
||||
printf("Unsupport opcode(%u) for server: %s\n", ipc_server_loop_cur_msg->header.opcode, ipc_node->name);
|
||||
}
|
||||
// current msg is a message that needs to ignore
|
||||
// finish this message in server's perspective
|
||||
@@ -233,8 +243,5 @@ void ipc_server_loop(struct IpcNode* ipc_node)
|
||||
ipc_server_loop_cur_msg = NULL;
|
||||
}
|
||||
}
|
||||
if (ipc_node->cycle_handler) {
|
||||
ipc_node->cycle_handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,13 @@ typedef struct {
|
||||
struct IpcArgInfo {
|
||||
uint16_t offset;
|
||||
uint16_t len;
|
||||
union {
|
||||
uint16_t attr;
|
||||
struct {
|
||||
uint16_t null_ptr : 1;
|
||||
uint16_t reserved : 15;
|
||||
};
|
||||
};
|
||||
} __attribute__((packed));
|
||||
|
||||
/* [header, ipc_arg_buffer_len[], ipc_arg_buffer[]] */
|
||||
@@ -76,7 +83,6 @@ typedef int (*IpcInterface)(struct IpcMsg* msg);
|
||||
struct IpcNode {
|
||||
char* name;
|
||||
IpcInterface interfaces[UINT8_MAX];
|
||||
void (*cycle_handler)();
|
||||
} __attribute__((packed));
|
||||
|
||||
#define IPC_SERVER_LOOP(ipc_node_name) rpc_server_loop_##rpc_node_name
|
||||
@@ -105,6 +111,10 @@ struct IpcNode {
|
||||
/// @return
|
||||
__attribute__((__always_inline__)) static inline void* ipc_msg_get_nth_arg_buf(struct IpcMsg* msg, int arg_num)
|
||||
{
|
||||
if (IPCMSG_ARG_INFO(msg, arg_num)->null_ptr == 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void*)((char*)msg + IPCMSG_ARG_INFO(msg, arg_num)->offset);
|
||||
}
|
||||
|
||||
@@ -243,6 +253,8 @@ bool is_cur_session_delayed(void);
|
||||
}
|
||||
|
||||
int cur_session_id(void);
|
||||
bool server_set_cycle_handler(struct IpcNode* ipc_node, void (*handler)());
|
||||
/// @brief delay the session(message, or a inter-process-call)
|
||||
/// the delayed call will be handled again later from begining, not from the position where delay_session() is called.
|
||||
/// @param
|
||||
void delay_session(void);
|
||||
bool is_cur_handler_been_delayed();
|
||||
@@ -46,10 +46,10 @@ int free_session(struct Session* session)
|
||||
|
||||
void* session_alloc_buf(struct Session* session, int len)
|
||||
{
|
||||
if (len > session_remain_capacity(session)) {
|
||||
if (len < 0 || len > session_remain_capacity(session)) {
|
||||
return NULL;
|
||||
}
|
||||
void* buf = session->buf + session->tail;
|
||||
void* buf = (void*)((uintptr_t)session->buf + session->tail);
|
||||
// we mapped double size of page, so it's ok to write buffer directly
|
||||
memset(buf, 0, len);
|
||||
session_forward_tail(session, len);
|
||||
@@ -58,7 +58,7 @@ void* session_alloc_buf(struct Session* session, int len)
|
||||
|
||||
bool session_free_buf(struct Session* session, int len)
|
||||
{
|
||||
if (len > session_used_size(session)) {
|
||||
if (len < 0 || len > session_used_size(session)) {
|
||||
return false;
|
||||
}
|
||||
assert(session_forward_head(session, len) != -1);
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
user_ldflags = -N -Ttext 0
|
||||
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/app \
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#define PUT_NOTAG(p, val) (*(unsigned int*)(p) = (val))
|
||||
|
||||
// Store predecessor or successor pointer for free blocks
|
||||
#define SET_PTR(p, ptr) (*(unsigned int*)(p) = (unsigned int)(ptr))
|
||||
#define SET_PTR(p, ptr) (*(uintptr_t*)(p) = (uintptr_t)(ptr))
|
||||
|
||||
// Read the size and allocation bit from address p
|
||||
#define GET_SIZE(p) (GET(p) & ~0x7)
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
user_ldflags = -N -Ttext 0
|
||||
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/app \
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
user_ldflags = -N -Ttext 0
|
||||
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
c_useropts = -O2
|
||||
|
||||
INC_DIR = -I$(KERNEL_ROOT)/services/app \
|
||||
|
||||
@@ -14,14 +14,19 @@
|
||||
|
||||
int spawn(struct Session* session, int fd, ipc_read_fn ipc_read, ipc_fsize_fn ipc_fsize, char* name, char** argv)
|
||||
{
|
||||
/* read elf image */
|
||||
int file_size = ipc_fsize(session, fd);
|
||||
void* img = malloc(file_size);
|
||||
int read_len = 0, cur_read_len = 0;
|
||||
int read_len = 0;
|
||||
while (read_len < file_size) {
|
||||
cur_read_len = file_size - read_len < 4096 ? file_size - read_len : 4096;
|
||||
read_len += ipc_read(session, fd, img + read_len, read_len, cur_read_len);
|
||||
int cur_read_len = file_size - read_len < 4096 ? file_size - read_len : 4096;
|
||||
if (cur_read_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
read_len += ipc_read(session, fd, (char*)((uintptr_t)img + read_len), read_len, cur_read_len);
|
||||
}
|
||||
int ret = syscall(SYSCALL_SPAWN, (intptr_t)img, (intptr_t)name, (intptr_t)argv, 0);
|
||||
/* sys call */
|
||||
int ret = syscall(SYSCALL_SPAWN, (uintptr_t)img, (uintptr_t)name, (uintptr_t)argv, 0);
|
||||
free(img);
|
||||
return ret;
|
||||
}
|
||||
@@ -104,4 +109,24 @@ int mmap(uintptr_t vaddr, uintptr_t paddr, int len, bool is_dev)
|
||||
int register_irq(int irq, int opcode)
|
||||
{
|
||||
return syscall(SYSCALL_REGISTER_IRQ, (intptr_t)irq, (intptr_t)opcode, 0, 0);
|
||||
}
|
||||
|
||||
int semaphore_new(int val)
|
||||
{
|
||||
return syscall(SYSCALL_SEMAPHORE, (intptr_t)SYS_SEM_NEW, (intptr_t)val, 0, 0);
|
||||
}
|
||||
|
||||
bool semaphore_free(int sem_id)
|
||||
{
|
||||
return syscall(SYSCALL_SEMAPHORE, (intptr_t)SYS_SEM_FREE, (intptr_t)sem_id, 0, 0);
|
||||
}
|
||||
|
||||
bool semaphore_wait(int sem_id)
|
||||
{
|
||||
return syscall(SYSCALL_SEMAPHORE, (intptr_t)SYS_SEM_WAIT, (intptr_t)sem_id, 0, 0);
|
||||
}
|
||||
|
||||
bool semaphore_signal(int sem_id)
|
||||
{
|
||||
return syscall(SYSCALL_SEMAPHORE, (intptr_t)SYS_SEM_SIGNAL, (intptr_t)sem_id, 0, 0);
|
||||
}
|
||||
@@ -32,6 +32,8 @@
|
||||
#define SYSCALL_REGISTER_IRQ 11 //
|
||||
|
||||
#define SYSCALL_KILL 12 // kill the task by id
|
||||
|
||||
#define SYSCALL_SEMAPHORE 13 // semaphore related operations
|
||||
// clang-format on
|
||||
|
||||
typedef enum {
|
||||
@@ -58,6 +60,13 @@ typedef union {
|
||||
int priority;
|
||||
} sys_state_info;
|
||||
|
||||
typedef enum {
|
||||
SYS_SEM_NEW = 0,
|
||||
SYS_SEM_FREE,
|
||||
SYS_SEM_SIGNAL,
|
||||
SYS_SEM_WAIT,
|
||||
} sys_sem_option;
|
||||
|
||||
typedef int (*ipc_read_fn)(struct Session* session, int fd, char* dst, int offset, int len);
|
||||
typedef int (*ipc_fsize_fn)(struct Session* session, int fd);
|
||||
typedef int (*ipc_write_fn)(struct Session* session, int fd, char* src, int offset, int len);
|
||||
@@ -69,15 +78,23 @@ int thread(void* entry, const char* name, char** argv);
|
||||
void exit(int status);
|
||||
int yield(task_yield_reason reason);
|
||||
int kill(int pid);
|
||||
|
||||
int register_server(char* name);
|
||||
int session(char* path, int capacity, struct Session* user_session);
|
||||
int poll_session(struct Session* userland_session_arr, int arr_capacity);
|
||||
int close_session(struct Session* session);
|
||||
int register_irq(int irq, int opcode);
|
||||
|
||||
int mmap(uintptr_t vaddr, uintptr_t paddr, int len, bool is_dev);
|
||||
|
||||
int task_heap_base();
|
||||
int get_memblock_info(sys_state_info* info);
|
||||
int set_priority(sys_state_info* info);
|
||||
int show_task();
|
||||
int show_mem();
|
||||
int show_cpu();
|
||||
int mmap(uintptr_t vaddr, uintptr_t paddr, int len, bool is_dev);
|
||||
int register_irq(int irq, int opcode);
|
||||
|
||||
int semaphore_new(int val);
|
||||
bool semaphore_free(int sem_id);
|
||||
bool semaphore_wait(int sem_id);
|
||||
bool semaphore_signal(int sem_id);
|
||||
@@ -9,6 +9,12 @@ user_ldflags = --start-group,-lgcc,-lc,--end-group
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
#cflags = -Wall -g -std=c11
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
|
||||
@@ -68,7 +68,8 @@ int IPC_DO_SERVE_FUNC(Ipc_sem_wait)(sem_t* sem, int* timeout)
|
||||
return SEMAPHORE_SUC;
|
||||
}
|
||||
|
||||
// block current session
|
||||
// delay current session
|
||||
// this handler will be invoke again later
|
||||
delay_session();
|
||||
return SEMAPHORE_ERR;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
ifeq ($(BOARD), imx6q-sabrelite)
|
||||
toolchain ?= arm-none-eabi-
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
ifeq ($(BOARD), zynq7000-zc702)
|
||||
toolchain ?= arm-xilinx-eabi-
|
||||
user_ldflags = --start-group,-lgcc,-lc,--end-group
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
#cflags = -Wall -g -std=c11 -Wno-unused
|
||||
cflags = -std=c11 -march=armv7-a -mtune=cortex-a9 -nostdlib -nodefaultlibs -mfloat-abi=soft -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
user_ldflags = -N -Ttext 0
|
||||
endif
|
||||
ifeq ($(BOARD), ok1028a-c)
|
||||
toolchain ?= aarch64-none-elf-
|
||||
user_ldflags = -N -Ttext 0
|
||||
cflags = -Wall -g -std=c11 -mtune=cortex-a72 -nostdlib -nodefaultlibs -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -ggdb -Wno-unused -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie
|
||||
endif
|
||||
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
|
||||
@@ -1735,7 +1735,7 @@ void shellKill(int pid)
|
||||
*/
|
||||
void shellLs(const char* path, ...)
|
||||
{
|
||||
if (*path == '\0') {
|
||||
if ((uintptr_t*)path == (uintptr_t*)shellLs || *path == '\0') {
|
||||
path = ".";
|
||||
}
|
||||
ls(&session_fs, (char*)path);
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#ifndef __SHELL_H__
|
||||
#define __SHELL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "shell_cfg.h"
|
||||
|
||||
#define SHELL_VERSION "3.2.3" /**< 版本号 */
|
||||
@@ -125,10 +127,10 @@
|
||||
* @param _func 被代理的函数
|
||||
* @param ... 代理参数
|
||||
*/
|
||||
#define SHELL_AGENCY_FUNC(_func, ...) \
|
||||
void SHELL_AGENCY_FUNC_NAME(_func)(int p1, int p2, int p3, int p4, int p5, int p6, int p7) \
|
||||
{ \
|
||||
_func(__VA_ARGS__); \
|
||||
#define SHELL_AGENCY_FUNC(_func, ...) \
|
||||
void SHELL_AGENCY_FUNC_NAME(_func)(intptr_t p1, intptr_t p2, intptr_t p3, intptr_t p4, intptr_t p5, intptr_t p6, intptr_t p7) \
|
||||
{ \
|
||||
_func(__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#if SHELL_USING_CMD_EXPORT == 1
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
* @copyright (c) 2019 Letter
|
||||
*
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "shell_ext.h"
|
||||
#include "shell.h"
|
||||
@@ -251,7 +253,7 @@ unsigned int shellExtParsePara(Shell* shell, char* string)
|
||||
*/
|
||||
int shellExtRun(Shell* shell, ShellCommand* command, int argc, char* argv[])
|
||||
{
|
||||
unsigned int params[8] = { 0 };
|
||||
uintptr_t params[8] = { 0 };
|
||||
int paramNum = command->attr.attrs.paramNum > (argc - 1) ? command->attr.attrs.paramNum : (argc - 1);
|
||||
for (int i = 0; i < argc - 1; i++) {
|
||||
params[i] = shellExtParsePara(shell, argv[i + 1]);
|
||||
|
||||
Reference in New Issue
Block a user