fw.src

来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· SRC 代码 · 共 362 行

SRC
362
字号
;/***************************************************************************
; File:         startup.src
; Author:       Naresh Gupta (nkgupta@hotmail.com)
; Date:         Wednesday Feb 17, 1999
; Organization: Hitachi Semiconductor America Inc.
; Purpose:      This file defines the modules StartUp, Out_LED, Clean_RAM
;
; Copyright(c) 1999 Hitachi Semiconductor America Ltd.
;***************************************************************************/

	.include "kxshx.h"
	.include "boot.inc"
	.include "shx.inc"
	.include "oalintr.inc"
	.include "platform.inc"

    .align 4
    .export _OEMExtraCCR
    .export _SH4CacheLines

;   SH4 cache setup
_OEMExtraCCR:	.data.l h'000
_SH4CacheLines	.data.l 512


	.import KernelStart
	.import _AlarmYear
	.import _TmpStack
	.import _PrintSpuriousInterrupt

;// Windows CE defines it's own stack in the KernelStart routine. Till that
;// time a temporary stack may be needed. This stack serves as a temporary
;// one. It would be overwritten once control is transferred to KernelStart.
_Start_KStack:      .datab.l    256, 0            ;// 4*256 bytes
_KStack             .data.l     0

_Jump_Loc            .equ       KernelStart
Stack                .equ       _KStack



	.include "StartUp.src"

;// Make this 1 if you want to clean the RAM before booting.
CLEAN_RAM		     .equ		0		;// 1:Clean All RAM, 0:Don't clean

;// Make this 1 if you want to display Marquee.
DISPLAY_MARQUEE	     .equ		0


;//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;// CleanRAM
;
;// This routine will set RAM from RAM_START to RAM_RAM_END to 0.
;// This is required so that the system boots up from clean RAM. If this
;// is not done, the junk data in RAM may be mis-interpreted while booting
;// leading to unknown results.
;// RAM cleaning is being done by using DMA in 32 byte burst transfer mode.
;
;// It can use registers r1, r2, r3, r4
;//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;// Items required by the CleanRAM function.
;// RAM START AND END ADDRESSES.
RAM_START		.equ		0xac000000 ;// Start of RAM to be cleaned
RAM_RAM_END		.equ		0xad000000 ;// End of RAM to be cleaned
RAM_FLASH_END	.equ		0xad000000 ;// End of RAM to be cleaned for FLASH
									   ;// image
INITIAL_VALUE	.equ		0x00000000 ;// Value to write to RAM bo clean

;// Value of DMA registers for channel 2.
DMAC_CHCR2_VAL1		.equ		h'000044C0
DMAC_DMATCR2_VAL	.equ		h'7FFFF
DMAC_CHCR2_VAL2		.equ		h'000044C1


		.align 4
	LEAF_ENTRY CleanRAM

 .aif CLEAN_RAM eq 1

		sts		pr, r14

;// Write INITIAL_VALUE to 8 long words starting at RAM_START.

		mov.l	#RAM_START,r0				; RAM Start Addtess
		mov.l	#INITIAL_VALUE,r1			; Initial VAlue written to RAM
		
		mov.l	r1, @(0, r0)						; 4 Bytes
		mov.l	r1, @(4, r0)						; 4 Bytes
		mov.l	r1, @(8, r0)						; 4 Bytes
		mov.l	r1, @(12, r0)						; 4 Bytes
		mov.l	r1, @(16, r0)						; 4 Bytes
		mov.l	r1, @(20, r0)						; 4 Bytes
		mov.l	r1, @(24, r0)						; 4 Bytes
		mov.l	r1, @(28, r0)						; 4 Bytes


		mov.l	#DMAC_DMAOR, r0						; DMA Operation register						
		mov.l	#DMAC_DMAOR_DME, r1					; DMA Master Enable.
		mov.l	r1, @r0
		
		mov.l	#DMAC_CHCR2, r0					; DMA channel control register
		mov.l	#DMAC_CHCR2_VAL1, r1				; sour fix , dest Incremental, Ext. address to Ext. Address
		mov.l	r1, @r0							; DMA channel disabled; 32 Byte Burst Mode	
											
		mov.l	#DMAC_SAR2, r0					; DMA  ch - 2 source register										
		mov.l	#RAM_START, r1					; RAM start address
		mov.l	r1, @r0

       	mov.l	#DMAC_DAR2, r0					; DMA ch - 2 Destination Register
		add 	#32, r1
		mov.l  	r1, @r0

;// Find out how many bytes to clear.
       	mov.l	#RAM_RAM_END, r2				; Last address to clear.
		sub		r1, r2							; Number of bytes

		shlr2	r2
		shlr2	r2
		shlr	r2
		
		mov.l	#DMAC_DMATCR2, r0					; DAM count register
		mov.l	r2, @r0

		mov.l	#DMAC_CHCR2, r0					; DMA channel control register
		mov.l	#DMAC_CHCR2_VAL2, r1				; sour fix dest Incremental, Ext. address to Ext. Address
		mov.l	r1, @r0							; DMA channel enabled; 64 bit transfer

copy_complete:

		mov.l	#ALPHA_LED, r8
		mov.l	#h'41, r7
		mov.l	r7, @r8
		 
		mov.l	@r0,r1							; read DMA channel control register
		mov.l	#h'00000002,r2					; BIT 1 to test for transfer complete
		tst		r2,r1		
		bt		copy_complete

		mov.l	#h'43, r7						; Dispaly Something on completion
		mov.l	r7, @r8

	;// Restore pr so as to jump back.
	lds		r14, pr
 .aendi

	rts
	nop

	ENTRY_END CleanRAM


; Data used for initialization.
	.align 4



;*******************************************************************************
; SH4 RTC Alarm interrupt service routine
;
;	This routine is invoked when the real time matches the alarm time. Since the year
; is not included as part of the alarm time, the year must be checked and the interrupt
; will be ignored if the year doesn't match.
;
; Registers: r0-r3, r6 available for use
;
;      Entry   in register bank 1, exceptions blocked
;      Exit    (r0) = interrupt dispostion information
;                      (see nkintr.h for values)
;      Uses    r0-r3,r6
; Clear the alarm flag.

	LEAF_ENTRY _AlarmISR
	mov		#RTC_RCR1, r2					; (r0) = RTC control register 1 contents
	mov.b	@r2, r0
	mov		#~RTC_RCR1_AF, r1
	and		r1, r0
	mov.b	r0, @r2							; clear alarm flag in control register 1

; Compare the current year with the alarm year.
;;
	mov		#_AlarmYear, r1					; (r1) = ptr to alarm year
	mov.w	@r1, r1							; (r1) = alarm year value
	mov		#RTC_RYRCNT, r3					; (r3) = ptr to RYRCNT (current year)
	mov.w	@r3, r2							; (r2) = current year (in BCD)
	cmp/eq	r1, r2
	bf/s	aisr40							; year matches, signal the alarm
	mov		#SYSINTR_NOP, r0

	mov		#RTC_RCR1, r2					; (r0) = RTC control register 1 contents
	mov.b	@r2, r0
	mov		#~(RTC_RCR1_AIE|RTC_RCR1_AF) , r1
	and		r1 , r0
	mov.b	r0, @r2							; Disable alarm interrupt in control register 1
	mov		#SYSINTR_RTC_ALARM, r0			; (r0) = interrupt cause

aisr40:
	rts
	nop
	.endf

;*****************************************************************************
;* OEMPowerOff - OFF button handler
;*
;* This routine is invoked when the OFF button is pressed. It is responsible
;* for any final power off state and putting the cpu into standby.
;*
;*	Entry	none
;*	Exit	none
;*	Uses	r0-r3
;*****************************************************************************
	LEAF_ENTRY _OEMPowerOff

	mov	#h'50000030, r0
	ldc	r0, SR
 
	;; NKCH
	;; Removed sleeping since i want it to run continuously.
   	;; sleep
 
	mov	#h'400000f0, r0
	ldc	r0, SR
	;; WRITE_LEDS	H'0f
	rts
	nop
	.endf


	;* Pointer to string to be printed on the LED whenever idle is called.
	.import _StrForLed
	.import _StrForLedCurrent
	.import _Display_Marquee
;*****************************************************************************
;* OEMIdle - system idle
;*
;* This routine is called by the kernel when there are no threads ready to
;* run. The CPU should be put into a reduced power mode and halted. It is important
;* to be able to resume execution quickly upon receiving an interrupt.
;*
;* NOTE: Exceptions are blocked when this routine called and must not be reenabled
;* unless the functions is going to return immediately. The SH4 ignores the block bit
;* in the PSR when sleeping so it is not necessary to enable interrupts before issuing
;* the sleep instruction.
;*
;*	Entry	Exceptions blocked
;*	Exit	none
;*	Uses	r0-r3
;*****************************************************************************
	LEAF_ENTRY OEMIdle

	;; Save pr, r14
	mov.l	r14, @-r15
	sts.l	pr, @-r15

 .aif DISPLAY_MARQUEE
	;; Call Display_Marquee. you may need to set and restore certain registers.
	mov.l	#_Display_Marquee, r0
	jsr		@r0
	nop

 .aendi DISPLAY_MARQUEE

	;; Resotre pr, r14
	lds.l	@r15+, pr
	mov.l	@r15+, r14

	sleep

	rts
	nop
	.endf

;*****************************************************************************
;* OEMNMI - non-maskable interrupt handler
;*
;* This routine is called when a non-maskable interrupt occurs. It should return
;* an interrupt cause the same as other interrupt service routines.
;*
;* Registers: r0-r3,r6 available for use.
;*
;*     Entry   in register bank 1, exceptions blocked
;*     Exit    (r0) = interrupt dispostion information
;*                   (see nkintr.h for values)
;*     Uses    r0
;*****************************************************************************
	LEAF_ENTRY OEMNMI

	rts
	mov	#SYSINTR_NOP, r0
	.endf

;/*****************************************************************************
;  This interrupt should never come since no handler is registered for this
;  interrupt. So print error message if this interrupt comes and ignore this
;  interrupt.
;*****************************************************************************/
	LEAF_ENTRY _SpuriousISR

;// Save complete state before calling a C function

	// Switch to temporary kernel stack
	// The interrupt service routines can spoil r0-r3
	// Save old stack pointer
	mov		r15, r1
	mov		#_TmpStack, r15
	mov.l	r1, @-r15

   	mov.l	r4, @-r15
	mov.l	r5, @-r15
   	mov.l	r6, @-r15
	mov.l	r7, @-r15
   	mov.l	r8, @-r15
	mov.l	r9, @-r15
   	mov.l	r10, @-r15
	mov.l	r11, @-r15
   	mov.l	r12, @-r15
	mov.l	r13, @-r15
   	mov.l	r14, @-r15
	sts.l	pr, @-r15
	mov		#_PrintSpuriousInterrupt, r0
	jsr		@r0
	nop
	lds.l	@r15+, pr
	mov.l	@r15+, r14
	mov.l	@r15+, r13
	mov.l	@r15+, r12
	mov.l	@r15+, r11
	mov.l	@r15+, r10
	mov.l	@r15+, r9
	mov.l	@r15+, r8
	mov.l	@r15+, r7
	mov.l	@r15+, r6
	mov.l	@r15+, r5
	mov.l	@r15+, r4

	// restore old stack
	mov.l	@r15+, r1
	mov		r1, r15

	mov	#SYSINTR_NOP, r0
	rts
	nop
	.endf


    LEAF_ENTRY _CPUEnterIdle
        ;
        ; NOTE: Exceptions are blocked when this routine called and must not
        ; be reenabled unless the functions is going to return immediately.
        ; The SH3 ignores the block bit in the PSR when sleeping so it is
        ; not necessary to enable interrupts before issuing the sleep
        ; instruction.
        ;
        sleep
        rts
        nop
    .endf


	.end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?