1 /* Copyright (C) 2010 Wildfire Games. 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining 4 * a copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sublicense, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 /* 24 * user-mode interface to Aken driver 25 */ 26 27 // Mahaf - ferryman in Egyptian mythology that wakes up Aken, 28 // and the interface to the Aken driver. 29 30 #ifndef INCLUDED_MAHAF 31 #define INCLUDED_MAHAF 32 33 /** 34 * @return whether mapping physical memory is known to be dangerous 35 * on this platform. 36 * 37 * callable before or after mahaf_Init. 38 * 39 * note: mahaf_MapPhysicalMemory will complain if it 40 * is called despite this function having returned true. 41 **/ 42 LIB_API bool mahaf_IsPhysicalMappingDangerous(); 43 44 45 LIB_API Status mahaf_Init(); 46 LIB_API void mahaf_Shutdown(); 47 48 LIB_API u8 mahaf_ReadPort8 (u16 port); 49 LIB_API u16 mahaf_ReadPort16(u16 port); 50 LIB_API u32 mahaf_ReadPort32(u16 port); 51 LIB_API void mahaf_WritePort8 (u16 port, u8 value); 52 LIB_API void mahaf_WritePort16(u16 port, u16 value); 53 LIB_API void mahaf_WritePort32(u16 port, u32 value); 54 55 LIB_API volatile void* mahaf_MapPhysicalMemory(uintptr_t physicalAddress, size_t numBytes); 56 LIB_API void mahaf_UnmapPhysicalMemory(volatile void* virtualAddress); 57 58 LIB_API u64 mahaf_ReadModelSpecificRegister(u64 reg); 59 LIB_API void mahaf_WriteModelSpecificRegister(u64 reg, u64 value); 60 61 // must be done in the driver because Windows clears CR4.PCE[8] 62 LIB_API u64 mahaf_ReadPerformanceMonitoringCounter(u64 reg); 63 64 #endif // INCLUDED_MAHAF 65