^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <asm/entry.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/contregs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/sun3-head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) PSL_HIGHIPL = 0x2700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) NBSG = 0x20000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) ICACHE_ONLY = 0x00000009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) CACHES_OFF = 0x00000008 | actually a clear and disable --m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define MAS_STACK INT_STACK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) ROOT_TABLE_SIZE = 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) PAGESIZE = 8192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) SUN3_INVALID_PMEG = 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .globl bootup_user_stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) .globl bootup_kernel_stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) .globl pg0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) .globl swapper_pg_dir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .globl kernel_pmd_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) .globl availmem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) .global m68k_pgtable_cachemode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) .global kpt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) | todo: all these should be in bss!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) swapper_pg_dir: .skip 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) pg0: .skip 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) kernel_pmd_table: .skip 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) .globl kernel_pg_dir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .equ kernel_pg_dir,kernel_pmd_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __HEAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) ENTRY(_stext)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ENTRY(_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* Firstly, disable interrupts and set up function codes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) movew #PSL_HIGHIPL, %sr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) moveq #FC_CONTROL, %d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) movec %d0, %sfc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) movec %d0, %dfc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* Make sure we're in context zero. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) moveq #0, %d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) movsb %d0, AC_CONTEXT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* map everything the bootloader left us into high memory, clean up the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) excess later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) lea (AC_SEGMAP+0),%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) lea (AC_SEGMAP+KERNBASE),%a1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) movsb %a0@, %d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) movsb %d1, %a1@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) cmpib #SUN3_INVALID_PMEG, %d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) beq 2f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) addl #NBSG,%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) addl #NBSG,%a1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) jmp 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* Disable caches and jump to high code. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) moveq #ICACHE_ONLY,%d0 | Cache disabled until we're ready to enable it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) movc %d0, %cacr | is this the right value? (yes --m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) jmp 1f:l
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* Following code executes at high addresses (0xE000xxx). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 1: lea init_task,%curptr | get initial thread...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) lea init_thread_union+THREAD_SIZE,%sp | ...and its stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /* Point MSP at an invalid page to trap if it's used. --m */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) movl #(PAGESIZE),%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) movc %d0,%msp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) moveq #-1,%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) movsb %d0,(AC_SEGMAP+0x0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) jbsr sun3_init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) jbsr base_trap_init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) jbsr start_kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) trap #15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .even
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) kpt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .long 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) availmem:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .long 0