Skip to contentSkip to conversation

unicore32 core architecture: low level entry and setup code

PATCH In review Guan Xuetao 2 participants 3 messages Dec 25, 2010 – Jan 10, 2011 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 4/12 unicore32 core architecture: low level entry and setup code

From: Guan Xuetao <[email protected]>

This patch implements low level entry and setup codes.

---
 arch/unicore32/include/asm/setup.h |   51 +++
 arch/unicore32/include/asm/traps.h |   32 ++
 arch/unicore32/kernel/entry.S      |  875 ++++++++++++++++++++++++++++++++++++
 arch/unicore32/kernel/head.S       |  261 +++++++++++
 arch/unicore32/kernel/setup.c      |  360 +++++++++++++++
 arch/unicore32/kernel/setup.h      |   28 ++
 arch/unicore32/kernel/traps.c      |  498 ++++++++++++++++++++
 7 files changed, 2105 insertions(+), 0 deletions(-)
arch/unicore32/include/asm/setup.h new file +51 -0
new file mode 100644
index 0000000..297a6d1
@@ -0,0 +1,51 @@
+/*
+ * linux/arch/unicore32/include/asm/setup.h
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __UNICORE_SETUP_H__
+#define __UNICORE_SETUP_H__
+
+#include <linux/types.h>
+
+#define COMMAND_LINE_SIZE 1024
+
+#ifdef __KERNEL__
+
+/*
+ * Memory map description
+ */
+# define NR_BANKS 8
+
+struct membank {
+	unsigned long start;
+	unsigned long size;
+	unsigned int highmem;
+};
+
+struct meminfo {
+	int nr_banks;
+	struct membank bank[NR_BANKS];
+};
+
+extern struct meminfo meminfo;
+
+#define for_each_bank(iter, mi)				\
+	for (iter = 0; iter < (mi)->nr_banks; iter++)
+
+#define bank_pfn_start(bank)	__phys_to_pfn((bank)->start)
+#define bank_pfn_end(bank)	__phys_to_pfn((bank)->start + (bank)->size)
+#define bank_pfn_size(bank)	((bank)->size >> PAGE_SHIFT)
+#define bank_phys_start(bank)	((bank)->start)
+#define bank_phys_end(bank)	((bank)->start + (bank)->size)
+#define bank_phys_size(bank)	((bank)->size)
+
+#endif  /*  __KERNEL__  */
+
+#endif
arch/unicore32/include/asm/traps.h new file +32 -0
new file mode 100644
index 0000000..72cd49d
@@ -0,0 +1,32 @@
+/*
+ * linux/arch/unicore32/include/asm/traps.h
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __UNICORE_TRAP_H__
+#define __UNICORE_TRAP_H__
+
+#include <linux/list.h>
+
+static inline int in_exception_text(unsigned long ptr)
+{
+	extern char __exception_text_start[];
+	extern char __exception_text_end[];
+
+	return ptr >= (unsigned long)&__exception_text_start &&
+	       ptr < (unsigned long)&__exception_text_end;
+}
+
+extern void __init early_trap_init(void);
+extern void dump_backtrace_entry(unsigned long where,
+		unsigned long from, unsigned long frame);
+
+extern void do_DataAbort(unsigned long addr, unsigned int fsr,
+		 struct pt_regs *regs);
+#endif
arch/unicore32/kernel/entry.S new file +875 -0

875 lines not on this page · raw message

arch/unicore32/kernel/head.S new file +261 -0

261 lines not on this page · raw message

arch/unicore32/kernel/setup.c new file +360 -0

360 lines not on this page · raw message

arch/unicore32/kernel/setup.h new file +28 -0
new file mode 100644
index 0000000..34db75b
@@ -0,0 +1,28 @@
+/*
+ * linux/arch/unicore32/kernel/setup.h
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __UNICORE_KERNEL_SETUP_H__
+#define __UNICORE_KERNEL_SETUP_H__
+
+extern void paging_init(void);
+extern void puv3_core_init(void);
+
+extern void puv3_ps2_init(void);
+extern void pci_puv3_preinit(void);
+extern void __init puv3_init_gpio(void);
+
+extern void setup_mm_for_reboot(char mode);
+
+extern char __stubs_start[], __stubs_end[];
+extern char __vectors_start[], __vectors_end[];
+
+extern void kernel_thread_helper(void);
+#endif
arch/unicore32/kernel/traps.c new file +498 -0

498 lines not on this page · raw message

maintainer
#1 lore raw
Quoted 19 lines · Guan Xuetao
arch/unicore32/include/asm/setup.h new file +19 -0
+#ifdef __KERNEL__
+
+/*
+ * Memory map description
+ */
+# define NR_BANKS 8
+
+struct membank {
+	unsigned long start;
+	unsigned long size;
+	unsigned int highmem;
+};
+
+struct meminfo {
+	int nr_banks;
+	struct membank bank[NR_BANKS];
+};
+
+extern struct meminfo meminfo;

arch/unicore32/include/asm/setup.h line 47

Quoted 10 lines
arch/unicore32/include/asm/setup.h new file +10 -0
+
+#define for_each_bank(iter, mi)				\
+	for (iter = 0; iter < (mi)->nr_banks; iter++)
+
+#define bank_pfn_start(bank)	__phys_to_pfn((bank)->start)
+#define bank_pfn_end(bank)	__phys_to_pfn((bank)->start + (bank)->size)
+#define bank_pfn_size(bank)	((bank)->size >> PAGE_SHIFT)
+#define bank_phys_start(bank)	((bank)->start)
+#define bank_phys_end(bank)	((bank)->start + (bank)->size)
+#define bank_phys_size(bank)	((bank)->size)

The membank stuff looks like a variation of the generic memblock interfaces.

Quoted 26 lines
arch/unicore32/kernel/traps.c new file +26 -0
+/*
+ * Handle all unrecognised system calls.
+ *  0x9f0000 - 0x9fffff are some more esoteric system calls
+ */
+#define NR(x) ((__UNICORE_NR_##x) - __UNICORE_NR_BASE)
+asmlinkage int uc32_syscall(int no, struct pt_regs *regs)
+{
+	if ((no >> 16) != (__UNICORE_NR_BASE >> 16))
+		return -ENOSYS;
+
+	switch (no & 0xffff) {
+	/*
+	 * Flush a region from virtual address 'r0' to virtual address 'r1'
+	 * _exclusive_.  There is no alignment requirement on either address;
+	 * user space does not need to know the hardware cache layout.
+	 *
+	 * r2 contains flags.  It should ALWAYS be passed as ZERO until it
+	 * is defined to be something else.  For now we ignore it, but may
+	 * the fires of hell burn in your belly if you break this rule. ;)
+	 *
+	 * (at a later date, we may want to allow this call to not flush
+	 * various aspects of the cache.  Passing '0' will guarantee that
+	 * everything necessary gets flushed to maintain consistency in
+	 * the specified region).
+	 */
+	case NR(cacheflush):

arch/unicore32/kernel/traps.c line 407

Quoted 10 lines
arch/unicore32/kernel/traps.c new file +10 -0
+		do_cache_op(regs->UCreg_00, regs->UCreg_01, regs->UCreg_02);
+		return 0;
+
+	case NR(cmpxchg):
+		return do_cmpxchg_op(regs);
+
+	default:
+		return -ENOSYS;
+	}
+}

With the generic system cal interface, this function should be replaced with straight system calls for each of the subfunctions.

Just use things definitions like

#define __NR_cacheflush __NR_arch_specific_syscall __SYSCALL(__NR_cacheflush, sys_uc32_cacheflush) #define __NR_cmpxchg __NR_arch_specific_syscall+1 __SYSCALL(__NR_cmpxchg, sys_uc32_cacheflush

in your asm/unistd.h file.

Arnd

#2 lore raw
Quoted 33 lines

-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: Friday, January 07, 2011 8:05 AM
To: Guan Xuetao
Cc: [email protected]; [email protected]
Subject: Re: [PATCHv1 04/12] unicore32 core architecture: low level entry and setup code

Quoted 23 lines · Guan Xuetao
arch/unicore32/include/asm/setup.h new file +23 -0
+#ifdef __KERNEL__
+
+/*
+ * Memory map description
+ */
+# define NR_BANKS 8
+
+struct membank {
+	unsigned long start;
+	unsigned long size;
+	unsigned int highmem;
+};
+
+struct meminfo {
+	int nr_banks;
+	struct membank bank[NR_BANKS];
+};
+
+extern struct meminfo meminfo;
+
+#define for_each_bank(iter, mi)				\
+	for (iter = 0; iter < (mi)->nr_banks; iter++)
+
Quoted 8 lines

arch/unicore32/include/asm/setup.h line 47

Quoted 6 lines
arch/unicore32/include/asm/setup.h new file +6 -0
+#define bank_pfn_start(bank)	__phys_to_pfn((bank)->start)
+#define bank_pfn_end(bank)	__phys_to_pfn((bank)->start + (bank)->size)
+#define bank_pfn_size(bank)	((bank)->size >> PAGE_SHIFT)
+#define bank_phys_start(bank)	((bank)->start)
+#define bank_phys_end(bank)	((bank)->start + (bank)->size)
+#define bank_phys_size(bank)	((bank)->size)

The membank stuff looks like a variation of the generic memblock interfaces.

Memblock codes came from arm, and I can only find similar definitions in arm, unicore32, and perhaps xtensa's sysmem_info.
So, I suggest an empty memblock.h is preferred, and perhaps more architectures could use it.

Quoted 41 lines
Quoted 27 lines
arch/unicore32/kernel/traps.c new file +26 -0
+/*
+ * Handle all unrecognised system calls.
+ *  0x9f0000 - 0x9fffff are some more esoteric system calls
+ */
+#define NR(x) ((__UNICORE_NR_##x) - __UNICORE_NR_BASE)
+asmlinkage int uc32_syscall(int no, struct pt_regs *regs)
+{
+	if ((no >> 16) != (__UNICORE_NR_BASE >> 16))
+		return -ENOSYS;
+
+	switch (no & 0xffff) {
+	/*
+	 * Flush a region from virtual address 'r0' to virtual address 'r1'
+	 * _exclusive_.  There is no alignment requirement on either address;
+	 * user space does not need to know the hardware cache layout.
+	 *
+	 * r2 contains flags.  It should ALWAYS be passed as ZERO until it
+	 * is defined to be something else.  For now we ignore it, but may
+	 * the fires of hell burn in your belly if you break this rule. ;)
+	 *
+	 * (at a later date, we may want to allow this call to not flush
+	 * various aspects of the cache.  Passing '0' will guarantee that
+	 * everything necessary gets flushed to maintain consistency in
+	 * the specified region).
+	 */
+	case NR(cacheflush):

arch/unicore32/kernel/traps.c line 407

Quoted 10 lines
arch/unicore32/kernel/traps.c new file +10 -0
+		do_cache_op(regs->UCreg_00, regs->UCreg_01, regs->UCreg_02);
+		return 0;
+
+	case NR(cmpxchg):
+		return do_cmpxchg_op(regs);
+
+	default:
+		return -ENOSYS;
+	}
+}

With the generic system cal interface, this function should be replaced with straight system calls for each of the subfunctions.

Quoted 8 lines

Just use things definitions like

#define __NR_cacheflush __NR_arch_specific_syscall __SYSCALL(__NR_cacheflush, sys_uc32_cacheflush) #define __NR_cmpxchg __NR_arch_specific_syscall+1 __SYSCALL(__NR_cmpxchg, sys_uc32_cacheflush

in your asm/unistd.h file.

Yes. Thanks. It's high time to do this work for me.

Guan Xuetao