Go to the source code of this file.
Data Structures | |
struct | CMD |
A command format structure. More... | |
Defines | |
#define | SH_VERSION "MiniShell version 0.03.01" |
The name & version of the shell. | |
#define | SH_COMMANDS ( sizeof(commands)/sizeof(CMD_t) ) |
The number of commands supported. | |
Typedefs | |
typedef CMD | CMD_t |
A command format structure. | |
Functions | |
void | shell () |
Definition in file shell.h.
|
The number of commands supported.
|
|
The name & version of the shell.
|
|
A command format structure.
|
|
Definition at line 946 of file shell.c.
00947 { 00948 // The MINIShell main program // 00949 00950 #define SH_PROMPT "\r[root:/fd0/%s]# " 00951 #define CMD_ARG (cmd+strlen(commands[i].name)+1) 00952 00953 // Shell command buffer // 00954 char cmd[STR_MAX_LENGTH]; 00955 int i; 00956 00957 // Reset the command buffer // 00958 memset(cmd, 0, sizeof(cmd)); 00959 00960 // Welcome message // 00961 set_color(DEFAULT_COLOR); 00962 kprintf("\n\rWelcome to the MiniShell (tty%u)", get_curr_task()->console); 00963 kprintf("\n\rHave a lot of fun...\n\r"); 00964 00965 // Command line // 00966 while(TRUE) 00967 { 00968 kprintf(SH_PROMPT, pwd()); 00969 gets(cmd); 00970 00971 for(i=0; i<SH_COMMANDS; i++) 00972 { 00973 // Parse the command // 00974 if ( strncmp(cmd, commands[i].name, strlen(commands[i].name))==0 ) 00975 { 00976 if (*(cmd+strlen(commands[i].name)) == '\0') 00977 { 00978 *CMD_ARG = '\0'; 00979 break; 00980 } 00981 if (*(cmd+strlen(commands[i].name)) == ' ') 00982 break; 00983 } 00984 } 00985 00986 if (i == SH_COMMANDS) 00987 { 00988 // No command requested // 00989 if (!cmd[0]) continue; 00990 00991 // Execute a file in the current path in foreground // 00992 if( !strncmp(cmd, "./", 2) ) 00993 { 00994 if( cmd[2]=='\0' ) 00995 { 00996 kprintf("\n%s: is a directory\n"); 00997 continue; 00998 } 00999 else 01000 { 01001 sh_exec(cmd+2); 01002 continue; 01003 } 01004 } 01005 01006 // Command not found // 01007 kprintf("\n%s: command not found\n", cmd); 01008 continue; 01009 } 01010 01011 switch(commands[i].index) 01012 { 01013 case SH_HELP: 01014 sh_help(CMD_ARG); 01015 break; 01016 01017 case SH_UNAME: 01018 kprintf("\n\r%s - Kernel [v%s]\n\r", KERNEL_NAME, KERNEL_VERSION); 01019 break; 01020 01021 case SH_CLEAR: 01022 set_color(DEFAULT_COLOR); 01023 clrscr(); 01024 break; 01025 01026 case SH_REBOOT: 01027 reboot(); 01028 break; 01029 01030 case SH_DUMP: 01031 breakpoint(); 01032 break; 01033 01034 case SH_READ: 01035 sh_read(CMD_ARG); 01036 break; 01037 01038 case SH_WRITE: 01039 sh_write(CMD_ARG); 01040 break; 01041 01042 case SH_PAGES: 01043 dump_dirty_pages(); 01044 break; 01045 01046 case SH_MEM: 01047 dump_memory_map(); 01048 break; 01049 01050 case SH_CHECKMEM: 01051 create_process( 01052 &check_free_frames_integrity, 01053 &check_free_frames_integrity, 01054 0, 01055 "frames_check", 01056 KERNEL_PRIVILEGE 01057 ); 01058 break; 01059 01060 case SH_FRAMES: 01061 dump_free_frames(); 01062 break; 01063 01064 case SH_EXEC: 01065 sh_exec(CMD_ARG); 01066 break; 01067 01068 case SH_BG: 01069 sh_bg(CMD_ARG); 01070 break; 01071 01072 case SH_V86EXEC: 01073 sh_v86_exec(CMD_ARG); 01074 break; 01075 01076 case SH_V86BG: 01077 sh_v86_bg(CMD_ARG); 01078 break; 01079 01080 case SH_TEST: 01081 sh_test(CMD_ARG); 01082 break; 01083 01084 case SH_CPUID: 01085 show_cpuid(); 01086 break; 01087 01088 case SH_MOUNT: 01089 Read_FAT(); 01090 break; 01091 01092 case SH_LS: 01093 ls(); 01094 break; 01095 01096 case SH_CAT: 01097 sh_cat(CMD_ARG); 01098 break; 01099 01100 case SH_CD: 01101 sh_cd(CMD_ARG); 01102 break; 01103 01104 case SH_RM: 01105 sh_rm(CMD_ARG); 01106 break; 01107 01108 case SH_PS: 01109 sh_ps(); 01110 break; 01111 01112 case SH_KILL: 01113 sh_kill(CMD_ARG); 01114 break; 01115 01116 case SH_RS232: 01117 rs232_chat(CMD_ARG); 01118 break; 01119 01120 case SH_PCISCAN: 01121 pci_scan(); 01122 break; 01123 01124 case SH_RTL8139_INIT: 01125 ifconfig(CMD_ARG); 01126 break; 01127 01128 case SH_ETH_PING: 01129 ping(CMD_ARG); 01130 break; 01131 01132 case SH_ETH_ARP: 01133 arp_request(CMD_ARG); 01134 break; 01135 01136 case SH_HALT: 01137 sh_halt(); 01138 break; 01139 01140 case SH_ELF: 01141 sh_elf(CMD_ARG); 01142 break; 01143 01144 // **************** Luca Giovacchini (Ide) **************** 01145 case SH_IDETEST: 01146 Sh_IdeTest(); 01147 break; 01148 case SH_IDEREAD: 01149 Sh_IdeRead(); 01150 break; 01151 case SH_IDEWRITE: 01152 Sh_IdeWrite(); 01153 break; 01154 case SH_IDEDEVICEINFO: 01155 Sh_IdeDeviceInfo(); 01156 break; 01157 // ******************************************************** 01158 01159 // ******************** Filippo Brogi ********************* 01160 case SH_LS_EXT2: 01161 ls_ext2(); 01162 break; 01163 01164 case SH_CD_EXT2: 01165 sh_cd2(CMD_ARG); 01166 break; 01167 01168 case SH_CAT_EXT2: 01169 sh_cat2(CMD_ARG); 01170 break; 01171 // ******************************************************** 01172 01173 case SH_TIME: 01174 kprintf("\r%u\n\r", time_read()); 01175 break; 01176 } 01177 } 01178 } |