[BACK]Return to procfs_machdep.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / x86 / x86

Annotation of src/sys/arch/x86/x86/procfs_machdep.c, Revision 1.19

1.19    ! maya        1: /*     $NetBSD: procfs_machdep.c,v 1.18 2017/10/05 03:24:40 msaitoh Exp $ */
1.1       rmind       2:
                      3: /*
                      4:  * Copyright (c) 2001 Wasabi Systems, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * Written by Frank van der Linden and Jason R. Thorpe for
                      8:  * Wasabi Systems, Inc.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *      This product includes software developed for the NetBSD Project by
                     21:  *      Wasabi Systems, Inc.
                     22:  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
                     23:  *    or promote products derived from this software without specific prior
                     24:  *    written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
                     30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     36:  * POSSIBILITY OF SUCH DAMAGE.
                     37:  */
                     38:
                     39: /*
                     40:  * NOTE: We simply use the primary CPU's cpuid_level and tsc_freq
                     41:  * here.  Might want to change this later.
                     42:  */
                     43:
                     44: #include <sys/cdefs.h>
1.19    ! maya       45: __KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.18 2017/10/05 03:24:40 msaitoh Exp $");
1.1       rmind      46:
                     47: #include <sys/param.h>
                     48: #include <sys/systm.h>
                     49: #include <sys/mount.h>
                     50: #include <sys/stat.h>
                     51: #include <sys/vnode.h>
                     52:
                     53: #include <miscfs/procfs/procfs.h>
                     54:
                     55: #include <machine/cpu.h>
                     56: #include <machine/reg.h>
                     57: #include <machine/specialreg.h>
1.18      msaitoh    58: #include <x86/cputypes.h>
                     59: #include <x86/cpuvar.h>
1.1       rmind      60:
1.10      msaitoh    61: /*
1.11      msaitoh    62:  *  The feature table. The order is the same as Linux's
1.10      msaitoh    63:  *  x86/include/asm/cpufeatures.h.
                     64:  */
1.8       msaitoh    65: static const char * const x86_features[][32] = {
1.13      msaitoh    66:        { /* (0) Common: 0x0000001 edx */
1.1       rmind      67:        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
                     68:        "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
                     69:        "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
1.8       msaitoh    70:        "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe"},
                     71:
1.13      msaitoh    72:        { /* (1) AMD-defined: 0x80000001 edx */
1.8       msaitoh    73:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     74:        NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
                     75:        NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
                     76:        NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm", "3dnowext","3dnow"},
                     77:
1.10      msaitoh    78:        { /* (2) Transmeta-defined */
1.8       msaitoh    79:        "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
                     80:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     81:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     82:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                     83:
1.10      msaitoh    84:        { /* (3) Linux mapping */
1.8       msaitoh    85:        "cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
                     86:        "constant_tsc", NULL, NULL,
                     87:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     88:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     89:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                     90:
1.13      msaitoh    91:        { /* (4) Intel-defined: 0x00000001 ecx */
1.8       msaitoh    92:        "pni", "pclmulqdq", "dtes64", "monitor", "ds_cpl", "vmx", "smx", "est",
                     93:        "tm2", "ssse3", "cid", "sdbg", "fma", "cx16", "xtpr", "pdcm",
                     94:        NULL, "pcid", "dca", "sse4_1", "sse4_2", "x2apic", "movbe", "popcnt",
                     95:        "tsc_deadline_timer", "aes", "xsave", NULL,
                     96:        "avx", "f16c", "rdrand", "hypervisor"},
                     97:
                     98:        { /* (5) VIA/Cyrix/Centaur-defined */
                     99:        NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
1.13      msaitoh   100:        "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
1.8       msaitoh   101:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    102:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    103:
                    104:        { /* (6) AMD defined 80000001 ecx */
                    105:        "lahf_lm", "cmp_legacy", "svm", "extapic",
                    106:        "cr8_legacy", "abm", "sse4a", "misalignsse",
                    107:        "3dnowprefetch", "osvw", "ibs", "xop", "skinit", "wdt", NULL, "lwp",
                    108:        "fma4", "tce", NULL, "nodeid_msr",
                    109:        NULL, "tbm", "topoext", "perfctr_core",
1.12      msaitoh   110:        "perfctr_nb", NULL, "bpext", "ptsc",
1.17      msaitoh   111:        "perfctr_llc", "mwaitx", NULL, NULL},
1.8       msaitoh   112:
1.10      msaitoh   113:        { /* (7) Linux mapping */
1.12      msaitoh   114:        NULL, NULL, "cpb", "ebp", NULL, "pln", "pts", "dtherm",
1.17      msaitoh   115:        "hw_pstate", "proc_feedback", "sme", NULL,
1.12      msaitoh   116:        NULL, NULL, NULL, "intel_pt",
1.8       msaitoh   117:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    118:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    119:
                    120:        { /* (8) Linux mapping */
                    121:        "tpr_shadow", "vnmi", "flexpriority", "ept",
                    122:        "vpid", "npt", "lbrv", "svm_lock",
                    123:        "nrip_save", "tsc_scale", "vmcb_clean", "flushbyasid",
                    124:        "decodeassists", "pausefilter", "pfthreshold", "vmmcall",
                    125:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    126:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    127:
                    128:        { /* (9) Intel-defined: 00000007 ebx */
                    129:        "fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep",
1.14      msaitoh   130:        "bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", "rdt_a",
1.12      msaitoh   131:        "avx512f", "avx512dq", "rdseed", "adx",
1.14      msaitoh   132:        "smap", NULL, NULL, "clflushopt",
1.8       msaitoh   133:        "clwb", NULL, "avx512pf", "avx512er",
1.12      msaitoh   134:        "avx512cd", "sha_ni", "avx512bw", "avx512vl"},
1.8       msaitoh   135:
1.17      msaitoh   136:        { /* (10) 0x0000000d:1 eax */
1.8       msaitoh   137:        "xsaveopt", "xsavec", "xgetbv1", "xsaves", NULL, NULL, NULL, NULL,
                    138:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    139:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    140:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    141:
1.10      msaitoh   142:        { /* (11) 0x0000000f:0 edx */
1.8       msaitoh   143:        NULL, "cqm_llc", NULL, NULL, NULL, NULL, NULL, NULL,
                    144:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    145:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    146:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    147:
1.10      msaitoh   148:        { /* (12) 0x0000000f:1 edx */
1.8       msaitoh   149:        "cqm_occup_llc", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    150:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    151:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    152:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
1.15      msaitoh   153:
                    154:        { /* (13) 0x80000008 ebx */
                    155:        "clzero", "irperf", NULL, NULL, NULL, NULL, NULL, NULL,
                    156:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    157:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    158:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    159:
                    160:        { /* (14) 0x00000006 eax */
                    161:        "dtherm", "ida", "arat", NULL, "pln", NULL, "pts", "hwp",
                    162:        "hwp_notify", "hwp_act_window", "hwp_epp","hwp_pkg_req",
                    163:        NULL, NULL, NULL, NULL,
                    164:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    165:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    166:
                    167:        { /* (15) 0x8000000a edx */
                    168:        "npt", "lbrv", "svm_lock", "nrip_save",
                    169:        "tsc_scale", "vmcb_clean", "flushbyasid", "decodeassists",
1.17      msaitoh   170:        NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL,
                    171:        "v_vmsave_vmload",
                    172:        "vgif", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1.15      msaitoh   173:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    174:
                    175:        { /* (16) 0x00000007:0 ecx */
                    176:        NULL, "avx512vbmi", NULL, "pku", "ospke", NULL, NULL, NULL,
                    177:        NULL, NULL, NULL, NULL, NULL, NULL, "avx512_vpopcntdq", NULL,
                    178:        "la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
                    179:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    180:
                    181:        { /* (17) 0x80000007 ebx */
                    182:        "overflow_recov", "succor", "smca", NULL, NULL, NULL, NULL, NULL,
                    183:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    184:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    185:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
1.1       rmind     186: };
                    187:
1.6       christos  188: static int     procfs_getonecpu(int, struct cpu_info *, char *, size_t *);
1.1       rmind     189:
                    190: /*
                    191:  * Linux-style /proc/cpuinfo.
                    192:  * Only used when procfs is mounted with -o linux.
                    193:  *
                    194:  * In the multiprocessor case, this should be a loop over all CPUs.
                    195:  */
                    196: int
1.6       christos  197: procfs_getcpuinfstr(char *bf, size_t *len)
1.1       rmind     198: {
                    199:        struct cpu_info *ci;
                    200:        CPU_INFO_ITERATOR cii;
1.6       christos  201:        size_t i, total, size, used;
1.1       rmind     202:
1.6       christos  203:        i = total = 0;
                    204:        used = size = *len;
1.8       msaitoh   205:
1.1       rmind     206:        for (CPU_INFO_FOREACH(cii, ci)) {
1.6       christos  207:                procfs_getonecpu(i++, ci, bf, &used);
                    208:                total += used + 1;
1.16      msaitoh   209:                if (used + 1 <= size) {
1.1       rmind     210:                        bf += used;
                    211:                        *bf++ = '\n';
1.6       christos  212:                        size -= used + 1;
                    213:                        used = size;
                    214:                } else
                    215:                        used = 0;
1.1       rmind     216:        }
1.6       christos  217:        size = *len;
                    218:        *len = total;
                    219:        return size < *len ? -1 : 0;
1.1       rmind     220: }
                    221:
                    222: static int
1.8       msaitoh   223: procfs_getonefeatreg(uint32_t reg, const char * const *table, char *p,
                    224:     size_t *left)
                    225: {
                    226:        size_t l;
                    227:
                    228:        for (size_t i = 0; i < 32; i++) {
                    229:                if ((reg & (1 << i)) && table[i]) {
                    230:                        l = snprintf(p, *left, "%s ", table[i]);
                    231:                        if (l < *left) {
                    232:                                *left -= l;
                    233:                                p += l;
                    234:                        } else
                    235:                                break;
                    236:                }
                    237:        }
                    238:
                    239:        return 0; /* XXX */
                    240: }
                    241:
                    242: /*
1.10      msaitoh   243:  * Print feature bits. The code assume that unused entry of x86_features[]
1.8       msaitoh   244:  * is zero-cleared.
                    245:  *
                    246:  * XXX This function will be rewritten when all of linux entries are
                    247:  * decoded.
                    248:  */
                    249: static int
                    250: procfs_getonecpufeatures(struct cpu_info *ci, char *p, size_t *left)
                    251: {
                    252:        size_t last = *left;
                    253:        size_t diff;
1.17      msaitoh   254:        u_int descs[4];
1.8       msaitoh   255:
                    256:        procfs_getonefeatreg(ci->ci_feat_val[0], x86_features[0], p, left);
                    257:        diff = last - *left;
                    258:
                    259:        procfs_getonefeatreg(ci->ci_feat_val[2], x86_features[1], p + diff,
                    260:            left);
                    261:        diff = last - *left;
                    262:
                    263:        /* x86_features[2] is for Transmeta */
                    264:        /* x86_features[3] is Linux defined mapping */
                    265:
                    266:        procfs_getonefeatreg(ci->ci_feat_val[1], x86_features[4], p + diff,
                    267:            left);
                    268:        diff = last - *left;
                    269:
                    270:        procfs_getonefeatreg(ci->ci_feat_val[4], x86_features[5], p + diff,
                    271:            left);
                    272:        diff = last - *left;
                    273:
                    274:        procfs_getonefeatreg(ci->ci_feat_val[3], x86_features[6], p + diff,
                    275:            left);
                    276:        diff = last - *left;
                    277:
                    278:        /* x86_features[7] is Linux defined mapping */
                    279:        /* x86_features[8] is Linux defined mapping */
                    280:
                    281:        procfs_getonefeatreg(ci->ci_feat_val[5], x86_features[9], p + diff,
                    282:            left);
                    283:        diff = last - *left;
                    284:
1.18      msaitoh   285:        if (ci->ci_max_cpuid >= 0x0d) {
1.17      msaitoh   286:                x86_cpuid2(0x0d, 1, descs);
                    287:                procfs_getonefeatreg(descs[0], x86_features[10], p + diff,
                    288:                    left);
                    289:                diff = last - *left;
                    290:        }
                    291:
1.18      msaitoh   292:        if (ci->ci_max_cpuid >= 0x0f) {
1.17      msaitoh   293:                x86_cpuid2(0x0f, 0, descs);
                    294:                procfs_getonefeatreg(descs[3], x86_features[11], p + diff,
                    295:                    left);
                    296:                diff = last - *left;
                    297:
                    298:                x86_cpuid2(0x0f, 1, descs);
                    299:                procfs_getonefeatreg(descs[3], x86_features[12], p + diff,
                    300:                    left);
                    301:                diff = last - *left;
                    302:        }
                    303:
1.18      msaitoh   304:        if ((cpu_vendor == CPUVENDOR_AMD)
                    305:            && (ci->ci_max_ext_cpuid >= 0x80000008)) {
                    306:                x86_cpuid(0x80000008, descs);
                    307:                procfs_getonefeatreg(descs[1], x86_features[13], p + diff,
                    308:                    left);
                    309:                diff = last - *left;
                    310:        }
1.17      msaitoh   311:
1.18      msaitoh   312:        if (ci->ci_max_cpuid >= 0x06) {
1.17      msaitoh   313:                x86_cpuid(0x06, descs);
                    314:                procfs_getonefeatreg(descs[0], x86_features[14], p + diff,
                    315:                    left);
                    316:                diff = last - *left;
                    317:        }
                    318:
1.18      msaitoh   319:        if ((cpu_vendor == CPUVENDOR_AMD)
                    320:            && (ci->ci_max_ext_cpuid >= 0x8000000a)) {
                    321:                x86_cpuid(0x8000000a, descs);
                    322:                procfs_getonefeatreg(descs[3], x86_features[15], p + diff,
                    323:                    left);
                    324:                diff = last - *left;
                    325:        }
1.15      msaitoh   326:
                    327:        procfs_getonefeatreg(ci->ci_feat_val[6], x86_features[16], p + diff,
                    328:            left);
                    329:        diff = last - *left;
                    330:
1.18      msaitoh   331:        if ((cpu_vendor == CPUVENDOR_AMD)
                    332:            && (ci->ci_max_ext_cpuid >= 0x80000007)) {
                    333:                x86_cpuid(0x80000007, descs);
                    334:                procfs_getonefeatreg(descs[1], x86_features[17], p + diff,
                    335:                    left);
                    336:                diff = last - *left;
                    337:        }
1.10      msaitoh   338:
1.8       msaitoh   339:        return 0; /* XXX */
                    340: }
                    341:
                    342: static int
1.6       christos  343: procfs_getonecpu(int xcpu, struct cpu_info *ci, char *bf, size_t *len)
1.1       rmind     344: {
1.6       christos  345:        size_t left, l, size;
                    346:        char featurebuf[1024], *p;
1.1       rmind     347:
                    348:        p = featurebuf;
                    349:        left = sizeof(featurebuf);
1.6       christos  350:        size = *len;
1.8       msaitoh   351:        procfs_getonecpufeatures(ci, p, &left);
1.1       rmind     352:
                    353:        p = bf;
                    354:        left = *len;
1.6       christos  355:        size = 0;
1.1       rmind     356:        l = snprintf(p, left,
                    357:            "processor\t: %d\n"
                    358:            "vendor_id\t: %s\n"
                    359:            "cpu family\t: %d\n"
                    360:            "model\t\t: %d\n"
                    361:            "model name\t: %s\n"
                    362:            "stepping\t: ",
                    363:            xcpu,
                    364:            (char *)ci->ci_vendor,
1.9       msaitoh   365:            CPUID_TO_FAMILY(ci->ci_signature),
                    366:            CPUID_TO_MODEL(ci->ci_signature),
1.1       rmind     367:            cpu_brand_string
                    368:        );
1.6       christos  369:        size += l;
                    370:        if (l < left) {
                    371:                left -= l;
                    372:                p += l;
                    373:        } else
                    374:                left = 0;
1.1       rmind     375:
                    376:        if (cpuid_level >= 0)
1.9       msaitoh   377:                l = snprintf(p, left, "%d\n",
                    378:                    CPUID_TO_STEPPING(ci->ci_signature));
1.1       rmind     379:        else
                    380:                l = snprintf(p, left, "unknown\n");
                    381:
1.6       christos  382:        size += l;
                    383:        if (l < left) {
                    384:                left -= l;
                    385:                p += l;
                    386:        } else
                    387:                left = 0;
1.1       rmind     388:
                    389:        if (ci->ci_data.cpu_cc_freq != 0) {
                    390:                uint64_t freq, fraq;
                    391:
                    392:                freq = (ci->ci_data.cpu_cc_freq + 4999) / 1000000;
                    393:                fraq = ((ci->ci_data.cpu_cc_freq + 4999) / 10000) % 100;
1.8       msaitoh   394:                l = snprintf(p, left, "cpu MHz\t\t: %" PRIu64 ".%02" PRIu64
                    395:                    "\n", freq, fraq);
1.1       rmind     396:        } else
                    397:                l = snprintf(p, left, "cpu MHz\t\t: unknown\n");
                    398:
1.6       christos  399:        size += l;
                    400:        if (l < left) {
                    401:                left -= l;
                    402:                p += l;
                    403:        } else
                    404:                left = 0;
1.1       rmind     405:
                    406:        l = snprintf(p, left,
1.15      msaitoh   407:            "apicid\t\t: %d\n"
                    408:            "initial apicid\t: %d\n",
                    409:            ci->ci_acpiid,
                    410:            ci->ci_initapicid
                    411:        );
                    412:        size += l;
                    413:        if (l < left) {
                    414:                left -= l;
                    415:                p += l;
                    416:        } else
                    417:                left = 0;
                    418:
                    419:        l = snprintf(p, left,
                    420: #ifdef __i386__
1.1       rmind     421:            "fdiv_bug\t: %s\n"
1.15      msaitoh   422: #endif
1.19    ! maya      423:            "fpu\t\t: yes\n"
1.2       dsl       424:            "fpu_exception\t: yes\n"
1.1       rmind     425:            "cpuid level\t: %d\n"
                    426:            "wp\t\t: %s\n"
1.15      msaitoh   427:            "flags\t\t: %s\n"
                    428:            "clflush size\t: %d\n",
                    429: #ifdef __i386__
1.3       dsl       430:            i386_fpu_fdivbug ? "yes" : "no",    /* an old pentium */
1.15      msaitoh   431: #endif
1.18      msaitoh   432:            ci->ci_max_cpuid,
1.1       rmind     433:            (rcr0() & CR0_WP) ? "yes" : "no",
1.15      msaitoh   434:            featurebuf,
                    435:            ci->ci_cflush_lsize
1.1       rmind     436:        );
1.6       christos  437:        size += l;
1.1       rmind     438:
1.6       christos  439:        left = *len;
                    440:        *len = size;
                    441:        return left < *len ? -1 : 0;
1.1       rmind     442: }
                    443:
                    444: #if defined(__HAVE_PROCFS_MACHDEP) && !defined(__x86_64__)
                    445:
                    446: void
                    447: procfs_machdep_allocvp(struct vnode *vp)
                    448: {
                    449:        struct pfsnode *pfs = vp->v_data;
                    450:
                    451:        switch (pfs->pfs_type) {
                    452:        case Pmachdep_xmmregs:
                    453:                /* /proc/N/xmmregs = -rw------- */
                    454:                pfs->pfs_mode = S_IRUSR|S_IWUSR;
                    455:                vp->v_type = VREG;
                    456:                break;
                    457:        default:
                    458:                KASSERT(false);
                    459:        }
                    460: }
                    461:
                    462: int
                    463: procfs_machdep_rw(struct lwp *curl, struct lwp *l, struct pfsnode *pfs,
                    464:     struct uio *uio)
                    465: {
                    466:
                    467:        switch (pfs->pfs_type) {
                    468:        case Pmachdep_xmmregs:
                    469:                return (procfs_machdep_doxmmregs(curl, l, pfs, uio));
                    470:        default:
                    471:                KASSERT(false);
                    472:        }
                    473:        return EINVAL;
                    474: }
                    475:
                    476: int
                    477: procfs_machdep_getattr(struct vnode *vp, struct vattr *vap, struct proc *procp)
                    478: {
                    479:        struct pfsnode *pfs = VTOPFS(vp);
                    480:
                    481:        switch (pfs->pfs_type) {
                    482:        case Pmachdep_xmmregs:
                    483:                vap->va_bytes = vap->va_size = sizeof(struct xmmregs);
                    484:                break;
                    485:        default:
                    486:                KASSERT(false);
                    487:        }
                    488:        return 0;
                    489: }
                    490:
                    491: int
                    492: procfs_machdep_doxmmregs(struct lwp *curl, struct lwp *l,
                    493:     struct pfsnode *pfs, struct uio *uio)
                    494: {
                    495:
                    496:        return process_machdep_doxmmregs(curl, l, uio);
                    497: }
                    498:
                    499: int
                    500: procfs_machdep_validxmmregs(struct lwp *l, struct mount *mp)
                    501: {
                    502:
                    503:        return process_machdep_validxmmregs(l->l_proc);
                    504: }
                    505:
                    506: #endif

CVSweb <webmaster@jp.NetBSD.org>