public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Salter <msalter@redhat.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 16/16] C6X: add support for DSBT binary format
Date: Wed, 11 May 2011 16:14:03 -0400	[thread overview]
Message-ID: <1305144843-5058-17-git-send-email-msalter@redhat.com> (raw)
In-Reply-To: <1305144843-5058-16-git-send-email-msalter@redhat.com>

This patch adds the C6X-specifc bits to use the DSBT binary format.

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 arch/c6x/configs/ti_dsk6455_defconfig       |    1 +
 arch/c6x/configs/ti_evmc6457_defconfig      |    1 +
 arch/c6x/configs/ti_evmc6472_defconfig      |    1 +
 arch/c6x/configs/ti_evmc6474_defconfig      |    1 +
 arch/c6x/configs/ti_evmc6474_lite_defconfig |    1 +
 arch/c6x/include/asm/elf.h                  |   14 ++++++++++++++
 arch/c6x/include/asm/mmu.h                  |    4 ++++
 arch/c6x/include/asm/ptrace.h               |   12 ++++++++++++
 arch/c6x/kernel/ptrace.c                    |   25 ++++++++++++++++++++++++-
 9 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/arch/c6x/configs/ti_dsk6455_defconfig b/arch/c6x/configs/ti_dsk6455_defconfig
index 3487af4..8112a70 100644
--- a/arch/c6x/configs/ti_dsk6455_defconfig
+++ b/arch/c6x/configs/ti_dsk6455_defconfig
@@ -229,6 +229,7 @@ CONFIG_HIGH_RES_TIMERS=y
 #
 # Executable file formats
 #
+CONFIG_BINFMT_ELF_DSBT=y
 # CONFIG_BINFMT_FLAT is not set
 # CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
diff --git a/arch/c6x/configs/ti_evmc6457_defconfig b/arch/c6x/configs/ti_evmc6457_defconfig
index e18b095..841f15a 100644
--- a/arch/c6x/configs/ti_evmc6457_defconfig
+++ b/arch/c6x/configs/ti_evmc6457_defconfig
@@ -229,6 +229,7 @@ CONFIG_HIGH_RES_TIMERS=y
 #
 # Executable file formats
 #
+CONFIG_BINFMT_ELF_DSBT=y
 # CONFIG_BINFMT_FLAT is not set
 # CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
diff --git a/arch/c6x/configs/ti_evmc6472_defconfig b/arch/c6x/configs/ti_evmc6472_defconfig
index 14ae81b..b18e9ee 100644
--- a/arch/c6x/configs/ti_evmc6472_defconfig
+++ b/arch/c6x/configs/ti_evmc6472_defconfig
@@ -231,6 +231,7 @@ CONFIG_HIGH_RES_TIMERS=y
 #
 # Executable file formats
 #
+CONFIG_BINFMT_ELF_DSBT=y
 # CONFIG_BINFMT_FLAT is not set
 # CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
diff --git a/arch/c6x/configs/ti_evmc6474_defconfig b/arch/c6x/configs/ti_evmc6474_defconfig
index 472ad6b..12f1808 100644
--- a/arch/c6x/configs/ti_evmc6474_defconfig
+++ b/arch/c6x/configs/ti_evmc6474_defconfig
@@ -229,6 +229,7 @@ CONFIG_HIGH_RES_TIMERS=y
 #
 # Executable file formats
 #
+CONFIG_BINFMT_ELF_DSBT=y
 # CONFIG_BINFMT_FLAT is not set
 # CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
diff --git a/arch/c6x/configs/ti_evmc6474_lite_defconfig b/arch/c6x/configs/ti_evmc6474_lite_defconfig
index e25e8ac..044cf47 100644
--- a/arch/c6x/configs/ti_evmc6474_lite_defconfig
+++ b/arch/c6x/configs/ti_evmc6474_lite_defconfig
@@ -229,6 +229,7 @@ CONFIG_HIGH_RES_TIMERS=y
 #
 # Executable file formats
 #
+CONFIG_BINFMT_ELF_DSBT=y
 # CONFIG_BINFMT_FLAT is not set
 # CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
diff --git a/arch/c6x/include/asm/elf.h b/arch/c6x/include/asm/elf.h
index 272c3ae..d57bb17 100644
--- a/arch/c6x/include/asm/elf.h
+++ b/arch/c6x/include/asm/elf.h
@@ -32,6 +32,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  */
 #define elf_check_arch(x) ((x)->e_machine == EM_TI_C6000)
 
+#define elf_check_dsbt(x) (1)
 #define elf_check_const_displacement(x) (1)
 
 /*
@@ -67,6 +68,14 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
 #define ELF_PLATFORM  (NULL)
 
+#define ELF_DSBT_PLAT_INIT(_regs, _exec_map, _interp_map, _dynamic_addr, _dsbt_table) \
+do {								\
+	_regs->b4	= (_exec_map);				\
+	_regs->a6	= (_interp_map);			\
+	_regs->b6	= (_dynamic_addr);			\
+	_regs->dp	= (_dsbt_table);			\
+} while (0)
+
 #define SET_PERSONALITY(ex) set_personality(PER_LINUX)
 
 /* C6X specific section types */
@@ -112,4 +121,9 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 #define R_C6000_FPHEAD		254
 #define R_C6000_NOCMP		255
 
+/* for binfmt_elf_dsbt */
+#define DT_ARCH_DSBT_BASE  DT_C6000_DSBT_BASE
+#define DT_ARCH_DSBT_SIZE  DT_C6000_DSBT_SIZE
+#define DT_ARCH_DSBT_INDEX DT_C6000_DSBT_INDEX
+
 #endif /*_ASM_C6X_ELF_H */
diff --git a/arch/c6x/include/asm/mmu.h b/arch/c6x/include/asm/mmu.h
index 8d376e9..1d9e9c1 100644
--- a/arch/c6x/include/asm/mmu.h
+++ b/arch/c6x/include/asm/mmu.h
@@ -15,6 +15,10 @@
 
 typedef struct {
 	unsigned long		end_brk;
+#ifdef CONFIG_BINFMT_ELF_DSBT
+	unsigned long	exec_dsbt_loadmap;
+	unsigned long	interp_dsbt_loadmap;
+#endif
 } mm_context_t;
 
 #endif /* _ASM_C6X_MMU_H */
diff --git a/arch/c6x/include/asm/ptrace.h b/arch/c6x/include/asm/ptrace.h
index 7e94de8..437df6f 100644
--- a/arch/c6x/include/asm/ptrace.h
+++ b/arch/c6x/include/asm/ptrace.h
@@ -162,11 +162,23 @@ struct pt_regs {
 	REG_PAIR(sp, dp);
 };
 
+/*
+ * These are 'magic' values for PTRACE_PEEKUSR that return info about where a
+ * process is located in memory.
+ */
+#define PT_TEXT_ADDR		  0x10000
+#define PT_DATA_ADDR		  0x10004
+#define PT_TEXT_END_ADDR	  0x10008
+
 #define PTRACE_GETREGS		  12
 #define PTRACE_SETREGS		  13
 #define PTRACE_GETFPREGS	  14
 #define PTRACE_SETFPREGS	  15
 
+#define PTRACE_GETDSBT		 31	/* get the ELF DSBT loadmap address */
+#define PTRACE_GETDSBT_EXEC	  0	/* [addr] request the executable loadmap */
+#define PTRACE_GETDSBT_INTERP	  1	/* [addr] request the interpreter loadmap */
+
 #ifdef __KERNEL__
 
 #define DEFAULT_CSR		  0x0001	/* interrupt enable by default */
diff --git a/arch/c6x/kernel/ptrace.c b/arch/c6x/kernel/ptrace.c
index fd38463..aa853e4 100644
--- a/arch/c6x/kernel/ptrace.c
+++ b/arch/c6x/kernel/ptrace.c
@@ -167,7 +167,13 @@ static int ptrace_read_user(struct task_struct *tsk, unsigned long off,
 
 
 	tmp = 0;
-	if (off < PT_REG_SIZE)
+	if (index == PT_TEXT_ADDR)
+		tmp = tsk->mm->start_code;
+	else if (index == PT_DATA_ADDR)
+		tmp = tsk->mm->start_data;
+	else if (index == PT_TEXT_END_ADDR)
+		tmp = tsk->mm->end_code;
+	else if (off < PT_REG_SIZE)
 		tmp = get_reg(tsk, index);
 	else
 		return -EIO;
@@ -250,6 +256,23 @@ long arch_ptrace(struct task_struct *child, long request,
 		}
 		break;
 
+	case PTRACE_GETDSBT: {
+		tmp = 0;
+		switch (addr) {
+		case PTRACE_GETDSBT_EXEC:
+			tmp = child->mm->context.exec_dsbt_loadmap;
+			break;
+		case PTRACE_GETDSBT_INTERP:
+			tmp = child->mm->context.interp_dsbt_loadmap;
+			break;
+		default:
+			break;
+		}
+
+		ret = put_user(tmp, (unsigned long __user *)data);
+		break;
+	}
+
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
-- 
1.6.2.5


  reply	other threads:[~2011-05-11 21:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-11 20:13 [PATCH] arch/c6x: new architecture port for linux Mark Salter
2011-05-11 20:13 ` [PATCH 01/16] fix default __strnlen_user macro Mark Salter
2011-05-11 20:13   ` [PATCH 02/16] fixed generic page.h for non-zero PAGE_OFFSET Mark Salter
2011-05-11 20:13     ` [PATCH 03/16] add driver for C64x+ ethernet driver Mark Salter
2011-05-11 20:13       ` [PATCH 04/16] add support for C64x+ debugger based console Mark Salter
2011-05-11 20:13         ` [PATCH 05/16] add ELF machine define for TI C6X DSPs Mark Salter
2011-05-11 20:13           ` [PATCH 06/16] add maintainers entry for C6X arch Mark Salter
2011-05-11 20:13             ` [PATCH 07/16] C6X: add toplevel configury and makefile Mark Salter
2011-05-11 20:13               ` [PATCH 08/16] C6X: add include files Mark Salter
2011-05-11 20:13                 ` [PATCH 09/16] C6X: add kernel files Mark Salter
2011-05-11 20:13                   ` [PATCH 10/16] C6X: add mm files Mark Salter
2011-05-11 20:13                     ` [PATCH 11/16] C6X: add lib files Mark Salter
2011-05-11 20:13                       ` [PATCH 12/16] C6X: add platform files Mark Salter
2011-05-11 20:14                         ` [PATCH 13/16] C6X: add drivers/platform/c6x files Mark Salter
2011-05-11 20:14                           ` [PATCH 14/16] C6X: add default configs Mark Salter
2011-05-11 20:14                             ` [PATCH 15/16] Add new elf binfmt support for DSBT Mark Salter
2011-05-11 20:14                               ` Mark Salter [this message]
2011-05-12  2:41         ` [04/16] add support for C64x+ debugger based console Milton Miller
2011-05-12 12:55           ` Mark Salter
2011-05-12  0:49       ` [PATCH 03/16] add driver for C64x+ ethernet driver Joe Perches
2011-05-13 15:30       ` Ben Hutchings
2011-05-13 13:55   ` [PATCH 01/16] fix default __strnlen_user macro Pavel Machek
2011-05-13 14:40     ` Mark Salter
2011-05-11 20:13 ` [PATCH] arch/c6x: new architecture port for linux Milton Miller
2011-05-12 12:34   ` Mark Salter
2011-05-11 21:34 ` Randy Dunlap
2011-05-12  0:57   ` Mark Salter
2011-05-12  1:07     ` Randy Dunlap
2011-05-12  1:16       ` Mark Salter
2011-05-21 17:10 ` Arnd Bergmann
2011-05-21 17:46   ` Geert Uytterhoeven
2011-06-16 12:54   ` Mark Salter
2011-06-16 14:02     ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305144843-5058-17-git-send-email-msalter@redhat.com \
    --to=msalter@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox