tools/power/cpupower/debug/i386/dump_psb.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/debug/i386/dump_psb.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/debug/i386/dump_psb.c- Extension
.c- Size
- 3648 bytes
- Lines
- 195
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.hstdio.hstdlib.hstring.hunistd.hgetopt.hsys/mman.h
Detected Declarations
struct psb_headerstruct pst_headerfunction decode_pstfunction decode_psbfunction print_helpfunction main
Annotated Snippet
struct psb_header {
char signature[10];
u_char version;
u_char flags;
u_short settlingtime;
u_char res1;
u_char numpst;
} __packed;
struct pst_header {
u_int32_t cpuid;
u_char fsb;
u_char maxfid;
u_char startvid;
u_char numpstates;
} __packed;
static u_int fsb;
static u_int sgtc;
static int
decode_pst(char *p, int npstates)
{
int i;
int freq, fid, vid;
for (i = 0; i < npstates; ++i) {
fid = *p++;
vid = *p++;
freq = 100 * fid_to_mult[fid] * fsb;
printf(" %2d %8dkHz FID %02x (%2d.%01d) VID %02x (%4dmV)\n",
i,
freq,
fid, fid_to_mult[fid]/10, fid_to_mult[fid]%10,
vid, vid_to_voltage[vid]);
}
return 0;
}
static
void decode_psb(char *p, int numpst)
{
int i;
struct psb_header *psb;
struct pst_header *pst;
psb = (struct psb_header*) p;
if (psb->version != 0x12)
return;
printf("PSB version: %hhx flags: %hhx settling time %hhuus res1 %hhx num pst %hhu\n",
psb->version,
psb->flags,
psb->settlingtime,
psb->res1,
psb->numpst);
sgtc = psb->settlingtime * 100;
if (sgtc < 10000)
sgtc = 10000;
p = ((char *) psb) + sizeof(struct psb_header);
if (numpst < 0)
numpst = psb->numpst;
else
printf("Overriding number of pst :%d\n", numpst);
for (i = 0; i < numpst; i++) {
pst = (struct pst_header*) p;
if (relevant != 0) {
if (relevant!= pst->cpuid)
goto next_one;
}
printf(" PST %d cpuid %.3x fsb %hhu mfid %hhx svid %hhx numberstates %hhu\n",
i+1,
pst->cpuid,
pst->fsb,
pst->maxfid,
pst->startvid,
pst->numpstates);
fsb = pst->fsb;
decode_pst(p + sizeof(struct pst_header), pst->numpstates);
Annotation
- Immediate include surface: `fcntl.h`, `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`, `getopt.h`, `sys/mman.h`.
- Detected declarations: `struct psb_header`, `struct pst_header`, `function decode_pst`, `function decode_psb`, `function print_help`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.