/*
* palinfo.c
*
* Prints processor specific information reported by PAL.
* This code is based on specification of PAL as of the
* Intel IA-64 Architecture Software Developer's Manual v1.0.
*
*
* Copyright (C) 2000-2001, 2003 Hewlett-Packard Co
* Stephane Eranian <eranian@hpl.hp.com>
* Copyright (C) 2004 Intel Corporation
* Ashok Raj <ashok.raj@intel.com>
*
* 05/26/2000 S.Eranian initial release
* 08/21/2000 S.Eranian updated to July 2000 PAL specs
* 02/05/2001 S.Eranian fixed module support
* 10/23/2001 S.Eranian updated pal_perf_mon_info bug fixes
* 03/24/2004 Ashok Raj updated to work with CPU Hotplug
*/
#include <linux/config.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/efi.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <asm/pal.h>
#include <asm/sal.h>
#include <asm/page.h>
#include <asm/processor.h>
#include <linux/smp.h>
MODULE_AUTHOR("Stephane Eranian <eranian@hpl.hp.com>");
MODULE_DESCRIPTION("/proc interface to IA-64 PAL");
MODULE_LICENSE("GPL");
#define PALINFO_VERSION "0.5"
typedef int (*palinfo_func_t)(char*);
typedef struct {
const char *name; /* name of the proc entry */
palinfo_func_t proc_read; /* function to call for reading */
struct proc_dir_entry *entry; /* registered entry (removal) */
} palinfo_entry_t;
/*
* A bunch of string array to get pretty printing
*/
static char *cache_types[] = {
"", /* not used */
"Instruction",
"Data",
"Data/Instruction" /* unified */
};
static const char *cache_mattrib[]={
"WriteThrough",
"WriteBack",
"", /* reserved */
"" /* reserved */
};
static const char *cache_st_hints[]={
"Temporal, level 1",
"Reserved",
"Reserved",
"Non-temporal, all levels",
"Reserved",
"Reserved",
"Reserved",
"Reserved"
};
static const char *cache_ld_hints[]={
"Temporal, level 1",
"Non-temporal, level 1",
"Reserved",
"Non-temporal, all levels",
"Reserved",
"Reserved",
"Reserved",
"Reserved"
};
static const char *rse_hints[]={
"enforced lazy",
"eager stores",
"eager loads",
"eager loads and stores"
};
#define RSE_HINTS_COUNT ARRAY_SIZE(rse_hints)
static const char *mem_attrib[]={
"WB", /* 000 */
"SW", /* 001 */
"010", /* 010 */
"011", /* 011 */
"UC", /* 100 */
"UCE", /* 101 */
"WC", /* 110 */
"NaTPage" /* 111 */
};
/*
* Take a 64bit vector and produces a string such that
* if bit n is set then 2^n in clear text is generated. The adjustment
* to the right unit is also done.
*
* Input:
* - a pointer to a buffer to hold the string
* - a 64-bit vector
* Ouput:
* - a pointer to the end of the buffer
*
*/
static char *
bitvector_process(char *p, u64 vector)
{
int i,j;
const char *units[]={ "", "K", "M", "G", "T" };
for (i=0, j=0; i < 64; i++ , j=i/10) {
if (vector & 0x1) {
p += sprintf(p, "%d%s ", 1 << (i-j*10), units[j]);
}
vector >>= 1;
}
return p;
}
/*
* Take a 64bit vector and produces a string such that
* if bit n is set then register n is present. The function
* takes into account consecutive registers and prints out ranges.
*
* Input:
* - a pointer to a buffer to hold the string
* - a 64-bit vector
* Ouput:
* - a pointer to the end of the buffer
*
*/
static char *
bitregister_process(char *p, u64 *reg_info, int max)
{
int i, begin, skip = 0;
u64 value = reg_info[0];
value >>= i = begin = ffs(value) - 1;
for(; i < max; i++ ) {
if (i != 0 && (i%64) == 0) value = *++reg_info;
if ((value & 0x1) == 0 && skip == 0) {
if (begin <= i - 2)
p += sprintf(p, "%d-%d ", begin, i-1);
else
p += sprintf(p, "%d ", i-1);
skip = 1;
begin = -1;
} else if ((value & 0x1) && skip == 1) {
skip = 0;
begin = i;
}
value >>=1;
}
if