mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 07:06:47 +00:00
new: 增加ktest_start函数以开启内核自测试
This commit is contained in:
parent
c1f51bf4cb
commit
7c9366b297
@ -2,7 +2,10 @@
|
|||||||
CFLAGS += -I .
|
CFLAGS += -I .
|
||||||
|
|
||||||
|
|
||||||
all: bitree.o kfifo.o
|
all: ktest.o bitree.o kfifo.o
|
||||||
|
|
||||||
|
ktest.o: ktest.c
|
||||||
|
gcc $(CFLAGS) -c ktest.c -o ktest.o
|
||||||
|
|
||||||
bitree.o: test-bitree.c
|
bitree.o: test-bitree.c
|
||||||
gcc $(CFLAGS) -c test-bitree.c -o test-bitree.o
|
gcc $(CFLAGS) -c test-bitree.c -o test-bitree.o
|
||||||
|
14
kernel/ktest/ktest.c
Normal file
14
kernel/ktest/ktest.c
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "ktest.h"
|
||||||
|
#include <process/process.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 开启一个新的内核线程以进行测试
|
||||||
|
*
|
||||||
|
* @param func 测试函数
|
||||||
|
* @param arg 传递给测试函数的参数
|
||||||
|
* @return pid_t 测试内核线程的pid
|
||||||
|
*/
|
||||||
|
pid_t ktest_start(uint64_t (*func)(uint64_t arg), uint64_t arg)
|
||||||
|
{
|
||||||
|
return kernel_thread(func, arg, 0);
|
||||||
|
}
|
@ -2,4 +2,13 @@
|
|||||||
#include <common/sys/types.h>
|
#include <common/sys/types.h>
|
||||||
|
|
||||||
uint64_t ktest_test_bitree(uint64_t arg);
|
uint64_t ktest_test_bitree(uint64_t arg);
|
||||||
uint64_t ktest_test_kfifo(uint64_t arg);
|
uint64_t ktest_test_kfifo(uint64_t arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 开启一个新的内核线程以进行测试
|
||||||
|
*
|
||||||
|
* @param func 测试函数
|
||||||
|
* @param arg 传递给测试函数的参数
|
||||||
|
* @return pid_t 测试内核线程的pid
|
||||||
|
*/
|
||||||
|
pid_t ktest_start(uint64_t (*func)(uint64_t arg), uint64_t arg);
|
@ -541,11 +541,13 @@ void *kmalloc(unsigned long size, unsigned long flags)
|
|||||||
}
|
}
|
||||||
int index;
|
int index;
|
||||||
for (int i = 0; i < 16; ++i)
|
for (int i = 0; i < 16; ++i)
|
||||||
|
{
|
||||||
if (kmalloc_cache_group[i].size >= size)
|
if (kmalloc_cache_group[i].size >= size)
|
||||||
{
|
{
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct slab_obj *slab_obj_ptr = kmalloc_cache_group[index].cache_pool_entry;
|
struct slab_obj *slab_obj_ptr = kmalloc_cache_group[index].cache_pool_entry;
|
||||||
|
|
||||||
|
@ -416,8 +416,8 @@ ul initial_kernel_thread(ul arg)
|
|||||||
usb_init();
|
usb_init();
|
||||||
|
|
||||||
// 对一些组件进行单元测试
|
// 对一些组件进行单元测试
|
||||||
kernel_thread(ktest_test_bitree, 0, 0);
|
ktest_start(ktest_test_bitree, 0);
|
||||||
kernel_thread(ktest_test_kfifo, 0, 0);
|
ktest_start(ktest_test_kfifo, 0);
|
||||||
|
|
||||||
// 准备切换到用户态
|
// 准备切换到用户态
|
||||||
struct pt_regs *regs;
|
struct pt_regs *regs;
|
||||||
|
@ -115,7 +115,7 @@ struct process_control_block
|
|||||||
// 进程切换时保存的状态信息
|
// 进程切换时保存的状态信息
|
||||||
struct thread_struct *thread;
|
struct thread_struct *thread;
|
||||||
|
|
||||||
// 连接各个pcb的双向链表(todo:删除这个变量)
|
// 连接各个pcb的双向链表
|
||||||
struct List list;
|
struct List list;
|
||||||
|
|
||||||
// 地址空间范围
|
// 地址空间范围
|
||||||
|
Loading…
x
Reference in New Issue
Block a user