Source-Changes-HG archive

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

[src/sommerfeld_i386mp_1]: src/sys/arch/i386/i386 MP BIOS "driver". Logicall...



details:   https://anonhg.NetBSD.org/src/rev/e64194244555
branches:  sommerfeld_i386mp_1
changeset: 482157:e64194244555
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sun Feb 20 17:09:12 2000 +0000

description:
MP BIOS "driver".  Logically part of mainbus.

Attempt to locate MP configuration table; if found, configure CPU's
and I/O apic's, and record interrupt routing information for
subsequent interrupt handler registration.

diffstat:

 sys/arch/i386/i386/mpbios.c |  1069 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1069 insertions(+), 0 deletions(-)

diffs (truncated from 1073 to 300 lines):

diff -r 5f50e50fc071 -r e64194244555 sys/arch/i386/i386/mpbios.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/mpbios.c       Sun Feb 20 17:09:12 2000 +0000
@@ -0,0 +1,1069 @@
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by RedBack Networks Inc.
+ *
+ * Author: Bill Sommerfeld
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+
+/*
+ * Copyright (c) 1999 Stefan Grefen
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the NetBSD
+ *      Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 AND CONTRIBUTORS 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.
+ */
+/*
+ * Derived from FreeBSD's mp_machdep.c
+ */
+/*
+ * Copyright (c) 1996, by Steve Passe
+ * 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. The name of the developer 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ *
+ *     $Id: mpbios.c,v 1.1.2.1 2000/02/20 17:09:12 sommerfeld Exp $
+ */
+
+/*
+ * The Intel MP-stuff is just one way of x86 SMP systems
+ * so only Intel MP specific stuff is here.
+ */
+
+#include "mpbios.h"
+
+#include "opt_mpbios.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_extern.h>
+#include <machine/specialreg.h>
+#include <machine/cputypes.h>
+#include <machine/cpuvar.h>
+#include <machine/bus.h>
+#include <machine/mpbiosreg.h>
+#include <machine/mpbiosvar.h>
+
+#include <machine/i82093reg.h>
+#include <machine/i82093var.h>
+#include <machine/i82489reg.h>
+#include <machine/i82489var.h>
+#include <dev/isa/isareg.h>
+
+#include <dev/ic/mc146818reg.h>                /* for NVRAM POST */
+#include <i386/isa/nvram.h>            /* for NVRAM POST */
+
+static struct mpbios_ioapic default_ioapic = {
+    2,0,1,IOAPICENTRY_FLAG_EN,(caddr_t)IOAPIC_BASE_DEFAULT
+};
+
+/* descriptions of MP basetable entries */
+struct mpbios_baseentry {
+       u_int8_t        type;
+       u_int8_t        length;
+       u_int16_t       count;
+       const char      *name;
+};
+
+static const char *loc_where[] = {
+       "extended bios data area",
+       "last page of base memory",
+       "bios"
+};
+
+struct mp_map 
+{
+       vaddr_t         baseva;
+       int             vsize;
+       paddr_t         pa;
+       paddr_t         pg;
+       int             psize;
+};
+
+int mp_print __P((void *, const char *));
+int mp_match __P((struct device *,struct cfdata *,void *));
+int mpbios_cpu_start __P((struct cpu_info *));
+static const void *mpbios_search __P((struct device *, paddr_t, int,
+    struct mp_map *));
+static inline int mpbios_cksum __P((const void *,int));
+
+static void mp_cfg_special_intr (int mpstype, int mpsflags, u_int32_t *redir);
+static void mp_cfg_pci_intr (int mpstype, int mpsflags, u_int32_t *redir);
+static void mp_cfg_isa_intr (int mpstype, int mpsflags, u_int32_t *redir);
+static void mp_print_special_intr (int intr);
+static void mp_print_pci_intr (int intr);
+static void mp_print_isa_intr (int intr);
+
+static int mpbios_cpu __P((const u_int8_t *, struct device *, paddr_t));
+static int mpbios_bus __P((const u_int8_t *, struct device *));
+static int mpbios_ioapic __P((const u_int8_t *, struct device *));
+static int mpbios_int __P((const u_int8_t *, int, struct mp_intr_map *));
+
+static const void *mpbios_map __P((paddr_t, int, struct mp_map *));
+static void mpbios_unmap __P((struct mp_map *));
+
+/*
+ * globals to help us bounce our way through parsing the config table.
+ */
+
+static struct mp_map mp_cfg_table_map;
+static struct mp_map mp_fp_map;
+const struct mpbios_cth        *mp_cth;
+const struct mpbios_fps        *mp_fps;
+
+#ifdef MPVERBOSE
+int mp_verbose = 1;
+#else
+int mp_verbose = 0;
+#endif
+       
+struct cpu_functions mpbios_cpu_funcs = { mpbios_cpu_start, NULL };
+
+int
+mp_print(aux, pnp)
+       void *aux;
+       const char *pnp;
+{
+       struct cpu_attach_args * caa = (struct cpu_attach_args *) aux;
+       if (pnp)
+               printf("%s at %s:",caa->caa_name, pnp);
+       return (UNCONF);
+}
+
+int
+mp_match(parent, cf, aux)
+       struct device *parent;
+       struct cfdata *cf;
+       void *aux;
+{
+       struct cpu_attach_args * caa = (struct cpu_attach_args *) aux;
+       if (strcmp(caa->caa_name, cf->cf_driver->cd_name))
+               return 0;
+
+       return ((*cf->cf_attach->ca_match)(parent, cf, aux));
+}
+
+/*
+ * Map a chunk of memory read-only and return an appropraitely
+ * const'ed pointer.
+ */
+
+static const void *
+mpbios_map (pa, len, handle)
+       paddr_t pa;
+       int len;
+       struct mp_map *handle;
+{
+       paddr_t pgpa = i386_trunc_page(pa);
+       paddr_t endpa = i386_round_page(pa + len);
+       vaddr_t va = uvm_km_valloc(kernel_map, endpa - pgpa);
+       vaddr_t retva = va + (pa & PGOFSET);
+       
+       handle->pa = pa;
+       handle->pg = pgpa;
+       handle->psize = len;
+       handle->baseva = va;
+       handle->vsize = endpa-pgpa;
+
+       do {
+               pmap_kenter_pa (va, pgpa, VM_PROT_READ);
+               va += NBPG;
+               pgpa += NBPG;
+       } while (pgpa < endpa);
+
+       return (const void *)retva;
+}
+
+inline static void
+mpbios_unmap (handle)
+       struct mp_map *handle;
+{
+       pmap_kremove (handle->baseva, handle->vsize);
+       uvm_km_free (kernel_map, handle->baseva, handle->vsize);
+}
+
+/*
+ * Look for an Intel MP spec table, indicating SMP capable hardware.
+ */
+int
+mpbios_probe(self)
+       struct device *self;
+{
+       paddr_t         ebda, memtop;
+
+       paddr_t         cthpa;
+       int             cthlen;
+       const u_int8_t  *mpbios_page;
+       int             scan_loc;
+       
+       struct          mp_map t;
+       
+       /* see if EBDA exists */
+
+       mpbios_page = mpbios_map (0, NBPG, &t);
+
+       ebda =   *(const u_int16_t *) (&mpbios_page[0x40e]);
+       ebda <<= 4;
+       
+       memtop = *(const u_int16_t *) (&mpbios_page[0x413]);
+       memtop <<= 10;
+
+       mpbios_page = NULL;
+       mpbios_unmap(&t);
+       
+       scan_loc = 0;
+



Home | Main Index | Thread Index | Old Index