head-de2.S 1.8 KB

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