libnx
jit.h
Go to the documentation of this file.
1 /**
2  * @file jit.h
3  * @brief Just-in-time compilation support.
4  * @author plutoo
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 
10 /// JIT implementation type.
11 typedef enum {
12  JitType_CodeMemory, ///< JIT supported using svcSetProcessMemoryPermission
13  JitType_JitMemory, ///< JIT supported using 4.0.0+ JIT syscalls.
14 } JitType;
15 
16 /// JIT buffer object.
17 typedef struct {
18  JitType type;
19  size_t size;
20  void* src_addr;
21  void* rx_addr;
22  void* rw_addr;
23  Handle handle;
24 } Jit;
25 
26 /**
27  * @brief Creates a JIT buffer.
28  * @param j JIT buffer.
29  * @param size Size of the JIT buffer.
30  * @return Result code.
31  */
32 Result jitCreate(Jit* j, size_t size);
33 
34 /**
35  * @brief Transition a JIT buffer to have writable permission.
36  * @param j JIT buffer.
37  * @return Result code.
38  */
40 
41 /**
42  * @brief Transition a JIT buffer to have executable permission.
43  * @param j JIT buffer.
44  * @return Result code.
45  */
47 
48 /**
49  * @brief Destroys a JIT buffer.
50  * @param j JIT buffer.
51  * @return Result code.
52  */
53 Result jitClose(Jit* j);
54 
55 /**
56  * @brief Gets the address of the writable memory alias of a JIT buffer.
57  * @param j JIT buffer.
58  * @return Pointer to alias of the JIT buffer that can be written to.
59  */
60 void* jitGetRwAddr(Jit* j);
61 
62 /**
63  * @brief Gets the address of the executable memory alias of a JIT buffer.
64  * @param j JIT buffer.
65  * @return Pointer to alias of the JIT buffer that can be executed.
66  */
67 void* jitGetRxAddr(Jit* j);
JIT supported using svcSetProcessMemoryPermission.
Definition: jit.h:12
u32 Handle
Kernel object handle.
Definition: types.h:45
u32 Result
Function error code result type.
Definition: types.h:46
void * jitGetRwAddr(Jit *j)
Gets the address of the writable memory alias of a JIT buffer.
Result jitTransitionToWritable(Jit *j)
Transition a JIT buffer to have writable permission.
JIT buffer object.
Definition: jit.h:17
JIT supported using 4.0.0+ JIT syscalls.
Definition: jit.h:13
Result jitClose(Jit *j)
Destroys a JIT buffer.
JitType
JIT implementation type.
Definition: jit.h:11
void * jitGetRxAddr(Jit *j)
Gets the address of the executable memory alias of a JIT buffer.
Result jitCreate(Jit *j, size_t size)
Creates a JIT buffer.
Result jitTransitionToExecutable(Jit *j)
Transition a JIT buffer to have executable permission.