diff options
| author | 2014-04-18 17:52:49 -0400 | |
|---|---|---|
| committer | 2014-04-18 17:52:49 -0400 | |
| commit | 958bca606e80110e05d7c142dda3097fddc96503 (patch) | |
| tree | 576917751444b4dfdb476d040b4e075bde431b7b /src/core/hle | |
| parent | Init window size from VideoCore. Start changing the default window behavior... (diff) | |
| parent | renamed hw_lcd module to just lcd (diff) | |
| download | yuzu-958bca606e80110e05d7c142dda3097fddc96503.tar.gz yuzu-958bca606e80110e05d7c142dda3097fddc96503.tar.xz yuzu-958bca606e80110e05d7c142dda3097fddc96503.zip | |
Merge branch 'hle-interface'
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/function_wrappers.h | 736 | ||||
| -rw-r--r-- | src/core/hle/hle.cpp | 120 | ||||
| -rw-r--r-- | src/core/hle/hle.h | 66 | ||||
| -rw-r--r-- | src/core/hle/service/apt.cpp | 116 | ||||
| -rw-r--r-- | src/core/hle/service/apt.h | 41 | ||||
| -rw-r--r-- | src/core/hle/service/gsp.cpp | 59 | ||||
| -rw-r--r-- | src/core/hle/service/gsp.h | 35 | ||||
| -rw-r--r-- | src/core/hle/service/hid.cpp | 33 | ||||
| -rw-r--r-- | src/core/hle/service/hid.h | 37 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 94 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 143 | ||||
| -rw-r--r-- | src/core/hle/service/srv.cpp | 58 | ||||
| -rw-r--r-- | src/core/hle/service/srv.h | 40 | ||||
| -rw-r--r-- | src/core/hle/syscall.cpp | 197 | ||||
| -rw-r--r-- | src/core/hle/syscall.h | 19 |
15 files changed, 1794 insertions, 0 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h new file mode 100644 index 000000000..4897d3f28 --- /dev/null +++ b/src/core/hle/function_wrappers.h | |||
| @@ -0,0 +1,736 @@ | |||
| 1 | // Copyright (c) 2012- PPSSPP Project. | ||
| 2 | |||
| 3 | // This program is free software: you can redistribute it and/or modify | ||
| 4 | // it under the terms of the GNU General Public License as published by | ||
| 5 | // the Free Software Foundation, version 2.0 or later versions. | ||
| 6 | |||
| 7 | // This program is distributed in the hope that it will be useful, | ||
| 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 10 | // GNU General Public License 2.0 for more details. | ||
| 11 | |||
| 12 | // A copy of the GPL 2.0 should have been included with the program. | ||
| 13 | // If not, see http://www.gnu.org/licenses/ | ||
| 14 | |||
| 15 | // Official git repository and contact information can be found at | ||
| 16 | // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "common/common_types.h" | ||
| 21 | #include "core/mem_map.h" | ||
| 22 | #include "core/hle/hle.h" | ||
| 23 | |||
| 24 | // For easy parameter parsing and return value processing. | ||
| 25 | |||
| 26 | //32bit wrappers | ||
| 27 | template<void func()> void WrapV_V() { | ||
| 28 | func(); | ||
| 29 | } | ||
| 30 | |||
| 31 | template<u32 func()> void WrapU_V() { | ||
| 32 | RETURN(func()); | ||
| 33 | } | ||
| 34 | |||
| 35 | template<int func(void *, const char *)> void WrapI_VC() { | ||
| 36 | u32 retval = func(Memory::GetPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1))); | ||
| 37 | RETURN(retval); | ||
| 38 | } | ||
| 39 | |||
| 40 | template<u32 func(int, void *, int)> void WrapU_IVI() { | ||
| 41 | u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2)); | ||
| 42 | RETURN(retval); | ||
| 43 | } | ||
| 44 | |||
| 45 | template<int func(const char *, int, int, u32)> void WrapI_CIIU() { | ||
| 46 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 47 | RETURN(retval); | ||
| 48 | } | ||
| 49 | |||
| 50 | template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() { | ||
| 51 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); | ||
| 52 | RETURN(retval); | ||
| 53 | } | ||
| 54 | |||
| 55 | // Hm, do so many params get passed in registers? | ||
| 56 | template<int func(const char *, int, const char *, int, int, int, int, int)> void WrapI_CICIIIII() { | ||
| 57 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), Memory::GetCharPointer(PARAM(2)), | ||
| 58 | PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7)); | ||
| 59 | RETURN(retval); | ||
| 60 | } | ||
| 61 | |||
| 62 | // Hm, do so many params get passed in registers? | ||
| 63 | template<int func(const char *, int, int, int, int, int, int)> void WrapI_CIIIIII() { | ||
| 64 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 65 | PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 66 | RETURN(retval); | ||
| 67 | } | ||
| 68 | |||
| 69 | // Hm, do so many params get passed in registers? | ||
| 70 | template<int func(int, int, int, int, int, int, u32)> void WrapI_IIIIIIU() { | ||
| 71 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 72 | RETURN(retval); | ||
| 73 | } | ||
| 74 | |||
| 75 | // Hm, do so many params get passed in registers? | ||
| 76 | template<int func(int, int, int, int, int, int, int, int, u32)> void WrapI_IIIIIIIIU() { | ||
| 77 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7), PARAM(8)); | ||
| 78 | RETURN(retval); | ||
| 79 | } | ||
| 80 | |||
| 81 | template<u32 func(int, void *)> void WrapU_IV() { | ||
| 82 | u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1))); | ||
| 83 | RETURN(retval); | ||
| 84 | } | ||
| 85 | |||
| 86 | template<float func()> void WrapF_V() { | ||
| 87 | RETURNF(func()); | ||
| 88 | } | ||
| 89 | |||
| 90 | // TODO: Not sure about the floating point parameter passing | ||
| 91 | template<float func(int, float, u32)> void WrapF_IFU() { | ||
| 92 | RETURNF(func(PARAM(0), PARAMF(0), PARAM(1))); | ||
| 93 | } | ||
| 94 | |||
| 95 | template<u32 func(u32)> void WrapU_U() { | ||
| 96 | u32 retval = func(PARAM(0)); | ||
| 97 | RETURN(retval); | ||
| 98 | } | ||
| 99 | |||
| 100 | template<u32 func(u32, int)> void WrapU_UI() { | ||
| 101 | u32 retval = func(PARAM(0), PARAM(1)); | ||
| 102 | RETURN(retval); | ||
| 103 | } | ||
| 104 | |||
| 105 | template<int func(u32)> void WrapI_U() { | ||
| 106 | int retval = func(PARAM(0)); | ||
| 107 | RETURN(retval); | ||
| 108 | } | ||
| 109 | |||
| 110 | template<int func(u32, int)> void WrapI_UI() { | ||
| 111 | int retval = func(PARAM(0), PARAM(1)); | ||
| 112 | RETURN(retval); | ||
| 113 | } | ||
| 114 | |||
| 115 | template<int func(u32, int, int, u32)> void WrapI_UIIU() { | ||
| 116 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 117 | RETURN(retval); | ||
| 118 | } | ||
| 119 | |||
| 120 | template<u32 func(int, u32, int)> void WrapU_IUI() { | ||
| 121 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 122 | RETURN(retval); | ||
| 123 | } | ||
| 124 | |||
| 125 | template<int func(u32, u32)> void WrapI_UU() { | ||
| 126 | int retval = func(PARAM(0), PARAM(1)); | ||
| 127 | RETURN(retval); | ||
| 128 | } | ||
| 129 | |||
| 130 | template<int func(u32, float, float)> void WrapI_UFF() { | ||
| 131 | // Not sure about the float arguments. | ||
| 132 | int retval = func(PARAM(0), PARAMF(0), PARAMF(1)); | ||
| 133 | RETURN(retval); | ||
| 134 | } | ||
| 135 | |||
| 136 | template<int func(u32, u32, u32)> void WrapI_UUU() { | ||
| 137 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 138 | RETURN(retval); | ||
| 139 | } | ||
| 140 | |||
| 141 | template<int func(u32, u32, u32, int)> void WrapI_UUUI() { | ||
| 142 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 143 | RETURN(retval); | ||
| 144 | } | ||
| 145 | |||
| 146 | template<int func(u32, u32, u32, int, int, int,int )> void WrapI_UUUIIII() { | ||
| 147 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 148 | RETURN(retval); | ||
| 149 | } | ||
| 150 | |||
| 151 | template<int func(u32, u32, u32, u32)> void WrapI_UUUU() { | ||
| 152 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 153 | RETURN(retval); | ||
| 154 | } | ||
| 155 | |||
| 156 | template<int func(u32, u32, u32, u32, u32)> void WrapI_UUUUU() { | ||
| 157 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 158 | RETURN(retval); | ||
| 159 | } | ||
| 160 | |||
| 161 | template<int func()> void WrapI_V() { | ||
| 162 | int retval = func(); | ||
| 163 | RETURN(retval); | ||
| 164 | } | ||
| 165 | |||
| 166 | template<u32 func(int)> void WrapU_I() { | ||
| 167 | u32 retval = func(PARAM(0)); | ||
| 168 | RETURN(retval); | ||
| 169 | } | ||
| 170 | |||
| 171 | template<u32 func(int, int, u32)> void WrapU_IIU() { | ||
| 172 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 173 | RETURN(retval); | ||
| 174 | } | ||
| 175 | |||
| 176 | template<int func(int)> void WrapI_I() { | ||
| 177 | int retval = func(PARAM(0)); | ||
| 178 | RETURN(retval); | ||
| 179 | } | ||
| 180 | |||
| 181 | template<void func(u32)> void WrapV_U() { | ||
| 182 | func(PARAM(0)); | ||
| 183 | } | ||
| 184 | |||
| 185 | template<void func(int)> void WrapV_I() { | ||
| 186 | func(PARAM(0)); | ||
| 187 | } | ||
| 188 | |||
| 189 | template<void func(u32, u32)> void WrapV_UU() { | ||
| 190 | func(PARAM(0), PARAM(1)); | ||
| 191 | } | ||
| 192 | |||
| 193 | template<void func(int, int)> void WrapV_II() { | ||
| 194 | func(PARAM(0), PARAM(1)); | ||
| 195 | } | ||
| 196 | |||
| 197 | template<void func(u32, const char *)> void WrapV_UC() { | ||
| 198 | func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 199 | } | ||
| 200 | |||
| 201 | template<int func(u32, const char *)> void WrapI_UC() { | ||
| 202 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 203 | RETURN(retval); | ||
| 204 | } | ||
| 205 | |||
| 206 | template<int func(u32, const char *, int)> void WrapI_UCI() { | ||
| 207 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2)); | ||
| 208 | RETURN(retval); | ||
| 209 | } | ||
| 210 | |||
| 211 | template<u32 func(u32, int , int , int, int, int)> void WrapU_UIIIII() { | ||
| 212 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 213 | RETURN(retval); | ||
| 214 | } | ||
| 215 | |||
| 216 | template<u32 func(u32, int , int , int, u32)> void WrapU_UIIIU() { | ||
| 217 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 218 | RETURN(retval); | ||
| 219 | } | ||
| 220 | |||
| 221 | template<u32 func(u32, int , int , int, int, int, int)> void WrapU_UIIIIII() { | ||
| 222 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 223 | RETURN(retval); | ||
| 224 | } | ||
| 225 | |||
| 226 | template<u32 func(u32, u32)> void WrapU_UU() { | ||
| 227 | u32 retval = func(PARAM(0), PARAM(1)); | ||
| 228 | RETURN(retval); | ||
| 229 | } | ||
| 230 | |||
| 231 | template<u32 func(u32, u32, int)> void WrapU_UUI() { | ||
| 232 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 233 | RETURN(retval); | ||
| 234 | } | ||
| 235 | |||
| 236 | template<u32 func(u32, u32, int, int)> void WrapU_UUII() { | ||
| 237 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 238 | RETURN(retval); | ||
| 239 | } | ||
| 240 | |||
| 241 | template<u32 func(const char *, u32, u32, u32)> void WrapU_CUUU() { | ||
| 242 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 243 | RETURN(retval); | ||
| 244 | } | ||
| 245 | |||
| 246 | template<void func(u32, int, u32, int, int)> void WrapV_UIUII() { | ||
| 247 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 248 | } | ||
| 249 | |||
| 250 | template<u32 func(u32, int, u32, int, int)> void WrapU_UIUII() { | ||
| 251 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 252 | RETURN(retval); | ||
| 253 | } | ||
| 254 | |||
| 255 | template<int func(u32, int, u32, int, int)> void WrapI_UIUII() { | ||
| 256 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 257 | RETURN(retval); | ||
| 258 | } | ||
| 259 | |||
| 260 | template<u32 func(u32, int, u32, int)> void WrapU_UIUI() { | ||
| 261 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 262 | RETURN(retval); | ||
| 263 | } | ||
| 264 | |||
| 265 | template<int func(u32, int, u32, int)> void WrapI_UIUI() { | ||
| 266 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 267 | RETURN(retval); | ||
| 268 | } | ||
| 269 | |||
| 270 | template<u32 func(u32, int, u32)> void WrapU_UIU() { | ||
| 271 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 272 | RETURN(retval); | ||
| 273 | } | ||
| 274 | |||
| 275 | template<u32 func(u32, int, u32, u32)> void WrapU_UIUU() { | ||
| 276 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 277 | RETURN(retval); | ||
| 278 | } | ||
| 279 | |||
| 280 | template<u32 func(u32, int, int)> void WrapU_UII() { | ||
| 281 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 282 | RETURN(retval); | ||
| 283 | } | ||
| 284 | |||
| 285 | template<u32 func(u32, int, int, u32)> void WrapU_UIIU() { | ||
| 286 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 287 | RETURN(retval); | ||
| 288 | } | ||
| 289 | |||
| 290 | template<int func(u32, int, int, u32, u32)> void WrapI_UIIUU() { | ||
| 291 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 292 | RETURN(retval); | ||
| 293 | } | ||
| 294 | |||
| 295 | template<int func(u32, u32, int, int)> void WrapI_UUII() { | ||
| 296 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 297 | RETURN(retval); | ||
| 298 | } | ||
| 299 | |||
| 300 | template<int func(u32, u32, int, int, int)> void WrapI_UUIII() { | ||
| 301 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 302 | RETURN(retval); | ||
| 303 | } | ||
| 304 | |||
| 305 | template<void func(u32, int, int, int)> void WrapV_UIII() { | ||
| 306 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 307 | } | ||
| 308 | |||
| 309 | template<void func(u32, int, int, int, int, int)> void WrapV_UIIIII() { | ||
| 310 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 311 | } | ||
| 312 | |||
| 313 | template<void func(u32, int, int)> void WrapV_UII() { | ||
| 314 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 315 | } | ||
| 316 | |||
| 317 | template<u32 func(int, u32)> void WrapU_IU() { | ||
| 318 | int retval = func(PARAM(0), PARAM(1)); | ||
| 319 | RETURN(retval); | ||
| 320 | } | ||
| 321 | |||
| 322 | template<int func(int, u32)> void WrapI_IU() { | ||
| 323 | int retval = func(PARAM(0), PARAM(1)); | ||
| 324 | RETURN(retval); | ||
| 325 | } | ||
| 326 | |||
| 327 | template<int func(u32, u32, int)> void WrapI_UUI() { | ||
| 328 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 329 | RETURN(retval); | ||
| 330 | } | ||
| 331 | |||
| 332 | template<int func(u32, u32, int, u32)> void WrapI_UUIU() { | ||
| 333 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 334 | RETURN(retval); | ||
| 335 | } | ||
| 336 | |||
| 337 | template<int func(int, int)> void WrapI_II() { | ||
| 338 | int retval = func(PARAM(0), PARAM(1)); | ||
| 339 | RETURN(retval); | ||
| 340 | } | ||
| 341 | |||
| 342 | template<int func(int, int, int)> void WrapI_III() { | ||
| 343 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 344 | RETURN(retval); | ||
| 345 | } | ||
| 346 | |||
| 347 | template<int func(int, u32, int)> void WrapI_IUI() { | ||
| 348 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 349 | RETURN(retval); | ||
| 350 | } | ||
| 351 | |||
| 352 | template<int func(int, int, int, int)> void WrapI_IIII() { | ||
| 353 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 354 | RETURN(retval); | ||
| 355 | } | ||
| 356 | |||
| 357 | template<int func(u32, int, int, int)> void WrapI_UIII() { | ||
| 358 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 359 | RETURN(retval); | ||
| 360 | } | ||
| 361 | |||
| 362 | template<int func(int, int, int, u32, int)> void WrapI_IIIUI() { | ||
| 363 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 364 | RETURN(retval); | ||
| 365 | } | ||
| 366 | |||
| 367 | template<int func(int, u32, u32, int, int)> void WrapI_IUUII() { | ||
| 368 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 369 | RETURN(retval); | ||
| 370 | } | ||
| 371 | |||
| 372 | template<int func(int, const char *, int, u32, u32)> void WrapI_ICIUU() { | ||
| 373 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4)); | ||
| 374 | RETURN(retval); | ||
| 375 | } | ||
| 376 | |||
| 377 | template<int func(int, int, u32)> void WrapI_IIU() { | ||
| 378 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 379 | RETURN(retval); | ||
| 380 | } | ||
| 381 | |||
| 382 | template<void func(int, u32)> void WrapV_IU() { | ||
| 383 | func(PARAM(0), PARAM(1)); | ||
| 384 | } | ||
| 385 | |||
| 386 | template<void func(u32, int)> void WrapV_UI() { | ||
| 387 | func(PARAM(0), PARAM(1)); | ||
| 388 | } | ||
| 389 | |||
| 390 | template<u32 func(const char *)> void WrapU_C() { | ||
| 391 | u32 retval = func(Memory::GetCharPointer(PARAM(0))); | ||
| 392 | RETURN(retval); | ||
| 393 | } | ||
| 394 | |||
| 395 | template<u32 func(const char *, const char *, const char *, u32)> void WrapU_CCCU() { | ||
| 396 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), | ||
| 397 | Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), | ||
| 398 | PARAM(3)); | ||
| 399 | RETURN(retval); | ||
| 400 | } | ||
| 401 | |||
| 402 | template<int func(const char *)> void WrapI_C() { | ||
| 403 | int retval = func(Memory::GetCharPointer(PARAM(0))); | ||
| 404 | RETURN(retval); | ||
| 405 | } | ||
| 406 | |||
| 407 | template<int func(const char *, u32)> void WrapI_CU() { | ||
| 408 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 409 | RETURN(retval); | ||
| 410 | } | ||
| 411 | |||
| 412 | template<int func(const char *, u32, int)> void WrapI_CUI() { | ||
| 413 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 414 | RETURN(retval); | ||
| 415 | } | ||
| 416 | |||
| 417 | template<int func(int, const char *, int, u32)> void WrapI_ICIU() { | ||
| 418 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); | ||
| 419 | RETURN(retval); | ||
| 420 | } | ||
| 421 | |||
| 422 | template<int func(const char *, int, u32)> void WrapI_CIU() { | ||
| 423 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 424 | RETURN(retval); | ||
| 425 | } | ||
| 426 | |||
| 427 | template<int func(const char *, u32, u32)> void WrapI_CUU() { | ||
| 428 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 429 | RETURN(retval); | ||
| 430 | } | ||
| 431 | |||
| 432 | template<int func(const char *, u32, u32, u32)> void WrapI_CUUU() { | ||
| 433 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 434 | PARAM(3)); | ||
| 435 | RETURN(retval); | ||
| 436 | } | ||
| 437 | |||
| 438 | template<int func(const char *, const char*, int, int)> void WrapI_CCII() { | ||
| 439 | int retval = func(Memory::GetCharPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); | ||
| 440 | RETURN(retval); | ||
| 441 | } | ||
| 442 | |||
| 443 | template<int func(const char *, u32, u32, int, u32, u32)> void WrapI_CUUIUU() { | ||
| 444 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 445 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 446 | RETURN(retval); | ||
| 447 | } | ||
| 448 | |||
| 449 | template<int func(const char *, int, int, u32, int, int)> void WrapI_CIIUII() { | ||
| 450 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 451 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 452 | RETURN(retval); | ||
| 453 | } | ||
| 454 | |||
| 455 | template<int func(const char *, int, u32, u32, u32)> void WrapI_CIUUU() { | ||
| 456 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 457 | PARAM(3), PARAM(4)); | ||
| 458 | RETURN(retval); | ||
| 459 | } | ||
| 460 | |||
| 461 | template<int func(const char *, u32, u32, u32, u32, u32)> void WrapI_CUUUUU() { | ||
| 462 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 463 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 464 | RETURN(retval); | ||
| 465 | } | ||
| 466 | |||
| 467 | template<u32 func(const char *, u32)> void WrapU_CU() { | ||
| 468 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 469 | RETURN((u32) retval); | ||
| 470 | } | ||
| 471 | |||
| 472 | template<u32 func(u32, const char *)> void WrapU_UC() { | ||
| 473 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 474 | RETURN(retval); | ||
| 475 | } | ||
| 476 | |||
| 477 | template<u32 func(const char *, u32, u32)> void WrapU_CUU() { | ||
| 478 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 479 | RETURN((u32) retval); | ||
| 480 | } | ||
| 481 | |||
| 482 | template<u32 func(int, int, int)> void WrapU_III() { | ||
| 483 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 484 | RETURN(retval); | ||
| 485 | } | ||
| 486 | |||
| 487 | template<u32 func(int, int)> void WrapU_II() { | ||
| 488 | u32 retval = func(PARAM(0), PARAM(1)); | ||
| 489 | RETURN(retval); | ||
| 490 | } | ||
| 491 | |||
| 492 | template<u32 func(int, int, int, int)> void WrapU_IIII() { | ||
| 493 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 494 | RETURN(retval); | ||
| 495 | } | ||
| 496 | |||
| 497 | template<u32 func(int, u32, u32)> void WrapU_IUU() { | ||
| 498 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 499 | RETURN(retval); | ||
| 500 | } | ||
| 501 | |||
| 502 | template<u32 func(int, u32, u32, u32)> void WrapU_IUUU() { | ||
| 503 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 504 | RETURN(retval); | ||
| 505 | } | ||
| 506 | |||
| 507 | template<u32 func(int, u32, u32, u32, u32)> void WrapU_IUUUU() { | ||
| 508 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 509 | RETURN(retval); | ||
| 510 | } | ||
| 511 | |||
| 512 | template<u32 func(u32, u32, u32)> void WrapU_UUU() { | ||
| 513 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 514 | RETURN(retval); | ||
| 515 | } | ||
| 516 | |||
| 517 | template<void func(int, u32, u32)> void WrapV_IUU() { | ||
| 518 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 519 | } | ||
| 520 | |||
| 521 | template<void func(int, int, u32)> void WrapV_IIU() { | ||
| 522 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 523 | } | ||
| 524 | |||
| 525 | template<void func(u32, int, u32)> void WrapV_UIU() { | ||
| 526 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 527 | } | ||
| 528 | |||
| 529 | template<int func(u32, int, u32)> void WrapI_UIU() { | ||
| 530 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 531 | RETURN(retval); | ||
| 532 | } | ||
| 533 | |||
| 534 | template<void func(int, u32, u32, u32, u32)> void WrapV_IUUUU() { | ||
| 535 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 536 | } | ||
| 537 | |||
| 538 | template<void func(u32, u32, u32)> void WrapV_UUU() { | ||
| 539 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 540 | } | ||
| 541 | |||
| 542 | template<void func(u32, u32, u32, u32)> void WrapV_UUUU() { | ||
| 543 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 544 | } | ||
| 545 | |||
| 546 | template<void func(const char *, u32, int, u32)> void WrapV_CUIU() { | ||
| 547 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 548 | } | ||
| 549 | |||
| 550 | template<int func(const char *, u32, int, u32)> void WrapI_CUIU() { | ||
| 551 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 552 | RETURN(retval); | ||
| 553 | } | ||
| 554 | |||
| 555 | template<void func(u32, const char *, u32, int, u32)> void WrapV_UCUIU() { | ||
| 556 | func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), | ||
| 557 | PARAM(4)); | ||
| 558 | } | ||
| 559 | |||
| 560 | template<int func(u32, const char *, u32, int, u32)> void WrapI_UCUIU() { | ||
| 561 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), | ||
| 562 | PARAM(3), PARAM(4)); | ||
| 563 | RETURN(retval); | ||
| 564 | } | ||
| 565 | |||
| 566 | template<void func(const char *, u32, int, int, u32)> void WrapV_CUIIU() { | ||
| 567 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), | ||
| 568 | PARAM(4)); | ||
| 569 | } | ||
| 570 | |||
| 571 | template<int func(const char *, u32, int, int, u32)> void WrapI_CUIIU() { | ||
| 572 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 573 | PARAM(3), PARAM(4)); | ||
| 574 | RETURN(retval); | ||
| 575 | } | ||
| 576 | |||
| 577 | template<u32 func(u32, u32, u32, u32)> void WrapU_UUUU() { | ||
| 578 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 579 | RETURN(retval); | ||
| 580 | } | ||
| 581 | |||
| 582 | template<u32 func(u32, const char *, u32, u32)> void WrapU_UCUU() { | ||
| 583 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); | ||
| 584 | RETURN(retval); | ||
| 585 | } | ||
| 586 | |||
| 587 | template<u32 func(u32, u32, u32, int)> void WrapU_UUUI() { | ||
| 588 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 589 | RETURN(retval); | ||
| 590 | } | ||
| 591 | |||
| 592 | template<u32 func(u32, u32, u32, int, u32)> void WrapU_UUUIU() { | ||
| 593 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 594 | RETURN(retval); | ||
| 595 | } | ||
| 596 | |||
| 597 | template<u32 func(u32, u32, u32, int, u32, int)> void WrapU_UUUIUI() { | ||
| 598 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 599 | RETURN(retval); | ||
| 600 | } | ||
| 601 | |||
| 602 | template<u32 func(u32, u32, int, u32)> void WrapU_UUIU() { | ||
| 603 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 604 | RETURN(retval); | ||
| 605 | } | ||
| 606 | |||
| 607 | template<u32 func(u32, int, int, int)> void WrapU_UIII() { | ||
| 608 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 609 | RETURN(retval); | ||
| 610 | } | ||
| 611 | |||
| 612 | template<int func(int, u32, u32, u32, u32)> void WrapI_IUUUU() { | ||
| 613 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 614 | RETURN(retval); | ||
| 615 | } | ||
| 616 | |||
| 617 | template<int func(int, u32, u32, u32, u32, u32)> void WrapI_IUUUUU() { | ||
| 618 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 619 | RETURN(retval); | ||
| 620 | } | ||
| 621 | |||
| 622 | template<int func(int, u32, int, int)> void WrapI_IUII() { | ||
| 623 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 624 | RETURN(retval); | ||
| 625 | } | ||
| 626 | template<u32 func(u32, u32, u32, u32, u32)> void WrapU_UUUUU() { | ||
| 627 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 628 | RETURN(retval); | ||
| 629 | } | ||
| 630 | |||
| 631 | template<void func(u32, u32, u32, u32, u32)> void WrapV_UUUUU() { | ||
| 632 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 633 | } | ||
| 634 | |||
| 635 | template<u32 func(const char *, const char *)> void WrapU_CC() { | ||
| 636 | int retval = func(Memory::GetCharPointer(PARAM(0)), | ||
| 637 | Memory::GetCharPointer(PARAM(1))); | ||
| 638 | RETURN(retval); | ||
| 639 | } | ||
| 640 | |||
| 641 | template<void func(const char *, int)> void WrapV_CI() { | ||
| 642 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 643 | } | ||
| 644 | |||
| 645 | template<u32 func(const char *, int)> void WrapU_CI() { | ||
| 646 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 647 | RETURN(retval); | ||
| 648 | } | ||
| 649 | |||
| 650 | template<u32 func(const char *, int, int)> void WrapU_CII() { | ||
| 651 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 652 | RETURN(retval); | ||
| 653 | } | ||
| 654 | |||
| 655 | template<int func(const char *, int, u32, int, u32)> void WrapU_CIUIU() { | ||
| 656 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 657 | PARAM(3), PARAM(4)); | ||
| 658 | RETURN(retval); | ||
| 659 | } | ||
| 660 | |||
| 661 | template<u32 func(const char *, int, u32, int, u32, int)> void WrapU_CIUIUI() { | ||
| 662 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 663 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 664 | RETURN(retval); | ||
| 665 | } | ||
| 666 | |||
| 667 | template<u32 func(u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUU() { | ||
| 668 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), | ||
| 669 | PARAM(5)); | ||
| 670 | RETURN(retval); | ||
| 671 | } | ||
| 672 | |||
| 673 | template<int func(int, u32, u32, u32)> void WrapI_IUUU() { | ||
| 674 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 675 | RETURN(retval); | ||
| 676 | } | ||
| 677 | |||
| 678 | template<int func(int, u32, u32)> void WrapI_IUU() { | ||
| 679 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 680 | RETURN(retval); | ||
| 681 | } | ||
| 682 | |||
| 683 | template<u32 func(u32, u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUUU() { | ||
| 684 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 685 | RETURN(retval); | ||
| 686 | } | ||
| 687 | |||
| 688 | template<int func(u32, int, u32, u32)> void WrapI_UIUU() { | ||
| 689 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 690 | RETURN(retval); | ||
| 691 | } | ||
| 692 | |||
| 693 | template<int func(int, const char *)> void WrapI_IC() { | ||
| 694 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 695 | RETURN(retval); | ||
| 696 | } | ||
| 697 | |||
| 698 | template <int func(int, const char *, const char *, u32, int)> void WrapI_ICCUI() { | ||
| 699 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), PARAM(3), PARAM(4)); | ||
| 700 | RETURN(retval); | ||
| 701 | } | ||
| 702 | |||
| 703 | template <int func(int, const char *, const char *, int)> void WrapI_ICCI() { | ||
| 704 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), PARAM(3)); | ||
| 705 | RETURN(retval); | ||
| 706 | } | ||
| 707 | |||
| 708 | template <int func(const char *, int, int)> void WrapI_CII() { | ||
| 709 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 710 | RETURN(retval); | ||
| 711 | } | ||
| 712 | |||
| 713 | template <int func(int, const char *, int)> void WrapI_ICI() { | ||
| 714 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2)); | ||
| 715 | RETURN(retval); | ||
| 716 | } | ||
| 717 | |||
| 718 | template<int func(int, void *, void *, void *, void *, u32, int)> void WrapI_IVVVVUI(){ | ||
| 719 | u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), Memory::GetPointer(PARAM(2)), Memory::GetPointer(PARAM(3)), Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); | ||
| 720 | RETURN(retval); | ||
| 721 | } | ||
| 722 | |||
| 723 | template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICUVIII(){ | ||
| 724 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)), PARAM(4), PARAM(5), PARAM(6)); | ||
| 725 | RETURN(retval); | ||
| 726 | } | ||
| 727 | |||
| 728 | template<int func(void *, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){ | ||
| 729 | u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 730 | RETURN(retval); | ||
| 731 | } | ||
| 732 | |||
| 733 | template<int func(u32, s64)> void WrapI_US64() { | ||
| 734 | int retval = func(PARAM(0), PARAM64(2)); | ||
| 735 | RETURN(retval); | ||
| 736 | } | ||
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp new file mode 100644 index 000000000..5672a659f --- /dev/null +++ b/src/core/hle/hle.cpp | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "core/mem_map.h" | ||
| 8 | #include "core/hle/hle.h" | ||
| 9 | #include "core/hle/syscall.h" | ||
| 10 | #include "core/hle/service/service.h" | ||
| 11 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 13 | |||
| 14 | namespace HLE { | ||
| 15 | |||
| 16 | static std::vector<ModuleDef> g_module_db; | ||
| 17 | |||
| 18 | u8* g_command_buffer = NULL; ///< Command buffer used for sharing between appcore and syscore | ||
| 19 | |||
| 20 | // Read from memory used by CTROS HLE functions | ||
| 21 | template <typename T> | ||
| 22 | inline void Read(T &var, const u32 addr) { | ||
| 23 | if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) { | ||
| 24 | var = *((const T*)&g_command_buffer[addr & CMD_BUFFER_MASK]); | ||
| 25 | } else { | ||
| 26 | ERROR_LOG(HLE, "unknown read from address %08X", addr); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | // Write to memory used by CTROS HLE functions | ||
| 31 | template <typename T> | ||
| 32 | inline void Write(u32 addr, const T data) { | ||
| 33 | if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) { | ||
| 34 | *(T*)&g_command_buffer[addr & CMD_BUFFER_MASK] = data; | ||
| 35 | } else { | ||
| 36 | ERROR_LOG(HLE, "unknown write to address %08X", addr); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | u8 *GetPointer(const u32 addr) { | ||
| 41 | if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) { | ||
| 42 | return g_command_buffer + (addr & CMD_BUFFER_MASK); | ||
| 43 | } else { | ||
| 44 | ERROR_LOG(HLE, "unknown pointer from address %08X", addr); | ||
| 45 | return 0; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | // Explicitly instantiate template functions because we aren't defining this in the header: | ||
| 50 | |||
| 51 | template void Read<u64>(u64 &var, const u32 addr); | ||
| 52 | template void Read<u32>(u32 &var, const u32 addr); | ||
| 53 | template void Read<u16>(u16 &var, const u32 addr); | ||
| 54 | template void Read<u8>(u8 &var, const u32 addr); | ||
| 55 | |||
| 56 | template void Write<u64>(u32 addr, const u64 data); | ||
| 57 | template void Write<u32>(u32 addr, const u32 data); | ||
| 58 | template void Write<u16>(u32 addr, const u16 data); | ||
| 59 | template void Write<u8>(u32 addr, const u8 data); | ||
| 60 | |||
| 61 | const FunctionDef* GetSyscallInfo(u32 opcode) { | ||
| 62 | u32 func_num = opcode & 0xFFFFFF; // 8 bits | ||
| 63 | if (func_num > 0xFF) { | ||
| 64 | ERROR_LOG(HLE,"Unknown syscall: 0x%02X", func_num); | ||
| 65 | return NULL; | ||
| 66 | } | ||
| 67 | return &g_module_db[0].func_table[func_num]; | ||
| 68 | } | ||
| 69 | |||
| 70 | void CallSyscall(u32 opcode) { | ||
| 71 | const FunctionDef *info = GetSyscallInfo(opcode); | ||
| 72 | |||
| 73 | if (!info) { | ||
| 74 | return; | ||
| 75 | } | ||
| 76 | if (info->func) { | ||
| 77 | info->func(); | ||
| 78 | } else { | ||
| 79 | ERROR_LOG(HLE, "Unimplemented SysCall function %s(..)", info->name.c_str()); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | /// Returns the coprocessor (in this case, syscore) command buffer pointer | ||
| 84 | Addr CallGetThreadCommandBuffer() { | ||
| 85 | // Called on insruction: mrc p15, 0, r0, c13, c0, 3 | ||
| 86 | // Returns an address in OSHLE memory for the CPU to read/write to | ||
| 87 | RETURN(CMD_BUFFER_ADDR); | ||
| 88 | return CMD_BUFFER_ADDR; | ||
| 89 | } | ||
| 90 | |||
| 91 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { | ||
| 92 | ModuleDef module = {name, num_functions, func_table}; | ||
| 93 | g_module_db.push_back(module); | ||
| 94 | } | ||
| 95 | |||
| 96 | void RegisterAllModules() { | ||
| 97 | Syscall::Register(); | ||
| 98 | } | ||
| 99 | |||
| 100 | void Init() { | ||
| 101 | Service::Init(); | ||
| 102 | |||
| 103 | g_command_buffer = new u8[CMD_BUFFER_SIZE]; | ||
| 104 | |||
| 105 | RegisterAllModules(); | ||
| 106 | |||
| 107 | NOTICE_LOG(HLE, "initialized OK"); | ||
| 108 | } | ||
| 109 | |||
| 110 | void Shutdown() { | ||
| 111 | Service::Shutdown(); | ||
| 112 | |||
| 113 | delete g_command_buffer; | ||
| 114 | |||
| 115 | g_module_db.clear(); | ||
| 116 | |||
| 117 | NOTICE_LOG(HLE, "shutdown OK"); | ||
| 118 | } | ||
| 119 | |||
| 120 | } // namespace | ||
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h new file mode 100644 index 000000000..628a1da89 --- /dev/null +++ b/src/core/hle/hle.h | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "core/core.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | |||
| 12 | #define PARAM(n) Core::g_app_core->GetReg(n) | ||
| 13 | #define PARAM64(n) (Core::g_app_core->GetReg(n) | ((u64)Core::g_app_core->GetReg(n + 1) << 32)) | ||
| 14 | #define RETURN(n) Core::g_app_core->SetReg(0, n) | ||
| 15 | |||
| 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 17 | |||
| 18 | namespace HLE { | ||
| 19 | |||
| 20 | enum { | ||
| 21 | CMD_BUFFER_ADDR = 0xA0010000, ///< Totally arbitrary unused address space | ||
| 22 | CMD_BUFFER_SIZE = 0x10000, | ||
| 23 | CMD_BUFFER_MASK = (CMD_BUFFER_SIZE - 1), | ||
| 24 | CMD_BUFFER_ADDR_END = (CMD_BUFFER_ADDR + CMD_BUFFER_SIZE), | ||
| 25 | }; | ||
| 26 | |||
| 27 | typedef u32 Addr; | ||
| 28 | typedef void (*Func)(); | ||
| 29 | |||
| 30 | struct FunctionDef { | ||
| 31 | u32 id; | ||
| 32 | Func func; | ||
| 33 | std::string name; | ||
| 34 | }; | ||
| 35 | |||
| 36 | struct ModuleDef { | ||
| 37 | std::string name; | ||
| 38 | int num_funcs; | ||
| 39 | const FunctionDef* func_table; | ||
| 40 | }; | ||
| 41 | |||
| 42 | // Read from memory used by CTROS HLE functions | ||
| 43 | template <typename T> | ||
| 44 | inline void Read(T &var, const u32 addr); | ||
| 45 | |||
| 46 | // Write to memory used by CTROS HLE functions | ||
| 47 | template <typename T> | ||
| 48 | inline void Write(u32 addr, const T data); | ||
| 49 | |||
| 50 | u8* GetPointer(const u32 Address); | ||
| 51 | |||
| 52 | inline const char* GetCharPointer(const u32 address) { | ||
| 53 | return (const char *)GetPointer(address); | ||
| 54 | } | ||
| 55 | |||
| 56 | void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table); | ||
| 57 | |||
| 58 | void CallSyscall(u32 opcode); | ||
| 59 | |||
| 60 | Addr CallGetThreadCommandBuffer(); | ||
| 61 | |||
| 62 | void Init(); | ||
| 63 | |||
| 64 | void Shutdown(); | ||
| 65 | |||
| 66 | } // namespace | ||
diff --git a/src/core/hle/service/apt.cpp b/src/core/hle/service/apt.cpp new file mode 100644 index 000000000..4f8d7248d --- /dev/null +++ b/src/core/hle/service/apt.cpp | |||
| @@ -0,0 +1,116 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | |||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/hle/hle.h" | ||
| 9 | #include "core/hle/service/apt.h" | ||
| 10 | |||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 12 | // Namespace APT_U | ||
| 13 | |||
| 14 | namespace APT_U { | ||
| 15 | |||
| 16 | void Initialize() { | ||
| 17 | NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize"); | ||
| 18 | } | ||
| 19 | |||
| 20 | void GetLockHandle() { | ||
| 21 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); | ||
| 22 | cmd_buff[5] = 0x00000000; // TODO: This should be an actual mutex handle | ||
| 23 | } | ||
| 24 | |||
| 25 | const HLE::FunctionDef FunctionTable[] = { | ||
| 26 | {0x00010040, GetLockHandle, "GetLockHandle"}, | ||
| 27 | {0x00020080, Initialize, "Initialize"}, | ||
| 28 | {0x00030040, NULL, "Enable"}, | ||
| 29 | {0x00040040, NULL, "Finalize"}, | ||
| 30 | {0x00050040, NULL, "GetAppletManInfo"}, | ||
| 31 | {0x00060040, NULL, "GetAppletInfo"}, | ||
| 32 | {0x00070000, NULL, "GetLastSignaledAppletId"}, | ||
| 33 | {0x00080000, NULL, "CountRegisteredApplet"}, | ||
| 34 | {0x00090040, NULL, "IsRegistered"}, | ||
| 35 | {0x000A0040, NULL, "GetAttribute"}, | ||
| 36 | {0x000B0040, NULL, "InquireNotification"}, | ||
| 37 | {0x000C0104, NULL, "SendParameter"}, | ||
| 38 | {0x000D0080, NULL, "ReceiveParameter"}, | ||
| 39 | {0x000E0080, NULL, "GlanceParameter"}, | ||
| 40 | {0x000F0100, NULL, "CancelParameter"}, | ||
| 41 | {0x001000C2, NULL, "DebugFunc"}, | ||
| 42 | {0x001100C0, NULL, "MapProgramIdForDebug"}, | ||
| 43 | {0x00120040, NULL, "SetHomeMenuAppletIdForDebug"}, | ||
| 44 | {0x00130000, NULL, "GetPreparationState"}, | ||
| 45 | {0x00140040, NULL, "SetPreparationState"}, | ||
| 46 | {0x00150140, NULL, "PrepareToStartApplication"}, | ||
| 47 | {0x00160040, NULL, "PreloadLibraryApplet"}, | ||
| 48 | {0x00170040, NULL, "FinishPreloadingLibraryApplet"}, | ||
| 49 | {0x00180040, NULL, "PrepareToStartLibraryApplet"}, | ||
| 50 | {0x00190040, NULL, "PrepareToStartSystemApplet"}, | ||
| 51 | {0x001A0000, NULL, "PrepareToStartNewestHomeMenu"}, | ||
| 52 | {0x001B00C4, NULL, "StartApplication"}, | ||
| 53 | {0x001C0000, NULL, "WakeupApplication"}, | ||
| 54 | {0x001D0000, NULL, "CancelApplication"}, | ||
| 55 | {0x001E0084, NULL, "StartLibraryApplet"}, | ||
| 56 | {0x001F0084, NULL, "StartSystemApplet"}, | ||
| 57 | {0x00200044, NULL, "StartNewestHomeMenu"}, | ||
| 58 | {0x00210000, NULL, "OrderToCloseApplication"}, | ||
| 59 | {0x00220040, NULL, "PrepareToCloseApplication"}, | ||
| 60 | {0x00230040, NULL, "PrepareToJumpToApplication"}, | ||
| 61 | {0x00240044, NULL, "JumpToApplication"}, | ||
| 62 | {0x002500C0, NULL, "PrepareToCloseLibraryApplet"}, | ||
| 63 | {0x00260000, NULL, "PrepareToCloseSystemApplet"}, | ||
| 64 | {0x00270044, NULL, "CloseApplication"}, | ||
| 65 | {0x00280044, NULL, "CloseLibraryApplet"}, | ||
| 66 | {0x00290044, NULL, "CloseSystemApplet"}, | ||
| 67 | {0x002A0000, NULL, "OrderToCloseSystemApplet"}, | ||
| 68 | {0x002B0000, NULL, "PrepareToJumpToHomeMenu"}, | ||
| 69 | {0x002C0044, NULL, "JumpToHomeMenu"}, | ||
| 70 | {0x002D0000, NULL, "PrepareToLeaveHomeMenu"}, | ||
| 71 | {0x002E0044, NULL, "LeaveHomeMenu"}, | ||
| 72 | {0x002F0040, NULL, "PrepareToLeaveResidentApplet"}, | ||
| 73 | {0x00300044, NULL, "LeaveResidentApplet"}, | ||
| 74 | {0x00310100, NULL, "PrepareToDoApplicationJump"}, | ||
| 75 | {0x00320084, NULL, "DoApplicationJump"}, | ||
| 76 | {0x00330000, NULL, "GetProgramIdOnApplicationJump"}, | ||
| 77 | {0x00340084, NULL, "SendDeliverArg"}, | ||
| 78 | {0x00350080, NULL, "ReceiveDeliverArg"}, | ||
| 79 | {0x00360040, NULL, "LoadSysMenuArg"}, | ||
| 80 | {0x00370042, NULL, "StoreSysMenuArg"}, | ||
| 81 | {0x00380040, NULL, "PreloadResidentApplet"}, | ||
| 82 | {0x00390040, NULL, "PrepareToStartResidentApplet"}, | ||
| 83 | {0x003A0044, NULL, "StartResidentApplet"}, | ||
| 84 | {0x003B0040, NULL, "CancelLibraryApplet"}, | ||
| 85 | {0x003C0042, NULL, "SendDspSleep"}, | ||
| 86 | {0x003D0042, NULL, "SendDspWakeUp"}, | ||
| 87 | {0x003E0080, NULL, "ReplySleepQuery"}, | ||
| 88 | {0x003F0040, NULL, "ReplySleepNotificationComplete"}, | ||
| 89 | {0x00400042, NULL, "SendCaptureBufferInfo"}, | ||
| 90 | {0x00410040, NULL, "ReceiveCaptureBufferInfo"}, | ||
| 91 | {0x00420080, NULL, "SleepSystem"}, | ||
| 92 | {0x00430040, NULL, "NotifyToWait"}, | ||
| 93 | {0x00440000, NULL, "GetSharedFont"}, | ||
| 94 | {0x00450040, NULL, "GetWirelessRebootInfo"}, | ||
| 95 | {0x00460104, NULL, "Wrap"}, | ||
| 96 | {0x00470104, NULL, "Unwrap"}, | ||
| 97 | {0x00480100, NULL, "GetProgramInfo"}, | ||
| 98 | {0x00490180, NULL, "Reboot"}, | ||
| 99 | {0x004A0040, NULL, "GetCaptureInfo"}, | ||
| 100 | {0x004B00C2, NULL, "AppletUtility"}, | ||
| 101 | {0x004C0000, NULL, "SetFatalErrDispMode"}, | ||
| 102 | {0x004D0080, NULL, "GetAppletProgramInfo"}, | ||
| 103 | {0x004E0000, NULL, "HardwareResetAsync"}, | ||
| 104 | }; | ||
| 105 | |||
| 106 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 107 | // Interface class | ||
| 108 | |||
| 109 | Interface::Interface() { | ||
| 110 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 111 | } | ||
| 112 | |||
| 113 | Interface::~Interface() { | ||
| 114 | } | ||
| 115 | |||
| 116 | } // namespace | ||
diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h new file mode 100644 index 000000000..e74baac0c --- /dev/null +++ b/src/core/hle/service/apt.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace APT_U | ||
| 11 | |||
| 12 | namespace APT_U { | ||
| 13 | |||
| 14 | // Application and title launching service. These services handle signaling for home/power button as | ||
| 15 | // well. Only one session for either APT service can be open at a time, normally processes close the | ||
| 16 | // service handle immediately once finished using the service. The commands for APT:U and APT:S are | ||
| 17 | // exactly the same, however certain commands are only accessible with APT:S(NS module will call | ||
| 18 | // svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services. | ||
| 19 | |||
| 20 | /// Interface to "APT:U" service | ||
| 21 | class Interface : public Service::Interface { | ||
| 22 | public: | ||
| 23 | |||
| 24 | Interface(); | ||
| 25 | |||
| 26 | ~Interface(); | ||
| 27 | |||
| 28 | /** | ||
| 29 | * Gets the string port name used by CTROS for the service | ||
| 30 | * @return Port name of service | ||
| 31 | */ | ||
| 32 | std::string GetPortName() const { | ||
| 33 | return "APT:U"; | ||
| 34 | } | ||
| 35 | |||
| 36 | private: | ||
| 37 | |||
| 38 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 39 | }; | ||
| 40 | |||
| 41 | } // namespace | ||
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp new file mode 100644 index 000000000..7c80ab8b5 --- /dev/null +++ b/src/core/hle/service/gsp.cpp | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | |||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/hle/hle.h" | ||
| 9 | #include "core/hle/service/gsp.h" | ||
| 10 | |||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 12 | // Namespace GSP_GPU | ||
| 13 | |||
| 14 | namespace GSP_GPU { | ||
| 15 | |||
| 16 | const HLE::FunctionDef FunctionTable[] = { | ||
| 17 | {0x00010082, NULL, "WriteHWRegs"}, | ||
| 18 | {0x00020084, NULL, "WriteHWRegsWithMask"}, | ||
| 19 | {0x00030082, NULL, "WriteHWRegRepeat"}, | ||
| 20 | {0x00040080, NULL, "ReadHWRegs"}, | ||
| 21 | {0x00050200, NULL, "SetBufferSwap"}, | ||
| 22 | {0x00060082, NULL, "SetCommandList"}, | ||
| 23 | {0x000700C2, NULL, "RequestDma"}, | ||
| 24 | {0x00080082, NULL, "FlushDataCache"}, | ||
| 25 | {0x00090082, NULL, "InvalidateDataCache"}, | ||
| 26 | {0x000A0044, NULL, "RegisterInterruptEvents"}, | ||
| 27 | {0x000B0040, NULL, "SetLcdForceBlack"}, | ||
| 28 | {0x000C0000, NULL, "TriggerCmdReqQueue"}, | ||
| 29 | {0x000D0140, NULL, "SetDisplayTransfer"}, | ||
| 30 | {0x000E0180, NULL, "SetTextureCopy"}, | ||
| 31 | {0x000F0200, NULL, "SetMemoryFill"}, | ||
| 32 | {0x00100040, NULL, "SetAxiConfigQoSMode"}, | ||
| 33 | {0x00110040, NULL, "SetPerfLogMode"}, | ||
| 34 | {0x00120000, NULL, "GetPerfLog"}, | ||
| 35 | {0x00130042, NULL, "RegisterInterruptRelayQueue"}, | ||
| 36 | {0x00140000, NULL, "UnregisterInterruptRelayQueue"}, | ||
| 37 | {0x00150002, NULL, "TryAcquireRight"}, | ||
| 38 | {0x00160042, NULL, "AcquireRight"}, | ||
| 39 | {0x00170000, NULL, "ReleaseRight"}, | ||
| 40 | {0x00180000, NULL, "ImportDisplayCaptureInfo"}, | ||
| 41 | {0x00190000, NULL, "SaveVramSysArea"}, | ||
| 42 | {0x001A0000, NULL, "RestoreVramSysArea"}, | ||
| 43 | {0x001B0000, NULL, "ResetGpuCore"}, | ||
| 44 | {0x001C0040, NULL, "SetLedForceOff"}, | ||
| 45 | {0x001D0040, NULL, "SetTestCommand"}, | ||
| 46 | {0x001E0080, NULL, "SetInternalPriorities"}, | ||
| 47 | }; | ||
| 48 | |||
| 49 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 50 | // Interface class | ||
| 51 | |||
| 52 | Interface::Interface() { | ||
| 53 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 54 | } | ||
| 55 | |||
| 56 | Interface::~Interface() { | ||
| 57 | } | ||
| 58 | |||
| 59 | } // namespace | ||
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h new file mode 100644 index 000000000..3b1846082 --- /dev/null +++ b/src/core/hle/service/gsp.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace GSP_GPU | ||
| 11 | |||
| 12 | namespace GSP_GPU { | ||
| 13 | |||
| 14 | /// Interface to "srv:" service | ||
| 15 | class Interface : public Service::Interface { | ||
| 16 | public: | ||
| 17 | |||
| 18 | Interface(); | ||
| 19 | |||
| 20 | ~Interface(); | ||
| 21 | |||
| 22 | /** | ||
| 23 | * Gets the string port name used by CTROS for the service | ||
| 24 | * @return Port name of service | ||
| 25 | */ | ||
| 26 | std::string GetPortName() const { | ||
| 27 | return "gsp::Gpu"; | ||
| 28 | } | ||
| 29 | |||
| 30 | private: | ||
| 31 | |||
| 32 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 33 | }; | ||
| 34 | |||
| 35 | } // namespace | ||
diff --git a/src/core/hle/service/hid.cpp b/src/core/hle/service/hid.cpp new file mode 100644 index 000000000..2d823dd16 --- /dev/null +++ b/src/core/hle/service/hid.cpp | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/log.h" | ||
| 6 | |||
| 7 | #include "core/hle/hle.h" | ||
| 8 | #include "core/hle/service/hid.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // Namespace HID_User | ||
| 12 | |||
| 13 | namespace HID_User { | ||
| 14 | |||
| 15 | const HLE::FunctionDef FunctionTable[] = { | ||
| 16 | {0x000A0000, NULL, "GetIPCHandles"}, | ||
| 17 | {0x00110000, NULL, "EnableAccelerometer"}, | ||
| 18 | {0x00130000, NULL, "EnableGyroscopeLow"}, | ||
| 19 | {0x00150000, NULL, "GetGyroscopeLowRawToDpsCoefficient"}, | ||
| 20 | {0x00160000, NULL, "GetGyroscopeLowCalibrateParam"}, | ||
| 21 | }; | ||
| 22 | |||
| 23 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 24 | // Interface class | ||
| 25 | |||
| 26 | Interface::Interface() { | ||
| 27 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 28 | } | ||
| 29 | |||
| 30 | Interface::~Interface() { | ||
| 31 | } | ||
| 32 | |||
| 33 | } // namespace | ||
diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h new file mode 100644 index 000000000..746c1b1fc --- /dev/null +++ b/src/core/hle/service/hid.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace HID_User | ||
| 11 | |||
| 12 | // This service is used for interfacing to physical user controls... perhaps "Human Interface | ||
| 13 | // Devices"? Uses include game pad controls, accelerometers, gyroscopes, etc. | ||
| 14 | |||
| 15 | namespace HID_User { | ||
| 16 | |||
| 17 | class Interface : public Service::Interface { | ||
| 18 | public: | ||
| 19 | |||
| 20 | Interface(); | ||
| 21 | |||
| 22 | ~Interface(); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Gets the string port name used by CTROS for the service | ||
| 26 | * @return Port name of service | ||
| 27 | */ | ||
| 28 | std::string GetPortName() const { | ||
| 29 | return "hid:USER"; | ||
| 30 | } | ||
| 31 | |||
| 32 | private: | ||
| 33 | |||
| 34 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 35 | }; | ||
| 36 | |||
| 37 | } // namespace | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp new file mode 100644 index 000000000..e6605a398 --- /dev/null +++ b/src/core/hle/service/service.cpp | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common.h" | ||
| 6 | #include "common/log.h" | ||
| 7 | #include "common/string_util.h" | ||
| 8 | |||
| 9 | #include "core/hle/hle.h" | ||
| 10 | #include "core/hle/service/service.h" | ||
| 11 | #include "core/hle/service/apt.h" | ||
| 12 | #include "core/hle/service/gsp.h" | ||
| 13 | #include "core/hle/service/hid.h" | ||
| 14 | #include "core/hle/service/srv.h" | ||
| 15 | |||
| 16 | namespace Service { | ||
| 17 | |||
| 18 | Manager* g_manager = NULL; ///< Service manager | ||
| 19 | |||
| 20 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 21 | // Service Manager class | ||
| 22 | |||
| 23 | Manager::Manager() { | ||
| 24 | } | ||
| 25 | |||
| 26 | Manager::~Manager() { | ||
| 27 | for(Interface* service : m_services) { | ||
| 28 | DeleteService(service->GetPortName()); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | /// Add a service to the manager (does not create it though) | ||
| 33 | void Manager::AddService(Interface* service) { | ||
| 34 | int index = m_services.size(); | ||
| 35 | u32 new_uid = GetUIDFromIndex(index); | ||
| 36 | |||
| 37 | m_services.push_back(service); | ||
| 38 | |||
| 39 | m_port_map[service->GetPortName()] = new_uid; | ||
| 40 | service->m_uid = new_uid; | ||
| 41 | } | ||
| 42 | |||
| 43 | /// Removes a service from the manager, also frees memory | ||
| 44 | void Manager::DeleteService(std::string port_name) { | ||
| 45 | auto service = FetchFromPortName(port_name); | ||
| 46 | |||
| 47 | m_services.erase(m_services.begin() + GetIndexFromUID(service->m_uid)); | ||
| 48 | m_port_map.erase(port_name); | ||
| 49 | |||
| 50 | delete service; | ||
| 51 | } | ||
| 52 | |||
| 53 | /// Get a Service Interface from its UID | ||
| 54 | Interface* Manager::FetchFromUID(u32 uid) { | ||
| 55 | int index = GetIndexFromUID(uid); | ||
| 56 | if (index < (int)m_services.size()) { | ||
| 57 | return m_services[index]; | ||
| 58 | } | ||
| 59 | return NULL; | ||
| 60 | } | ||
| 61 | |||
| 62 | /// Get a Service Interface from its port | ||
| 63 | Interface* Manager::FetchFromPortName(std::string port_name) { | ||
| 64 | auto itr = m_port_map.find(port_name); | ||
| 65 | if (itr == m_port_map.end()) { | ||
| 66 | return NULL; | ||
| 67 | } | ||
| 68 | return FetchFromUID(itr->second); | ||
| 69 | } | ||
| 70 | |||
| 71 | |||
| 72 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 73 | // Module interface | ||
| 74 | |||
| 75 | /// Initialize ServiceManager | ||
| 76 | void Init() { | ||
| 77 | g_manager = new Manager; | ||
| 78 | |||
| 79 | g_manager->AddService(new SRV::Interface); | ||
| 80 | g_manager->AddService(new APT_U::Interface); | ||
| 81 | g_manager->AddService(new GSP_GPU::Interface); | ||
| 82 | g_manager->AddService(new HID_User::Interface); | ||
| 83 | |||
| 84 | NOTICE_LOG(HLE, "Services initialized OK"); | ||
| 85 | } | ||
| 86 | |||
| 87 | /// Shutdown ServiceManager | ||
| 88 | void Shutdown() { | ||
| 89 | delete g_manager; | ||
| 90 | NOTICE_LOG(HLE, "Services shutdown OK"); | ||
| 91 | } | ||
| 92 | |||
| 93 | |||
| 94 | } | ||
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h new file mode 100644 index 000000000..9cbf8b6fa --- /dev/null +++ b/src/core/hle/service/service.h | |||
| @@ -0,0 +1,143 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <vector> | ||
| 8 | #include <map> | ||
| 9 | #include <string> | ||
| 10 | |||
| 11 | #include "common/common.h" | ||
| 12 | #include "common/common_types.h" | ||
| 13 | #include "core/hle/syscall.h" | ||
| 14 | |||
| 15 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 16 | // Namespace Service | ||
| 17 | |||
| 18 | namespace Service { | ||
| 19 | |||
| 20 | typedef s32 NativeUID; ///< Native handle for a service | ||
| 21 | |||
| 22 | static const int kMaxPortSize = 0x08; ///< Maximum size of a port name (8 characters) | ||
| 23 | static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header | ||
| 24 | |||
| 25 | class Manager; | ||
| 26 | |||
| 27 | /// Interface to a CTROS service | ||
| 28 | class Interface { | ||
| 29 | friend class Manager; | ||
| 30 | public: | ||
| 31 | |||
| 32 | Interface() { | ||
| 33 | } | ||
| 34 | |||
| 35 | virtual ~Interface() { | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Gets the UID for the serice | ||
| 40 | * @return UID of service in native format | ||
| 41 | */ | ||
| 42 | NativeUID GetUID() const { | ||
| 43 | return (NativeUID)m_uid; | ||
| 44 | } | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Gets the string name used by CTROS for a service | ||
| 48 | * @return Port name of service | ||
| 49 | */ | ||
| 50 | virtual std::string GetPortName() const { | ||
| 51 | return "[UNKNOWN SERVICE PORT]"; | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | ||
| 56 | * @return Return result of svcSendSyncRequest passed back to user app | ||
| 57 | */ | ||
| 58 | Syscall::Result Sync() { | ||
| 59 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + kCommandHeaderOffset); | ||
| 60 | auto itr = m_functions.find(cmd_buff[0]); | ||
| 61 | |||
| 62 | if (itr == m_functions.end()) { | ||
| 63 | ERROR_LOG(OSHLE, "Unknown/unimplemented function: port = %s, command = 0x%08X!", | ||
| 64 | GetPortName().c_str(), cmd_buff[0]); | ||
| 65 | return -1; | ||
| 66 | } | ||
| 67 | if (itr->second.func == NULL) { | ||
| 68 | ERROR_LOG(OSHLE, "Unimplemented function: port = %s, name = %s!", | ||
| 69 | GetPortName().c_str(), itr->second.name.c_str()); | ||
| 70 | return -1; | ||
| 71 | } | ||
| 72 | |||
| 73 | itr->second.func(); | ||
| 74 | |||
| 75 | return 0; // TODO: Implement return from actual function | ||
| 76 | } | ||
| 77 | |||
| 78 | protected: | ||
| 79 | /** | ||
| 80 | * Registers the functions in the service | ||
| 81 | */ | ||
| 82 | void Register(const HLE::FunctionDef* functions, int len) { | ||
| 83 | for (int i = 0; i < len; i++) { | ||
| 84 | m_functions[functions[i].id] = functions[i]; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | private: | ||
| 89 | u32 m_uid; | ||
| 90 | std::map<u32, HLE::FunctionDef> m_functions; | ||
| 91 | |||
| 92 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 93 | }; | ||
| 94 | |||
| 95 | /// Simple class to manage accessing services from ports and UID handles | ||
| 96 | class Manager { | ||
| 97 | |||
| 98 | public: | ||
| 99 | Manager(); | ||
| 100 | |||
| 101 | ~Manager(); | ||
| 102 | |||
| 103 | /// Add a service to the manager (does not create it though) | ||
| 104 | void AddService(Interface* service); | ||
| 105 | |||
| 106 | /// Removes a service from the manager (does not delete it though) | ||
| 107 | void DeleteService(std::string port_name); | ||
| 108 | |||
| 109 | /// Get a Service Interface from its UID | ||
| 110 | Interface* FetchFromUID(u32 uid); | ||
| 111 | |||
| 112 | /// Get a Service Interface from its port | ||
| 113 | Interface* FetchFromPortName(std::string port_name); | ||
| 114 | |||
| 115 | private: | ||
| 116 | |||
| 117 | /// Convert an index into m_services vector into a UID | ||
| 118 | static u32 GetUIDFromIndex(const int index) { | ||
| 119 | return index | 0x10000000; | ||
| 120 | } | ||
| 121 | |||
| 122 | /// Convert a UID into an index into m_services | ||
| 123 | static int GetIndexFromUID(const u32 uid) { | ||
| 124 | return uid & 0x0FFFFFFF; | ||
| 125 | } | ||
| 126 | |||
| 127 | std::vector<Interface*> m_services; | ||
| 128 | std::map<std::string, u32> m_port_map; | ||
| 129 | |||
| 130 | DISALLOW_COPY_AND_ASSIGN(Manager); | ||
| 131 | }; | ||
| 132 | |||
| 133 | /// Initialize ServiceManager | ||
| 134 | void Init(); | ||
| 135 | |||
| 136 | /// Shutdown ServiceManager | ||
| 137 | void Shutdown(); | ||
| 138 | |||
| 139 | |||
| 140 | extern Manager* g_manager; ///< Service manager | ||
| 141 | |||
| 142 | |||
| 143 | } // namespace | ||
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp new file mode 100644 index 000000000..579ea4a34 --- /dev/null +++ b/src/core/hle/service/srv.cpp | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/hle.h" | ||
| 6 | #include "core/hle/service/srv.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // Namespace SRV | ||
| 12 | |||
| 13 | namespace SRV { | ||
| 14 | |||
| 15 | void Initialize() { | ||
| 16 | NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); | ||
| 17 | } | ||
| 18 | |||
| 19 | void GetServiceHandle() { | ||
| 20 | Syscall::Result res = 0; | ||
| 21 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); | ||
| 22 | |||
| 23 | std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize); | ||
| 24 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | ||
| 25 | |||
| 26 | NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name.c_str(), | ||
| 27 | service->GetUID()); | ||
| 28 | |||
| 29 | if (NULL != service) { | ||
| 30 | cmd_buff[3] = service->GetUID(); | ||
| 31 | } else { | ||
| 32 | ERROR_LOG(OSHLE, "Service %s does not exist", port_name.c_str()); | ||
| 33 | res = -1; | ||
| 34 | } | ||
| 35 | cmd_buff[1] = res; | ||
| 36 | |||
| 37 | //return res; | ||
| 38 | } | ||
| 39 | |||
| 40 | const HLE::FunctionDef FunctionTable[] = { | ||
| 41 | {0x00010002, Initialize, "Initialize"}, | ||
| 42 | {0x00020000, NULL, "GetProcSemaphore"}, | ||
| 43 | {0x00030100, NULL, "RegisterService"}, | ||
| 44 | {0x000400C0, NULL, "UnregisterService"}, | ||
| 45 | {0x00050100, GetServiceHandle, "GetServiceHandle"}, | ||
| 46 | }; | ||
| 47 | |||
| 48 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 49 | // Interface class | ||
| 50 | |||
| 51 | Interface::Interface() { | ||
| 52 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 53 | } | ||
| 54 | |||
| 55 | Interface::~Interface() { | ||
| 56 | } | ||
| 57 | |||
| 58 | } // namespace | ||
diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h new file mode 100644 index 000000000..d9ac8fc88 --- /dev/null +++ b/src/core/hle/service/srv.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/service/service.h" | ||
| 6 | |||
| 7 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 8 | // Namespace SRV | ||
| 9 | |||
| 10 | namespace SRV { | ||
| 11 | |||
| 12 | /// Interface to "srv:" service | ||
| 13 | class Interface : public Service::Interface { | ||
| 14 | |||
| 15 | public: | ||
| 16 | |||
| 17 | Interface(); | ||
| 18 | |||
| 19 | ~Interface(); | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Gets the string name used by CTROS for the service | ||
| 23 | * @return Port name of service | ||
| 24 | */ | ||
| 25 | std::string GetPortName() const { | ||
| 26 | return "srv:"; | ||
| 27 | } | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | ||
| 31 | * @return Return result of svcSendSyncRequest passed back to user app | ||
| 32 | */ | ||
| 33 | Syscall::Result Sync(); | ||
| 34 | |||
| 35 | private: | ||
| 36 | |||
| 37 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 38 | }; | ||
| 39 | |||
| 40 | } // namespace | ||
diff --git a/src/core/hle/syscall.cpp b/src/core/hle/syscall.cpp new file mode 100644 index 000000000..e5533a741 --- /dev/null +++ b/src/core/hle/syscall.cpp | |||
| @@ -0,0 +1,197 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <map> | ||
| 6 | |||
| 7 | #include "core/mem_map.h" | ||
| 8 | |||
| 9 | #include "core/hle/function_wrappers.h" | ||
| 10 | #include "core/hle/syscall.h" | ||
| 11 | #include "core/hle/service/service.h" | ||
| 12 | |||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 14 | // Namespace Syscall | ||
| 15 | |||
| 16 | namespace Syscall { | ||
| 17 | |||
| 18 | /// Map application or GSP heap memory | ||
| 19 | Result ControlMemory(void* outaddr, u32 addr0, u32 addr1, u32 size, u32 operation, u32 permissions) { | ||
| 20 | u32 virtual_address = 0x00000000; | ||
| 21 | |||
| 22 | switch (operation) { | ||
| 23 | |||
| 24 | // Map GSP heap memory? | ||
| 25 | case 0x00010003: | ||
| 26 | virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions); | ||
| 27 | break; | ||
| 28 | |||
| 29 | // Unknown ControlMemory operation | ||
| 30 | default: | ||
| 31 | ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation); | ||
| 32 | } | ||
| 33 | |||
| 34 | Core::g_app_core->SetReg(1, Memory::MapBlock_HeapGSP(size, operation, permissions)); | ||
| 35 | return 0; | ||
| 36 | } | ||
| 37 | |||
| 38 | /// Connect to an OS service given the port name, returns the handle to the port to out | ||
| 39 | Result ConnectToPort(void* out, const char* port_name) { | ||
| 40 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | ||
| 41 | Core::g_app_core->SetReg(1, service->GetUID()); | ||
| 42 | return 0; | ||
| 43 | } | ||
| 44 | |||
| 45 | /// Synchronize to an OS service | ||
| 46 | Result SendSyncRequest(Handle session) { | ||
| 47 | Service::Interface* service = Service::g_manager->FetchFromUID(session); | ||
| 48 | service->Sync(); | ||
| 49 | return 0; | ||
| 50 | } | ||
| 51 | |||
| 52 | /// Close a handle | ||
| 53 | Result CloseHandle(Handle handle) { | ||
| 54 | // ImplementMe | ||
| 55 | return 0; | ||
| 56 | } | ||
| 57 | |||
| 58 | /// Wait for a handle to synchronize, timeout after the specified nanoseconds | ||
| 59 | Result WaitSynchronization1(Handle handle, s64 nanoseconds) { | ||
| 60 | // ImplementMe | ||
| 61 | return 0; | ||
| 62 | } | ||
| 63 | |||
| 64 | const HLE::FunctionDef Syscall_Table[] = { | ||
| 65 | {0x00, NULL, "Unknown"}, | ||
| 66 | {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"}, | ||
| 67 | {0x02, NULL, "QueryMemory"}, | ||
| 68 | {0x03, NULL, "ExitProcess"}, | ||
| 69 | {0x04, NULL, "GetProcessAffinityMask"}, | ||
| 70 | {0x05, NULL, "SetProcessAffinityMask"}, | ||
| 71 | {0x06, NULL, "GetProcessIdealProcessor"}, | ||
| 72 | {0x07, NULL, "SetProcessIdealProcessor"}, | ||
| 73 | {0x08, NULL, "CreateThread"}, | ||
| 74 | {0x09, NULL, "ExitThread"}, | ||
| 75 | {0x0A, NULL, "SleepThread"}, | ||
| 76 | {0x0B, NULL, "GetThreadPriority"}, | ||
| 77 | {0x0C, NULL, "SetThreadPriority"}, | ||
| 78 | {0x0D, NULL, "GetThreadAffinityMask"}, | ||
| 79 | {0x0E, NULL, "SetThreadAffinityMask"}, | ||
| 80 | {0x0F, NULL, "GetThreadIdealProcessor"}, | ||
| 81 | {0x10, NULL, "SetThreadIdealProcessor"}, | ||
| 82 | {0x11, NULL, "GetCurrentProcessorNumber"}, | ||
| 83 | {0x12, NULL, "Run"}, | ||
| 84 | {0x13, NULL, "CreateMutex"}, | ||
| 85 | {0x14, NULL, "ReleaseMutex"}, | ||
| 86 | {0x15, NULL, "CreateSemaphore"}, | ||
| 87 | {0x16, NULL, "ReleaseSemaphore"}, | ||
| 88 | {0x17, NULL, "CreateEvent"}, | ||
| 89 | {0x18, NULL, "SignalEvent"}, | ||
| 90 | {0x19, NULL, "ClearEvent"}, | ||
| 91 | {0x1A, NULL, "CreateTimer"}, | ||
| 92 | {0x1B, NULL, "SetTimer"}, | ||
| 93 | {0x1C, NULL, "CancelTimer"}, | ||
| 94 | {0x1D, NULL, "ClearTimer"}, | ||
| 95 | {0x1E, NULL, "CreateMemoryBlock"}, | ||
| 96 | {0x1F, NULL, "MapMemoryBlock"}, | ||
| 97 | {0x20, NULL, "UnmapMemoryBlock"}, | ||
| 98 | {0x21, NULL, "CreateAddressArbiter"}, | ||
| 99 | {0x22, NULL, "ArbitrateAddress"}, | ||
| 100 | {0x23, WrapI_U<CloseHandle>, "CloseHandle"}, | ||
| 101 | {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"}, | ||
| 102 | {0x25, NULL, "WaitSynchronizationN"}, | ||
| 103 | {0x26, NULL, "SignalAndWait"}, | ||
| 104 | {0x27, NULL, "DuplicateHandle"}, | ||
| 105 | {0x28, NULL, "GetSystemTick"}, | ||
| 106 | {0x29, NULL, "GetHandleInfo"}, | ||
| 107 | {0x2A, NULL, "GetSystemInfo"}, | ||
| 108 | {0x2B, NULL, "GetProcessInfo"}, | ||
| 109 | {0x2C, NULL, "GetThreadInfo"}, | ||
| 110 | {0x2D, WrapI_VC<ConnectToPort>, "ConnectToPort"}, | ||
| 111 | {0x2E, NULL, "SendSyncRequest1"}, | ||
| 112 | {0x2F, NULL, "SendSyncRequest2"}, | ||
| 113 | {0x30, NULL, "SendSyncRequest3"}, | ||
| 114 | {0x31, NULL, "SendSyncRequest4"}, | ||
| 115 | {0x32, WrapI_U<SendSyncRequest>, "SendSyncRequest"}, | ||
| 116 | {0x33, NULL, "OpenProcess"}, | ||
| 117 | {0x34, NULL, "OpenThread"}, | ||
| 118 | {0x35, NULL, "GetProcessId"}, | ||
| 119 | {0x36, NULL, "GetProcessIdOfThread"}, | ||
| 120 | {0x37, NULL, "GetThreadId"}, | ||
| 121 | {0x38, NULL, "GetResourceLimit"}, | ||
| 122 | {0x39, NULL, "GetResourceLimitLimitValues"}, | ||
| 123 | {0x3A, NULL, "GetResourceLimitCurrentValues"}, | ||
| 124 | {0x3B, NULL, "GetThreadContext"}, | ||
| 125 | {0x3C, NULL, "Break"}, | ||
| 126 | {0x3D, NULL, "OutputDebugString"}, | ||
| 127 | {0x3E, NULL, "ControlPerformanceCounter"}, | ||
| 128 | {0x3F, NULL, "Unknown"}, | ||
| 129 | {0x40, NULL, "Unknown"}, | ||
| 130 | {0x41, NULL, "Unknown"}, | ||
| 131 | {0x42, NULL, "Unknown"}, | ||
| 132 | {0x43, NULL, "Unknown"}, | ||
| 133 | {0x44, NULL, "Unknown"}, | ||
| 134 | {0x45, NULL, "Unknown"}, | ||
| 135 | {0x46, NULL, "Unknown"}, | ||
| 136 | {0x47, NULL, "CreatePort"}, | ||
| 137 | {0x48, NULL, "CreateSessionToPort"}, | ||
| 138 | {0x49, NULL, "CreateSession"}, | ||
| 139 | {0x4A, NULL, "AcceptSession"}, | ||
| 140 | {0x4B, NULL, "ReplyAndReceive1"}, | ||
| 141 | {0x4C, NULL, "ReplyAndReceive2"}, | ||
| 142 | {0x4D, NULL, "ReplyAndReceive3"}, | ||
| 143 | {0x4E, NULL, "ReplyAndReceive4"}, | ||
| 144 | {0x4F, NULL, "ReplyAndReceive"}, | ||
| 145 | {0x50, NULL, "BindInterrupt"}, | ||
| 146 | {0x51, NULL, "UnbindInterrupt"}, | ||
| 147 | {0x52, NULL, "InvalidateProcessDataCache"}, | ||
| 148 | {0x53, NULL, "StoreProcessDataCache"}, | ||
| 149 | {0x54, NULL, "FlushProcessDataCache"}, | ||
| 150 | {0x55, NULL, "StartInterProcessDma"}, | ||
| 151 | {0x56, NULL, "StopDma"}, | ||
| 152 | {0x57, NULL, "GetDmaState"}, | ||
| 153 | {0x58, NULL, "RestartDma"}, | ||
| 154 | {0x59, NULL, "Unknown"}, | ||
| 155 | {0x5A, NULL, "Unknown"}, | ||
| 156 | {0x5B, NULL, "Unknown"}, | ||
| 157 | {0x5C, NULL, "Unknown"}, | ||
| 158 | {0x5D, NULL, "Unknown"}, | ||
| 159 | {0x5E, NULL, "Unknown"}, | ||
| 160 | {0x5F, NULL, "Unknown"}, | ||
| 161 | {0x60, NULL, "DebugActiveProcess"}, | ||
| 162 | {0x61, NULL, "BreakDebugProcess"}, | ||
| 163 | {0x62, NULL, "TerminateDebugProcess"}, | ||
| 164 | {0x63, NULL, "GetProcessDebugEvent"}, | ||
| 165 | {0x64, NULL, "ContinueDebugEvent"}, | ||
| 166 | {0x65, NULL, "GetProcessList"}, | ||
| 167 | {0x66, NULL, "GetThreadList"}, | ||
| 168 | {0x67, NULL, "GetDebugThreadContext"}, | ||
| 169 | {0x68, NULL, "SetDebugThreadContext"}, | ||
| 170 | {0x69, NULL, "QueryDebugProcessMemory"}, | ||
| 171 | {0x6A, NULL, "ReadProcessMemory"}, | ||
| 172 | {0x6B, NULL, "WriteProcessMemory"}, | ||
| 173 | {0x6C, NULL, "SetHardwareBreakPoint"}, | ||
| 174 | {0x6D, NULL, "GetDebugThreadParam"}, | ||
| 175 | {0x6E, NULL, "Unknown"}, | ||
| 176 | {0x6F, NULL, "Unknown"}, | ||
| 177 | {0x70, NULL, "ControlProcessMemory"}, | ||
| 178 | {0x71, NULL, "MapProcessMemory"}, | ||
| 179 | {0x72, NULL, "UnmapProcessMemory"}, | ||
| 180 | {0x73, NULL, "Unknown"}, | ||
| 181 | {0x74, NULL, "Unknown"}, | ||
| 182 | {0x75, NULL, "Unknown"}, | ||
| 183 | {0x76, NULL, "TerminateProcess"}, | ||
| 184 | {0x77, NULL, "Unknown"}, | ||
| 185 | {0x78, NULL, "CreateResourceLimit"}, | ||
| 186 | {0x79, NULL, "Unknown"}, | ||
| 187 | {0x7A, NULL, "Unknown"}, | ||
| 188 | {0x7B, NULL, "Unknown"}, | ||
| 189 | {0x7C, NULL, "KernelSetState"}, | ||
| 190 | {0x7D, NULL, "QueryProcessMemory"}, | ||
| 191 | }; | ||
| 192 | |||
| 193 | void Register() { | ||
| 194 | HLE::RegisterModule("SyscallTable", ARRAY_SIZE(Syscall_Table), Syscall_Table); | ||
| 195 | } | ||
| 196 | |||
| 197 | } // namespace | ||
diff --git a/src/core/hle/syscall.h b/src/core/hle/syscall.h new file mode 100644 index 000000000..7a94e0136 --- /dev/null +++ b/src/core/hle/syscall.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace Syscall | ||
| 11 | |||
| 12 | namespace Syscall { | ||
| 13 | |||
| 14 | typedef u32 Handle; | ||
| 15 | typedef s32 Result; | ||
| 16 | |||
| 17 | void Register(); | ||
| 18 | |||
| 19 | } // namespace | ||