mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-19 09:06:32 +00:00
修正系统入口为系统调用门
This commit is contained in:
@ -2,12 +2,29 @@
|
||||
#include "../process/process.h"
|
||||
#include <exception/gate.h>
|
||||
#include <exception/irq.h>
|
||||
#include<driver/disk/ahci/ahci.h>
|
||||
#include <driver/disk/ahci/ahci.h>
|
||||
|
||||
// 导出系统调用入口函数,定义在entry.S中
|
||||
extern void system_call(void);
|
||||
extern void syscall_int(void);
|
||||
|
||||
/**
|
||||
* @brief 导出系统调用处理函数的符号
|
||||
*
|
||||
*/
|
||||
#define SYSCALL_COMMON(syscall_num, symbol) extern unsigned long symbol(struct pt_regs *regs);
|
||||
SYSCALL_COMMON(0, system_call_not_exists); // 导出system_call_not_exists函数
|
||||
#undef SYSCALL_COMMON // 取消前述宏定义
|
||||
|
||||
/**
|
||||
* @brief 重新定义为:把系统调用函数加入系统调用表
|
||||
* @param syscall_num 系统调用号
|
||||
* @param symbol 系统调用处理函数
|
||||
*/
|
||||
#define SYSCALL_COMMON(syscall_num, symbol) [syscall_num] = symbol,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief sysenter的系统调用函数,从entry.S中跳转到这里
|
||||
*
|
||||
@ -27,7 +44,7 @@ void syscall_init()
|
||||
{
|
||||
kinfo("Initializing syscall...");
|
||||
|
||||
set_system_trap_gate(0x80, 0, syscall_intr_table[0]); // 系统调用门
|
||||
set_system_trap_gate(0x80, 0, syscall_int); // 系统调用门
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,9 +95,10 @@ long enter_syscall_int(ul syscall_id, ul arg0, ul arg1, ul arg2, ul arg3, ul arg
|
||||
ul sys_printf(struct pt_regs *regs)
|
||||
{
|
||||
|
||||
if(regs->r9 == 0 &®s->r10 == 0)
|
||||
printk((char*)regs->r8);
|
||||
else printk_color(regs->r9, regs->r10, (char*)regs->r8);
|
||||
if (regs->r9 == 0 && regs->r10 == 0)
|
||||
printk((char *)regs->r8);
|
||||
else
|
||||
printk_color(regs->r9, regs->r10, (char *)regs->r8);
|
||||
// printk_color(BLACK, WHITE, (char *)regs->r8);
|
||||
|
||||
return 0;
|
||||
@ -98,4 +116,12 @@ void do_syscall_int(struct pt_regs *regs, unsigned long error_code)
|
||||
|
||||
ul ret = system_call_table[regs->rax](regs);
|
||||
regs->rax = ret; // 返回码
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
system_call_t system_call_table[MAX_SYSTEM_CALL_NUM] =
|
||||
{
|
||||
[0] = system_call_not_exists,
|
||||
[1] = sys_printf,
|
||||
[2 ... 254] = system_call_not_exists,
|
||||
[255] = sys_ahci_end_req};
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "../common/glib.h"
|
||||
#include "../common/kprint.h"
|
||||
#include "../process/ptrace.h"
|
||||
|
||||
#include <common/unistd.h>
|
||||
// 定义最大系统调用数量
|
||||
#define MAX_SYSTEM_CALL_NUM 256
|
||||
|
||||
@ -13,6 +13,8 @@ typedef unsigned long (*system_call_t)(struct pt_regs *regs);
|
||||
|
||||
extern void ret_from_system_call(void); // 导出从系统调用返回的函数(定义在entry.S)
|
||||
|
||||
extern system_call_t system_call_table[MAX_SYSTEM_CALL_NUM];
|
||||
|
||||
/**
|
||||
* @brief 初始化系统调用模块
|
||||
*
|
||||
@ -57,10 +59,3 @@ ul sys_ahci_end_req(struct pt_regs *regs);
|
||||
|
||||
// 系统调用的内核入口程序
|
||||
void do_syscall_int(struct pt_regs *regs, unsigned long error_code);
|
||||
|
||||
system_call_t system_call_table[MAX_SYSTEM_CALL_NUM] =
|
||||
{
|
||||
[0] = system_call_not_exists,
|
||||
[1] = sys_printf,
|
||||
[2 ... 254] = system_call_not_exists,
|
||||
[255] = sys_ahci_end_req};
|
||||
|
@ -10,6 +10,6 @@
|
||||
*/
|
||||
|
||||
#define SYS_NOT_EXISTS 0
|
||||
#define SYS_PRINTF 1
|
||||
#define SYS_PUT_STRING 1
|
||||
|
||||
#define SYS_AHCI_END_REQ 255
|
||||
#define SYS_AHCI_END_REQ 255 // AHCI DMA请求结束end_request的系统调用
|
Reference in New Issue
Block a user