Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc avoid using 'extern <func|data>;' inside a .c...



details:   https://anonhg.NetBSD.org/src/rev/bb78bd47c7f2
branches:  trunk
changeset: 980102:bb78bd47c7f2
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Jan 24 07:36:53 2021 +0000

description:
avoid using 'extern <func|data>;' inside a .c file, but instead
use header files and ensure definitions are not duplicated or
are technically (if not in codegen) wrong.

diffstat:

 sys/arch/sparc/dev/cons.h              |    3 +-
 sys/arch/sparc/include/autoconf.h      |    4 +-
 sys/arch/sparc/include/cpu.h           |    5 +-
 sys/arch/sparc/include/db_machdep.h    |    4 +-
 sys/arch/sparc/include/intr.h          |    4 +-
 sys/arch/sparc/include/locore.h        |   56 +++++++++++++
 sys/arch/sparc/include/pmap.h          |   12 ++-
 sys/arch/sparc/include/trap.h          |    7 +-
 sys/arch/sparc/sparc/autoconf.c        |   25 +----
 sys/arch/sparc/sparc/cache.c           |    9 +-
 sys/arch/sparc/sparc/cpu.c             |    7 +-
 sys/arch/sparc/sparc/db_interface.c    |    8 +-
 sys/arch/sparc/sparc/eeprom.c          |    7 +-
 sys/arch/sparc/sparc/intr.c            |   10 +-
 sys/arch/sparc/sparc/locore.s          |   20 ++--
 sys/arch/sparc/sparc/machdep.c         |   11 +--
 sys/arch/sparc/sparc/memecc.c          |    6 +-
 sys/arch/sparc/sparc/mkclock.c         |    8 +-
 sys/arch/sparc/sparc/msiiepvar.h       |    5 +-
 sys/arch/sparc/sparc/oclock.c          |   14 +--
 sys/arch/sparc/sparc/pci_fixup.c       |    4 +-
 sys/arch/sparc/sparc/pmap.c            |  136 +++++++++++++++-----------------
 sys/arch/sparc/sparc/process_machdep.c |   10 +-
 sys/arch/sparc/sparc/promlib.c         |    8 +-
 sys/arch/sparc/sparc/timervar.h        |    7 +-
 sys/arch/sparc/sparc/trap.c            |   17 +--
 26 files changed, 218 insertions(+), 189 deletions(-)

diffs (truncated from 1221 to 300 lines):

diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/dev/cons.h
--- a/sys/arch/sparc/dev/cons.h Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/dev/cons.h Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cons.h,v 1.5 2005/11/16 00:49:03 uwe Exp $     */
+/*     $NetBSD: cons.h,v 1.6 2021/01/24 07:36:53 mrg Exp $     */
 
 
 /*
@@ -9,6 +9,7 @@
 extern int prom_stdout_node;
 extern char prom_stdin_args[];
 extern char prom_stdout_args[];
+extern struct consdev consdev_prom;
 
 #ifdef KGDB
 struct zs_chanstate;
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/include/autoconf.h
--- a/sys/arch/sparc/include/autoconf.h Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/include/autoconf.h Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.h,v 1.49 2021/01/17 01:02:28 mrg Exp $ */
+/*     $NetBSD: autoconf.h,v 1.50 2021/01/24 07:36:54 mrg Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -179,5 +179,7 @@
 
 /* Exported from autoconf.c for other consumers.  */
 extern char    machine_model[100];
+extern struct sparc_bus_dma_tag mainbus_dma_tag;
+extern struct sparc_bus_space_tag mainbus_space_tag;
 
 #endif /* !_MACHINE_AUTOCONF_H_ */
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/include/cpu.h
--- a/sys/arch/sparc/include/cpu.h      Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/include/cpu.h      Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.108 2020/05/16 17:52:42 ad Exp $ */
+/*     $NetBSD: cpu.h,v 1.109 2021/01/24 07:36:54 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -490,6 +490,9 @@
 /* Provide %pc of a lwp */
 #define LWP_PC(l)       ((l)->l_md.md_tf->tf_pc)
 
+/* Hardware cross-call mutex */
+extern kmutex_t xpmsg_mutex;
+
 /*
  * Interrupt handler chains.  Interrupt handlers should return 0 for
  * ``not me'' or 1 (``I took care of it'').  intr_establish() inserts a
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/include/db_machdep.h
--- a/sys/arch/sparc/include/db_machdep.h       Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/include/db_machdep.h       Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_machdep.h,v 1.28 2017/11/06 03:47:48 christos Exp $ */
+/*     $NetBSD: db_machdep.h,v 1.29 2021/01/24 07:36:54 mrg Exp $ */
 
 /*
  * Mach Operating System
@@ -93,6 +93,8 @@
 bool           db_inst_unconditional_flow_transfer(int inst);
 db_addr_t      db_branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
 
+void           ddb_suspend(struct trapframe *);
+
 #define inst_trap_return(ins)  db_inst_trap_return(ins)
 #define inst_return(ins)       db_inst_return(ins)
 #define inst_call(ins)         db_inst_call(ins)
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/include/intr.h
--- a/sys/arch/sparc/include/intr.h     Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/include/intr.h     Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.13 2019/08/21 04:17:41 msaitoh Exp $ */
+/*     $NetBSD: intr.h,v 1.14 2021/01/24 07:36:54 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -80,6 +80,8 @@
  * structure, which is otherwise internal to intr.c.
  */
 #if defined(SUN4M) || defined(SUN4D)
+extern int (*moduleerr_handler)(void);
+extern int (*memerr_handler)(void);
 extern void    raise(int, int);
 #if !(defined(SUN4) || defined(SUN4C))
 #define sparc_softintr_schedule(cookie)        raise(0, *((int *) (cookie)))
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/include/locore.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc/include/locore.h   Sun Jan 24 07:36:53 2021 +0000
@@ -0,0 +1,56 @@
+/*     $NetBSD: locore.h,v 1.1 2021/01/24 07:36:54 mrg Exp $ */
+
+/*
+ * Copyright (c) 2021 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SPARC_LOCORE_H_
+#define _SPARC_LOCORE_H_
+
+/*
+ * Items defined in locore or the linker scripts
+ */
+
+void ft_tlb_flush(int va, int ctx, int lvl);
+void sparc_v8_muldiv(void);
+void cpu_hatch(void);
+
+extern char etext[];
+extern char kernel_data_start[];
+extern char kernel_text[];
+extern char end[];
+extern char sparc_fsbail[];
+
+extern uint8_t u0[];
+
+extern int sparc_interrupt4m[];
+extern int sparc_interrupt44c[];
+
+extern char *kernel_top;
+extern void *bootinfo;
+
+#endif /* _SPARC_LOCORE_H_ */
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/include/pmap.h
--- a/sys/arch/sparc/include/pmap.h     Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/include/pmap.h     Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.95 2020/12/18 00:45:52 mrg Exp $ */
+/*     $NetBSD: pmap.h,v 1.96 2021/01/24 07:36:54 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -55,6 +55,8 @@
 #include <uvm/uvm_prot.h>
 #include <uvm/uvm_pmap.h>
 
+#include <machine/promlib.h>
+
 #include <sparc/pte.h>
 
 /*
@@ -187,6 +189,12 @@
 
 #define PMAP_NULL      ((pmap_t)0)
 
+/* Mostly private data exported for a few key consumers. */
+extern struct memarr *pmemarr;
+extern int npmemarr;
+extern vaddr_t prom_vstart;
+extern vaddr_t prom_vend;
+
 /*
  * Bounds on managed physical addresses. Used by (MD) users
  * of uvm_pglistalloc() to provide search hints.
@@ -385,6 +393,8 @@
 #define tlb_flush_context_real()       sta(ASI_SRMMUFP_L0, ASI_SRMMUFP, 0)
 #define tlb_flush_all_real()           sta(ASI_SRMMUFP_LN, ASI_SRMMUFP, 0)
 
+void setpte4m(vaddr_t va, int pte);
+
 #endif /* SUN4M || SUN4D */
 
 #define __HAVE_VM_PAGE_MD
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/include/trap.h
--- a/sys/arch/sparc/include/trap.h     Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/include/trap.h     Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.h,v 1.19 2018/12/19 13:57:50 maxv Exp $ */
+/*     $NetBSD: trap.h,v 1.20 2021/01/24 07:36:54 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -133,4 +133,9 @@
 #define        ST_DIV0         (T_DIV0 & 0x7f)
 #define        ST_FLUSHWIN     (T_FLUSHWIN & 0x7f)
 
+#if defined(_KERNEL) && !defined(_LOCORE)
+extern const char *trap_type[];
+extern struct fpstate initfpstate;
+#endif
+
 #endif /* _MACHINE_TRAP_H_ */
diff -r e6ba0a9f6f21 -r bb78bd47c7f2 sys/arch/sparc/sparc/autoconf.c
--- a/sys/arch/sparc/sparc/autoconf.c   Sun Jan 24 05:30:05 2021 +0000
+++ b/sys/arch/sparc/sparc/autoconf.c   Sun Jan 24 07:36:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.263 2021/01/17 01:04:58 mrg Exp $ */
+/*     $NetBSD: autoconf.c,v 1.264 2021/01/24 07:36:54 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.263 2021/01/17 01:04:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.264 2021/01/24 07:36:54 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -76,6 +76,7 @@
 #include <sys/boot_flag.h>
 #include <sys/ksyms.h>
 #include <sys/userconf.h>
+#include <sys/kgdb.h>
 
 #include <net/if.h>
 #include <net/if_ether.h>
@@ -89,6 +90,7 @@
 #include <machine/promlib.h>
 #include <machine/autoconf.h>
 #include <machine/bootinfo.h>
+#include <machine/locore.h>
 
 #include <sparc/sparc/memreg.h>
 #include <machine/cpu.h>
@@ -96,6 +98,7 @@
 #include <sparc/sparc/asm.h>
 #include <sparc/sparc/cpuvar.h>
 #include <sparc/sparc/timerreg.h>
+#include <sparc/dev/cons.h>
 
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcidevs.h>
@@ -120,11 +123,6 @@
  * the machine.
  */
 
-#ifdef KGDB
-extern int kgdb_debug_panic;
-#endif
-extern void *bootinfo;
-
 #if !NKSYMS && !defined(DDB) && !defined(MODULAR)
 void bootinfo_relocate(void *);
 #endif
@@ -300,13 +298,8 @@
 void
 bootstrap(void)
 {
-       extern uint8_t u0[];
-       extern struct consdev consdev_prom;
-
 #if NKSYMS || defined(DDB) || defined(MODULAR)
        struct btinfo_symtab *bi_sym;
-#else
-       extern int end[];
 #endif
        struct btinfo_boothowto *bi_howto;
 
@@ -324,7 +317,6 @@
 #if defined(SUN4M) || defined(SUN4D)
        /* Switch to sparc v8 multiply/divide functions on v8 machines */
        if (cpu_arch == 8) {
-               extern void sparc_v8_muldiv(void);
                sparc_v8_muldiv();
        }
 #endif /* SUN4M || SUN4D */
@@ -419,7 +411,6 @@
        int nvaddrs, *vaddrs, vstore[10];
        u_int pte;
        int i;
-       extern void setpte4m(u_int, u_int);
 
        if ((node = prom_opennode("/obio/interrupt")) == 0
            && (node = prom_finddevice("/obio/interrupt")) == 0)
@@ -489,8 +480,6 @@
 static void
 bootstrapIIep(void)
 {
-       extern struct sparc_bus_space_tag mainbus_space_tag;
-
        int node;
        bus_space_handle_t bh;



Home | Main Index | Thread Index | Old Index