Skip to contentSkip to conversation

unicore32 core architecture: generic headers stuff

PATCH In review Guan Xuetao 2 participants 4 messages Dec 25, 2010 – Jan 9, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/12 unicore32 core architecture: generic headers stuff

From: Guan Xuetao <[email protected]>

This patch includes some generic headers stuff. Because all one-line asm-generic headers
are auto-generated by ASM_GENERIC_HEADERS in arch/unicore32/Makefile,
so the rest seems very little. ELF handling functions are also here.

---
 arch/unicore32/include/asm/elf.h    |   94 +++++++++++++++++++++++++++++++++++
 arch/unicore32/include/asm/ftrace.h |    4 ++
 arch/unicore32/include/asm/sizes.h  |   47 +++++++++++++++++
 arch/unicore32/include/asm/stat.h   |   71 ++++++++++++++++++++++++++
 arch/unicore32/include/asm/string.h |   52 +++++++++++++++++++
 arch/unicore32/kernel/elf.c         |   38 ++++++++++++++
 6 files changed, 306 insertions(+), 0 deletions(-)
arch/unicore32/include/asm/elf.h new file +94 -0
new file mode 100644
index 0000000..8e2e311
@@ -0,0 +1,94 @@
+/*
+ * linux/arch/unicore32/include/asm/elf.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_ELF_H__
+#define __UNICORE_ELF_H__
+
+#include <asm/hwcap.h>
+
+/*
+ * ELF register definitions..
+ */
+#include <asm/ptrace.h>
+
+typedef unsigned long elf_greg_t;
+typedef unsigned long elf_freg_t[3];
+
+#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef struct fp_soft_struct elf_fpregset_t;
+
+#define EM_UNICORE		110
+
+#define R_UNICORE_NONE		0
+#define R_UNICORE_PC24		1
+#define R_UNICORE_ABS32		2
+#define R_UNICORE_CALL		28
+#define R_UNICORE_JUMP24	29
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS	ELFCLASS32
+#define ELF_DATA	ELFDATA2LSB
+#define ELF_ARCH	EM_UNICORE
+
+/*
+ * This yields a string that ld.so will use to load implementation
+ * specific libraries for optimization.  This is more specific in
+ * intent than poking at uname or /proc/cpuinfo.
+ *
+ */
+#define ELF_PLATFORM_SIZE 8
+#define ELF_PLATFORM	(elf_platform)
+
+extern char elf_platform[];
+
+struct elf32_hdr;
+
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+extern int elf_check_arch(const struct elf32_hdr *);
+#define elf_check_arch elf_check_arch
+
+struct task_struct;
+int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
+#define ELF_CORE_COPY_TASK_REGS dump_task_regs
+
+#define ELF_EXEC_PAGESIZE	4096
+
+/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
+   use of this is to invoke "./ld.so someprog" to test out a new version of
+   the loader.  We need to make sure that it is out of the way of the program
+   that it will "exec", and that there is sufficient room for the brk.  */
+
+#define ELF_ET_DYN_BASE	(2 * TASK_SIZE / 3)
+
+/* When the program starts, a1 contains a pointer to a function to be
+   registered with atexit, as per the SVR4 ABI.  A value of 0 means we
+   have no such handler.  */
+#define ELF_PLAT_INIT(_r, load_addr)	{(_r)->UCreg_00 = 0; }
+
+extern void elf_set_personality(const struct elf32_hdr *);
+#define SET_PERSONALITY(ex)	elf_set_personality(&(ex))
+
+struct mm_struct;
+extern unsigned long arch_randomize_brk(struct mm_struct *mm);
+#define arch_randomize_brk arch_randomize_brk
+
+extern int vectors_user_mapping(void);
+#define arch_setup_additional_pages(bprm, uses_interp) vectors_user_mapping()
+#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
+
+#endif
arch/unicore32/include/asm/ftrace.h new file +4 -0
new file mode 100644
index 0000000..6adc683
@@ -0,0 +1,4 @@
+#ifndef __UNICORE_FTRACE_H__
+#define __UNICORE_FTRACE_H__
+
+#endif
arch/unicore32/include/asm/sizes.h new file +47 -0

47 lines not on this page · raw message

arch/unicore32/include/asm/stat.h new file +71 -0

71 lines not on this page · raw message

arch/unicore32/include/asm/string.h new file +52 -0

52 lines not on this page · raw message

arch/unicore32/kernel/elf.c new file +38 -0
new file mode 100644
index 0000000..0a17673
@@ -0,0 +1,38 @@
+/*
+ * linux/arch/unicore32/kernel/elf.c
+ *
+ * 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.
+ */
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/personality.h>
+#include <linux/binfmts.h>
+#include <linux/elf.h>
+
+int elf_check_arch(const struct elf32_hdr *x)
+{
+	/* Make sure it's an UniCore executable */
+	if (x->e_machine != EM_UNICORE)
+		return 0;
+
+	/* Make sure the entry address is reasonable */
+	if (x->e_entry & 3)
+		return 0;
+
+	return 1;
+}
+EXPORT_SYMBOL(elf_check_arch);
+
+void elf_set_personality(const struct elf32_hdr *x)
+{
+	unsigned int personality = PER_LINUX;
+
+	set_personality(personality);
+}
+EXPORT_SYMBOL(elf_set_personality);
maintainer
#1 lore raw
Quoted 15 lines · Guan Xuetao
arch/unicore32/include/asm/sizes.h new file +9 -0
new file mode 100644
index 0000000..3720307
@@ -0,0 +1,47 @@
+/*
+ * linux/arch/unicore32/include/asm/sizes.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

arch/unicore32/include/asm/sizes.h line 18

Quoted 10 lines
arch/unicore32/include/asm/sizes.h new file +9 -0
+ * published by the Free Software Foundation.
+ */
+#ifndef __UNICORE_SIZES_H__
+#define __UNICORE_SIZES_H__
+
+/* handy sizes */
+#define SZ_16				0x00000010
+#define SZ_256				0x00000100
+#define SZ_512				0x00000200
...

This would be nice to have in include/asm-generic. Please make a patch that adds the file there and use it with your scripts.

arch/unicore32/include/asm/stat.h line 2

Quoted 5 lines
arch/unicore32/include/asm/stat.h new file +2 -0
@@ -0,0 +1,71 @@
+/*
+ * linux/arch/unicore32/include/asm/stat.h

I think we discussed this particular header before. There should be no reason to have your own version instead of using the generic file like you do for the rest of the API headers.

Arnd

#2 lore raw
Quoted 30 lines

-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: Friday, January 07, 2011 7:56 AM
To: Guan Xuetao
Cc: [email protected]; [email protected]
Subject: Re: [PATCHv1 02/12] unicore32 core architecture: generic headers stuff

Quoted 20 lines · Guan Xuetao
arch/unicore32/include/asm/sizes.h new file +14 -0
new file mode 100644
index 0000000..3720307
@@ -0,0 +1,47 @@
+/*
+ * linux/arch/unicore32/include/asm/sizes.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_SIZES_H__
+#define __UNICORE_SIZES_H__
+
Quoted 8 lines

arch/unicore32/include/asm/sizes.h line 18

Quoted 5 lines
arch/unicore32/include/asm/sizes.h new file +4 -0
+/* handy sizes */
+#define SZ_16				0x00000010
+#define SZ_256				0x00000100
+#define SZ_512				0x00000200
...

This would be nice to have in include/asm-generic. Please make a patch that adds the file there and use it with your scripts.

Ok, my pleasure.

Quoted 10 lines

arch/unicore32/include/asm/stat.h line 2

Quoted 6 lines
arch/unicore32/include/asm/stat.h new file +2 -0
@@ -0,0 +1,71 @@
+/*
+ * linux/arch/unicore32/include/asm/stat.h

I think we discussed this particular header before. There should be no reason to have your own version instead of using the generic file like you do for the rest of the API headers.

The generic-version stat.h can't work for existing binary file systems in unicore32. I will submit a patch for generic-version stat.h for discussion.

Quoted 2 lines

Arnd

Thanks arnd.

Guan Xuetao

maintainer
#3 lore raw
Quoted 6 lines · Guan Xuetao
Quoted 3 lines

I think we discussed this particular header before. There should be no reason to have your own version instead of using the generic file like you do for the rest of the API headers.

The generic-version stat.h can't work for existing binary file systems in unicore32. I will submit a patch for generic-version stat.h for discussion.

But the generic version of stat.h goes together with the generic version of unistd.h, which the code you submitted is now using.

I understand that you are using a patch to use the traditional system call table right now, on top of the generalized code. Can't you use the same patch for the stat.h file?

Arnd