mahatma.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * main program entry point
  3. *
  4. * Copyright (c) 2009 Openmoko Inc.
  5. *
  6. * Authors Daniel Mack <daniel@caiaq.de>
  7. * Christopher Hall <hsw@openmoko.com>
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /* wikilib and guilib includes */
  23. #include <guilib.h>
  24. #include <wikilib.h>
  25. #include <input.h>
  26. #include <stdlib.h>
  27. #include <malloc-simple.h>
  28. #include <tff.h>
  29. #include <regs.h>
  30. #include <profile.h>
  31. #include <tick.h>
  32. #include <suspend.h>
  33. #include <analog.h>
  34. //#include <temperature.h>
  35. /* local includes */
  36. #include "msg-output.h"
  37. #include "serial.h"
  38. #include "traps.h"
  39. #include "gui.h"
  40. #include "msg.h"
  41. #include "touchscreen.h"
  42. #include "gpio.h"
  43. #include "gui.h"
  44. #define VERSION "0.2"
  45. static FATFS fatfs;
  46. __attribute ((noreturn))
  47. int main(void)
  48. {
  49. // set the initial stack and data pointers
  50. asm volatile (
  51. "\txld.w\t%r15, __MAIN_STACK\n"
  52. "\tld.w\t%sp, %r15\n"
  53. "\txld.w\t%r15, __dp\n"
  54. "\tld.w\t%r4, 0\n"
  55. "\tld.w\t%psr, %r4\n"
  56. );
  57. // critical first initialisation
  58. Suspend_initialise(); // set up clocks so must be first
  59. traps_init(); // set up vectors so must be second
  60. // other high priority initialisation
  61. Tick_initialise();
  62. Analog_initialise();
  63. //Temperature_initialise();
  64. msg_init();
  65. // start of normal initialisation
  66. // anything below here can use debug outputs
  67. msg(MSG_INFO, "Starting\n");
  68. // initialise remainder of I/O
  69. gpio_init();
  70. touchscreen_init();
  71. fb_init();
  72. // set up memory manager before remaining initialisation
  73. malloc_init_simple();
  74. if (f_mount(0, &fatfs) != FR_OK)
  75. msg(MSG_INFO, "unable to mount FAT filesystem!\n");
  76. wikilib_init();
  77. //guilib_init();
  78. profile_init();
  79. // initialisation complete
  80. msg(MSG_INFO, "Mahatma super slim kernel v%s\n", VERSION);
  81. // the next function will loop forever and call wl_input_wait()
  82. for (;;) {
  83. wikilib_run();
  84. }
  85. }