My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

start_c.c 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /******************************************************************************
  2. * The MIT License
  3. *
  4. * Copyright (c) 2011 LeafLabs, LLC.
  5. *
  6. * Permission is hereby granted, free of charge, to any person
  7. * obtaining a copy of this software and associated documentation
  8. * files (the "Software"), to deal in the Software without
  9. * restriction, including without limitation the rights to use, copy,
  10. * modify, merge, publish, distribute, sublicense, and/or sell copies
  11. * of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  21. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  22. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. * SOFTWARE.
  25. *****************************************************************************/
  26. /*
  27. * This file is a modified version of a file obtained from
  28. * CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the
  29. * following text appeared:
  30. *
  31. * Copyright (c) 2006, 2007 CodeSourcery Inc
  32. *
  33. * The authors hereby grant permission to use, copy, modify, distribute,
  34. * and license this software and its documentation for any purpose, provided
  35. * that existing copyright notices are retained in all copies and that this
  36. * notice is included verbatim in any distributions. No written agreement,
  37. * license, or royalty fee is required for any of the authorized uses.
  38. * Modifications to this software may be copyrighted by their authors
  39. * and need not follow the licensing terms described here, provided that
  40. * the new terms are clearly indicated on the first page of each file where
  41. * they apply.
  42. */
  43. #include <stddef.h>
  44. extern void __libc_init_array(void);
  45. extern int main(int, char**, char**);
  46. extern void exit(int) __attribute__((noreturn, weak));
  47. /* The linker must ensure that these are at least 4-byte aligned. */
  48. extern char __data_start__, __data_end__;
  49. extern char __bss_start__, __bss_end__;
  50. struct rom_img_cfg {
  51. int *img_start;
  52. };
  53. extern char _lm_rom_img_cfgp;
  54. void __attribute__((noreturn)) start_c(void) {
  55. struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp;
  56. int *src = img_cfg->img_start;
  57. int *dst = (int*)&__data_start__;
  58. int exit_code;
  59. /* Initialize .data, if necessary. */
  60. if (src != dst) {
  61. int *end = (int*)&__data_end__;
  62. while (dst < end) {
  63. *dst++ = *src++;
  64. }
  65. }
  66. /* Zero .bss. */
  67. dst = (int*)&__bss_start__;
  68. while (dst < (int*)&__bss_end__) {
  69. *dst++ = 0;
  70. }
  71. /* Run initializers. */
  72. __libc_init_array();
  73. /* Jump to main. */
  74. exit_code = main(0, 0, 0);
  75. if (exit) {
  76. exit(exit_code);
  77. }
  78. /* If exit is NULL, make sure we don't return. */
  79. for (;;)
  80. continue;
  81. }