Skip to content

Commit a6ae190

Browse files
committed
更新syscall
1 parent 427a21a commit a6ae190

File tree

21 files changed

+293
-143
lines changed

21 files changed

+293
-143
lines changed

build.py

Lines changed: 0 additions & 74 deletions
This file was deleted.

iso/limine.conf

Lines changed: 0 additions & 6 deletions
This file was deleted.

iso/limine/limine-bios-cd.bin

-24 KB
Binary file not shown.

iso/limine/limine-bios.sys

-205 KB
Binary file not shown.

lib/libelf_parse.a

243 KB
Binary file not shown.

lib/libos_terminal.a

-206 KB
Binary file not shown.

linker.ld

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ SECTIONS
55

66
. = 2M;
77

8-
.multiboot :
9-
{
10-
*(.multiboot)
11-
}
12-
138
.text :
149
{
10+
*(.multiboot)
1511
*(.text)
1612
}
1713

src/boot/asmfunc.asm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
global gdt_flush,tss_flush,idt_flush,switch_to,copy_page_physical
2+
global asm_syscall_handler
3+
4+
extern syscall
25

36
gdt_flush: ; void gdt_flush(uint32_t gdtr);
47
mov eax, [esp + 4] ; [esp+4]按规定是第一个参数,即gdtr
@@ -84,3 +87,19 @@ copy_page_physical:
8487
popf ; Pop EFLAGS back.
8588
pop ebx ; Get the original value of EBX back.
8689
ret
90+
91+
asm_syscall_handler:
92+
cli
93+
push ds
94+
push es
95+
push fs
96+
push gs
97+
pusha
98+
call syscall
99+
mov dword [esp+28], eax
100+
popa
101+
pop gs
102+
pop fs
103+
pop es
104+
pop ds
105+
IRETD

src/core/main.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,25 @@
1717
#include "keyboard.h"
1818
#include "scheduler.h"
1919
#include "krlibc.h"
20+
#include "syscall.h"
2021
#include "shell.h"
2122

2223
extern void* program_break_end;
2324

2425
extern void iso9660_regist(); //iso9660.c
2526

27+
int terminal_manual_flush(void* arg) { // 终端刷新服务
28+
while (1) {
29+
terminal_flush();
30+
}
31+
}
32+
2633
/*
2734
* 内核初始化函数, 最终会演变为CPU0的IDLE进程
2835
* > 注意, 其所有的函数调用顺序均不可改变. 需按顺序初始化OS功能
2936
* @Noreturn
3037
*/
31-
_Noreturn void kernel_main(multiboot_t *multiboot, uint32_t kernel_stack) {
38+
void kernel_main(multiboot_t *multiboot, uint32_t kernel_stack) {
3239
vga_install();
3340

3441
if(multiboot->cmdline != (multiboot_uint32_t)NULL) {
@@ -63,29 +70,17 @@ _Noreturn void kernel_main(multiboot_t *multiboot, uint32_t kernel_stack) {
6370
init_pcb();
6471

6572
keyboard_init();
73+
setup_syscall();
6674
create_kernel_thread((void*)setup_shell, NULL, "Shell");
6775
klogf(true,"Enable kernel shell service.\n");
76+
create_kernel_thread(terminal_manual_flush, NULL, "Terminal manual flush");
77+
klogf(true,"Enable terminal flush service.\n");
6878

6979
klogf(true,"Kernel load done!\n");
7080
enable_scheduler();
7181
io_sti(); //内核加载完毕, 打开中断以启动进程调度器, 开始运行
7282

73-
// int ret = vfs_mkdir("/dev");
74-
// printk(" vfs ret=%d\n",ret);
75-
// vfs_mount(NULL, vfs_open("/dev"));
76-
// vfs_node_t p = vfs_open("/");
77-
// list_foreach(p->child, i) {
78-
// vfs_node_t c = (vfs_node_t)i->data;
79-
// printk("%s ", c->name);
80-
// }
81-
// printk("\n");
82-
83-
// uint8_t *buf = kmalloc(2048);
84-
// p = vfs_open("/dev/ide_atapi0");
85-
// vfs_read(p,buf,2048,2048);
86-
// for(int i = 0;i<2048;i++) {
87-
// printk("%02x ",buf[i]);
88-
// }
83+
__syscall(SYSCALL_PRINT,"Hello! Syscall!\n");
8984

9085
while(1) io_hlt();
9186
}

src/core/memory/page.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ page_directory_t *clone_directory(page_directory_t *src) {
169169
return dir;
170170
}
171171

172+
page_directory_t *get_current_directory(){
173+
return current_directory;
174+
}
175+
172176
void page_fault(registers_t *regs) {
173177
io_cli();
174178
uint32_t faulting_address;

0 commit comments

Comments
 (0)