main.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * main.c
  3. *
  4. * System initialisation and navigation main loop.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. int EXC_reset(void) __attribute__((alias("main")));
  12. static void canary_init(void)
  13. {
  14. _irq_stackbottom[0] = _thread_stackbottom[0] = 0xdeadbeef;
  15. }
  16. static void canary_check(void)
  17. {
  18. ASSERT(_irq_stackbottom[0] == 0xdeadbeef);
  19. ASSERT(_thread_stackbottom[0] == 0xdeadbeef);
  20. }
  21. int main(void)
  22. {
  23. /* Relocate DATA. Initialise BSS. */
  24. if (_sdat != _ldat)
  25. memcpy(_sdat, _ldat, _edat-_sdat);
  26. memset(_sbss, 0, _ebss-_sbss);
  27. canary_init();
  28. stm32_init();
  29. time_init();
  30. console_init();
  31. console_crash_on_input();
  32. board_init();
  33. printk("\n** Greaseweazle v%u.%u\n", fw_major, fw_minor);
  34. printk("** Keir Fraser <keir.xen@gmail.com>\n");
  35. printk("** https://github.com/keirf/Greaseweazle\n\n");
  36. floppy_init();
  37. usb_init();
  38. for (;;) {
  39. canary_check();
  40. usb_process();
  41. floppy_process();
  42. }
  43. return 0;
  44. }
  45. /*
  46. * Local variables:
  47. * mode: C
  48. * c-file-style: "Linux"
  49. * c-basic-offset: 4
  50. * tab-width: 4
  51. * indent-tabs-mode: nil
  52. * End:
  53. */