Annotation of sys/arch/hppa/dev/cpu.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: cpu.c,v 1.28 2004/12/28 05:18:25 mickey Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 1998-2003 Michael Shalayeff
! 5: * All rights reserved.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: * 1. Redistributions of source code must retain the above copyright
! 11: * notice, this list of conditions and the following disclaimer.
! 12: * 2. Redistributions in binary form must reproduce the above copyright
! 13: * notice, this list of conditions and the following disclaimer in the
! 14: * documentation and/or other materials provided with the distribution.
! 15: *
! 16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 19: * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
! 20: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
! 21: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! 22: * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 23: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
! 24: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
! 25: * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
! 26: * THE POSSIBILITY OF SUCH DAMAGE.
! 27: */
! 28:
! 29: #include <sys/param.h>
! 30: #include <sys/systm.h>
! 31: #include <sys/device.h>
! 32: #include <sys/reboot.h>
! 33:
! 34: #include <machine/cpufunc.h>
! 35: #include <machine/pdc.h>
! 36: #include <machine/reg.h>
! 37: #include <machine/iomod.h>
! 38: #include <machine/autoconf.h>
! 39:
! 40: #include <hppa/dev/cpudevs.h>
! 41:
! 42: struct cpu_softc {
! 43: struct device sc_dev;
! 44:
! 45: hppa_hpa_t sc_hpa;
! 46: void *sc_ih;
! 47: };
! 48:
! 49: int cpumatch(struct device *, void *, void *);
! 50: void cpuattach(struct device *, struct device *, void *);
! 51:
! 52: struct cfattach cpu_ca = {
! 53: sizeof(struct cpu_softc), cpumatch, cpuattach
! 54: };
! 55:
! 56: struct cfdriver cpu_cd = {
! 57: NULL, "cpu", DV_DULL
! 58: };
! 59:
! 60: int
! 61: cpumatch(parent, cfdata, aux)
! 62: struct device *parent;
! 63: void *cfdata;
! 64: void *aux;
! 65: {
! 66: struct confargs *ca = aux;
! 67: struct cfdata *cf = cfdata;
! 68:
! 69: /* there will be only one for now XXX */
! 70: /* probe any 1.0, 1.1 or 2.0 */
! 71: if (cf->cf_unit > 0 ||
! 72: ca->ca_type.iodc_type != HPPA_TYPE_NPROC ||
! 73: ca->ca_type.iodc_sv_model != HPPA_NPROC_HPPA)
! 74: return 0;
! 75:
! 76: return 1;
! 77: }
! 78:
! 79: int
! 80: cpu_hardclock(void *v)
! 81: {
! 82: hardclock(v);
! 83: return (1);
! 84: }
! 85:
! 86: void
! 87: cpuattach(parent, self, aux)
! 88: struct device *parent;
! 89: struct device *self;
! 90: void *aux;
! 91: {
! 92: /* machdep.c */
! 93: extern struct pdc_model pdc_model;
! 94: extern struct pdc_cache pdc_cache;
! 95: extern struct pdc_btlb pdc_btlb;
! 96: extern u_int cpu_ticksnum, cpu_ticksdenom;
! 97: extern u_int fpu_enable;
! 98:
! 99: struct cpu_softc *sc = (struct cpu_softc *)self;
! 100: struct confargs *ca = aux;
! 101: u_int mhz = 100 * cpu_ticksnum / cpu_ticksdenom;
! 102: const char *p;
! 103:
! 104: printf (": %s ", cpu_typename);
! 105: if (pdc_model.hvers) {
! 106: static const char lvls[4][4] = { "0", "1", "1.5", "2" };
! 107:
! 108: printf("L%s-%c ", lvls[pdc_model.pa_lvl], "AB"[pdc_model.mc]);
! 109: }
! 110:
! 111: printf ("%d", mhz / 100);
! 112: if (mhz % 100 > 9)
! 113: printf(".%02d", mhz % 100);
! 114: printf("MHz");
! 115:
! 116: if (fpu_enable) {
! 117: extern u_int fpu_version;
! 118: u_int32_t ver[2];
! 119:
! 120: mtctl(fpu_enable, CR_CCR);
! 121: __asm volatile(
! 122: "fstds %%fr0,0(%0)\n\t"
! 123: "copr,0,0\n\t"
! 124: "fstds %%fr0,0(%0)"
! 125: :: "r" (&ver) : "memory");
! 126: mtctl(0, CR_CCR);
! 127: fpu_version = HPPA_FPUVER(ver[0]);
! 128: printf(", FPU %s rev %d",
! 129: hppa_mod_info(HPPA_TYPE_FPU, fpu_version >> 5),
! 130: fpu_version & 0x1f);
! 131: }
! 132:
! 133: printf("\n%s: ", self->dv_xname);
! 134: p = "";
! 135: if (!pdc_cache.dc_conf.cc_sh) {
! 136: printf("%uK(%db/l) Icache, ",
! 137: pdc_cache.ic_size / 1024, pdc_cache.ic_conf.cc_line * 16);
! 138: p = "D";
! 139: }
! 140:
! 141: printf("%uK(%db/l) wr-%s %scache, ",
! 142: pdc_cache.dc_size / 1024, pdc_cache.dc_conf.cc_line * 16,
! 143: pdc_cache.dc_conf.cc_wt? "thru" : "back", p);
! 144:
! 145: p = "";
! 146: if (!pdc_cache.dt_conf.tc_sh) {
! 147: printf("%u ITLB, ", pdc_cache.it_size);
! 148: p = "D";
! 149: }
! 150: printf("%u %scoherent %sTLB",
! 151: pdc_cache.dt_size, pdc_cache.dt_conf.tc_cst? "" : "in", p);
! 152:
! 153: if (pdc_btlb.finfo.num_c)
! 154: printf(", %u BTLB", pdc_btlb.finfo.num_c);
! 155: else if (pdc_btlb.finfo.num_i || pdc_btlb.finfo.num_d)
! 156: printf(", %u/%u D/I BTLBs",
! 157: pdc_btlb.finfo.num_i, pdc_btlb.finfo.num_d);
! 158: printf("\n");
! 159:
! 160: /* sanity against lusers amongst config editors */
! 161: if (ca->ca_irq == 31)
! 162: sc->sc_ih = cpu_intr_establish(IPL_CLOCK, ca->ca_irq,
! 163: cpu_hardclock, NULL /*frame*/, sc->sc_dev.dv_xname);
! 164: else
! 165: printf ("%s: bad irq %d\n", sc->sc_dev.dv_xname, ca->ca_irq);
! 166: }
CVSweb