head-de2.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #if defined(CONFIG_RAM32MB)
  2. #define MEM_END 0x02000000 /* Memory size 32Mb */
  3. #elif defined(CONFIG_RAM16MB)
  4. #define MEM_END 0x01000000 /* Memory size 16Mb */
  5. #else
  6. #define MEM_END 0x00800000 /* Memory size 8Mb */
  7. #endif
  8. #undef CRT_DEBUG
  9. .macro PUTC CHAR
  10. #ifdef CRT_DEBUG
  11. moveq #\CHAR, %d7
  12. jsr putc
  13. #endif
  14. .endm
  15. .global _start
  16. .global _rambase
  17. .global _ramvec
  18. .global _ramstart
  19. .global _ramend
  20. .data
  21. /*
  22. * Set up the usable of RAM stuff
  23. */
  24. _rambase:
  25. .long 0
  26. _ramvec:
  27. .long 0
  28. _ramstart:
  29. .long 0
  30. _ramend:
  31. .long 0
  32. .text
  33. _start:
  34. /*
  35. * Setup initial stack
  36. */
  37. /* disable all interrupts */
  38. movew #0x2700, %sr
  39. movel #-1, 0xfffff304
  40. movel #MEM_END-4, %sp
  41. PUTC '\r'
  42. PUTC '\n'
  43. PUTC 'A'
  44. PUTC 'B'
  45. /*
  46. * Determine end of RAM
  47. */
  48. movel #MEM_END, %a0
  49. movel %a0, _ramend
  50. PUTC 'C'
  51. /*
  52. * Move ROM filesystem above bss :-)
  53. */
  54. moveal #_sbss, %a0 /* romfs at the start of bss */
  55. moveal #_ebss, %a1 /* Set up destination */
  56. movel %a0, %a2 /* Copy of bss start */
  57. movel 8(%a0), %d1 /* Get size of ROMFS */
  58. addql #8, %d1 /* Allow for rounding */
  59. andl #0xfffffffc, %d1 /* Whole words */
  60. addl %d1, %a0 /* Copy from end */
  61. addl %d1, %a1 /* Copy from end */
  62. movel %a1, _ramstart /* Set start of ram */
  63. 1:
  64. movel -(%a0), %d0 /* Copy dword */
  65. movel %d0, -(%a1)
  66. cmpl %a0, %a2 /* Check if at end */
  67. bne 1b
  68. PUTC 'D'
  69. /*
  70. * Initialize BSS segment to 0
  71. */
  72. lea _sbss, %a0
  73. lea _ebss, %a1
  74. /* Copy 0 to %a0 until %a0 == %a1 */
  75. 2: cmpal %a0, %a1
  76. beq 1f
  77. clrl (%a0)+
  78. bra 2b
  79. 1:
  80. PUTC 'E'
  81. /*
  82. * Load the current task pointer and stack
  83. */
  84. lea init_thread_union, %a0
  85. lea 0x2000(%a0), %sp
  86. PUTC 'F'
  87. PUTC '\r'
  88. PUTC '\n'
  89. /*
  90. * Go
  91. */
  92. jmp start_kernel
  93. /*
  94. * Local functions
  95. */
  96. #ifdef CRT_DEBUG
  97. putc:
  98. moveb %d7, 0xfffff907
  99. 1:
  100. movew 0xfffff906, %d7
  101. andw #0x2000, %d7
  102. beq 1b
  103. rts
  104. #endif