Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/bebox Cleanup macros of access for bebox-register.



details:   https://anonhg.NetBSD.org/src/rev/58dfc77ca9ff
branches:  trunk
changeset: 782198:58dfc77ca9ff
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Sat Oct 20 12:37:49 2012 +0000

description:
Cleanup macros of access for bebox-register.

diffstat:

 sys/arch/bebox/bebox/pic_bebox.c |  17 ++++++-----------
 sys/arch/bebox/include/bebox.h   |  10 ++++++----
 2 files changed, 12 insertions(+), 15 deletions(-)

diffs (92 lines):

diff -r 41285acb8c1b -r 58dfc77ca9ff sys/arch/bebox/bebox/pic_bebox.c
--- a/sys/arch/bebox/bebox/pic_bebox.c  Sat Oct 20 12:13:46 2012 +0000
+++ b/sys/arch/bebox/bebox/pic_bebox.c  Sat Oct 20 12:37:49 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pic_bebox.c,v 1.8 2011/08/07 15:13:07 kiyohara Exp $ */
+/* $NetBSD: pic_bebox.c,v 1.9 2012/10/20 12:37:49 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_bebox.c,v 1.8 2011/08/07 15:13:07 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_bebox.c,v 1.9 2012/10/20 12:37:49 kiyohara Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -43,9 +43,6 @@
 
 #include <arch/powerpc/pic/picvar.h>
 
-#define BEBOX_INTR_MASK                0x0ffffffc
-#define BEBOX_SET_MASK         0x80000000
-#define BEBOX_INTR(x)          (0x80000000 >> x)
 
 static void bebox_enable_irq(struct pic_ops *, int, int);
 static void bebox_disable_irq(struct pic_ops *, int);
@@ -78,16 +75,14 @@
 bebox_enable_irq(struct pic_ops *pic, int irq, int type)
 {
 
-       *(volatile unsigned int *)(BEBOX_REG + CPU0_INT_MASK) =
-           BEBOX_SET_MASK | (1 << (31 - irq));
+       SET_BEBOX_REG(CPU0_INT_MASK, 1 << (31 - irq));
 }
 
 static void
 bebox_disable_irq(struct pic_ops *pic, int irq)
 {
 
-       *(volatile unsigned int *)(BEBOX_REG + CPU0_INT_MASK) =
-           (1 << (31 - irq));
+       CLEAR_BEBOX_REG(CPU0_INT_MASK, 1 << (31 - irq));
 }
 
 static int
@@ -95,9 +90,9 @@
 {
        unsigned int state;
 
-       state = *(volatile unsigned int *)(BEBOX_REG + INT_SOURCE);
+       state = READ_BEBOX_REG(INT_SOURCE);
        state &= BEBOX_INTR_MASK;
-       state &= *(volatile unsigned int *)(BEBOX_REG + CPU0_INT_MASK);
+       state &= READ_BEBOX_REG(CPU0_INT_MASK);
        if (state == 0)
                return 255;
        return __builtin_clz(state);
diff -r 41285acb8c1b -r 58dfc77ca9ff sys/arch/bebox/include/bebox.h
--- a/sys/arch/bebox/include/bebox.h    Sat Oct 20 12:13:46 2012 +0000
+++ b/sys/arch/bebox/include/bebox.h    Sat Oct 20 12:37:49 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bebox.h,v 1.1 2011/08/07 15:04:45 kiyohara Exp $       */
+/*     $NetBSD: bebox.h,v 1.2 2012/10/20 12:37:49 kiyohara Exp $       */
 /*
  * Copyright (c) 2011 KIYOHARA Takashi
  * All rights reserved.
@@ -36,11 +36,11 @@
 #define BEBOX_SET_MASK         0x80000000
 #define BEBOX_CLEAR_MASK       0x00000000
 
-#define READ_BEBOX_REG(reg)    *(uint32_t *)(BEBOX_REG + (reg))
+#define READ_BEBOX_REG(reg)    *(volatile uint32_t *)(BEBOX_REG + (reg))
 #define SET_BEBOX_REG(reg, v)  \
-               *(uint32_t *)(BEBOX_REG + (reg)) = ((v) | BEBOX_SET_MASK)
+       *(volatile uint32_t *)(BEBOX_REG + (reg)) = ((v) | BEBOX_SET_MASK)
 #define CLEAR_BEBOX_REG(reg, v)        \
-               *(uint32_t *)(BEBOX_REG + (reg)) = ((v) | BEBOX_CLEAR_MASK)
+       *(volatile uint32_t *)(BEBOX_REG + (reg)) = ((v) | BEBOX_CLEAR_MASK)
 
 #define CPU0_INT_MASK       0x0f0      /* Interrupt Mask for CPU0 */
 #define CPU1_INT_MASK       0x1f0      /* Interrupt Mask for CPU1 */
@@ -49,6 +49,8 @@
 #define CPU_RESET           0x4f0      /* Reset Control */
 #define INTR_VECTOR_REG             0xff0
 
+#define BEBOX_INTR_MASK        0x0ffffffc
+
 /* Control */
 #define CPU0_SMI       (1 << 30)       /* SMI to CPU0 */
 #define CPU1_SMI       (1 << 29)       /* SMI to CPU1 */



Home | Main Index | Thread Index | Old Index