Re: [PATCH 08/60] microblaze_v4: exception handling

2008-06-26 Thread Michal Simek
Ray Lee napsal(a):
> On Thu, Jun 26, 2008 at 12:19 PM, Michal Simek <[EMAIL PROTECTED]> wrote:
>>> On Thu, Jun 26, 2008 at 5:29 AM,  <[EMAIL PROTECTED]> wrote:
 +ex_sw:
 +   /* Get the destination register number into r5 */
 +   lbuir5, r0, ex_reg_op;
 +   /* Form store_word jump table offset (sw_table + (8 * regnum)) */
 +   la  r6, r0, sw_table;
 +   add r5, r5, r5;
 +   add r5, r5, r5;
 +   add r5, r5, r5;
 +   add r5, r5, r6;
 +   bra r5;
>>> Possibly stupid question: This is part of the unaligned store word
>>> exception handler, yes? Shouldn't the above add's be addk's to
>>> preserve the state of the carry register pre/post store?
>> I don't think that addk is important. I have some tests for exception, I 
>> want to
>> cover full exception handling.
> 
> Okay. It doesn't match your other exception handlers, though, which is
> why I noticed it in the first place (they use addk).

thanks for notice. I'll keep in my mind when I test it.

M


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 08/60] microblaze_v4: exception handling

2008-06-26 Thread Ray Lee
On Thu, Jun 26, 2008 at 12:19 PM, Michal Simek <[EMAIL PROTECTED]> wrote:
>> On Thu, Jun 26, 2008 at 5:29 AM,  <[EMAIL PROTECTED]> wrote:
>>> +ex_sw:
>>> +   /* Get the destination register number into r5 */
>>> +   lbuir5, r0, ex_reg_op;
>>> +   /* Form store_word jump table offset (sw_table + (8 * regnum)) */
>>> +   la  r6, r0, sw_table;
>>> +   add r5, r5, r5;
>>> +   add r5, r5, r5;
>>> +   add r5, r5, r5;
>>> +   add r5, r5, r6;
>>> +   bra r5;
>>
>> Possibly stupid question: This is part of the unaligned store word
>> exception handler, yes? Shouldn't the above add's be addk's to
>> preserve the state of the carry register pre/post store?
>
> I don't think that addk is important. I have some tests for exception, I want 
> to
> cover full exception handling.

Okay. It doesn't match your other exception handlers, though, which is
why I noticed it in the first place (they use addk).
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 08/60] microblaze_v4: exception handling

2008-06-26 Thread Michal Simek



> On Thu, Jun 26, 2008 at 5:29 AM,  <[EMAIL PROTECTED]> wrote:
>> +ex_sw:
>> +   /* Get the destination register number into r5 */
>> +   lbuir5, r0, ex_reg_op;
>> +   /* Form store_word jump table offset (sw_table + (8 * regnum)) */
>> +   la  r6, r0, sw_table;
>> +   add r5, r5, r5;
>> +   add r5, r5, r5;
>> +   add r5, r5, r5;
>> +   add r5, r5, r6;
>> +   bra r5;
> 
> Possibly stupid question: This is part of the unaligned store word
> exception handler, yes? Shouldn't the above add's be addk's to
> preserve the state of the carry register pre/post store?

I don't think that addk is important. I have some tests for exception, I want to
cover full exception handling.

M

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 08/60] microblaze_v4: exception handling

2008-06-26 Thread Ray Lee
On Thu, Jun 26, 2008 at 5:29 AM,  <[EMAIL PROTECTED]> wrote:
> +ex_sw:
> +   /* Get the destination register number into r5 */
> +   lbuir5, r0, ex_reg_op;
> +   /* Form store_word jump table offset (sw_table + (8 * regnum)) */
> +   la  r6, r0, sw_table;
> +   add r5, r5, r5;
> +   add r5, r5, r5;
> +   add r5, r5, r5;
> +   add r5, r5, r6;
> +   bra r5;

Possibly stupid question: This is part of the unaligned store word
exception handler, yes? Shouldn't the above add's be addk's to
preserve the state of the carry register pre/post store?
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 08/60] microblaze_v4: exception handling

2008-06-26 Thread monstr
From: Michal Simek <[EMAIL PROTECTED]>


Signed-off-by: Michal Simek <[EMAIL PROTECTED]>
---
 arch/microblaze/kernel/exceptions.c   |   77 +
 arch/microblaze/kernel/hw_exception_handler.S |  392 +
 include/asm-microblaze/exceptions.h   |   63 
 3 files changed, 532 insertions(+), 0 deletions(-)
 create mode 100644 arch/microblaze/kernel/exceptions.c
 create mode 100644 arch/microblaze/kernel/hw_exception_handler.S
 create mode 100644 include/asm-microblaze/exceptions.h

diff --git a/arch/microblaze/kernel/exceptions.c 
b/arch/microblaze/kernel/exceptions.c
new file mode 100644
index 000..734038e
--- /dev/null
+++ b/arch/microblaze/kernel/exceptions.c
@@ -0,0 +1,77 @@
+/*
+ * HW exception handling
+ *
+ * Copyright (C) 2007 Xilinx, 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  /* For KM CPU var */
+
+/* Initialize_exception_handlers() - called from setup.c/trap_init() */
+void initialize_exception_handlers(void)
+{
+}
+
+#define MICROBLAZE_ILL_OPCODE_EXCEPTION0x02
+#define MICROBLAZE_IOPB_BUS_EXCEPTION  0x03
+#define MICROBLAZE_DOPB_BUS_EXCEPTION  0x04
+#define MICROBLAZE_DIV_ZERO_EXCEPTION  0x05
+#define MICROBLAZE_FPU_EXCEPTION   0x06
+
+static void handle_unexpected_exception(unsigned int esr,
+   unsigned int kernel_mode, unsigned int addr)
+{
+   printk(KERN_WARNING "Unexpected exception %02x in %s mode, PC=%08x\n",
+   esr, kernel_mode ? "kernel" : "user", addr);
+}
+
+static void handle_exception(const char *message, int signal,
+   unsigned int kernel_mode, unsigned int addr)
+{
+   if (kernel_mode)
+   panic("%s in the kernel mode, PC=%08x\n", message, addr);
+   else
+   force_sig(signal, current);
+}
+
+asmlinkage void other_exception_handler(unsigned int esr, unsigned int addr)
+{
+   unsigned int kernel_mode = per_cpu(KM, 0);
+
+   switch (esr) {
+
+   case MICROBLAZE_ILL_OPCODE_EXCEPTION:
+   handle_exception("Illegal instruction", SIGILL,
+   kernel_mode, addr);
+   break;
+
+   case MICROBLAZE_IOPB_BUS_EXCEPTION:
+   handle_exception("Instruction bus error", SIGBUS,
+   kernel_mode, addr);
+   break;
+
+   case MICROBLAZE_DOPB_BUS_EXCEPTION:
+   handle_exception("Data bus error", SIGBUS, kernel_mode, addr);
+   break;
+
+   case MICROBLAZE_DIV_ZERO_EXCEPTION:
+   handle_exception("Divide by zero", SIGILL, kernel_mode, addr);
+   break;
+
+   case MICROBLAZE_FPU_EXCEPTION:
+   handle_exception("FPU error", SIGFPE, kernel_mode, addr);
+   break;
+
+   default:
+   handle_unexpected_exception(esr, kernel_mode, addr);
+   }
+
+   return;
+}
diff --git a/arch/microblaze/kernel/hw_exception_handler.S 
b/arch/microblaze/kernel/hw_exception_handler.S
new file mode 100644
index 000..894ebd0
--- /dev/null
+++ b/arch/microblaze/kernel/hw_exception_handler.S
@@ -0,0 +1,392 @@
+/*
+ * Unaligned exception handling for Microblaze
+ *
+ * cleanup code (C) 2007 Michal Simek <[EMAIL PROTECTED]>
+ * uClinux customisation (C) 2005 John Williams
+ *
+ * Original code
+ * Copyright (C) 2004 Xilinx, Inc. All rights reserved.
+ *
+ * Xilinx, Inc.
+ * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
+ * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
+ * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
+ * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
+ * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
+ * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
+ * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
+ * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
+ * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
+ * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Id: hw_exception_handler.S,v 1.1.2.1 2007/03/16 16:09:57 imanuilov Exp $
+ *
+ */
+
+/*
+ * Microblaze HW Exception Handler
+ * - Non self-modifying exception handler for the following exception 
conditions
+ * - Unalignment
+ * - Instruction bus error
+ * - Data bus error
+ * - Illegal instruction opcode
+ * - Divide-by-zero
+ *
+ * Note we disable interrupts during exception handling, otherwise we will
+ * possibly get multiple re-entrancy if interrupt handles themselves cause
+ * exceptions. JW
+ */
+
+#include 
+#include 
+#include 
+
+/* Helpful Macros */
+#define EX_HANDLER_STACK_SIZ   (4*19)
+#define RM