/
githubmirror
/
pciutils
Обзор
Документация
Войти
/
githubmirror
/
pciutils
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lib/physmem-access.h
52 строки
1 KB
Pali Rohár
libpci: Move physical memory mapping mmap() code from ecam/mmio-ports to physmem-posix.c file
18 фев 2024, 18:18
18 фев 2024, 18:18
7d347ab
Код
Авторство
О чём код?
/* * The PCI Library -- Compiler-specific wrappers for memory mapped I/O * * Copyright (c) 2023 Pali Rohár <pali@kernel.org> * * Can be freely distributed and used under the terms of the GNU GPL v2+ * * SPDX-License-Identifier: GPL-2.0-or-later */ /* * FIXME * Unfortunately gcc does not provide architecture independent way to read from * or write to memory mapped I/O. The best approximation is to use volatile and * for the write operation follow it by the read operation from the same address. */ static inline void physmem_writeb(unsigned char value, volatile void *ptr) { *(volatile unsigned char *)ptr = value; } static inline void physmem_writew(unsigned short value, volatile void *ptr) { *(volatile unsigned short *)ptr = value; } static inline void physmem_writel(u32 value, volatile void *ptr) { *(volatile u32 *)ptr = value; } static inline unsigned char physmem_readb(volatile void *ptr) { return *(volatile unsigned char *)ptr; } static inline unsigned short physmem_readw(volatile void *ptr) { return *(volatile unsigned short *)ptr; } static inline u32 physmem_readl(volatile void *ptr) { return *(volatile u32 *)ptr; }