summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/leon/startup/boardinit.S
blob: 2c6f6b8ce086c4e074eca9ea3c8dabca9e0fe744 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 *  boardinit.s
 *
 *  Start code for the LEON.
 *
 *  $Id$
 */

#include <rtems/asm.h>
#include <leon.h>

	.global __bsp_board_init

__bsp_board_init:

/* Check if LEON is initialised. If not, this means that we are
   running on the simulator. Initiate some of the parameters
   that are done by the boot-prom otherwise.
*/

        set     SYM(LEON_REG), %l0  	! %l0 = base address of peripherals
	ld	[%l0+LEON_REG_CACHECTRL_OFFSET], %l1 ! Check if LEON has been initialised
	andcc	%l1, 3, %g0
	bne	2f
	nop

	flush
	set	0x1000f, %l1
	st      %l1, [%l0 + LEON_REG_CACHECTRL_OFFSET]     ! enable caches
	ld      [%l0 + LEON_REG_SIM_ROM_SIZE_OFFSET], %g1  ! load simulator rom size
	clr	%l2
	srl	%g1, 13, %g1		! calculate appropriate rom size
1:
	srl	%g1, 1, %g1
	tst	%g1
	bne,a	1b
	inc	%l2
	sll	%l2, 14, %l2
	st	%l2, [%l0 + LEON_REG_MEMCFG1_OFFSET] ! set prom size in memcfg1

	set	0, %l2
	ld      [%l0 + LEON_REG_SIM_RAM_SIZE_OFFSET], %g2 ! load simulator ram size
	srl	%g2, 13, %g1		! calculate appropriate ram size
1:
	srl	%g1, 1, %g1
	tst	%g1
	bne,a	1b
	inc	%l2
	sll	%l2, 9, %l2
	or	%l2, 0x20, %l2	! set 32-bit ram width by default
	st	%l2, [%l0 + LEON_REG_MEMCFG2_OFFSET] ! set ram size in memcfg2

	set	SYM(RAM_START), %l1  ! Cannot use RAM_END due to bug in linker
	set	SYM(RAM_SIZE), %l2
	add	%l1, %l2, %sp
	set	49, %l2
	st	%l2, [%l0 + LEON_REG_SCALER_LOAD_OFFSET] ! scaler reload register
	st	%l2, [%l0 + LEON_REG_SCALERCNT_OFFSET] ! scaler counter register

2:
	retl
	nop

/* end of file */