1/* 2 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6#ifndef PCI_BUS_MANAGER_PPC_IO_H 7#define PCI_BUS_MANAGER_PPC_IO_H 8 9#include <SupportDefs.h> 10 11static inline void 12ppc_out8(vuint8 *address, uint8 value) 13{ 14 *address = value; 15 asm volatile("eieio; sync"); 16} 17 18 19static inline void 20ppc_out16(vuint16 *address, uint16 value) 21{ 22 *address = value; 23 asm volatile("eieio; sync"); 24} 25 26 27static inline void 28ppc_out16_reverse(vuint16 *address, uint16 value) 29{ 30 asm volatile("sthbrx %1, 0, %0" : : "r"(address), "r"(value)); 31 asm volatile("eieio; sync"); 32} 33 34 35static inline void 36ppc_out32(vuint32 *address, uint32 value) 37{ 38 *address = value; 39 asm volatile("eieio; sync"); 40} 41 42 43static inline void 44ppc_out32_reverse(vuint32 *address, uint32 value) 45{ 46 asm volatile("stwbrx %1, 0, %0" : : "r"(address), "r"(value)); 47 asm volatile("eieio; sync"); 48} 49 50 51static inline uint8 52ppc_in8(const vuint8 *address) 53{ 54 uint8 value = *address; 55 asm volatile("eieio; sync"); 56 return value; 57} 58 59 60static inline uint16 61ppc_in16(const vuint16 *address) 62{ 63 uint16 value = *address; 64 asm volatile("eieio; sync"); 65 return value; 66} 67 68 69static inline uint16 70ppc_in16_reverse(const vuint16 *address) 71{ 72 uint16 value; 73 asm volatile("lhbrx %0, 0, %1" : "=r"(value) : "r"(address)); 74 asm volatile("eieio; sync"); 75 return value; 76} 77 78 79static inline uint32 80ppc_in32(const vuint32 *address) 81{ 82 uint32 value = *address; 83 asm volatile("eieio; sync"); 84 return value; 85} 86 87 88static inline uint32 89ppc_in32_reverse(const vuint32 *address) 90{ 91 uint32 value; 92 asm volatile("lwbrx %0, 0, %1" : "=r"(value) : "r"(address)); 93 asm volatile("eieio; sync"); 94 return value; 95} 96 97#endif // PCI_BUS_MANAGER_PPC_IO_H 98