tools/testing/selftests/powerpc/dscr/dscr.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/dscr/dscr.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/dscr/dscr.h- Extension
.h- Size
- 1841 bytes
- Lines
- 90
- 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.
Dependency Surface
unistd.hstdio.hstdlib.hstring.hfcntl.hdirent.hpthread.hsched.hsys/types.hsys/stat.hsys/wait.hreg.hutils.h
Detected Declarations
function Registerfunction set_dscrfunction get_dscr_usrfunction set_dscr_usrfunction get_default_dscrfunction set_default_dscr
Annotated Snippet
#ifndef _SELFTESTS_POWERPC_DSCR_DSCR_H
#define _SELFTESTS_POWERPC_DSCR_DSCR_H
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <pthread.h>
#include <sched.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include "reg.h"
#include "utils.h"
#define THREADS 100 /* Max threads */
#define COUNT 100 /* Max iterations */
#define DSCR_MAX 16 /* Max DSCR value */
#define LEN_MAX 100 /* Max name length */
#define DSCR_DEFAULT "/sys/devices/system/cpu/dscr_default"
#define CPU_PATH "/sys/devices/system/cpu/"
#define rmb() asm volatile("lwsync":::"memory")
#define wmb() asm volatile("lwsync":::"memory")
#define READ_ONCE(x) (*(volatile typeof(x) *)&(x))
/* Prilvilege state DSCR access */
inline unsigned long get_dscr(void)
{
return mfspr(SPRN_DSCR_PRIV);
}
inline void set_dscr(unsigned long val)
{
mtspr(SPRN_DSCR_PRIV, val);
}
/* Problem state DSCR access */
inline unsigned long get_dscr_usr(void)
{
return mfspr(SPRN_DSCR);
}
inline void set_dscr_usr(unsigned long val)
{
mtspr(SPRN_DSCR, val);
}
/* Default DSCR access */
unsigned long get_default_dscr(void)
{
int err;
unsigned long val;
err = read_ulong(DSCR_DEFAULT, &val, 16);
if (err) {
perror("read() failed");
exit(1);
}
return val;
}
void set_default_dscr(unsigned long val)
{
int err;
err = write_ulong(DSCR_DEFAULT, val, 16);
if (err) {
perror("write() failed");
exit(1);
}
}
#endif /* _SELFTESTS_POWERPC_DSCR_DSCR_H */
Annotation
- Immediate include surface: `unistd.h`, `stdio.h`, `stdlib.h`, `string.h`, `fcntl.h`, `dirent.h`, `pthread.h`, `sched.h`.
- Detected declarations: `function Register`, `function set_dscr`, `function get_dscr_usr`, `function set_dscr_usr`, `function get_default_dscr`, `function set_default_dscr`.
- 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.