更新shell切换机制
This commit is contained in:
parent
07e44df26a
commit
37677878c0
@ -63,8 +63,6 @@ int main(){
|
|||||||
|
|
||||||
argc = cmd_parse(com, argv, ' ');
|
argc = cmd_parse(com, argv, ' ');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (argc == -1) {
|
if (argc == -1) {
|
||||||
printf("[Shell]: Error: out of arguments buffer\n");
|
printf("[Shell]: Error: out of arguments buffer\n");
|
||||||
continue;
|
continue;
|
||||||
@ -72,23 +70,13 @@ int main(){
|
|||||||
|
|
||||||
if (!strcmp("version", argv[0])){
|
if (!strcmp("version", argv[0])){
|
||||||
print_info();
|
print_info();
|
||||||
|
}if (!strcmp("system", argv[0])){
|
||||||
|
exit(0);
|
||||||
}else if (!strcmp("help", argv[0]) || !strcmp("?", argv[0]) || !strcmp("h", argv[0])) {
|
}else if (!strcmp("help", argv[0]) || !strcmp("?", argv[0]) || !strcmp("h", argv[0])) {
|
||||||
printf("-=[CoolPotShell Helper]=-\n");
|
printf("-=[CoolPotShell Helper]=-\n");
|
||||||
printf("help ? h Print shell help info.\n");
|
printf("help ? h Print shell help info.\n");
|
||||||
printf("version Print os version.\n");
|
printf("version Print os version.\n");
|
||||||
printf("type <name> Read a file.\n");
|
printf("system Launch system shell.\n");
|
||||||
printf("ls List all files.\n");
|
|
||||||
printf("mkdir <name> Make a directory.\n");
|
|
||||||
printf("del rm <name> Delete a file.\n");
|
|
||||||
printf("sysinfo Print system info.\n");
|
|
||||||
printf("proc [kill<pid>|list] List all running processes.\n");
|
|
||||||
printf("reset Reset OS.\n");
|
|
||||||
printf("shutdown exit Shutdown OS.\n");
|
|
||||||
printf("debug Print os debug info.\n");
|
|
||||||
printf("disk[list|<ID>|cg<ID>]List or view disks.\n");
|
|
||||||
printf("cd <path> Change shell top directory.\n");
|
|
||||||
printf("sb3 <name> Player a wav sound file.\n");
|
|
||||||
printf("exec <path> Execute a application.\n");
|
|
||||||
} else printf("\033ff3030;[Shell]: Unknown command '%s'.\033c6c6c6;\n", argv[0]);
|
} else printf("\033ff3030;[Shell]: Unknown command '%s'.\033c6c6c6;\n", argv[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,8 +43,6 @@ void shutdown_kernel(){
|
|||||||
kill_all_task();
|
kill_all_task();
|
||||||
clock_sleep(10);
|
clock_sleep(10);
|
||||||
power_off();
|
power_off();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t memory_all(){
|
uint32_t memory_all(){
|
||||||
@ -53,6 +51,15 @@ uint32_t memory_all(){
|
|||||||
|
|
||||||
int check_task(int *pid){
|
int check_task(int *pid){
|
||||||
struct task_struct *shell = found_task_pid(*pid);
|
struct task_struct *shell = found_task_pid(*pid);
|
||||||
|
|
||||||
|
if(shell == NULL){
|
||||||
|
printf("\n[Task-Check]: Task was throw exception.\n");
|
||||||
|
printf("Enter any key to restart kernel.> ");
|
||||||
|
getc();
|
||||||
|
printf("\n");
|
||||||
|
reset_kernel();
|
||||||
|
}
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
if(shell->state == TASK_DEATH){
|
if(shell->state == TASK_DEATH){
|
||||||
printf("\n[Task-Check]: Task was throw exception.\n");
|
printf("\n[Task-Check]: Task was throw exception.\n");
|
||||||
@ -65,6 +72,18 @@ int check_task(int *pid){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int check_task_usershell(int *pid){
|
||||||
|
struct task_struct *shell = found_task_pid(*pid);
|
||||||
|
while (1){
|
||||||
|
if(shell->state == TASK_DEATH){
|
||||||
|
screen_clear();
|
||||||
|
int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell");
|
||||||
|
kernel_thread(check_task,&pid,"CPOS-CK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void kernel_main(multiboot_t *multiboot) {
|
void kernel_main(multiboot_t *multiboot) {
|
||||||
|
|
||||||
io_cli();
|
io_cli();
|
||||||
@ -141,7 +160,22 @@ void kernel_main(multiboot_t *multiboot) {
|
|||||||
clock_sleep(25);
|
clock_sleep(25);
|
||||||
|
|
||||||
vfs_change_path("apps");
|
vfs_change_path("apps");
|
||||||
klogf(user_process("shell.bin","Shell") != -1,"Shell process init.\n");
|
int pid = user_process("shell.bin","Shell");
|
||||||
|
klogf(pid != -1,"Shell process init.\n");
|
||||||
|
if(pid == -1){
|
||||||
|
printf("UserShell launch fault.\n");
|
||||||
|
printf("Launching system 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");
|
||||||
|
goto ker;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel_thread(check_task_usershell,&pid,"CPOS-UCK");
|
||||||
|
|
||||||
|
ker:
|
||||||
|
|
||||||
//klogf(user_process("init.bin","Init") != -1,"Init base process init.\n");
|
//klogf(user_process("init.bin","Init") != -1,"Init base process init.\n");
|
||||||
|
|
||||||
//int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell");
|
//int pid = kernel_thread(setup_shell,NULL,"CPOS-Shell");
|
||||||
|
@ -29,7 +29,7 @@ static char syscall_getch(uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t esi,ui
|
|||||||
|
|
||||||
static void syscall_exit(uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t esi,uint32_t edi){
|
static void syscall_exit(uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t esi,uint32_t edi){
|
||||||
task_kill(get_current()->pid);
|
task_kill(get_current()->pid);
|
||||||
printf("PID[%d] exit code: %d",get_current()->pid,ebx);
|
//printf("PID[%d] exit code: %d",get_current()->pid,ebx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* syscall_malloc(uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t esi,uint32_t edi){
|
static void* syscall_malloc(uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t esi,uint32_t edi){
|
||||||
|
Loading…
Reference in New Issue
Block a user