新增change_path的syscall
This commit is contained in:
parent
beee408a87
commit
91c097aad6
|
@ -14,6 +14,7 @@
|
||||||
#define SYSCALL_VFS_WRITEFILE 11
|
#define SYSCALL_VFS_WRITEFILE 11
|
||||||
#define SYSCALL_SYSINFO 12
|
#define SYSCALL_SYSINFO 12
|
||||||
#define SYSCALL_EXEC 13
|
#define SYSCALL_EXEC 13
|
||||||
|
#define SYSCALL_CHANGE_PATH 14
|
||||||
|
|
||||||
#include "ctype.h"
|
#include "ctype.h"
|
||||||
|
|
||||||
|
@ -30,5 +31,6 @@ void syscall_vfs_readfile(char* filename,char* buffer);
|
||||||
void syscall_vfs_writefile(char* filename,char* buffer,unsigned int size);
|
void syscall_vfs_writefile(char* filename,char* buffer,unsigned int size);
|
||||||
void* syscall_sysinfo();
|
void* syscall_sysinfo();
|
||||||
int syscall_exec(char *filename);
|
int syscall_exec(char *filename);
|
||||||
|
void syscall_vfs_change_path(const char* path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
printf("Init service launched.\n");
|
printf("Init service launched.\n");
|
||||||
|
syscall_vfs_change_path("apps");
|
||||||
int pid = exec_elf("shell.bin");
|
int pid = exec_elf("shell.bin");
|
||||||
printf("Launching shell pid [%d]\n",pid);
|
|
||||||
if(pid != -1){
|
if(pid != -1){
|
||||||
printf("Shell launch win! PID:[%d]\n",pid);
|
printf("Shell launch win! PID:[%d]\n",pid);
|
||||||
} else printf("Error: Cannot launch shell\n");
|
} else printf("Error: Cannot launch shell\n");
|
||||||
|
|
|
@ -94,4 +94,12 @@ int syscall_exec(char *filename){
|
||||||
register uint32_t ebx asm("ebx") = __arg1;
|
register uint32_t ebx asm("ebx") = __arg1;
|
||||||
asm volatile("int $31\n\t" : "=a"(rets) : "0"(SYSCALL_EXEC), "r"(ebx) : "memory", "cc");
|
asm volatile("int $31\n\t" : "=a"(rets) : "0"(SYSCALL_EXEC), "r"(ebx) : "memory", "cc");
|
||||||
return rets;
|
return rets;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syscall_vfs_change_path(const char *path){
|
||||||
|
uint32_t rets;
|
||||||
|
uint32_t __arg1 = (uint32_t)(path);
|
||||||
|
register uint32_t ebx asm("ebx") = __arg1;
|
||||||
|
asm volatile("int $31\n\t" : "=a"(rets) : "0"(SYSCALL_CHANGE_PATH), "r"(ebx) : "memory", "cc");
|
||||||
|
return rets;
|
||||||
}
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
#define SYSCALL_VFS_WRITEFILE 11
|
#define SYSCALL_VFS_WRITEFILE 11
|
||||||
#define SYSCALL_SYSINFO 12
|
#define SYSCALL_SYSINFO 12
|
||||||
#define SYSCALL_EXEC 13
|
#define SYSCALL_EXEC 13
|
||||||
|
#define SYSCALL_CHANGE_PATH 14
|
||||||
|
|
||||||
void syscall_install();
|
void syscall_install();
|
||||||
|
|
||||||
|
|
|
@ -159,13 +159,13 @@ void kernel_main(multiboot_t *multiboot) {
|
||||||
clock_sleep(25);
|
clock_sleep(25);
|
||||||
|
|
||||||
vfs_change_path("apps");
|
vfs_change_path("apps");
|
||||||
klogf(user_process("init.bin","InitService") != -1,"Init service process init.\n");
|
//klogf(user_process("init.bin","InitService") != -1,"Init service process init.\n");
|
||||||
|
|
||||||
|
int pid = user_process("shell.bin","UserShell");
|
||||||
|
kernel_thread(check_task_usershell,&pid,"CTU");
|
||||||
|
|
||||||
//klogf(user_process("init.bin","Init") != -1,"Init base process init.\n");
|
// int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell");
|
||||||
|
// klogf(pid != -1,"Launch kernel shell.\n");
|
||||||
//int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell");
|
|
||||||
//klogf(pid != -1,"Launch kernel shell.\n");
|
|
||||||
//kernel_thread(check_task,&pid,"CPOS-CK");
|
//kernel_thread(check_task,&pid,"CPOS-CK");
|
||||||
|
|
||||||
//panic_pane("System out of memory error!",OUT_OF_MEMORY);
|
//panic_pane("System out of memory error!",OUT_OF_MEMORY);
|
||||||
|
|
|
@ -230,7 +230,7 @@ void init_page(multiboot_t *mboot) {
|
||||||
current_directory = kernel_directory;
|
current_directory = kernel_directory;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (i < placement_address + 0x50000) {
|
while (i < placement_address + 0xf0000) {
|
||||||
/*
|
/*
|
||||||
* 内核部分对ring3而言不可读不可写
|
* 内核部分对ring3而言不可读不可写
|
||||||
* 无偏移页表映射
|
* 无偏移页表映射
|
||||||
|
@ -240,6 +240,11 @@ void init_page(multiboot_t *mboot) {
|
||||||
i += 0x1000;
|
i += 0x1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = KHEAP_START; i < KHEAP_START + KHEAP_INITIAL_SIZE; i++) {
|
||||||
|
alloc_frame(get_page(i, 1, kernel_directory,false), 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int j = mboot->framebuffer_addr,size = mboot->framebuffer_height * mboot->framebuffer_width*mboot->framebuffer_bpp;
|
unsigned int j = mboot->framebuffer_addr,size = mboot->framebuffer_height * mboot->framebuffer_width*mboot->framebuffer_bpp;
|
||||||
|
|
||||||
while (j <= mboot->framebuffer_addr + size){
|
while (j <= mboot->framebuffer_addr + size){
|
||||||
|
@ -247,9 +252,7 @@ void init_page(multiboot_t *mboot) {
|
||||||
j += 0x1000;
|
j += 0x1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = KHEAP_START; i < KHEAP_START + KHEAP_INITIAL_SIZE; i++) {
|
|
||||||
alloc_frame(get_page(i, 1, kernel_directory,false), 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
register_interrupt_handler(14, page_fault);
|
register_interrupt_handler(14, page_fault);
|
||||||
|
|
|
@ -63,6 +63,10 @@ static void syscall_vfs_writefile(uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_
|
||||||
vfs_writefile(ebx,ecx,edx);
|
vfs_writefile(ebx,ecx,edx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void syscall_vfs_chang_path(uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t esi,uint32_t edi){
|
||||||
|
vfs_change_path(ebx);
|
||||||
|
}
|
||||||
|
|
||||||
struct sysinfo{
|
struct sysinfo{
|
||||||
char* osname;
|
char* osname;
|
||||||
char* kenlname;
|
char* kenlname;
|
||||||
|
@ -133,6 +137,7 @@ void *sycall_handlers[MAX_SYSCALLS] = {
|
||||||
[SYSCALL_VFS_WRITEFILE] = syscall_vfs_writefile,
|
[SYSCALL_VFS_WRITEFILE] = syscall_vfs_writefile,
|
||||||
[SYSCALL_SYSINFO] = syscall_sysinfo,
|
[SYSCALL_SYSINFO] = syscall_sysinfo,
|
||||||
[SYSCALL_EXEC] = syscall_exec,
|
[SYSCALL_EXEC] = syscall_exec,
|
||||||
|
[SYSCALL_CHANGE_PATH] = syscall_vfs_chang_path,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef size_t (*syscall_t)(size_t, size_t, size_t, size_t, size_t);
|
typedef size_t (*syscall_t)(size_t, size_t, size_t, size_t, size_t);
|
||||||
|
|
|
@ -194,6 +194,7 @@ int32_t user_process(char *path, char *name){ // 用户进程创建
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
io_sti();
|
io_sti();
|
||||||
|
|
||||||
uint32_t size = vfs_filesize(path);
|
uint32_t size = vfs_filesize(path);
|
||||||
if(size == -1){
|
if(size == -1){
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -221,8 +222,6 @@ int32_t user_process(char *path, char *name){ // 用户进程创建
|
||||||
new_task->tty = kmalloc(sizeof(tty_t));
|
new_task->tty = kmalloc(sizeof(tty_t));
|
||||||
init_default_tty(new_task);
|
init_default_tty(new_task);
|
||||||
|
|
||||||
extern char root_disk;
|
|
||||||
vfs_change_disk(new_task,root_disk);
|
|
||||||
vfs_copy(new_task,get_current()->vfs_now);
|
vfs_copy(new_task,get_current()->vfs_now);
|
||||||
|
|
||||||
io_sti();
|
io_sti();
|
||||||
|
|
Loading…
Reference in New Issue