[BACK]Return to loader.S CVS log [TXT][DIR] Up to [local] / funnyos / arch / testarm / boot

File: [local] / funnyos / arch / testarm / boot / loader.S (download)

Revision 1.4, Mon Nov 5 18:54:35 2007 UTC (16 years, 7 months ago) by init
Branch: MAIN
Changes since 1.3: +9 -5 lines

in _vector_irq store r0-r12 and r14 (lr) registers into an irq stack;
this prevents System Mode (and whatever-mode) registers from crush while we are in IRQ_mode
- use ldmia sp!, {r0-r12, pc}^ to restore all registers and to copy spsr into cpsr ATOMICALLY,
This fixes interesting bug when we end up in IRQ_mode after we've changed CPU mode back to Sys..

With this diff i can finally see messages from rtc driver every time it interrupts IRQC.

/*
 * $Id: loader.S,v 1.4 2007/11/05 18:54:35 init Exp $
 */
/*
 *	FunnyOS loader
 *	for gxemul test arm machines.
 */
.text
.global _start
.global main

_start:
b 	_vector_reset		/* reset */
bl 	_vector_undef		/* undefined insn */
bl 	_vector_swi			/* software intr handler */
bl 	_vector_dataabrt	/* data abort */
bl 	_vector_prefabrt	/* prefetch abort */
.word 0x00000000		/* [reserved] */
b 	_vector_irq			/* IRQ */
bl 	_vector_fiq			/* Fast Interrupt Request */

_vector_reset:
	/*
	 *	Will enter here just right after RESET.
	 *	Set up stack and call main.
	 */

	/*
	 * Setup an IRQ stack
	 */
	/* switch into irq mode with interrupts disabled */
	msr cpsr_c, #(0x12 | 0x80) 

	/* set sp (sp is banked) */
	ldr sp, Airqstack

	/*
	 * Setup system stack
	 */
	/* switch into system mode (interrupts turned off) */
	msr cpsr_c, #(0x1f | 0x80)

	/* set system stack pointer */
	ldr sp, Asysstack

	b main
	/* NOTREACHED */

_vector_undef:
	/* Undefined insn handler */
	mov pc, r14

_vector_swi:
	mov pc, r14

_vector_dataabrt:
	/* XXX fatal */
	nop

_vector_prefabrt:
	nop

_vector_irq:
	/* decrement pc by one insn */
	sub lr, lr, #4

	/* store all system mode registers */
	stmdb sp!, {r0-r12, lr}

	bl irq_trampoline

	/* load r0-r12 and pc from the stack */
	/* note ^ that copies SPSR into CPSR */
	ldmia sp!, {r0-r12, pc}^

_vector_fiq:
	nop

/* last word of the physical memory */
Asysstack:
.word 	0x01fffffc
Airqstack:
.word 	0x01fff000