nutentry.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ;***************************************************************************
  2. ; KPIT Cummins Infosystems Ltd, Pune, India. - 7th July 2003.
  3. ;
  4. ; This program is distributed in the hope that it will be useful,
  5. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  6. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
  7. ;
  8. ; Adapted to Nut/OS by Jan Dubiec <jdx@slackware.pl>
  9. ;
  10. ;***************************************************************************
  11. ;
  12. ; System initialisation routine - entry point for the application.
  13. ; The stack pointer is initialised, then the hardware initialisation
  14. ; routine called. If needed, the .text section is copied into RAM
  15. ; and then the static data areas are initialised, before the main
  16. ; function is executed. A simple exit funtion is also supplied.
  17. ;
  18. ;****************************************************************************
  19. .h8300h
  20. .section .init
  21. .global _NutEntry
  22. .global _NutExit
  23. .extern _NutHWInit
  24. .extern _NutInit
  25. .extern ___data_start
  26. .extern ___data_end
  27. .extern ___bss_start
  28. .extern ___bss_end
  29. .extern ___mdata_end
  30. .extern ___stack
  31. _NutEntry:
  32. ; initialise the stack pointer
  33. mov.l #___stack, er7
  34. ; disable interrupts
  35. orc.b #0xc0, ccr
  36. ; call the hardware initialisation routine
  37. jsr @_NutHWInit
  38. #ifdef NUTDEBUG
  39. ; clear the whole internal RAM
  40. mov.l #4, er3 ; double word chunks
  41. mov.l #0, er2
  42. mov.l #0xffff20, er1 ; end of RAM
  43. mov.l #0xffbf20, er0 ; beginning of RAM
  44. cmp.l er0, er1
  45. beq start_c2
  46. start_c1:
  47. mov.l er2, @er0
  48. add.l er3, er0
  49. cmp.l er0, er1 ; dest == edata?
  50. bne start_c1
  51. start_c2:
  52. #endif
  53. #ifdef ROMSTART
  54. #ifdef TEXT_IN_RAM /* program code should executed run from RAM*/
  55. ; get the boundaries for the .text and .data section initialisation
  56. mov.l #___text_start, er0; source start address
  57. #else
  58. ; get the boundaries for the .data section initialisation
  59. mov.l #___data_start, er0; source start address
  60. #endif /* TEXT_IN_RAM */
  61. mov.l #___data_end, er1 ; source end address
  62. mov.l #___mdata_end, er2; destination address; see linker script
  63. cmp.l er0,er1
  64. beq start_1
  65. start_l:
  66. mov.b @er2, r3l ; get from src
  67. mov.b r3l, @er0 ; place in dest
  68. inc.l #1, er2 ; inc src
  69. inc.l #1, er0 ; inc dest
  70. cmp.l er0, er1 ; dest == edata?
  71. bne start_l
  72. start_1:
  73. #endif /* ROMSTART */
  74. ; zero out .bss section
  75. mov.l #___bss_start, er0
  76. mov.l #___bss_end, er1
  77. cmp.l er0, er1
  78. beq start_3
  79. sub.b r2l, r2l
  80. start_2:
  81. mov.b r2l, @er0
  82. inc.l #1, er0
  83. cmp.l er0, er1
  84. bne start_2
  85. start_3:
  86. ; enable interrupts
  87. andc.b #0x3f, ccr
  88. ; start Nut/OS
  89. jsr @_NutInit
  90. ; jump to exit
  91. mov.l er0, er4
  92. jmp @_NutExit
  93. _NutExit:
  94. nop
  95. bra _NutExit