← Back to team overview

t-kernel team mailing list archive

[PATCH] icoll: [wip] adding icoll support

 

From: Du Huanpeng <u74147@xxxxxxxxx>

Signed-off-by: Du Huanpeng <u74147@xxxxxxxxx>
---
 tkernel_source/monitor/Makefile.src                |  2 +
 .../monitor/hwdepend/arm/cpu/reset-reset.S         |  8 ++--
 .../monitor/hwdepend/arm/mach-mx28/config.c        | 53 +++-------------------
 .../monitor/hwdepend/arm/mach-mx28/icoll.c         | 36 +++++++--------
 .../hwdepend/arm/mach-mx28/include/mach/mx28.h     |  3 +-
 tkernel_source/monitor/tmmain/kernel.c             | 10 +++-
 tkernel_source/monitor/tmmain/monkey.S             | 16 +++++++
 7 files changed, 56 insertions(+), 72 deletions(-)

diff --git a/tkernel_source/monitor/Makefile.src b/tkernel_source/monitor/Makefile.src
index 198919d..3199c7a 100644
--- a/tkernel_source/monitor/Makefile.src
+++ b/tkernel_source/monitor/Makefile.src
@@ -46,6 +46,7 @@ SRC += driver/sio/sio-sam9.c
 endif
 ifeq ($(MACH),mach-mx28)
 SRC += driver/sio/sio-mx28.c
+SRC += hwdepend/arm/mach-mx28/icoll.c
 endif
 
 SRC += hwdepend/arm/$(MACH)/system.c
@@ -81,6 +82,7 @@ SRC += tmmain/version.c
 SRC += lib/printk.c
 
 SRC += tmmain/monkey.S
+SRC += tmmain/kernel.c
 endif
 
 OBJ := $(SRC)
diff --git a/tkernel_source/monitor/hwdepend/arm/cpu/reset-reset.S b/tkernel_source/monitor/hwdepend/arm/cpu/reset-reset.S
index 19007bc..057c9ec 100644
--- a/tkernel_source/monitor/hwdepend/arm/cpu/reset-reset.S
+++ b/tkernel_source/monitor/hwdepend/arm/cpu/reset-reset.S
@@ -323,10 +323,12 @@ reset_entry:
 	svc	81			@ syscall
 	svc	91			@ syscall
 	svc	101			@ syscall
-	svc	88			@ syscall
+	svc	0x88			@ syscall
 
-	ldr	r0, =0x44000003
-	ldr	r1, [r0]		@ data abort
+	bl	start_kernel
+
+@	ldr	r0, =0x44000003
+@	ldr	r1, [r0]		@ data abort
 	
 @	b	resetLoop		// return will cause another reset
 	b	.
diff --git a/tkernel_source/monitor/hwdepend/arm/mach-mx28/config.c b/tkernel_source/monitor/hwdepend/arm/mach-mx28/config.c
index e0217b5..e9639db 100644
--- a/tkernel_source/monitor/hwdepend/arm/mach-mx28/config.c
+++ b/tkernel_source/monitor/hwdepend/arm/mach-mx28/config.c
@@ -38,29 +38,17 @@ EXPORT	MEMSEG	MemSeg[] = {
 	{0x00000000, 0x00020000, MSA_SRAM,	PGA_RW|PGA_NC},
 	/* DDR2 SDRAM, 64MiB */
 	{0x40000000, 0x44000000, MSA_RAM,	PGA_RW|PGA_C},
-        /* EM1 internal device (1) */
-	{0x40000000, 0x70000000, MSA_IO,	PGA_RW|PGA_D |PGA_S|PGA_XN},
-	/* Bank0 */
-	{0x70000000, 0x72000000, MSA_FROM,	PGA_RO|PGA_C |0x90000000},
-        /* EM1 internal SRAM */
-	{0xa0000000, 0xb0000000, MSA_SRAM,	PGA_RW|PGA_NC},
-        /* EM1 internal device (2) */
-	{0xb0000000, 0xd0000000, MSA_IO,	PGA_RW|PGA_D |PGA_S|PGA_XN},
-        /* EM1 internal Boot ROM */
-	{0xf0000000, 0xffffffff, MSA_ROM,	PGA_RO|PGA_NC},
-
-	{0x70000000, 0x70020000, MSA_MON,	0},
-	{0x70030000, 0x72000000, MSA_RDA,	0},
-	{0x30006000, 0x34000000, MSA_OS,	0},
+        /* APBH, APBX */
+	{0x80000000, 0x80010000, MSA_IO,	PGA_RW|PGA_D |PGA_S|PGA_XN},
+	/* AHB On-Chip ROM */
+	{0xC0000000, 0xC0020000, MSA_FROM,	PGA_RO|PGA_C |0x90000000},
 };
 
 EXPORT	W	N_MemSeg = sizeof(MemSeg) / sizeof(MEMSEG);
 
 /* unused memory region definition */
 EXPORT	MEMSEG	NoMemSeg[] = {
-	{0x00000000, 0x10000000, 0,		0},
-	{0x72000000, 0xa0000000, 0,		0},
-	{0xd0000000, 0xf0000000, 0,		0},
+	{0x00000000, 0x00000000, 0,		0},
 };
 
 EXPORT	W	N_NoMemSeg = sizeof(NoMemSeg) / sizeof(MEMSEG);
@@ -92,39 +80,12 @@ EXPORT	UB *	const PBootAddr = (UB *)0x30200000;	/* primary boot loader address *
  
 /* ------------------------------------------------------------------------ */
 
-#define	IICC_IICE	(1 << 7)
-#define	IICC_WREL	(1 << 5)
-#define	IICC_WTIM	(1 << 3)
-#define	IICC_ACKE	(1 << 2)
-#define	IICC_STT	(1 << 1)
-#define	IICC_SPT	(1 << 0)
-
-#define	IICCL_SMC	(1 << 3)
-#define	IICCL_DFC	(1 << 2)
-
-#define	IICSE_MSTS	(1 << 15)
-#define	IICSE_ALD	(1 << 14)
-#define	IICSE_ACKD	(1 << 10)
-#define	IICSE_SPD	(1 << 8)
-
-#define	IICF_IICBSY	(1 << 6)
-#define	IICF_STCEN	(1 << 1)
-#define	IICF_IICRSV	(1 << 0)
-
-#define	IIC_TOPDATA	(1 << 11)
-#define	IIC_LASTDATA	(1 << 10)
-
-#define	TIMEOUT		1000000	/* microsec */
-
-#define	IIC2_IRQ	39
-#define	IRQbit(x)	(1 << ((x) % 32))
-
 /* wait for register state information */
 LOCAL	ER	wait_state(UW addr, UW mask, UW value)
 {
-	W	i;
+	int i = 1000000;
 
-	for (i = TIMEOUT; i > 0; i--) ;
+	while(--i);
 
 	return i ? E_OK : E_TMOUT;
 }
diff --git a/tkernel_source/monitor/hwdepend/arm/mach-mx28/icoll.c b/tkernel_source/monitor/hwdepend/arm/mach-mx28/icoll.c
index 1e0b55b..e95d2b1 100644
--- a/tkernel_source/monitor/hwdepend/arm/mach-mx28/icoll.c
+++ b/tkernel_source/monitor/hwdepend/arm/mach-mx28/icoll.c
@@ -27,17 +27,17 @@
 
 #include "regs-icoll.h"
 
-void __iomem *g_icoll_base;
+volatile void  *g_icoll_base;
 
 /*
  * IRQ handling
  */
 static void icoll_ack_irq(unsigned int irq)
 {
-	__raw_writel(0, g_icoll_base + HW_ICOLL_VECTOR);
+	out_w(0, g_icoll_base + HW_ICOLL_VECTOR);
 
 	/* ACK current interrupt */
-	__raw_writel(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0,
+	out_w(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0,
 		     g_icoll_base + HW_ICOLL_LEVELACK);
 
 	/* Barrier */
@@ -46,13 +46,13 @@ static void icoll_ack_irq(unsigned int irq)
 
 static void icoll_mask_irq(unsigned int irq)
 {
-	__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
+	out_w(BM_ICOLL_INTERRUPTn_ENABLE,
 		     g_icoll_base + HW_ICOLL_INTERRUPTn_CLR(irq));
 }
 
 static void icoll_unmask_irq(unsigned int irq)
 {
-	__raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
+	out_w(BM_ICOLL_INTERRUPTn_ENABLE,
 		     g_icoll_base + HW_ICOLL_INTERRUPTn_SET(irq));
 }
 
@@ -74,7 +74,7 @@ void __init avic_init_irq(void __iomem *base, int nr_irqs)
 	g_icoll_base = base;
 
 	/* Reset icoll */
-	__raw_writel(BM_ICOLL_CTRL_SFTRST, g_icoll_base + HW_ICOLL_CTRL_CLR);
+	out_w(BM_ICOLL_CTRL_SFTRST, g_icoll_base + HW_ICOLL_CTRL_CLR);
 
 	for (i = 0; i < 100000; i++) {
 		if (!(__raw_readl(g_icoll_base + HW_ICOLL_CTRL) &
@@ -87,29 +87,29 @@ void __init avic_init_irq(void __iomem *base, int nr_irqs)
 		       __func__, __LINE__);
 		return;
 	}
-	__raw_writel(BM_ICOLL_CTRL_CLKGATE, g_icoll_base + HW_ICOLL_CTRL_CLR);
+	out_w(BM_ICOLL_CTRL_CLKGATE, g_icoll_base + HW_ICOLL_CTRL_CLR);
 
 	for (i = 0; i < nr_irqs; i++) {
-		__raw_writel(0, g_icoll_base + HW_ICOLL_INTERRUPTn(i));
+		out_w(0, g_icoll_base + HW_ICOLL_INTERRUPTn(i));
 		set_irq_chip(i, &icoll_chip);
 		set_irq_handler(i, handle_level_irq);
 		set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
 	}
 
-	__raw_writel(BF_ICOLL_LEVELACK_IRQLEVELACK
+	out_w(BF_ICOLL_LEVELACK_IRQLEVELACK
 		     (BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0),
 		     g_icoll_base + HW_ICOLL_LEVELACK);
-	__raw_writel(BF_ICOLL_LEVELACK_IRQLEVELACK
+	out_w(BF_ICOLL_LEVELACK_IRQLEVELACK
 		     (BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL1),
 		     g_icoll_base + HW_ICOLL_LEVELACK);
-	__raw_writel(BF_ICOLL_LEVELACK_IRQLEVELACK
+	out_w(BF_ICOLL_LEVELACK_IRQLEVELACK
 		     (BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL2),
 		     g_icoll_base + HW_ICOLL_LEVELACK);
-	__raw_writel(BF_ICOLL_LEVELACK_IRQLEVELACK
+	out_w(BF_ICOLL_LEVELACK_IRQLEVELACK
 		     (BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL3),
 		     g_icoll_base + HW_ICOLL_LEVELACK);
 
-	__raw_writel(0, g_icoll_base + HW_ICOLL_VECTOR);
+	out_w(0, g_icoll_base + HW_ICOLL_VECTOR);
 	/* Barrier */
 	(void)__raw_readl(g_icoll_base + HW_ICOLL_STAT);
 }
@@ -117,25 +117,23 @@ void __init avic_init_irq(void __iomem *base, int nr_irqs)
 void mxs_set_irq_fiq(unsigned int irq, unsigned int type)
 {
 	if (type == 0)
-		__raw_writel(BM_ICOLL_INTERRUPTn_ENFIQ,
+		out_w(BM_ICOLL_INTERRUPTn_ENFIQ,
 			g_icoll_base +
 			HW_ICOLL_INTERRUPTn_CLR(irq));
 	else
-		__raw_writel(BM_ICOLL_INTERRUPTn_ENFIQ,
+		out_w(BM_ICOLL_INTERRUPTn_ENFIQ,
 			g_icoll_base +
 			HW_ICOLL_INTERRUPTn_SET(irq));
 }
-EXPORT_SYMBOL(mxs_set_irq_fiq);
 
 void mxs_enable_fiq_functionality(int enable)
 {
 	if (enable)
-		__raw_writel(BM_ICOLL_CTRL_FIQ_FINAL_ENABLE,
+		out_w(BM_ICOLL_CTRL_FIQ_FINAL_ENABLE,
 			g_icoll_base + HW_ICOLL_CTRL_SET);
 	else
-		__raw_writel(BM_ICOLL_CTRL_FIQ_FINAL_ENABLE,
+		out_w(BM_ICOLL_CTRL_FIQ_FINAL_ENABLE,
 			g_icoll_base + HW_ICOLL_CTRL_CLR);
 
 }
-EXPORT_SYMBOL(mxs_enable_fiq_functionality);
 
diff --git a/tkernel_source/monitor/hwdepend/arm/mach-mx28/include/mach/mx28.h b/tkernel_source/monitor/hwdepend/arm/mach-mx28/include/mach/mx28.h
index 073b5cf..20bf8c7 100644
--- a/tkernel_source/monitor/hwdepend/arm/mach-mx28/include/mach/mx28.h
+++ b/tkernel_source/monitor/hwdepend/arm/mach-mx28/include/mach/mx28.h
@@ -19,11 +19,10 @@
 #ifndef __ASM_ARCH_MACH_MX28_H__
 #define __ASM_ARCH_MACH_MX28_H__
 
-#include <asm/sizes.h>
 
 #define MX28_SOC_IO_PHYS_BASE	0x80000000
 #define MX28_SOC_IO_VIRT_BASE	0xF0000000
-#define MX28_SOC_IO_AREA_SIZE	SZ_1M
+#define MX28_SOC_IO_AREA_SIZE	(1*1024*1024)
 
 /* Virtual address where OCRAM is mapped */
 #define MX28_OCRAM_PHBASE   0x00000000
diff --git a/tkernel_source/monitor/tmmain/kernel.c b/tkernel_source/monitor/tmmain/kernel.c
index a54b2bd..1d50761 100644
--- a/tkernel_source/monitor/tmmain/kernel.c
+++ b/tkernel_source/monitor/tmmain/kernel.c
@@ -6,9 +6,15 @@ int start_kernel(int argc, char *argv[])
 {
 	int i;
 	int rc;
+	int reg[16];
 
-	for(i=0; i<256; i++){
-		rc = syscall(i);
+	printk("starting kernel...");
+
+	printk("CPSR: [%08X]\n", getcpsr());
+	getr(reg);
+
+	for(i=0; i<16; i++){
+		printk("register [%d]: [%X]\n", i, reg[i]);
 	}
 	printk("Hello World!\n");
 	return 0;
diff --git a/tkernel_source/monitor/tmmain/monkey.S b/tkernel_source/monitor/tmmain/monkey.S
index b6804c5..6ba0558 100644
--- a/tkernel_source/monitor/tmmain/monkey.S
+++ b/tkernel_source/monitor/tmmain/monkey.S
@@ -17,3 +17,19 @@ syscall:
 	str	r0, __syscall
 	b	__syscall
 
+
+	.global getcpsr
+getcpsr:
+	mrs	r0, cpsr
+	bx	lr
+
+
+	.global getpc
+getpc:
+	mov	r0, lr
+	bx	lr
+
+	.global getr
+getr:
+	stmia	r0, {r0-r15}
+	bx	lr
-- 
1.9.1




References