|
@@ -48,5 +48,28 @@ extern void __uc32_iounmap(volatile void __iomem *addr);
|
|
|
#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT)
|
|
|
#define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1)
|
|
|
|
|
|
+#ifdef CONFIG_STRICT_DEVMEM
|
|
|
+
|
|
|
+#include <linux/ioport.h>
|
|
|
+#include <linux/mm.h>
|
|
|
+
|
|
|
+/*
|
|
|
+ * devmem_is_allowed() checks to see if /dev/mem access to a certain
|
|
|
+ * address is valid. The argument is a physical page number.
|
|
|
+ * We mimic x86 here by disallowing access to system RAM as well as
|
|
|
+ * device-exclusive MMIO regions. This effectively disable read()/write()
|
|
|
+ * on /dev/mem.
|
|
|
+ */
|
|
|
+static inline int devmem_is_allowed(unsigned long pfn)
|
|
|
+{
|
|
|
+ if (iomem_is_exclusive(pfn << PAGE_SHIFT))
|
|
|
+ return 0;
|
|
|
+ if (!page_is_ram(pfn))
|
|
|
+ return 1;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+#endif /* CONFIG_STRICT_DEVMEM */
|
|
|
+
|
|
|
#endif /* __KERNEL__ */
|
|
|
#endif /* __UNICORE_IO_H__ */
|