arch/s390/include/asm/pci_io.h

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

File Facts

System
Linux kernel
Corpus path
arch/s390/include/asm/pci_io.h
Extension
.h
Size
4453 bytes
Lines
208
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 zpci_iomap_entry {
	u32 fh;
	u8 bar;
	u16 count;
};

extern struct zpci_iomap_entry *zpci_iomap_start;

#define ZPCI_ADDR(idx) (ZPCI_IOMAP_ADDR_BASE | ((u64) idx << ZPCI_IOMAP_SHIFT))
#define ZPCI_IDX(addr)								\
	(((__force u64) addr & ZPCI_IOMAP_ADDR_IDX_MASK) >> ZPCI_IOMAP_SHIFT)
#define ZPCI_OFFSET(addr)							\
	((__force u64) addr & ZPCI_IOMAP_ADDR_OFF_MASK)

#define ZPCI_CREATE_REQ(handle, space, len)					\
	((u64) handle << 32 | space << 16 | len)

#define zpci_read(LENGTH, RETTYPE)						\
static inline RETTYPE zpci_read_##RETTYPE(const volatile void __iomem *addr)	\
{										\
	u64 data;								\
	int rc;									\
										\
	rc = zpci_load(&data, addr, LENGTH);					\
	if (rc)									\
		data = -1ULL;							\
	return (RETTYPE) data;							\
}

#define zpci_write(LENGTH, VALTYPE)						\
static inline void zpci_write_##VALTYPE(VALTYPE val,				\
					const volatile void __iomem *addr)	\
{										\
	u64 data = (VALTYPE) val;						\
										\
	zpci_store(addr, data, LENGTH);						\
}

zpci_read(8, u64)
zpci_read(4, u32)
zpci_read(2, u16)
zpci_read(1, u8)
zpci_write(8, u64)
zpci_write(4, u32)
zpci_write(2, u16)
zpci_write(1, u8)

static inline int zpci_write_single(volatile void __iomem *dst, const void *src,
				    unsigned long len)
{
	u64 val;

	switch (len) {
	case 1:
		val = (u64) *((u8 *) src);
		break;
	case 2:
		val = (u64) *((u16 *) src);
		break;
	case 4:
		val = (u64) *((u32 *) src);
		break;
	case 8:
		val = (u64) *((u64 *) src);
		break;
	default:
		val = 0;		/* let FW report error */
		break;
	}
	return zpci_store(dst, val, len);
}

static inline int zpci_read_single(void *dst, const volatile void __iomem *src,
				   unsigned long len)
{
	u64 data;
	int cc;

	cc = zpci_load(&data, src, len);
	if (cc)
		goto out;

	switch (len) {
	case 1:
		*((u8 *) dst) = (u8) data;
		break;
	case 2:
		*((u16 *) dst) = (u16) data;
		break;
	case 4:

Annotation

Implementation Notes