2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* S390 version
|
2012-07-20 09:15:04 +00:00
|
|
|
* Copyright IBM Corp. 1999
|
2005-04-16 22:20:36 +00:00
|
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
|
|
|
|
*
|
|
|
|
* Derived from "include/asm-i386/io.h"
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _S390_IO_H
|
|
|
|
#define _S390_IO_H
|
|
|
|
|
2012-11-29 11:50:30 +00:00
|
|
|
#include <linux/kernel.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/page.h>
|
2012-11-29 11:50:30 +00:00
|
|
|
#include <asm/pci_io.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Change virtual addresses to physical addresses and vv.
|
|
|
|
* These are pretty trivial
|
|
|
|
*/
|
2005-11-09 05:34:42 +00:00
|
|
|
static inline unsigned long virt_to_phys(volatile void * address)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned long real_address;
|
2006-09-28 14:56:43 +00:00
|
|
|
asm volatile(
|
|
|
|
" lra %0,0(%1)\n"
|
|
|
|
" jz 0f\n"
|
|
|
|
" la %0,0\n"
|
2012-11-29 11:50:30 +00:00
|
|
|
"0:"
|
2006-09-28 14:56:43 +00:00
|
|
|
: "=a" (real_address) : "a" (address) : "cc");
|
2012-11-29 11:50:30 +00:00
|
|
|
return real_address;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-11-29 11:50:30 +00:00
|
|
|
#define virt_to_phys virt_to_phys
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-09 05:34:42 +00:00
|
|
|
static inline void * phys_to_virt(unsigned long address)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-02-12 14:49:57 +00:00
|
|
|
return (void *) address;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
s390: allow absolute memory access for /dev/mem
Currently dev/mem for s390 provides only real memory access. This means
that the CPU prefix pages are swapped. The prefix swap for real memory
works as follows:
Each CPU owns a prefix register that points to a page aligned memory
location "P". If this CPU accesses the address range [0,0x1fff], it is
translated by the hardware to [P,P+0x1fff]. Accordingly if this CPU
accesses the address range [P,P+0x1fff], it is translated by the hardware
to [0,0x1fff]. Therefore, if [P,P+0x1fff] or [0,0x1fff] is read from
the current /dev/mem device, the incorrectly swapped memory content is
returned.
With this patch the /dev/mem architecture code is modified to provide
absolute memory access. This is done via the arch specific functions
xlate_dev_mem_ptr() and unxlate_dev_mem_ptr(). For swapped pages on
s390 the function xlate_dev_mem_ptr() now returns a new buffer with a
copy of the requested absolute memory. In case the buffer was allocated,
the unxlate_dev_mem_ptr() function frees it after /dev/mem code has
called copy_to_user().
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2012-05-09 14:27:36 +00:00
|
|
|
void *xlate_dev_mem_ptr(unsigned long phys);
|
|
|
|
void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert a virtual cached pointer to an uncached pointer
|
|
|
|
*/
|
|
|
|
#define xlate_dev_kmem_ptr(p) p
|
|
|
|
|
2012-11-29 11:50:30 +00:00
|
|
|
#define IO_SPACE_LIMIT 0
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
|
|
|
#define ioremap_nocache(addr, size) ioremap(addr, size)
|
|
|
|
#define ioremap_wc ioremap_nocache
|
|
|
|
|
|
|
|
/* TODO: s390 cannot support io_remap_pfn_range... */
|
|
|
|
#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
|
|
|
|
remap_pfn_range(vma, vaddr, pfn, size, prot)
|
|
|
|
|
|
|
|
static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
|
|
|
|
{
|
|
|
|
return (void __iomem *) offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void iounmap(volatile void __iomem *addr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* s390 needs a private implementation of pci_iomap since ioremap with its
|
|
|
|
* offset parameter isn't sufficient. That's because BAR spaces are not
|
|
|
|
* disjunctive on s390 so we need the bar parameter of pci_iomap to find
|
|
|
|
* the corresponding device and create the mapping cookie.
|
|
|
|
*/
|
|
|
|
#define pci_iomap pci_iomap
|
|
|
|
#define pci_iounmap pci_iounmap
|
|
|
|
|
|
|
|
#define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count)
|
|
|
|
#define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count)
|
|
|
|
#define memset_io(dst, val, count) zpci_memset_io(dst, val, count)
|
|
|
|
|
|
|
|
#define __raw_readb zpci_read_u8
|
|
|
|
#define __raw_readw zpci_read_u16
|
|
|
|
#define __raw_readl zpci_read_u32
|
|
|
|
#define __raw_readq zpci_read_u64
|
|
|
|
#define __raw_writeb zpci_write_u8
|
|
|
|
#define __raw_writew zpci_write_u16
|
|
|
|
#define __raw_writel zpci_write_u32
|
|
|
|
#define __raw_writeq zpci_write_u64
|
|
|
|
|
2013-01-07 13:03:34 +00:00
|
|
|
#define readb_relaxed readb
|
|
|
|
#define readw_relaxed readw
|
|
|
|
#define readl_relaxed readl
|
|
|
|
#define readq_relaxed readq
|
|
|
|
|
2012-11-29 11:50:30 +00:00
|
|
|
#endif /* CONFIG_PCI */
|
|
|
|
|
|
|
|
#include <asm-generic/io.h>
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|