ppc_htab.c
来自「linux-2.4.29操作系统的源码」· C语言 代码 · 共 702 行 · 第 1/2 页
C
702 行
} if ( !strncmp( buffer, "itlb", 4) ) { if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) { /* setup mmcr0 and clear the correct pmc */ asm volatile( "mfspr %0,%1\n\t" /* get current mccr0 */ "rlwinm %0,%0,0,0,31-6\n\t" /* clear bits [26-31] */ "ori %0,%0,%2 \n\t" /* or in mmcr0 settings */ "mtspr %1,%0 \n\t" /* set new mccr0 */ "mtspr %3,%4 \n\t" /* reset the pmc */ : "=r" (tmp) : "i" (MMCR0), "i" (MMCR0_PMC2_ITLB), "i" (PMC2), "r" (0) ); } } if ( !strncmp( buffer, "dc miss", 7) ) { if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) { /* setup mmcr0 and clear the correct pmc */ asm volatile( "mfspr %0,%1\n\t" /* get current mccr0 */ "rlwinm %0,%0,0,0,31-6\n\t" /* clear bits [26-31] */ "ori %0,%0,%2 \n\t" /* or in mmcr0 settings */ "mtspr %1,%0 \n\t" /* set new mccr0 */ "mtspr %3,%4 \n\t" /* reset the pmc */ : "=r" (tmp) : "i" (MMCR0), "i" (MMCR0_PMC2_DCACHEMISS), "i" (PMC2), "r" (0) ); } } return count;#if 0 /* resizing htab is a bit difficult right now -- Cort */ unsigned long size; extern void reset_SDR1(void); /* only know how to set size right now */ if ( strncmp( buffer, "size ", 5) ) return -EINVAL; size = simple_strtoul( &buffer[5], NULL, 10 ); /* only allow to shrink */ if ( size >= Hash_size>>10 ) return -EINVAL; /* minimum size of htab */ if ( size < 64 ) return -EINVAL; /* make sure it's a multiple of 64k */ if ( size % 64 ) return -EINVAL; printk("Hash table resize to %luk\n", size); /* * We need to rehash all kernel entries for the new htab size. * Kernel only since we do a flush_tlb_all(). Since it's kernel * we only need to bother with vsids 0-15. To avoid problems of * clobbering un-rehashed values we put the htab at a new spot * and put everything there. * -- Cort */ Hash_size = size<<10; Hash_mask = (Hash_size >> 6) - 1; _SDR1 = __pa(Hash) | (Hash_mask >> 10); flush_tlb_all(); reset_SDR1();#endif return count;#else /* CONFIG_PPC_STD_MMU */ return 0;#endif /* CONFIG_PPC_STD_MMU */}static long longppc_htab_lseek(struct file * file, loff_t offset, int orig){ switch (orig) { case 0: file->f_pos = offset; return(file->f_pos); case 1: file->f_pos += offset; return(file->f_pos); case 2: return(-EINVAL); default: return(-EINVAL); }}#define TMPBUFLEN 512int proc_dol2crvec(ctl_table *table, int write, struct file *filp, void *buffer, size_t *lenp){ int vleft, first=1, len, left, val; char buf[TMPBUFLEN], *p; static const char *sizestrings[4] = { "2MB", "256KB", "512KB", "1MB" }; static const char *clockstrings[8] = { "clock disabled", "+1 clock", "+1.5 clock", "+3.5 clock", "+2 clock", "+2.5 clock", "+3 clock", "+4 clock" }; static const char *typestrings[4] = { "flow-through burst SRAM", "reserved SRAM", "pipelined burst SRAM", "pipelined late-write SRAM" }; static const char *holdstrings[4] = { "0.5", "1.0", "(reserved2)", "(reserved3)" }; if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR)) return -EFAULT; if ( /*!table->maxlen ||*/ (filp->f_pos && !write)) { *lenp = 0; return 0; } vleft = table->maxlen / sizeof(int); left = *lenp; for (; left /*&& vleft--*/; first=0) { if (write) { while (left) { char c; if(get_user(c,(char *) buffer)) return -EFAULT; if (!isspace(c)) break; left--; buffer++; } if (!left) break; len = left; if (len > TMPBUFLEN-1) len = TMPBUFLEN-1; if(copy_from_user(buf, buffer, len)) return -EFAULT; buf[len] = 0; p = buf; if (*p < '0' || *p > '9') break; val = simple_strtoul(p, &p, 0); len = p-buf; if ((len < left) && *p && !isspace(*p)) break; buffer += len; left -= len; _set_L2CR(val); } else { int is750fx = cur_cpu_spec[0]->cpu_features & CPU_FTR_750FX; p = buf; if (!first) *p++ = '\t'; val = _get_L2CR(); p += sprintf(p, "0x%08x: ", val); p += sprintf(p, " L2 %s, ", (val >> 31) & 1 ? "enabled" : "disabled"); if (!(val>>30&1)) p += sprintf(p, "no "); if (is750fx) p += sprintf(p, "ECC checkstop"); else p += sprintf(p, "parity"); /* 75x & 74x0 have different L2CR than 745x */ if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_SPEC7450)) { if (!is750fx) { p += sprintf(p, ", %s", sizestrings[(val >> 28) & 3]); p += sprintf(p, ", %s", clockstrings[(val >> 25) & 7]); p += sprintf(p, ", %s", typestrings[(val >> 23) & 3]); } p += sprintf(p, "%s", (val>>22)&1 ? ", data only" : ""); if (!is750fx) { p += sprintf(p, "%s", (val>>20)&1 ? ", ZZ enabled": ""); } p += sprintf(p, ", %s", (val>>19)&1 ? "write-through" : "copy-back"); p += sprintf(p, "%s", (val>>18)&1 ? ", testing" : ""); if (!is750fx) { p += sprintf(p, ", %sns hold", holdstrings[(val>>16)&3]); p += sprintf(p, "%s", (val>>15)&1 ? ", DLL slow" : ""); p += sprintf(p, "%s", (val>>14)&1 ? ", diff clock" :""); p += sprintf(p, "%s", (val>>13)&1 ? ", DLL bypass" :""); } else { if ((val>>11)&1) p += sprintf(p, ", lock way 0"); if ((val>>10)&1) p += sprintf(p, ", lock way 1"); if ((val>>9)&1) p += sprintf(p, ", Snoop Hit in Locked Line Error Enabled"); } } else { /* 745x */ p += sprintf(p, ", %sinstn only", (val>>20)&1 ? "" : "no "); p += sprintf(p, ", %sdata only", (val>>16)&1 ? "" : "no "); p += sprintf(p, ", %s replacement", (val>>12)&1 ? "secondary" : "default"); } p += sprintf(p,"\n"); len = strlen(buf); if (len > left) len = left; if(copy_to_user(buffer, buf, len)) return -EFAULT; left -= len; buffer += len; break; } } if (!write && !first && left) { if(put_user('\n', (char *) buffer)) return -EFAULT; left--, buffer++; } if (write) { p = (char *) buffer; while (left) { char c; if(get_user(c, p++)) return -EFAULT; if (!isspace(c)) break; left--; } } if (write && first) return -EINVAL; *lenp -= left; filp->f_pos += *lenp; return 0;}int proc_dol3crvec(ctl_table *table, int write, struct file *filp, void *buffer, size_t *lenp){ int vleft, first=1, len, left, val; char buf[TMPBUFLEN], *p; static const char *clockstrings[8] = { "+6 clock", "reserved(1)", "+2 clock", "+2.5 clock", "+3 clock", "+3.5 clock", "+4 clock", "+5 clock" }; static const char *clocksampstrings[4] = { "2 clock", "3 clock", "4 clock", "5 clock" }; static const char *pclocksampstrings[8] = { "0 P-clock", "1 P-clock", "2 P-clock", "3 P-clock", "4 P-clock", "5 P-clock", "reserved(6)", "reserved(7)" }; static const char *typestrings[4] = { "MSUG2 DDR SRAM", "Pipelined synchronous late-write SRAM", "Reserved", "PB2 SRAM" }; if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR)) return -EFAULT; if (write) return -EFAULT; if (filp->f_pos && !write) { *lenp = 0; return 0; } vleft = table->maxlen / sizeof(int); left = *lenp; for (; left; first=0) { p = buf; if (!first) *p++ = '\t'; val = _get_L3CR(); p += sprintf(p, "0x%08x: ", val); p += sprintf(p, " L3 %s", (val >> 31) & 1 ? "enabled" : "disabled"); p += sprintf(p, ", %sdata parity", (val>>30)&1 ? "" : "no "); p += sprintf(p, ", %saddr parity", (val>>29)&1 ? "" : "no "); p += sprintf(p, ", %s", (val>>28)&1 ? "2MB" : "1MB"); p += sprintf(p, ", clocks %s", (val>>27)&1 ? "enabled" : "disabled"); p += sprintf(p, ", %s", clockstrings[(val >> 23) & 7]); p += sprintf(p, ", %sinstn only", (val>>22)&1 ? "" : "no "); p += sprintf(p, ", %ssample point override", (val>>18)&1 ? "" : "no "); p += sprintf(p, ", %s sample point", clocksampstrings[(val>>16)&3]); p += sprintf(p, ", %s sample point", pclocksampstrings[(val>>13)&7]); p += sprintf(p, ", %s replacement", (val>>12)&1 ? "secondary" : "default"); p += sprintf(p, ", %s", typestrings[(val >> 8) & 3]); p += sprintf(p, ", %sclock cntl", (val>>7)&1 ? "" : "no "); p += sprintf(p, ", %sdata only", (val>>6)&1 ? "" : "no "); p += sprintf(p, ", private mem %s", (val>>2)&1 ? "enabled" : "disabled"); p += sprintf(p, ", %sprivate mem", val&1 ? "2MB " : "1MB "); p += sprintf(p,"\n"); len = strlen(buf); if (len > left) len = left; if(copy_to_user(buffer, buf, len)) return -EFAULT; left -= len; buffer += len; break; } if (!write && !first && left) { if(put_user('\n', (char *) buffer)) return -EFAULT; left--, buffer++; } *lenp -= left; filp->f_pos += *lenp; return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?