os/kernelhwsrv/bsptemplate/asspandvariant/template_assp/interrupts.cia
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// template\template_assp\interrupts.cia
sl@0
    15
// Template ASSP interrupt control and dispatch
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <template_assp_priv.h>
sl@0
    20
sl@0
    21
__NAKED__ void TemplateInterrupt::IrqDispatch()
sl@0
    22
	{
sl@0
    23
	// IRQ dispatcher
sl@0
    24
	// Enter with r0-r3, r12 and return address on IRQ stack
sl@0
    25
	// Must preserve r4-r11
sl@0
    26
sl@0
    27
	// for the moment, use bit number as priority
sl@0
    28
	asm("stmfd sp!, {r4-r6,lr} ");
sl@0
    29
	asm("ldr r4, __KTemplateIntCtrlBase ");
sl@0
    30
	asm("ldr r5, __Handlers ");
sl@0
    31
	asm("dispatch_irq: ");
sl@0
    32
	asm("ldr r12, [r4, #%a0]" : : "i" ((TInt)KHoInterruptsIrqPending));		// r12=IRQ pending register
sl@0
    33
	asm("cmp r12, #0 ");
sl@0
    34
	asm("ldmeqfd sp!, {r4-r6,pc} ");										// no more pending, so finish
sl@0
    35
	asm("mov r3, #31 ");
sl@0
    36
	asm("cmp r12, #0x00010000 ");
sl@0
    37
	asm("movcc r12, r12, lsl #16 ");
sl@0
    38
	asm("subcc r3, r3, #16 ");
sl@0
    39
	asm("cmp r12, #0x01000000 ");
sl@0
    40
	asm("movcc r12, r12, lsl #8 ");
sl@0
    41
	asm("subcc r3, r3, #8 ");
sl@0
    42
	asm("cmp r12, #0x10000000 ");
sl@0
    43
	asm("movcc r12, r12, lsl #4 ");
sl@0
    44
	asm("subcc r3, r3, #4 ");
sl@0
    45
	asm("cmp r12, #0x40000000 ");
sl@0
    46
	asm("movcc r12, r12, lsl #2 ");
sl@0
    47
	asm("subcc r3, r3, #2 ");
sl@0
    48
	asm("cmp r12, #0x80000000 ");
sl@0
    49
	asm("subcc r3, r3, #1 ");												// r3=bit no. of MS 1
sl@0
    50
	asm("add r0, r5, r3, lsl #3 ");											// r0=address of SInterruptHandler
sl@0
    51
	asm("adr lr, dispatch_irq ");											// return to dispatch_irq
sl@0
    52
	asm("ldmia r0, {r0,pc} ");												// (*iIsr)(iPtr);
sl@0
    53
	}
sl@0
    54
sl@0
    55
__NAKED__ void TemplateInterrupt::FiqDispatch()
sl@0
    56
	{
sl@0
    57
	// FIQ dispatcher
sl@0
    58
	// Enter with return address on FIQ stack
sl@0
    59
	// We may use r8-r12, but must preserve other registers
sl@0
    60
	// for the moment, use bit number as priority
sl@0
    61
	// NOTE: STACK MISALIGNED ON ENTRY (1 WORD PUSHED)
sl@0
    62
	asm("stmfd sp!, {r0-r3,lr} ");
sl@0
    63
	asm("ldr r8, __KTemplateIntCtrlBase ");
sl@0
    64
	asm("ldr r9, __Handlers ");
sl@0
    65
	asm("dispatch_fiq: ");
sl@0
    66
	asm("ldr r12, [r4, #%a0]" : : "i" ((TInt)KHoInterruptsFiqPending));		// r12=FIQ pending register
sl@0
    67
	asm("cmp r12, #0 ");
sl@0
    68
	asm("ldmeqfd sp!, {r0-r3,pc} ");										// no more pending, so finish
sl@0
    69
	asm("mov r3, #31 ");
sl@0
    70
	asm("cmp r12, #0x00010000 ");
sl@0
    71
	asm("movcc r12, r12, lsl #16 ");
sl@0
    72
	asm("subcc r3, r3, #16 ");
sl@0
    73
	asm("cmp r12, #0x01000000 ");
sl@0
    74
	asm("movcc r12, r12, lsl #8 ");
sl@0
    75
	asm("subcc r3, r3, #8 ");
sl@0
    76
	asm("cmp r12, #0x10000000 ");
sl@0
    77
	asm("movcc r12, r12, lsl #4 ");
sl@0
    78
	asm("subcc r3, r3, #4 ");
sl@0
    79
	asm("cmp r12, #0x40000000 ");
sl@0
    80
	asm("movcc r12, r12, lsl #2 ");
sl@0
    81
	asm("subcc r3, r3, #2 ");
sl@0
    82
	asm("cmp r12, #0x80000000 ");
sl@0
    83
	asm("subcc r3, r3, #1 ");												// r3=bit no. of MS 1
sl@0
    84
	asm("add r0, r9, r3, lsl #3 ");											// r0=address of SInterruptHandler
sl@0
    85
	asm("adr lr, dispatch_fiq ");											// return to dispatch_fiq
sl@0
    86
	asm("ldmia r0, {r0,pc} ");												// (*iIsr)(iPtr);
sl@0
    87
sl@0
    88
	asm("__KTemplateIntCtrlBase: ");
sl@0
    89
	asm(".word %a0" : : "i" ((TInt)KHwBaseInterrupts));
sl@0
    90
	asm("__Handlers: ");
sl@0
    91
	asm(".word %a0" : : "i" ((TInt)&TemplateInterrupt::Handlers[0]));
sl@0
    92
	}
sl@0
    93