omap3530/beagleboard/src/variant.cia
changeset 0 6663340f3fc9
child 36 601ea115c8aa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omap3530/beagleboard/src/variant.cia	Thu Oct 15 12:59:54 2009 +0100
@@ -0,0 +1,63 @@
+// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// omap3530/beagleboard/src/variant.cia
+//
+
+#include <e32cmn.h>
+#include <e32cia.h>
+#include <beagle/iolines.h>
+
+/******************************************************************************
+ * Interrupt handling/dispatch
+ ******************************************************************************/
+__NAKED__ void XIntDispatch(TAny*)
+	{
+	// Service second-level Variant Interrupts
+	// Enter with r0->{Variant int controller base; Handlers;}
+	asm("stmfd sp!, {r4,lr} ");
+	asm("ldmia r0, {r3,r4} ");										// r3=Variant interrupt controller base, r4->handlers
+	asm("0: ");
+	asm("ldr r0, [r3, #%a0]" : : "i" ((TInt)KHoIntContEnable));		// r0=bitmask with enabled interrupts
+	asm("ldr r1, [r3, #%a0]" : : "i" ((TInt)KHoIntContPending));	// r1=bitmask with pending interrupts
+	asm("mov r2, #31 ");											// int id
+	asm("and r0, r0, r1 ");
+	asm("bics r0, r0, #0xf8000000 ");								// mask unused bits (only 26 2nd-level ints defined)
+	asm("ldmeqfd sp!, {r4,pc} ");									// if no 2nd level interrupts pending, exit
+	asm("cmp r0, #0x00010000 ");
+	asm("movcc r0, r0, lsl #16 ");
+	asm("subcc r2, r2, #16 ");
+	asm("cmp r0, #0x01000000 ");
+	asm("movcc r0, r0, lsl #8 ");
+	asm("subcc r2, r2, #8 ");
+	asm("cmp r0, #0x10000000 ");
+	asm("movcc r0, r0, lsl #4 ");
+	asm("subcc r2, r2, #4 ");
+	asm("cmp r0, #0x40000000 ");
+	asm("movcc r0, r0, lsl #2 ");
+	asm("subcc r2, r2, #2 ");
+	asm("cmp r0, #0x80000000 ");
+	asm("subcc r2, r2, #1 ");										// r2=bit no. of MS 1
+	asm("add r0, r4, r2, lsl #3 ");									// r0->handler for this interrupt
+	asm("adr lr, 0b ");												// look again after calling handler
+	asm("ldmia r0, {r0,pc} ");										// jump to handler
+	}
+
+__NAKED__ void ArmWaitForInterrupt()
+	{
+	//ARM_WFI;
+	asm(".word %a0" : : "i" ((TInt)(0x0320f003 | ((14)<<28) )) )
+	asm("	bx		lr");
+	}
+
+