Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sandpoint/stand/altboot Added in8() and out8() to a...



details:   https://anonhg.NetBSD.org/src/rev/cd987800a106
branches:  trunk
changeset: 770723:cd987800a106
user:      phx <phx%NetBSD.org@localhost>
date:      Sun Oct 30 21:08:33 2011 +0000

description:
Added in8() and out8() to access a byte with reorder-protection.
Use it in all drivers instead of (volatile uint8_t *).

diffstat:

 sys/arch/sandpoint/stand/altboot/brdsetup.c |   6 +++---
 sys/arch/sandpoint/stand/altboot/dsk.c      |   6 +++---
 sys/arch/sandpoint/stand/altboot/entry.S    |  16 +++++++++++++++-
 sys/arch/sandpoint/stand/altboot/fxp.c      |   6 +++---
 sys/arch/sandpoint/stand/altboot/globals.h  |   6 ++++--
 sys/arch/sandpoint/stand/altboot/nvt.c      |   6 +++---
 sys/arch/sandpoint/stand/altboot/rge.c      |   6 +++---
 sys/arch/sandpoint/stand/altboot/skg.c      |   6 +++---
 sys/arch/sandpoint/stand/altboot/stg.c      |   6 +++---
 sys/arch/sandpoint/stand/altboot/vge.c      |   6 +++---
 10 files changed, 43 insertions(+), 27 deletions(-)

diffs (210 lines):

diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/brdsetup.c
--- a/sys/arch/sandpoint/stand/altboot/brdsetup.c       Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/brdsetup.c       Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.18 2011/05/29 18:06:45 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.19 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -172,8 +172,8 @@
 #define  LSR_THRE      0x20
 #define  LSR_DRDY      0x01
 #define DCR            0x11
-#define UART_READ(base, r)     *(volatile char *)(base + (r))
-#define UART_WRITE(base, r, v) *(volatile char *)(base + (r)) = (v)
+#define UART_READ(base, r)     in8(base + (r))
+#define UART_WRITE(base, r, v) out8(base + (r), (v))
 
 void brdsetup(void);   /* called by entry.S */
 
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/dsk.c
--- a/sys/arch/sandpoint/stand/altboot/dsk.c    Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/dsk.c    Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.8 2011/07/17 20:54:46 joerg Exp $ */
+/* $NetBSD: dsk.c,v 1.9 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -56,8 +56,8 @@
  */
 #define CSR_READ_4(r)          in32rb(r)
 #define CSR_WRITE_4(r,v)       out32rb(r,v)
-#define CSR_READ_1(r)          *(volatile uint8_t *)(r)
-#define CSR_WRITE_1(r,v)       *(volatile uint8_t *)(r)=(v)
+#define CSR_READ_1(r)          in8(r)
+#define CSR_WRITE_1(r,v)       out8(r,v)
 
 struct dskdv {
        char *name;
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/entry.S
--- a/sys/arch/sandpoint/stand/altboot/entry.S  Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/entry.S  Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.S,v 1.4 2011/10/30 20:42:09 phx Exp $ */
+/* $NetBSD: entry.S,v 1.5 2011/10/30 21:08:33 phx Exp $ */
 
 #include <powerpc/psl.h>
 #include <powerpc/spr.h>
@@ -207,6 +207,20 @@
        .globl  newaltboot_end
 newaltboot_end:
 
+
+/* 8-bit i/o access */
+       .globl  out8
+out8:
+       stb     4,0(3)
+       eieio
+       blr
+
+       .globl  in8
+in8:
+       lbz     3,0(3)
+       eieio
+       blr
+
 /*
  * reverse endian access to mimic outw/outl/inw/inl
  */
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/fxp.c
--- a/sys/arch/sandpoint/stand/altboot/fxp.c    Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/fxp.c    Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fxp.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: fxp.c,v 1.3 2011/10/30 21:08:33 phx Exp $ */
 
 /*
  * most of the following code was imported from dev/ic/i82557.c; the
@@ -86,8 +86,8 @@
  * - no vtophys() translation, vaddr_t == paddr_t. 
  * - PIPT writeback cache aware.
  */
-#define CSR_WRITE_1(l, r, v)   *(volatile uint8_t *)((l)->iobase+(r)) = (v)
-#define CSR_READ_1(l, r)       *(volatile uint8_t *)((l)->iobase+(r))
+#define CSR_WRITE_1(l, r, v)   out8((l)->iobase+(r), (v))
+#define CSR_READ_1(l, r)       in8((l)->iobase+(r))
 #define CSR_WRITE_2(l, r, v)   out16rb((l)->iobase+(r), (v))
 #define CSR_READ_2(l, r)       in16rb((l)->iobase+(r))
 #define CSR_WRITE_4(l, r, v)   out32rb((l)->iobase+(r), (v))
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/globals.h
--- a/sys/arch/sandpoint/stand/altboot/globals.h        Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/globals.h        Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.12 2011/03/26 17:55:05 phx Exp $ */
+/* $NetBSD: globals.h,v 1.13 2011/10/30 21:08:33 phx Exp $ */
 
 #ifdef DEBUG
 #define        DPRINTF(x)      printf x
@@ -49,7 +49,9 @@
 /* PPC processor ctl */
 void __syncicache(void *, size_t);
 
-/* byte swap access */
+/* i/o access */
+void out8(unsigned, unsigned);
+unsigned in8(unsigned);
 void out16rb(unsigned, unsigned);
 void out32rb(unsigned, unsigned);
 unsigned in16rb(unsigned);
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/nvt.c
--- a/sys/arch/sandpoint/stand/altboot/nvt.c    Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/nvt.c    Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvt.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: nvt.c,v 1.3 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,8 +44,8 @@
  * - no vtophys() translation, vaddr_t == paddr_t.
  * - PIPT writeback cache aware.
  */
-#define CSR_WRITE_1(l, r, v)   *(volatile uint8_t *)((l)->csr+(r)) = (v)
-#define CSR_READ_1(l, r)       *(volatile uint8_t *)((l)->csr+(r))
+#define CSR_WRITE_1(l, r, v)   out8((l)->csr+(r), (v))
+#define CSR_READ_1(l, r)       in8((l)->csr+(r))
 #define CSR_WRITE_2(l, r, v)   out16rb((l)->csr+(r), (v))
 #define CSR_READ_2(l, r)       in16rb((l)->csr+(r))
 #define CSR_WRITE_4(l, r, v)   out32rb((l)->csr+(r), (v))
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/rge.c
--- a/sys/arch/sandpoint/stand/altboot/rge.c    Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/rge.c    Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rge.c,v 1.5 2011/04/29 22:21:36 phx Exp $ */
+/* $NetBSD: rge.c,v 1.6 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,8 +44,8 @@
  * - no vtophys() translation, vaddr_t == paddr_t. 
  * - PIPT writeback cache aware.
  */
-#define CSR_WRITE_1(l, r, v)   *(volatile uint8_t *)((l)->csr+(r)) = (v)
-#define CSR_READ_1(l, r)       *(volatile uint8_t *)((l)->csr+(r))
+#define CSR_WRITE_1(l, r, v)   out8((l)->csr+(r), (v))
+#define CSR_READ_1(l, r)       in8((l)->csr+(r))
 #define CSR_WRITE_2(l, r, v)   out16rb((l)->csr+(r), (v))
 #define CSR_READ_2(l, r)       in16rb((l)->csr+(r))
 #define CSR_WRITE_4(l, r, v)   out32rb((l)->csr+(r), (v))
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/skg.c
--- a/sys/arch/sandpoint/stand/altboot/skg.c    Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/skg.c    Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: skg.c,v 1.3 2011/05/29 18:06:45 phx Exp $ */
+/* $NetBSD: skg.c,v 1.4 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 Frank Wille.
@@ -43,8 +43,8 @@
  * - no vtophys() translation, vaddr_t == paddr_t.
  * - PIPT writeback cache aware.
  */
-#define CSR_WRITE_1(l, r, v)   *(volatile uint8_t *)((l)->csr+(r)) = (v)
-#define CSR_READ_1(l, r)       *(volatile uint8_t *)((l)->csr+(r))
+#define CSR_WRITE_1(l, r, v)   out8((l)->csr+(r), (v))
+#define CSR_READ_1(l, r)       in8((l)->csr+(r))
 #define CSR_WRITE_2(l, r, v)   out16rb((l)->csr+(r), (v))
 #define CSR_READ_2(l, r)       in16rb((l)->csr+(r))
 #define CSR_WRITE_4(l, r, v)   out32rb((l)->csr+(r), (v))
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/stg.c
--- a/sys/arch/sandpoint/stand/altboot/stg.c    Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/stg.c    Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stg.c,v 1.5 2011/03/12 16:41:23 phx Exp $ */
+/* $NetBSD: stg.c,v 1.6 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -38,8 +38,8 @@
 
 #include "globals.h"
 
-#define CSR_WRITE_1(l, r, v)   *(volatile uint8_t *)((l)->csr+(r)) = (v)
-#define CSR_READ_1(l, r)       *(volatile uint8_t *)((l)->csr+(r))
+#define CSR_WRITE_1(l, r, v)   out8((l)->csr+(r), (v))
+#define CSR_READ_1(l, r)       in8((l)->csr+(r))
 #define CSR_WRITE_2(l, r, v)   out16rb((l)->csr+(r), (v))
 #define CSR_READ_2(l, r)       in16rb((l)->csr+(r))
 #define CSR_WRITE_4(l, r, v)   out32rb((l)->csr+(r), (v))
diff -r 591f12cdde23 -r cd987800a106 sys/arch/sandpoint/stand/altboot/vge.c
--- a/sys/arch/sandpoint/stand/altboot/vge.c    Sun Oct 30 20:42:09 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/vge.c    Sun Oct 30 21:08:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vge.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: vge.c,v 1.3 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,8 +44,8 @@
  * - no vtophys() translation, vaddr_t == paddr_t.
  * - PIPT writeback cache aware.
  */
-#define CSR_WRITE_1(l, r, v)   *(volatile uint8_t *)((l)->csr+(r)) = (v)
-#define CSR_READ_1(l, r)       *(volatile uint8_t *)((l)->csr+(r))
+#define CSR_WRITE_1(l, r, v)   out8((l)->csr+(r), (v))
+#define CSR_READ_1(l, r)       in8((l)->csr+(r))
 #define CSR_WRITE_2(l, r, v)   out16rb((l)->csr+(r), (v))
 #define CSR_READ_2(l, r)       in16rb((l)->csr+(r))
 #define CSR_WRITE_4(l, r, v)   out32rb((l)->csr+(r), (v))



Home | Main Index | Thread Index | Old Index