[BACK]Return to cpu.c CVS log [TXT][DIR] Up to [local] / sys / arch / hppa64 / dev

Annotation of sys/arch/hppa64/dev/cpu.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: cpu.c,v 1.2 2005/05/22 01:38:09 mickey Exp $  */
                      2:
                      3: /*
                      4:  * Copyright (c) 2005 Michael Shalayeff
                      5:  * All rights reserved.
                      6:  *
                      7:  * Permission to use, copy, modify, and distribute this software for any
                      8:  * purpose with or without fee is hereby granted, provided that the above
                      9:  * copyright notice and this permission notice appear in all copies.
                     10:  *
                     11:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     12:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     13:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     14:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     15:  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
                     16:  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
                     17:  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     18:  */
                     19:
                     20: #include <sys/param.h>
                     21: #include <sys/systm.h>
                     22: #include <sys/device.h>
                     23: #include <sys/reboot.h>
                     24:
                     25: #include <machine/pdc.h>
                     26: #include <machine/reg.h>
                     27: #include <machine/iomod.h>
                     28: #include <machine/autoconf.h>
                     29:
                     30: #include <arch/hppa/dev/cpudevs.h>
                     31:
                     32: struct cpu_softc {
                     33:        struct  device sc_dev;
                     34:
                     35:        hppa_hpa_t sc_hpa;
                     36:        void *sc_ih;
                     37: };
                     38:
                     39: int    cpumatch(struct device *, void *, void *);
                     40: void   cpuattach(struct device *, struct device *, void *);
                     41:
                     42: struct cfattach cpu_ca = {
                     43:        sizeof(struct cpu_softc), cpumatch, cpuattach
                     44: };
                     45:
                     46: struct cfdriver cpu_cd = {
                     47:        NULL, "cpu", DV_DULL
                     48: };
                     49:
                     50: int
                     51: cpumatch(parent, cfdata, aux)
                     52:        struct device *parent;
                     53:        void *cfdata;
                     54:        void *aux;
                     55: {
                     56:        struct confargs *ca = aux;
                     57:        /* struct cfdata *cf = cfdata; */
                     58:
                     59:        if ((ca->ca_name && !strcmp(ca->ca_name, "cpu")) ||
                     60:            (ca->ca_type.iodc_type == HPPA_TYPE_NPROC &&
                     61:             ca->ca_type.iodc_sv_model == HPPA_NPROC_HPPA))
                     62:                return 1;
                     63:
                     64:        return 0;
                     65: }
                     66:
                     67: int
                     68: cpu_hardclock(void *v)
                     69: {
                     70:        hardclock(v);
                     71:        return (1);
                     72: }
                     73:
                     74: void
                     75: cpuattach(parent, self, aux)
                     76:        struct device *parent;
                     77:        struct device *self;
                     78:        void *aux;
                     79: {
                     80:        /* machdep.c */
                     81:        extern struct pdc_model pdc_model;
                     82:        extern struct pdc_cache pdc_cache;
                     83:        extern u_int cpu_ticksnum, cpu_ticksdenom;
                     84:        extern u_int fpu_enable;
                     85:
                     86:        /* struct cpu_softc *sc = (struct cpu_softc *)self; */
                     87:        /* struct confargs *ca = aux; */
                     88:        u_int mhz = 100 * cpu_ticksnum / cpu_ticksdenom;
                     89:        const char *p;
                     90:
                     91:        printf (": %s ", cpu_typename);
                     92:        if (pdc_model.hvers) {
                     93:                static const char lvls[4][4] = { "0", "1", "1.5", "2" };
                     94:
                     95:                printf("L%s-%c ", lvls[pdc_model.pa_lvl], "AB"[pdc_model.mc]);
                     96:        }
                     97:
                     98:        printf ("%d", mhz / 100);
                     99:        if (mhz % 100 > 9)
                    100:                printf(".%02d", mhz % 100);
                    101:        printf("MHz");
                    102:
                    103:        if (fpu_enable) {
                    104:                extern u_int fpu_version;
                    105:                u_int32_t ver[2];
                    106:
                    107:                mtctl(fpu_enable, CR_CCR);
                    108:                __asm volatile(
                    109:                    "fstds   %%fr0,0(%0)\n\t"
                    110:                    "copr,0,0\n\t"
                    111:                    "fstds   %%fr0,0(%0)"
                    112:                    :: "r" (&ver) : "memory");
                    113:                mtctl(0, CR_CCR);
                    114:                fpu_version = HPPA_FPUVER(ver[0]);
                    115:                printf(", FPU %s rev %d",
                    116:                    hppa_mod_info(HPPA_TYPE_FPU, fpu_version >> 5),
                    117:                    fpu_version & 0x1f);
                    118:        }
                    119:
                    120:        printf("\n%s: ", self->dv_xname);
                    121:        p = "";
                    122:        if (!pdc_cache.dc_conf.cc_sh) {
                    123:                printf("%uK(%db/l) Icache, ",
                    124:                    pdc_cache.ic_size / 1024, pdc_cache.ic_conf.cc_line * 16);
                    125:                p = "D";
                    126:        }
                    127:        printf("%uK(%db/l) wr-%s %scoherent %scache, ",
                    128:            pdc_cache.dc_size / 1024, pdc_cache.dc_conf.cc_line * 16,
                    129:            pdc_cache.dc_conf.cc_wt? "thru" : "back",
                    130:            pdc_cache.dc_conf.cc_cst? "" : "in", p);
                    131:
                    132:        p = "";
                    133:        if (!pdc_cache.dt_conf.tc_sh) {
                    134:                printf("%u ITLB, ", pdc_cache.it_size);
                    135:                p = "D";
                    136:        }
                    137:        printf("%u %scoherent %sTLB\n",
                    138:            pdc_cache.dt_size, pdc_cache.dt_conf.tc_cst? "" : "in", p);
                    139:
                    140: /* TODO spin up others */
                    141: }

CVSweb