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