Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386/i386 next step in getting machdep.c maintainab...



details:   https://anonhg.NetBSD.org/src/rev/7a7b42451d00
branches:  trunk
changeset: 481354:7a7b42451d00
user:      drochner <drochner%NetBSD.org@localhost>
date:      Wed Jan 26 18:49:26 2000 +0000

description:
next step in getting machdep.c maintainable - put bus_space related
stuff into a separate file
being here, add new Pentium-III processor ID (models with on-die cache)

diffstat:

 sys/arch/i386/i386/machdep.c |  906 +------------------------------------------
 1 files changed, 7 insertions(+), 899 deletions(-)

diffs (truncated from 963 to 300 lines):

diff -r 1ce7bf54d5e2 -r 7a7b42451d00 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Wed Jan 26 18:47:59 2000 +0000
+++ b/sys/arch/i386/i386/machdep.c      Wed Jan 26 18:49:26 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.374 2000/01/19 23:06:06 thorpej Exp $    */
+/*     $NetBSD: machdep.c,v 1.375 2000/01/26 18:49:26 drochner Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -117,9 +117,6 @@
 
 #include <sys/sysctl.h>
 
-#define _I386_BUS_DMA_PRIVATE
-#include <machine/bus.h>
-
 #include <machine/cpu.h>
 #include <machine/cpufunc.h>
 #include <machine/gdt.h>
@@ -202,24 +199,6 @@
 extern paddr_t hole_start, hole_end;
 
 /*
- * Extent maps to manage I/O and ISA memory hole space.  Allocate
- * storage for 8 regions in each, initially.  Later, ioport_malloc_safe
- * will indicate that it's safe to use malloc() to dynamically allocate
- * region descriptors.
- *
- * N.B. At least two regions are _always_ allocated from the iomem
- * extent map; (0 -> ISA hole) and (end of ISA hole -> end of RAM).
- *
- * The extent maps are not static!  Machine-dependent ISA and EISA
- * routines need access to them for bus address space allocation.
- */
-static long ioport_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
-static long iomem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
-struct extent *ioport_ex;
-struct extent *iomem_ex;
-static int ioport_malloc_safe;
-
-/*
  * Size of memory segments, before any memory is stolen.
  */
 phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
@@ -236,12 +215,6 @@
 static int exec_nomid  __P((struct proc *, struct exec_package *));
 #endif
 
-int    i386_mem_add_mapping __P((bus_addr_t, bus_size_t,
-           int, bus_space_handle_t *));
-
-int    _bus_dmamap_load_buffer __P((bus_dma_tag_t, bus_dmamap_t, void *,
-           bus_size_t, struct proc *, int, paddr_t *, int *, int));
-
 void cyrix6x86_cpu_setup __P((void));
 
 static __inline u_char
@@ -383,8 +356,8 @@
 #endif
 #endif
 
-       /* Safe for i/o port allocation to use malloc now. */
-       ioport_malloc_safe = 1;
+       /* Safe for i/o port / memory space allocation to use malloc now. */
+       i386_bus_space_mallocok();
 }
 
 /*
@@ -541,7 +514,8 @@
                                "Pentium II (Klamath)", "Pentium Pro",
                                "Pentium II (Deschutes)",
                                "Pentium II (Celeron)",
-                               "Pentium III", 0, 0, 0, 0, 0, 0, 0, 0,
+                               "Pentium III", "Pentium III (E)",
+                               0, 0, 0, 0, 0, 0, 0,
                                "Pentium Pro, II or III"        /* Default */
                        },
                        NULL
@@ -1530,27 +1504,12 @@
        int x;
        struct region_descriptor region;
        extern void consinit __P((void));
+       extern struct extent *iomem_ex;
 
        proc0.p_addr = proc0paddr;
        curpcb = &proc0.p_addr->u_pcb;
 
-       /*
-        * Initialize the I/O port and I/O mem extent maps.
-        * Note: we don't have to check the return value since
-        * creation of a fixed extent map will never fail (since
-        * descriptor storage has already been allocated).
-        *
-        * N.B. The iomem extent manages _all_ physical addresses
-        * on the machine.  When the amount of RAM is found, the two
-        * extents of RAM are allocated from the map (0 -> ISA hole
-        * and end of ISA hole -> end of RAM).
-        */
-       ioport_ex = extent_create("ioport", 0x0, 0xffff, M_DEVBUF,
-           (caddr_t)ioport_ex_storage, sizeof(ioport_ex_storage),
-           EX_NOCOALESCE|EX_NOWAIT);
-       iomem_ex = extent_create("iomem", 0x0, 0xffffffff, M_DEVBUF,
-           (caddr_t)iomem_ex_storage, sizeof(iomem_ex_storage),
-           EX_NOCOALESCE|EX_NOWAIT);
+       i386_bus_space_init();
 
        consinit();     /* XXX SHOULD NOT BE DONE HERE */
 
@@ -1905,854 +1864,3 @@
 
        for (;;);
 }
-
-int
-i386_memio_map(t, bpa, size, flags, bshp)
-       bus_space_tag_t t;
-       bus_addr_t bpa;
-       bus_size_t size;
-       int flags;
-       bus_space_handle_t *bshp;
-{
-       int error;
-       struct extent *ex;
-
-       /*
-        * Pick the appropriate extent map.
-        */
-       if (t == I386_BUS_SPACE_IO) {
-               if (flags & BUS_SPACE_MAP_LINEAR)
-                       return (EOPNOTSUPP);
-               ex = ioport_ex;
-       } else if (t == I386_BUS_SPACE_MEM)
-               ex = iomem_ex;
-       else
-               panic("i386_memio_map: bad bus space tag");
-
-       /*
-        * Before we go any further, let's make sure that this
-        * region is available.
-        */
-       error = extent_alloc_region(ex, bpa, size,
-           EX_NOWAIT | (ioport_malloc_safe ? EX_MALLOCOK : 0));
-       if (error)
-               return (error);
-
-       /*
-        * For I/O space, that's all she wrote.
-        */
-       if (t == I386_BUS_SPACE_IO) {
-               *bshp = bpa;
-               return (0);
-       }
-
-       if (bpa >= IOM_BEGIN && (bpa + size) <= IOM_END) {
-               *bshp = (bus_space_handle_t)ISA_HOLE_VADDR(bpa);
-               return(0);
-       }
-
-       /*
-        * For memory space, map the bus physical address to
-        * a kernel virtual address.
-        */
-       error = i386_mem_add_mapping(bpa, size,
-               (flags & BUS_SPACE_MAP_CACHEABLE) != 0, bshp);
-       if (error) {
-               if (extent_free(ex, bpa, size, EX_NOWAIT |
-                   (ioport_malloc_safe ? EX_MALLOCOK : 0))) {
-                       printf("i386_memio_map: pa 0x%lx, size 0x%lx\n",
-                           bpa, size);
-                       printf("i386_memio_map: can't free region\n");
-               }
-       }
-
-       return (error);
-}
-
-int
-_i386_memio_map(t, bpa, size, flags, bshp)
-       bus_space_tag_t t;
-       bus_addr_t bpa;
-       bus_size_t size;
-       int flags;
-       bus_space_handle_t *bshp;
-{
-
-       /*
-        * For I/O space, just fill in the handle.
-        */
-       if (t == I386_BUS_SPACE_IO) {
-               if (flags & BUS_SPACE_MAP_LINEAR)
-                       return (EOPNOTSUPP);
-               *bshp = bpa;
-               return (0);
-       }
-
-       /*
-        * For memory space, map the bus physical address to
-        * a kernel virtual address.
-        */
-       return (i386_mem_add_mapping(bpa, size,
-           (flags & BUS_SPACE_MAP_CACHEABLE) != 0, bshp));
-}
-
-int
-i386_memio_alloc(t, rstart, rend, size, alignment, boundary, flags,
-    bpap, bshp)
-       bus_space_tag_t t;
-       bus_addr_t rstart, rend;
-       bus_size_t size, alignment, boundary;
-       int flags;
-       bus_addr_t *bpap;
-       bus_space_handle_t *bshp;
-{
-       struct extent *ex;
-       u_long bpa;
-       int error;
-
-       /*
-        * Pick the appropriate extent map.
-        */
-       if (t == I386_BUS_SPACE_IO) {
-               if (flags & BUS_SPACE_MAP_LINEAR)
-                       return (EOPNOTSUPP);
-               ex = ioport_ex;
-       } else if (t == I386_BUS_SPACE_MEM)
-               ex = iomem_ex;
-       else
-               panic("i386_memio_alloc: bad bus space tag");
-
-       /*
-        * Sanity check the allocation against the extent's boundaries.
-        */
-       if (rstart < ex->ex_start || rend > ex->ex_end)
-               panic("i386_memio_alloc: bad region start/end");
-
-       /*
-        * Do the requested allocation.
-        */
-       error = extent_alloc_subregion(ex, rstart, rend, size, alignment,
-           boundary,
-           EX_FAST | EX_NOWAIT | (ioport_malloc_safe ?  EX_MALLOCOK : 0),
-           &bpa);
-
-       if (error)
-               return (error);
-
-       /*
-        * For I/O space, that's all she wrote.
-        */
-       if (t == I386_BUS_SPACE_IO) {
-               *bshp = *bpap = bpa;
-               return (0);
-       }
-
-       /*
-        * For memory space, map the bus physical address to
-        * a kernel virtual address.
-        */
-       error = i386_mem_add_mapping(bpa, size,
-           (flags & BUS_SPACE_MAP_CACHEABLE) != 0, bshp);
-       if (error) {
-               if (extent_free(iomem_ex, bpa, size, EX_NOWAIT |
-                   (ioport_malloc_safe ? EX_MALLOCOK : 0))) {
-                       printf("i386_memio_alloc: pa 0x%lx, size 0x%lx\n",
-                           bpa, size);
-                       printf("i386_memio_alloc: can't free region\n");
-               }
-       }
-
-       *bpap = bpa;
-
-       return (error);
-}
-
-int
-i386_mem_add_mapping(bpa, size, cacheable, bshp)
-       bus_addr_t bpa;
-       bus_size_t size;
-       int cacheable;
-       bus_space_handle_t *bshp;
-{
-       u_long pa, endpa;
-       vaddr_t va;
-       pt_entry_t *pte;
-
-       pa = i386_trunc_page(bpa);
-       endpa = i386_round_page(bpa + size);
-
-#ifdef DIAGNOSTIC
-       if (endpa <= pa)
-               panic("i386_mem_add_mapping: overflow");
-#endif
-
-       va = uvm_km_valloc(kernel_map, endpa - pa);
-       if (va == 0)
-               return (ENOMEM);
-
-       *bshp = (bus_space_handle_t)(va + (bpa & PGOFSET));
-
-       for (; pa < endpa; pa += NBPG, va += NBPG) {



Home | Main Index | Thread Index | Old Index