Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Make it so kernels can be compiled for 32-bit or 64...



details:   https://anonhg.NetBSD.org/src/rev/87db582fcb4d
branches:  trunk
changeset: 534007:87db582fcb4d
user:      scw <scw%NetBSD.org@localhost>
date:      Fri Jul 12 19:33:27 2002 +0000

description:
Make it so kernels can be compiled for 32-bit or 64-bit with a
simple config file option.

Also, don't hard code the endian setting in a header file. Rely instead
on the compiler defining __LITTLE_ENDIAN__ and DTRT as appropriate.

diffstat:

 sys/arch/evbsh5/conf/CAYMAN              |   7 +++-
 sys/arch/evbsh5/conf/SIMULATOR           |   7 +++-
 sys/arch/evbsh5/conf/std.evbsh5.eb       |  11 +++++++
 sys/arch/evbsh5/include/endian_machdep.h |   9 +-----
 sys/arch/sh5/conf/Makefile.sh5           |  46 ++++++++++++++++++++++++++-----
 sys/arch/sh5/include/endian_machdep.h    |  10 ++++--
 sys/arch/sh5/sh5/exception.S             |  17 +++++++++--
 7 files changed, 80 insertions(+), 27 deletions(-)

diffs (217 lines):

diff -r 3224f3762ebf -r 87db582fcb4d sys/arch/evbsh5/conf/CAYMAN
--- a/sys/arch/evbsh5/conf/CAYMAN       Fri Jul 12 19:27:32 2002 +0000
+++ b/sys/arch/evbsh5/conf/CAYMAN       Fri Jul 12 19:33:27 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: CAYMAN,v 1.1 2002/07/05 13:31:37 scw Exp $
+#      $NetBSD: CAYMAN,v 1.2 2002/07/12 19:33:28 scw Exp $
 
 #
 # Config file for SuperH "CAYMAN" SH-5 Evaluation board
@@ -10,10 +10,13 @@
 
 options        INCLUDE_CONFIG_FILE
 
-#ident         "CAYMAN-$Revision: 1.1 $"
+#ident         "CAYMAN-$Revision: 1.2 $"
 
 options        CPU_STB1
 
+# Uncomment this to build a 64-bit kernel
+#makeoptions   SH5_ABI=64
+
 options        DIAGNOSTIC
 options        DEBUG
 #options       DDB
diff -r 3224f3762ebf -r 87db582fcb4d sys/arch/evbsh5/conf/SIMULATOR
--- a/sys/arch/evbsh5/conf/SIMULATOR    Fri Jul 12 19:27:32 2002 +0000
+++ b/sys/arch/evbsh5/conf/SIMULATOR    Fri Jul 12 19:33:27 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: SIMULATOR,v 1.1 2002/07/05 13:31:37 scw Exp $
+#      $NetBSD: SIMULATOR,v 1.2 2002/07/12 19:33:28 scw Exp $
 
 # NetBSD/sh5 on the simple `chess' based simulator.
 #
@@ -11,11 +11,14 @@
 
 options        INCLUDE_CONFIG_FILE
 
-#ident         "SIMULATOR-$Revision: 1.1 $"
+#ident         "SIMULATOR-$Revision: 1.2 $"
 
 options        CPU_STB1
 options        SIMULATED_CLOCK
 
+# Uncomment this to build a 64-bit kernel
+#makeoptions   SH5_ABI=64
+
 options        DIAGNOSTIC
 options        DEBUG
 #options       DDB
diff -r 3224f3762ebf -r 87db582fcb4d sys/arch/evbsh5/conf/std.evbsh5.eb
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbsh5/conf/std.evbsh5.eb        Fri Jul 12 19:33:27 2002 +0000
@@ -0,0 +1,11 @@
+#      $NetBSD: std.evbsh5.eb,v 1.1 2002/07/12 19:33:28 scw Exp $
+#
+# Options/devices that all Big Endian evbsh5s should have
+#
+
+machine evbsh5 sh5
+
+options        EXEC_ELF32
+options        EXEC_SCRIPT
+
+makeoptions    MACHINE_ARCH=sh5eb
diff -r 3224f3762ebf -r 87db582fcb4d sys/arch/evbsh5/include/endian_machdep.h
--- a/sys/arch/evbsh5/include/endian_machdep.h  Fri Jul 12 19:27:32 2002 +0000
+++ b/sys/arch/evbsh5/include/endian_machdep.h  Fri Jul 12 19:33:27 2002 +0000
@@ -1,10 +1,3 @@
-/*     $NetBSD: endian_machdep.h,v 1.1 2002/07/05 13:31:44 scw Exp $   */
-
-#ifndef _EVBSH5_ENDIAN_MACHDEP_H
-#define _EVBSH5_ENDIAN_MACHDEP_H
-
-#define        _BYTE_ORDER     _LITTLE_ENDIAN
+/*     $NetBSD: endian_machdep.h,v 1.2 2002/07/12 19:33:29 scw Exp $   */
 
 #include <sh5/endian_machdep.h>
-
-#endif /* _EVBSH5_ENDIAN_MACHDEP_H */
diff -r 3224f3762ebf -r 87db582fcb4d sys/arch/sh5/conf/Makefile.sh5
--- a/sys/arch/sh5/conf/Makefile.sh5    Fri Jul 12 19:27:32 2002 +0000
+++ b/sys/arch/sh5/conf/Makefile.sh5    Fri Jul 12 19:33:27 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.sh5,v 1.3 2002/07/11 14:42:55 scw Exp $
+#      $NetBSD: Makefile.sh5,v 1.4 2002/07/12 19:33:27 scw Exp $
 
 # Makefile for NetBSD/sh5
 #
@@ -34,18 +34,48 @@
 ##
 ## The kernel must be compiled to *not* use FPU registers.
 ##
-CC=            sh5gcc -D__NetBSD__ -ml -m5-32media-nofpu
-AS=            sh5gcc -D__NetBSD__ -ml -m5-32media-nofpu
-LD=            sh5ld -m shlelf32
+SH5_ABI?=32
+.if (${SH5_ABI} == 32 || ${SH5_ABI} == 0x20)
+SH5_ABI=32
+SH5_ABI_DEF=-D_ILP32
+.elif (${SH5_ABI} == 64 || ${SH5_ABI} == 0x40)
+SH5_ABI=64
+SH5_ABI_DEF=-D_LP64
+.else
+.BEGIN:
+       @echo "SH5_ABI must be either 32 or 64"
+       @false
+.endif
+
+.if (${MACHINE_ARCH} == sh5el)
+SH5_ENDIAN_CC= -ml
+SH5_ENDIAN_LD= shlelf${SH5_ABI}
+.elif (${MACHINE_ARCH} == sh5eb)
+SH5_ENDIAN_CC= -mb
+SH5_ENDIAN_LD= shelf${SH5_ABI}
+.else
+.BEGIN:
+       @echo "MACHINE_ARCH must be either sh5el or sh5eb"
+       @false
+.endif
+
+CC=            sh5gcc
+AS=            sh5gcc
+LD=            sh5ld -m ${SH5_ENDIAN_LD}
 AR=            sh5ar
+NM=            sh5nm
 RANLIB=                sh5ranlib
 SIZE=          sh5size
-CPPFLAGS+=     -D${MACHINE}
+
+CPPFLAGS+=     -D__NetBSD__ -D${MACHINE} ${SH5_ABI_DEF}
+CFLAGS+=       ${SH5_ENDIAN_CC} -m5-${SH5_ABI}media-nofpu
+AFLAGS+=       ${SH5_ENDIAN_CC} -m5-${SH5_ABI}media-nofpu
+AFLAGS+=       -x assembler-with-cpp -traditional-cpp
+COPTS?=                -O0
 DEFWARNINGS=   no
-CWARNFLAGS+=   -Wall -Wno-main -Wpointer-arith -Wno-uninitialized
+CWARNFLAGS+=   -Werror -Wall -Wno-main -Wpointer-arith
+CWARNFLAGS+=   -Wno-uninitialized -Wno-format
 CWARNFLAGS+=   -Wmissing-prototypes -Wstrict-prototypes
-AFLAGS+=       -x assembler-with-cpp -traditional-cpp
-COPTS?=                -O2
 
 ##
 ## (3) libkern and compat
diff -r 3224f3762ebf -r 87db582fcb4d sys/arch/sh5/include/endian_machdep.h
--- a/sys/arch/sh5/include/endian_machdep.h     Fri Jul 12 19:27:32 2002 +0000
+++ b/sys/arch/sh5/include/endian_machdep.h     Fri Jul 12 19:33:27 2002 +0000
@@ -1,14 +1,16 @@
-/*     $NetBSD: endian_machdep.h,v 1.1 2002/07/05 13:31:58 scw Exp $   */
+/*     $NetBSD: endian_machdep.h,v 1.2 2002/07/12 19:33:27 scw Exp $   */
 
-#ifndef _BYTE_ORDER
-# error  Define SH target CPU endian-ness in port-specific header file.
+#ifdef __LITTLE_ENDIAN__
+#define _BYTE_ORDER     _LITTLE_ENDIAN
+#else
+#define _BYTE_ORDER     _BIG_ENDIAN
 #endif
 
 #ifdef __GNUC__
 
 #include <sh5/bswap.h>
 
-#if BTYE_ORDER == LITTLE_ENDIAN
+#if _BTYE_ORDER == _LITTLE_ENDIAN
 #define        ntohl(x)        ((in_addr_t)bswap32(x))
 #define        ntohs(x)        ((in_port_t)bswap16(x))
 #define        htonl(x)        ((in_addr_t)bswap32(x))
diff -r 3224f3762ebf -r 87db582fcb4d sys/arch/sh5/sh5/exception.S
--- a/sys/arch/sh5/sh5/exception.S      Fri Jul 12 19:27:32 2002 +0000
+++ b/sys/arch/sh5/sh5/exception.S      Fri Jul 12 19:33:27 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exception.S,v 1.2 2002/07/12 15:42:28 scw Exp $        */
+/*     $NetBSD: exception.S,v 1.3 2002/07/12 19:33:28 scw Exp $        */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -583,10 +583,11 @@
 
        /* The miss happened in kernel-mode */
 #ifndef _LP64
-       LDSC32(SH5_KSEG1_BASE >> PGSHIFT, r1)   /* #4c: */
+       LDSC32(SH5_KSEG1_BASE, r1)      /* #4c: */
 #else
-       LDSC64(SH5_KSEG1_BASE >> PGSHIFT, r1)   /* #4c: */
+       LDSC64(SH5_KSEG1_BASE, r1)      /* #4c: */
 #endif
+       shari   r1, PGSHIFT, r1
        bgtu/u  r1, r0, tr0             /* #54: Jump if not in KSEG1 */
 
        /* Ok, we're dealing with a kernel-mode KSEG1 access */
@@ -797,7 +798,12 @@
        getcon  kcr0, r1                /* Get cpu_info for this cpu */
        LDPTR   r1, CI_CURPROC, r1      /* Get curproc */
        beq/u   r1, r63, tr0            /* Exit if NULL */
+#ifndef _LP64
        addi    r1, P_MD_ASTPENDING, r1 /* Point to md_astpending */
+#else
+       movi    P_MD_ASTPENDING, r2     /* Exceeds 10-bit field in _LP64 mode */
+       add     r1, r2, r1              /* Point to md_astpending */
+#endif
        swap.q  r1, r63, r0             /* AST pending for this process? */
        beq/l   r0, r63, tr0            /* Nope. Moving right along ... */
        pta/l   Ltrapagain, tr0
@@ -852,7 +858,12 @@
        getcon  kcr0, r1                /* Get cpu_info for this cpu */
        LDPTR   r1, CI_CURPROC, r1      /* Get curproc */
        beq/u   r1, r63, tr0            /* Exit if NULL */
+#ifndef _LP64
        addi    r1, P_MD_ASTPENDING, r1 /* Point to md_astpending */
+#else
+       movi    P_MD_ASTPENDING, r2     /* Exceeds 10-bit field in _LP64 mode */
+       add     r1, r2, r1              /* Point to md_astpending */
+#endif
        swap.q  r1, r63, r0             /* ASTs pending for this process? */
        beq/l   r0, r63, tr0            /* Nope. Moving right along ... */
 



Home | Main Index | Thread Index | Old Index