cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

io.c (935B)


      1// SPDX-License-Identifier: GPL-2.0
      2#include <linux/module.h>
      3#include <linux/types.h>
      4
      5#include <asm/io.h>
      6
      7/*
      8 * Copy data from IO memory space to "real" memory space.
      9 * This needs to be optimized.
     10 */
     11void memcpy_fromio(void *to, const volatile void __iomem *from, long count)
     12{
     13	char *dst = to;
     14
     15	while (count) {
     16		count--;
     17		*dst++ = readb(from++);
     18	}
     19}
     20EXPORT_SYMBOL(memcpy_fromio);
     21
     22/*
     23 * Copy data from "real" memory space to IO memory space.
     24 * This needs to be optimized.
     25 */
     26void memcpy_toio(volatile void __iomem *to, const void *from, long count)
     27{
     28	const char *src = from;
     29
     30	while (count) {
     31		count--;
     32		writeb(*src++, to++);
     33	}
     34}
     35EXPORT_SYMBOL(memcpy_toio);
     36
     37/*
     38 * "memset" on IO memory space.
     39 * This needs to be optimized.
     40 */
     41void memset_io(volatile void __iomem *dst, int c, long count)
     42{
     43	unsigned char ch = (char)(c & 0xff);
     44
     45	while (count) {
     46		count--;
     47		writeb(ch, dst);
     48		dst++;
     49	}
     50}
     51EXPORT_SYMBOL(memset_io);