Home | History | Annotate | Line # | Download | only in arm
      1 ;	$NetBSD: arm_sa1100_asm.asm,v 1.2 2019/12/15 16:48:25 tsutsui Exp $	
      2 ;
      3 ; Copyright (c) 2001 The NetBSD Foundation, Inc.
      4 ; All rights reserved.
      5 ;
      6 ; This code is derived from software contributed to The NetBSD Foundation
      7 ; by UCHIYAMA Yasushi.
      8 ;
      9 ; Redistribution and use in source and binary forms, with or without
     10 ; modification, are permitted provided that the following conditions
     11 ; are met:
     12 ; 1. Redistributions of source code must retain the above copyright
     13 ;    notice, this list of conditions and the following disclaimer.
     14 ; 2. Redistributions in binary form must reproduce the above copyright
     15 ;    notice, this list of conditions and the following disclaimer in the
     16 ;    documentation and/or other materials provided with the distribution.
     17 ;
     18 ; THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19 ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20 ; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21 ; PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22 ; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24 ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25 ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26 ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27 ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28 ; POSSIBILITY OF SUCH DAMAGE.
     29 ;
     30 
     31 ;
     32 ;armasm.exe $(InputPath)
     33 ;arm.obj
     34 ;
     35 
     36 	AREA	|.text|, CODE, PIC
     37 
     38 	; FlatJump_sa1100 (kaddr_t bootinfo, kaddr_t pvec, kaddr_t stack
     39 	;		kaddr_t jump)
     40 	;	bootinfo	boot information block address.
     41 	;	pvec		page vector of kernel.
     42 	;	stack		physical address of stack
     43 	;	jump		physical address of boot function
     44 	; *** MMU and pipeline behavier are SA-1100 specific. ***
     45 	EXPORT	|FlatJump_sa1100|
     46 |FlatJump_sa1100| PROC
     47 	; disable interrupt
     48 	mrs	r4, cpsr
     49 	orr	r4, r4, #0xc0
     50 	msr	cpsr, r4
     51 	; disable MMU, I/D-Cache, Writebuffer.
     52 	; interrupt vector address is 0xffff0000
     53 	; 32bit exception handler/address range.
     54 	ldr	r4, [pc, #24]
     55 	; Disable WB/Cache/MMU
     56 	mcr	p15, 0, r4, c1, c0, 0
     57 	; Invalidate I/D-cache.
     58 	mcr	p15, 0, r4, c7, c7, 0	; Fetch translated	fetch
     59 	; Invalidate TLB entries.
     60 	mcr	p15, 0, r4, c8, c7, 0	; Fetch translated	decode
     61 	; jump to kernel entry physical address.
     62 	mov	pc, r3			; Fetch translated	execute
     63 	; NOTREACHED
     64 	nop				; Fetch nontranslated	cache access
     65 	nop				; Fetch nontranslated	writeback
     66 	mov	pc, lr			; Fetch nontranslated
     67 	DCD	0x00002030
     68 	ENDP  ; |FlatJump_sa1100|
     69 ;
     70 ;	UART test
     71 ;
     72 	; boot_func (uint32_t mapaddr, uint32_t bootinfo, uint32_t flags)
     73 	;
     74 	EXPORT	|boot_func_sa1100|
     75 |boot_func_sa1100| PROC
     76 	nop				; Cop15 hazard
     77 	nop				; Cop15 hazard
     78 	nop				; Cop15 hazard
     79 	mov	sp, r2			; set bootloader stack
     80 ;	mov	r4, r0
     81 ;	mov	r5, r1
     82 ;	bl	colorbar
     83 ;	mov	r0, r4
     84 ;	mov	r1, r5
     85 	bl	boot_sa1100
     86 	nop	; NOTREACHED
     87 	nop
     88 	ENDP  ; |boot_func_sa1100|
     89 
     90 	EXPORT |colorbar|
     91 |colorbar| PROC
     92 	stmfd	sp!, {r4-r7, lr}
     93 	adr	r4, |$FBADDR|
     94 	ldr	r4, [r4]
     95 
     96 	mov	r7, #8
     97 	add	r0, r0, r7
     98 |color_loop|
     99 	mov	r6, r0
    100 	and	r6, r6, #7
    101 	orr	r6, r6, r6, LSL #8
    102 	orr	r6, r6, r6, LSL #16
    103 	add	r5, r4, #0x9600
    104 |fb_loop|
    105 	str	r6, [r4], #4
    106 	cmp	r4, r5
    107 	blt	|fb_loop|
    108 
    109 	subs	r7, r7, #1
    110 	bne	|color_loop|
    111 
    112 	ldmfd	sp!, {r4-r7, pc}
    113 |$FBADDR|
    114 	DCD	0xc0003000	; use WindowsCE default.
    115 	ENDP  ; |colorbar|
    116 
    117 	EXPORT	|boot_sa1100|
    118 |boot_sa1100| PROC
    119 ;
    120 ;	UART test code
    121 ;
    122 ;	; print boot_info address (r0) and page_vector start address (r1).
    123 ;	mov	r4, r0
    124 ;	mov	r5, r1
    125 ;	mov	r0, #'I'
    126 ;	bl	btputc
    127 ;	mov	r0, r4
    128 ;	bl	hexdump
    129 ;	mov	r0, #'P'
    130 ;	bl	btputc
    131 ;	mov	r0, r5
    132 ;	bl	hexdump
    133 ;	mov	r7, r4
    134 ;	mov	r2, r5		; start
    135 
    136 	mov	r7, r0		; if enabled above debug print, remove this.
    137 	mov	r2, r1		; if enabled above debug print, remove this.
    138 |page_loop|
    139 	mvn	r0, #0		; ~0
    140 	cmp	r2, r0
    141 	beq	|page_end|	; if (next == ~0) goto page_end
    142 
    143 	mov	r1, r2		; p = next
    144 	ldr	r2, [r1]	; next
    145 	ldr	r3, [r1, #4]	; src
    146 	ldr	r4, [r1, #8]	; dst
    147 	ldr	r5, [r1, #12]	; sz
    148 
    149 	cmp	r3, r0
    150 	add	r6, r4, r5	; end address
    151 	bne	|page_memcpy4|	; if (src != ~0) goto page_memcpy4
    152 
    153 	mov	r0, #0
    154 |page_memset|			; memset (dst, 0, sz) uncached.
    155 	str	r0, [r4], #4
    156 	cmp	r4, r6
    157 	blt	|page_memset|
    158 	b	|page_loop|
    159 
    160 |page_memcpy4|			; memcpy (dst, src, sz) uncached.
    161 	ldr	r0, [r3], #4
    162 	ldr	r5, [r3], #4
    163 	str	r0, [r4], #4
    164 	cmp	r4, r6
    165 	strlt	r5, [r4], #4
    166 	cmplt	r4, r6
    167 	blt	|page_memcpy4|
    168 
    169 	b	|page_loop|
    170 |page_end|
    171 	;
    172 	; jump to kernel
    173 	;
    174 ;	mov	r0, #'E'
    175 ;	bl	btputc
    176 ;	ldr	r0, [r7]
    177 ;	bl	hexdump
    178 ;	ldr	r0, [r7]
    179 ;	ldr	r0, [r0]
    180 ;	bl	hexdump	
    181 
    182 	; set stack pointer
    183 	mov	r5, #4096
    184 	add	r6, r6, #8192
    185 	sub	r5, r5, #1
    186 	bic	sp, r6, r5
    187 
    188 	; set bootargs
    189 	ldr	r4, [r7]
    190 	ldr	r0, [r7, #4]
    191 	ldr	r1, [r7, #8]
    192 	ldr	r2, [r7, #12]
    193 	mov	pc, r4
    194 	; NOTREACHED
    195 
    196 |infinite_loop|
    197 	nop
    198 	nop
    199 	nop
    200 	nop
    201 	nop
    202 	b	|infinite_loop|
    203 	ENDP  ; |boot|
    204 
    205 |btputc| PROC
    206 	adr	r1, |$UARTTXBSY|
    207 	ldr	r1, [r1]
    208 |btputc_busy|
    209 	ldr	r2, [r1]
    210 	and	r2, r2, #1
    211 	cmp	r2, #1
    212 	beq	|btputc_busy|
    213 	adr	r1, |$UARTTXADR|
    214 	ldr	r1, [r1]
    215 	str	r0, [r1]
    216 	mov	pc, lr
    217 	ENDP	;|btputc|
    218 
    219 |hexdump| PROC
    220 	stmfd	sp!, {r4-r5, lr}
    221 	mov	r4, r0
    222 	mov	r0, #0x30
    223 	bl	btputc
    224 	mov	r0, #0x78
    225 	bl	btputc
    226 	mov	r0, r4
    227 	;	Transmit register address
    228 	adr	r1, |$UARTTXADR|
    229 	ldr	r1, [r1]
    230 	;	Transmit busy register address
    231 	adr	r2, |$UARTTXBSY|
    232 	ldr	r2, [r2]
    233 	mov	r5, #8
    234 |hex_loop|
    235 	mov	r3, r0, LSR #28
    236 	cmp	r3, #9
    237 	addgt	r3, r3, #0x41 - 10
    238 	addle	r3, r3, #0x30
    239 |hex_busyloop|
    240 	ldr	r4, [r2]
    241 	and	r4, r4, #1
    242 	cmp	r4, #1
    243 	beq	|hex_busyloop|
    244 	str	r3, [r1]
    245 	mov	r0, r0, LSL #4
    246 	subs	r5, r5, #1
    247 	bne	|hex_loop|
    248 	mov	r0, #0x0d
    249 	bl	btputc
    250 	mov	r0, #0x0a
    251 	bl	btputc
    252 	ldmfd	sp!, {r4-r5, pc}
    253 	ENDP	;|hexdump|
    254 
    255 |$UARTTXADR|
    256 	DCD	0x80050014
    257 |$UARTTXBSY|
    258 	DCD	0x80050020
    259 
    260 	EXPORT	|boot_func_end_sa1100| [ DATA ]
    261 |boot_func_end_sa1100|	DCD	0x0
    262 
    263 	END
    264