Go to the source code of this file.
Data Structures | |
| struct | SHELL_CONTROL |
Functions | |
| void | ShellInit (void) |
| void | ShellSvc (void) |
| bool | ShellStatusCheck (void) |
| void | ShellArgumentInitial (void) |
| void | ShellArgumentSvc (void) |
| void | ShellArgumentParser (void) |
| void | ShellArgumentExecute (U8 **Argv, U8 Argc) |
| U8 | ShellArgumentCheck (void) |
| void | ShellArgumentReset (void) |
| void | ShellArgumentReceive (U8 **Argv, U8 Argc) |
| bool | ShellArgumentBs (void) |
| void | ShellArgumentDel (void) |
| void | ShellArgumentKeyPut (U8) |
| void | ShellArgumentIns (void) |
| void | ShellArgumentHome (void) |
| void | ShellArgumentEnd (void) |
| void | ShellArgumentPageUp (void) |
| void | ShellArgumentPageDown (void) |
| void | ShellArgumentArrowUp (void) |
| void | ShellArgumentArrowDown (void) |
| void | ShellArgumentArrowLeft (void) |
| void | ShellArgumentArrowRight (void) |
| void | ShellDump (void) |
Variables | |
| SHELL_CONTROL | ShellCtrl |
| void ShellArgumentArrowDown | ( | void | ) |
| void ShellArgumentArrowLeft | ( | void | ) |
| void ShellArgumentArrowRight | ( | void | ) |
| void ShellArgumentArrowUp | ( | void | ) |
| bool ShellArgumentBs | ( | void | ) |
Definition at line 511 of file shell.c.
00511 { 00512 if(ArgumentCtrl.Put==0) return false; 00513 else{ 00514 ArgumentCtrl.Put--; 00515 return true; 00516 } 00517 }
| U8 ShellArgumentCheck | ( | void | ) |
Definition at line 500 of file shell.c.
00500 { 00501 if(ArgumentCtrl.HasInput==true) return true; 00502 else return false; 00503 }
| void ShellArgumentDel | ( | void | ) |
| void ShellArgumentEnd | ( | void | ) |
| void ShellArgumentHome | ( | void | ) |
| void ShellArgumentInitial | ( | void | ) |
Definition at line 288 of file shell.c.
00288 { 00289 ArgumentCtrl.Put=0; 00290 ArgumentCtrl.Insert=false; 00291 ArgumentCtrl.Argc=0; 00292 ArgumentCtrl.Status=0; 00293 ArgumentCtrl.HasInput=false; 00294 ArgumentCtrl.State=ArgumentRxState; 00295 }
| void ShellArgumentIns | ( | void | ) |
| void ShellArgumentKeyPut | ( | U8 | ) |
Definition at line 519 of file shell.c.
00519 { 00520 if(ArgumentCtrl.Put<(ARGUMENT_INDEX_MAX-1)){ 00521 ArgumentCtrl.Data[ArgumentCtrl.Put]=Data; 00522 ArgumentCtrl.Put++; 00523 } 00524 }
| void ShellArgumentPageDown | ( | void | ) |
| void ShellArgumentPageUp | ( | void | ) |
| void ShellArgumentParser | ( | void | ) |
Definition at line 453 of file shell.c.
00453 { 00454 U8 Index; 00455 U8 State; 00456 U8 Status; 00457 00458 Index=0; 00459 Status=0; 00460 ArgumentCtrl.Argc=0; 00461 State=ArgumentSearchState; 00462 while(1){ 00463 switch(State){ 00464 case ArgumentSearchState: 00465 if(ArgumentCtrl.Data[Index]==ASCII_SP){;} 00466 else if(ArgumentCtrl.Data[Index]==ASCII_CR){ 00467 ArgumentCtrl.Data[Index]=0; 00468 ArgumentCtrl.Data[Index+1]=ASCII_CR; 00469 State=ArgumentDoneState; 00470 } 00471 else{ 00472 ArgumentCtrl.pArgv[ArgumentCtrl.Argc]=&ArgumentCtrl.Data[Index]; 00473 ArgumentCtrl.Argc++; 00474 State=ArgumentGoThroughState; 00475 } 00476 break; 00477 case ArgumentGoThroughState: 00478 if(ArgumentCtrl.Data[Index]==ASCII_CR){ 00479 ArgumentCtrl.Data[Index]=0; 00480 ArgumentCtrl.Data[Index+1]=ASCII_CR; 00481 State=ArgumentDoneState; 00482 } 00483 else if(ArgumentCtrl.Data[Index]==ASCII_SP){ 00484 ArgumentCtrl.Data[Index]=0; 00485 State=ArgumentSearchState; 00486 } 00487 break; 00488 case ArgumentDoneState: 00489 if(ArgumentCtrl.Put==ARGUMENT_INDEX_MAX){ 00490 ShellArgumentReset(); 00491 return; 00492 } 00493 ArgumentCtrl.HasInput=true; 00494 return; 00495 } 00496 Index++; 00497 } 00498 }
| void ShellArgumentReset | ( | void | ) |
Definition at line 505 of file shell.c.
00505 { 00506 ArgumentCtrl.Put=0; 00507 ArgumentCtrl.Argc=0; 00508 ArgumentCtrl.HasInput=false; 00509 }
| void ShellArgumentSvc | ( | void | ) |
Definition at line 297 of file shell.c.
00297 { 00298 U8 Data; 00299 00300 //if(KeyboardKeyBufferCheck()==BUFFER_EMPTY) return; 00301 //while(KeyboardKeyBufferCheck()==BUFFER_EMPTY) OsYield(); 00302 while(KeyboardKeyBufferCheck()==BUFFER_EMPTY) OsEventWait(&KeyboardCtrl.KeyboardEvent,0xffff); 00303 Data=KeyboardKeyBufferGet(); 00304 if(Data>=0x80){ 00305 switch(Data){ 00306 case KB_SPECIAL_F1_KEY: 00307 case KB_SPECIAL_F2_KEY: 00308 case KB_SPECIAL_F3_KEY: 00309 case KB_SPECIAL_F4_KEY: 00310 case KB_SPECIAL_F5_KEY: 00311 case KB_SPECIAL_F6_KEY: 00312 case KB_SPECIAL_F7_KEY: 00313 case KB_SPECIAL_F8_KEY: 00314 case KB_SPECIAL_F9_KEY: 00315 case KB_SPECIAL_F10_KEY: 00316 case KB_SPECIAL_F11_KEY: 00317 case KB_SPECIAL_F12_KEY: 00318 case KB_SPECIAL_PRTSCR_KEY: 00319 break; 00320 case KB_SPECIAL_SCROLL_LOCK_KEY: 00321 if(KeyboardCtrl.LedChange=true){ 00322 KeyboardSetLed(); 00323 KeyboardCtrl.LedChange=false; 00324 } 00325 break; 00326 case KB_SPECIAL_PAUSE_BREAK_KEY: 00327 case KB_SPECIAL_TAB_KEY: 00328 case KB_SPECIAL_SHIFT_AT_LEFT_KEY: 00329 case KB_SPECIAL_SHIFT_AT_RIGHT_KEY: 00330 case KB_SPECIAL_CTRL_AT_LEFT_KEY: 00331 case KB_SPECIAL_CTRL_AT_RIGHT_KEY: 00332 case KB_SPECIAL_WINDOW_AT_LEFT_KEY: 00333 case KB_SPECIAL_WINDOW_AT_RIGHT_KEY: 00334 case KB_SPECIAL_ATL_AT_LEFT_KEY: 00335 case KB_SPECIAL_ATL_AT_RIGHT_KEY: 00336 case KB_SPECIAL_MENUS_KEY: 00337 case KB_SPECIAL_INSERT_KEY: 00338 case KB_SPECIAL_HOME_KEY: 00339 case KB_SPECIAL_PAGE_DOWN_KEY: 00340 case KB_SPECIAL_END_KEY: 00341 case KB_SPECIAL_PAGE_UP_KEY: 00342 break; 00343 case KB_SPECIAL_CAP_LOCK_KEY: 00344 if(KeyboardCtrl.LedChange=true){ 00345 KeyboardSetLed(); 00346 KeyboardCtrl.LedChange=false; 00347 } 00348 break; 00349 case KB_SPECIAL_UP_ARROW_KEY: 00350 case KB_SPECIAL_LEFT_ARROW_KEY: 00351 case KB_SPECIAL_DOWN_ARROW_KEY: 00352 case KB_SPECIAL_RIGHT_ARROW_KEY: 00353 break; 00354 case KB_SPECIAL_NUM_LOCK_KEY: 00355 if(KeyboardCtrl.LedChange=true){ 00356 KeyboardSetLed(); 00357 KeyboardCtrl.LedChange=false; 00358 } 00359 break; 00360 case KB_SPECIAL_INS: 00361 default: 00362 break; 00363 } 00364 } 00365 else{ 00366 switch(Data){ 00367 case ASCII_NUL: // ^@ 00368 break; 00369 case ASCII_SOH: // ^A 00370 break; 00371 case ASCII_STX: // ^B 00372 break; 00373 case ASCII_ETX: // ^C 00374 break; 00375 case ASCII_EOT: // ^D 00376 break; 00377 case ASCII_ENQ: // ^E 00378 break; 00379 case ASCII_ACK: // ^F 00380 break; 00381 case ASCII_BEL: // ^G 00382 break; 00383 case ASCII_BS: // ^H 00384 if(ShellArgumentBs()==true){ 00385 GuiBackSpace(); 00386 } 00387 break; 00388 case ASCII_HT: // ^I 00389 break; 00390 case ASCII_LF: // ^J 00391 break; 00392 case ASCII_VT: // ^K 00393 break; 00394 case ASCII_FF: // ^L 00395 break; 00396 case ASCII_CR: // ^M 00397 ShellArgumentKeyPut(Data); 00398 ShellArgumentParser(); 00399 break; 00400 case ASCII_SO: // ^N 00401 break; 00402 case ASCII_SI: // ^O 00403 break; 00404 case ASCII_DLE: // ^P 00405 break; 00406 case ASCII_DC1: // ^Q 00407 break; 00408 case ASCII_DC2: // ^R 00409 break; 00410 case ASCII_DC3: // ^S 00411 break; 00412 case ASCII_DC4: // ^T 00413 break; 00414 case ASCII_NAK: // ^U 00415 break; 00416 case ASCII_SYN: // ^V 00417 break; 00418 case ASCII_ETB: // ^W 00419 break; 00420 case ASCII_CAN: // ^X 00421 break; 00422 case ASCII_EM: // ^Y 00423 break; 00424 case ASCII_SUB: // ^Z 00425 break; 00426 case ASCII_ESC: // ^[ 00427 break; 00428 case ASCII_FS: /* ^\ */ 00429 break; 00430 case ASCII_GS: // ^] 00431 break; 00432 case ASCII_RS: // ^^ 00433 break; 00434 case ASCII_US: // ^_ 00435 break; 00436 case ASCII_DEL: // 00437 //ShellArgumentDel(); 00438 break; 00439 default: 00440 if((Data>=0x20)&&(Data<=0x7e)){ 00441 GuiCharPrint(Data); 00442 ShellArgumentKeyPut(Data); 00443 } 00444 break; 00445 } 00446 } 00447 }
| void ShellDump | ( | void | ) |
| void ShellInit | ( | void | ) |
Definition at line 81 of file shell.c.
00081 { 00082 ShellCtrl.State=ShellInitialState; 00083 ShellCtrl.Timer=0; 00084 ShellArgumentInitial(); 00085 }
| bool ShellStatusCheck | ( | void | ) |
Definition at line 283 of file shell.c.
00283 { 00284 if(ShellCtrl.State>=ShellWaitCommandState) return true; 00285 else return false; 00286 }
| void ShellSvc | ( | void | ) |
Definition at line 87 of file shell.c.
00087 { 00088 U8 i; 00089 U8 Argc; 00090 U8 *pData; 00091 U8 **ppArgv; // pointer of pArgv 00092 void (*GotoStart)(void); 00093 OS_TASKENTRY *pOsTask; 00094 00095 switch(ShellCtrl.State){ 00096 case ShellIdleState: 00097 break; 00098 case ShellInitialState: 00099 ShellArgumentInitial(); 00100 GuiStringPrint("\n********************"); 00101 GuiStringPrint("\n Hello, this is FORMOSA."); 00102 GuiStringPrint("\n Version 201003140"); 00103 GuiStringPrint("\n********************"); 00104 GuiStringPrint("\n$"); 00105 ShellCtrl.State=ShellWaitCommandState; 00106 break; 00107 case ShellWaitCommandState: 00108 ShellArgumentSvc(); 00109 if(ShellArgumentCheck()==true) ShellCtrl.State=ShellDispatchState; 00110 break; 00111 case ShellDispatchState: 00112 Argc=ArgumentCtrl.Argc; 00113 ppArgv=(U8 **)&ArgumentCtrl.pArgv; 00114 if(Argc>0){ 00115 for(i=0;;i++){ 00116 if(ShellCommand[i]==(U8 *)0){ 00117 GuiStringPrint("\n'"); 00118 GuiStringPrint(ArgumentCtrl.pArgv[0]); 00119 GuiStringPrint("' command not found"); 00120 break; 00121 } 00122 if(SystemlibStringCompare((U8 *)ArgumentCtrl.pArgv[0],(U8 *)ShellCommand[i])==true){ 00123 ShellCtrl.ExecuteItem=i; 00124 ShellCtrl.ExecuteState=ExecutionStartState; 00125 ShellCtrl.State=ShellExecutionState; 00126 return; 00127 } 00128 } 00129 } 00130 GuiStringPrint("\n$"); 00131 ShellArgumentReset(); 00132 ShellCtrl.State=ShellWaitCommandState; 00133 break; 00134 case ShellExecutionState: 00135 switch(ShellCtrl.ExecuteItem){ 00136 case ItemInfo: 00137 switch(ShellCtrl.ExecuteState){ 00138 case ExecutionStartState: 00139 GuiStringPrint("\n system infomation"); 00140 GuiStringPrint("\n cpu: 80x86"); 00141 GuiStringPrint("\n sdram: 32mb"); 00142 ShellCtrl.ExecuteState=ExecutionStopState; 00143 break; 00144 case ExecutionRunState: 00145 break; 00146 case ExecutionStopState: 00147 ShellCtrl.State=ShellExecutionStopState; 00148 break; 00149 } 00150 break; 00151 case ItemHelp: 00152 switch(ShellCtrl.ExecuteState){ 00153 case ExecutionStartState: 00154 GuiStringPrint("\n command list:"); 00155 GuiStringPrint("\n info"); 00156 GuiStringPrint("\n help"); 00157 ShellCtrl.ExecuteState=ExecutionRunState; 00158 break; 00159 case ExecutionRunState: 00160 ShellCtrl.ExecuteState=ExecutionStopState; 00161 break; 00162 case ExecutionStopState: 00163 ShellCtrl.State=ShellExecutionStopState; 00164 break; 00165 } 00166 break; 00167 case ItemOs: 00168 switch(ShellCtrl.ExecuteState){ 00169 case ExecutionStartState: 00170 GuiStringPrint("\n os dump"); 00171 pOsTask=(OS_TASKENTRY *)OsTaskCurrent; 00172 if(pOsTask!=(OS_TASKENTRY *)0){ 00173 GuiStringPrint("\n OsTaskCurrent"); 00174 GuiStringPrint("\n name:"); 00175 GuiStringPrint(pOsTask->Name); 00176 } 00177 ShellCtrl.ExecuteState=ExecutionRunState; 00178 break; 00179 case ExecutionRunState: 00180 ShellCtrl.ExecuteState=ExecutionStopState; 00181 break; 00182 case ExecutionStopState: 00183 ShellCtrl.State=ShellExecutionStopState; 00184 break; 00185 } 00186 break; 00187 case ItemFdc: 00188 switch(ShellCtrl.ExecuteState){ 00189 case ExecutionStartState: 00190 Fdc1Init(); 00191 Fdc1SeekProcedure(0); 00192 ShellCtrl.ExecuteState=ExecutionRunState; 00193 break; 00194 case ExecutionRunState: 00195 ShellCtrl.ExecuteState=ExecutionStopState; 00196 break; 00197 case ExecutionStopState: 00198 ShellCtrl.State=ShellExecutionStopState; 00199 break; 00200 } 00201 break; 00202 case ItemXmodem: 00203 switch(ShellCtrl.ExecuteState){ 00204 case ExecutionStartState: 00205 Uart1BufferReset(); 00206 XmodemRxStart(); 00207 ShellCtrl.ExecuteState=ExecutionRunState; 00208 break; 00209 case ExecutionRunState: 00210 if(XmodemStatusCheck()!=true) return; 00211 Uart1BufferReset(); 00212 if(XmodemCtrl.ErrorCount!=0) GuiStringPrint("\n xmodem has error"); 00213 GuiStringPrint("\n BlockNumber:"); 00214 GuiU32Print((U32)XmodemCtrl.BlockNumber); 00215 GuiStringPrint("\n TotalBlockCount:"); 00216 GuiU32Print((U32)XmodemCtrl.TotalBlockCount); 00217 GuiStringPrint("\n ByteCount:"); 00218 GuiU32Print((U32)XmodemCtrl.ByteCount); 00219 GuiStringPrint("\n pData:"); 00220 GuiU32Print((U32)XmodemCtrl.pData); 00221 //GuiStringPrint("\n State: %2x ",XmodemCtrl.State); 00222 //GuiU32Print((U32)XmodemCtrl.State); 00223 //GuiStringPrint("\n SubState: %2x ",XmodemCtrl.SubState); 00224 //GuiU32Print((U32)XmodemCtrl.SubState); 00225 GuiStringPrint("\n ErrorCount:"); 00226 GuiU32Print((U32)XmodemCtrl.ErrorCount); 00227 GuiStringPrint("\n ErrorCode:"); 00228 GuiU32Print((U32)XmodemCtrl.ErrorCode); 00229 GuiStringPrint("\n ErrorRecord:"); 00230 GuiU32Print((U32)XmodemCtrl.ErrorRecord); 00231 GuiStringPrint("\n xmodem transfer done"); 00232 ShellCtrl.ExecuteState=ExecutionStopState; 00233 break; 00234 case ExecutionStopState: 00235 ShellCtrl.State=ShellExecutionStopState; 00236 break; 00237 } 00238 break; 00239 case ItemDump: 00240 switch(ShellCtrl.ExecuteState){ 00241 case ExecutionStartState: 00242 SystemlibDumpMemory(IMAGE_ADDRESS,0x60); 00243 ShellCtrl.ExecuteState=ExecutionRunState; 00244 break; 00245 case ExecutionRunState: 00246 ShellCtrl.ExecuteState=ExecutionStopState; 00247 break; 00248 case ExecutionStopState: 00249 ShellCtrl.State=ShellExecutionStopState; 00250 break; 00251 } 00252 break; 00253 case ItemRun: 00254 switch(ShellCtrl.ExecuteState){ 00255 case ExecutionStartState: 00256 GotoStart=(void (*)(void))IMAGE_ADDRESS; 00257 (*GotoStart)(); 00258 ShellCtrl.ExecuteState=ExecutionRunState; 00259 break; 00260 case ExecutionRunState: 00261 ShellCtrl.ExecuteState=ExecutionStopState; 00262 break; 00263 case ExecutionStopState: 00264 ShellCtrl.State=ShellExecutionStopState; 00265 break; 00266 } 00267 break; 00268 default: 00269 ShellCtrl.State=ShellExecutionStopState; 00270 break; 00271 } 00272 break; 00273 case ShellExecutionStopState: 00274 GuiStringPrint("\n$"); 00275 ShellArgumentReset(); 00276 ShellCtrl.State=ShellWaitCommandState; 00277 break; 00278 default: 00279 break; 00280 } 00281 }
1.5.9