You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmdline.c 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include <console.h>
  2. #include "etherboot.h"
  3. #include "cmdline.h"
  4. #include "cmdlinelib.h"
  5. #include "cmdlist.h"
  6. #define CMDL_DELAY (2000 * TICKS_PER_SEC) / 1000;
  7. void cmdl_exec_cmdline();
  8. char cmdl_spin();
  9. void cmdl_start()
  10. {
  11. unsigned int stop;
  12. //int spin;
  13. //printf("gPXE %s (GPL) etherboot.org ... ", VERSION);
  14. printf("gPXE %s (GPL) etherboot.org\n", VERSION);
  15. stop = currticks() + CMDL_DELAY;
  16. while(currticks() < stop){
  17. /*if(spin++ % 250 == 0){
  18. putchar(8);
  19. putchar(cmdl_spin());
  20. }*/
  21. if(iskey()){
  22. if(getchar() == 2){
  23. putchar('\n');
  24. cmdl_exec_cmdline();
  25. break;
  26. }else{
  27. putchar('\n');
  28. printf("Skipping command line.\n");
  29. break;
  30. }
  31. }
  32. }
  33. putchar('\n');
  34. // empty the input buffer
  35. while(iskey()) {
  36. getchar();
  37. }
  38. }
  39. /*char cmdl_spin()
  40. {
  41. static int state;*/
  42. //int spinner[4] = {'-', '\\', '|', '/'}; <- undefined reference to memcpy!
  43. /* int spinner[4];
  44. spinner[0] = '-';
  45. spinner[1] = '\\';
  46. spinner[2] = '|';
  47. spinner[3] = '/';
  48. return spinner[state++ % 4];
  49. }*/
  50. void cmdl_exec_cmdline(){
  51. cmd_line* cmd;
  52. cmd = cmdl_create();
  53. cmdl_setputchar(cmd, putchar);
  54. cmdl_setgetchar(cmd, getchar);
  55. cmdl_setprintf(cmd, printf);
  56. cmdl_setpropmt(cmd, "gPXE>");
  57. printf("Welcome to Etherboot\n\n");
  58. cmdl_enterloop(cmd);
  59. cmdl_free(cmd);
  60. }