更新硬盘设备查看命令

This commit is contained in:
xiaoyi1212 2024-05-13 20:52:43 +08:00
parent 8da818145d
commit bc324a121a
2 changed files with 56 additions and 8 deletions

View File

@ -84,7 +84,7 @@ void kernel_main(multiboot_t *multiboot) {
clock_sleep(25); clock_sleep(25);
//kernel_thread(setup_shell, NULL, "CPOS-Shell"); kernel_thread(setup_shell, NULL, "CPOS-Shell");
launch_date(); launch_date();
for (;;) { for (;;) {

View File

@ -4,9 +4,10 @@
#include "../include/common.h" #include "../include/common.h"
#include "../include/task.h" #include "../include/task.h"
#include "../include/cmos.h" #include "../include/cmos.h"
#include "../include/pcat.h" #include "../include/vdisk.h"
extern Queue *key_char_queue; extern Queue *key_char_queue;
extern vdisk vdisk_ctl[10];
char getc() { char getc() {
while (key_char_queue->size == 0x00) { while (key_char_queue->size == 0x00) {
@ -133,6 +134,13 @@ void cmd_debug(){
print_proc_t(&index,get_current(),get_current()->next,0); print_proc_t(&index,get_current(),get_current()->next,0);
printf("Process Runnable: %d\n",index); printf("Process Runnable: %d\n",index);
cmd_date(); cmd_date();
for (int i = 0; i < 10; i++) {
if (vdisk_ctl[i].flag) {
vdisk vd = vdisk_ctl[i];
char id = i + ('A');
printf("[DISK-%c]: Size: %dMB | Name: %s\n",id,vd.size,vd.DriveName);
}
}
printf(" > > > > ====[Registers Info]==== < < < <\n"); printf(" > > > > ====[Registers Info]==== < < < <\n");
register uint32_t eax asm("eax"), register uint32_t eax asm("eax"),
ecx asm("ecx"), ecx asm("ecx"),
@ -145,12 +153,52 @@ void cmd_debug(){
printf("ESI: 0x%08x | EDI 0x%08x | EBP 0x%08x | EFLAGS 0x%08x\n",esi,edi,ebp,get_current()->context.eflags); printf("ESI: 0x%08x | EDI 0x%08x | EBP 0x%08x | EFLAGS 0x%08x\n",esi,edi,ebp,get_current()->context.eflags);
} }
void cmd_pcat(int argc,char **argv){ void cmd_disk(int argc,char **argv){
if (argc == 1) { if(argc > 1){
if(!strcmp("list",argv[1])){
printf("[Disk]: Loaded disk - ");
for (int i = 0; i < 10; i++) {
if (vdisk_ctl[i].flag) {
vdisk vd = vdisk_ctl[i];
char id = i + ('A');
printf("(%c) ",id,vd.size,vd.DriveName);
}
}
printf("\n");
return;
}
if(strlen(argv[1]) > 1){
printf("\033[DISK]: Cannot found disk.\036\n");
return;
}
for (int i = 0; i < 10; i++) {
if (vdisk_ctl[i].flag) {
vdisk vd = vdisk_ctl[i];
char id = i + ('A');
if(id == (argv[1][0])){
printf("[Disk(%c)]: \n"
" Size: %dMB\n"
" Name: %s\n"
" WriteAddress: 0x%08x\n"
" ReadAddress: 0x%08x\n",id,vd.size,vd.DriveName,vd.Write,vd.Read);
return;
}
}
}
printf("\033[DISK]: Cannot found disk.\036\n");
return; return;
} }
printf("[Disk]: Loaded disk - ");
for (int i = 0; i < 10; i++) {
if (vdisk_ctl[i].flag) {
vdisk vd = vdisk_ctl[i];
char id = i + ('A');
printf("(%c) ",id,vd.size,vd.DriveName);
}
}
printf("\n");
} }
void setup_shell(){ void setup_shell(){
@ -194,8 +242,8 @@ void setup_shell(){
cmd_shutdown(); cmd_shutdown();
else if (!strcmp("debug", argv[0])) else if (!strcmp("debug", argv[0]))
cmd_debug(); cmd_debug();
else if (!strcmp("pcat", argv[0])) else if (!strcmp("disk", argv[0]))
cmd_pcat(argc,argv); cmd_disk(argc,argv);
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])) {
vga_writestring("-=[\037CoolPotShell Helper\036]=-\n"); vga_writestring("-=[\037CoolPotShell Helper\036]=-\n");
vga_writestring("help ? h \032Print shell help info.\036\n"); vga_writestring("help ? h \032Print shell help info.\036\n");
@ -209,7 +257,7 @@ void setup_shell(){
vga_writestring("reset \032Reset OS.\036\n"); vga_writestring("reset \032Reset OS.\036\n");
vga_writestring("shutdown exit \032Shutdown OS.\036\n"); vga_writestring("shutdown exit \032Shutdown OS.\036\n");
vga_writestring("debug \032Print os debug info.\036\n"); vga_writestring("debug \032Print os debug info.\036\n");
vga_writestring("pcat [filename] \032Launch pcat application.\036\n"); vga_writestring("disk [list|<ID>] \032List or view disks.\036\n");
} else printf("\033[Shell]: Unknown command '%s'.\036\n", argv[0]); } else printf("\033[Shell]: Unknown command '%s'.\036\n", argv[0]);
} }
} }