Pyrogenesis  trunk
mahaf.h
Go to the documentation of this file.
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  **/
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 
59 LIB_API void mahaf_WriteModelSpecificRegister(u64 reg, u64 value);
60 
61 // must be done in the driver because Windows clears CR4.PCE[8]
63 
64 #endif // INCLUDED_MAHAF
LIB_API void mahaf_WritePort8(u16 port, u8 value)
Definition: mahaf.cpp:95
LIB_API u64 mahaf_ReadPerformanceMonitoringCounter(u64 reg)
Definition: mahaf.cpp:176
uint16_t u16
Definition: types.h:38
LIB_API void mahaf_WritePort32(u16 port, u32 value)
Definition: mahaf.cpp:105
LIB_API u8 mahaf_ReadPort8(u16 port)
Definition: mahaf.cpp:61
uint8_t u8
Definition: types.h:37
LIB_API void mahaf_WriteModelSpecificRegister(u64 reg, u64 value)
Definition: mahaf.cpp:181
uint64_t u64
Definition: types.h:40
uint32_t u32
Definition: types.h:39
LIB_API volatile void * mahaf_MapPhysicalMemory(uintptr_t physicalAddress, size_t numBytes)
Definition: mahaf.cpp:122
LIB_API bool mahaf_IsPhysicalMappingDangerous()
Definition: mahaf.cpp:111
i64 Status
Error handling system.
Definition: status.h:171
LIB_API void mahaf_Shutdown()
Definition: mahaf.cpp:395
LIB_API Status mahaf_Init()
Definition: mahaf.cpp:390
LIB_API u64 mahaf_ReadModelSpecificRegister(u64 reg)
Definition: mahaf.cpp:171
LIB_API u32 mahaf_ReadPort32(u16 port)
Definition: mahaf.cpp:75
LIB_API u16 mahaf_ReadPort16(u16 port)
Definition: mahaf.cpp:68
LIB_API void mahaf_WritePort16(u16 port, u16 value)
Definition: mahaf.cpp:100
LIB_API void mahaf_UnmapPhysicalMemory(volatile void *virtualAddress)
Definition: mahaf.cpp:142