mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-11 00:46:49 +00:00
🐛 修复printf的bug
This commit is contained in:
parent
fd0147e04c
commit
37da6ef19e
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -92,7 +92,9 @@
|
|||||||
"stdint.h": "c",
|
"stdint.h": "c",
|
||||||
"syscall.h": "c",
|
"syscall.h": "c",
|
||||||
"fcntl.h": "c",
|
"fcntl.h": "c",
|
||||||
"types.h": "c"
|
"types.h": "c",
|
||||||
|
"string.h": "c",
|
||||||
|
"math.h": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "Enabled",
|
"C_Cpp.errorSquiggles": "Enabled",
|
||||||
"esbonio.sphinx.confDir": ""
|
"esbonio.sphinx.confDir": ""
|
||||||
|
@ -362,7 +362,6 @@ uint64_t sys_brk(struct pt_regs *regs)
|
|||||||
if ((int64_t)regs->r8 == -1)
|
if ((int64_t)regs->r8 == -1)
|
||||||
{
|
{
|
||||||
kdebug("get brk_start=%#018lx", current_pcb->mm->brk_start);
|
kdebug("get brk_start=%#018lx", current_pcb->mm->brk_start);
|
||||||
return 0;
|
|
||||||
return current_pcb->mm->brk_start;
|
return current_pcb->mm->brk_start;
|
||||||
}
|
}
|
||||||
if ((int64_t)regs->r8 == -2)
|
if ((int64_t)regs->r8 == -2)
|
||||||
@ -408,12 +407,7 @@ ul sys_ahci_end_req(struct pt_regs *regs)
|
|||||||
// 系统调用的内核入口程序
|
// 系统调用的内核入口程序
|
||||||
void do_syscall_int(struct pt_regs *regs, unsigned long error_code)
|
void do_syscall_int(struct pt_regs *regs, unsigned long error_code)
|
||||||
{
|
{
|
||||||
if(regs->rax == SYS_BRK)
|
|
||||||
{
|
|
||||||
kdebug("is sysbrk");
|
|
||||||
regs->rax = 0xc00000UL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ul ret = system_call_table[regs->rax](regs);
|
ul ret = system_call_table[regs->rax](regs);
|
||||||
if(regs->rax == SYS_BRK)
|
if(regs->rax == SYS_BRK)
|
||||||
kdebug("brk ret=%#018lx", ret);
|
kdebug("brk ret=%#018lx", ret);
|
||||||
|
@ -9,6 +9,22 @@
|
|||||||
static char *write_num(char *str, uint64_t num, int base, int field_width, int precision, int flags);
|
static char *write_num(char *str, uint64_t num, int base, int field_width, int precision, int flags);
|
||||||
static char *write_float_point_num(char *str, double num, int field_width, int precision, int flags);
|
static char *write_float_point_num(char *str, double num, int field_width, int precision, int flags);
|
||||||
|
|
||||||
|
|
||||||
|
static int skip_and_atoi(const char **s)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief 获取连续的一段字符对应整数的值
|
||||||
|
* @param:**s 指向 指向字符串的指针 的指针
|
||||||
|
*/
|
||||||
|
int ans = 0;
|
||||||
|
while (is_digit(**s))
|
||||||
|
{
|
||||||
|
ans = ans * 10 + (**s) - '0';
|
||||||
|
++(*s);
|
||||||
|
}
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 往屏幕上输出字符串
|
* @brief 往屏幕上输出字符串
|
||||||
*
|
*
|
||||||
@ -138,7 +154,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
else if (is_digit(*fmt))
|
else if (is_digit(*fmt))
|
||||||
{
|
{
|
||||||
field_width = atoi(&fmt);
|
field_width = skip_and_atoi(&fmt);
|
||||||
if (field_width < 0)
|
if (field_width < 0)
|
||||||
{
|
{
|
||||||
field_width = -field_width;
|
field_width = -field_width;
|
||||||
@ -158,7 +174,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
else if is_digit (*fmt)
|
else if is_digit (*fmt)
|
||||||
{
|
{
|
||||||
precision = atoi(&fmt);
|
precision = skip_and_atoi(&fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <libc/unistd.h>
|
#include <libc/unistd.h>
|
||||||
#include <libc/stdlib.h>
|
#include <libc/stdlib.h>
|
||||||
|
#include <libc/ctype.h>
|
||||||
|
|
||||||
int abs(int i)
|
int abs(int i)
|
||||||
{
|
{
|
||||||
|
@ -14,15 +14,11 @@ long syscall_invoke(uint64_t syscall_id, uint64_t arg0, uint64_t arg1, uint64_t
|
|||||||
"movq %8, %%r14 \n\t"
|
"movq %8, %%r14 \n\t"
|
||||||
"movq %9, %%r15 \n\t"
|
"movq %9, %%r15 \n\t"
|
||||||
"int $0x80 \n\t"
|
"int $0x80 \n\t"
|
||||||
"movq %%rax, %0 \n\t"
|
// "movq %%rax, %0 \n\t"
|
||||||
: "=m"(err_code)
|
: "=a"(err_code)
|
||||||
: "a"(syscall_id), "m"(arg0), "m"(arg1), "m"(arg2), "m"(arg3), "m"(arg4), "m"(arg5), "m"(arg6), "m"(arg7)
|
: "a"(syscall_id), "m"(arg0), "m"(arg1), "m"(arg2), "m"(arg3), "m"(arg4), "m"(arg5), "m"(arg6), "m"(arg7)
|
||||||
: "memory", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "rcx", "rdx");
|
: "memory", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "rcx", "rdx");
|
||||||
errno = err_code;
|
errno = err_code;
|
||||||
if (syscall_id == SYS_BRK || syscall_id == SYS_OPEN)
|
|
||||||
{
|
|
||||||
printf("retval = %#018lx\n", (uint64_t)err_code);
|
|
||||||
printf("errcode = %d\n", err_code);
|
|
||||||
}
|
|
||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user