finsh_init.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Initialization procedure for finsh shell.
  3. *
  4. * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
  5. *
  6. * This file is part of RT-Thread (http://www.rt-thread.org)
  7. * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  24. *
  25. * Change Logs:
  26. * Date Author Notes
  27. * 2010-03-22 Bernard first version
  28. */
  29. #include <finsh.h>
  30. #include "finsh_node.h"
  31. #include "finsh_vm.h"
  32. #include "finsh_parser.h"
  33. #include "finsh_var.h"
  34. #include "finsh_error.h"
  35. #include "finsh_heap.h"
  36. int finsh_init(struct finsh_parser* parser)
  37. {
  38. finsh_parser_init(parser);
  39. /* finsh init */
  40. finsh_node_init();
  41. finsh_var_init();
  42. finsh_error_init();
  43. finsh_heap_init();
  44. return 0;
  45. }
  46. long finsh_stack_bottom()
  47. {
  48. return finsh_vm_stack[0].long_value;
  49. }
  50. int finsh_flush(struct finsh_parser* parser)
  51. {
  52. finsh_parser_init(parser);
  53. /* finsh init */
  54. finsh_node_init();
  55. finsh_error_init();
  56. return 0;
  57. }
  58. int finsh_reset(struct finsh_parser* parser)
  59. {
  60. /* finsh init */
  61. finsh_node_init();
  62. finsh_var_init();
  63. finsh_error_init();
  64. finsh_heap_init();
  65. return 0;
  66. }