arch/s390/include/asm/ctlreg.h

Source file repositories/reference/linux-study-clean/arch/s390/include/asm/ctlreg.h

File Facts

System
Linux kernel
Corpus path
arch/s390/include/asm/ctlreg.h
Extension
.h
Size
8004 bytes
Lines
257
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ctlreg {
	unsigned long val;
};

#define __local_ctl_load(low, high, array) do {				\
	struct addrtype {						\
		char _[sizeof(array)];					\
	};								\
	int _high = high;						\
	int _low = low;							\
	int _esize;							\
									\
	_esize = (_high - _low + 1) * sizeof(struct ctlreg);		\
	BUILD_BUG_ON(sizeof(struct addrtype) != _esize);		\
	typecheck(struct ctlreg, array[0]);				\
	asm volatile(							\
		"	lctlg	%[_low],%[_high],%[_arr]"		\
		:							\
		: [_arr] "Q" (*(struct addrtype *)(&array)),		\
		  [_low] "i" (low), [_high] "i" (high)			\
		: "memory");						\
} while (0)

#define __local_ctl_store(low, high, array) do {			\
	struct addrtype {						\
		char _[sizeof(array)];					\
	};								\
	int _high = high;						\
	int _low = low;							\
	int _esize;							\
									\
	_esize = (_high - _low + 1) * sizeof(struct ctlreg);		\
	BUILD_BUG_ON(sizeof(struct addrtype) != _esize);		\
	typecheck(struct ctlreg, array[0]);				\
	asm volatile(							\
		"	stctg	%[_low],%[_high],%[_arr]"		\
		: [_arr] "=Q" (*(struct addrtype *)(&array))		\
		: [_low] "i" (low), [_high] "i" (high));		\
} while (0)

static __always_inline void local_ctl_load(unsigned int cr, struct ctlreg *reg)
{
	asm volatile(
		"	lctlg	%[cr],%[cr],%[reg]"
		:
		: [reg] "Q" (*reg), [cr] "i" (cr)
		: "memory");
}

static __always_inline void local_ctl_store(unsigned int cr, struct ctlreg *reg)
{
	asm volatile(
		"	stctg	%[cr],%[cr],%[reg]"
		: [reg] "=Q" (*reg)
		: [cr] "i" (cr));
}

static __always_inline struct ctlreg local_ctl_set_bit(unsigned int cr, unsigned int bit)
{
	struct ctlreg new, old;

	local_ctl_store(cr, &old);
	new = old;
	new.val |= 1UL << bit;
	local_ctl_load(cr, &new);
	return old;
}

static __always_inline struct ctlreg local_ctl_clear_bit(unsigned int cr, unsigned int bit)
{
	struct ctlreg new, old;

	local_ctl_store(cr, &old);
	new = old;
	new.val &= ~(1UL << bit);
	local_ctl_load(cr, &new);
	return old;
}

struct lowcore;

void system_ctlreg_lock(void);
void system_ctlreg_unlock(void);
void system_ctlreg_init_save_area(struct lowcore *lc);
void system_ctlreg_modify(unsigned int cr, unsigned long data, int request);

enum {
	CTLREG_SET_BIT,
	CTLREG_CLEAR_BIT,
	CTLREG_LOAD,

Annotation

Implementation Notes