Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386 - Declare biosbasemem and biosextmem in <machi...



details:   https://anonhg.NetBSD.org/src/rev/d2b909172248
branches:  trunk
changeset: 485193:d2b909172248
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Apr 21 18:37:20 2000 +0000

description:
- Declare biosbasemem and biosextmem in <machine/cpu.h>, don't extern
  them everywhere they're used.
- Avoid integer overflow when converting bios{base,ext}mem (in units of
  kilobytes) to bytes.

diffstat:

 sys/arch/i386/i386/apm.c     |   3 +--
 sys/arch/i386/i386/machdep.c |  25 +++++++++++++------------
 sys/arch/i386/include/cpu.h  |   4 +++-
 3 files changed, 17 insertions(+), 15 deletions(-)

diffs (120 lines):

diff -r 72f90b33d021 -r d2b909172248 sys/arch/i386/i386/apm.c
--- a/sys/arch/i386/i386/apm.c  Fri Apr 21 18:20:53 2000 +0000
+++ b/sys/arch/i386/i386/apm.c  Fri Apr 21 18:37:20 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apm.c,v 1.46 2000/03/15 09:30:11 fvdl Exp $ */
+/*     $NetBSD: apm.c,v 1.47 2000/04/21 18:37:20 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -906,7 +906,6 @@
        struct device *parent, *self;
        void *aux;
 {
-       extern int biosbasemem;
        struct apm_softc *apmsc = (void *)self;
        struct bioscallregs regs;
        int error, apm_data_seg_ok;
diff -r 72f90b33d021 -r d2b909172248 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Fri Apr 21 18:20:53 2000 +0000
+++ b/sys/arch/i386/i386/machdep.c      Fri Apr 21 18:37:20 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.380 2000/04/05 10:09:50 jdolecek Exp $   */
+/*     $NetBSD: machdep.c,v 1.381 2000/04/21 18:37:20 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -201,7 +201,6 @@
 vm_map_t mb_map = NULL;
 vm_map_t phys_map = NULL;
 
-extern int biosbasemem, biosextmem;
 extern paddr_t avail_start, avail_end;
 extern paddr_t hole_start, hole_end;
 
@@ -1521,14 +1520,16 @@
 extern vector IDTVEC(svr4_fasttrap);
 #endif /* COMPAT_SVR4 */
 
+#define        KBTOB(x)        ((size_t)(x) * 1024UL)
+
 void
 init386(first_avail)
        vaddr_t first_avail;
 {
-       int x;
-       struct region_descriptor region;
        extern void consinit __P((void));
        extern struct extent *iomem_ex;
+       struct region_descriptor region;
+       int x;
 
        proc0.p_addr = proc0paddr;
        curpcb = &proc0.p_addr->u_pcb;
@@ -1542,11 +1543,11 @@
         * extent map.  This is done before the addresses are
         * page rounded just to make sure we get them all.
         */
-       if (extent_alloc_region(iomem_ex, 0, biosbasemem * 1024, EX_NOWAIT)) {
+       if (extent_alloc_region(iomem_ex, 0, KBTOB(biosbasemem), EX_NOWAIT)) {
                /* XXX What should we do? */
                printf("WARNING: CAN'T ALLOCATE BASE MEMORY FROM IOMEM EXTENT MAP!\n");
        }
-       if (extent_alloc_region(iomem_ex, IOM_END, biosextmem * 1024,
+       if (extent_alloc_region(iomem_ex, IOM_END, KBTOB(biosextmem),
            EX_NOWAIT)) {
                /* XXX What should we do? */
                printf("WARNING: CAN'T ALLOCATE EXTENDED MEMORY FROM IOMEM EXTENT MAP!\n");
@@ -1575,14 +1576,14 @@
 
 #if NBIOSCALL > 0
        avail_start = 3*NBPG;   /* save us a page for trampoline code and
-                                one additional PT page! */
+                                  one additional PT page! */
 #else
        avail_start = NBPG;     /* BIOS leaves data in low memory */
                                /* and VM system doesn't work with phys 0 */
 #endif
-       avail_end = IOM_END + trunc_page(biosextmem * 1024);
+       avail_end = IOM_END + trunc_page(KBTOB(biosextmem));
 
-       hole_start = trunc_page(biosbasemem * 1024);
+       hole_start = trunc_page(KBTOB(biosbasemem));
        /* we load right after the I/O hole; adjust hole_end to compensate */
        hole_end = round_page(first_avail);
 
@@ -1694,13 +1695,13 @@
        enable_intr();
 
        /* number of pages of physmem addr space */
-       physmem = btoc(biosbasemem * 1024) + btoc(biosextmem * 1024);
+       physmem = btoc(KBTOB(biosbasemem)) + btoc(KBTOB(biosextmem));
 
        mem_clusters[0].start = 0;
-       mem_clusters[0].size  = trunc_page(biosbasemem * 1024);
+       mem_clusters[0].size  = trunc_page(KBTOB(biosbasemem));
 
        mem_clusters[1].start = IOM_END;
-       mem_clusters[1].size  = trunc_page(biosextmem * 1024);
+       mem_clusters[1].size  = trunc_page(KBTOB(biosextmem));
 
        mem_cluster_cnt = 2;
 
diff -r 72f90b33d021 -r d2b909172248 sys/arch/i386/include/cpu.h
--- a/sys/arch/i386/include/cpu.h       Fri Apr 21 18:20:53 2000 +0000
+++ b/sys/arch/i386/include/cpu.h       Fri Apr 21 18:37:20 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.61 2000/03/29 03:54:03 simonb Exp $  */
+/*     $NetBSD: cpu.h,v 1.62 2000/04/21 18:37:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -120,6 +120,8 @@
 };
 
 #ifdef _KERNEL
+extern int biosbasemem;
+extern int biosextmem;
 extern int cpu;
 extern int cpu_class;
 extern int cpu_feature;



Home | Main Index | Thread Index | Old Index