head-de2.S 1.6 KB

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