[PATCH 14/60] microblaze_v4: lmb support - Kernel

This is a discussion on [PATCH 14/60] microblaze_v4: lmb support - Kernel ; From: Michal Simek Signed-off-by: Michal Simek --- include/asm-microblaze/lmb.h | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) create mode 100644 include/asm-microblaze/lmb.h diff --git a/include/asm-microblaze/lmb.h b/include/asm-microblaze/lmb.h new file mode 100644 index 0000000..a0a0a92 --- /dev/null +++ b/include/asm-microblaze/lmb.h @@ -0,0 +1,17 @@ ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: [PATCH 14/60] microblaze_v4: lmb support

  1. [PATCH 14/60] microblaze_v4: lmb support

    From: Michal Simek


    Signed-off-by: Michal Simek
    ---
    include/asm-microblaze/lmb.h | 17 +++++++++++++++++
    1 files changed, 17 insertions(+), 0 deletions(-)
    create mode 100644 include/asm-microblaze/lmb.h

    diff --git a/include/asm-microblaze/lmb.h b/include/asm-microblaze/lmb.h
    new file mode 100644
    index 0000000..a0a0a92
    --- /dev/null
    +++ b/include/asm-microblaze/lmb.h
    @@ -0,0 +1,17 @@
    +/*
    + * Copyright (C) 2008 Michal Simek
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + */
    +
    +#ifndef _ASM_MICROBLAZE_LMB_H
    +#define _ASM_MICROBLAZE_LMB_H
    +
    +/* LMB limit is OFF */
    +#define LMB_REAL_LIMIT 0xFFFFFFFF
    +
    +#endif /* _ASM_MICROBLAZE_LMB_H */
    +
    +
    --
    1.5.4.GIT

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [PATCH 18/60] microblaze_v4: supported function for memory - kernel/lib

    From: Michal Simek


    Signed-off-by: Michal Simek
    ---
    arch/microblaze/lib/memcpy.c | 160 +++++++++++++++++++++++++++++++++++++
    arch/microblaze/lib/memmove.c | 174 +++++++++++++++++++++++++++++++++++++++++
    arch/microblaze/lib/memset.c | 78 ++++++++++++++++++
    3 files changed, 412 insertions(+), 0 deletions(-)
    create mode 100644 arch/microblaze/lib/memcpy.c
    create mode 100644 arch/microblaze/lib/memmove.c
    create mode 100644 arch/microblaze/lib/memset.c

    diff --git a/arch/microblaze/lib/memcpy.c b/arch/microblaze/lib/memcpy.c
    new file mode 100644
    index 0000000..199668d
    --- /dev/null
    +++ b/arch/microblaze/lib/memcpy.c
    @@ -0,0 +1,160 @@
    +/*
    + * Copyright (C) 2008 Michal Simek
    + *
    + * Reasonably optimised generic C-code for memcpy on Microblaze
    + * This is generic C code to do efficient, alignment-aware memcpy.
    + *
    + * It is based on demo code originally Copyright 2001 by Intel Corp, taken from
    + * http://www.embedded.com/showArticle....cleID=19205567
    + *
    + * Attempts were made, unsuccesfully, to contact the original
    + * author of this code (Michael Morrow, Intel). Below is the original
    + * copyright notice.
    + *
    + * This software has been developed by Intel Corporation.
    + * Intel specifically disclaims all warranties, express or
    + * implied, and all liability, including consequential and
    + * other indirect damages, for the use of this program, including
    + * liability for infringement of any proprietary rights,
    + * and including the warranties of merchantability and fitness
    + * for a particular purpose. Intel does not assume any
    + * responsibility for and errors which may appear in this program
    + * not any responsibility to update it.
    + */
    +
    +#include
    +#include
    +#include
    +#include
    +
    +#include
    +#include
    +
    +#ifdef __HAVE_ARCH_MEMCPY
    +void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
    +{
    + const char *src = v_src;
    + char *dst = v_dst;
    +#ifndef CONFIG_OPT_LIB_FUNCTION
    + /* Simple, byte oriented memcpy. */
    + while (c--)
    + *dst++ = *src++;
    +
    + return v_dst;
    +#else
    + /* The following code tries to optimize the copy by using unsigned
    + * alignment. This will work fine if both source and destination are
    + * aligned on the same boundary. However, if they are aligned on
    + * different boundaries shifts will be necessary. This might result in
    + * bad performance on MicroBlaze systems without a barrel shifter.
    + */
    + const uint32_t *i_src;
    + uint32_t *i_dst;
    +
    + if (c >= 4) {
    + unsigned value, buf_hold;
    +
    + /* Align the dstination to a word boundry. */
    + /* This is done in an endian independant manner. */
    + switch ((unsigned long)dst & 3) {
    + case 1:
    + *dst++ = *src++;
    + --c;
    + case 2:
    + *dst++ = *src++;
    + --c;
    + case 3:
    + *dst++ = *src++;
    + --c;
    + }
    +
    + i_dst = (void *)dst;
    +
    + /* Choose a copy scheme based on the source */
    + /* alignment relative to dstination. */
    + switch ((unsigned long)src & 3) {
    + case 0x0: /* Both byte offsets are aligned */
    + i_src = (const void *)src;
    +
    + for (; c >= 4; c -= 4)
    + *i_dst++ = *i_src++;
    +
    + src = (const void *)i_src;
    + break;
    + case 0x1: /* Unaligned - Off by 1 */
    + /* Word align the source */
    + i_src = (const void *) ((unsigned)src & ~3);
    +
    + /* Load the holding buffer */
    + buf_hold = *i_src++ << 8;
    +
    + for (; c >= 4; c -= 4) {
    + value = *i_src++;
    + *i_dst++ = buf_hold | value >> 24;
    + buf_hold = value << 8;
    + }
    +
    + /* Realign the source */
    + src = (const void *)i_src;
    + src -= 3;
    + break;
    + case 0x2: /* Unaligned - Off by 2 */
    + /* Word align the source */
    + i_src = (const void *) ((unsigned)src & ~3);
    +
    + /* Load the holding buffer */
    + buf_hold = *i_src++ << 16;
    +
    + for (; c >= 4; c -= 4) {
    + value = *i_src++;
    + *i_dst++ = buf_hold | value >> 16;
    + buf_hold = value << 16;
    + }
    +
    + /* Realign the source */
    + src = (const void *)i_src;
    + src -= 2;
    + break;
    + case 0x3: /* Unaligned - Off by 3 */
    + /* Word align the source */
    + i_src = (const void *) ((unsigned)src & ~3);
    +
    + /* Load the holding buffer */
    + buf_hold = *i_src++ << 24;
    +
    + for (; c >= 4; c -= 4) {
    + value = *i_src++;
    + *i_dst++ = buf_hold | value >> 8;
    + buf_hold = value << 24;
    + }
    +
    + /* Realign the source */
    + src = (const void *)i_src;
    + src -= 1;
    + break;
    + }
    + dst = (void *)i_dst;
    + }
    +
    + /* Finish off any remaining bytes */
    + /* simple fast copy, ... unless a cache boundry is crossed */
    + switch (c) {
    + case 3:
    + *dst++ = *src++;
    + case 2:
    + *dst++ = *src++;
    + case 1:
    + *dst++ = *src++;
    + }
    +
    + return v_dst;
    +#endif
    +}
    +EXPORT_SYMBOL(memcpy);
    +#endif /* __HAVE_ARCH_MEMCPY */
    +
    +
    +void *cacheable_memcpy(void *d, const void *s, __kernel_size_t c)
    +{
    + return memcpy(d, s, c);
    +}
    diff --git a/arch/microblaze/lib/memmove.c b/arch/microblaze/lib/memmove.c
    new file mode 100644
    index 0000000..4db1ea6
    --- /dev/null
    +++ b/arch/microblaze/lib/memmove.c
    @@ -0,0 +1,174 @@
    +/*
    + * Copyright (C) 2008 Michal Simek
    + *
    + * Reasonably optimised generic C-code for memcpy on Microblaze
    + * This is generic C code to do efficient, alignment-aware memmove.
    + *
    + * It is based on demo code originally Copyright 2001 by Intel Corp, taken from
    + * http://www.embedded.com/showArticle....cleID=19205567
    + *
    + * Attempts were made, unsuccesfully, to contact the original
    + * author of this code (Michael Morrow, Intel). Below is the original
    + * copyright notice.
    + *
    + * This software has been developed by Intel Corporation.
    + * Intel specifically disclaims all warranties, express or
    + * implied, and all liability, including consequential and
    + * other indirect damages, for the use of this program, including
    + * liability for infringement of any proprietary rights,
    + * and including the warranties of merchantability and fitness
    + * for a particular purpose. Intel does not assume any
    + * responsibility for and errors which may appear in this program
    + * not any responsibility to update it.
    + */
    +
    +#include
    +#include
    +#include
    +#include
    +
    +#include
    +
    +#ifdef __HAVE_ARCH_MEMMOVE
    +void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
    +{
    + const char *src = v_src;
    + char *dst = v_dst;
    +
    +#ifdef CONFIG_OPT_LIB_FUNCTION
    + const uint32_t *i_src;
    + uint32_t *i_dst;
    +#endif
    +
    + if (!c)
    + return v_dst;
    +
    + /* Use memcpy when source is higher than dest */
    + if (v_dst <= v_src)
    + return memcpy(v_dst, v_src, c);
    +
    +#ifndef CONFIG_OPT_LIB_FUNCTION
    + /* copy backwards, from end to beginning */
    + src += c;
    + dst += c;
    +
    + /* Simple, byte oriented memmove. */
    + while (c--)
    + *--dst = *--src;
    +
    + return v_dst;
    +#else
    + /* The following code tries to optimize the copy by using unsigned
    + * alignment. This will work fine if both source and destination are
    + * aligned on the same boundary. However, if they are aligned on
    + * different boundaries shifts will be necessary. This might result in
    + * bad performance on MicroBlaze systems without a barrel shifter.
    + */
    + /* FIXME this part needs more test */
    + /* Do a descending copy - this is a bit trickier! */
    + dst += c;
    + src += c;
    +
    + if (c >= 4) {
    + unsigned value, buf_hold;
    +
    + /* Align the destination to a word boundry. */
    + /* This is done in an endian independant manner. */
    +
    + switch ((unsigned long)dst & 3) {
    + case 3:
    + *--dst = *--src;
    + --c;
    + case 2:
    + *--dst = *--src;
    + --c;
    + case 1:
    + *--dst = *--src;
    + --c;
    + }
    +
    + i_dst = (void *)dst;
    + /* Choose a copy scheme based on the source */
    + /* alignment relative to dstination. */
    + switch ((unsigned long)src & 3) {
    + case 0x0: /* Both byte offsets are aligned */
    +
    + i_src = (const void *)src;
    +
    + for (; c >= 4; c -= 4)
    + *--i_dst = *--i_src;
    +
    + src = (const void *)i_src;
    + break;
    + case 0x1: /* Unaligned - Off by 1 */
    + /* Word align the source */
    + i_src = (const void *) (((unsigned)src + 4) & ~3);
    +
    + /* Load the holding buffer */
    + buf_hold = *--i_src >> 24;
    +
    + for (; c >= 4; c -= 4) {
    + value = *--i_src;
    + *--i_dst = buf_hold << 8 | value;
    + buf_hold = value >> 24;
    + }
    +
    + /* Realign the source */
    + src = (const void *)i_src;
    + src += 1;
    + break;
    + case 0x2: /* Unaligned - Off by 2 */
    + /* Word align the source */
    + i_src = (const void *) (((unsigned)src + 4) & ~3);
    +
    + /* Load the holding buffer */
    + buf_hold = *--i_src >> 16;
    +
    + for (; c >= 4; c -= 4) {
    + value = *--i_src;
    + *--i_dst = buf_hold << 16 | value;
    + buf_hold = value >> 16;
    + }
    +
    + /* Realign the source */
    + src = (const void *)i_src;
    + src += 2;
    + break;
    + case 0x3: /* Unaligned - Off by 3 */
    + /* Word align the source */
    + i_src = (const void *) (((unsigned)src + 4) & ~3);
    +
    + /* Load the holding buffer */
    + buf_hold = *--i_src >> 8;
    +
    + for (; c >= 4; c -= 4) {
    + value = *--i_src;
    + *--i_dst = buf_hold << 24 | value;
    + buf_hold = value >> 8;
    + }
    +
    + /* Realign the source */
    + src = (const void *)i_src;
    + src += 3;
    + break;
    + }
    + dst = (void *)i_dst;
    + }
    +
    + /* simple fast copy, ... unless a cache boundry is crossed */
    + /* Finish off any remaining bytes */
    + switch (c) {
    + case 4:
    + *--dst = *--src;
    + case 3:
    + *--dst = *--src;
    + case 2:
    + *--dst = *--src;
    + case 1:
    + *--dst = *--src;
    + }
    + return v_dst;
    +#endif
    +}
    +EXPORT_SYMBOL(memmove);
    +#endif /* __HAVE_ARCH_MEMMOVE */
    diff --git a/arch/microblaze/lib/memset.c b/arch/microblaze/lib/memset.c
    new file mode 100644
    index 0000000..6a2f4e5
    --- /dev/null
    +++ b/arch/microblaze/lib/memset.c
    @@ -0,0 +1,78 @@
    +/*
    + * Copyright (C) 2008 Michal Simek
    + *
    + * Reasonably optimised generic C-code for memset on Microblaze
    + * This is generic C code to do efficient, alignment-aware memcpy.
    + *
    + * It is based on demo code originally Copyright 2001 by Intel Corp, taken from
    + * http://www.embedded.com/showArticle....cleID=19205567
    + *
    + * Attempts were made, unsuccesfully, to contact the original
    + * author of this code (Michael Morrow, Intel). Below is the original
    + * copyright notice.
    + *
    + * This software has been developed by Intel Corporation.
    + * Intel specifically disclaims all warranties, express or
    + * implied, and all liability, including consequential and
    + * other indirect damages, for the use of this program, including
    + * liability for infringement of any proprietary rights,
    + * and including the warranties of merchantability and fitness
    + * for a particular purpose. Intel does not assume any
    + * responsibility for and errors which may appear in this program
    + * not any responsibility to update it.
    + */
    +
    +#include
    +#include
    +#include
    +#include
    +
    +#include
    +
    +#ifdef __HAVE_ARCH_MEMSET
    +void *memset(void *v_src, int c, __kernel_size_t n)
    +{
    +
    + char *src = v_src;
    +#ifdef CONFIG_OPT_LIB_FUNCTION
    + uint32_t *i_src;
    + uint32_t w32;
    +#endif
    + /* Truncate c to 8 bits */
    + c = (c & 0xFF);
    +
    +#ifdef CONFIG_OPT_LIB_FUNCTION
    + /* Make a repeating word out of it */
    + w32 = c;
    + w32 |= w32 << 8;
    + w32 |= w32 << 16;
    +
    + if (n >= 4) {
    + /* Align the destination to a word boundary */
    + /* This is done in an endian independant manner */
    + switch ((unsigned) src & 3) {
    + case 1: *src++ = c;
    + --n;
    + case 2: *src++ = c;
    + --n;
    + case 3: *src++ = c;
    + --n;
    + }
    +
    + i_src = (void *)src;
    +
    + /* Do as many full-word copies as we can */
    + for (; n >= 4; n -= 4)
    + *i_src++ = w32;
    +
    + src = (void *)i_src;
    + }
    +#endif
    + /* Simple, byte oriented memset or the rest of count. */
    + while (n--)
    + *src++ = c;
    +
    + return v_src;
    +}
    +EXPORT_SYMBOL(memset);
    +#endif /* __HAVE_ARCH_MEMSET */
    --
    1.5.4.GIT

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [PATCH 29/60] microblaze_v4: traps support

    From: Michal Simek


    Signed-off-by: Michal Simek
    ---
    arch/microblaze/kernel/traps.c | 86 ++++++++++++++++++++++++++++++++++++++++
    1 files changed, 86 insertions(+), 0 deletions(-)
    create mode 100644 arch/microblaze/kernel/traps.c

    diff --git a/arch/microblaze/kernel/traps.c b/arch/microblaze/kernel/traps.c
    new file mode 100644
    index 0000000..69d75ee
    --- /dev/null
    +++ b/arch/microblaze/kernel/traps.c
    @@ -0,0 +1,86 @@
    +/*
    + * Copyright (C) 2006 Atmark Techno, Inc.
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + */
    +
    +#include
    +#include
    +#include
    +#include
    +
    +#include
    +#include
    +
    +void trap_init(void)
    +{
    + initialize_exception_handlers();
    + __enable_hw_exceptions();
    +}
    +
    +void __bad_xchg(volatile void *ptr, int size)
    +{
    + printk(KERN_INFO "xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n",
    + __builtin_return_address(0), ptr, size);
    + BUG();
    +}
    +EXPORT_SYMBOL(__bad_xchg);
    +
    +static int kstack_depth_to_print = 24;
    +
    +void show_trace(struct task_struct *task, unsigned long *stack)
    +{
    + unsigned long addr;
    +
    + if (!stack)
    + stack = (unsigned long *)&stack;
    +
    + printk(KERN_INFO "Call Trace: ");
    +#ifdef CONFIG_KALLSYMS
    + printk(KERN_INFO "\n");
    +#endif
    + while (!kstack_end(stack)) {
    + addr = *stack++;
    + if (__kernel_text_address(addr)) {
    + printk(KERN_INFO "[<%08lx>] ", addr);
    + print_symbol("%s\n", addr);
    + }
    + }
    + printk(KERN_INFO "\n");
    +}
    +
    +void show_stack(struct task_struct *task, unsigned long *sp)
    +{
    + unsigned long *stack;
    + int i;
    +
    + if (sp == NULL) {
    + if (task)
    + sp = (unsigned long *) ((struct thread_info *)
    + (task->stack))->cpu_context.r1;
    + else
    + sp = (unsigned long *)&sp;
    + }
    +
    + stack = sp;
    +
    + printk(KERN_INFO "\nStack:\n ");
    +
    + for (i = 0; i < kstack_depth_to_print; i++) {
    + if (kstack_end(sp))
    + break;
    + if (i && ((i % 8) == 0))
    + printk("\n ");
    + printk("%08lx ", *sp++);
    + }
    + printk("\n");
    + show_trace(task, stack);
    +}
    +
    +void dump_stack(void)
    +{
    + show_stack(NULL, NULL);
    +}
    +EXPORT_SYMBOL(dump_stack);
    --
    1.5.4.GIT

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. [PATCH 26/60] microblaze_v4: time support

    From: Michal Simek


    Signed-off-by: Michal Simek
    ---
    include/asm-microblaze/delay.h | 30 ++++++++++++++++++++++++++++++
    include/asm-microblaze/timex.h | 18 ++++++++++++++++++
    2 files changed, 48 insertions(+), 0 deletions(-)
    create mode 100644 include/asm-microblaze/delay.h
    create mode 100644 include/asm-microblaze/timex.h

    diff --git a/include/asm-microblaze/delay.h b/include/asm-microblaze/delay.h
    new file mode 100644
    index 0000000..cdafdad
    --- /dev/null
    +++ b/include/asm-microblaze/delay.h
    @@ -0,0 +1,30 @@
    +/*
    + * include/asm-microblaze/delay.h
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + *
    + * Copyright (C) 2006 Atmark Techno, Inc.
    + */
    +
    +#ifndef _ASM_MICROBLAZE_DELAY_H
    +#define _ASM_MICROBLAZE_DELAY_H
    +
    +extern unsigned long loops_per_jiffy;
    +
    +extern inline void __delay(unsigned long loops)
    +{
    + asm volatile ("# __delay \n\t" \
    + "1: addi %0, %0, -1 \t\n" \
    + "bneid %0, 1b \t\n" \
    + "nop \t\n"
    + : "=r" (loops)
    + : "0" (loops));
    +}
    +
    +static inline void udelay(unsigned long usec)
    +{
    +}
    +
    +#endif /* _ASM_MICROBLAZE_DELAY_H */
    diff --git a/include/asm-microblaze/timex.h b/include/asm-microblaze/timex.h
    new file mode 100644
    index 0000000..678525d
    --- /dev/null
    +++ b/include/asm-microblaze/timex.h
    @@ -0,0 +1,18 @@
    +/*
    + * Copyright (C) 2006 Atmark Techno, Inc.
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + */
    +
    +#ifndef _ASM_MICROBLAZE_TIMEX_H
    +#define _ASM_MICROBLAZE_TIMEX_H
    +
    +#define CLOCK_TICK_RATE 1000 /* Timer input freq. */
    +
    +typedef unsigned long cycles_t;
    +
    +#define get_cycles() (0)
    +
    +#endif /* _ASM_TIMEX_H */
    --
    1.5.4.GIT

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. [PATCH 28/60] microblaze_v4: ptrace support

    From: Michal Simek


    Signed-off-by: Michal Simek
    ---
    arch/microblaze/kernel/ptrace.c | 206 +++++++++++++++++++++++++++++++++++++++
    include/asm-microblaze/ptrace.h | 68 +++++++++++++
    2 files changed, 274 insertions(+), 0 deletions(-)
    create mode 100644 arch/microblaze/kernel/ptrace.c
    create mode 100644 include/asm-microblaze/ptrace.h

    diff --git a/arch/microblaze/kernel/ptrace.c b/arch/microblaze/kernel/ptrace.c
    new file mode 100644
    index 0000000..834d463
    --- /dev/null
    +++ b/arch/microblaze/kernel/ptrace.c
    @@ -0,0 +1,206 @@
    +/*
    + * `ptrace' system call
    + *
    + * Copyright (C) 2008 Michal Simek
    + * Copyright (C) 2007 PetaLogix
    + * Copyright (C) 2004-07 John Williams
    + *
    + * derived from arch/v850/kernel/ptrace.c
    + *
    + * Copyright (C) 2002,03 NEC Electronics Corporation
    + * Copyright (C) 2002,03 Miles Bader
    + *
    + * Derived from arch/mips/kernel/ptrace.c:
    + *
    + * Copyright (C) 1992 Ross Biro
    + * Copyright (C) Linus Torvalds
    + * Copyright (C) 1994, 95, 96, 97, 98, 2000 Ralf Baechle
    + * Copyright (C) 1996 David S. Miller
    + * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
    + * Copyright (C) 1999 MIPS Technologies, Inc.
    + *
    + * This file is subject to the terms and conditions of the GNU General
    + * Public License. See the file COPYING in the main directory of this
    + * archive for more details.
    + */
    +
    +#include
    +#include
    +#include
    +#include
    +#include
    +#include
    +
    +#include
    +#include
    +#include
    +#include
    +#include
    +
    +/* Returns the address where the register at REG_OFFS in P is stashed away. */
    +static microblaze_reg_t *reg_save_addr(unsigned reg_offs,
    + struct task_struct *t)
    +{
    + struct pt_regs *regs;
    +
    + /*
    + * Three basic cases:
    + *
    + * (1) A register normally saved before calling the scheduler, is
    + * available in the kernel entry pt_regs structure at the top
    + * of the kernel stack. The kernel trap/irq exit path takes
    + * care to save/restore almost all registers for ptrace'd
    + * processes.
    + *
    + * (2) A call-clobbered register, where the process P entered the
    + * kernel via [syscall] trap, is not stored anywhere; that's
    + * OK, because such registers are not expected to be preserved
    + * when the trap returns anyway (so we don't actually bother to
    + * test for this case).
    + *
    + * (3) A few registers not used at all by the kernel, and so
    + * normally never saved except by context-switches, are in the
    + * context switch state.
    + */
    +
    + /* Register saved during kernel entry (or not available). */
    + regs = task_pt_regs(t);
    +
    + return (microblaze_reg_t *)((char *)regs + reg_offs);
    +}
    +
    +long arch_ptrace(struct task_struct *child, long request, long addr, long data)
    +{
    + int rval;
    +
    + switch (request) {
    + unsigned long val, copied;
    +
    + case PTRACE_PEEKTEXT: /* read word at location addr. */
    + case PTRACE_PEEKDATA:
    + pr_debug("PEEKTEXT/PEEKDATA at %08lX\n", addr);
    + copied = access_process_vm(child, addr, &val, sizeof(val), 0);
    + rval = -EIO;
    + if (copied != sizeof(val))
    + break;
    + rval = put_user(val, (unsigned long *)data);
    + goto out;
    +
    + case PTRACE_POKETEXT: /* write the word at location addr. */
    + case PTRACE_POKEDATA:
    + pr_debug("POKETEXT/POKEDATA to %08lX\n", addr);
    + rval = 0;
    + if (access_process_vm(child, addr, &data, sizeof(data), 1)
    + == sizeof(data))
    + break;
    + rval = -EIO;
    + goto out;
    +
    + /* Read/write the word at location ADDR in the registers. */
    + case PTRACE_PEEKUSR:
    + case PTRACE_POKEUSR:
    + pr_debug("PEEKUSR/POKEUSR : 0x%08lx\n", addr);
    + rval = 0;
    + if (addr >= PT_SIZE && request == PTRACE_PEEKUSR) {
    + /* Special requests that don't actually correspond
    + to offsets in struct pt_regs. */
    + if (addr == PT_TEXT_ADDR) {
    + val = child->mm->start_code;
    + } else if (addr == PT_DATA_ADDR) {
    + val = child->mm->start_data;
    + } else if (addr == PT_TEXT_LEN) {
    + val = child->mm->end_code
    + - child->mm->start_code;
    + } else {
    + rval = -EIO;
    + }
    + } else if (addr >= 0 && addr < PT_SIZE && (addr & 0x3) == 0) {
    + microblaze_reg_t *reg_addr = reg_save_addr(addr, child);
    + if (request == PTRACE_PEEKUSR)
    + val = *reg_addr;
    + else
    + *reg_addr = data;
    + } else
    + rval = -EIO;
    +
    + if (rval == 0 && request == PTRACE_PEEKUSR)
    + rval = put_user(val, (unsigned long *)data);
    + goto out;
    +
    + /* Continue and stop at next (return from) syscall */
    + case PTRACE_SYSCALL:
    + pr_debug("PTRACE_SYSCALL\n");
    + case PTRACE_SINGLESTEP:
    + pr_debug("PTRACE_SINGLESTEP\n");
    + /* Restart after a signal. */
    + case PTRACE_CONT:
    + pr_debug("PTRACE_CONT\n");
    + rval = -EIO;
    + if (!valid_signal(data))
    + break;
    +
    + if (request == PTRACE_SYSCALL)
    + set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
    + else
    + clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
    +
    + child->exit_code = data;
    + pr_debug("wakeup_process\n");
    + wake_up_process(child);
    + rval = 0;
    + break;
    +
    + /*
    + * make the child exit. Best I can do is send it a sigkill.
    + * perhaps it should be put in the status that it wants to
    + * exit.
    + */
    + case PTRACE_KILL:
    + pr_debug("PTRACE_KILL\n");
    + rval = 0;
    + if (child->exit_state == EXIT_ZOMBIE) /* already dead */
    + break;
    + child->exit_code = SIGKILL;
    + wake_up_process(child);
    + break;
    +
    + case PTRACE_DETACH: /* detach a process that was attached. */
    + pr_debug("PTRACE_DETACH\n");
    + rval = ptrace_detach(child, data);
    + break;
    +
    + default:
    + rval = -EIO;
    + goto out;
    + }
    + out:
    + return rval;
    +}
    +
    +#if 0
    +static asmlinkage void syscall_trace(void)
    +{
    + if (!test_thread_flag(TIF_SYSCALL_TRACE))
    + return;
    + if (!(current->ptrace & PT_PTRACED))
    + return;
    + /* The 0x80 provides a way for the tracing parent to distinguish
    + between a syscall stop and SIGTRAP delivery */
    + ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
    + ? 0x80 : 0));
    + /*
    + * this isn't the same as continuing with a signal, but it will do
    + * for normal use. strace only continues with a signal if the
    + * stopping signal is not SIGTRAP. -brl
    + */
    + if (current->exit_code) {
    + send_sig(current->exit_code, current, 1);
    + current->exit_code = 0;
    + }
    +}
    +#endif
    +
    +void ptrace_disable(struct task_struct *child)
    +{
    + /* nothing to do */
    +}
    diff --git a/include/asm-microblaze/ptrace.h b/include/asm-microblaze/ptrace.h
    new file mode 100644
    index 0000000..122f4af
    --- /dev/null
    +++ b/include/asm-microblaze/ptrace.h
    @@ -0,0 +1,68 @@
    +/*
    + * Copyright (C) 2006 Atmark Techno, Inc.
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + */
    +
    +#ifndef _ASM_MICROBLAZE_PTRACE_H
    +#define _ASM_MICROBLAZE_PTRACE_H
    +
    +#ifndef __ASSEMBLY__
    +#include
    +
    +typedef unsigned long microblaze_reg_t;
    +
    +struct pt_regs {
    + microblaze_reg_t r0;
    + microblaze_reg_t r1;
    + microblaze_reg_t r2;
    + microblaze_reg_t r3;
    + microblaze_reg_t r4;
    + microblaze_reg_t r5;
    + microblaze_reg_t r6;
    + microblaze_reg_t r7;
    + microblaze_reg_t r8;
    + microblaze_reg_t r9;
    + microblaze_reg_t r10;
    + microblaze_reg_t r11;
    + microblaze_reg_t r12;
    + microblaze_reg_t r13;
    + microblaze_reg_t r14;
    + microblaze_reg_t r15;
    + microblaze_reg_t r16;
    + microblaze_reg_t r17;
    + microblaze_reg_t r18;
    + microblaze_reg_t r19;
    + microblaze_reg_t r20;
    + microblaze_reg_t r21;
    + microblaze_reg_t r22;
    + microblaze_reg_t r23;
    + microblaze_reg_t r24;
    + microblaze_reg_t r25;
    + microblaze_reg_t r26;
    + microblaze_reg_t r27;
    + microblaze_reg_t r28;
    + microblaze_reg_t r29;
    + microblaze_reg_t r30;
    + microblaze_reg_t r31;
    + microblaze_reg_t pc;
    + microblaze_reg_t msr;
    + microblaze_reg_t ear;
    + microblaze_reg_t esr;
    + microblaze_reg_t fsr;
    + int kernel_mode;
    +};
    +
    +#define kernel_mode(regs) ((regs)->kernel_mode)
    +#define user_mode(regs) (!kernel_mode(regs))
    +
    +#define instruction_pointer(regs) ((regs)->pc)
    +#define profile_pc(regs) instruction_pointer(regs)
    +
    +extern void show_regs(struct pt_regs *);
    +
    +#endif /* __ASSEMBLY__ */
    +
    +#endif /* _ASM_MICROBLAZE_PTRACE_H */
    --
    1.5.4.GIT

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. [PATCH 25/60] microblaze_v4: process and init task function

    From: Michal Simek


    Signed-off-by: Michal Simek
    ---
    arch/microblaze/kernel/init_task.c | 28 ++++++++
    arch/microblaze/kernel/process.c | 127 ++++++++++++++++++++++++++++++++++++
    2 files changed, 155 insertions(+), 0 deletions(-)
    create mode 100644 arch/microblaze/kernel/init_task.c
    create mode 100644 arch/microblaze/kernel/process.c

    diff --git a/arch/microblaze/kernel/init_task.c b/arch/microblaze/kernel/init_task.c
    new file mode 100644
    index 0000000..c841b55
    --- /dev/null
    +++ b/arch/microblaze/kernel/init_task.c
    @@ -0,0 +1,28 @@
    +/*
    + * Copyright (C) 2006 Atmark Techno, Inc.
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + */
    +
    +#include
    +#include
    +#include
    +#include
    +#include
    +
    +#include
    +
    +static struct fs_struct init_fs = INIT_FS;
    +static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
    +static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
    +struct mm_struct init_mm = INIT_MM(init_mm);
    +EXPORT_SYMBOL(init_mm);
    +
    +union thread_union init_thread_union
    + __attribute__((__section__(".data.init_task"))) =
    +{ INIT_THREAD_INFO(init_task) };
    +
    +struct task_struct init_task = INIT_TASK(init_task);
    +EXPORT_SYMBOL(init_task);
    diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
    new file mode 100644
    index 0000000..c8e6bef
    --- /dev/null
    +++ b/arch/microblaze/kernel/process.c
    @@ -0,0 +1,127 @@
    +/*
    + * Copyright (C) 2006 Atmark Techno, Inc.
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + */
    +
    +#include
    +#include
    +#include
    +
    +#include
    +
    +/* FIXME */
    +void show_regs(struct pt_regs *regs)
    +{
    + unsigned long *p;
    + int i;
    + printk(KERN_INFO "pc:\t0x%08lx\tsp:\t0x%08lx\n", regs->pc, regs->r1);
    + printk(KERN_INFO
    + "flags:\t0x%08lx\tear:\t0x%08lx\tesr:\t"
    + "0x%08lx\tfsr:\t0x%08lx\n",
    + regs->msr, regs->ear, regs->esr, regs->fsr);
    + printk(KERN_INFO
    + "r0:\t0x%08lx\tr1:\t0x%08lx\tr2:\t0x%08lx\tr3\t0x%0 8lx\n",
    + 0L, regs->r1, regs->r2, regs->r3);
    + for (i = 4, p = &(regs->r4); i < 32; i += 4, p += 4) {
    + printk(KERN_INFO "r%i:\t0x%08lx\tr%i:\t0x%08lx\tr%i:\t"
    + "0x%08lx\tr%i:\t0x%08lx\n",
    + i, *p, i+1, *(p+1), i+2, *(p+2), i+3, *(p+3));
    + }
    + printk(KERN_INFO "\n");
    +}
    +
    +void (*pm_power_off)(void) = NULL;
    +EXPORT_SYMBOL(pm_power_off);
    +
    +void cpu_idle(void)
    +{
    + set_thread_flag(TIF_POLLING_NRFLAG);
    +
    + while (1) {
    + while (!need_resched())
    + cpu_relax();
    +
    + preempt_enable_no_resched();
    + schedule();
    + preempt_disable();
    + }
    +}
    +
    +void flush_thread(void)
    +{
    +}
    +
    +int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
    + unsigned long unused,
    + struct task_struct *p, struct pt_regs *regs)
    +{
    + struct pt_regs *childregs = task_pt_regs(p);
    + struct thread_info *ti = task_thread_info(p);
    +
    + *childregs = *regs;
    +
    + if (user_mode(regs))
    + childregs->r1 = usp;
    + else
    + childregs->r1 = ((unsigned long) ti) + THREAD_SIZE;
    +
    + memset(&ti->cpu_context, 0, sizeof(struct cpu_context));
    + ti->cpu_context.r1 = (unsigned long)childregs;
    + ti->cpu_context.msr = (unsigned long)childregs->msr;
    + ti->cpu_context.r15 = (unsigned long)ret_from_fork - 8;
    +
    + if (clone_flags & CLONE_SETTLS)
    + ;/* FIXME: not sure what to do */
    +
    + return 0;
    +}
    +
    +/*
    + * Return saved PC of a blocked thread.
    + * FIXME this needs to be checked
    + */
    +unsigned long thread_saved_pc(struct task_struct *tsk)
    +{
    + struct cpu_context *ctx =
    + &(((struct thread_info *)(tsk->stack))->cpu_context);
    +
    + /* Check whether the thread is blocked in resume() */
    + if (in_sched_functions(ctx->r15))
    + return ((unsigned long)ctx->r15);
    + else
    + return ctx->r14;
    +}
    +
    +static void kernel_thread_helper(int (*fn)(void *), void *arg)
    +{
    + fn(arg);
    + do_exit(-1);
    +}
    +
    +int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
    +{
    + struct pt_regs regs;
    + int ret;
    +
    + memset(&regs, 0, sizeof(regs));
    + /* store them in non-volatile registers */
    + regs.r5 = (unsigned long)fn;
    + regs.r6 = (unsigned long)arg;
    + local_save_flags(regs.msr);
    + regs.pc = (unsigned long)kernel_thread_helper;
    + regs.kernel_mode = 1;
    +
    + ret = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
    + &regs, 0, NULL, NULL);
    +
    + return ret;
    +}
    +
    +unsigned long get_wchan(struct task_struct *p)
    +{
    +/* TBD (used by procfs) */
    + return 0;
    +}
    --
    1.5.4.GIT

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. Re: [PATCH 27/60] microblaze_v4: virtualization

    On Thu, Jun 26, 2008 at 02:29:56PM +0200, monstr@seznam.cz wrote:
    > From: Michal Simek
    >
    >
    > Signed-off-by: Michal Simek
    > ---
    > include/asm-microblaze/kvm.h | 1 +
    > 1 files changed, 1 insertions(+), 0 deletions(-)
    > create mode 100644 include/asm-microblaze/kvm.h
    >
    > diff --git a/include/asm-microblaze/kvm.h b/include/asm-microblaze/kvm.h
    > new file mode 100644
    > index 0000000..01c5e79
    > --- /dev/null
    > +++ b/include/asm-microblaze/kvm.h
    > @@ -0,0 +1 @@
    > +/* Microblaze does not support KVM */


    There's a patch pending for 2.6.27 that will remove the requirement for
    this empty header.

    cu
    Adrian

    --

    "Is there not promise of rain?" Ling Tan asked suddenly out
    of the darkness. There had been need of rain for many days.
    "Only a promise," Lao Er said.
    Pearl S. Buck - Dragon Seed

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread