mahatma.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 <analog.h>
  33. //#include <temperature.h>
  34. /* local includes */
  35. #include "msg-output.h"
  36. #include "serial.h"
  37. #include "traps.h"
  38. #include "gui.h"
  39. #include "msg.h"
  40. #include "touchscreen.h"
  41. #include "gpio.h"
  42. #include "gui.h"
  43. #define VERSION "0.1"
  44. static FATFS fatfs;
  45. __attribute ((noreturn))
  46. int main(void)
  47. {
  48. // set the initial stack and data pointers
  49. asm volatile (
  50. "\txld.w\t%r15, __MAIN_STACK\n"
  51. "\tld.w\t%sp, %r15\n"
  52. "\txld.w\t%r15, __dp\n"
  53. "\tld.w\t%r4, 0\n"
  54. "\tld.w\t%psr, %r4\n"
  55. );
  56. // critical first initialisation
  57. traps_init();
  58. Tick_initialise();
  59. Analog_initialise();
  60. //Temperature_initialise();
  61. msg_init();
  62. // start of normal initialisation
  63. // eanything below here can use debug outputs
  64. msg(MSG_INFO, "Starting\n");
  65. // initialise remainder of I/O
  66. gpio_init();
  67. touchscreen_init();
  68. fb_init();
  69. // set up memory manager before remaining initialisation
  70. malloc_init_simple();
  71. if (f_mount(0, &fatfs) != FR_OK)
  72. msg(MSG_INFO, "unable to mount FAT filesystem!\n");
  73. wikilib_init();
  74. //guilib_init();
  75. profile_init();
  76. // initialisation complete
  77. msg(MSG_INFO, "Mahatma super slim kernel v%s\n", VERSION);
  78. // the next function will loop forever and call wl_input_wait()
  79. for (;;) {
  80. wikilib_run();
  81. }
  82. }