From 6e3626236930252f5fc8aef57e0f9a6e1d68964c Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Tue, 26 Jun 2018 13:37:51 +0900 Subject: [PATCH] Build from scratch to use latest libnx --- README.md | 2 + libnx.nimble | 5 +- libnxGen.cfg | 9 +- nim.cfg | 4 + src/libnx/wrapper/acc.nim | 43 - src/libnx/wrapper/apm.nim | 12 - src/libnx/wrapper/applet.nim | 54 - src/libnx/wrapper/audin.nim | 56 - src/libnx/wrapper/audio.nim | 9 - src/libnx/wrapper/audout.nim | 56 - src/libnx/wrapper/binder.nim | 32 - src/libnx/wrapper/buffer_producer.nim | 135 -- src/libnx/wrapper/cache.nim | 12 - src/libnx/wrapper/condvar.nim | 73 -- src/libnx/wrapper/console.nim | 52 - src/libnx/wrapper/csrng.nim | 9 - src/libnx/wrapper/detect.nim | 14 - src/libnx/wrapper/env.nim | 56 - src/libnx/wrapper/fatal.nim | 13 - src/libnx/wrapper/fs.nim | 172 --- src/libnx/wrapper/fs_dev.nim | 29 - src/libnx/wrapper/fsldr.nim | 15 - src/libnx/wrapper/fspr.nim | 19 - src/libnx/wrapper/gfx.nim | 124 -- src/libnx/wrapper/hid.nim | 508 -------- src/libnx/wrapper/ioctl.nim | 64 - src/libnx/wrapper/ipc.nim | 348 ----- src/libnx/wrapper/irs.nim | 71 - src/libnx/wrapper/jit.nim | 29 - src/libnx/wrapper/ldr.nim | 57 - src/libnx/wrapper/lock.nim | 33 - src/libnx/wrapper/lr.nim | 52 - src/libnx/wrapper/mutex.nim | 26 - src/libnx/wrapper/nacp.nim | 38 - src/libnx/wrapper/nifm.nim | 12 - src/libnx/wrapper/nim.cfg | 2 - src/libnx/wrapper/nro.nim | 40 - src/libnx/wrapper/ns.nim | 36 - src/libnx/wrapper/nv.nim | 22 - src/libnx/wrapper/nvgfx.nim | 13 - src/libnx/wrapper/nvioctl.nim | 138 -- src/libnx/wrapper/nx/include/switch.h | 84 -- .../wrapper/nx/include/switch/arm/atomics.h | 17 - .../wrapper/nx/include/switch/arm/cache.h | 41 - src/libnx/wrapper/nx/include/switch/arm/tls.h | 18 - .../wrapper/nx/include/switch/audio/audio.h | 19 - .../wrapper/nx/include/switch/gfx/binder.h | 29 - .../nx/include/switch/gfx/buffer_producer.h | 151 --- src/libnx/wrapper/nx/include/switch/gfx/gfx.h | 117 -- .../wrapper/nx/include/switch/gfx/ioctl.h | 47 - .../wrapper/nx/include/switch/gfx/nvgfx.h | 8 - .../wrapper/nx/include/switch/gfx/nvioctl.h | 110 -- .../wrapper/nx/include/switch/gfx/parcel.h | 31 - .../nx/include/switch/kernel/condvar.h | 69 - .../wrapper/nx/include/switch/kernel/detect.h | 19 - .../wrapper/nx/include/switch/kernel/ipc.h | 674 ---------- .../wrapper/nx/include/switch/kernel/jit.h | 68 - .../wrapper/nx/include/switch/kernel/mutex.h | 74 -- .../wrapper/nx/include/switch/kernel/random.h | 21 - .../wrapper/nx/include/switch/kernel/rwlock.h | 39 - .../wrapper/nx/include/switch/kernel/shmem.h | 67 - .../wrapper/nx/include/switch/kernel/svc.h | 1077 --------------- .../wrapper/nx/include/switch/kernel/thread.h | 67 - .../wrapper/nx/include/switch/kernel/tmem.h | 70 - .../nx/include/switch/kernel/virtmem.h | 36 - src/libnx/wrapper/nx/include/switch/nacp.h | 51 - src/libnx/wrapper/nx/include/switch/nro.h | 54 - src/libnx/wrapper/nx/include/switch/result.h | 100 -- .../include/switch/runtime/devices/console.h | 167 --- .../include/switch/runtime/devices/fs_dev.h | 43 - .../switch/runtime/devices/romfs_dev.h | 98 -- .../include/switch/runtime/devices/socket.h | 39 - .../switch/runtime/devices/usb_comms.h | 31 - .../wrapper/nx/include/switch/runtime/env.h | 90 -- .../nx/include/switch/runtime/nxlink.h | 10 - .../nx/include/switch/runtime/util/utf.h | 157 --- .../wrapper/nx/include/switch/services/acc.h | 52 - .../wrapper/nx/include/switch/services/apm.h | 16 - .../nx/include/switch/services/applet.h | 88 -- .../nx/include/switch/services/audin.h | 60 - .../nx/include/switch/services/audout.h | 60 - .../wrapper/nx/include/switch/services/bsd.h | 77 -- .../nx/include/switch/services/csrng.h | 13 - .../nx/include/switch/services/fatal.h | 29 - .../wrapper/nx/include/switch/services/fs.h | 213 --- .../nx/include/switch/services/fsldr.h | 17 - .../wrapper/nx/include/switch/services/fspr.h | 18 - .../wrapper/nx/include/switch/services/hid.h | 627 --------- .../wrapper/nx/include/switch/services/irs.h | 86 -- .../wrapper/nx/include/switch/services/ldr.h | 50 - .../wrapper/nx/include/switch/services/lr.h | 41 - .../wrapper/nx/include/switch/services/nifm.h | 18 - .../wrapper/nx/include/switch/services/ns.h | 47 - .../wrapper/nx/include/switch/services/nv.h | 26 - .../wrapper/nx/include/switch/services/pl.h | 37 - .../wrapper/nx/include/switch/services/pm.h | 30 - .../wrapper/nx/include/switch/services/set.h | 133 -- .../nx/include/switch/services/sfdnsres.h | 48 - .../wrapper/nx/include/switch/services/sm.h | 228 ---- .../wrapper/nx/include/switch/services/smm.h | 16 - .../wrapper/nx/include/switch/services/spl.h | 90 -- .../wrapper/nx/include/switch/services/time.h | 33 - .../wrapper/nx/include/switch/services/usb.h | 190 --- .../wrapper/nx/include/switch/services/vi.h | 60 - src/libnx/wrapper/nx/include/switch/types.h | 69 - src/libnx/wrapper/nxlink.nim | 14 - src/libnx/wrapper/parcel.nim | 41 - src/libnx/wrapper/pl.nim | 27 - src/libnx/wrapper/pm.nim | 30 - src/libnx/wrapper/random.nim | 7 - src/libnx/wrapper/result.nim | 116 -- src/libnx/wrapper/romfs_dev.nim | 101 -- src/libnx/wrapper/rwlock.nim | 19 - src/libnx/wrapper/set.nim | 69 - src/libnx/wrapper/shmem.nim | 80 -- src/libnx/wrapper/sm.nim | 206 --- src/libnx/wrapper/smm.nim | 14 - src/libnx/wrapper/socket.nim | 31 - src/libnx/wrapper/spl.nim | 125 -- src/libnx/wrapper/svc.nim | 1150 ----------------- src/libnx/wrapper/switch.nim | 62 - src/libnx/wrapper/thread.nim | 25 - src/libnx/wrapper/time.nim | 22 - src/libnx/wrapper/tls.nim | 19 - src/libnx/wrapper/tmem.nim | 28 - src/libnx/wrapper/types.nim | 39 - src/libnx/wrapper/usb.nim | 166 --- src/libnx/wrapper/usb_comms.nim | 20 - src/libnx/wrapper/utf.nim | 24 - src/libnx/wrapper/vi.nim | 61 - src/libnx/wrapper/virtmem.nim | 12 - 131 files changed, 15 insertions(+), 11252 deletions(-) create mode 100644 nim.cfg delete mode 100644 src/libnx/wrapper/acc.nim delete mode 100644 src/libnx/wrapper/apm.nim delete mode 100644 src/libnx/wrapper/applet.nim delete mode 100644 src/libnx/wrapper/audin.nim delete mode 100644 src/libnx/wrapper/audio.nim delete mode 100644 src/libnx/wrapper/audout.nim delete mode 100644 src/libnx/wrapper/binder.nim delete mode 100644 src/libnx/wrapper/buffer_producer.nim delete mode 100644 src/libnx/wrapper/cache.nim delete mode 100644 src/libnx/wrapper/condvar.nim delete mode 100644 src/libnx/wrapper/console.nim delete mode 100644 src/libnx/wrapper/csrng.nim delete mode 100644 src/libnx/wrapper/detect.nim delete mode 100644 src/libnx/wrapper/env.nim delete mode 100644 src/libnx/wrapper/fatal.nim delete mode 100644 src/libnx/wrapper/fs.nim delete mode 100644 src/libnx/wrapper/fs_dev.nim delete mode 100644 src/libnx/wrapper/fsldr.nim delete mode 100644 src/libnx/wrapper/fspr.nim delete mode 100644 src/libnx/wrapper/gfx.nim delete mode 100644 src/libnx/wrapper/hid.nim delete mode 100644 src/libnx/wrapper/ioctl.nim delete mode 100644 src/libnx/wrapper/ipc.nim delete mode 100644 src/libnx/wrapper/irs.nim delete mode 100644 src/libnx/wrapper/jit.nim delete mode 100644 src/libnx/wrapper/ldr.nim delete mode 100644 src/libnx/wrapper/lock.nim delete mode 100644 src/libnx/wrapper/lr.nim delete mode 100644 src/libnx/wrapper/mutex.nim delete mode 100644 src/libnx/wrapper/nacp.nim delete mode 100644 src/libnx/wrapper/nifm.nim delete mode 100644 src/libnx/wrapper/nim.cfg delete mode 100644 src/libnx/wrapper/nro.nim delete mode 100644 src/libnx/wrapper/ns.nim delete mode 100644 src/libnx/wrapper/nv.nim delete mode 100644 src/libnx/wrapper/nvgfx.nim delete mode 100644 src/libnx/wrapper/nvioctl.nim delete mode 100644 src/libnx/wrapper/nx/include/switch.h delete mode 100644 src/libnx/wrapper/nx/include/switch/arm/atomics.h delete mode 100644 src/libnx/wrapper/nx/include/switch/arm/cache.h delete mode 100644 src/libnx/wrapper/nx/include/switch/arm/tls.h delete mode 100644 src/libnx/wrapper/nx/include/switch/audio/audio.h delete mode 100644 src/libnx/wrapper/nx/include/switch/gfx/binder.h delete mode 100644 src/libnx/wrapper/nx/include/switch/gfx/buffer_producer.h delete mode 100644 src/libnx/wrapper/nx/include/switch/gfx/gfx.h delete mode 100644 src/libnx/wrapper/nx/include/switch/gfx/ioctl.h delete mode 100644 src/libnx/wrapper/nx/include/switch/gfx/nvgfx.h delete mode 100644 src/libnx/wrapper/nx/include/switch/gfx/nvioctl.h delete mode 100644 src/libnx/wrapper/nx/include/switch/gfx/parcel.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/condvar.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/detect.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/ipc.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/jit.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/mutex.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/random.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/rwlock.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/shmem.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/svc.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/thread.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/tmem.h delete mode 100644 src/libnx/wrapper/nx/include/switch/kernel/virtmem.h delete mode 100644 src/libnx/wrapper/nx/include/switch/nacp.h delete mode 100644 src/libnx/wrapper/nx/include/switch/nro.h delete mode 100644 src/libnx/wrapper/nx/include/switch/result.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/devices/console.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/devices/fs_dev.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/devices/romfs_dev.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/devices/socket.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/devices/usb_comms.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/env.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/nxlink.h delete mode 100644 src/libnx/wrapper/nx/include/switch/runtime/util/utf.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/acc.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/apm.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/applet.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/audin.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/audout.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/bsd.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/csrng.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/fatal.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/fs.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/fsldr.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/fspr.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/hid.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/irs.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/ldr.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/lr.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/nifm.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/ns.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/nv.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/pl.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/pm.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/set.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/sfdnsres.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/sm.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/smm.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/spl.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/time.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/usb.h delete mode 100644 src/libnx/wrapper/nx/include/switch/services/vi.h delete mode 100644 src/libnx/wrapper/nx/include/switch/types.h delete mode 100644 src/libnx/wrapper/nxlink.nim delete mode 100644 src/libnx/wrapper/parcel.nim delete mode 100644 src/libnx/wrapper/pl.nim delete mode 100644 src/libnx/wrapper/pm.nim delete mode 100644 src/libnx/wrapper/random.nim delete mode 100644 src/libnx/wrapper/result.nim delete mode 100644 src/libnx/wrapper/romfs_dev.nim delete mode 100644 src/libnx/wrapper/rwlock.nim delete mode 100644 src/libnx/wrapper/set.nim delete mode 100644 src/libnx/wrapper/shmem.nim delete mode 100644 src/libnx/wrapper/sm.nim delete mode 100644 src/libnx/wrapper/smm.nim delete mode 100644 src/libnx/wrapper/socket.nim delete mode 100644 src/libnx/wrapper/spl.nim delete mode 100644 src/libnx/wrapper/svc.nim delete mode 100644 src/libnx/wrapper/switch.nim delete mode 100644 src/libnx/wrapper/thread.nim delete mode 100644 src/libnx/wrapper/time.nim delete mode 100644 src/libnx/wrapper/tls.nim delete mode 100644 src/libnx/wrapper/tmem.nim delete mode 100644 src/libnx/wrapper/types.nim delete mode 100644 src/libnx/wrapper/usb.nim delete mode 100644 src/libnx/wrapper/usb_comms.nim delete mode 100644 src/libnx/wrapper/utf.nim delete mode 100644 src/libnx/wrapper/vi.nim delete mode 100644 src/libnx/wrapper/virtmem.nim diff --git a/README.md b/README.md index d9a115d..dc05a29 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ You also must have DevkitPro and switch (libnx) libraries for [Mac and Linux](ht Simply run ```bash +# Because of a bug in nimble right now, you must install this first! +nimble install "https://github.com/jyapayne/nimgenEx#head" nimble install ``` diff --git a/libnx.nimble b/libnx.nimble index 6e16a60..683be4a 100644 --- a/libnx.nimble +++ b/libnx.nimble @@ -12,14 +12,15 @@ requires "nim >= 0.18.1", "https://github.com/jyapayne/nimgenEx#head" requires "https://github.com/jyapayne/switch-build#head" task setup, "Download and generate bindings": + echo "Building libnx..." exec "nimgen libnxGen.cfg" task buildExamples, "Build switch examples": exec "switch_build --author='jyapayne' --version='1.0.0' examples/helloworld/helloworld.nim" exec "switch_build --author='jyapayne' --version='1.0.0' examples/accounts/account_ex.nim" -#before install: -# setupTask() +before install: + setupTask() task test, "Run tests": exec "nim c -r tests/test.nim" diff --git a/libnxGen.cfg b/libnxGen.cfg index 614b47c..1880157 100644 --- a/libnxGen.cfg +++ b/libnxGen.cfg @@ -22,9 +22,12 @@ filter=lock "${output}/nim.cfg" [n.prepare] -gitremote = "https://github.com/switchbrew/libnx" -gitsparse = """ -nx/include/* +git = "https://github.com/switchbrew/libnx" +execute = """ +cd ${output} +# for listing users +curl https://patch-diff.githubusercontent.com/raw/switchbrew/libnx/pull/103.patch | git am +make """ [n.after] diff --git a/nim.cfg b/nim.cfg new file mode 100644 index 0000000..fa3db33 --- /dev/null +++ b/nim.cfg @@ -0,0 +1,4 @@ +--passC="-I$PWD/src/libnx/wrapper/nx/include" +--passL="-specs=$PWD/src/libnx/wrapper/nx/switch.specs -L$PWD/src/libnx/wrapper/nx/lib -lnx" +#--passC="-I$DEVKITPRO/libnx/include" +#--passL="-specs=$DEVKITPRO/libnx/switch.specs -L$DEVKITPRO/libnx/lib -lnx" diff --git a/src/libnx/wrapper/acc.nim b/src/libnx/wrapper/acc.nim deleted file mode 100644 index dde671f..0000000 --- a/src/libnx/wrapper/acc.nim +++ /dev/null @@ -1,43 +0,0 @@ -import strutils -import ospaths -const headeracc = currentSourcePath().splitPath().head & "/nx/include/switch/services/acc.h" -import libnx/ext/integer128 -import libnx/wrapper/types -import libnx/wrapper/sm -type - AccountProfile* {.importc: "AccountProfile", header: headeracc, bycopy.} = object - s* {.importc: "s".}: Service - - AccountUserData* {.importc: "AccountUserData", header: headeracc, bycopy.} = object - unk_x0* {.importc: "unk_x0".}: uint32 - iconID* {.importc: "iconID".}: uint32 - iconBackgroundColorID* {.importc: "iconBackgroundColorID".}: uint8 - unk_x9* {.importc: "unk_x9".}: array[0x00000007, uint8] - miiID* {.importc: "miiID".}: array[0x00000010, uint8] - unk_x20* {.importc: "unk_x20".}: array[0x00000060, uint8] - - AccountProfileBase* {.importc: "AccountProfileBase", header: headeracc, bycopy.} = object - userID* {.importc: "userID".}: u128 - lastEditTimestamp* {.importc: "lastEditTimestamp".}: uint64 - username* {.importc: "username".}: array[0x00000020, char] - - -proc accountInitialize*(): Result {.cdecl, importc: "accountInitialize", - header: headeracc.} -proc accountExit*() {.cdecl, importc: "accountExit", header: headeracc.} -proc accountGetService*(): ptr Service {.cdecl, importc: "accountGetService", - header: headeracc.} -proc accountGetActiveUser*(userID: ptr u128; account_selected: ptr bool): Result {. - cdecl, importc: "accountGetActiveUser", header: headeracc.} -proc accountGetProfile*(`out`: ptr AccountProfile; userID: u128): Result {.cdecl, - importc: "accountGetProfile", header: headeracc.} -proc accountProfileGet*(profile: ptr AccountProfile; userdata: ptr AccountUserData; - profilebase: ptr AccountProfileBase): Result {.cdecl, - importc: "accountProfileGet", header: headeracc.} -proc accountProfileGetImageSize*(profile: ptr AccountProfile; image_size: ptr csize): Result {. - cdecl, importc: "accountProfileGetImageSize", header: headeracc.} -proc accountProfileLoadImage*(profile: ptr AccountProfile; buf: pointer; len: csize; - image_size: ptr csize): Result {.cdecl, - importc: "accountProfileLoadImage", header: headeracc.} -proc accountProfileClose*(profile: ptr AccountProfile) {.cdecl, - importc: "accountProfileClose", header: headeracc.} \ No newline at end of file diff --git a/src/libnx/wrapper/apm.nim b/src/libnx/wrapper/apm.nim deleted file mode 100644 index c343872..0000000 --- a/src/libnx/wrapper/apm.nim +++ /dev/null @@ -1,12 +0,0 @@ -import strutils -import ospaths -const headerapm = currentSourcePath().splitPath().head & "/nx/include/switch/services/apm.h" -import libnx/wrapper/types -proc apmInitialize*(): Result {.cdecl, importc: "apmInitialize", header: headerapm.} -proc apmExit*() {.cdecl, importc: "apmExit", header: headerapm.} -proc apmSetPerformanceConfiguration*(PerformanceMode: uint32; - PerformanceConfiguration: uint32): Result {. - cdecl, importc: "apmSetPerformanceConfiguration", header: headerapm.} -proc apmGetPerformanceConfiguration*(PerformanceMode: uint32; - PerformanceConfiguration: ptr uint32): Result {. - cdecl, importc: "apmGetPerformanceConfiguration", header: headerapm.} \ No newline at end of file diff --git a/src/libnx/wrapper/applet.nim b/src/libnx/wrapper/applet.nim deleted file mode 100644 index 1a09362..0000000 --- a/src/libnx/wrapper/applet.nim +++ /dev/null @@ -1,54 +0,0 @@ -import strutils -import ospaths -const headerapplet = currentSourcePath().splitPath().head & "/nx/include/switch/services/applet.h" -import libnx/wrapper/types -type - AppletType* {.size: sizeof(cint).} = enum - AppletType_None = -2, AppletType_Default = -1, AppletType_Application = 0, - AppletType_SystemApplet = 1, AppletType_LibraryApplet = 2, - AppletType_OverlayApplet = 3, AppletType_SystemApplication = 4 - AppletOperationMode* {.size: sizeof(cint).} = enum - AppletOperationMode_Handheld = 0, AppletOperationMode_Docked = 1 - AppletHookType* {.size: sizeof(cint).} = enum - AppletHookType_OnFocusState = 0, AppletHookType_OnOperationMode, - AppletHookType_OnPerformanceMode, AppletHookType_Max - AppletHookFn* = proc (hook: AppletHookType; param: pointer) {.cdecl.} - - - - -type - AppletHookCookie* {.importc: "AppletHookCookie", header: headerapplet, bycopy.} = object - next* {.importc: "next".}: ptr AppletHookCookie - callback* {.importc: "callback".}: AppletHookFn - param* {.importc: "param".}: pointer - - -proc appletInitialize*(): Result {.cdecl, importc: "appletInitialize", - header: headerapplet.} -proc appletExit*() {.cdecl, importc: "appletExit", header: headerapplet.} -proc appletGetAppletResourceUserId*(`out`: ptr uint64): Result {.cdecl, - importc: "appletGetAppletResourceUserId", header: headerapplet.} -proc appletNotifyRunning*(`out`: ptr uint8) {.cdecl, importc: "appletNotifyRunning", - header: headerapplet.} -proc appletCreateManagedDisplayLayer*(`out`: ptr uint64): Result {.cdecl, - importc: "appletCreateManagedDisplayLayer", header: headerapplet.} -proc appletGetDesiredLanguage*(LanguageCode: ptr uint64): Result {.cdecl, - importc: "appletGetDesiredLanguage", header: headerapplet.} -proc appletSetScreenShotPermission*(val: s32): Result {.cdecl, - importc: "appletSetScreenShotPermission", header: headerapplet.} -proc appletSetScreenShotImageOrientation*(val: s32): Result {.cdecl, - importc: "appletSetScreenShotImageOrientation", header: headerapplet.} -proc appletMainLoop*(): bool {.cdecl, importc: "appletMainLoop", - header: headerapplet.} -proc appletHook*(cookie: ptr AppletHookCookie; callback: AppletHookFn; param: pointer) {. - cdecl, importc: "appletHook", header: headerapplet.} -proc appletUnhook*(cookie: ptr AppletHookCookie) {.cdecl, importc: "appletUnhook", - header: headerapplet.} -proc appletGetOperationMode*(): uint8 {.cdecl, importc: "appletGetOperationMode", - header: headerapplet.} -proc appletGetPerformanceMode*(): uint32 {.cdecl, - importc: "appletGetPerformanceMode", - header: headerapplet.} -proc appletGetFocusState*(): uint8 {.cdecl, importc: "appletGetFocusState", - header: headerapplet.} \ No newline at end of file diff --git a/src/libnx/wrapper/audin.nim b/src/libnx/wrapper/audin.nim deleted file mode 100644 index 1b11745..0000000 --- a/src/libnx/wrapper/audin.nim +++ /dev/null @@ -1,56 +0,0 @@ -import libnx/wrapper/types -import strutils -import ospaths -const headeraudin = currentSourcePath().splitPath().head & "/nx/include/switch/services/audin.h" -import libnx/wrapper/audio -type - AudioInState* {.size: sizeof(cint).} = enum - AudioInState_Started = 0, AudioInState_Stopped = 1 - - -type - AudioInBuffer* {.importc: "AudioInBuffer", header: headeraudin, bycopy.} = object - next* {.importc: "next".}: ptr AudioInBuffer - buffer* {.importc: "buffer".}: pointer - buffer_size* {.importc: "buffer_size".}: uint64 - data_size* {.importc: "data_size".}: uint64 - data_offset* {.importc: "data_offset".}: uint64 - - -proc audinInitialize*(): Result {.cdecl, importc: "audinInitialize", - header: headeraudin.} -proc audinExit*() {.cdecl, importc: "audinExit", header: headeraudin.} -proc audinListAudioIns*(DeviceNames: cstring; DeviceNamesCount: ptr uint32): Result {. - cdecl, importc: "audinListAudioIns", header: headeraudin.} -proc audinOpenAudioIn*(DeviceNameIn: cstring; DeviceNameOut: cstring; - SampleRateIn: uint32; ChannelCountIn: uint32; - SampleRateOut: ptr uint32; ChannelCountOut: ptr uint32; - Format: ptr PcmFormat; State: ptr AudioInState): Result {. - cdecl, importc: "audinOpenAudioIn", header: headeraudin.} -proc audinGetAudioInState*(State: ptr AudioInState): Result {.cdecl, - importc: "audinGetAudioInState", header: headeraudin.} -proc audinStartAudioIn*(): Result {.cdecl, importc: "audinStartAudioIn", - header: headeraudin.} -proc audinStopAudioIn*(): Result {.cdecl, importc: "audinStopAudioIn", - header: headeraudin.} -proc audinAppendAudioInBuffer*(Buffer: ptr AudioInBuffer): Result {.cdecl, - importc: "audinAppendAudioInBuffer", header: headeraudin.} -proc audinGetReleasedAudioInBuffer*(Buffer: ptr ptr AudioInBuffer; - ReleasedBuffersCount: ptr uint32): Result {.cdecl, - importc: "audinGetReleasedAudioInBuffer", header: headeraudin.} -proc audinContainsAudioInBuffer*(Buffer: ptr AudioInBuffer; - ContainsBuffer: ptr bool): Result {.cdecl, - importc: "audinContainsAudioInBuffer", header: headeraudin.} -proc audinCaptureBuffer*(source: ptr AudioInBuffer; released: ptr ptr AudioInBuffer): Result {. - cdecl, importc: "audinCaptureBuffer", header: headeraudin.} -proc audinWaitCaptureFinish*(released: ptr ptr AudioInBuffer; - released_count: ptr uint32; timeout: uint64): Result {.cdecl, - importc: "audinWaitCaptureFinish", header: headeraudin.} -proc audinGetSampleRate*(): uint32 {.cdecl, importc: "audinGetSampleRate", - header: headeraudin.} -proc audinGetChannelCount*(): uint32 {.cdecl, importc: "audinGetChannelCount", - header: headeraudin.} -proc audinGetPcmFormat*(): PcmFormat {.cdecl, importc: "audinGetPcmFormat", - header: headeraudin.} -proc audinGetDeviceState*(): AudioInState {.cdecl, importc: "audinGetDeviceState", - header: headeraudin.} \ No newline at end of file diff --git a/src/libnx/wrapper/audio.nim b/src/libnx/wrapper/audio.nim deleted file mode 100644 index 1177fd5..0000000 --- a/src/libnx/wrapper/audio.nim +++ /dev/null @@ -1,9 +0,0 @@ -import strutils -import ospaths -const headeraudio = currentSourcePath().splitPath().head & "/nx/include/switch/audio/audio.h" -import libnx/wrapper/types -type - PcmFormat* {.size: sizeof(cint).} = enum - PcmFormat_Invalid = 0, PcmFormat_Int8 = 1, PcmFormat_Int16 = 2, PcmFormat_Int24 = 3, - PcmFormat_Int32 = 4, PcmFormat_Float = 5, PcmFormat_Adpcm = 6 - diff --git a/src/libnx/wrapper/audout.nim b/src/libnx/wrapper/audout.nim deleted file mode 100644 index 91c3934..0000000 --- a/src/libnx/wrapper/audout.nim +++ /dev/null @@ -1,56 +0,0 @@ -import libnx/wrapper/types -import strutils -import ospaths -const headeraudout = currentSourcePath().splitPath().head & "/nx/include/switch/services/audout.h" -import libnx/wrapper/audio -type - AudioOutState* {.size: sizeof(cint).} = enum - AudioOutState_Started = 0, AudioOutState_Stopped = 1 - - -type - AudioOutBuffer* {.importc: "AudioOutBuffer", header: headeraudout, bycopy.} = object - next* {.importc: "next".}: ptr AudioOutBuffer - buffer* {.importc: "buffer".}: pointer - buffer_size* {.importc: "buffer_size".}: uint64 - data_size* {.importc: "data_size".}: uint64 - data_offset* {.importc: "data_offset".}: uint64 - - -proc audoutInitialize*(): Result {.cdecl, importc: "audoutInitialize", - header: headeraudout.} -proc audoutExit*() {.cdecl, importc: "audoutExit", header: headeraudout.} -proc audoutListAudioOuts*(DeviceNames: cstring; DeviceNamesCount: ptr uint32): Result {. - cdecl, importc: "audoutListAudioOuts", header: headeraudout.} -proc audoutOpenAudioOut*(DeviceNameIn: cstring; DeviceNameOut: cstring; - SampleRateIn: uint32; ChannelCountIn: uint32; - SampleRateOut: ptr uint32; ChannelCountOut: ptr uint32; - Format: ptr PcmFormat; State: ptr AudioOutState): Result {. - cdecl, importc: "audoutOpenAudioOut", header: headeraudout.} -proc audoutGetAudioOutState*(State: ptr AudioOutState): Result {.cdecl, - importc: "audoutGetAudioOutState", header: headeraudout.} -proc audoutStartAudioOut*(): Result {.cdecl, importc: "audoutStartAudioOut", - header: headeraudout.} -proc audoutStopAudioOut*(): Result {.cdecl, importc: "audoutStopAudioOut", - header: headeraudout.} -proc audoutAppendAudioOutBuffer*(Buffer: ptr AudioOutBuffer): Result {.cdecl, - importc: "audoutAppendAudioOutBuffer", header: headeraudout.} -proc audoutGetReleasedAudioOutBuffer*(Buffer: ptr ptr AudioOutBuffer; - ReleasedBuffersCount: ptr uint32): Result {. - cdecl, importc: "audoutGetReleasedAudioOutBuffer", header: headeraudout.} -proc audoutContainsAudioOutBuffer*(Buffer: ptr AudioOutBuffer; - ContainsBuffer: ptr bool): Result {.cdecl, - importc: "audoutContainsAudioOutBuffer", header: headeraudout.} -proc audoutPlayBuffer*(source: ptr AudioOutBuffer; released: ptr ptr AudioOutBuffer): Result {. - cdecl, importc: "audoutPlayBuffer", header: headeraudout.} -proc audoutWaitPlayFinish*(released: ptr ptr AudioOutBuffer; released_count: ptr uint32; - timeout: uint64): Result {.cdecl, - importc: "audoutWaitPlayFinish", header: headeraudout.} -proc audoutGetSampleRate*(): uint32 {.cdecl, importc: "audoutGetSampleRate", - header: headeraudout.} -proc audoutGetChannelCount*(): uint32 {.cdecl, importc: "audoutGetChannelCount", - header: headeraudout.} -proc audoutGetPcmFormat*(): PcmFormat {.cdecl, importc: "audoutGetPcmFormat", - header: headeraudout.} -proc audoutGetDeviceState*(): AudioOutState {.cdecl, - importc: "audoutGetDeviceState", header: headeraudout.} \ No newline at end of file diff --git a/src/libnx/wrapper/binder.nim b/src/libnx/wrapper/binder.nim deleted file mode 100644 index 4e4fea2..0000000 --- a/src/libnx/wrapper/binder.nim +++ /dev/null @@ -1,32 +0,0 @@ -import strutils -import ospaths -const headerbinder = currentSourcePath().splitPath().head & "/nx/include/switch/gfx/binder.h" -import libnx/wrapper/types -const - BINDER_FIRST_CALL_TRANSACTION* = 0x00000001 - -type - Binder* {.importc: "Binder", header: headerbinder, bycopy.} = object - created* {.importc: "created".}: bool - initialized* {.importc: "initialized".}: bool - sessionHandle* {.importc: "sessionHandle".}: Handle - id* {.importc: "id".}: s32 - nativeHandle* {.importc: "nativeHandle".}: Handle - ipcBufferSize* {.importc: "ipcBufferSize".}: csize - hasTransactAuto* {.importc: "hasTransactAuto".}: bool - - -proc binderCreateSession*(session: ptr Binder; sessionHandle: Handle; ID: s32) {. - cdecl, importc: "binderCreateSession", header: headerbinder.} -proc binderInitSession*(session: ptr Binder; unk0: uint32): Result {.cdecl, - importc: "binderInitSession", header: headerbinder.} -proc binderExitSession*(session: ptr Binder) {.cdecl, importc: "binderExitSession", - header: headerbinder.} -proc binderTransactParcel*(session: ptr Binder; code: uint32; parcel_data: pointer; - parcel_data_size: csize; parcel_reply: pointer; - parcel_reply_size: csize; flags: uint32): Result {.cdecl, - importc: "binderTransactParcel", header: headerbinder.} -proc binderAdjustRefcount*(session: ptr Binder; addval: s32; `type`: s32): Result {. - cdecl, importc: "binderAdjustRefcount", header: headerbinder.} -proc binderGetNativeHandle*(session: ptr Binder; unk0: uint32; handle_out: ptr Handle): Result {. - cdecl, importc: "binderGetNativeHandle", header: headerbinder.} \ No newline at end of file diff --git a/src/libnx/wrapper/buffer_producer.nim b/src/libnx/wrapper/buffer_producer.nim deleted file mode 100644 index 9db053c..0000000 --- a/src/libnx/wrapper/buffer_producer.nim +++ /dev/null @@ -1,135 +0,0 @@ -import strutils -import ospaths -const headerbuffer_producer = currentSourcePath().splitPath().head & "/nx/include/switch/gfx/buffer_producer.h" -import libnx/wrapper/types -import libnx/wrapper/binder -import libnx/wrapper/nvioctl -type - INNER_C_STRUCT_3208597589* {.importc: "no_name", header: headerbuffer_producer, - bycopy.} = object - unk_x0* {.importc: "unk_x0".}: uint32 - nvmap_handle0* {.importc: "nvmap_handle0".}: uint32 - unk_x8* {.importc: "unk_x8".}: uint32 - unk_xc* {.importc: "unk_xc".}: uint32 - unk_x10* {.importc: "unk_x10".}: uint32 - unk_x14* {.importc: "unk_x14".}: uint32 - unk_x18* {.importc: "unk_x18".}: uint32 - unk_x1c* {.importc: "unk_x1c".}: uint32 - unk_x20* {.importc: "unk_x20".}: uint32 - width_unk0* {.importc: "width_unk0".}: uint32 - buffer_size0* {.importc: "buffer_size0".}: uint32 - unk_x2c* {.importc: "unk_x2c".}: uint32 - unk_x30* {.importc: "unk_x30".}: uint32 - width_unk1* {.importc: "width_unk1".}: uint32 - height_unk* {.importc: "height_unk".}: uint32 - flags* {.importc: "flags".}: uint32 - unk_x40* {.importc: "unk_x40".}: uint32 - unk_x44* {.importc: "unk_x44".}: uint32 - byte_stride* {.importc: "byte_stride".}: uint32 - nvmap_handle1* {.importc: "nvmap_handle1".}: uint32 - buffer_offset* {.importc: "buffer_offset".}: uint32 - unk_x54* {.importc: "unk_x54".}: uint32 - unk_x58* {.importc: "unk_x58".}: uint32 - unk_x5c* {.importc: "unk_x5c".}: uint32 - unk_x60* {.importc: "unk_x60".}: uint32 - unk_x64* {.importc: "unk_x64".}: uint32 - unk_x68* {.importc: "unk_x68".}: uint32 - buffer_size1* {.importc: "buffer_size1".}: uint32 - unk_x70* {.importc: "unk_x70".}: array[0x00000033, uint32] - timestamp* {.importc: "timestamp".}: uint64 - - bufferProducerFence* {.importc: "bufferProducerFence", - header: headerbuffer_producer, bycopy.} = object - is_valid* {.importc: "is_valid".}: uint32 - nv_fences* {.importc: "nv_fences".}: array[4, nvioctl_fence] - - bufferProducerRect* {.importc: "bufferProducerRect", - header: headerbuffer_producer, bycopy.} = object - left* {.importc: "left".}: s32 - top* {.importc: "top".}: s32 - right* {.importc: "right".}: s32 - bottom* {.importc: "bottom".}: s32 - - bufferProducerQueueBufferInput* {.importc: "bufferProducerQueueBufferInput", - header: headerbuffer_producer, bycopy.} = object - timestamp* {.importc: "timestamp".}: s64 - isAutoTimestamp* {.importc: "isAutoTimestamp".}: s32 - crop* {.importc: "crop".}: bufferProducerRect - scalingMode* {.importc: "scalingMode".}: s32 - transform* {.importc: "transform".}: uint32 - stickyTransform* {.importc: "stickyTransform".}: uint32 - unk* {.importc: "unk".}: array[2, uint32] - fence* {.importc: "fence".}: bufferProducerFence - - bufferProducerQueueBufferOutput* {.importc: "bufferProducerQueueBufferOutput", - header: headerbuffer_producer, bycopy.} = object - width* {.importc: "width".}: uint32 - height* {.importc: "height".}: uint32 - transformHint* {.importc: "transformHint".}: uint32 - numPendingBuffers* {.importc: "numPendingBuffers".}: uint32 - - bufferProducerGraphicBuffer* {.importc: "bufferProducerGraphicBuffer", - header: headerbuffer_producer, bycopy.} = object - magic* {.importc: "magic".}: uint32 - width* {.importc: "width".}: uint32 - height* {.importc: "height".}: uint32 - stride* {.importc: "stride".}: uint32 - format* {.importc: "format".}: uint32 - usage* {.importc: "usage".}: uint32 - pid* {.importc: "pid".}: uint32 - refcount* {.importc: "refcount".}: uint32 - numFds* {.importc: "numFds".}: uint32 - numInts* {.importc: "numInts".}: uint32 - data* {.importc: "data".}: INNER_C_STRUCT_3208597589 - - -const - NATIVE_WINDOW_WIDTH* = 0 - NATIVE_WINDOW_HEIGHT* = 1 - NATIVE_WINDOW_FORMAT* = 2 - -const - NATIVE_WINDOW_API_CPU* = 2 - -const - HAL_TRANSFORM_FLIP_H* = 0x00000001 - HAL_TRANSFORM_FLIP_V* = 0x00000002 - HAL_TRANSFORM_ROT_90* = 0x00000004 - HAL_TRANSFORM_ROT_180* = 0x00000003 - HAL_TRANSFORM_ROT_270* = 0x00000007 - -const - NATIVE_WINDOW_TRANSFORM_FLIP_H* = HAL_TRANSFORM_FLIP_H - NATIVE_WINDOW_TRANSFORM_FLIP_V* = HAL_TRANSFORM_FLIP_V - NATIVE_WINDOW_TRANSFORM_ROT_90* = HAL_TRANSFORM_ROT_90 - NATIVE_WINDOW_TRANSFORM_ROT_180* = HAL_TRANSFORM_ROT_180 - NATIVE_WINDOW_TRANSFORM_ROT_270* = HAL_TRANSFORM_ROT_270 - -proc bufferProducerInitialize*(session: ptr Binder): Result {.cdecl, - importc: "bufferProducerInitialize", header: headerbuffer_producer.} -proc bufferProducerExit*() {.cdecl, importc: "bufferProducerExit", - header: headerbuffer_producer.} -proc bufferProducerRequestBuffer*(bufferIdx: s32; - buf: ptr bufferProducerGraphicBuffer): Result {. - cdecl, importc: "bufferProducerRequestBuffer", header: headerbuffer_producer.} -proc bufferProducerDequeueBuffer*(async: bool; width: uint32; height: uint32; format: s32; - usage: uint32; buf: ptr s32; - fence: ptr bufferProducerFence): Result {.cdecl, - importc: "bufferProducerDequeueBuffer", header: headerbuffer_producer.} -proc bufferProducerDetachBuffer*(slot: s32): Result {.cdecl, - importc: "bufferProducerDetachBuffer", header: headerbuffer_producer.} -proc bufferProducerQueueBuffer*(buf: s32; - input: ptr bufferProducerQueueBufferInput; - output: ptr bufferProducerQueueBufferOutput): Result {. - cdecl, importc: "bufferProducerQueueBuffer", header: headerbuffer_producer.} -proc bufferProducerQuery*(what: s32; value: ptr s32): Result {.cdecl, - importc: "bufferProducerQuery", header: headerbuffer_producer.} -proc bufferProducerConnect*(api: s32; producerControlledByApp: bool; - output: ptr bufferProducerQueueBufferOutput): Result {. - cdecl, importc: "bufferProducerConnect", header: headerbuffer_producer.} -proc bufferProducerDisconnect*(api: s32): Result {.cdecl, - importc: "bufferProducerDisconnect", header: headerbuffer_producer.} -proc bufferProducerGraphicBufferInit*(buf: s32; - input: ptr bufferProducerGraphicBuffer): Result {. - cdecl, importc: "bufferProducerGraphicBufferInit", - header: headerbuffer_producer.} \ No newline at end of file diff --git a/src/libnx/wrapper/cache.nim b/src/libnx/wrapper/cache.nim deleted file mode 100644 index 791a78b..0000000 --- a/src/libnx/wrapper/cache.nim +++ /dev/null @@ -1,12 +0,0 @@ -import strutils -import ospaths -const headercache = currentSourcePath().splitPath().head & "/nx/include/switch/arm/cache.h" -import libnx/wrapper/types -proc armDCacheFlush*(`addr`: pointer; size: csize) {.cdecl, - importc: "armDCacheFlush", header: headercache.} -proc armDCacheClean*(`addr`: pointer; size: csize) {.cdecl, - importc: "armDCacheClean", header: headercache.} -proc armICacheInvalidate*(`addr`: pointer; size: csize) {.cdecl, - importc: "armICacheInvalidate", header: headercache.} -proc armDCacheZero*(`addr`: pointer; size: csize) {.cdecl, importc: "armDCacheZero", - header: headercache.} \ No newline at end of file diff --git a/src/libnx/wrapper/condvar.nim b/src/libnx/wrapper/condvar.nim deleted file mode 100644 index d122e05..0000000 --- a/src/libnx/wrapper/condvar.nim +++ /dev/null @@ -1,73 +0,0 @@ -import strutils -import ospaths -const headercondvar = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/condvar.h" -## * -## @file condvar.h -## @brief Condition variable synchronization primitive. -## @author plutoo -## @copyright libnx Authors -## - -import - libnx/wrapper/types, libnx/wrapper/mutex - -## / Condition variable structure. - -type - CondVar* {.importc: "CondVar", header: headercondvar, bycopy.} = object - tag* {.importc: "tag".}: uint32 - mutex* {.importc: "mutex".}: ptr Mutex - - -## * -## @brief Initializes a condition variable. -## @param[in] c Condition variable object. -## @param[in] m Mutex object to use inside the condition variable. -## - -proc condvarInit*(c: ptr CondVar; m: ptr Mutex) {.cdecl, importc: "condvarInit", - header: headercondvar.} -## * -## @brief Waits on a condition variable with a timeout. -## @param[in] c Condition variable object. -## @param[in] timeout Timeout in nanoseconds. -## @return Result code (0xEA01 on timeout). -## @remark On function return, the underlying mutex is acquired. -## - -proc condvarWaitTimeout*(c: ptr CondVar; timeout: uint64): Result {.cdecl, - importc: "condvarWaitTimeout", header: headercondvar.} -## * -## @brief Waits on a condition variable. -## @param[in] c Condition variable object. -## @return Result code. -## @remark On function return, the underlying mutex is acquired. -## - -proc condvarWait*(c: ptr CondVar): Result {.inline, cdecl, importc: "condvarWait", - header: headercondvar.} -## * -## @brief Wakes up up to the specified number of threads waiting on a condition variable. -## @param[in] c Condition variable object. -## @param[in] num Maximum number of threads to wake up (or -1 to wake them all up). -## @return Result code. -## - -proc condvarWake*(c: ptr CondVar; num: cint): Result {.cdecl, importc: "condvarWake", - header: headercondvar.} -## * -## @brief Wakes up a single thread waiting on a condition variable. -## @param[in] c Condition variable object. -## @return Result code. -## - -proc condvarWakeOne*(c: ptr CondVar): Result {.inline, cdecl, - importc: "condvarWakeOne", header: headercondvar.} -## * -## @brief Wakes up all thread waiting on a condition variable. -## @param[in] c Condition variable object. -## @return Result code. -## - -proc condvarWakeAll*(c: ptr CondVar): Result {.inline, cdecl, - importc: "condvarWakeAll", header: headercondvar.} \ No newline at end of file diff --git a/src/libnx/wrapper/console.nim b/src/libnx/wrapper/console.nim deleted file mode 100644 index 0cd88b3..0000000 --- a/src/libnx/wrapper/console.nim +++ /dev/null @@ -1,52 +0,0 @@ -import strutils -import ospaths -const headerconsole = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/devices/console.h" -import libnx/wrapper/types -type - ConsolePrint* = proc (con: pointer; c: cint): bool {.cdecl.} - ConsoleFont* {.importc: "ConsoleFont", header: headerconsole, bycopy.} = object - gfx* {.importc: "gfx".}: ptr uint16 - asciiOffset* {.importc: "asciiOffset".}: uint16 - numChars* {.importc: "numChars".}: uint16 - - PrintConsole* {.importc: "PrintConsole", header: headerconsole, bycopy.} = object - font* {.importc: "font".}: ConsoleFont - frameBuffer* {.importc: "frameBuffer".}: ptr uint32 - frameBuffer2* {.importc: "frameBuffer2".}: ptr uint32 - cursorX* {.importc: "cursorX".}: cint - cursorY* {.importc: "cursorY".}: cint - prevCursorX* {.importc: "prevCursorX".}: cint - prevCursorY* {.importc: "prevCursorY".}: cint - consoleWidth* {.importc: "consoleWidth".}: cint - consoleHeight* {.importc: "consoleHeight".}: cint - windowX* {.importc: "windowX".}: cint - windowY* {.importc: "windowY".}: cint - windowWidth* {.importc: "windowWidth".}: cint - windowHeight* {.importc: "windowHeight".}: cint - tabSize* {.importc: "tabSize".}: cint - fg* {.importc: "fg".}: cint - bg* {.importc: "bg".}: cint - flags* {.importc: "flags".}: cint - PrintChar* {.importc: "PrintChar".}: ConsolePrint - consoleInitialised* {.importc: "consoleInitialised".}: bool - - debugDevice* {.size: sizeof(cint).} = enum - debugDevice_NULL, debugDevice_SVC, debugDevice_CONSOLE - -const - debugDevice_3DMOO = debugDevice_SVC - -proc consoleSetFont*(console: ptr PrintConsole; font: ptr ConsoleFont) {.cdecl, - importc: "consoleSetFont", header: headerconsole.} -proc consoleSetWindow*(console: ptr PrintConsole; x: cint; y: cint; width: cint; - height: cint) {.cdecl, importc: "consoleSetWindow", - header: headerconsole.} -proc consoleGetDefault*(): ptr PrintConsole {.cdecl, importc: "consoleGetDefault", - header: headerconsole.} -proc consoleSelect*(console: ptr PrintConsole): ptr PrintConsole {.cdecl, - importc: "consoleSelect", header: headerconsole.} -proc consoleInit*(console: ptr PrintConsole): ptr PrintConsole {.cdecl, - importc: "consoleInit", header: headerconsole.} -proc consoleDebugInit*(device: debugDevice) {.cdecl, importc: "consoleDebugInit", - header: headerconsole.} -proc consoleClear*() {.cdecl, importc: "consoleClear", header: headerconsole.} \ No newline at end of file diff --git a/src/libnx/wrapper/csrng.nim b/src/libnx/wrapper/csrng.nim deleted file mode 100644 index 50c9472..0000000 --- a/src/libnx/wrapper/csrng.nim +++ /dev/null @@ -1,9 +0,0 @@ -import strutils -import ospaths -const headercsrng = currentSourcePath().splitPath().head & "/nx/include/switch/services/csrng.h" -import libnx/wrapper/types -proc csrngInitialize*(): Result {.cdecl, importc: "csrngInitialize", - header: headercsrng.} -proc csrngExit*() {.cdecl, importc: "csrngExit", header: headercsrng.} -proc csrngGetRandomBytes*(`out`: pointer; out_size: csize): Result {.cdecl, - importc: "csrngGetRandomBytes", header: headercsrng.} \ No newline at end of file diff --git a/src/libnx/wrapper/detect.nim b/src/libnx/wrapper/detect.nim deleted file mode 100644 index 9470aac..0000000 --- a/src/libnx/wrapper/detect.nim +++ /dev/null @@ -1,14 +0,0 @@ -import strutils -import ospaths -const headerdetect = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/detect.h" -import libnx/wrapper/types -proc kernelAbove200*(): bool {.cdecl, importc: "kernelAbove200", - header: headerdetect.} -proc kernelAbove300*(): bool {.cdecl, importc: "kernelAbove300", - header: headerdetect.} -proc kernelAbove400*(): bool {.cdecl, importc: "kernelAbove400", - header: headerdetect.} -proc kernelAbove500*(): bool {.cdecl, importc: "kernelAbove500", - header: headerdetect.} -proc detectDebugger*(): bool {.cdecl, importc: "detectDebugger", - header: headerdetect.} \ No newline at end of file diff --git a/src/libnx/wrapper/env.nim b/src/libnx/wrapper/env.nim deleted file mode 100644 index 7399be3..0000000 --- a/src/libnx/wrapper/env.nim +++ /dev/null @@ -1,56 +0,0 @@ -import strutils -import ospaths -const headerenv = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/env.h" -import libnx/wrapper/types -type - ConfigEntry* {.importc: "ConfigEntry", header: headerenv, bycopy.} = object - Key* {.importc: "Key".}: uint32 - Flags* {.importc: "Flags".}: uint32 - Value* {.importc: "Value".}: array[2, uint64] - - -const - EntryFlag_IsMandatory* = (1 shl (0)) - -const - EntryType_EndOfList* = 0 - EntryType_MainThreadHandle* = 1 - EntryType_NextLoadPath* = 2 - EntryType_OverrideHeap* = 3 - EntryType_OverrideService* = 4 - EntryType_Argv* = 5 - EntryType_SyscallAvailableHint* = 6 - EntryType_AppletType* = 7 - EntryType_AppletWorkaround* = 8 - EntryType_StdioSockets* = 9 - EntryType_ProcessHandle* = 10 - EntryType_LastLoadResult* = 11 - -type - LoaderReturnFn* = proc (result_code: cint) {.cdecl.} - -proc envSetup*(ctx: pointer; main_thread: Handle; saved_lr: LoaderReturnFn) {.cdecl, - importc: "envSetup", header: headerenv.} -proc envGetMainThreadHandle*(): Handle {.cdecl, importc: "envGetMainThreadHandle", - header: headerenv.} -proc envIsNso*(): bool {.cdecl, importc: "envIsNso", header: headerenv.} -proc envHasHeapOverride*(): bool {.cdecl, importc: "envHasHeapOverride", - header: headerenv.} -proc envGetHeapOverrideAddr*(): pointer {.cdecl, - importc: "envGetHeapOverrideAddr", - header: headerenv.} -proc envGetHeapOverrideSize*(): uint64 {.cdecl, importc: "envGetHeapOverrideSize", - header: headerenv.} -proc envHasArgv*(): bool {.cdecl, importc: "envHasArgv", header: headerenv.} -proc envGetArgv*(): pointer {.cdecl, importc: "envGetArgv", header: headerenv.} -proc envIsSyscallHinted*(svc: uint8): bool {.cdecl, importc: "envIsSyscallHinted", - header: headerenv.} -proc envGetOwnProcessHandle*(): Handle {.cdecl, importc: "envGetOwnProcessHandle", - header: headerenv.} -proc envGetExitFuncPtr*(): LoaderReturnFn {.cdecl, importc: "envGetExitFuncPtr", - header: headerenv.} -proc envSetNextLoad*(path: cstring; argv: cstring): Result {.cdecl, - importc: "envSetNextLoad", header: headerenv.} -proc envHasNextLoad*(): bool {.cdecl, importc: "envHasNextLoad", header: headerenv.} -proc envGetLastLoadResult*(): Result {.cdecl, importc: "envGetLastLoadResult", - header: headerenv.} \ No newline at end of file diff --git a/src/libnx/wrapper/fatal.nim b/src/libnx/wrapper/fatal.nim deleted file mode 100644 index 8c43ae1..0000000 --- a/src/libnx/wrapper/fatal.nim +++ /dev/null @@ -1,13 +0,0 @@ -import strutils -import ospaths -const headerfatal = currentSourcePath().splitPath().head & "/nx/include/switch/services/fatal.h" -import libnx/wrapper/types -type - FatalType* {.size: sizeof(cint).} = enum - FatalType_ErrorReportAndErrorScreen = 0, FatalType_ErrorReport = 1, - FatalType_ErrorScreen = 2 - - -proc fatalSimple*(err: Result) {.cdecl, importc: "fatalSimple", header: headerfatal.} -proc fatalWithType*(err: Result; `type`: FatalType) {.cdecl, - importc: "fatalWithType", header: headerfatal.} \ No newline at end of file diff --git a/src/libnx/wrapper/fs.nim b/src/libnx/wrapper/fs.nim deleted file mode 100644 index 0c30d3a..0000000 --- a/src/libnx/wrapper/fs.nim +++ /dev/null @@ -1,172 +0,0 @@ -import strutils -import ospaths -const headerfs = currentSourcePath().splitPath().head & "/nx/include/switch/services/fs.h" -import libnx/ext/integer128 -import libnx/wrapper/types -import libnx/wrapper/sm -const - FS_MAX_PATH* = 0x00000301 - FS_SAVEDATA_CURRENT_TITLEID* = 0 - FS_SAVEDATA_USERID_COMMONSAVE* = 0 - -type - FsFileSystem* {.importc: "FsFileSystem", header: headerfs, bycopy.} = object - s* {.importc: "s".}: Service - - FsFile* {.importc: "FsFile", header: headerfs, bycopy.} = object - s* {.importc: "s".}: Service - - FsDir* {.importc: "FsDir", header: headerfs, bycopy.} = object - s* {.importc: "s".}: Service - - FsStorage* {.importc: "FsStorage", header: headerfs, bycopy.} = object - s* {.importc: "s".}: Service - - FsSaveDataIterator* {.importc: "FsSaveDataIterator", header: headerfs, bycopy.} = object - s* {.importc: "s".}: Service - - FsEventNotifier* {.importc: "FsEventNotifier", header: headerfs, bycopy.} = object - s* {.importc: "s".}: Service - - FsDeviceOperator* {.importc: "FsDeviceOperator", header: headerfs, bycopy.} = object - s* {.importc: "s".}: Service - - FsDirectoryEntry* {.importc: "FsDirectoryEntry", header: headerfs, bycopy.} = object - name* {.importc: "name".}: array[0x00000301, char] - pad* {.importc: "pad".}: array[3, uint8] - `type`* {.importc: "type".}: s8 - pad2* {.importc: "pad2".}: array[3, uint8] - fileSize* {.importc: "fileSize".}: uint64 - - FsSave* {.importc: "FsSave", header: headerfs, bycopy.} = object - titleID* {.importc: "titleID".}: uint64 - userID* {.importc: "userID".}: u128 - saveID* {.importc: "saveID".}: uint64 - SaveDataType* {.importc: "SaveDataType".}: uint64 - unk_x28* {.importc: "unk_x28".}: uint64 - unk_x30* {.importc: "unk_x30".}: uint64 - unk_x38* {.importc: "unk_x38".}: uint64 - - FsSaveDataInfo* {.importc: "FsSaveDataInfo", header: headerfs, bycopy.} = object - saveID_unk* {.importc: "saveID_unk".}: uint64 - SaveDataSpaceId* {.importc: "SaveDataSpaceId".}: uint8 - SaveDataType* {.importc: "SaveDataType".}: uint8 - pad* {.importc: "pad".}: array[6, uint8] - userID* {.importc: "userID".}: u128 - saveID* {.importc: "saveID".}: uint64 - titleID* {.importc: "titleID".}: uint64 - size* {.importc: "size".}: uint64 - unk_x38* {.importc: "unk_x38".}: array[0x00000028, uint8] - - FsEntryType* {.size: sizeof(cint).} = enum - ENTRYTYPE_DIR = 0, ENTRYTYPE_FILE = 1 - FsFileFlags* {.size: sizeof(cint).} = enum - FS_OPEN_READ = (1 shl (0)), FS_OPEN_WRITE = (1 shl (1)), FS_OPEN_APPEND = (1 shl (2)) - FsDirectoryFlags* {.size: sizeof(cint).} = enum - FS_DIROPEN_DIRECTORY = (1 shl (0)), FS_DIROPEN_FILE = (1 shl (1)) - FsStorageId* {.size: sizeof(cint).} = enum - FsStorageId_None = 0, FsStorageId_Host = 1, FsStorageId_GameCard = 2, - FsStorageId_NandSystem = 3, FsStorageId_NandUser = 4, FsStorageId_SdCard = 5 - FsContentStorageId* {.size: sizeof(cint).} = enum - FS_CONTENTSTORAGEID_NandSystem = 0, FS_CONTENTSTORAGEID_NandUser = 1, - FS_CONTENTSTORAGEID_SdCard = 2 - FsSaveDataSpaceId* {.size: sizeof(cint).} = enum - FsSaveDataSpaceId_All = -1, FsSaveDataSpaceId_NandSystem = 0, - FsSaveDataSpaceId_NandUser = 1, FsSaveDataSpaceId_SdCard = 2, - FsSaveDataSpaceId_TemporaryStorage = 3 - FsSaveDataType* {.size: sizeof(cint).} = enum - FsSaveDataType_SystemSaveData = 0, FsSaveDataType_SaveData = 1, - FsSaveDataType_BcatDeliveryCacheStorage = 2, FsSaveDataType_DeviceSaveData = 3, - FsSaveDataType_TemporaryStorage = 4, FsSaveDataType_CacheStorage = 5 - - - - - - - - -proc fsInitialize*(): Result {.cdecl, importc: "fsInitialize", header: headerfs.} -proc fsExit*() {.cdecl, importc: "fsExit", header: headerfs.} -proc fsGetServiceSession*(): ptr Service {.cdecl, importc: "fsGetServiceSession", - header: headerfs.} -proc fsMountSdcard*(`out`: ptr FsFileSystem): Result {.cdecl, - importc: "fsMountSdcard", header: headerfs.} -proc fsMountSaveData*(`out`: ptr FsFileSystem; inval: uint8; save: ptr FsSave): Result {. - cdecl, importc: "fsMountSaveData", header: headerfs.} -proc fsMountSystemSaveData*(`out`: ptr FsFileSystem; inval: uint8; save: ptr FsSave): Result {. - cdecl, importc: "fsMountSystemSaveData", header: headerfs.} -proc fsOpenSaveDataIterator*(`out`: ptr FsSaveDataIterator; SaveDataSpaceId: s32): Result {. - cdecl, importc: "fsOpenSaveDataIterator", header: headerfs.} -proc fsOpenDataStorageByCurrentProcess*(`out`: ptr FsStorage): Result {.cdecl, - importc: "fsOpenDataStorageByCurrentProcess", header: headerfs.} -proc fsOpenDeviceOperator*(`out`: ptr FsDeviceOperator): Result {.cdecl, - importc: "fsOpenDeviceOperator", header: headerfs.} -proc fsOpenSdCardDetectionEventNotifier*(`out`: ptr FsEventNotifier): Result {. - cdecl, importc: "fsOpenSdCardDetectionEventNotifier", header: headerfs.} -proc fsMount_SaveData*(`out`: ptr FsFileSystem; titleID: uint64; userID: u128): Result {. - cdecl, importc: "fsMount_SaveData", header: headerfs.} -proc fsMount_SystemSaveData*(`out`: ptr FsFileSystem; saveID: uint64): Result {.cdecl, - importc: "fsMount_SystemSaveData", header: headerfs.} -proc fsFsCreateFile*(fs: ptr FsFileSystem; path: cstring; size: csize; flags: cint): Result {. - cdecl, importc: "fsFsCreateFile", header: headerfs.} -proc fsFsDeleteFile*(fs: ptr FsFileSystem; path: cstring): Result {.cdecl, - importc: "fsFsDeleteFile", header: headerfs.} -proc fsFsCreateDirectory*(fs: ptr FsFileSystem; path: cstring): Result {.cdecl, - importc: "fsFsCreateDirectory", header: headerfs.} -proc fsFsDeleteDirectory*(fs: ptr FsFileSystem; path: cstring): Result {.cdecl, - importc: "fsFsDeleteDirectory", header: headerfs.} -proc fsFsDeleteDirectoryRecursively*(fs: ptr FsFileSystem; path: cstring): Result {. - cdecl, importc: "fsFsDeleteDirectoryRecursively", header: headerfs.} -proc fsFsRenameFile*(fs: ptr FsFileSystem; path0: cstring; path1: cstring): Result {. - cdecl, importc: "fsFsRenameFile", header: headerfs.} -proc fsFsRenameDirectory*(fs: ptr FsFileSystem; path0: cstring; path1: cstring): Result {. - cdecl, importc: "fsFsRenameDirectory", header: headerfs.} -proc fsFsGetEntryType*(fs: ptr FsFileSystem; path: cstring; `out`: ptr FsEntryType): Result {. - cdecl, importc: "fsFsGetEntryType", header: headerfs.} -proc fsFsOpenFile*(fs: ptr FsFileSystem; path: cstring; flags: cint; `out`: ptr FsFile): Result {. - cdecl, importc: "fsFsOpenFile", header: headerfs.} -proc fsFsOpenDirectory*(fs: ptr FsFileSystem; path: cstring; flags: cint; - `out`: ptr FsDir): Result {.cdecl, - importc: "fsFsOpenDirectory", header: headerfs.} -proc fsFsCommit*(fs: ptr FsFileSystem): Result {.cdecl, importc: "fsFsCommit", - header: headerfs.} -proc fsFsGetFreeSpace*(fs: ptr FsFileSystem; path: cstring; `out`: ptr uint64): Result {. - cdecl, importc: "fsFsGetFreeSpace", header: headerfs.} -proc fsFsGetTotalSpace*(fs: ptr FsFileSystem; path: cstring; `out`: ptr uint64): Result {. - cdecl, importc: "fsFsGetTotalSpace", header: headerfs.} -proc fsFsClose*(fs: ptr FsFileSystem) {.cdecl, importc: "fsFsClose", header: headerfs.} -proc fsFileRead*(f: ptr FsFile; off: uint64; buf: pointer; len: csize; `out`: ptr csize): Result {. - cdecl, importc: "fsFileRead", header: headerfs.} -proc fsFileWrite*(f: ptr FsFile; off: uint64; buf: pointer; len: csize): Result {.cdecl, - importc: "fsFileWrite", header: headerfs.} -proc fsFileFlush*(f: ptr FsFile): Result {.cdecl, importc: "fsFileFlush", - header: headerfs.} -proc fsFileSetSize*(f: ptr FsFile; sz: uint64): Result {.cdecl, importc: "fsFileSetSize", - header: headerfs.} -proc fsFileGetSize*(f: ptr FsFile; `out`: ptr uint64): Result {.cdecl, - importc: "fsFileGetSize", header: headerfs.} -proc fsFileClose*(f: ptr FsFile) {.cdecl, importc: "fsFileClose", header: headerfs.} -proc fsDirRead*(d: ptr FsDir; inval: uint64; total_entries: ptr csize; max_entries: csize; - buf: ptr FsDirectoryEntry): Result {.cdecl, importc: "fsDirRead", - header: headerfs.} -proc fsDirGetEntryCount*(d: ptr FsDir; count: ptr uint64): Result {.cdecl, - importc: "fsDirGetEntryCount", header: headerfs.} -proc fsDirClose*(d: ptr FsDir) {.cdecl, importc: "fsDirClose", header: headerfs.} -proc fsStorageRead*(s: ptr FsStorage; off: uint64; buf: pointer; len: csize): Result {. - cdecl, importc: "fsStorageRead", header: headerfs.} -proc fsStorageClose*(s: ptr FsStorage) {.cdecl, importc: "fsStorageClose", - header: headerfs.} -proc fsSaveDataIteratorRead*(s: ptr FsSaveDataIterator; buf: ptr FsSaveDataInfo; - max_entries: csize; total_entries: ptr csize): Result {. - cdecl, importc: "fsSaveDataIteratorRead", header: headerfs.} -proc fsSaveDataIteratorClose*(s: ptr FsSaveDataIterator) {.cdecl, - importc: "fsSaveDataIteratorClose", header: headerfs.} -proc fsEventNotifierGetEventHandle*(e: ptr FsEventNotifier; `out`: ptr Handle): Result {. - cdecl, importc: "fsEventNotifierGetEventHandle", header: headerfs.} -proc fsEventNotifierClose*(e: ptr FsEventNotifier) {.cdecl, - importc: "fsEventNotifierClose", header: headerfs.} -proc fsDeviceOperatorIsSdCardInserted*(d: ptr FsDeviceOperator; `out`: ptr bool): Result {. - cdecl, importc: "fsDeviceOperatorIsSdCardInserted", header: headerfs.} -proc fsDeviceOperatorClose*(d: ptr FsDeviceOperator) {.cdecl, - importc: "fsDeviceOperatorClose", header: headerfs.} \ No newline at end of file diff --git a/src/libnx/wrapper/fs_dev.nim b/src/libnx/wrapper/fs_dev.nim deleted file mode 100644 index bb813c9..0000000 --- a/src/libnx/wrapper/fs_dev.nim +++ /dev/null @@ -1,29 +0,0 @@ -import strutils -import ospaths -const headerfs_dev = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/devices/fs_dev.h" -import libnx/wrapper/types -import libnx/wrapper/fs -const - FSDEV_DIRITER_MAGIC* = 0x66736476 - -type - fsdev_dir_t* {.importc: "fsdev_dir_t", header: headerfs_dev, bycopy.} = object - magic* {.importc: "magic".}: uint32 - fd* {.importc: "fd".}: FsDir - index* {.importc: "index".}: ssize_t - size* {.importc: "size".}: csize - entry_data* {.importc: "entry_data".}: array[32, FsDirectoryEntry] - - -proc fsdevMountSdmc*(): Result {.cdecl, importc: "fsdevMountSdmc", - header: headerfs_dev.} -proc fsdevMountDevice*(name: cstring; fs: FsFileSystem): cint {.cdecl, - importc: "fsdevMountDevice", header: headerfs_dev.} -proc fsdevUnmountDevice*(name: cstring): cint {.cdecl, - importc: "fsdevUnmountDevice", header: headerfs_dev.} -proc fsdevCommitDevice*(name: cstring): Result {.cdecl, - importc: "fsdevCommitDevice", header: headerfs_dev.} -proc fsdevGetDefaultFileSystem*(): ptr FsFileSystem {.cdecl, - importc: "fsdevGetDefaultFileSystem", header: headerfs_dev.} -proc fsdevUnmountAll*(): Result {.cdecl, importc: "fsdevUnmountAll", - header: headerfs_dev.} \ No newline at end of file diff --git a/src/libnx/wrapper/fsldr.nim b/src/libnx/wrapper/fsldr.nim deleted file mode 100644 index 2440dc1..0000000 --- a/src/libnx/wrapper/fsldr.nim +++ /dev/null @@ -1,15 +0,0 @@ -import strutils -import ospaths -const headerfsldr = currentSourcePath().splitPath().head & "/nx/include/switch/services/fsldr.h" -import libnx/wrapper/types -import libnx/wrapper/sm -import libnx/wrapper/fs -proc fsldrInitialize*(): Result {.cdecl, importc: "fsldrInitialize", - header: headerfsldr.} -proc fsldrExit*() {.cdecl, importc: "fsldrExit", header: headerfsldr.} -proc fsldrOpenCodeFileSystem*(tid: uint64; path: cstring; `out`: ptr FsFileSystem): Result {. - cdecl, importc: "fsldrOpenCodeFileSystem", header: headerfsldr.} -proc fsldrIsArchivedProgram*(pid: uint64; `out`: ptr bool): Result {.cdecl, - importc: "fsldrIsArchivedProgram", header: headerfsldr.} -proc fsldrSetCurrentProcess*(): Result {.cdecl, importc: "fsldrSetCurrentProcess", - header: headerfsldr.} \ No newline at end of file diff --git a/src/libnx/wrapper/fspr.nim b/src/libnx/wrapper/fspr.nim deleted file mode 100644 index 5080259..0000000 --- a/src/libnx/wrapper/fspr.nim +++ /dev/null @@ -1,19 +0,0 @@ -import strutils -import ospaths -const headerfspr = currentSourcePath().splitPath().head & "/nx/include/switch/services/fspr.h" -import libnx/wrapper/types -import libnx/wrapper/sm -import libnx/wrapper/fs -proc fsprInitialize*(): Result {.cdecl, importc: "fsprInitialize", - header: headerfspr.} -proc fsprExit*() {.cdecl, importc: "fsprExit", header: headerfspr.} -proc fsprRegisterProgram*(pid: uint64; titleID: uint64; storageID: FsStorageId; - fs_access_header: pointer; fah_size: csize; - fs_access_control: pointer; fac_size: csize): Result {. - cdecl, importc: "fsprRegisterProgram", header: headerfspr.} -proc fsprUnregisterProgram*(pid: uint64): Result {.cdecl, - importc: "fsprUnregisterProgram", header: headerfspr.} -proc fsprSetCurrentProcess*(): Result {.cdecl, importc: "fsprSetCurrentProcess", - header: headerfspr.} -proc fsprSetEnabledProgramVerification*(enabled: bool): Result {.cdecl, - importc: "fsprSetEnabledProgramVerification", header: headerfspr.} \ No newline at end of file diff --git a/src/libnx/wrapper/gfx.nim b/src/libnx/wrapper/gfx.nim deleted file mode 100644 index f95daff..0000000 --- a/src/libnx/wrapper/gfx.nim +++ /dev/null @@ -1,124 +0,0 @@ -import strutils -import ospaths -const headergfx = currentSourcePath().splitPath().head & "/nx/include/switch/gfx/gfx.h" -## * -## @file gfx.h -## @brief High-level graphics API. -## This API exposes a framebuffer (technically speaking, a windowbuffer) to be used for drawing graphics. -## @author yellows8 -## @copyright libnx Authors -## - -import - libnx/wrapper/types - -## / Converts red, green, blue, and alpha components to packed RGBA8. - -template RGBA8*(r, g, b, a: untyped): untyped = - (((r) and 0x000000FF) or (((g) and 0x000000FF) shl 8) or - (((b) and 0x000000FF) shl 16) or (((a) and 0x000000FF) shl 24)) - -## / Same as \ref RGBA8 except with alpha=0xff. - -template RGBA8_MAXALPHA*(r, g, b: untyped): untyped = - RGBA8(r, g, b, 0x000000FF) - -## / GfxMode set by \ref gfxSetMode. The default is GfxMode_LinearDouble. Note that the text-console (see console.h) sets this to GfxMode_TiledDouble. - -type - GfxMode* {.size: sizeof(cint).} = enum - GfxMode_TiledSingle, ## /< Single-buffering with raw tiled (block-linear) framebuffer. - GfxMode_TiledDouble, ## /< Double-buffering with raw tiled (block-linear) framebuffer. - GfxMode_LinearDouble ## /< Double-buffering with linear framebuffer, which is transferred to the actual framebuffer by \ref gfxFlushBuffers(). - - -## / Framebuffer pixel-format is RGBA8888, there's no known way to change this. -## * -## @brief Initializes the graphics subsystem. -## @warning Do not use \ref viInitialize when using this function. -## - -proc gfxInitDefault*() {.cdecl, importc: "gfxInitDefault", header: headergfx.} -## * -## @brief Uninitializes the graphics subsystem. -## @warning Do not use \ref viExit when using this function. -## - -proc gfxExit*() {.cdecl, importc: "gfxExit", header: headergfx.} -## * -## @brief Sets the resolution to be used when initializing the graphics subsystem. -## @param[in] width Horizontal resolution, in pixels. -## @param[in] height Vertical resolution, in pixels. -## @note The default resolution is 720p. -## @note This can only be used before calling \ref gfxInitDefault, this will use \ref fatalSimple otherwise. If the input is 0, the default resolution will be used during \ref gfxInitDefault. This sets the maximum resolution for the framebuffer, used during \ref gfxInitDefault. This is also used as the current resolution when crop isn't set. The width/height are reset to the default when \ref gfxExit is used. -## @note Normally you should only use this when you need a maximum resolution larger than the default, see above. -## @note The width and height are aligned to 4. -## - -proc gfxInitResolution*(width: uint32; height: uint32) {.cdecl, - importc: "gfxInitResolution", header: headergfx.} -## / Wrapper for \ref gfxInitResolution with resolution=1080p. Use this if you want to support 1080p or >720p in docked-mode. - -proc gfxInitResolutionDefault*() {.cdecl, importc: "gfxInitResolutionDefault", - header: headergfx.} -## / Configure framebuffer crop, by default crop is all-zero. Use all-zero input to reset to default. \ref gfxExit resets this to the default. -## / When the input is invalid this returns without changing the crop data, this includes the input values being larger than the framebuf width/height. -## / This will update the display width/height returned by \ref gfxGetFramebuffer, with that width/height being reset to the default when required. -## / \ref gfxGetFramebufferDisplayOffset uses absolute x/y, it will not adjust for non-zero crop left/top. -## / The new crop config will not take affect with double-buffering disabled. When used during frame-drawing, this should be called before \ref gfxGetFramebuffer. -## / The right and bottom params are aligned to 4. - -proc gfxConfigureCrop*(left: s32; top: s32; right: s32; bottom: s32) {.cdecl, - importc: "gfxConfigureCrop", header: headergfx.} -## / Wrapper for \ref gfxConfigureCrop. Use this to set the resolution, within the bounds of the maximum resolution. Use all-zero input to reset to default. - -proc gfxConfigureResolution*(width: s32; height: s32) {.cdecl, - importc: "gfxConfigureResolution", header: headergfx.} -## / If enabled, \ref gfxConfigureResolution will be used with the input resolution for the current OperationMode. Then \ref gfxConfigureResolution will automatically be used with the specified resolution each time OperationMode changes. - -proc gfxConfigureAutoResolution*(enable: bool; handheld_width: s32; - handheld_height: s32; docked_width: s32; - docked_height: s32) {.cdecl, - importc: "gfxConfigureAutoResolution", header: headergfx.} -## / Wrapper for \ref gfxConfigureAutoResolution. handheld_resolution=720p, docked_resolution={all-zero for using current maximum resolution}. - -proc gfxConfigureAutoResolutionDefault*(enable: bool) {.cdecl, - importc: "gfxConfigureAutoResolutionDefault", header: headergfx.} -## / Waits for vertical sync. - -proc gfxWaitForVsync*() {.cdecl, importc: "gfxWaitForVsync", header: headergfx.} -## / Swaps the framebuffers (for double-buffering). - -proc gfxSwapBuffers*() {.cdecl, importc: "gfxSwapBuffers", header: headergfx.} -## / Get the current framebuffer address, with optional output ptrs for the display framebuffer width/height. The display width/height is adjusted by \ref gfxConfigureCrop and \ref gfxConfigureResolution. - -proc gfxGetFramebuffer*(width: ptr uint32; height: ptr uint32): ptr uint8 {.cdecl, - importc: "gfxGetFramebuffer", header: headergfx.} -## / Get the framebuffer width/height without crop. - -proc gfxGetFramebufferResolution*(width: ptr uint32; height: ptr uint32) {.cdecl, - importc: "gfxGetFramebufferResolution", header: headergfx.} -## / Use this to get the actual byte-size of the framebuffer for use with memset/etc. - -proc gfxGetFramebufferSize*(): csize {.cdecl, importc: "gfxGetFramebufferSize", - header: headergfx.} -## / Sets the \ref GfxMode. - -proc gfxSetMode*(mode: GfxMode) {.cdecl, importc: "gfxSetMode", header: headergfx.} -## / Controls whether a vertical-flip is done when determining the pixel-offset within the actual framebuffer. By default this is enabled. - -proc gfxSetDrawFlip*(flip: bool) {.cdecl, importc: "gfxSetDrawFlip", - header: headergfx.} -## / Configures transform. See the NATIVE_WINDOW_TRANSFORM_* enums in buffer_producer.h. The default is NATIVE_WINDOW_TRANSFORM_FLIP_V. - -proc gfxConfigureTransform*(transform: uint32) {.cdecl, - importc: "gfxConfigureTransform", header: headergfx.} -## / Flushes the framebuffer in the data cache. When \ref GfxMode is GfxMode_LinearDouble, this also transfers the linear-framebuffer to the actual framebuffer. - -proc gfxFlushBuffers*() {.cdecl, importc: "gfxFlushBuffers", header: headergfx.} -## / Use this to get the pixel-offset in the framebuffer. Returned value is in pixels, not bytes. -## / This implements tegra blocklinear, with hard-coded constants etc. -## / Do not use this when \ref GfxMode is GfxMode_LinearDouble. - -proc gfxGetFramebufferDisplayOffset*(x: uint32; y: uint32): uint32 {.inline, cdecl, - importc: "gfxGetFramebufferDisplayOffset", header: headergfx.} \ No newline at end of file diff --git a/src/libnx/wrapper/hid.nim b/src/libnx/wrapper/hid.nim deleted file mode 100644 index 9805468..0000000 --- a/src/libnx/wrapper/hid.nim +++ /dev/null @@ -1,508 +0,0 @@ -import strutils -import ospaths -const headerhid = currentSourcePath().splitPath().head & "/nx/include/switch/services/hid.h" -## * -## @file hid.h -## @brief Human input device (hid) service IPC wrapper. -## @author shinyquagsire23 -## @author yellows8 -## @copyright libnx Authors -## - -import - libnx/wrapper/types, libnx/wrapper/sm - -## Begin enums and output structs - -type - HidMouseButton* {.size: sizeof(cint).} = enum - MOUSE_LEFT = BIT(0), MOUSE_RIGHT = BIT(1), MOUSE_MIDDLE = BIT(2), - MOUSE_FORWARD = BIT(3), MOUSE_BACK = BIT(4) - HidKeyboardModifier* {.size: sizeof(cint).} = enum - KBD_MOD_LCTRL = BIT(0), KBD_MOD_LSHIFT = BIT(1), KBD_MOD_LALT = BIT(2), - KBD_MOD_LMETA = BIT(3), KBD_MOD_RCTRL = BIT(4), KBD_MOD_RSHIFT = BIT(5), - KBD_MOD_RALT = BIT(6), KBD_MOD_RMETA = BIT(7), KBD_MOD_CAPSLOCK = BIT(8), - KBD_MOD_SCROLLLOCK = BIT(9), KBD_MOD_NUMLOCK = BIT(10) - HidKeyboardScancode* {.size: sizeof(cint).} = enum - KBD_NONE = 0x00000000, KBD_ERR_OVF = 0x00000001, KBD_A = 0x00000004, - KBD_B = 0x00000005, KBD_C = 0x00000006, KBD_D = 0x00000007, KBD_E = 0x00000008, - KBD_F = 0x00000009, KBD_G = 0x0000000A, KBD_H = 0x0000000B, KBD_I = 0x0000000C, - KBD_J = 0x0000000D, KBD_K = 0x0000000E, KBD_L = 0x0000000F, KBD_M = 0x00000010, - KBD_N = 0x00000011, KBD_O = 0x00000012, KBD_P = 0x00000013, KBD_Q = 0x00000014, - KBD_R = 0x00000015, KBD_S = 0x00000016, KBD_T = 0x00000017, KBD_U = 0x00000018, - KBD_V = 0x00000019, KBD_W = 0x0000001A, KBD_X = 0x0000001B, KBD_Y = 0x0000001C, - KBD_Z = 0x0000001D, KBD_1 = 0x0000001E, KBD_2 = 0x0000001F, KBD_3 = 0x00000020, - KBD_4 = 0x00000021, KBD_5 = 0x00000022, KBD_6 = 0x00000023, KBD_7 = 0x00000024, - KBD_8 = 0x00000025, KBD_9 = 0x00000026, KBD_0 = 0x00000027, KBD_ENTER = 0x00000028, - KBD_ESC = 0x00000029, KBD_BACKSPACE = 0x0000002A, KBD_TAB = 0x0000002B, - KBD_SPACE = 0x0000002C, KBD_MINUS = 0x0000002D, KBD_EQUAL = 0x0000002E, - KBD_LEFTBRACE = 0x0000002F, KBD_RIGHTBRACE = 0x00000030, - KBD_BACKSLASH = 0x00000031, KBD_HASHTILDE = 0x00000032, - KBD_SEMICOLON = 0x00000033, KBD_APOSTROPHE = 0x00000034, KBD_GRAVE = 0x00000035, - KBD_COMMA = 0x00000036, KBD_DOT = 0x00000037, KBD_SLASH = 0x00000038, - KBD_CAPSLOCK = 0x00000039, KBD_F1 = 0x0000003A, KBD_F2 = 0x0000003B, - KBD_F3 = 0x0000003C, KBD_F4 = 0x0000003D, KBD_F5 = 0x0000003E, KBD_F6 = 0x0000003F, - KBD_F7 = 0x00000040, KBD_F8 = 0x00000041, KBD_F9 = 0x00000042, KBD_F10 = 0x00000043, - KBD_F11 = 0x00000044, KBD_F12 = 0x00000045, KBD_SYSRQ = 0x00000046, - KBD_SCROLLLOCK = 0x00000047, KBD_PAUSE = 0x00000048, KBD_INSERT = 0x00000049, - KBD_HOME = 0x0000004A, KBD_PAGEUP = 0x0000004B, KBD_DELETE = 0x0000004C, - KBD_END = 0x0000004D, KBD_PAGEDOWN = 0x0000004E, KBD_RIGHT = 0x0000004F, - KBD_LEFT = 0x00000050, KBD_DOWN = 0x00000051, KBD_UP = 0x00000052, - KBD_NUMLOCK = 0x00000053, KBD_KPSLASH = 0x00000054, KBD_KPASTERISK = 0x00000055, - KBD_KPMINUS = 0x00000056, KBD_KPPLUS = 0x00000057, KBD_KPENTER = 0x00000058, - KBD_KP1 = 0x00000059, KBD_KP2 = 0x0000005A, KBD_KP3 = 0x0000005B, - KBD_KP4 = 0x0000005C, KBD_KP5 = 0x0000005D, KBD_KP6 = 0x0000005E, - KBD_KP7 = 0x0000005F, KBD_KP8 = 0x00000060, KBD_KP9 = 0x00000061, - KBD_KP0 = 0x00000062, KBD_KPDOT = 0x00000063, KBD_102ND = 0x00000064, - KBD_COMPOSE = 0x00000065, KBD_POWER = 0x00000066, KBD_KPEQUAL = 0x00000067, - KBD_F13 = 0x00000068, KBD_F14 = 0x00000069, KBD_F15 = 0x0000006A, - KBD_F16 = 0x0000006B, KBD_F17 = 0x0000006C, KBD_F18 = 0x0000006D, - KBD_F19 = 0x0000006E, KBD_F20 = 0x0000006F, KBD_F21 = 0x00000070, - KBD_F22 = 0x00000071, KBD_F23 = 0x00000072, KBD_F24 = 0x00000073, - KBD_OPEN = 0x00000074, KBD_HELP = 0x00000075, KBD_PROPS = 0x00000076, - KBD_FRONT = 0x00000077, KBD_STOP = 0x00000078, KBD_AGAIN = 0x00000079, - KBD_UNDO = 0x0000007A, KBD_CUT = 0x0000007B, KBD_COPY = 0x0000007C, - KBD_PASTE = 0x0000007D, KBD_FIND = 0x0000007E, KBD_MUTE = 0x0000007F, - KBD_VOLUMEUP = 0x00000080, KBD_VOLUMEDOWN = 0x00000081, - KBD_CAPSLOCK_ACTIVE = 0x00000082, KBD_NUMLOCK_ACTIVE = 0x00000083, - KBD_SCROLLLOCK_ACTIVE = 0x00000084, KBD_KPCOMMA = 0x00000085, - KBD_KPLEFTPAREN = 0x000000B6, KBD_KPRIGHTPAREN = 0x000000B7, - KBD_LEFTCTRL = 0x000000E0, KBD_LEFTSHIFT = 0x000000E1, KBD_LEFTALT = 0x000000E2, - KBD_LEFTMETA = 0x000000E3, KBD_RIGHTCTRL = 0x000000E4, - KBD_RIGHTSHIFT = 0x000000E5, KBD_RIGHTALT = 0x000000E6, - KBD_RIGHTMETA = 0x000000E7, KBD_MEDIA_PLAYPAUSE = 0x000000E8, - KBD_MEDIA_STOPCD = 0x000000E9, KBD_MEDIA_PREVIOUSSONG = 0x000000EA, - KBD_MEDIA_NEXTSONG = 0x000000EB, KBD_MEDIA_EJECTCD = 0x000000EC, - KBD_MEDIA_VOLUMEUP = 0x000000ED, KBD_MEDIA_VOLUMEDOWN = 0x000000EE, - KBD_MEDIA_MUTE = 0x000000EF, KBD_MEDIA_WWW = 0x000000F0, - KBD_MEDIA_BACK = 0x000000F1, KBD_MEDIA_FORWARD = 0x000000F2, - KBD_MEDIA_STOP = 0x000000F3, KBD_MEDIA_FIND = 0x000000F4, - KBD_MEDIA_SCROLLUP = 0x000000F5, KBD_MEDIA_SCROLLDOWN = 0x000000F6, - KBD_MEDIA_EDIT = 0x000000F7, KBD_MEDIA_SLEEP = 0x000000F8, - KBD_MEDIA_COFFEE = 0x000000F9, KBD_MEDIA_REFRESH = 0x000000FA, - KBD_MEDIA_CALC = 0x000000FB - HidControllerType* {.size: sizeof(cint).} = enum - TYPE_PROCONTROLLER = BIT(0), TYPE_HANDHELD = BIT(1), TYPE_JOYCON_PAIR = BIT(2), - TYPE_JOYCON_LEFT = BIT(3), TYPE_JOYCON_RIGHT = BIT(4) - HidControllerLayoutType* {.size: sizeof(cint).} = enum - LAYOUT_PROCONTROLLER = 0, ## Pro Controller or Hid gamepad - LAYOUT_HANDHELD = 1, ## Two Joy-Con docked to rails - LAYOUT_SINGLE = 2, ## Horizontal single Joy-Con or pair of Joy-Con, adjusted for orientation - LAYOUT_LEFT = 3, ## Only raw left Joy-Con state, no orientation adjustment - LAYOUT_RIGHT = 4, ## Only raw right Joy-Con state, no orientation adjustment - LAYOUT_DEFAULT_DIGITAL = 5, ## Same as next, but sticks have 8-direction values only - LAYOUT_DEFAULT = 6 ## Safe default, single Joy-Con have buttons/sticks rotated for orientation - HidControllerColorDescription* {.size: sizeof(cint).} = enum - COLORS_NONEXISTENT = BIT(1) - HidControllerKeys* {.size: sizeof(cint).} = enum - KEY_A = BIT(0), ## /< A - KEY_B = BIT(1), ## /< B - KEY_X = BIT(2), ## /< X - KEY_Y = BIT(3), ## /< Y - KEY_LSTICK = BIT(4), ## /< Left Stick Button - KEY_RSTICK = BIT(5), ## /< Right Stick Button - KEY_L = BIT(6), ## /< L - KEY_R = BIT(7), ## /< R - KEY_ZL = BIT(8), ## /< ZL - KEY_ZR = BIT(9), ## /< ZR - KEY_PLUS = BIT(10), ## /< Plus - KEY_MINUS = BIT(11), ## /< Minus - KEY_DLEFT = BIT(12), ## /< D-Pad Left - KEY_DUP = BIT(13), ## /< D-Pad Up - KEY_DRIGHT = BIT(14), ## /< D-Pad Right - KEY_DDOWN = BIT(15), ## /< D-Pad Down - KEY_LSTICK_LEFT = BIT(16), ## /< Left Stick Left - KEY_LSTICK_UP = BIT(17), ## /< Left Stick Up - KEY_LSTICK_RIGHT = BIT(18), ## /< Left Stick Right - KEY_LSTICK_DOWN = BIT(19), ## /< Left Stick Down - KEY_RSTICK_LEFT = BIT(20), ## /< Right Stick Left - KEY_LEFT = KEY_DLEFT.int or KEY_LSTICK_LEFT.int or KEY_RSTICK_LEFT.int, ## /< D-Pad Left or Sticks Left - KEY_RSTICK_UP = BIT(21), ## /< Right Stick Up - KEY_UP = KEY_DUP.int or KEY_LSTICK_UP.int or KEY_RSTICK_UP.int, ## /< D-Pad Up or Sticks Up - KEY_RSTICK_RIGHT = BIT(22), ## /< Right Stick Right - KEY_RIGHT = KEY_DRIGHT.int or KEY_LSTICK_RIGHT.int or KEY_RSTICK_RIGHT.int, ## /< D-Pad Right or Sticks Right - KEY_RSTICK_DOWN = BIT(23), ## /< Right Stick Down - KEY_DOWN = KEY_DDOWN.int or KEY_LSTICK_DOWN.int or KEY_RSTICK_DOWN.int, ## /< D-Pad Down or Sticks Down - KEY_SL = BIT(24), ## /< SL - KEY_SR = BIT(25), ## /< SR - ## Pseudo-key for at least one finger on the touch screen - KEY_TOUCH = BIT(26), ## Buttons by orientation (for single Joy-Con), also works with Joy-Con pairs, Pro Controller - ## Generic catch-all directions, also works for single Joy-Con - - - - - HidControllerJoystick* {.size: sizeof(cint).} = enum - JOYSTICK_LEFT = 0, JOYSTICK_RIGHT = 1, JOYSTICK_NUM_STICKS = 2 - HidControllerConnectionState* {.size: sizeof(cint).} = enum - CONTROLLER_STATE_CONNECTED = BIT(0), CONTROLLER_STATE_WIRED = BIT(1) - HidControllerID* {.size: sizeof(cint).} = enum - CONTROLLER_PLAYER_1 = 0, CONTROLLER_PLAYER_2 = 1, CONTROLLER_PLAYER_3 = 2, - CONTROLLER_PLAYER_4 = 3, CONTROLLER_PLAYER_5 = 4, CONTROLLER_PLAYER_6 = 5, - CONTROLLER_PLAYER_7 = 6, CONTROLLER_PLAYER_8 = 7, CONTROLLER_HANDHELD = 8, - CONTROLLER_UNKNOWN = 9, CONTROLLER_P1_AUTO = 10 ## / Not an actual HID-sysmodule ID. Only for hidKeys*()/hidJoystickRead(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD. - touchPosition* {.importc: "touchPosition", header: headerhid, bycopy.} = object - px* {.importc: "px".}: uint32 - py* {.importc: "py".}: uint32 - dx* {.importc: "dx".}: uint32 - dy* {.importc: "dy".}: uint32 - angle* {.importc: "angle".}: uint32 - - JoystickPosition* {.importc: "JoystickPosition", header: headerhid, bycopy.} = object - dx* {.importc: "dx".}: s32 - dy* {.importc: "dy".}: s32 - - MousePosition* {.importc: "MousePosition", header: headerhid, bycopy.} = object - x* {.importc: "x".}: uint32 - y* {.importc: "y".}: uint32 - velocityX* {.importc: "velocityX".}: uint32 - velocityY* {.importc: "velocityY".}: uint32 - scrollVelocityX* {.importc: "scrollVelocityX".}: uint32 - scrollVelocityY* {.importc: "scrollVelocityY".}: uint32 - - - - - - - - - - - - -const - JOYSTICK_MAX* = (0x00008000) - JOYSTICK_MIN* = (-0x00008000) - -## End enums and output structs -## Begin HidTouchScreen - -type - HidTouchScreenHeader* {.importc: "HidTouchScreenHeader", header: headerhid, bycopy.} = object - timestampTicks* {.importc: "timestampTicks".}: uint64 - numEntries* {.importc: "numEntries".}: uint64 - latestEntry* {.importc: "latestEntry".}: uint64 - maxEntryIndex* {.importc: "maxEntryIndex".}: uint64 - timestamp* {.importc: "timestamp".}: uint64 - - -## static_assert(sizeof(HidTouchScreenHeader) == 0x28, "Hid touch screen header structure has incorrect size"); - -type - HidTouchScreenEntryHeader* {.importc: "HidTouchScreenEntryHeader", - header: headerhid, bycopy.} = object - timestamp* {.importc: "timestamp".}: uint64 - numTouches* {.importc: "numTouches".}: uint64 - - -## static_assert(sizeof(HidTouchScreenEntryHeader) == 0x10, "Hid touch screen entry header structure has incorrect size"); - -type - HidTouchScreenEntryTouch* {.importc: "HidTouchScreenEntryTouch", - header: headerhid, bycopy.} = object - timestamp* {.importc: "timestamp".}: uint64 - padding* {.importc: "padding".}: uint32 - touchIndex* {.importc: "touchIndex".}: uint32 - x* {.importc: "x".}: uint32 - y* {.importc: "y".}: uint32 - diameterX* {.importc: "diameterX".}: uint32 - diameterY* {.importc: "diameterY".}: uint32 - angle* {.importc: "angle".}: uint32 - padding_2* {.importc: "padding_2".}: uint32 - - -## static_assert(sizeof(HidTouchScreenEntryTouch) == 0x28, "Hid touch screen touch structure has incorrect size"); - -type - HidTouchScreenEntry* {.importc: "HidTouchScreenEntry", header: headerhid, bycopy.} = object - header* {.importc: "header".}: HidTouchScreenEntryHeader - touches* {.importc: "touches".}: array[16, HidTouchScreenEntryTouch] - unk* {.importc: "unk".}: uint64 - - -## static_assert(sizeof(HidTouchScreenEntry) == 0x298, "Hid touch screen entry structure has incorrect size"); - -type - HidTouchScreen* {.importc: "HidTouchScreen", header: headerhid, bycopy.} = object - header* {.importc: "header".}: HidTouchScreenHeader - entries* {.importc: "entries".}: array[17, HidTouchScreenEntry] - padding* {.importc: "padding".}: array[0x000003C0, uint8] - - -## static_assert(sizeof(HidTouchScreen) == 0x3000, "Hid touch screen structure has incorrect size"); -## End HidTouchScreen -## Begin HidMouse - -type - HidMouseHeader* {.importc: "HidMouseHeader", header: headerhid, bycopy.} = object - timestampTicks* {.importc: "timestampTicks".}: uint64 - numEntries* {.importc: "numEntries".}: uint64 - latestEntry* {.importc: "latestEntry".}: uint64 - maxEntryIndex* {.importc: "maxEntryIndex".}: uint64 - - -## static_assert(sizeof(HidMouseHeader) == 0x20, "Hid mouse header structure has incorrect size"); - -type - HidMouseEntry* {.importc: "HidMouseEntry", header: headerhid, bycopy.} = object - timestamp* {.importc: "timestamp".}: uint64 - timestamp_2* {.importc: "timestamp_2".}: uint64 - position* {.importc: "position".}: MousePosition - buttons* {.importc: "buttons".}: uint64 - - -## static_assert(sizeof(HidMouseEntry) == 0x30, "Hid mouse entry structure has incorrect size"); - -type - HidMouse* {.importc: "HidMouse", header: headerhid, bycopy.} = object - header* {.importc: "header".}: HidMouseHeader - entries* {.importc: "entries".}: array[17, HidMouseEntry] - padding* {.importc: "padding".}: array[0x000000B0, uint8] - - -## static_assert(sizeof(HidMouse) == 0x400, "Hid mouse structure has incorrect size"); -## End HidMouse -## Begin HidKeyboard - -type - HidKeyboardHeader* {.importc: "HidKeyboardHeader", header: headerhid, bycopy.} = object - timestampTicks* {.importc: "timestampTicks".}: uint64 - numEntries* {.importc: "numEntries".}: uint64 - latestEntry* {.importc: "latestEntry".}: uint64 - maxEntryIndex* {.importc: "maxEntryIndex".}: uint64 - - -## static_assert(sizeof(HidKeyboardHeader) == 0x20, "Hid keyboard header structure has incorrect size"); - -type - HidKeyboardEntry* {.importc: "HidKeyboardEntry", header: headerhid, bycopy.} = object - timestamp* {.importc: "timestamp".}: uint64 - timestamp_2* {.importc: "timestamp_2".}: uint64 - modifier* {.importc: "modifier".}: uint64 - keys* {.importc: "keys".}: array[8, uint32] - - -## static_assert(sizeof(HidKeyboardEntry) == 0x38, "Hid keyboard entry structure has incorrect size"); - -type - HidKeyboard* {.importc: "HidKeyboard", header: headerhid, bycopy.} = object - header* {.importc: "header".}: HidKeyboardHeader - entries* {.importc: "entries".}: array[17, HidKeyboardEntry] - padding* {.importc: "padding".}: array[0x00000028, uint8] - - -## static_assert(sizeof(HidKeyboard) == 0x400, "Hid keyboard structure has incorrect size"); -## End HidKeyboard -## Begin HidController - -type - HidControllerMAC* {.importc: "HidControllerMAC", header: headerhid, bycopy.} = object - timestamp* {.importc: "timestamp".}: uint64 - mac* {.importc: "mac".}: array[0x00000008, uint8] - unk* {.importc: "unk".}: uint64 - timestamp_2* {.importc: "timestamp_2".}: uint64 - - -## static_assert(sizeof(HidControllerMAC) == 0x20, "Hid controller MAC structure has incorrect size"); - -type - HidControllerHeader* {.importc: "HidControllerHeader", header: headerhid, bycopy.} = object - `type`* {.importc: "type".}: uint32 - isHalf* {.importc: "isHalf".}: uint32 - singleColorsDescriptor* {.importc: "singleColorsDescriptor".}: uint32 - singleColorBody* {.importc: "singleColorBody".}: uint32 - singleColorButtons* {.importc: "singleColorButtons".}: uint32 - splitColorsDescriptor* {.importc: "splitColorsDescriptor".}: uint32 - leftColorBody* {.importc: "leftColorBody".}: uint32 - leftColorButtons* {.importc: "leftColorButtons".}: uint32 - rightColorBody* {.importc: "rightColorBody".}: uint32 - rightColorbuttons* {.importc: "rightColorbuttons".}: uint32 - - -## static_assert(sizeof(HidControllerHeader) == 0x28, "Hid controller header structure has incorrect size"); - -type - HidControllerLayoutHeader* {.importc: "HidControllerLayoutHeader", - header: headerhid, bycopy.} = object - timestampTicks* {.importc: "timestampTicks".}: uint64 - numEntries* {.importc: "numEntries".}: uint64 - latestEntry* {.importc: "latestEntry".}: uint64 - maxEntryIndex* {.importc: "maxEntryIndex".}: uint64 - - -## static_assert(sizeof(HidControllerLayoutHeader) == 0x20, "Hid controller layout header structure has incorrect size"); - -type - HidControllerInputEntry* {.importc: "HidControllerInputEntry", header: headerhid, - bycopy.} = object - timestamp* {.importc: "timestamp".}: uint64 - timestamp_2* {.importc: "timestamp_2".}: uint64 - buttons* {.importc: "buttons".}: uint64 - joysticks* {.importc: "joysticks".}: array[JOYSTICK_NUM_STICKS, JoystickPosition] - connectionState* {.importc: "connectionState".}: uint64 - - -## static_assert(sizeof(HidControllerInputEntry) == 0x30, "Hid controller input entry structure has incorrect size"); - -type - HidControllerLayout* {.importc: "HidControllerLayout", header: headerhid, bycopy.} = object - header* {.importc: "header".}: HidControllerLayoutHeader - entries* {.importc: "entries".}: array[17, HidControllerInputEntry] - - -## static_assert(sizeof(HidControllerLayout) == 0x350, "Hid controller layout structure has incorrect size"); - -type - HidController* {.importc: "HidController", header: headerhid, bycopy.} = object - header* {.importc: "header".}: HidControllerHeader - layouts* {.importc: "layouts".}: array[7, HidControllerLayout] - unk_1* {.importc: "unk_1".}: array[0x00002A70, uint8] - macLeft* {.importc: "macLeft".}: HidControllerMAC - macRight* {.importc: "macRight".}: HidControllerMAC - unk_2* {.importc: "unk_2".}: array[0x00000DF8, uint8] - - -## static_assert(sizeof(HidController) == 0x5000, "Hid controller structure has incorrect size"); -## End HidController - -type - HidSharedMemory* {.importc: "HidSharedMemory", header: headerhid, bycopy.} = object - header* {.importc: "header".}: array[0x00000400, uint8] - touchscreen* {.importc: "touchscreen".}: HidTouchScreen - mouse* {.importc: "mouse".}: HidMouse - keyboard* {.importc: "keyboard".}: HidKeyboard - unkSection1* {.importc: "unkSection1".}: array[0x00000400, uint8] - unkSection2* {.importc: "unkSection2".}: array[0x00000400, uint8] - unkSection3* {.importc: "unkSection3".}: array[0x00000400, uint8] - unkSection4* {.importc: "unkSection4".}: array[0x00000400, uint8] - unkSection5* {.importc: "unkSection5".}: array[0x00000200, uint8] - unkSection6* {.importc: "unkSection6".}: array[0x00000200, uint8] - unkSection7* {.importc: "unkSection7".}: array[0x00000200, uint8] - unkSection8* {.importc: "unkSection8".}: array[0x00000800, uint8] - controllerSerials* {.importc: "controllerSerials".}: array[0x00004000, uint8] - controllers* {.importc: "controllers".}: array[10, HidController] - unkSection9* {.importc: "unkSection9".}: array[0x00004600, uint8] - - -## static_assert(sizeof(HidSharedMemory) == 0x40000, "Hid Shared Memory structure has incorrect size"); - -type - HidVibrationDeviceInfo* {.importc: "HidVibrationDeviceInfo", header: headerhid, - bycopy.} = object - unk_x0* {.importc: "unk_x0".}: uint32 - unk_x4* {.importc: "unk_x4".}: uint32 ## /< 0x1 for left-joycon, 0x2 for right-joycon. - - -## static_assert(sizeof(HidVibrationDeviceInfo) == 0x8, "Hid VibrationDeviceInfo structure has incorrect size"); - -type - HidVibrationValue* {.importc: "HidVibrationValue", header: headerhid, bycopy.} = object - amp_low* {.importc: "amp_low".}: cfloat ## /< Low Band amplitude. 1.0f: Max amplitude. - freq_low* {.importc: "freq_low".}: cfloat ## /< Low Band frequency in Hz. - amp_high* {.importc: "amp_high".}: cfloat ## /< High Band amplitude. 1.0f: Max amplitude. - freq_high* {.importc: "freq_high".}: cfloat ## /< High Band frequency in Hz. - - -## static_assert(sizeof(HidVibrationValue) == 0x10, "Hid VibrationValue structure has incorrect size"); - -proc hidInitialize*(): Result {.cdecl, importc: "hidInitialize", header: headerhid.} -proc hidExit*() {.cdecl, importc: "hidExit", header: headerhid.} -proc hidReset*() {.cdecl, importc: "hidReset", header: headerhid.} -proc hidGetSessionService*(): ptr Service {.cdecl, importc: "hidGetSessionService", - header: headerhid.} -proc hidGetSharedmemAddr*(): pointer {.cdecl, importc: "hidGetSharedmemAddr", - header: headerhid.} -proc hidSetControllerLayout*(id: HidControllerID; - layoutType: HidControllerLayoutType) {.cdecl, - importc: "hidSetControllerLayout", header: headerhid.} -proc hidGetControllerLayout*(id: HidControllerID): HidControllerLayoutType {. - cdecl, importc: "hidGetControllerLayout", header: headerhid.} -proc hidScanInput*() {.cdecl, importc: "hidScanInput", header: headerhid.} -proc hidKeysHeld*(id: HidControllerID): uint64 {.cdecl, importc: "hidKeysHeld", - header: headerhid.} -proc hidKeysDown*(id: HidControllerID): uint64 {.cdecl, importc: "hidKeysDown", - header: headerhid.} -proc hidKeysUp*(id: HidControllerID): uint64 {.cdecl, importc: "hidKeysUp", - header: headerhid.} -proc hidMouseButtonsHeld*(): uint64 {.cdecl, importc: "hidMouseButtonsHeld", - header: headerhid.} -proc hidMouseButtonsDown*(): uint64 {.cdecl, importc: "hidMouseButtonsDown", - header: headerhid.} -proc hidMouseButtonsUp*(): uint64 {.cdecl, importc: "hidMouseButtonsUp", - header: headerhid.} -proc hidMouseRead*(pos: ptr MousePosition) {.cdecl, importc: "hidMouseRead", - header: headerhid.} -proc hidKeyboardModifierHeld*(modifier: HidKeyboardModifier): bool {.cdecl, - importc: "hidKeyboardModifierHeld", header: headerhid.} -proc hidKeyboardModifierDown*(modifier: HidKeyboardModifier): bool {.cdecl, - importc: "hidKeyboardModifierDown", header: headerhid.} -proc hidKeyboardModifierUp*(modifier: HidKeyboardModifier): bool {.cdecl, - importc: "hidKeyboardModifierUp", header: headerhid.} -proc hidKeyboardHeld*(key: HidKeyboardScancode): bool {.cdecl, - importc: "hidKeyboardHeld", header: headerhid.} -proc hidKeyboardDown*(key: HidKeyboardScancode): bool {.cdecl, - importc: "hidKeyboardDown", header: headerhid.} -proc hidKeyboardUp*(key: HidKeyboardScancode): bool {.cdecl, - importc: "hidKeyboardUp", header: headerhid.} -proc hidTouchCount*(): uint32 {.cdecl, importc: "hidTouchCount", header: headerhid.} -proc hidTouchRead*(pos: ptr touchPosition; point_id: uint32) {.cdecl, - importc: "hidTouchRead", header: headerhid.} -proc hidJoystickRead*(pos: ptr JoystickPosition; id: HidControllerID; - stick: HidControllerJoystick) {.cdecl, - importc: "hidJoystickRead", header: headerhid.} -## / This can be used to check what CONTROLLER_P1_AUTO uses. -## / Returns 0 when CONTROLLER_PLAYER_1 is connected, otherwise returns 1 for handheld-mode. - -proc hidGetHandheldMode*(): bool {.cdecl, importc: "hidGetHandheldMode", - header: headerhid.} -## / Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*. -## / When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example). -## / id must be CONTROLLER_PLAYER_*. - -proc hidSetNpadJoyAssignmentModeSingleByDefault*(id: HidControllerID): Result {. - cdecl, importc: "hidSetNpadJoyAssignmentModeSingleByDefault", - header: headerhid.} -## / Use this if you want to use a pair of joy-cons as a single CONTROLLER_PLAYER_*. Only necessary if you want to use this mode in your application after \ref hidSetNpadJoyAssignmentModeSingleByDefault was used with this pair of joy-cons. -## / Used automatically during app startup/exit for all controllers. -## / When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example). -## / id must be CONTROLLER_PLAYER_*. - -proc hidSetNpadJoyAssignmentModeDual*(id: HidControllerID): Result {.cdecl, - importc: "hidSetNpadJoyAssignmentModeDual", header: headerhid.} -## / Merge two single joy-cons into a dual-mode controller. Use this after \ref hidSetNpadJoyAssignmentModeDual, when \ref hidSetNpadJoyAssignmentModeSingleByDefault was previously used (this includes using this manually at application exit). - -proc hidMergeSingleJoyAsDualJoy*(id0: HidControllerID; id1: HidControllerID): Result {. - cdecl, importc: "hidMergeSingleJoyAsDualJoy", header: headerhid.} -proc hidInitializeVibrationDevices*(VibrationDeviceHandles: ptr uint32; - total_handles: csize; id: HidControllerID; - `type`: HidControllerType): Result {.cdecl, - importc: "hidInitializeVibrationDevices", header: headerhid.} -## / Gets HidVibrationDeviceInfo for the specified VibrationDeviceHandle. - -proc hidGetVibrationDeviceInfo*(VibrationDeviceHandle: ptr uint32; - VibrationDeviceInfo: ptr HidVibrationDeviceInfo): Result {. - cdecl, importc: "hidGetVibrationDeviceInfo", header: headerhid.} -## / Send the VibrationValue to the specified VibrationDeviceHandle. - -proc hidSendVibrationValue*(VibrationDeviceHandle: ptr uint32; - VibrationValue: ptr HidVibrationValue): Result {.cdecl, - importc: "hidSendVibrationValue", header: headerhid.} -## / Gets the current HidVibrationValue for the specified VibrationDeviceHandle. - -proc hidGetActualVibrationValue*(VibrationDeviceHandle: ptr uint32; - VibrationValue: ptr HidVibrationValue): Result {. - cdecl, importc: "hidGetActualVibrationValue", header: headerhid.} -## / Sets whether vibration is allowed, this also affects the config displayed by System Settings. - -proc hidPermitVibration*(flag: bool): Result {.cdecl, - importc: "hidPermitVibration", header: headerhid.} -## / Gets whether vibration is allowed. - -proc hidIsVibrationPermitted*(flag: ptr bool): Result {.cdecl, - importc: "hidIsVibrationPermitted", header: headerhid.} -## / Send VibrationValues[index] to VibrationDeviceHandles[index], where count is the number of entries in the VibrationDeviceHandles/VibrationValues arrays. - -proc hidSendVibrationValues*(VibrationDeviceHandles: ptr uint32; - VibrationValues: ptr HidVibrationValue; count: csize): Result {. - cdecl, importc: "hidSendVibrationValues", header: headerhid.} \ No newline at end of file diff --git a/src/libnx/wrapper/ioctl.nim b/src/libnx/wrapper/ioctl.nim deleted file mode 100644 index fa12486..0000000 --- a/src/libnx/wrapper/ioctl.nim +++ /dev/null @@ -1,64 +0,0 @@ -import strutils -import ospaths -const headerioctl = currentSourcePath().splitPath().head & "/nx/include/switch/gfx/ioctl.h" -## The below defines are based on Linux kernel ioctl.h. - -const - UNV_IOC_NRBITS* = 8 - UNV_IOC_TYPEBITS* = 8 - UNV_IOC_SIZEBITS* = 14 - UNV_IOC_DIRBITS* = 2 - UNV_IOC_NRMASK* = ((1 shl UNV_IOC_NRBITS) - 1) - UNV_IOC_TYPEMASK* = ((1 shl UNV_IOC_TYPEBITS) - 1) - UNV_IOC_SIZEMASK* = ((1 shl UNV_IOC_SIZEBITS) - 1) - UNV_IOC_DIRMASK* = ((1 shl UNV_IOC_DIRBITS) - 1) - UNV_IOC_NRSHIFT* = 0 - UNV_IOC_TYPESHIFT* = (UNV_IOC_NRSHIFT + UNV_IOC_NRBITS) - UNV_IOC_SIZESHIFT* = (UNV_IOC_TYPESHIFT + UNV_IOC_TYPEBITS) - UNV_IOC_DIRSHIFT* = (UNV_IOC_SIZESHIFT + UNV_IOC_SIZEBITS) - -## -## Direction bits. -## - -const - UNV_IOC_NONE* = 0 - UNV_IOC_WRITE* = 1 - UNV_IOC_READ* = 2 - -template UNV_IOC*(dir, `type`, nr, size: untyped): untyped = - (((dir) shl UNV_IOC_DIRSHIFT) or ((`type`) shl UNV_IOC_TYPESHIFT) or - ((nr) shl UNV_IOC_NRSHIFT) or ((size) shl UNV_IOC_SIZESHIFT)) - -## used to create numbers - -template UNV_IO*(`type`, nr: untyped): untyped = - UNV_IOC(UNV_IOC_NONE, (`type`), (nr), 0) - -template UNV_IOR*(`type`, nr, size: untyped): untyped = - UNV_IOC(UNV_IOC_READ, (`type`), (nr), sizeof((size))) - -template UNV_IOW*(`type`, nr, size: untyped): untyped = - UNV_IOC(UNV_IOC_WRITE, (`type`), (nr), sizeof((size))) - -template UNV_IOWR*(`type`, nr, size: untyped): untyped = - UNV_IOC(UNV_IOC_READ or UNV_IOC_WRITE, (`type`), (nr), sizeof((size))) - -## used to decode ioctl numbers.. - -template UNV_IOC_DIR*(nr: untyped): untyped = - (((nr) shr UNV_IOC_DIRSHIFT) and UNV_IOC_DIRMASK) - -template UNV_IOC_TYPE*(nr: untyped): untyped = - (((nr) shr UNV_IOC_TYPESHIFT) and UNV_IOC_TYPEMASK) - -template UNV_IOC_NR*(nr: untyped): untyped = - (((nr) shr UNV_IOC_NRSHIFT) and UNV_IOC_NRMASK) - -template UNV_IOC_SIZE*(nr: untyped): untyped = - (((nr) shr UNV_IOC_SIZESHIFT) and UNV_IOC_SIZEMASK) - -const - DUnv_in* = true - DUnv_out* = true - DUnv_inout* = true diff --git a/src/libnx/wrapper/ipc.nim b/src/libnx/wrapper/ipc.nim deleted file mode 100644 index b52c860..0000000 --- a/src/libnx/wrapper/ipc.nim +++ /dev/null @@ -1,348 +0,0 @@ -import strutils -import ospaths -const headeripc = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/ipc.h" -## * -## @file ipc.h -## @brief Inter-process communication handling -## @author plutoo -## @copyright libnx Authors -## - -import - libnx/wrapper/types, - libnx/wrapper/result, libnx/wrapper/tls, libnx/wrapper/svc - -## / IPC input header magic - -const - SFCI_MAGIC* = 0x49434653 - -## / IPC output header magic - -const - SFCO_MAGIC* = 0x4F434653 - -## / IPC invalid object ID - -const - IPC_INVALID_OBJECT_ID* = uint32.high - -## /@name IPC request building -## /@{ -## / IPC command (request) structure. - -const - IPC_MAX_BUFFERS* = 8 - IPC_MAX_OBJECTS* = 8 - -type - BufferType* {.size: sizeof(cint).} = enum - BufferType_Normal = 0, ## /< Regular buffer. - BufferType_Type1 = 1, ## /< Allows ProcessMemory and shared TransferMemory. - BufferType_Invalid = 2, BufferType_Type3 = 3 - BufferDirection* {.size: sizeof(cint).} = enum - BufferDirection_Send = 0, BufferDirection_Recv = 1, BufferDirection_Exch = 2 - IpcCommandType* {.size: sizeof(cint).} = enum - IpcCommandType_Invalid = 0, IpcCommandType_LegacyRequest = 1, - IpcCommandType_Close = 2, IpcCommandType_LegacyControl = 3, - IpcCommandType_Request = 4, IpcCommandType_Control = 5, - IpcCommandType_RequestWithContext = 6, IpcCommandType_ControlWithContext = 7 - DomainMessageType* {.size: sizeof(cint).} = enum - DomainMessageType_Invalid = 0, DomainMessageType_SendMessage = 1, - DomainMessageType_Close = 2 - - - - - -## / IPC domain message header. - -type - DomainMessageHeader* {.importc: "DomainMessageHeader", header: headeripc, bycopy.} = object - Type* {.importc: "Type".}: uint8 - NumObjectIds* {.importc: "NumObjectIds".}: uint8 - Length* {.importc: "Length".}: uint16 - ThisObjectId* {.importc: "ThisObjectId".}: uint32 - Pad* {.importc: "Pad".}: array[2, uint32] - - IpcCommand* {.importc: "IpcCommand", header: headeripc, bycopy.} = object - NumSend* {.importc: "NumSend".}: csize ## A - NumRecv* {.importc: "NumRecv".}: csize ## B - NumExch* {.importc: "NumExch".}: csize ## W - Buffers* {.importc: "Buffers".}: array[IPC_MAX_BUFFERS, pointer] - BufferSizes* {.importc: "BufferSizes".}: array[IPC_MAX_BUFFERS, csize] - BufferTypes* {.importc: "BufferTypes".}: array[IPC_MAX_BUFFERS, BufferType] - NumStaticIn* {.importc: "NumStaticIn".}: csize ## X - NumStaticOut* {.importc: "NumStaticOut".}: csize ## C - Statics* {.importc: "Statics".}: array[IPC_MAX_BUFFERS, pointer] - StaticSizes* {.importc: "StaticSizes".}: array[IPC_MAX_BUFFERS, csize] - StaticIndices* {.importc: "StaticIndices".}: array[IPC_MAX_BUFFERS, uint8] - SendPid* {.importc: "SendPid".}: bool - NumHandlesCopy* {.importc: "NumHandlesCopy".}: csize - NumHandlesMove* {.importc: "NumHandlesMove".}: csize - Handles* {.importc: "Handles".}: array[IPC_MAX_OBJECTS, Handle] - NumObjectIds* {.importc: "NumObjectIds".}: csize - ObjectIds* {.importc: "ObjectIds".}: array[IPC_MAX_OBJECTS, uint32] - - -## * -## @brief Initializes an IPC command structure. -## @param cmd IPC command structure. -## - -proc ipcInitialize*(cmd: ptr IpcCommand) {.inline, cdecl, importc: "ipcInitialize", - header: headeripc.} -## / IPC buffer descriptor. - -type - IpcBufferDescriptor* {.importc: "IpcBufferDescriptor", header: headeripc, bycopy.} = object - Size* {.importc: "Size".}: uint32 ## /< Size of the buffer. - Addr* {.importc: "Addr".}: uint32 ## /< Lower 32-bits of the address of the buffer - Packed* {.importc: "Packed".}: uint32 ## /< Packed data (including higher bits of the address) - - -## / IPC static send-buffer descriptor. - -type - IpcStaticSendDescriptor* {.importc: "IpcStaticSendDescriptor", header: headeripc, - bycopy.} = object - Packed* {.importc: "Packed".}: uint32 ## /< Packed data (including higher bits of the address) - Addr* {.importc: "Addr".}: uint32 ## /< Lower 32-bits of the address - - -## / IPC static receive-buffer descriptor. - -type - IpcStaticRecvDescriptor* {.importc: "IpcStaticRecvDescriptor", header: headeripc, - bycopy.} = object - Addr* {.importc: "Addr".}: uint32 ## /< Lower 32-bits of the address of the buffer - Packed* {.importc: "Packed".}: uint32 ## /< Packed data (including higher bits of the address) - - -## * -## @brief Adds a buffer to an IPC command structure. -## @param cmd IPC command structure. -## @param buffer Address of the buffer. -## @param size Size of the buffer. -## @param type Buffer type. -## - -proc ipcAddSendBuffer*(cmd: ptr IpcCommand; buffer: pointer; size: csize; - `type`: BufferType) {.inline, cdecl, - importc: "ipcAddSendBuffer", header: headeripc.} -## * -## @brief Adds a receive-buffer to an IPC command structure. -## @param cmd IPC command structure. -## @param buffer Address of the buffer. -## @param size Size of the buffer. -## @param type Buffer type. -## - -proc ipcAddRecvBuffer*(cmd: ptr IpcCommand; buffer: pointer; size: csize; - `type`: BufferType) {.inline, cdecl, - importc: "ipcAddRecvBuffer", header: headeripc.} -## * -## @brief Adds an exchange-buffer to an IPC command structure. -## @param cmd IPC command structure. -## @param buffer Address of the buffer. -## @param size Size of the buffer. -## @param type Buffer type. -## - -proc ipcAddExchBuffer*(cmd: ptr IpcCommand; buffer: pointer; size: csize; - `type`: BufferType) {.inline, cdecl, - importc: "ipcAddExchBuffer", header: headeripc.} -## * -## @brief Adds a static-buffer to an IPC command structure. -## @param cmd IPC command structure. -## @param buffer Address of the buffer. -## @param size Size of the buffer. -## @param index Index of buffer. -## - -proc ipcAddSendStatic*(cmd: ptr IpcCommand; buffer: pointer; size: csize; index: uint8) {. - inline, cdecl, importc: "ipcAddSendStatic", header: headeripc.} -## * -## @brief Adds a static-receive-buffer to an IPC command structure. -## @param cmd IPC command structure. -## @param buffer Address of the buffer. -## @param size Size of the buffer. -## @param index Index of buffer. -## - -proc ipcAddRecvStatic*(cmd: ptr IpcCommand; buffer: pointer; size: csize; index: uint8) {. - inline, cdecl, importc: "ipcAddRecvStatic", header: headeripc.} -## * -## @brief Adds a smart-buffer (buffer + static-buffer pair) to an IPC command structure. -## @param cmd IPC command structure. -## @param ipc_buffer_size IPC buffer size. -## @param buffer Address of the buffer. -## @param size Size of the buffer. -## @param index Index of buffer. -## - -proc ipcAddSendSmart*(cmd: ptr IpcCommand; ipc_buffer_size: csize; buffer: pointer; - size: csize; index: uint8) {.inline, cdecl, - importc: "ipcAddSendSmart", header: headeripc.} -## * -## @brief Adds a smart-receive-buffer (buffer + static-receive-buffer pair) to an IPC command structure. -## @param cmd IPC command structure. -## @param ipc_buffer_size IPC buffer size. -## @param buffer Address of the buffer. -## @param size Size of the buffer. -## @param index Index of buffer. -## - -proc ipcAddRecvSmart*(cmd: ptr IpcCommand; ipc_buffer_size: csize; buffer: pointer; - size: csize; index: uint8) {.inline, cdecl, - importc: "ipcAddRecvSmart", header: headeripc.} -## * -## @brief Tags an IPC command structure to send the PID. -## @param cmd IPC command structure. -## - -proc ipcSendPid*(cmd: ptr IpcCommand) {.inline, cdecl, importc: "ipcSendPid", - header: headeripc.} -## * -## @brief Adds a copy-handle to be sent through an IPC command structure. -## @param cmd IPC command structure. -## @param h Handle to send. -## @remark The receiving process gets a copy of the handle. -## - -proc ipcSendHandleCopy*(cmd: ptr IpcCommand; h: Handle) {.inline, cdecl, - importc: "ipcSendHandleCopy", header: headeripc.} -## * -## @brief Adds a move-handle to be sent through an IPC command structure. -## @param cmd IPC command structure. -## @param h Handle to send. -## @remark The sending process loses ownership of the handle, which is transferred to the receiving process. -## - -proc ipcSendHandleMove*(cmd: ptr IpcCommand; h: Handle) {.inline, cdecl, - importc: "ipcSendHandleMove", header: headeripc.} -## * -## @brief Prepares the header of an IPC command structure. -## @param cmd IPC command structure. -## @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request -## @return Pointer to the raw embedded data structure in the request, ready to be filled out. -## - -proc ipcPrepareHeader*(cmd: ptr IpcCommand; sizeof_raw: csize): pointer {.inline, - cdecl, importc: "ipcPrepareHeader", header: headeripc.} -## * -## @brief Dispatches an IPC request. -## @param session IPC session handle. -## @return Result code. -## - -proc ipcDispatch*(session: Handle): Result {.inline, cdecl, importc: "ipcDispatch", - header: headeripc.} -## /@} -## /@name IPC response parsing -## /@{ -## / IPC parsed command (response) structure. - -type - IpcParsedCommand* {.importc: "IpcParsedCommand", header: headeripc, bycopy.} = object - CommandType* {.importc: "CommandType".}: IpcCommandType ## /< Type of the command - HasPid* {.importc: "HasPid".}: bool ## /< true if the 'Pid' field is filled out. - Pid* {.importc: "Pid".}: uint64 ## /< PID included in the response (only if HasPid is true) - NumHandles* {.importc: "NumHandles".}: csize ## /< Number of handles copied. - Handles* {.importc: "Handles".}: array[IPC_MAX_OBJECTS, Handle] ## /< Handles. - WasHandleCopied* {.importc: "WasHandleCopied".}: array[IPC_MAX_OBJECTS, bool] ## /< true if the handle was moved, false if it was copied. - IsDomainMessage* {.importc: "IsDomainMessage".}: bool ## /< true if the the message is a Domain message. - MessageType* {.importc: "MessageType".}: DomainMessageType ## /< Type of the domain message. - MessageLength* {.importc: "MessageLength".}: uint32 ## /< Size of rawdata (for domain messages). - ThisObjectId* {.importc: "ThisObjectId".}: uint32 ## /< Object ID to call the command on (for domain messages). - NumObjectIds* {.importc: "NumObjectIds".}: csize ## /< Number of object IDs (for domain messages). - ObjectIds* {.importc: "ObjectIds".}: array[IPC_MAX_OBJECTS, uint32] ## /< Object IDs (for domain messages). - NumBuffers* {.importc: "NumBuffers".}: csize ## /< Number of buffers in the response. - Buffers* {.importc: "Buffers".}: array[IPC_MAX_BUFFERS, pointer] ## /< Pointers to the buffers. - BufferSizes* {.importc: "BufferSizes".}: array[IPC_MAX_BUFFERS, csize] ## /< Sizes of the buffers. - BufferTypes* {.importc: "BufferTypes".}: array[IPC_MAX_BUFFERS, BufferType] ## /< Types of the buffers. - BufferDirections* {.importc: "BufferDirections".}: array[IPC_MAX_BUFFERS, - BufferDirection] ## /< Direction of each buffer. - NumStatics* {.importc: "NumStatics".}: csize ## /< Number of statics in the response. - Statics* {.importc: "Statics".}: array[IPC_MAX_BUFFERS, pointer] ## /< Pointers to the statics. - StaticSizes* {.importc: "StaticSizes".}: array[IPC_MAX_BUFFERS, csize] ## /< Sizes of the statics. - StaticIndices* {.importc: "StaticIndices".}: array[IPC_MAX_BUFFERS, uint8] ## /< Indices of the statics. - NumStaticsOut* {.importc: "NumStaticsOut".}: csize ## /< Number of output statics available in the response. - Raw* {.importc: "Raw".}: pointer ## /< Pointer to the raw embedded data structure in the response. - RawWithoutPadding* {.importc: "RawWithoutPadding".}: pointer ## /< Pointer to the raw embedded data structure, without padding. - RawSize* {.importc: "RawSize".}: csize ## /< Size of the raw embedded data. - - -## * -## @brief Parse an IPC command response into an IPC parsed command structure. -## @param IPC parsed command structure to fill in. -## @return Result code. -## - -proc ipcParse*(r: ptr IpcParsedCommand): Result {.inline, cdecl, importc: "ipcParse", - header: headeripc.} -## * -## @brief Queries the size of an IPC pointer buffer. -## @param session IPC session handle. -## @param size Output variable in which to store the size. -## @return Result code. -## - -proc ipcQueryPointerBufferSize*(session: Handle; size: ptr csize): Result {.inline, - cdecl, importc: "ipcQueryPointerBufferSize", header: headeripc.} -## * -## @brief Closes the IPC session with proper clean up. -## @param session IPC session handle. -## @return Result code. -## - -proc ipcCloseSession*(session: Handle): Result {.inline, cdecl, - importc: "ipcCloseSession", header: headeripc.} -## /@} -## /@name IPC domain handling -## /@{ -## * -## @brief Converts an IPC session handle into a domain. -## @param session IPC session handle. -## @param object_id_out Output variable in which to store the object ID. -## @return Result code. -## - -proc ipcConvertSessionToDomain*(session: Handle; object_id_out: ptr uint32): Result {. - inline, cdecl, importc: "ipcConvertSessionToDomain", header: headeripc.} -## * -## @brief Adds an object ID to be sent through an IPC domain command structure. -## @param cmd IPC domain command structure. -## @param object_id Object ID to send. -## - -proc ipcSendObjectId*(cmd: ptr IpcCommand; object_id: uint32) {.inline, cdecl, - importc: "ipcSendObjectId", header: headeripc.} -## * -## @brief Prepares the header of an IPC command structure (domain version). -## @param cmd IPC command structure. -## @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request -## @oaram object_id Domain object ID. -## @return Pointer to the raw embedded data structure in the request, ready to be filled out. -## - -proc ipcPrepareHeaderForDomain*(cmd: ptr IpcCommand; sizeof_raw: csize; object_id: uint32): pointer {. - inline, cdecl, importc: "ipcPrepareHeaderForDomain", header: headeripc.} -## * -## @brief Parse an IPC command response into an IPC parsed command structure (domain version). -## @param IPC parsed command structure to fill in. -## @return Result code. -## - -proc ipcParseForDomain*(r: ptr IpcParsedCommand): Result {.inline, cdecl, - importc: "ipcParseForDomain", header: headeripc.} -## * -## @brief Closes a domain object by ID. -## @param session IPC session handle. -## @param object_id ID of the object to close. -## @return Result code. -## - -proc ipcCloseObjectById*(session: Handle; object_id: uint32): Result {.inline, cdecl, - importc: "ipcCloseObjectById", header: headeripc.} -## /@} diff --git a/src/libnx/wrapper/irs.nim b/src/libnx/wrapper/irs.nim deleted file mode 100644 index 45d5980..0000000 --- a/src/libnx/wrapper/irs.nim +++ /dev/null @@ -1,71 +0,0 @@ -import strutils -import ospaths -const headerirs = currentSourcePath().splitPath().head & "/nx/include/switch/services/irs.h" -import libnx/wrapper/types -import libnx/wrapper/sm -import libnx/wrapper/hid -type - IrsPackedMomentProcessorConfig* {.importc: "IrsPackedMomentProcessorConfig", - header: headerirs, bycopy.} = object - unk_x0* {.importc: "unk_x0".}: uint64 - unk_x8* {.importc: "unk_x8".}: uint8 - unk_x9* {.importc: "unk_x9".}: uint8 - unk_xa* {.importc: "unk_xa".}: uint8 - pad* {.importc: "pad".}: array[5, uint8] - unk_x10* {.importc: "unk_x10".}: uint16 - unk_x12* {.importc: "unk_x12".}: uint32 - unk_x16* {.importc: "unk_x16".}: uint16 - unk_constant* {.importc: "unk_constant".}: uint32 - unk_x1c* {.importc: "unk_x1c".}: uint8 - unk_x1d* {.importc: "unk_x1d".}: uint8 - pad2* {.importc: "pad2".}: array[2, uint8] - - IrsImageTransferProcessorConfig* {.importc: "IrsImageTransferProcessorConfig", - header: headerirs, bycopy.} = object - exposure* {.importc: "exposure".}: uint64 - ir_leds* {.importc: "ir_leds".}: uint32 - digital_gain* {.importc: "digital_gain".}: uint32 - color_invert* {.importc: "color_invert".}: uint8 - pad* {.importc: "pad".}: array[7, uint8] - sensor_res* {.importc: "sensor_res".}: uint32 - - IrsPackedImageTransferProcessorConfig* {. - importc: "IrsPackedImageTransferProcessorConfig", header: headerirs, bycopy.} = object - exposure* {.importc: "exposure".}: uint64 - ir_leds* {.importc: "ir_leds".}: uint8 - digital_gain* {.importc: "digital_gain".}: uint8 - color_invert* {.importc: "color_invert".}: uint8 - pad* {.importc: "pad".}: array[5, uint8] - unk_constant* {.importc: "unk_constant".}: uint32 - sensor_res* {.importc: "sensor_res".}: uint8 - pad2* {.importc: "pad2".}: array[3, uint8] - - IrsImageTransferProcessorState* {.importc: "IrsImageTransferProcessorState", - header: headerirs, bycopy.} = object - unk_x0* {.importc: "unk_x0".}: array[0x00000010, uint8] - - -proc irsInitialize*(): Result {.cdecl, importc: "irsInitialize", header: headerirs.} -proc irsExit*() {.cdecl, importc: "irsExit", header: headerirs.} -proc irsGetSessionService*(): ptr Service {.cdecl, importc: "irsGetSessionService", - header: headerirs.} -proc irsGetSharedmemAddr*(): pointer {.cdecl, importc: "irsGetSharedmemAddr", - header: headerirs.} -proc irsActivateIrsensor*(activate: bool): Result {.cdecl, - importc: "irsActivateIrsensor", header: headerirs.} -proc irsGetIrCameraHandle*(IrCameraHandle: ptr uint32; id: HidControllerID): Result {. - cdecl, importc: "irsGetIrCameraHandle", header: headerirs.} -proc irsRunImageTransferProcessor*(IrCameraHandle: uint32; - config: ptr IrsImageTransferProcessorConfig; - size: csize): Result {.cdecl, - importc: "irsRunImageTransferProcessor", header: headerirs.} -proc irsGetImageTransferProcessorState*(IrCameraHandle: uint32; buffer: pointer; - size: csize; state: ptr IrsImageTransferProcessorState): Result {. - cdecl, importc: "irsGetImageTransferProcessorState", header: headerirs.} -proc irsStopImageProcessor*(IrCameraHandle: uint32): Result {.cdecl, - importc: "irsStopImageProcessor", header: headerirs.} -proc irsSuspendImageProcessor*(IrCameraHandle: uint32): Result {.cdecl, - importc: "irsSuspendImageProcessor", header: headerirs.} -proc irsGetDefaultImageTransferProcessorConfig*( - config: ptr IrsImageTransferProcessorConfig) {.cdecl, - importc: "irsGetDefaultImageTransferProcessorConfig", header: headerirs.} \ No newline at end of file diff --git a/src/libnx/wrapper/jit.nim b/src/libnx/wrapper/jit.nim deleted file mode 100644 index 7f95ab5..0000000 --- a/src/libnx/wrapper/jit.nim +++ /dev/null @@ -1,29 +0,0 @@ -import strutils -import ospaths -const headerjit = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/jit.h" -import libnx/wrapper/types -type - JitType* {.size: sizeof(cint).} = enum - JitType_CodeMemory, JitType_JitMemory - Jit* {.importc: "Jit", header: headerjit, bycopy.} = object - `type`* {.importc: "type".}: JitType - size* {.importc: "size".}: csize - src_addr* {.importc: "src_addr".}: pointer - rx_addr* {.importc: "rx_addr".}: pointer - rw_addr* {.importc: "rw_addr".}: pointer - is_executable* {.importc: "is_executable".}: bool - handle* {.importc: "handle".}: Handle - - - -proc jitCreate*(j: ptr Jit; size: csize): Result {.cdecl, importc: "jitCreate", - header: headerjit.} -proc jitTransitionToWritable*(j: ptr Jit): Result {.cdecl, - importc: "jitTransitionToWritable", header: headerjit.} -proc jitTransitionToExecutable*(j: ptr Jit): Result {.cdecl, - importc: "jitTransitionToExecutable", header: headerjit.} -proc jitClose*(j: ptr Jit): Result {.cdecl, importc: "jitClose", header: headerjit.} -proc jitGetRwAddr*(j: ptr Jit): pointer {.cdecl, importc: "jitGetRwAddr", - header: headerjit.} -proc jitGetRxAddr*(j: ptr Jit): pointer {.cdecl, importc: "jitGetRxAddr", - header: headerjit.} \ No newline at end of file diff --git a/src/libnx/wrapper/ldr.nim b/src/libnx/wrapper/ldr.nim deleted file mode 100644 index 276ac4e..0000000 --- a/src/libnx/wrapper/ldr.nim +++ /dev/null @@ -1,57 +0,0 @@ -import strutils -import ospaths -const headerldr = currentSourcePath().splitPath().head & "/nx/include/switch/services/ldr.h" -import libnx/wrapper/types -import libnx/wrapper/sm -import libnx/wrapper/fs -type - LoaderProgramInfo* {.importc: "LoaderProgramInfo", header: headerldr, bycopy.} = object - main_thread_priority* {.importc: "main_thread_priority".}: uint8 - default_cpu_id* {.importc: "default_cpu_id".}: uint8 - application_type* {.importc: "application_type".}: uint16 - main_thread_stack_size* {.importc: "main_thread_stack_size".}: uint32 - title_id* {.importc: "title_id".}: uint64 - acid_sac_size* {.importc: "acid_sac_size".}: uint32 - aci0_sac_size* {.importc: "aci0_sac_size".}: uint32 - acid_fac_size* {.importc: "acid_fac_size".}: uint32 - aci0_fah_size* {.importc: "aci0_fah_size".}: uint32 - ac_buffer* {.importc: "ac_buffer".}: array[0x000003E0, uint8] - - LoaderNsoInfo* {.importc: "LoaderNsoInfo", header: headerldr, bycopy.} = object - base_address* {.importc: "base_address".}: uint64 - size* {.importc: "size".}: uint64 - build_id* {.importc: "build_id".}: array[0x00000020, uint8] - - -proc ldrShellInitialize*(): Result {.cdecl, importc: "ldrShellInitialize", - header: headerldr.} -proc ldrShellExit*() {.cdecl, importc: "ldrShellExit", header: headerldr.} -proc ldrDmntInitialize*(): Result {.cdecl, importc: "ldrDmntInitialize", - header: headerldr.} -proc ldrDmntExit*() {.cdecl, importc: "ldrDmntExit", header: headerldr.} -proc ldrPmInitialize*(): Result {.cdecl, importc: "ldrPmInitialize", - header: headerldr.} -proc ldrPmExit*() {.cdecl, importc: "ldrPmExit", header: headerldr.} -proc ldrShellAddTitleToLaunchQueue*(tid: uint64; args: pointer; args_size: csize): Result {. - cdecl, importc: "ldrShellAddTitleToLaunchQueue", header: headerldr.} -proc ldrShellClearLaunchQueue*(): Result {.cdecl, - importc: "ldrShellClearLaunchQueue", - header: headerldr.} -proc ldrDmntAddTitleToLaunchQueue*(tid: uint64; args: pointer; args_size: csize): Result {. - cdecl, importc: "ldrDmntAddTitleToLaunchQueue", header: headerldr.} -proc ldrDmntClearLaunchQueue*(): Result {.cdecl, - importc: "ldrDmntClearLaunchQueue", - header: headerldr.} -proc ldrDmntGetNsoInfos*(pid: uint64; out_nso_infos: ptr LoaderNsoInfo; out_size: csize; - num_out: ptr uint32): Result {.cdecl, - importc: "ldrDmntGetNsoInfos", header: headerldr.} -proc ldrPmCreateProcess*(flags: uint64; launch_index: uint64; reslimit_h: Handle; - out_process_h: ptr Handle): Result {.cdecl, - importc: "ldrPmCreateProcess", header: headerldr.} -proc ldrPmGetProgramInfo*(title_id: uint64; storage_id: FsStorageId; - out_program_info: ptr LoaderProgramInfo): Result {.cdecl, - importc: "ldrPmGetProgramInfo", header: headerldr.} -proc ldrPmRegisterTitle*(title_id: uint64; storage_id: FsStorageId; out_index: ptr uint64): Result {. - cdecl, importc: "ldrPmRegisterTitle", header: headerldr.} -proc ldrPmUnregisterTitle*(launch_index: uint64): Result {.cdecl, - importc: "ldrPmUnregisterTitle", header: headerldr.} \ No newline at end of file diff --git a/src/libnx/wrapper/lock.nim b/src/libnx/wrapper/lock.nim deleted file mode 100644 index cfd25d1..0000000 --- a/src/libnx/wrapper/lock.nim +++ /dev/null @@ -1,33 +0,0 @@ -import strutils -import ospaths -const headerlock = "/opt/devkitpro/devkitA64/aarch64-none-elf/include/sys/lock.h" -import libnx/wrapper/types -type - LOCK_T* = int32_t - DUlock_t* {.importc: "__lock_t", header: headerlock, bycopy.} = object - lock* {.importc: "lock".}: LOCK_T - thread_tag* {.importc: "thread_tag".}: uint32_t - counter* {.importc: "counter".}: uint32_t - - LOCK_RECURSIVE_T* = DUlock_t - -proc DUlibc_lock_init*(lock: ptr LOCK_T) {.cdecl, importc: "__libc_lock_init", - header: headerlock.} -proc DUlibc_lock_init_recursive*(lock: ptr LOCK_RECURSIVE_T) {.cdecl, - importc: "__libc_lock_init_recursive", header: headerlock.} -proc DUlibc_lock_close*(lock: ptr LOCK_T) {.cdecl, importc: "__libc_lock_close", - header: headerlock.} -proc DUlibc_lock_close_recursive*(lock: ptr LOCK_RECURSIVE_T) {.cdecl, - importc: "__libc_lock_close_recursive", header: headerlock.} -proc DUlibc_lock_acquire*(lock: ptr LOCK_T) {.cdecl, - importc: "__libc_lock_acquire", header: headerlock.} -proc DUlibc_lock_acquire_recursive*(lock: ptr LOCK_RECURSIVE_T) {.cdecl, - importc: "__libc_lock_acquire_recursive", header: headerlock.} -proc DUlibc_lock_release*(lock: ptr LOCK_T) {.cdecl, - importc: "__libc_lock_release", header: headerlock.} -proc DUlibc_lock_release_recursive*(lock: ptr LOCK_RECURSIVE_T) {.cdecl, - importc: "__libc_lock_release_recursive", header: headerlock.} -proc DUlibc_lock_try_acquire*(lock: ptr LOCK_T): cint {.cdecl, - importc: "__libc_lock_try_acquire", header: headerlock.} -proc DUlibc_lock_try_acquire_recursive*(lock: ptr LOCK_RECURSIVE_T): cint {.cdecl, - importc: "__libc_lock_try_acquire_recursive", header: headerlock.} \ No newline at end of file diff --git a/src/libnx/wrapper/lr.nim b/src/libnx/wrapper/lr.nim deleted file mode 100644 index 72d1800..0000000 --- a/src/libnx/wrapper/lr.nim +++ /dev/null @@ -1,52 +0,0 @@ -import strutils -import ospaths -const headerlr = currentSourcePath().splitPath().head & "/nx/include/switch/services/lr.h" -import libnx/wrapper/types -import libnx/wrapper/sm -import libnx/wrapper/fs -type - LrLocationResolver* {.importc: "LrLocationResolver", header: headerlr, bycopy.} = object - s* {.importc: "s".}: Service - - LrRegisteredLocationResolver* {.importc: "LrRegisteredLocationResolver", - header: headerlr, bycopy.} = object - s* {.importc: "s".}: Service - - -proc lrInitialize*(): Result {.cdecl, importc: "lrInitialize", header: headerlr.} -proc lrExit*() {.cdecl, importc: "lrExit", header: headerlr.} -proc lrOpenLocationResolver*(storage: FsStorageId; `out`: ptr LrLocationResolver): Result {. - cdecl, importc: "lrOpenLocationResolver", header: headerlr.} -proc lrOpenRegisteredLocationResolver*(`out`: ptr LrRegisteredLocationResolver): Result {. - cdecl, importc: "lrOpenRegisteredLocationResolver", header: headerlr.} -proc lrLrResolveProgramPath*(lr: ptr LrLocationResolver; tid: uint64; `out`: cstring): Result {. - cdecl, importc: "lrLrResolveProgramPath", header: headerlr.} -proc lrLrRedirectProgramPath*(lr: ptr LrLocationResolver; tid: uint64; path: cstring): Result {. - cdecl, importc: "lrLrRedirectProgramPath", header: headerlr.} -proc lrLrResolveApplicationControlPath*(lr: ptr LrLocationResolver; tid: uint64; - `out`: cstring): Result {.cdecl, - importc: "lrLrResolveApplicationControlPath", header: headerlr.} -proc lrLrResolveApplicationHtmlDocumentPath*(lr: ptr LrLocationResolver; tid: uint64; - `out`: cstring): Result {.cdecl, - importc: "lrLrResolveApplicationHtmlDocumentPath", - header: headerlr.} -proc lrLrResolveDataPath*(lr: ptr LrLocationResolver; tid: uint64; `out`: cstring): Result {. - cdecl, importc: "lrLrResolveDataPath", header: headerlr.} -proc lrLrRedirectApplicationControlPath*(lr: ptr LrLocationResolver; tid: uint64; - path: cstring): Result {.cdecl, - importc: "lrLrRedirectApplicationControlPath", header: headerlr.} -proc lrLrRedirectApplicationHtmlDocumentPath*(lr: ptr LrLocationResolver; tid: uint64; - path: cstring): Result {.cdecl, - importc: "lrLrRedirectApplicationHtmlDocumentPath", - header: headerlr.} -proc lrLrResolveLegalInformationPath*(lr: ptr LrLocationResolver; tid: uint64; - `out`: cstring): Result {.cdecl, - importc: "lrLrResolveLegalInformationPath", header: headerlr.} -proc lrLrRedirectLegalInformationPath*(lr: ptr LrLocationResolver; tid: uint64; - path: cstring): Result {.cdecl, - importc: "lrLrRedirectLegalInformationPath", header: headerlr.} -proc lrLrRefresh*(lr: ptr LrLocationResolver): Result {.cdecl, - importc: "lrLrRefresh", header: headerlr.} -proc lrRegLrResolveProgramPath*(reg: ptr LrRegisteredLocationResolver; tid: uint64; - `out`: cstring): Result {.cdecl, - importc: "lrRegLrResolveProgramPath", header: headerlr.} \ No newline at end of file diff --git a/src/libnx/wrapper/mutex.nim b/src/libnx/wrapper/mutex.nim deleted file mode 100644 index c327d71..0000000 --- a/src/libnx/wrapper/mutex.nim +++ /dev/null @@ -1,26 +0,0 @@ -import strutils -import ospaths -const headermutex = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/mutex.h" -import libnx/wrapper/lock -import libnx/wrapper/types -type - Mutex* = LOCK_T - RMutex* = LOCK_RECURSIVE_T - -proc mutexInit*(m: ptr Mutex) {.inline, cdecl.} = - m[] = 0 - -proc mutexLock*(m: ptr Mutex) {.cdecl, importc: "mutexLock", header: headermutex.} -proc mutexTryLock*(m: ptr Mutex): bool {.cdecl, importc: "mutexTryLock", - header: headermutex.} -proc mutexUnlock*(m: ptr Mutex) {.cdecl, importc: "mutexUnlock", header: headermutex.} -proc rmutexInit*(m: ptr RMutex) {.inline, cdecl.} = - m.lock = 0 - m.thread_tag = 0 - m.counter = 0 - -proc rmutexLock*(m: ptr RMutex) {.cdecl, importc: "rmutexLock", header: headermutex.} -proc rmutexTryLock*(m: ptr RMutex): bool {.cdecl, importc: "rmutexTryLock", - header: headermutex.} -proc rmutexUnlock*(m: ptr RMutex) {.cdecl, importc: "rmutexUnlock", - header: headermutex.} \ No newline at end of file diff --git a/src/libnx/wrapper/nacp.nim b/src/libnx/wrapper/nacp.nim deleted file mode 100644 index 1ebbb26..0000000 --- a/src/libnx/wrapper/nacp.nim +++ /dev/null @@ -1,38 +0,0 @@ -import strutils -import ospaths -const headernacp = currentSourcePath().splitPath().head & "/nx/include/switch/nacp.h" -import libnx/wrapper/types -type - NacpLanguageEntry* {.importc: "NacpLanguageEntry", header: headernacp, bycopy.} = object - name* {.importc: "name".}: array[0x00000200, char] - author* {.importc: "author".}: array[0x00000100, char] - - NacpStruct* {.importc: "NacpStruct", header: headernacp, bycopy.} = object - lang* {.importc: "lang".}: array[16, NacpLanguageEntry] - x3000_unk* {.importc: "x3000_unk".}: array[0x00000024, uint8] - x3024_unk* {.importc: "x3024_unk".}: uint32 - x3028_unk* {.importc: "x3028_unk".}: uint32 - x302C_unk* {.importc: "x302C_unk".}: uint32 - x3030_unk* {.importc: "x3030_unk".}: uint32 - x3034_unk* {.importc: "x3034_unk".}: uint32 - titleID0* {.importc: "titleID0".}: uint64 - x3040_unk* {.importc: "x3040_unk".}: array[0x00000020, uint8] - version* {.importc: "version".}: array[0x00000010, char] - titleID_DlcBase* {.importc: "titleID_DlcBase".}: uint64 - titleID1* {.importc: "titleID1".}: uint64 - x3080_unk* {.importc: "x3080_unk".}: uint32 - x3084_unk* {.importc: "x3084_unk".}: uint32 - x3088_unk* {.importc: "x3088_unk".}: uint32 - x308C_unk* {.importc: "x308C_unk".}: array[0x00000024, uint8] - titleID2* {.importc: "titleID2".}: uint64 - titleIDs* {.importc: "titleIDs".}: array[7, uint64] - x30F0_unk* {.importc: "x30F0_unk".}: uint32 - x30F4_unk* {.importc: "x30F4_unk".}: uint32 - titleID3* {.importc: "titleID3".}: uint64 - bcatPassphrase* {.importc: "bcatPassphrase".}: array[0x00000040, char] - x3140_unk* {.importc: "x3140_unk".}: array[0x00000EC0, uint8] - - -proc nacpGetLanguageEntry*(nacp: ptr NacpStruct; - langentry: ptr ptr NacpLanguageEntry): Result {.cdecl, - importc: "nacpGetLanguageEntry", header: headernacp.} \ No newline at end of file diff --git a/src/libnx/wrapper/nifm.nim b/src/libnx/wrapper/nifm.nim deleted file mode 100644 index fe24ff0..0000000 --- a/src/libnx/wrapper/nifm.nim +++ /dev/null @@ -1,12 +0,0 @@ -import strutils -import ospaths -const headernifm = currentSourcePath().splitPath().head & "/nx/include/switch/services/nifm.h" -import libnx/wrapper/types -import libnx/wrapper/ipc -import libnx/wrapper/detect -import libnx/wrapper/sm -proc nifmInitialize*(): Result {.cdecl, importc: "nifmInitialize", - header: headernifm.} -proc nifmExit*() {.cdecl, importc: "nifmExit", header: headernifm.} -proc nifmGetCurrentIpAddress*(`out`: ptr uint32): Result {.cdecl, - importc: "nifmGetCurrentIpAddress", header: headernifm.} \ No newline at end of file diff --git a/src/libnx/wrapper/nim.cfg b/src/libnx/wrapper/nim.cfg deleted file mode 100644 index e0e940f..0000000 --- a/src/libnx/wrapper/nim.cfg +++ /dev/null @@ -1,2 +0,0 @@ ---path:"../" ---path:"../../" diff --git a/src/libnx/wrapper/nro.nim b/src/libnx/wrapper/nro.nim deleted file mode 100644 index 85d264c..0000000 --- a/src/libnx/wrapper/nro.nim +++ /dev/null @@ -1,40 +0,0 @@ -import strutils -import ospaths -const headernro = currentSourcePath().splitPath().head & "/nx/include/switch/nro.h" -const - NROHEADER_MAGIC* = 0x0304F524 - NROASSETHEADER_MAGIC* = 0x54455341 - NROASSETHEADER_VERSION* = 0 - -type - NroSegment* {.importc: "NroSegment", header: headernro, bycopy.} = object - file_off* {.importc: "file_off".}: uint32 - size* {.importc: "size".}: uint32 - - NroStart* {.importc: "NroStart", header: headernro, bycopy.} = object - unused* {.importc: "unused".}: uint32 - mod_offset* {.importc: "mod_offset".}: uint32 - padding* {.importc: "padding".}: array[8, uint8] - - NroHeader* {.importc: "NroHeader", header: headernro, bycopy.} = object - magic* {.importc: "magic".}: uint32 - unk1* {.importc: "unk1".}: uint32 - size* {.importc: "size".}: uint32 - unk2* {.importc: "unk2".}: uint32 - segments* {.importc: "segments".}: array[3, NroSegment] - bss_size* {.importc: "bss_size".}: uint32 - unk3* {.importc: "unk3".}: uint32 - build_id* {.importc: "build_id".}: array[0x00000020, uint8] - padding* {.importc: "padding".}: array[0x00000020, uint8] - - NroAssetSection* {.importc: "NroAssetSection", header: headernro, bycopy.} = object - offset* {.importc: "offset".}: uint64 - size* {.importc: "size".}: uint64 - - NroAssetHeader* {.importc: "NroAssetHeader", header: headernro, bycopy.} = object - magic* {.importc: "magic".}: uint32 - version* {.importc: "version".}: uint32 - icon* {.importc: "icon".}: NroAssetSection - nacp* {.importc: "nacp".}: NroAssetSection - romfs* {.importc: "romfs".}: NroAssetSection - diff --git a/src/libnx/wrapper/ns.nim b/src/libnx/wrapper/ns.nim deleted file mode 100644 index b9705da..0000000 --- a/src/libnx/wrapper/ns.nim +++ /dev/null @@ -1,36 +0,0 @@ -import strutils -import ospaths -const headerns = currentSourcePath().splitPath().head & "/nx/include/switch/services/ns.h" -import libnx/wrapper/types -import libnx/wrapper/nacp -import libnx/wrapper/fs -type - NsApplicationControlData* {.importc: "NsApplicationControlData", - header: headerns, bycopy.} = object - nacp* {.importc: "nacp".}: NacpStruct - icon* {.importc: "icon".}: array[0x00020000, uint8] - - -proc nsInitialize*(): Result {.cdecl, importc: "nsInitialize", header: headerns.} -proc nsExit*() {.cdecl, importc: "nsExit", header: headerns.} -proc nsGetApplicationControlData*(flag: uint8; titleID: uint64; - buffer: ptr NsApplicationControlData; size: csize; - actual_size: ptr csize): Result {.cdecl, - importc: "nsGetApplicationControlData", header: headerns.} -proc nsGetTotalSpaceSize*(storage_id: FsStorageId; size: ptr uint64): Result {.cdecl, - importc: "nsGetTotalSpaceSize", header: headerns.} -proc nsGetFreeSpaceSize*(storage_id: FsStorageId; size: ptr uint64): Result {.cdecl, - importc: "nsGetFreeSpaceSize", header: headerns.} -proc nsvmInitialize*(): Result {.cdecl, importc: "nsvmInitialize", header: headerns.} -proc nsvmExit*() {.cdecl, importc: "nsvmExit", header: headerns.} -proc nsvmNeedsUpdateVulnerability*(`out`: ptr bool): Result {.cdecl, - importc: "nsvmNeedsUpdateVulnerability", header: headerns.} -proc nsvmGetSafeSystemVersion*(`out`: ptr uint16): Result {.cdecl, - importc: "nsvmGetSafeSystemVersion", header: headerns.} -proc nsdevInitialize*(): Result {.cdecl, importc: "nsdevInitialize", - header: headerns.} -proc nsdevExit*() {.cdecl, importc: "nsdevExit", header: headerns.} -proc nsdevTerminateProcess*(pid: uint64): Result {.cdecl, - importc: "nsdevTerminateProcess", header: headerns.} -proc nsdevTerminateProgram*(tid: uint64): Result {.cdecl, - importc: "nsdevTerminateProgram", header: headerns.} \ No newline at end of file diff --git a/src/libnx/wrapper/nv.nim b/src/libnx/wrapper/nv.nim deleted file mode 100644 index af129f6..0000000 --- a/src/libnx/wrapper/nv.nim +++ /dev/null @@ -1,22 +0,0 @@ -import strutils -import ospaths -const headernv = currentSourcePath().splitPath().head & "/nx/include/switch/services/nv.h" -import libnx/wrapper/types -type - nvServiceType* {.size: sizeof(cint).} = enum - NVSERVTYPE_Default = -1, NVSERVTYPE_Application = 0, NVSERVTYPE_Applet = 1, - NVSERVTYPE_Sysmodule = 2, NVSERVTYPE_T = 3 - - -proc nvInitialize*(servicetype: nvServiceType; sharedmem_size: csize): Result {. - cdecl, importc: "nvInitialize", header: headernv.} -proc nvExit*() {.cdecl, importc: "nvExit", header: headernv.} -proc nvOpen*(fd: ptr uint32; devicepath: cstring): Result {.cdecl, importc: "nvOpen", - header: headernv.} -proc nvIoctl*(fd: uint32; request: uint32; argp: pointer): Result {.cdecl, - importc: "nvIoctl", header: headernv.} -proc nvClose*(fd: uint32): Result {.cdecl, importc: "nvClose", header: headernv.} -proc nvQueryEvent*(fd: uint32; event_id: uint32; handle_out: ptr Handle): Result {.cdecl, - importc: "nvQueryEvent", header: headernv.} -proc nvConvertError*(rc: cint): Result {.cdecl, importc: "nvConvertError", - header: headernv.} \ No newline at end of file diff --git a/src/libnx/wrapper/nvgfx.nim b/src/libnx/wrapper/nvgfx.nim deleted file mode 100644 index b1116e2..0000000 --- a/src/libnx/wrapper/nvgfx.nim +++ /dev/null @@ -1,13 +0,0 @@ -import strutils -import ospaths -const headernvgfx = currentSourcePath().splitPath().head & "/nx/include/switch/gfx/nvgfx.h" -import libnx/wrapper/types -proc nvgfxInitialize*(): Result {.cdecl, importc: "nvgfxInitialize", - header: headernvgfx.} -proc nvgfxExit*() {.cdecl, importc: "nvgfxExit", header: headernvgfx.} -proc nvgfxEventWait*(syncpt_id: uint32; threshold: uint32; timeout: s32): Result {.cdecl, - importc: "nvgfxEventWait", header: headernvgfx.} -proc nvgfxSubmitGpfifo*(): Result {.cdecl, importc: "nvgfxSubmitGpfifo", - header: headernvgfx.} -proc nvgfxGetFramebuffer*(buffer: ptr ptr uint8; size: ptr csize): Result {.cdecl, - importc: "nvgfxGetFramebuffer", header: headernvgfx.} \ No newline at end of file diff --git a/src/libnx/wrapper/nvioctl.nim b/src/libnx/wrapper/nvioctl.nim deleted file mode 100644 index 7138463..0000000 --- a/src/libnx/wrapper/nvioctl.nim +++ /dev/null @@ -1,138 +0,0 @@ -import strutils -import ospaths -const headernvioctl = currentSourcePath().splitPath().head & "/nx/include/switch/gfx/nvioctl.h" -import libnx/wrapper/types -type - gpu_characteristics* {.importc: "gpu_characteristics", header: headernvioctl, - bycopy.} = object - arch* {.importc: "arch".}: uint32 - impl* {.importc: "impl".}: uint32 - rev* {.importc: "rev".}: uint32 - num_gpc* {.importc: "num_gpc".}: uint32 - L2_cache_size* {.importc: "L2_cache_size".}: uint64 - on_board_video_memory_size* {.importc: "on_board_video_memory_size".}: uint64 - num_tpc_per_gpc* {.importc: "num_tpc_per_gpc".}: uint32 - bus_type* {.importc: "bus_type".}: uint32 - big_page_size* {.importc: "big_page_size".}: uint32 - compression_page_size* {.importc: "compression_page_size".}: uint32 - pde_coverage_bit_count* {.importc: "pde_coverage_bit_count".}: uint32 - available_big_page_sizes* {.importc: "available_big_page_sizes".}: uint32 - gpc_mask* {.importc: "gpc_mask".}: uint32 - sm_arch_sm_version* {.importc: "sm_arch_sm_version".}: uint32 - sm_arch_spa_version* {.importc: "sm_arch_spa_version".}: uint32 - sm_arch_warp_count* {.importc: "sm_arch_warp_count".}: uint32 - gpu_va_bit_count* {.importc: "gpu_va_bit_count".}: uint32 - reserved* {.importc: "reserved".}: uint32 - flags* {.importc: "flags".}: uint64 - twod_class* {.importc: "twod_class".}: uint32 - threed_class* {.importc: "threed_class".}: uint32 - compute_class* {.importc: "compute_class".}: uint32 - gpfifo_class* {.importc: "gpfifo_class".}: uint32 - inline_to_memory_class* {.importc: "inline_to_memory_class".}: uint32 - dma_copy_class* {.importc: "dma_copy_class".}: uint32 - max_fbps_count* {.importc: "max_fbps_count".}: uint32 - fbp_en_mask* {.importc: "fbp_en_mask".}: uint32 - max_ltc_per_fbp* {.importc: "max_ltc_per_fbp".}: uint32 - max_lts_per_ltc* {.importc: "max_lts_per_ltc".}: uint32 - max_tex_per_tpc* {.importc: "max_tex_per_tpc".}: uint32 - max_gpc_count* {.importc: "max_gpc_count".}: uint32 - rop_l2_en_mask_0* {.importc: "rop_l2_en_mask_0".}: uint32 - rop_l2_en_mask_1* {.importc: "rop_l2_en_mask_1".}: uint32 - chipname* {.importc: "chipname".}: uint64 - gr_compbit_store_base_hw* {.importc: "gr_compbit_store_base_hw".}: uint64 - - nvioctl_va_region* {.importc: "nvioctl_va_region", header: headernvioctl, bycopy.} = object - offset* {.importc: "offset".}: uint64 - page_size* {.importc: "page_size".}: uint32 - pad* {.importc: "pad".}: uint32 - pages* {.importc: "pages".}: uint64 - - nvioctl_l2_state* {.importc: "nvioctl_l2_state", header: headernvioctl, bycopy.} = object - mask* {.importc: "mask".}: uint32 - flush* {.importc: "flush".}: uint32 - - nvioctl_fence* {.importc: "nvioctl_fence", header: headernvioctl, bycopy.} = object - id* {.importc: "id".}: uint32 - value* {.importc: "value".}: uint32 - - nvioctl_gpfifo_entry* {.importc: "nvioctl_gpfifo_entry", header: headernvioctl, - bycopy.} = object - entry0* {.importc: "entry0".}: uint32 - entry1* {.importc: "entry1".}: uint32 - - nvioctl_channel_obj_classnum* {.size: sizeof(cint).} = enum - NvChannelObjClassNum_2D = 0x0000902D, NvChannelObjClassNum_Kepler = 0x0000A140, - NvChannelObjClassNum_ChannelGpfifo = 0x0000B06F, - NvChannelObjClassNum_DMA = 0x0000B0B5, NvChannelObjClassNum_3D = 0x0000B197, - NvChannelObjClassNum_Compute = 0x0000B1C0 - - -type - nvioctl_channel_priority* {.size: sizeof(cint).} = enum - NvChannelPriority_Low = 0x00000032, NvChannelPriority_Medium = 0x00000064, - NvChannelPriority_High = 0x00000096 - - -proc nvioctlNvhostCtrl_EventSignal*(fd: uint32; event_id: uint32): Result {.cdecl, - importc: "nvioctlNvhostCtrl_EventSignal", header: headernvioctl.} -proc nvioctlNvhostCtrl_EventWait*(fd: uint32; syncpt_id: uint32; threshold: uint32; - timeout: s32; event_id: uint32; `out`: ptr uint32): Result {. - cdecl, importc: "nvioctlNvhostCtrl_EventWait", header: headernvioctl.} -proc nvioctlNvhostCtrl_EventRegister*(fd: uint32; event_id: uint32): Result {.cdecl, - importc: "nvioctlNvhostCtrl_EventRegister", header: headernvioctl.} -proc nvioctlNvhostCtrlGpu_ZCullGetCtxSize*(fd: uint32; `out`: ptr uint32): Result {.cdecl, - importc: "nvioctlNvhostCtrlGpu_ZCullGetCtxSize", header: headernvioctl.} -proc nvioctlNvhostCtrlGpu_ZCullGetInfo*(fd: uint32; `out`: array[40 shr 2, uint32]): Result {. - cdecl, importc: "nvioctlNvhostCtrlGpu_ZCullGetInfo", header: headernvioctl.} -proc nvioctlNvhostCtrlGpu_GetCharacteristics*(fd: uint32; - `out`: ptr gpu_characteristics): Result {.cdecl, - importc: "nvioctlNvhostCtrlGpu_GetCharacteristics", header: headernvioctl.} -proc nvioctlNvhostCtrlGpu_GetTpcMasks*(fd: uint32; inval: uint32; - `out`: array[24 shr 2, uint32]): Result {.cdecl, - importc: "nvioctlNvhostCtrlGpu_GetTpcMasks", header: headernvioctl.} -proc nvioctlNvhostCtrlGpu_GetL2State*(fd: uint32; `out`: ptr nvioctl_l2_state): Result {. - cdecl, importc: "nvioctlNvhostCtrlGpu_GetL2State", header: headernvioctl.} -proc nvioctlNvhostAsGpu_BindChannel*(fd: uint32; channel_fd: uint32): Result {.cdecl, - importc: "nvioctlNvhostAsGpu_BindChannel", header: headernvioctl.} -proc nvioctlNvhostAsGpu_AllocSpace*(fd: uint32; pages: uint32; page_size: uint32; flags: uint32; - align: uint64; offset: ptr uint64): Result {.cdecl, - importc: "nvioctlNvhostAsGpu_AllocSpace", header: headernvioctl.} -proc nvioctlNvhostAsGpu_MapBufferEx*(fd: uint32; flags: uint32; kind: uint32; nvmap_handle: uint32; - page_size: uint32; buffer_offset: uint64; - mapping_size: uint64; input_offset: uint64; - offset: ptr uint64): Result {.cdecl, - importc: "nvioctlNvhostAsGpu_MapBufferEx", header: headernvioctl.} -proc nvioctlNvhostAsGpu_GetVARegions*(fd: uint32; regions: array[2, nvioctl_va_region]): Result {. - cdecl, importc: "nvioctlNvhostAsGpu_GetVARegions", header: headernvioctl.} -proc nvioctlNvhostAsGpu_InitializeEx*(fd: uint32; big_page_size: uint32; flags: uint32): Result {. - cdecl, importc: "nvioctlNvhostAsGpu_InitializeEx", header: headernvioctl.} -proc nvioctlNvmap_Create*(fd: uint32; size: uint32; nvmap_handle: ptr uint32): Result {.cdecl, - importc: "nvioctlNvmap_Create", header: headernvioctl.} -proc nvioctlNvmap_FromId*(fd: uint32; id: uint32; nvmap_handle: ptr uint32): Result {.cdecl, - importc: "nvioctlNvmap_FromId", header: headernvioctl.} -proc nvioctlNvmap_Alloc*(fd: uint32; nvmap_handle: uint32; heapmask: uint32; flags: uint32; - align: uint32; kind: uint8; `addr`: pointer): Result {.cdecl, - importc: "nvioctlNvmap_Alloc", header: headernvioctl.} -proc nvioctlNvmap_GetId*(fd: uint32; nvmap_handle: uint32; id: ptr uint32): Result {.cdecl, - importc: "nvioctlNvmap_GetId", header: headernvioctl.} -proc nvioctlChannel_SetNvmapFd*(fd: uint32; nvmap_fd: uint32): Result {.cdecl, - importc: "nvioctlChannel_SetNvmapFd", header: headernvioctl.} -proc nvioctlChannel_SubmitGpfifo*(fd: uint32; entries: ptr nvioctl_gpfifo_entry; - num_entries: uint32; flags: uint32; - fence_out: ptr nvioctl_fence): Result {.cdecl, - importc: "nvioctlChannel_SubmitGpfifo", header: headernvioctl.} -proc nvioctlChannel_AllocObjCtx*(fd: uint32; class_num: uint32; flags: uint32): Result {.cdecl, - importc: "nvioctlChannel_AllocObjCtx", header: headernvioctl.} -proc nvioctlChannel_ZCullBind*(fd: uint32; gpu_va: uint64; mode: uint32): Result {.cdecl, - importc: "nvioctlChannel_ZCullBind", header: headernvioctl.} -proc nvioctlChannel_SetErrorNotifier*(fd: uint32; offset: uint64; size: uint64; - nvmap_handle: uint32): Result {.cdecl, - importc: "nvioctlChannel_SetErrorNotifier", header: headernvioctl.} -proc nvioctlChannel_SetPriority*(fd: uint32; priority: uint32): Result {.cdecl, - importc: "nvioctlChannel_SetPriority", header: headernvioctl.} -proc nvioctlChannel_AllocGpfifoEx2*(fd: uint32; num_entries: uint32; flags: uint32; unk0: uint32; - unk1: uint32; unk2: uint32; unk3: uint32; - fence_out: ptr nvioctl_fence): Result {.cdecl, - importc: "nvioctlChannel_AllocGpfifoEx2", header: headernvioctl.} -proc nvioctlChannel_SetUserData*(fd: uint32; `addr`: pointer): Result {.cdecl, - importc: "nvioctlChannel_SetUserData", header: headernvioctl.} \ No newline at end of file diff --git a/src/libnx/wrapper/nx/include/switch.h b/src/libnx/wrapper/nx/include/switch.h deleted file mode 100644 index 2ed024d..0000000 --- a/src/libnx/wrapper/nx/include/switch.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @file switch.h - * @brief Central Switch header. Includes all others. - * @copyright libnx Authors - */ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "switch/types.h" -#include "switch/result.h" - -#include "switch/nro.h" -#include "switch/nacp.h" - -#include "switch/arm/tls.h" -#include "switch/arm/cache.h" - -#include "switch/kernel/svc.h" -#include "switch/kernel/tmem.h" -#include "switch/kernel/shmem.h" -#include "switch/kernel/mutex.h" -#include "switch/kernel/rwlock.h" -#include "switch/kernel/condvar.h" -#include "switch/kernel/thread.h" -#include "switch/kernel/virtmem.h" -#include "switch/kernel/detect.h" -#include "switch/kernel/random.h" -#include "switch/kernel/jit.h" -#include "switch/kernel/ipc.h" - -#include "switch/services/sm.h" -#include "switch/services/smm.h" -#include "switch/services/fs.h" -#include "switch/services/fsldr.h" -#include "switch/services/fspr.h" -#include "switch/services/acc.h" -#include "switch/services/apm.h" -#include "switch/services/applet.h" -#include "switch/services/audin.h" -#include "switch/services/audout.h" -#include "switch/services/csrng.h" -//#include "switch/services/bsd.h" Use switch/runtime/devices/socket.h instead -#include "switch/services/fatal.h" -#include "switch/services/time.h" -#include "switch/services/usb.h" -#include "switch/services/hid.h" -#include "switch/services/irs.h" -#include "switch/services/pl.h" -#include "switch/services/vi.h" -#include "switch/services/nv.h" -#include "switch/services/nifm.h" -#include "switch/services/ns.h" -#include "switch/services/ldr.h" -#include "switch/services/pm.h" -#include "switch/services/set.h" -#include "switch/services/lr.h" -#include "switch/services/spl.h" - -#include "switch/gfx/gfx.h" -#include "switch/gfx/binder.h" -#include "switch/gfx/parcel.h" -#include "switch/gfx/buffer_producer.h" -#include "switch/gfx/ioctl.h" -#include "switch/gfx/nvioctl.h" -#include "switch/gfx/nvgfx.h" - -#include "switch/runtime/env.h" -#include "switch/runtime/nxlink.h" - -#include "switch/runtime/util/utf.h" - -#include "switch/runtime/devices/console.h" -#include "switch/runtime/devices/usb_comms.h" -#include "switch/runtime/devices/fs_dev.h" -#include "switch/runtime/devices/romfs_dev.h" -#include "switch/runtime/devices/socket.h" - -#ifdef __cplusplus -} -#endif - diff --git a/src/libnx/wrapper/nx/include/switch/arm/atomics.h b/src/libnx/wrapper/nx/include/switch/arm/atomics.h deleted file mode 100644 index c671423..0000000 --- a/src/libnx/wrapper/nx/include/switch/arm/atomics.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "../types.h" - -static inline u32 atomicIncrement32(u32* p) { - return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST); -} - -static inline u32 atomicDecrement32(u32* p) { - return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST); -} - -static inline u64 atomicIncrement64(u64* p) { - return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST); -} - -static inline u64 atomicDecrement64(u64* p) { - return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST); -} diff --git a/src/libnx/wrapper/nx/include/switch/arm/cache.h b/src/libnx/wrapper/nx/include/switch/arm/cache.h deleted file mode 100644 index a97fbbe..0000000 --- a/src/libnx/wrapper/nx/include/switch/arm/cache.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file cache.h - * @brief AArch64 cache operations. - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/** - * @brief Performs a data cache flush on the specified buffer. - * @param addr Address of the buffer. - * @param size Size of the buffer, in bytes. - * @remarks Cache flush is defined as Clean + Invalidate. - * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). - */ -void armDCacheFlush(void* addr, size_t size); - -/** - * @brief Performs a data cache clean on the specified buffer. - * @param addr Address of the buffer. - * @param size Size of the buffer, in bytes. - * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). - */ -void armDCacheClean(void* addr, size_t size); - -/** - * @brief Performs an instruction cache invalidation clean on the specified buffer. - * @param addr Address of the buffer. - * @param size Size of the buffer, in bytes. - * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). - */ -void armICacheInvalidate(void* addr, size_t size); - -/** - * @brief Performs a data cache zeroing operation on the specified buffer. - * @param addr Address of the buffer. - * @param size Size of the buffer, in bytes. - * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). - */ -void armDCacheZero(void* addr, size_t size); diff --git a/src/libnx/wrapper/nx/include/switch/arm/tls.h b/src/libnx/wrapper/nx/include/switch/arm/tls.h deleted file mode 100644 index e24ac85..0000000 --- a/src/libnx/wrapper/nx/include/switch/arm/tls.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @file tls.h - * @brief AArch64 thread local storage. - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/** - * @brief Gets the thread local storage buffer. - * @return The thread local storage buffer. - */ -static inline void* armGetTls(void) { - void* ret; - __asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret)); - return ret; -} diff --git a/src/libnx/wrapper/nx/include/switch/audio/audio.h b/src/libnx/wrapper/nx/include/switch/audio/audio.h deleted file mode 100644 index cbea7cb..0000000 --- a/src/libnx/wrapper/nx/include/switch/audio/audio.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @file audio.h - * @brief Global audio service. - * @author hexkyz - * @copyright libnx Authors - */ -#pragma once - -#include "../types.h" - -typedef enum { - PcmFormat_Invalid = 0, - PcmFormat_Int8 = 1, - PcmFormat_Int16 = 2, - PcmFormat_Int24 = 3, - PcmFormat_Int32 = 4, - PcmFormat_Float = 5, - PcmFormat_Adpcm = 6, -} PcmFormat; diff --git a/src/libnx/wrapper/nx/include/switch/gfx/binder.h b/src/libnx/wrapper/nx/include/switch/gfx/binder.h deleted file mode 100644 index 44e87cd..0000000 --- a/src/libnx/wrapper/nx/include/switch/gfx/binder.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "../types.h" - -#define BINDER_FIRST_CALL_TRANSACTION 0x1 - -typedef struct { - bool created; - bool initialized; - Handle sessionHandle; - s32 id; - Handle nativeHandle; - size_t ipcBufferSize; - bool hasTransactAuto; -} Binder; - -// binderExitSession will not close the sessionHandle since it's user-specified via binderCreateSession and may be used elsewhere. -void binderCreateSession(Binder *session, Handle sessionHandle, s32 ID); -Result binderInitSession(Binder *session, u32 unk0); -void binderExitSession(Binder *session); - -Result binderTransactParcel( - Binder *session, u32 code, - void* parcel_data, size_t parcel_data_size, - void* parcel_reply, size_t parcel_reply_size, - u32 flags); - -Result binderAdjustRefcount(Binder *session, s32 addval, s32 type); -Result binderGetNativeHandle(Binder *session, u32 unk0, Handle *handle_out); - diff --git a/src/libnx/wrapper/nx/include/switch/gfx/buffer_producer.h b/src/libnx/wrapper/nx/include/switch/gfx/buffer_producer.h deleted file mode 100644 index e6a8a75..0000000 --- a/src/libnx/wrapper/nx/include/switch/gfx/buffer_producer.h +++ /dev/null @@ -1,151 +0,0 @@ -#pragma once -#include "../gfx/nvioctl.h" - -typedef struct { - u32 is_valid; - nvioctl_fence nv_fences[4]; -} PACKED bufferProducerFence; - -typedef struct { - s32 left; - s32 top; - s32 right; - s32 bottom; -} PACKED bufferProducerRect; - -typedef struct { - s64 timestamp; - s32 isAutoTimestamp; - bufferProducerRect crop; - s32 scalingMode; - u32 transform;//See the NATIVE_WINDOW_TRANSFORM_* enums. - u32 stickyTransform; - u32 unk[2]; - bufferProducerFence fence; -} PACKED bufferProducerQueueBufferInput; - -typedef struct { - u32 width; - u32 height; - u32 transformHint; - u32 numPendingBuffers; -} PACKED bufferProducerQueueBufferOutput; - -typedef struct { - u32 magic; - u32 width; - u32 height; - u32 stride; - u32 format; - u32 usage; - - u32 pid; - u32 refcount; - - u32 numFds; - u32 numInts; - - struct {//Actual size is numFds*4 + numInts*4. - u32 unk_x0; - u32 nvmap_handle0; - u32 unk_x8; - u32 unk_xc; - u32 unk_x10; - u32 unk_x14; - u32 unk_x18; - u32 unk_x1c; - u32 unk_x20; - u32 width_unk0; - u32 buffer_size0; - u32 unk_x2c; - u32 unk_x30; - u32 width_unk1; - u32 height_unk; - u32 flags; - u32 unk_x40; - u32 unk_x44; - u32 byte_stride; - u32 nvmap_handle1; - u32 buffer_offset; - u32 unk_x54; - u32 unk_x58; - u32 unk_x5c; - u32 unk_x60; - u32 unk_x64; - u32 unk_x68; - u32 buffer_size1; - u32 unk_x70[0x33];//Normally all-zero. - u64 timestamp; - } PACKED data; -} PACKED bufferProducerGraphicBuffer; - -//From Android window.h. -/* attributes queriable with query() */ -enum { - NATIVE_WINDOW_WIDTH = 0, - NATIVE_WINDOW_HEIGHT = 1, - NATIVE_WINDOW_FORMAT = 2, -//... -// NATIVE_WINDOW_DEFAULT_WIDTH = 6, //These two return invalid data. -// NATIVE_WINDOW_DEFAULT_HEIGHT = 7, -}; - -//From Android window.h. -/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ -enum { - //... - /* Buffers will be queued after being filled using the CPU - */ - NATIVE_WINDOW_API_CPU = 2, - //... -}; - -//From Android hardware.h. - -/** - * Transformation definitions - * - * IMPORTANT NOTE: - * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. - * - */ - -enum { - /* flip source image horizontally (around the vertical axis) */ - HAL_TRANSFORM_FLIP_H = 0x01, - /* flip source image vertically (around the horizontal axis)*/ - HAL_TRANSFORM_FLIP_V = 0x02, - /* rotate source image 90 degrees clockwise */ - HAL_TRANSFORM_ROT_90 = 0x04, - /* rotate source image 180 degrees */ - HAL_TRANSFORM_ROT_180 = 0x03, - /* rotate source image 270 degrees clockwise */ - HAL_TRANSFORM_ROT_270 = 0x07, -}; - -//From Android window.h. -/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ -enum { - /* flip source image horizontally */ - NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, - /* flip source image vertically */ - NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, - /* rotate source image 90 degrees clock-wise */ - NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, - /* rotate source image 180 degrees */ - NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, - /* rotate source image 270 degrees clock-wise */ - NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, -}; - -Result bufferProducerInitialize(Binder *session); -void bufferProducerExit(void); - -Result bufferProducerRequestBuffer(s32 bufferIdx, bufferProducerGraphicBuffer *buf); -Result bufferProducerDequeueBuffer(bool async, u32 width, u32 height, s32 format, u32 usage, s32 *buf, bufferProducerFence *fence); -Result bufferProducerDetachBuffer(s32 slot); -Result bufferProducerQueueBuffer(s32 buf, bufferProducerQueueBufferInput *input, bufferProducerQueueBufferOutput *output); -Result bufferProducerQuery(s32 what, s32* value); -Result bufferProducerConnect(s32 api, bool producerControlledByApp, bufferProducerQueueBufferOutput *output); -Result bufferProducerDisconnect(s32 api); -Result bufferProducerGraphicBufferInit(s32 buf, bufferProducerGraphicBuffer *input); diff --git a/src/libnx/wrapper/nx/include/switch/gfx/gfx.h b/src/libnx/wrapper/nx/include/switch/gfx/gfx.h deleted file mode 100644 index 590f909..0000000 --- a/src/libnx/wrapper/nx/include/switch/gfx/gfx.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file gfx.h - * @brief High-level graphics API. - * This API exposes a framebuffer (technically speaking, a windowbuffer) to be used for drawing graphics. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/// Converts red, green, blue, and alpha components to packed RGBA8. -#define RGBA8(r,g,b,a) (((r)&0xff)|(((g)&0xff)<<8)|(((b)&0xff)<<16)|(((a)&0xff)<<24)) - -/// Same as \ref RGBA8 except with alpha=0xff. -#define RGBA8_MAXALPHA(r,g,b) RGBA8(r,g,b,0xff) - -/// GfxMode set by \ref gfxSetMode. The default is GfxMode_LinearDouble. Note that the text-console (see console.h) sets this to GfxMode_TiledDouble. -typedef enum -{ - GfxMode_TiledSingle, ///< Single-buffering with raw tiled (block-linear) framebuffer. - GfxMode_TiledDouble, ///< Double-buffering with raw tiled (block-linear) framebuffer. - GfxMode_LinearDouble ///< Double-buffering with linear framebuffer, which is transferred to the actual framebuffer by \ref gfxFlushBuffers(). -} GfxMode; - -/// Framebuffer pixel-format is RGBA8888, there's no known way to change this. - -/** - * @brief Initializes the graphics subsystem. - * @warning Do not use \ref viInitialize when using this function. - */ -void gfxInitDefault(void); - -/** - * @brief Uninitializes the graphics subsystem. - * @warning Do not use \ref viExit when using this function. - */ -void gfxExit(void); - -/** - * @brief Sets the resolution to be used when initializing the graphics subsystem. - * @param[in] width Horizontal resolution, in pixels. - * @param[in] height Vertical resolution, in pixels. - * @note The default resolution is 720p. - * @note This can only be used before calling \ref gfxInitDefault, this will use \ref fatalSimple otherwise. If the input is 0, the default resolution will be used during \ref gfxInitDefault. This sets the maximum resolution for the framebuffer, used during \ref gfxInitDefault. This is also used as the current resolution when crop isn't set. The width/height are reset to the default when \ref gfxExit is used. - * @note Normally you should only use this when you need a maximum resolution larger than the default, see above. - * @note The width and height are aligned to 4. - */ -void gfxInitResolution(u32 width, u32 height); - -/// Wrapper for \ref gfxInitResolution with resolution=1080p. Use this if you want to support 1080p or >720p in docked-mode. -void gfxInitResolutionDefault(void); - -/// Configure framebuffer crop, by default crop is all-zero. Use all-zero input to reset to default. \ref gfxExit resets this to the default. -/// When the input is invalid this returns without changing the crop data, this includes the input values being larger than the framebuf width/height. -/// This will update the display width/height returned by \ref gfxGetFramebuffer, with that width/height being reset to the default when required. -/// \ref gfxGetFramebufferDisplayOffset uses absolute x/y, it will not adjust for non-zero crop left/top. -/// The new crop config will not take affect with double-buffering disabled. When used during frame-drawing, this should be called before \ref gfxGetFramebuffer. -/// The right and bottom params are aligned to 4. -void gfxConfigureCrop(s32 left, s32 top, s32 right, s32 bottom); - -/// Wrapper for \ref gfxConfigureCrop. Use this to set the resolution, within the bounds of the maximum resolution. Use all-zero input to reset to default. -void gfxConfigureResolution(s32 width, s32 height); - -/// If enabled, \ref gfxConfigureResolution will be used with the input resolution for the current OperationMode. Then \ref gfxConfigureResolution will automatically be used with the specified resolution each time OperationMode changes. -void gfxConfigureAutoResolution(bool enable, s32 handheld_width, s32 handheld_height, s32 docked_width, s32 docked_height); - -/// Wrapper for \ref gfxConfigureAutoResolution. handheld_resolution=720p, docked_resolution={all-zero for using current maximum resolution}. -void gfxConfigureAutoResolutionDefault(bool enable); - -/// Waits for vertical sync. -void gfxWaitForVsync(void); - -/// Swaps the framebuffers (for double-buffering). -void gfxSwapBuffers(void); - -/// Get the current framebuffer address, with optional output ptrs for the display framebuffer width/height. The display width/height is adjusted by \ref gfxConfigureCrop and \ref gfxConfigureResolution. -u8* gfxGetFramebuffer(u32* width, u32* height); - -/// Get the framebuffer width/height without crop. -void gfxGetFramebufferResolution(u32* width, u32* height); - -/// Use this to get the actual byte-size of the framebuffer for use with memset/etc. -size_t gfxGetFramebufferSize(void); - -/// Sets the \ref GfxMode. -void gfxSetMode(GfxMode mode); - -/// Controls whether a vertical-flip is done when determining the pixel-offset within the actual framebuffer. By default this is enabled. -void gfxSetDrawFlip(bool flip); - -/// Configures transform. See the NATIVE_WINDOW_TRANSFORM_* enums in buffer_producer.h. The default is NATIVE_WINDOW_TRANSFORM_FLIP_V. -void gfxConfigureTransform(u32 transform); - -/// Flushes the framebuffer in the data cache. When \ref GfxMode is GfxMode_LinearDouble, this also transfers the linear-framebuffer to the actual framebuffer. -void gfxFlushBuffers(void); - -/// Use this to get the pixel-offset in the framebuffer. Returned value is in pixels, not bytes. -/// This implements tegra blocklinear, with hard-coded constants etc. -/// Do not use this when \ref GfxMode is GfxMode_LinearDouble. -static inline u32 gfxGetFramebufferDisplayOffset(u32 x, u32 y) { - u32 tmp_pos; - - extern size_t g_gfx_framebuf_aligned_width; - extern size_t g_gfx_framebuf_display_height; - extern bool g_gfx_drawflip; - - //if (x >= g_gfx_framebuf_width || y >= g_gfx_framebuf_display_height) return (gfxGetFramebufferSize()-4)/4;//Return the last pixel-offset in the buffer, the data located here is not displayed due to alignment. (Disabled for perf) - - if (g_gfx_drawflip) y = g_gfx_framebuf_display_height-1-y; - - tmp_pos = ((y & 127) / 16) + (x/16*8) + ((y/16/8)*(g_gfx_framebuf_aligned_width/16*8)); - tmp_pos *= 16*16 * 4; - - tmp_pos += ((y%16)/8)*512 + ((x%16)/8)*256 + ((y%8)/2)*64 + ((x%8)/4)*32 + (y%2)*16 + (x%4)*4;//This line is a modified version of code from the Tegra X1 datasheet. - - return tmp_pos / 4; -} diff --git a/src/libnx/wrapper/nx/include/switch/gfx/ioctl.h b/src/libnx/wrapper/nx/include/switch/gfx/ioctl.h deleted file mode 100644 index 5af6089..0000000 --- a/src/libnx/wrapper/nx/include/switch/gfx/ioctl.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -//The below defines are based on Linux kernel ioctl.h. - -#define _NV_IOC_NRBITS 8 -#define _NV_IOC_TYPEBITS 8 -#define _NV_IOC_SIZEBITS 14 -#define _NV_IOC_DIRBITS 2 - -#define _NV_IOC_NRMASK ((1 << _NV_IOC_NRBITS)-1) -#define _NV_IOC_TYPEMASK ((1 << _NV_IOC_TYPEBITS)-1) -#define _NV_IOC_SIZEMASK ((1 << _NV_IOC_SIZEBITS)-1) -#define _NV_IOC_DIRMASK ((1 << _NV_IOC_DIRBITS)-1) - -#define _NV_IOC_NRSHIFT 0 -#define _NV_IOC_TYPESHIFT (_NV_IOC_NRSHIFT+_NV_IOC_NRBITS) -#define _NV_IOC_SIZESHIFT (_NV_IOC_TYPESHIFT+_NV_IOC_TYPEBITS) -#define _NV_IOC_DIRSHIFT (_NV_IOC_SIZESHIFT+_NV_IOC_SIZEBITS) - -/* - * Direction bits. - */ -#define _NV_IOC_NONE 0U -#define _NV_IOC_WRITE 1U -#define _NV_IOC_READ 2U - -#define _NV_IOC(dir,type,nr,size) \ - (((dir) << _NV_IOC_DIRSHIFT) | \ - ((type) << _NV_IOC_TYPESHIFT) | \ - ((nr) << _NV_IOC_NRSHIFT) | \ - ((size) << _NV_IOC_SIZESHIFT)) - -/* used to create numbers */ -#define _NV_IO(type,nr) _NV_IOC(_NV_IOC_NONE,(type),(nr),0) -#define _NV_IOR(type,nr,size) _NV_IOC(_NV_IOC_READ,(type),(nr),sizeof(size)) -#define _NV_IOW(type,nr,size) _NV_IOC(_NV_IOC_WRITE,(type),(nr),sizeof(size)) -#define _NV_IOWR(type,nr,size) _NV_IOC(_NV_IOC_READ|_NV_IOC_WRITE,(type),(nr),sizeof(size)) - -/* used to decode ioctl numbers.. */ -#define _NV_IOC_DIR(nr) (((nr) >> _NV_IOC_DIRSHIFT) & _NV_IOC_DIRMASK) -#define _NV_IOC_TYPE(nr) (((nr) >> _NV_IOC_TYPESHIFT) & _NV_IOC_TYPEMASK) -#define _NV_IOC_NR(nr) (((nr) >> _NV_IOC_NRSHIFT) & _NV_IOC_NRMASK) -#define _NV_IOC_SIZE(nr) (((nr) >> _NV_IOC_SIZESHIFT) & _NV_IOC_SIZEMASK) - -#define __nv_in -#define __nv_out -#define __nv_inout diff --git a/src/libnx/wrapper/nx/include/switch/gfx/nvgfx.h b/src/libnx/wrapper/nx/include/switch/gfx/nvgfx.h deleted file mode 100644 index 6d8a9f6..0000000 --- a/src/libnx/wrapper/nx/include/switch/gfx/nvgfx.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "../types.h" - -Result nvgfxInitialize(void); -void nvgfxExit(void); -Result nvgfxEventWait(u32 syncpt_id, u32 threshold, s32 timeout); -Result nvgfxSubmitGpfifo(void); -Result nvgfxGetFramebuffer(u8 **buffer, size_t *size); diff --git a/src/libnx/wrapper/nx/include/switch/gfx/nvioctl.h b/src/libnx/wrapper/nx/include/switch/gfx/nvioctl.h deleted file mode 100644 index 24c75e0..0000000 --- a/src/libnx/wrapper/nx/include/switch/gfx/nvioctl.h +++ /dev/null @@ -1,110 +0,0 @@ -#pragma once -#include "../types.h" - -typedef struct { - u32 arch; // 0x120 (NVGPU_GPU_ARCH_GM200) - u32 impl; // 0xB (NVGPU_GPU_IMPL_GM20B) - u32 rev; // 0xA1 (Revision A1) - u32 num_gpc; // 0x1 - u64 L2_cache_size; // 0x40000 - u64 on_board_video_memory_size; // 0x0 (not used) - u32 num_tpc_per_gpc; // 0x2 - u32 bus_type; // 0x20 (NVGPU_GPU_BUS_TYPE_AXI) - u32 big_page_size; // 0x20000 - u32 compression_page_size; // 0x20000 - u32 pde_coverage_bit_count; // 0x1B - u32 available_big_page_sizes; // 0x30000 - u32 gpc_mask; // 0x1 - u32 sm_arch_sm_version; // 0x503 (Maxwell Generation 5.0.3?) - u32 sm_arch_spa_version; // 0x503 (Maxwell Generation 5.0.3?) - u32 sm_arch_warp_count; // 0x80 - u32 gpu_va_bit_count; // 0x28 - u32 reserved; // NULL - u64 flags; // 0x55 - u32 twod_class; // 0x902D (FERMI_TWOD_A) - u32 threed_class; // 0xB197 (MAXWELL_B) - u32 compute_class; // 0xB1C0 (MAXWELL_COMPUTE_B) - u32 gpfifo_class; // 0xB06F (MAXWELL_CHANNEL_GPFIFO_A) - u32 inline_to_memory_class; // 0xA140 (KEPLER_INLINE_TO_MEMORY_B) - u32 dma_copy_class; // 0xB0B5 (MAXWELL_DMA_COPY_A) - u32 max_fbps_count; // 0x1 - u32 fbp_en_mask; // 0x0 (disabled) - u32 max_ltc_per_fbp; // 0x2 - u32 max_lts_per_ltc; // 0x1 - u32 max_tex_per_tpc; // 0x0 (not supported) - u32 max_gpc_count; // 0x1 - u32 rop_l2_en_mask_0; // 0x21D70 (fuse_status_opt_rop_l2_fbp_r) - u32 rop_l2_en_mask_1; // 0x0 - u64 chipname; // 0x6230326D67 ("gm20b") - u64 gr_compbit_store_base_hw; // 0x0 (not supported) -} gpu_characteristics; - -typedef struct { - u64 offset; - u32 page_size; - u32 pad; - u64 pages; -} nvioctl_va_region; - -typedef struct { - u32 mask; // always 0x07 - u32 flush; // active flush bit field -} nvioctl_l2_state; - -typedef struct { - u32 id; - u32 value; -} nvioctl_fence; - -typedef struct { - u32 entry0; - u32 entry1; -} nvioctl_gpfifo_entry; - -//Used with nvioctlChannel_AllocObjCtx(). -enum nvioctl_channel_obj_classnum { - NvChannelObjClassNum_2D = 0x902D, - NvChannelObjClassNum_3D = 0xB197, - NvChannelObjClassNum_Compute = 0xB1C0, - NvChannelObjClassNum_Kepler = 0xA140, - NvChannelObjClassNum_DMA = 0xB0B5, - NvChannelObjClassNum_ChannelGpfifo = 0xB06F -}; - -//Used with nvioctlChannel_SetPriority(). -enum nvioctl_channel_priority { - NvChannelPriority_Low = 0x32, - NvChannelPriority_Medium = 0x64, - NvChannelPriority_High = 0x96 -}; - -Result nvioctlNvhostCtrl_EventSignal(u32 fd, u32 event_id); -Result nvioctlNvhostCtrl_EventWait(u32 fd, u32 syncpt_id, u32 threshold, s32 timeout, u32 event_id, u32 *out); -Result nvioctlNvhostCtrl_EventRegister(u32 fd, u32 event_id); - -Result nvioctlNvhostCtrlGpu_ZCullGetCtxSize(u32 fd, u32 *out); -Result nvioctlNvhostCtrlGpu_ZCullGetInfo(u32 fd, u32 out[40>>2]); -Result nvioctlNvhostCtrlGpu_GetCharacteristics(u32 fd, gpu_characteristics *out); -Result nvioctlNvhostCtrlGpu_GetTpcMasks(u32 fd, u32 inval, u32 out[24>>2]); -Result nvioctlNvhostCtrlGpu_GetL2State(u32 fd, nvioctl_l2_state *out); - -Result nvioctlNvhostAsGpu_BindChannel(u32 fd, u32 channel_fd); -Result nvioctlNvhostAsGpu_AllocSpace(u32 fd, u32 pages, u32 page_size, u32 flags, u64 align, u64 *offset); -Result nvioctlNvhostAsGpu_MapBufferEx(u32 fd, u32 flags, u32 kind, u32 nvmap_handle, u32 page_size, u64 buffer_offset, u64 mapping_size, u64 input_offset, u64 *offset); -Result nvioctlNvhostAsGpu_GetVARegions(u32 fd, nvioctl_va_region regions[2]); -Result nvioctlNvhostAsGpu_InitializeEx(u32 fd, u32 big_page_size, u32 flags); - -Result nvioctlNvmap_Create(u32 fd, u32 size, u32 *nvmap_handle); -Result nvioctlNvmap_FromId(u32 fd, u32 id, u32 *nvmap_handle); -Result nvioctlNvmap_Alloc(u32 fd, u32 nvmap_handle, u32 heapmask, u32 flags, u32 align, u8 kind, void* addr); -Result nvioctlNvmap_GetId(u32 fd, u32 nvmap_handle, u32 *id); - -Result nvioctlChannel_SetNvmapFd(u32 fd, u32 nvmap_fd); -Result nvioctlChannel_SubmitGpfifo(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_entries, u32 flags, nvioctl_fence *fence_out); -Result nvioctlChannel_AllocObjCtx(u32 fd, u32 class_num, u32 flags); -Result nvioctlChannel_ZCullBind(u32 fd, u64 gpu_va, u32 mode); -Result nvioctlChannel_SetErrorNotifier(u32 fd, u64 offset, u64 size, u32 nvmap_handle); -Result nvioctlChannel_SetPriority(u32 fd, u32 priority); -Result nvioctlChannel_AllocGpfifoEx2(u32 fd, u32 num_entries, u32 flags, u32 unk0, u32 unk1, u32 unk2, u32 unk3, nvioctl_fence *fence_out); -Result nvioctlChannel_SetUserData(u32 fd, void* addr); - diff --git a/src/libnx/wrapper/nx/include/switch/gfx/parcel.h b/src/libnx/wrapper/nx/include/switch/gfx/parcel.h deleted file mode 100644 index e208a81..0000000 --- a/src/libnx/wrapper/nx/include/switch/gfx/parcel.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "../result.h" -#include "../gfx/binder.h" - -typedef struct { - u8 payload[0x400]; - u32 capacity; - u32 size; - u32 pos; - - u8 *ParcelObjects; - u32 ParcelObjectsSize; -} Parcel; - -void parcelInitialize(Parcel *ctx); -Result parcelTransact(Binder *session, u32 code, Parcel *in_parcel, Parcel *reply_parcel); - -void* parcelWriteData(Parcel *ctx, void* data, size_t data_size); -void* parcelReadData(Parcel *ctx, void* data, size_t data_size); - -void parcelWriteInt32(Parcel *ctx, s32 val); -void parcelWriteUInt32(Parcel *ctx, u32 val); -void parcelWriteString16(Parcel *ctx, const char *str); - -s32 parcelReadInt32(Parcel *ctx); -u32 parcelReadUInt32(Parcel *ctx); -void parcelWriteInterfaceToken(Parcel *ctx, const char *str); - -void* parcelReadFlattenedObject(Parcel *ctx, size_t *size); -void* parcelWriteFlattenedObject(Parcel *ctx, void* data, size_t size); - diff --git a/src/libnx/wrapper/nx/include/switch/kernel/condvar.h b/src/libnx/wrapper/nx/include/switch/kernel/condvar.h deleted file mode 100644 index cd428b7..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/condvar.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file condvar.h - * @brief Condition variable synchronization primitive. - * @author plutoo - * @copyright libnx Authors - */ -#include "../types.h" -#include "../kernel/mutex.h" - -/// Condition variable structure. -typedef struct { - u32 tag; - Mutex* mutex; -} CondVar; - -/** - * @brief Initializes a condition variable. - * @param[in] c Condition variable object. - * @param[in] m Mutex object to use inside the condition variable. - */ -void condvarInit(CondVar* c, Mutex* m); - -/** - * @brief Waits on a condition variable with a timeout. - * @param[in] c Condition variable object. - * @param[in] timeout Timeout in nanoseconds. - * @return Result code (0xEA01 on timeout). - * @remark On function return, the underlying mutex is acquired. - */ -Result condvarWaitTimeout(CondVar* c, u64 timeout); - -/** - * @brief Waits on a condition variable. - * @param[in] c Condition variable object. - * @return Result code. - * @remark On function return, the underlying mutex is acquired. - */ -static inline Result condvarWait(CondVar* c) -{ - return condvarWaitTimeout(c, -1ull); -} - -/** - * @brief Wakes up up to the specified number of threads waiting on a condition variable. - * @param[in] c Condition variable object. - * @param[in] num Maximum number of threads to wake up (or -1 to wake them all up). - * @return Result code. - */ -Result condvarWake(CondVar* c, int num); - -/** - * @brief Wakes up a single thread waiting on a condition variable. - * @param[in] c Condition variable object. - * @return Result code. - */ -static inline Result condvarWakeOne(CondVar* c) -{ - return condvarWake(c, 1); -} - -/** - * @brief Wakes up all thread waiting on a condition variable. - * @param[in] c Condition variable object. - * @return Result code. - */ -static inline Result condvarWakeAll(CondVar* c) -{ - return condvarWake(c, -1); -} diff --git a/src/libnx/wrapper/nx/include/switch/kernel/detect.h b/src/libnx/wrapper/nx/include/switch/kernel/detect.h deleted file mode 100644 index 6d86a09..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/detect.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @file detect.h - * @brief Kernel version detection - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/// Returns true if the kernel version is equal to or above 2.0.0. -bool kernelAbove200(void); -/// Returns true if the kernel version is equal to or above 3.0.0. -bool kernelAbove300(void); -/// Returns true if the kernel version is equal to or above 4.0.0. -bool kernelAbove400(void); -/// Returns true if the kernel version is equal to or above 5.0.0. -bool kernelAbove500(void); -/// Returns true if the process has a debugger attached. -bool detectDebugger(void); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/ipc.h b/src/libnx/wrapper/nx/include/switch/kernel/ipc.h deleted file mode 100644 index 49d28f3..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/ipc.h +++ /dev/null @@ -1,674 +0,0 @@ -/** - * @file ipc.h - * @brief Inter-process communication handling - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../result.h" -#include "../arm/tls.h" -#include "../kernel/svc.h" - -/// IPC input header magic -#define SFCI_MAGIC 0x49434653 -/// IPC output header magic -#define SFCO_MAGIC 0x4f434653 - -/// IPC invalid object ID -#define IPC_INVALID_OBJECT_ID UINT32_MAX - -///@name IPC request building -///@{ - -/// IPC command (request) structure. -#define IPC_MAX_BUFFERS 8 -#define IPC_MAX_OBJECTS 8 - -typedef enum { - BufferType_Normal=0, ///< Regular buffer. - BufferType_Type1=1, ///< Allows ProcessMemory and shared TransferMemory. - BufferType_Invalid=2, - BufferType_Type3=3 ///< Same as Type1 except remote process is not allowed to use device-mapping. -} BufferType; - -typedef enum { - BufferDirection_Send=0, - BufferDirection_Recv=1, - BufferDirection_Exch=2, -} BufferDirection; - -typedef enum { - IpcCommandType_Invalid = 0, - IpcCommandType_LegacyRequest = 1, - IpcCommandType_Close = 2, - IpcCommandType_LegacyControl = 3, - IpcCommandType_Request = 4, - IpcCommandType_Control = 5, - IpcCommandType_RequestWithContext = 6, - IpcCommandType_ControlWithContext = 7, -} IpcCommandType; - -typedef enum { - DomainMessageType_Invalid = 0, - DomainMessageType_SendMessage = 1, - DomainMessageType_Close = 2, -} DomainMessageType; - -/// IPC domain message header. -typedef struct { - u8 Type; - u8 NumObjectIds; - u16 Length; - u32 ThisObjectId; - u32 Pad[2]; -} DomainMessageHeader; - -typedef struct { - size_t NumSend; // A - size_t NumRecv; // B - size_t NumExch; // W - const void* Buffers[IPC_MAX_BUFFERS]; - size_t BufferSizes[IPC_MAX_BUFFERS]; - BufferType BufferTypes[IPC_MAX_BUFFERS]; - - size_t NumStaticIn; // X - size_t NumStaticOut; // C - const void* Statics[IPC_MAX_BUFFERS]; - size_t StaticSizes[IPC_MAX_BUFFERS]; - u8 StaticIndices[IPC_MAX_BUFFERS]; - - bool SendPid; - size_t NumHandlesCopy; - size_t NumHandlesMove; - Handle Handles[IPC_MAX_OBJECTS]; - - size_t NumObjectIds; - u32 ObjectIds[IPC_MAX_OBJECTS]; -} IpcCommand; - -/** - * @brief Initializes an IPC command structure. - * @param cmd IPC command structure. - */ -static inline void ipcInitialize(IpcCommand* cmd) { - *cmd = (IpcCommand){0}; -} - -/// IPC buffer descriptor. -typedef struct { - u32 Size; ///< Size of the buffer. - u32 Addr; ///< Lower 32-bits of the address of the buffer - u32 Packed; ///< Packed data (including higher bits of the address) -} IpcBufferDescriptor; - -/// IPC static send-buffer descriptor. -typedef struct { - u32 Packed; ///< Packed data (including higher bits of the address) - u32 Addr; ///< Lower 32-bits of the address -} IpcStaticSendDescriptor; - -/// IPC static receive-buffer descriptor. -typedef struct { - u32 Addr; ///< Lower 32-bits of the address of the buffer - u32 Packed; ///< Packed data (including higher bits of the address) -} IpcStaticRecvDescriptor; - -/** - * @brief Adds a buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param type Buffer type. - */ -static inline void ipcAddSendBuffer(IpcCommand* cmd, const void* buffer, size_t size, BufferType type) { - size_t off = cmd->NumSend; - cmd->Buffers[off] = buffer; - cmd->BufferSizes[off] = size; - cmd->BufferTypes[off] = type; - cmd->NumSend++; -} - -/** - * @brief Adds a receive-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param type Buffer type. - */ -static inline void ipcAddRecvBuffer(IpcCommand* cmd, void* buffer, size_t size, BufferType type) { - size_t off = cmd->NumSend + cmd->NumRecv; - cmd->Buffers[off] = buffer; - cmd->BufferSizes[off] = size; - cmd->BufferTypes[off] = type; - cmd->NumRecv++; -} - -/** - * @brief Adds an exchange-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param type Buffer type. - */ -static inline void ipcAddExchBuffer(IpcCommand* cmd, void* buffer, size_t size, BufferType type) { - size_t off = cmd->NumSend + cmd->NumRecv + cmd->NumExch; - cmd->Buffers[off] = buffer; - cmd->BufferSizes[off] = size; - cmd->BufferTypes[off] = type; - cmd->NumExch++; -} - -/** - * @brief Adds a static-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -static inline void ipcAddSendStatic(IpcCommand* cmd, const void* buffer, size_t size, u8 index) { - size_t off = cmd->NumStaticIn; - cmd->Statics[off] = buffer; - cmd->StaticSizes[off] = size; - cmd->StaticIndices[off] = index; - cmd->NumStaticIn++; -} - -/** - * @brief Adds a static-receive-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -static inline void ipcAddRecvStatic(IpcCommand* cmd, void* buffer, size_t size, u8 index) { - size_t off = cmd->NumStaticIn + cmd->NumStaticOut; - cmd->Statics[off] = buffer; - cmd->StaticSizes[off] = size; - cmd->StaticIndices[off] = index; - cmd->NumStaticOut++; -} - -/** - * @brief Adds a smart-buffer (buffer + static-buffer pair) to an IPC command structure. - * @param cmd IPC command structure. - * @param ipc_buffer_size IPC buffer size. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -static inline void ipcAddSendSmart(IpcCommand* cmd, size_t ipc_buffer_size, const void* buffer, size_t size, u8 index) { - if (ipc_buffer_size != 0 && size <= ipc_buffer_size) { - ipcAddSendBuffer(cmd, NULL, 0, BufferType_Normal); - ipcAddSendStatic(cmd, buffer, size, index); - } else { - ipcAddSendBuffer(cmd, buffer, size, BufferType_Normal); - ipcAddSendStatic(cmd, NULL, 0, index); - } -} - -/** - * @brief Adds a smart-receive-buffer (buffer + static-receive-buffer pair) to an IPC command structure. - * @param cmd IPC command structure. - * @param ipc_buffer_size IPC buffer size. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -static inline void ipcAddRecvSmart(IpcCommand* cmd, size_t ipc_buffer_size, void* buffer, size_t size, u8 index) { - if (ipc_buffer_size != 0 && size <= ipc_buffer_size) { - ipcAddRecvBuffer(cmd, NULL, 0, BufferType_Normal); - ipcAddRecvStatic(cmd, buffer, size, index); - } else { - ipcAddRecvBuffer(cmd, buffer, size, BufferType_Normal); - ipcAddRecvStatic(cmd, NULL, 0, index); - } -} - -/** - * @brief Tags an IPC command structure to send the PID. - * @param cmd IPC command structure. - */ -static inline void ipcSendPid(IpcCommand* cmd) { - cmd->SendPid = true; -} - -/** - * @brief Adds a copy-handle to be sent through an IPC command structure. - * @param cmd IPC command structure. - * @param h Handle to send. - * @remark The receiving process gets a copy of the handle. - */ -static inline void ipcSendHandleCopy(IpcCommand* cmd, Handle h) { - cmd->Handles[cmd->NumHandlesCopy++] = h; -} - -/** - * @brief Adds a move-handle to be sent through an IPC command structure. - * @param cmd IPC command structure. - * @param h Handle to send. - * @remark The sending process loses ownership of the handle, which is transferred to the receiving process. - */ -static inline void ipcSendHandleMove(IpcCommand* cmd, Handle h) { - cmd->Handles[cmd->NumHandlesCopy + cmd->NumHandlesMove++] = h; -} - -/** - * @brief Prepares the header of an IPC command structure. - * @param cmd IPC command structure. - * @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request - * @return Pointer to the raw embedded data structure in the request, ready to be filled out. - */ -static inline void* ipcPrepareHeader(IpcCommand* cmd, size_t sizeof_raw) { - u32* buf = (u32*)armGetTls(); - size_t i; - *buf++ = IpcCommandType_Request | (cmd->NumStaticIn << 16) | (cmd->NumSend << 20) | (cmd->NumRecv << 24) | (cmd->NumExch << 28); - - u32* fill_in_size_later = buf; - - if (cmd->NumStaticOut > 0) { - *buf = (cmd->NumStaticOut + 2) << 10; - } - else { - *buf = 0; - } - - if (cmd->SendPid || cmd->NumHandlesCopy > 0 || cmd->NumHandlesMove > 0) { - *buf++ |= 0x80000000; - *buf++ = (!!cmd->SendPid) | (cmd->NumHandlesCopy << 1) | (cmd->NumHandlesMove << 5); - - if (cmd->SendPid) - buf += 2; - - for (i=0; i<(cmd->NumHandlesCopy + cmd->NumHandlesMove); i++) - *buf++ = cmd->Handles[i]; - } - else { - buf++; - } - - for (i=0; iNumStaticIn; i++, buf+=2) { - IpcStaticSendDescriptor* desc = (IpcStaticSendDescriptor*) buf; - - uintptr_t ptr = (uintptr_t) cmd->Statics[i]; - desc->Addr = ptr; - desc->Packed = cmd->StaticIndices[i] | (cmd->StaticSizes[i] << 16) | - (((ptr >> 32) & 15) << 12) | (((ptr >> 36) & 15) << 6); - } - - for (i=0; i<(cmd->NumSend + cmd->NumRecv + cmd->NumExch); i++, buf+=3) { - IpcBufferDescriptor* desc = (IpcBufferDescriptor*) buf; - desc->Size = cmd->BufferSizes[i]; - - uintptr_t ptr = (uintptr_t) cmd->Buffers[i]; - desc->Addr = ptr; - desc->Packed = cmd->BufferTypes[i] | - (((ptr >> 32) & 15) << 28) | ((ptr >> 36) << 2); - } - - u32 padding = ((16 - (((uintptr_t) buf) & 15)) & 15) / 4; - u32* raw = (u32*) (buf + padding); - - size_t raw_size = (sizeof_raw/4) + 4; - buf += raw_size; - - u16* buf_u16 = (u16*) buf; - - for (i=0; iNumStaticOut; i++) { - size_t off = cmd->NumStaticIn + i; - size_t sz = (uintptr_t) cmd->StaticSizes[off]; - - buf_u16[i] = (sz > 0xFFFF) ? 0 : sz; - } - - size_t u16s_size = ((2*cmd->NumStaticOut) + 3)/4; - buf += u16s_size; - raw_size += u16s_size; - - *fill_in_size_later |= raw_size; - - for (i=0; iNumStaticOut; i++, buf+=2) { - IpcStaticRecvDescriptor* desc = (IpcStaticRecvDescriptor*) buf; - size_t off = cmd->NumStaticIn + i; - - uintptr_t ptr = (uintptr_t) cmd->Statics[off]; - desc->Addr = ptr; - desc->Packed = (ptr >> 32) | (cmd->StaticSizes[off] << 16); - } - - return (void*) raw; -} - -/** - * @brief Dispatches an IPC request. - * @param session IPC session handle. - * @return Result code. - */ -static inline Result ipcDispatch(Handle session) { - return svcSendSyncRequest(session); -} - -///@} - -///@name IPC response parsing -///@{ - -/// IPC parsed command (response) structure. -typedef struct { - IpcCommandType CommandType; ///< Type of the command - - bool HasPid; ///< true if the 'Pid' field is filled out. - u64 Pid; ///< PID included in the response (only if HasPid is true) - - size_t NumHandles; ///< Number of handles copied. - Handle Handles[IPC_MAX_OBJECTS]; ///< Handles. - bool WasHandleCopied[IPC_MAX_OBJECTS]; ///< true if the handle was moved, false if it was copied. - - bool IsDomainMessage; ///< true if the the message is a Domain message. - DomainMessageType MessageType; ///< Type of the domain message. - u32 MessageLength; ///< Size of rawdata (for domain messages). - u32 ThisObjectId; ///< Object ID to call the command on (for domain messages). - size_t NumObjectIds; ///< Number of object IDs (for domain messages). - u32 ObjectIds[IPC_MAX_OBJECTS]; ///< Object IDs (for domain messages). - - size_t NumBuffers; ///< Number of buffers in the response. - void* Buffers[IPC_MAX_BUFFERS]; ///< Pointers to the buffers. - size_t BufferSizes[IPC_MAX_BUFFERS]; ///< Sizes of the buffers. - BufferType BufferTypes[IPC_MAX_BUFFERS]; ///< Types of the buffers. - BufferDirection BufferDirections[IPC_MAX_BUFFERS]; ///< Direction of each buffer. - - size_t NumStatics; ///< Number of statics in the response. - void* Statics[IPC_MAX_BUFFERS]; ///< Pointers to the statics. - size_t StaticSizes[IPC_MAX_BUFFERS]; ///< Sizes of the statics. - u8 StaticIndices[IPC_MAX_BUFFERS]; ///< Indices of the statics. - - size_t NumStaticsOut; ///< Number of output statics available in the response. - - void* Raw; ///< Pointer to the raw embedded data structure in the response. - void* RawWithoutPadding; ///< Pointer to the raw embedded data structure, without padding. - size_t RawSize; ///< Size of the raw embedded data. -} IpcParsedCommand; - -/** - * @brief Parse an IPC command response into an IPC parsed command structure. - * @param IPC parsed command structure to fill in. - * @return Result code. - */ -static inline Result ipcParse(IpcParsedCommand* r) { - u32* buf = (u32*)armGetTls(); - u32 ctrl0 = *buf++; - u32 ctrl1 = *buf++; - size_t i; - - r->IsDomainMessage = false; - - r->CommandType = (IpcCommandType) (ctrl0 & 0xffff); - r->HasPid = false; - r->RawSize = (ctrl1 & 0x1ff) * 4; - r->NumHandles = 0; - - r->NumStaticsOut = (ctrl1 >> 10) & 15; - if (r->NumStaticsOut >> 1) r->NumStaticsOut--; // Value 2 -> Single descriptor - if (r->NumStaticsOut >> 1) r->NumStaticsOut--; // Value 3+ -> (Value - 2) descriptors - - if (ctrl1 & 0x80000000) { - u32 ctrl2 = *buf++; - - if (ctrl2 & 1) { - r->HasPid = true; - r->Pid = *buf++; - r->Pid |= ((u64)(*buf++)) << 32; - } - - size_t num_handles_copy = ((ctrl2 >> 1) & 15); - size_t num_handles_move = ((ctrl2 >> 5) & 15); - - size_t num_handles = num_handles_copy + num_handles_move; - u32* buf_after_handles = buf + num_handles; - - if (num_handles > IPC_MAX_OBJECTS) - num_handles = IPC_MAX_OBJECTS; - - for (i=0; iHandles[i] = *(buf+i); - r->WasHandleCopied[i] = (i < num_handles_copy); - } - - r->NumHandles = num_handles; - buf = buf_after_handles; - } - - size_t num_statics = (ctrl0 >> 16) & 15; - u32* buf_after_statics = buf + num_statics*2; - - if (num_statics > IPC_MAX_BUFFERS) - num_statics = IPC_MAX_BUFFERS; - - for (i=0; iPacked; - - r->Statics[i] = (void*) (desc->Addr | (((packed >> 12) & 15) << 32) | (((packed >> 6) & 15) << 36)); - r->StaticSizes[i] = packed >> 16; - r->StaticIndices[i] = packed & 63; - } - - r->NumStatics = num_statics; - buf = buf_after_statics; - - size_t num_bufs_send = (ctrl0 >> 20) & 15; - size_t num_bufs_recv = (ctrl0 >> 24) & 15; - size_t num_bufs_exch = (ctrl0 >> 28) & 15; - - size_t num_bufs = num_bufs_send + num_bufs_recv + num_bufs_exch; - r->Raw = (void*)(((uintptr_t)(buf + num_bufs*3) + 15) &~ 15); - r->RawWithoutPadding = (void*)((uintptr_t)(buf + num_bufs*3)); - - if (num_bufs > IPC_MAX_BUFFERS) - num_bufs = IPC_MAX_BUFFERS; - - for (i=0; iPacked; - - r->Buffers[i] = (void*) (desc->Addr | ((packed >> 28) << 32) | (((packed >> 2) & 15) << 36)); - r->BufferSizes[i] = desc->Size; - r->BufferTypes[i] = (BufferType) (packed & 3); - - if (i < num_bufs_send) - r->BufferDirections[i] = BufferDirection_Send; - else if (i < (num_bufs_send + num_bufs_recv)) - r->BufferDirections[i] = BufferDirection_Recv; - else - r->BufferDirections[i] = BufferDirection_Exch; - } - - r->NumBuffers = num_bufs; - return 0; -} - -/** - * @brief Queries the size of an IPC pointer buffer. - * @param session IPC session handle. - * @param size Output variable in which to store the size. - * @return Result code. - */ -static inline Result ipcQueryPointerBufferSize(Handle session, size_t *size) { - u32* buf = (u32*)armGetTls(); - - buf[0] = IpcCommandType_Control; - buf[1] = 8; - buf[2] = 0; - buf[3] = 0; - buf[4] = SFCI_MAGIC; - buf[5] = 0; - buf[6] = 3; - buf[7] = 0; - - Result rc = ipcDispatch(session); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct ipcQueryPointerBufferSizeResponse { - u64 magic; - u64 result; - u32 size; - } *raw = (struct ipcQueryPointerBufferSizeResponse*)r.Raw; - - rc = raw->result; - - if (R_SUCCEEDED(rc)) { - *size = raw->size & 0xffff; - } - } - - return rc; -} - -/** - * @brief Closes the IPC session with proper clean up. - * @param session IPC session handle. - * @return Result code. - */ -static inline Result ipcCloseSession(Handle session) { - u32* buf = (u32*)armGetTls(); - buf[0] = IpcCommandType_Close; - buf[1] = 0; - return ipcDispatch(session); -} -///@} - -///@name IPC domain handling -///@{ - -/** - * @brief Converts an IPC session handle into a domain. - * @param session IPC session handle. - * @param object_id_out Output variable in which to store the object ID. - * @return Result code. - */ -static inline Result ipcConvertSessionToDomain(Handle session, u32* object_id_out) { - u32* buf = (u32*)armGetTls(); - - buf[0] = IpcCommandType_Control; - buf[1] = 8; - buf[4] = SFCI_MAGIC; - buf[5] = 0; - buf[6] = 0; - buf[7] = 0; - - Result rc = ipcDispatch(session); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct ipcConvertSessionToDomainResponse { - u64 magic; - u64 result; - u32 object_id; - } *raw = (struct ipcConvertSessionToDomainResponse*)r.Raw; - - rc = raw->result; - - if (R_SUCCEEDED(rc)) { - *object_id_out = raw->object_id; - } - } - - return rc; -} - -/** - * @brief Adds an object ID to be sent through an IPC domain command structure. - * @param cmd IPC domain command structure. - * @param object_id Object ID to send. - */ -static inline void ipcSendObjectId(IpcCommand* cmd, u32 object_id) { - cmd->ObjectIds[cmd->NumObjectIds++] = object_id; -} - -/** - * @brief Prepares the header of an IPC command structure (domain version). - * @param cmd IPC command structure. - * @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request - * @oaram object_id Domain object ID. - * @return Pointer to the raw embedded data structure in the request, ready to be filled out. - */ -static inline void* ipcPrepareHeaderForDomain(IpcCommand* cmd, size_t sizeof_raw, u32 object_id) { - void* raw = ipcPrepareHeader(cmd, sizeof_raw + sizeof(DomainMessageHeader)); - DomainMessageHeader* hdr = (DomainMessageHeader*) raw; - u32 *object_ids = (u32*)(((uintptr_t) raw) + sizeof(DomainMessageHeader) + sizeof_raw); - - hdr->Type = DomainMessageType_SendMessage; - hdr->NumObjectIds = (u8)cmd->NumObjectIds; - hdr->Length = sizeof_raw; - hdr->ThisObjectId = object_id; - hdr->Pad[0] = hdr->Pad[1] = 0; - - for(size_t i = 0; i < cmd->NumObjectIds; i++) - object_ids[i] = cmd->ObjectIds[i]; - return (void*)(((uintptr_t) raw) + sizeof(DomainMessageHeader)); -} - -/** - * @brief Parse an IPC command response into an IPC parsed command structure (domain version). - * @param IPC parsed command structure to fill in. - * @return Result code. - */ -static inline Result ipcParseForDomain(IpcParsedCommand* r) { - Result rc = ipcParse(r); - DomainMessageHeader *hdr; - u32 *object_ids; - if(R_FAILED(rc)) - return rc; - - hdr = (DomainMessageHeader*) r->Raw; - object_ids = (u32*)(((uintptr_t) hdr) + sizeof(DomainMessageHeader) + hdr->Length); - r->Raw = (void*)(((uintptr_t) r->Raw) + sizeof(DomainMessageHeader)); - - r->IsDomainMessage = true; - r->MessageType = (DomainMessageType)(hdr->Type); - switch (r->MessageType) { - case DomainMessageType_SendMessage: - case DomainMessageType_Close: - break; - default: - return MAKERESULT(Module_Libnx, LibnxError_DomainMessageUnknownType); - } - r->ThisObjectId = hdr->ThisObjectId; - r->NumObjectIds = hdr->NumObjectIds > 8 ? 8 : hdr->NumObjectIds; - if ((uintptr_t)object_ids + sizeof(u32) * r->NumObjectIds - (uintptr_t)armGetTls() >= 0x100) { - return MAKERESULT(Module_Libnx, LibnxError_DomainMessageTooManyObjectIds); - } - for(size_t i = 0; i < r->NumObjectIds; i++) - r->ObjectIds[i] = object_ids[i]; - - return rc; -} - -/** - * @brief Closes a domain object by ID. - * @param session IPC session handle. - * @param object_id ID of the object to close. - * @return Result code. - */ -static inline Result ipcCloseObjectById(Handle session, u32 object_id) { - IpcCommand c; - DomainMessageHeader* hdr; - - ipcInitialize(&c); - hdr = (DomainMessageHeader*)ipcPrepareHeader(&c, sizeof(DomainMessageHeader)); - - hdr->Type = 2; - hdr->NumObjectIds = 0; - hdr->Length = 0; - hdr->ThisObjectId = object_id; - hdr->Pad[0] = hdr->Pad[1] = 0; - - return ipcDispatch(session); // this command has no associated response -} - -///@} diff --git a/src/libnx/wrapper/nx/include/switch/kernel/jit.h b/src/libnx/wrapper/nx/include/switch/kernel/jit.h deleted file mode 100644 index f626166..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/jit.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file jit.h - * @brief Just-in-time compilation support. - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/// JIT implementation type. -typedef enum { - JitType_CodeMemory, ///< JIT supported using svcSetProcessMemoryPermission - JitType_JitMemory, ///< JIT supported using 4.0.0+ code-memory syscalls (this isn't usable on 5.0.0+ so JitType_CodeMemory is used instead). -} JitType; - -/// JIT buffer object. -typedef struct { - JitType type; - size_t size; - void* src_addr; - void* rx_addr; - void* rw_addr; - bool is_executable; - Handle handle; -} Jit; - -/** - * @brief Creates a JIT buffer. - * @param j JIT buffer. - * @param size Size of the JIT buffer. - * @return Result code. - */ -Result jitCreate(Jit* j, size_t size); - -/** - * @brief Transition a JIT buffer to have writable permission. - * @param j JIT buffer. - * @return Result code. - */ -Result jitTransitionToWritable(Jit* j); - -/** - * @brief Transition a JIT buffer to have executable permission. - * @param j JIT buffer. - * @return Result code. - */ -Result jitTransitionToExecutable(Jit* j); - -/** - * @brief Destroys a JIT buffer. - * @param j JIT buffer. - * @return Result code. - */ -Result jitClose(Jit* j); - -/** - * @brief Gets the address of the writable memory alias of a JIT buffer. - * @param j JIT buffer. - * @return Pointer to alias of the JIT buffer that can be written to. - */ -void* jitGetRwAddr(Jit* j); - -/** - * @brief Gets the address of the executable memory alias of a JIT buffer. - * @param j JIT buffer. - * @return Pointer to alias of the JIT buffer that can be executed. - */ -void* jitGetRxAddr(Jit* j); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/mutex.h b/src/libnx/wrapper/nx/include/switch/kernel/mutex.h deleted file mode 100644 index fe6ca3a..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/mutex.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file mutex.h - * @brief Mutex synchronization primitive. - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include -#include "../types.h" - -/// Mutex datatype, defined in newlib. -typedef _LOCK_T Mutex; -/// Recursive mutex datatype, defined in newlib. -typedef _LOCK_RECURSIVE_T RMutex; - -/** - * @brief Initializes a mutex. - * @param m Mutex object. - * @note A mutex can also be statically initialized by assigning 0 to it. - */ -static inline void mutexInit(Mutex* m) -{ - *m = 0; -} - -/** - * @brief Locks a mutex. - * @param m Mutex object. - */ -void mutexLock(Mutex* m); - -/** - * @brief Attempts to lock a mutex without waiting. - * @param m Mutex object. - * @return 1 if the mutex has been acquired successfully, and 0 on contention. - */ -bool mutexTryLock(Mutex* m); - -/** - * @brief Unlocks a mutex. - * @param m Mutex object. - */ -void mutexUnlock(Mutex* m); - -/** - * @brief Initializes a recursive mutex. - * @param m Recursive mutex object. - * @note A recursive mutex can also be statically initialized by assigning {0,0,0} to it. - */ -static inline void rmutexInit(RMutex* m) -{ - m->lock = 0; - m->thread_tag = 0; - m->counter = 0; -} - -/** - * @brief Locks a recursive mutex. - * @param m Recursive mutex object. - */ -void rmutexLock(RMutex* m); - -/** - * @brief Attempts to lock a recursive mutex without waiting. - * @param m Recursive mutex object. - * @return 1 if the mutex has been acquired successfully, and 0 on contention. - */ -bool rmutexTryLock(RMutex* m); - -/** - * @brief Unlocks a recursive mutex. - * @param m Recursive mutex object. - */ -void rmutexUnlock(RMutex* m); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/random.h b/src/libnx/wrapper/nx/include/switch/kernel/random.h deleted file mode 100644 index a134865..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/random.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @file random.h - * @brief OS-seeded pseudo-random number generation support (ChaCha algorithm). - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/** - * @brief Fills a buffer with random data. - * @param buf Pointer to the buffer. - * @param len Size of the buffer in bytes. - */ -void randomGet(void* buf, size_t len); - -/** - * @brief Returns a random 64-bit value. - * @return Random value. - */ -u64 randomGet64(void); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/rwlock.h b/src/libnx/wrapper/nx/include/switch/kernel/rwlock.h deleted file mode 100644 index eb70b43..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/rwlock.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file rwlock.h - * @brief Read/write lock synchronization primitive. - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../kernel/mutex.h" - -/// Read/write lock structure. -typedef struct { - RMutex r; - RMutex g; - u64 b; -} RwLock; - -/** - * @brief Locks the read/write lock for reading. - * @param r Read/write lock object. - */ -void rwlockReadLock(RwLock* r); - -/** - * @brief Unlocks the read/write lock for reading. - * @param r Read/write lock object. - */ -void rwlockReadUnlock(RwLock* r); - -/** - * @brief Locks the read/write lock for writing. - * @param r Read/write lock object. - */ -void rwlockWriteLock(RwLock* r); - -/** - * @brief Unlocks the read/write lock for writing. - * @param r Read/write lock object. - */ -void rwlockWriteUnlock(RwLock* r); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/shmem.h b/src/libnx/wrapper/nx/include/switch/kernel/shmem.h deleted file mode 100644 index b40af1b..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/shmem.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file shmem.h - * @brief Shared memory object handling - * @author plutoo - * @copyright libnx Authors - * @remark Shared memory differs from transfer memory in the fact that the kernel (as opposed to the user process) allocates and owns its backing memory. - */ -#pragma once -#include "../types.h" - -/// Shared memory information structure. -typedef struct { - Handle handle; ///< Kernel object handle. - size_t size; ///< Size of the shared memory object. - Permission perm; ///< Permissions. - void* map_addr; ///< Address to which the shared memory object is mapped. -} SharedMemory; - -/** - * @brief Creates a shared memory object. - * @param s Shared memory information structure which will be filled in. - * @param size Size of the shared memory object to create. - * @param local_perm Permissions with which the shared memory object will be mapped in the local process. - * @param remote_perm Permissions with which the shared memory object will be mapped in the remote process (can be Perm_DontCare). - * @return Result code. - * @warning This is a privileged operation; in normal circumstances applications cannot use this function. - */ -Result shmemCreate(SharedMemory* s, size_t size, Permission local_perm, Permission remote_perm); - -/** - * @brief Loads a shared memory object coming from a remote process. - * @param s Shared memory information structure which will be filled in. - * @param handle Handle of the shared memory object. - * @param size Size of the shared memory object that is being loaded. - * @param perm Permissions with which the shared memory object will be mapped in the local process. - */ -void shmemLoadRemote(SharedMemory* s, Handle handle, size_t size, Permission perm); - -/** - * @brief Maps a shared memory object. - * @param s Shared memory information structure. - * @return Result code. - */ -Result shmemMap(SharedMemory* s); - -/** - * @brief Unmaps a shared memory object. - * @param s Shared memory information structure. - * @return Result code. - */ -Result shmemUnmap(SharedMemory* s); - -/** - * @brief Retrieves the mapped address of a shared memory object. - * @param s Shared memory information structure. - * @return Mapped address of the shared memory object. - */ -static inline void* shmemGetAddr(SharedMemory* s) { - return s->map_addr; -} - -/** - * @brief Frees up resources used by a shared memory object, unmapping and closing handles, etc. - * @param s Shared memory information structure. - * @return Result code. - */ -Result shmemClose(SharedMemory* s); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/svc.h b/src/libnx/wrapper/nx/include/switch/kernel/svc.h deleted file mode 100644 index e5d0c4b..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/svc.h +++ /dev/null @@ -1,1077 +0,0 @@ -/** - * @file svc.h - * @brief Wrappers for kernel syscalls. - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/// Pseudo handle for the current process. -#define CUR_PROCESS_HANDLE 0xFFFF8001 - -/// Pseudo handle for the current thread. -#define CUR_THREAD_HANDLE 0xFFFF8000 - -/// Memory type enumeration (lower 8 bits of \ref MemoryState) -typedef enum { - MemType_Unmapped=0x00, ///< Unmapped memory. - MemType_Io=0x01, ///< Mapped by kernel capability parsing in \ref svcCreateProcess. - MemType_Normal=0x02, ///< Mapped by kernel capability parsing in \ref svcCreateProcess. - MemType_CodeStatic=0x03, ///< Mapped during \ref svcCreateProcess. - MemType_CodeMutable=0x04, ///< Transition from MemType_CodeStatic performed by \ref svcSetProcessMemoryPermission. - MemType_Heap=0x05, ///< Mapped using \ref svcSetHeapSize. - MemType_SharedMem=0x06, ///< Mapped using \ref svcMapSharedMemory. - MemType_WeirdMappedMem=0x07, ///< Mapped using \ref svcMapMemory. - MemType_ModuleCodeStatic=0x08, ///< Mapped using \ref svcMapProcessCodeMemory. - MemType_ModuleCodeMutable=0x09, ///< Transition from \ref MemType_ModuleCodeStatic performed by \ref svcSetProcessMemoryPermission. - MemType_IpcBuffer0=0x0A, ///< IPC buffers with descriptor flags=0. - MemType_MappedMemory=0x0B, ///< Mapped using \ref svcMapMemory. - MemType_ThreadLocal=0x0C, ///< Mapped during \ref svcCreateThread. - MemType_TransferMemIsolated=0x0D, ///< Mapped using \ref svcMapTransferMemory when the owning process has perm=0. - MemType_TransferMem=0x0E, ///< Mapped using \ref svcMapTransferMemory when the owning process has perm!=0. - MemType_ProcessMem=0x0F, ///< Mapped using \ref svcMapProcessMemory. - MemType_Reserved=0x10, ///< Reserved. - MemType_IpcBuffer1=0x11, ///< IPC buffers with descriptor flags=1. - MemType_IpcBuffer3=0x12, ///< IPC buffers with descriptor flags=3. - MemType_KernelStack=0x13, ///< Mapped in kernel during \ref svcCreateThread. - MemType_CodeReadOnly=0x14, ///< Mapped in kernel during \ref svcControlCodeMemory. - MemType_CodeWritable=0x15, ///< Mapped in kernel during \ref svcControlCodeMemory. -} MemoryType; - -/// Memory state bitmasks. -typedef enum { - MemState_Type=0xFF, ///< Type field (see \ref MemoryType). - MemState_PermChangeAllowed=BIT(8), ///< Permission change allowed. - MemState_ForceRwByDebugSyscalls=BIT(9), ///< Force read/writable by debug syscalls. - MemState_IpcSendAllowed_Type0=BIT(10), ///< IPC type 0 send allowed. - MemState_IpcSendAllowed_Type3=BIT(11), ///< IPC type 3 send allowed. - MemState_IpcSendAllowed_Type1=BIT(12), ///< IPC type 1 send allowed. - MemState_ProcessPermChangeAllowed=BIT(14), ///< Process permission change allowed. - MemState_MapAllowed=BIT(15), ///< Map allowed. - MemState_UnmapProcessCodeMemAllowed=BIT(16), ///< Unmap process code memory allowed. - MemState_TransferMemAllowed=BIT(17), ///< Transfer memory allowed. - MemState_QueryPAddrAllowed=BIT(18), ///< Query physical address allowed. - MemState_MapDeviceAllowed=BIT(19), ///< Map device allowed (\ref svcMapDeviceAddressSpace and \ref svcMapDeviceAddressSpaceByForce). - MemState_MapDeviceAlignedAllowed=BIT(20), ///< Map device aligned allowed. - MemState_IpcBufferAllowed=BIT(21), ///< IPC buffer allowed. - MemState_IsPoolAllocated=BIT(22), ///< Is pool allocated. - MemState_IsRefCounted=MemState_IsPoolAllocated, ///< Alias for \ref MemState_IsPoolAllocated. - MemState_MapProcessAllowed=BIT(23), ///< Map process allowed. - MemState_AttrChangeAllowed=BIT(24), ///< Attribute change allowed. - MemState_CodeMemAllowed=BIT(25), ///< Code memory allowed. -} MemoryState; - -/// Memory attribute bitmasks. -typedef enum { - MemAttr_IsBorrowed=BIT(0), ///< Is borrowed memory. - MemAttr_IsIpcMapped=BIT(1), ///< Is IPC mapped (when IpcRefCount > 0). - MemAttr_IsDeviceMapped=BIT(2), ///< Is device mapped (when DeviceRefCount > 0). - MemAttr_IsUncached=BIT(3), ///< Is uncached. -} MemoryAttribute; - -/// Memory permission bitmasks. -typedef enum { - Perm_None = 0, ///< No permissions. - Perm_R = BIT(0), ///< Read permission. - Perm_W = BIT(1), ///< Write permission. - Perm_X = BIT(2), ///< Execute permission. - Perm_Rw = Perm_R | Perm_W, ///< Read/write permissions. - Perm_Rx = Perm_R | Perm_X, ///< Read/execute permissions. - Perm_DontCare = BIT(28), ///< Don't care -} Permission; - -/// Memory information structure. -typedef struct { - u64 addr; ///< Base address. - u64 size; ///< Size. - u32 type; ///< Memory type (see lower 8 bits of \ref MemoryState). - u32 attr; ///< Memory attributes (see \ref MemoryAttribute). - u32 perm; ///< Memory permissions (see \ref Permission). - u32 device_refcount; ///< Device reference count. - u32 ipc_refcount; ///< IPC reference count. - u32 padding; ///< Padding. -} MemoryInfo; - -/// Secure monitor arguments. -typedef struct { - u64 X[8]; ///< Values of X0 through X7. -} PACKED SecmonArgs; - -/// Code memory mapping operations -typedef enum { - CodeMapOperation_MapOwner=0, ///< Map owner. - CodeMapOperation_MapSlave=1, ///< Map slave. - CodeMapOperation_UnmapOwner=2, ///< Unmap owner. - CodeMapOperation_UnmapSlave=3, ///< Unmap slave. -} CodeMapOperation; - -/// Limitable Resources. -typedef enum { - LimitableResource_Memory=0, ///switchbrew.org Wiki for more details. - * @note Syscall number 0x02. - */ -Result svcSetMemoryAttribute(void* addr, u64 size, u32 val0, u32 val1); - -/** - * @brief Maps a memory range into a different range. Mainly used for adding guard pages around stack. - * Source range gets reprotected to Perm_None (it can no longer be accessed), and \ref MemAttr_IsBorrowed is set in the source \ref MemoryAttribute. - * @param[in] dst_addr Destination address. - * @param[in] src_addr Source address. - * @param[in] size Size of the range. - * @return Result code. - * @note Syscall number 0x04. - */ -Result svcMapMemory(void* dst_addr, void* src_addr, u64 size); - -/** - * @brief Unmaps a region that was previously mapped with \ref svcMapMemory. - * @param[in] dst_addr Destination address. - * @param[in] src_addr Source address. - * @param[in] size Size of the range. - * @return Result code. - * @note Syscall number 0x05. - */ -Result svcUnmapMemory(void* dst_addr, void* src_addr, u64 size); - -/** - * @brief Query information about an address. Will always fetch the lowest page-aligned mapping that contains the provided address. - * @param[out] meminfo_ptr \ref MemoryInfo structure which will be filled in. - * @param[out] page_info Page information which will be filled in. - * @param[in] addr Address to query. - * @return Result code. - * @note Syscall number 0x06. - */ -Result svcQueryMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, u64 addr); - -///@} - -///@name Process and thread management -///@{ - -/** - * @brief Exits the current process. - * @note Syscall number 0x07. - */ - -void NORETURN svcExitProcess(void); - -/** - * @brief Creates a thread. - * @return Result code. - * @note Syscall number 0x08. - */ -Result svcCreateThread(Handle* out, void* entry, void* arg, void* stack_top, int prio, int cpuid); - -/** - * @brief Starts a freshly created thread. - * @return Result code. - * @note Syscall number 0x09. - */ -Result svcStartThread(Handle handle); - -/** - * @brief Exits the current thread. - * @note Syscall number 0x0A. - */ -void NORETURN svcExitThread(void); - -/** - * @brief Sleeps the current thread for the specified amount of time. - * @return Result code. - * @note Syscall number 0x0B. - */ -Result svcSleepThread(u64 nano); - -/** - * @brief Gets a thread's priority. - * @return Result code. - * @note Syscall number 0x0C. - */ -Result svcGetThreadPriority(u32* priority, Handle handle); - -/** - * @brief Sets a thread's priority. - * @return Result code. - * @note Syscall number 0x0D. - */ -Result svcSetThreadPriority(Handle handle, u32 priority); - -/** - * @brief Gets the current processor's number. - * @return The current processor's number. - * @note Syscall number 0x10. - */ -u32 svcGetCurrentProcessorNumber(void); - -///@} - -///@name Synchronization -///@{ - -/** - * @brief Sets an event's signalled status. - * @return Result code. - * @note Syscall number 0x11. - */ -Result svcSignalEvent(Handle handle); - -/** - * @brief Clears an event's signalled status. - * @return Result code. - * @note Syscall number 0x12. - */ -Result svcClearEvent(Handle handle); - -///@} - -///@name Inter-process memory sharing -///@{ - -/** - * @brief Maps a block of shared memory. - * @return Result code. - * @note Syscall number 0x13. - */ -Result svcMapSharedMemory(Handle handle, void* addr, size_t size, u32 perm); - -/** - * @brief Unmaps a block of shared memory. - * @return Result code. - * @note Syscall number 0x14. - */ -Result svcUnmapSharedMemory(Handle handle, void* addr, size_t size); - -/** - * @brief Creates a block of transfer memory. - * @return Result code. - * @note Syscall number 0x15. - */ -Result svcCreateTransferMemory(Handle* out, void* addr, size_t size, u32 perm); - -///@} - -///@name Miscellaneous -///@{ - -/** - * @brief Closes a handle, decrementing the reference count of the corresponding kernel object. - * This might result in the kernel freeing the object. - * @param handle Handle to close. - * @return Result code. - * @note Syscall number 0x16. - */ -Result svcCloseHandle(Handle handle); - -///@} - -///@name Synchronization -///@{ - -/** - * @brief Resets a signal. - * @return Result code. - * @note Syscall number 0x17. - */ -Result svcResetSignal(Handle handle); - -///@} - -///@name Synchronization -///@{ - -/** - * @brief Waits on one or more synchronization objects, optionally with a timeout. - * @return Result code. - * @note Syscall number 0x18. - */ -Result svcWaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout); - -/** - * @brief Waits on a single synchronization object, optionally with a timeout. - * @return Result code. - * @note Wrapper for \ref svcWaitSynchronization. - */ -static inline Result svcWaitSynchronizationSingle(Handle handle, u64 timeout) { - s32 tmp; - return svcWaitSynchronization(&tmp, &handle, 1, timeout); -} - -/** - * @brief Waits a \ref svcWaitSynchronization operation being done on a synchronization object in another thread. - * @return Result code. - * @note Syscall number 0x19. - */ -Result svcCancelSynchronization(Handle thread); - -/** - * @brief Arbitrates a mutex lock operation in userspace. - * @return Result code. - * @note Syscall number 0x1A. - */ -Result svcArbitrateLock(u32 wait_tag, u32* tag_location, u32 self_tag); - -/** - * @brief Arbitrates a mutex unlock operation in userspace. - * @return Result code. - * @note Syscall number 0x1B. - */ -Result svcArbitrateUnlock(u32* tag_location); - -/** - * @brief Performs a condition variable wait operation in userspace. - * @return Result code. - * @note Syscall number 0x1C. - */ -Result svcWaitProcessWideKeyAtomic(u32* key, u32* tag_location, u32 self_tag, u64 timeout); - -/** - * @brief Performs a condition variable wake-up operation in userspace. - * @return Result code. - * @note Syscall number 0x1D. - */ -Result svcSignalProcessWideKey(u32* key, s32 num); - -///@} - -///@name Miscellaneous -///@{ - -/** - * @brief Gets the current system tick. - * @return The current system tick. - * @note Syscall number 0x1E. - */ -u64 svcGetSystemTick(void); - -///@} - -///@name Inter-process communication (IPC) -///@{ - -/** - * @brief Connects to a registered named port. - * @return Result code. - * @note Syscall number 0x1F. - */ -Result svcConnectToNamedPort(Handle* session, const char* name); - -/** - * @brief Sends an IPC synchronization request to a session. - * @return Result code. - * @note Syscall number 0x21. - */ -Result svcSendSyncRequest(Handle session); - -/** - * @brief Sends an IPC synchronization request to a session from an user allocated buffer. - * @return Result code. - * @remark size must be allocated to 0x1000 bytes. - * @note Syscall number 0x22. - */ -Result svcSendSyncRequestWithUserBuffer(void* usrBuffer, u64 size, Handle session); - -/** - * @brief Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version). - * @return Result code. - * @remark size must be allocated to 0x1000 bytes. - * @note Syscall number 0x23. - */ -Result svcSendAsyncRequestWithUserBuffer(Handle* handle, void* usrBuffer, u64 size, Handle session); - -///@} - -///@name Process and thread management -///@{ - -/** - * @brief Gets the PID associated with a process. - * @return Result code. - * @note Syscall number 0x24. - */ -Result svcGetProcessId(u64 *processID, Handle handle); - -/** - * @brief Gets the TID associated with a process. - * @return Result code. - * @note Syscall number 0x25. - */ -Result svcGetThreadId(u64 *threadID, Handle handle); - -///@} - -///@name Miscellaneous -///@{ - -/** - * @brief Breaks execution. Panic. - * @param[in] breakReason Break reason. - * @param[in] inval1 First break parameter. - * @param[in] inval2 Second break parameter. - * @return Result code. - * @note Syscall number 0x26. - */ -Result svcBreak(u32 breakReason, u64 inval1, u64 inval2); - -///@} - -///@name Debugging -///@{ - -/** - * @brief Outputs debug text, if used during debugging. - * @param[in] str Text to output. - * @param[in] size Size of the text in bytes. - * @return Result code. - * @note Syscall number 0x27. - */ -Result svcOutputDebugString(const char *str, u64 size); - -///@} - -///@name Miscellaneous -///@{ - -/** - * @brief Retrieves information about the system, or a certain kernel object. - * @param[out] out Variable to which store the information. - * @param[in] id0 First ID of the property to retrieve. - * @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system. - * @param[in] id1 Second ID of the property to retrieve. - * @return Result code. - * @remark The full list of property IDs can be found on the switchbrew.org wiki. - * @note Syscall number 0x29. - */ -Result svcGetInfo(u64* out, u64 id0, Handle handle, u64 id1); - -///@} - -///@name Memory management -///@{ - -/** - * @brief Maps new heap memory at the desired address. [3.0.0+] - * @return Result code. - * @note Syscall number 0x2A. - */ -Result svcMapPhysicalMemory(void *address, u64 size); - -/** - * @brief Undoes the effects of \ref svcMapPhysicalMemory. [3.0.0+] - * @return Result code. - * @note Syscall number 0x2B. - */ -Result svcUnmapPhysicalMemory(void *address, u64 size); - -///@} - -///@name Process and thread management -///@{ - -/** - * @brief Configures the pause/unpause status of a thread. - * @return Result code. - * @note Syscall number 0x32. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcSetThreadActivity(Handle thread, bool paused); - -///@} - -///@name Resource Limit Management -///@{ - -/** - * @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle. - * @return Result code. - * @note Syscall number 0x30. - */ -Result svcGetResourceLimitLimitValue(u64 *out, Handle reslimit_h, LimitableResource which); - -/** - * @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle. - * @return Result code. - * @note Syscall number 0x31. - */ -Result svcGetResourceLimitCurrentValue(u64 *out, Handle reslimit_h, LimitableResource which); - -///@} - -///@name Inter-process communication (IPC) -///@{ - -/** - * @brief Creates an IPC session. - * @return Result code. - * @note Syscall number 0x40. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreateSession(Handle *server_handle, Handle *client_handle, u32 unk0, u64 unk1);//unk* are normally 0? - -/** - * @brief Accepts an IPC session. - * @return Result code. - * @note Syscall number 0x41. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcAcceptSession(Handle *session_handle, Handle port_handle); - -/** - * @brief Performs IPC input/output. - * @return Result code. - * @note Syscall number 0x43. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout); - -/** - * @brief Performs IPC input/output from an user allocated buffer. - * @return Result code. - * @note Syscall number 0x44. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcReplyAndReceiveWithUserBuffer(s32* index, void* usrBuffer, u64 size, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout); - -///@} - -///@name Synchronization -///@{ - -/** - * @brief Creates a system event. - * @return Result code. - * @note Syscall number 0x45. - */ -Result svcCreateEvent(Handle* server_handle, Handle* client_handle); - -///@} - -///@name Memory management -///@{ - -/** - * @brief Maps unsafe memory (usable for GPU DMA) for a system module at the desired address. [5.0.0+] - * @return Result code. - * @note Syscall number 0x48. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcMapPhysicalMemoryUnsafe(void *address, u64 size); - -/** - * @brief Undoes the effects of \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] - * @return Result code. - * @note Syscall number 0x49. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcUnmapPhysicalMemoryUnsafe(void *address, u64 size); - -/** - * @brief Sets the system-wide limit for unsafe memory mappable using \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] - * @return Result code. - * @note Syscall number 0x4A. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcSetUnsafeLimit(u64 size); - -///@} - - -///@name Code memory / Just-in-time (JIT) compilation support -///@{ - -/** - * @brief Creates code memory in the caller's address space [4.0.0+]. - * @return Result code. - * @note Syscall number 0x4B. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreateCodeMemory(Handle* code_handle, void* src_addr, u64 size); - -/** - * @brief Maps code memory in the caller's address space [4.0.0+]. - * @return Result code. - * @note Syscall number 0x4C. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcControlCodeMemory(Handle code_handle, CodeMapOperation op, void* dst_addr, u64 size, u64 perm); - -///@} - -///@name Device memory-mapped I/O (MMIO) -///@{ - -/** - * @brief Reads/writes a protected MMIO register. - * @return Result code. - * @note Syscall number 0x4E. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcReadWriteRegister(u32* outVal, u64 regAddr, u32 rwMask, u32 inVal); - -///@} - -///@name Inter-process memory sharing -///@{ - -/** - * @brief Creates a block of shared memory. - * @return Result code. - * @note Syscall number 0x50. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreateSharedMemory(Handle* out, size_t size, u32 local_perm, u32 other_perm); - -/** - * @brief Maps a block of transfer memory. - * @return Result code. - * @note Syscall number 0x51. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcMapTransferMemory(Handle tmem_handle, void* addr, size_t size, u32 perm); - -/** - * @brief Unmaps a block of transfer memory. - * @return Result code. - * @note Syscall number 0x52. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcUnmapTransferMemory(Handle tmem_handle, void* addr, size_t size); - -///@} - -///@name Device memory-mapped I/O (MMIO) -///@{ - -/** - * @brief Creates an event and binds it to a specific hardware interrupt. - * @return Result code. - * @note Syscall number 0x53. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreateInterruptEvent(Handle* handle, u64 irqNum, u32 flag); - -/** - * @brief Queries information about a certain virtual address, including its physical address. - * @return Result code. - * @note Syscall number 0x54. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcQueryPhysicalAddress(u64 out[3], u64 virtaddr); - -/** - * @brief Returns a virtual address mapped to a given IO range. - * @return Result code. - * @note Syscall number 0x55. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size); - -///@} - -///@name I/O memory management unit (IOMMU) -///@{ - -/** - * @brief Creates a virtual address space for binding device address spaces. - * @return Result code. - * @note Syscall number 0x56. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreateDeviceAddressSpace(Handle *handle, u64 dev_addr, u64 dev_size); - -/** - * @brief Attaches a device address space to a device. - * @return Result code. - * @note Syscall number 0x57. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcAttachDeviceAddressSpace(u64 device, Handle handle); - -/** - * @brief Detaches a device address space from a device. - * @return Result code. - * @note Syscall number 0x58. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcDetachDeviceAddressSpace(u64 device, Handle handle); - -/** - * @brief Maps an attached device address space to an userspace address. - * @return Result code. - * @remark The userspace destination address must have the \ref MemState_MapDeviceAllowed bit set. - * @note Syscall number 0x59. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm); - -/** - * @brief Maps an attached device address space to an userspace address. - * @return Result code. - * @remark The userspace destination address must have the \ref MemState_MapDeviceAlignedAllowed bit set. - * @note Syscall number 0x5A. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm); - -/** - * @brief Unmaps an attached device address space from an userspace address. - * @return Result code. - * @note Syscall number 0x5C. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcUnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 dev_addr); - -///@} - -///@name Debugging -///@{ - -/** - * @brief Debugs an active process. - * @return Result code. - * @note Syscall number 0x60. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcDebugActiveProcess(Handle* debug, u64 processID); - -/** - * @brief Breaks an active debugging session. - * @return Result code. - * @note Syscall number 0x61. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcBreakDebugProcess(Handle debug); - -/** - * @brief Gets an incoming debug event from a debugging session. - * @return Result code. - * @note Syscall number 0x63. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcGetDebugEvent(u8* event_out, Handle debug); - -/** - * @brief Continues a debugging session. - * @return Result code. - * @note Syscall number 0x64. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcContinueDebugEvent(Handle debug, u32 flags, u64 threadID); - -/** - * @brief Gets the context of a thread in a debugging session. - * @return Result code. - * @note Syscall number 0x67. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcGetDebugThreadContext(u8* out, Handle debug, u64 threadID, u32 flags); - -///@} - -///@name Process and thread management -///@{ - -/** - * @brief Retrieves a list of all running processes. - * @return Result code. - * @note Syscall number 0x65. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcGetProcessList(u32 *num_out, u64 *pids_out, u32 max_pids); - -/** - * @brief Retrieves a list of all threads for a debug handle (or zero). - * @return Result code. - * @note Syscall number 0x66. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcGetThreadList(u32 *num_out, u64 *tids_out, u32 max_tids, Handle debug); - -///@} - -///@name Debugging -///@{ - -/** - * @brief Queries memory information from a process that is being debugged. - * @return Result code. - * @note Syscall number 0x69. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcQueryDebugProcessMemory(MemoryInfo* meminfo_ptr, u32* pageinfo, Handle debug, u64 addr); - -/** - * @brief Reads memory from a process that is being debugged. - * @return Result code. - * @note Syscall number 0x6A. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcReadDebugProcessMemory(void* buffer, Handle debug, u64 addr, u64 size); - -/** - * @brief Writes to memory in a process that is being debugged. - * @return Result code. - * @note Syscall number 0x6B. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcWriteDebugProcessMemory(Handle debug, void* buffer, u64 addr, u64 size); - -/** - * @brief Gets parameters from a thread in a debugging session. - * @return Result code. - * @note Syscall number 0x6D. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcGetDebugThreadParam(u64* out_64, u32* out_32, Handle debug, u64 threadID, DebugThreadParam param); - -///@} - -///@name Miscellaneous -///@{ - -/** - * @brief Retrieves privileged information about the system, or a certain kernel object. - * @param[out] out Variable to which store the information. - * @param[in] id0 First ID of the property to retrieve. - * @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system. - * @param[in] id1 Second ID of the property to retrieve. - * @return Result code. - * @remark The full list of property IDs can be found on the switchbrew.org wiki. - * @note Syscall number 0x6F. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcGetSystemInfo(u64* out, u64 id0, Handle handle, u64 id1); - -///@} - -///@name Inter-process communication (IPC) -///@{ - -/** - * @brief Creates a port. - * @return Result code. - * @note Syscall number 0x70. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreatePort(Handle* portServer, Handle *portClient, s32 max_sessions, bool is_light, const char* name); - -/** - * @brief Manages a named port. - * @return Result code. - * @note Syscall number 0x71. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcManageNamedPort(Handle* portServer, const char* name, s32 maxSessions); - -/** - * @brief Manages a named port. - * @return Result code. - * @note Syscall number 0x72. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcConnectToPort(Handle* session, Handle port); - -///@} - -///@name Memory management -///@{ - -/** - * @brief Sets the memory permissions for the specified memory with the supplied process handle. - * @param[in] proc Process handle. - * @param[in] addr Address of the memory. - * @param[in] size Size of the memory. - * @param[in] perm Permissions (see \ref Permission). - * @return Result code. - * @remark This returns an error (0xD801) when \p perm is >0x5, hence -WX and RWX are not allowed. - * @note Syscall number 0x73. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcSetProcessMemoryPermission(Handle proc, u64 addr, u64 size, u32 perm); - -/** - * @brief Maps the src address from the supplied process handle into the current process. - * @param[in] dst Address to which map the memory in the current process. - * @param[in] proc Process handle. - * @param[in] src Source mapping address. - * @param[in] size Size of the memory. - * @return Result code. - * @remark This allows mapping code and rodata with RW- permission. - * @note Syscall number 0x74. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcMapProcessMemory(void* dst, Handle proc, u64 src, u64 size); - -/** - * @brief Undoes the effects of \ref svcMapProcessMemory. - * @param[in] dst Destination mapping address - * @param[in] proc Process handle. - * @param[in] src Address of the memory in the process. - * @param[in] size Size of the memory. - * @return Result code. - * @remark This allows mapping code and rodata with RW- permission. - * @note Syscall number 0x75. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcUnmapProcessMemory(void* dst, Handle proc, u64 src, u64 size); - -/** - * @brief Maps normal heap in a certain process as executable code (used when loading NROs). - * @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE). - * @param[in] dst Destination mapping address. - * @param[in] src Source mapping address. - * @param[in] size Size of the mapping. - * @return Result code. - * @note Syscall number 0x77. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcMapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size); - -/** - * @brief Undoes the effects of \ref svcMapProcessCodeMemory. - * @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE). - * @param[in] dst Destination mapping address. - * @param[in] src Source mapping address. - * @param[in] size Size of the mapping. - * @return Result code. - * @note Syscall number 0x78. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcUnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size); - -///@} - -///@name Process and thread management -///@{ - -/** - * @brief Creates a new process. - * @return Result code. - * @note Syscall number 0x79. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreateProcess(Handle* out, void* proc_info, u32* caps, u64 cap_num); - -/** - * @brief Starts executing a freshly created process. - * @return Result code. - * @note Syscall number 0x7A. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcStartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size); - -/** - * @brief Terminates a running process. - * @return Result code. - * @note Syscall number 0x7B. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcTerminateProcess(Handle proc); - -/** - * @brief Gets a \ref ProcessInfoType for a process. - * @return Result code. - * @note Syscall number 0x7C. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcGetProcessInfo(u64 *out, Handle proc, ProcessInfoType which); - -///@} - -///@name Resource Limit Management -///@{ - -/** - * @brief Creates a new Resource Limit handle. - * @return Result code. - * @note Syscall number 0x7D. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcCreateResourceLimit(Handle* out); - -/** - * @brief Sets the value for a \ref LimitableResource for a Resource Limit handle. - * @return Result code. - * @note Syscall number 0x7E. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -Result svcSetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u64 value); - -///@} - -///@name ( ͡° ͜ʖ ͡°) -///@{ - -/** - * @brief Calls a secure monitor function (TrustZone, EL3). - * @param regs Arguments to pass to the secure monitor. - * @return Return value from the secure monitor. - * @note Syscall number 0x7F. - * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. - */ -u64 svcCallSecureMonitor(SecmonArgs* regs); - -///@} diff --git a/src/libnx/wrapper/nx/include/switch/kernel/thread.h b/src/libnx/wrapper/nx/include/switch/kernel/thread.h deleted file mode 100644 index da146b2..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/thread.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file thread.h - * @brief Multi-threading support - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/// Thread information structure. -typedef struct { - Handle handle; ///< Thread handle. - void* stack_mem; ///< Pointer to stack memory. - void* stack_mirror; ///< Pointer to stack memory mirror. - size_t stack_sz; ///< Stack size. -} Thread; - -/** - * @brief Creates a thread. - * @param t Thread information structure which will be filled in. - * @param entry Entrypoint of the thread. - * @param arg Argument to pass to the entrypoint. - * @param stack_sz Stack size (rounded up to page alignment). - * @param prio Thread priority (0x00~0x3F); 0x2C is the usual priority of the main thread. - * @param cpuid ID of the core on which to create the thread (0~3); or -2 to use the default core for the current process. - * @return Result code. - */ -Result threadCreate( - Thread* t, ThreadFunc entry, void* arg, size_t stack_sz, int prio, - int cpuid); - -/** - * @brief Starts the execution of a thread. - * @param t Thread information structure. - * @return Result code. - */ -Result threadStart(Thread* t); - -/** - * @brief Waits for a thread to finish executing. - * @param t Thread information structure. - * @return Result code. - */ -Result threadWaitForExit(Thread* t); - -/** - * @brief Frees up resources associated with a thread. - * @param t Thread information structure. - * @return Result code. - */ -Result threadClose(Thread* t); - -/** - * @brief Pauses the execution of a thread. - * @param t Thread information structure. - * @return Result code. - * @warning This is a privileged operation; in normal circumstances applications cannot use this function. - */ -Result threadPause(Thread* t); - -/** - * @brief Resumes the execution of a thread, after having been paused. - * @param t Thread information structure. - * @return Result code. - * @warning This is a privileged operation; in normal circumstances applications cannot use this function. - */ -Result threadResume(Thread* t); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/tmem.h b/src/libnx/wrapper/nx/include/switch/kernel/tmem.h deleted file mode 100644 index 4093812..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/tmem.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file tmem.h - * @brief Transfer memory handling - * @author plutoo - * @copyright libnx Authors - * @remark Transfer memory differs from shared memory in the fact that the user process (as opposed to the kernel) allocates and owns its backing memory. - */ -#pragma once -#include "../types.h" -#include "../kernel/svc.h" - -/// Transfer memory information structure. -typedef struct { - Handle handle; ///< Kernel object handle. - size_t size; ///< Size of the transfer memory object. - Permission perm; ///< Permissions of the transfer memory object. - void* src_addr; ///< Address of the source backing memory. - void* map_addr; ///< Address to which the transfer memory object is mapped. -} TransferMemory; - -/** - * @brief Creates a transfer memory object. - * @param t Transfer memory information structure that will be filled in. - * @param size Size of the transfer memory object to create. - * @param perm Permissions with which to protect the transfer memory in the local process. - * @return Result code. - */ -Result tmemCreate(TransferMemory* t, size_t size, Permission perm); - -/** - * @brief Loads a transfer memory object coming from a remote process. - * @param t Transfer memory information structure which will be filled in. - * @param handle Handle of the transfer memory object. - * @param size Size of the transfer memory object that is being loaded. - * @param perm Permissions which the transfer memory is expected to have in the process that owns the memory. - * @warning This is a privileged operation; in normal circumstances applications shouldn't use this function. - */ -void tmemLoadRemote(TransferMemory* t, Handle handle, size_t size, Permission perm); - -/** - * @brief Maps a transfer memory object. - * @param t Transfer memory information structure. - * @return Result code. - * @warning This is a privileged operation; in normal circumstances applications cannot use this function. - */ -Result tmemMap(TransferMemory* t); - -/** - * @brief Unmaps a transfer memory object. - * @param t Transfer memory information structure. - * @return Result code. - * @warning This is a privileged operation; in normal circumstances applications cannot use this function. - */ -Result tmemUnmap(TransferMemory* t); - -/** - * @brief Retrieves the mapped address of a transfer memory object. - * @param t Transfer memory information structure. - * @return Mapped address of the transfer memory object. - */ -static inline void* tmemGetAddr(TransferMemory* t){ - return t->map_addr; -} - -/** - * @brief Frees up resources used by a transfer memory object, unmapping and closing handles, etc. - * @param t Transfer memory information structure. - * @return Result code. - */ -Result tmemClose(TransferMemory* t); diff --git a/src/libnx/wrapper/nx/include/switch/kernel/virtmem.h b/src/libnx/wrapper/nx/include/switch/kernel/virtmem.h deleted file mode 100644 index f5cec3a..0000000 --- a/src/libnx/wrapper/nx/include/switch/kernel/virtmem.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file virtmem.h - * @brief Virtual memory mapping utilities - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/** - * @brief Reserves a slice of general purpose address space. - * @param size The size of the slice of address space that will be reserved (rounded up to page alignment). - * @return Pointer to the slice of address space, or NULL on failure. - */ -void* virtmemReserve(size_t size); - -/** - * @brief Relinquishes a slice of address space reserved with virtmemReserve (currently no-op). - * @param addr Pointer to the slice. - * @param size Size of the slice. - */ -void virtmemFree(void* addr, size_t size); - -/** - * @brief Reserves a slice of address space inside the alias memory mapping region(s) (for use with svcMapMemory). - * @param size The size of the slice of address space that will be reserved (rounded up to page alignment). - * @return Pointer to the slice of address space, or NULL on failure. - */ -void* virtmemReserveMap(size_t size); - -/** - * @brief Relinquishes a slice of address space reserved with virtmemReserveMap (currently no-op). - * @param addr Pointer to the slice. - * @param size Size of the slice. - */ -void virtmemFreeMap(void* addr, size_t size); diff --git a/src/libnx/wrapper/nx/include/switch/nacp.h b/src/libnx/wrapper/nx/include/switch/nacp.h deleted file mode 100644 index 48fee47..0000000 --- a/src/libnx/wrapper/nx/include/switch/nacp.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file nacp.h - * @brief Control.nacp structure / related code for nacp. - * @copyright libnx Authors - */ - -#pragma once - -/// Language entry. These strings are UTF-8. -typedef struct { - char name[0x200]; - char author[0x100]; -} NacpLanguageEntry; - -typedef struct { - NacpLanguageEntry lang[16]; - - u8 x3000_unk[0x24];////Normally all-zero? - u32 x3024_unk; - u32 x3028_unk; - u32 x302C_unk; - u32 x3030_unk; - u32 x3034_unk; - u64 titleID0; - - u8 x3040_unk[0x20]; - char version[0x10]; - - u64 titleID_DlcBase; - u64 titleID1; - - u32 x3080_unk; - u32 x3084_unk; - u32 x3088_unk; - u8 x308C_unk[0x24];//zeros? - - u64 titleID2; - u64 titleIDs[7];//"Array of application titleIDs, normally the same as the above app-titleIDs. Only set for game-updates?" - - u32 x30F0_unk; - u32 x30F4_unk; - - u64 titleID3;//"Application titleID. Only set for game-updates?" - - char bcatPassphrase[0x40]; - u8 x3140_unk[0xEC0];//Normally all-zero? -} NacpStruct; - -/// Get the NacpLanguageEntry from the input nacp corresponding to the current system language (this may fallback to other languages when needed). Output langentry is NULL if none found / content of entry is empty. -Result nacpGetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry); - diff --git a/src/libnx/wrapper/nx/include/switch/nro.h b/src/libnx/wrapper/nx/include/switch/nro.h deleted file mode 100644 index 53e7c27..0000000 --- a/src/libnx/wrapper/nx/include/switch/nro.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file nro.h - * @brief NRO headers. - * @copyright libnx Authors - */ - -#pragma once - -#define NROHEADER_MAGIC 0x304f524e - -#define NROASSETHEADER_MAGIC 0x54455341 -#define NROASSETHEADER_VERSION 0 - -/// Entry for each segment in the codebin. -typedef struct { - u32 file_off; - u32 size; -} NroSegment; - -/// Offset 0x0 in the NRO. -typedef struct { - u32 unused; - u32 mod_offset; - u8 padding[8]; -} NroStart; - -/// This follows NroStart, the actual nro-header. -typedef struct { - u32 magic; - u32 unk1; - u32 size; - u32 unk2; - NroSegment segments[3]; - u32 bss_size; - u32 unk3; - u8 build_id[0x20]; - u8 padding[0x20]; -} NroHeader; - -/// Custom asset section. -typedef struct { - u64 offset; - u64 size; -} NroAssetSection; - -/// Custom asset header. -typedef struct { - u32 magic; - u32 version; - NroAssetSection icon; - NroAssetSection nacp; - NroAssetSection romfs; -} NroAssetHeader; - diff --git a/src/libnx/wrapper/nx/include/switch/result.h b/src/libnx/wrapper/nx/include/switch/result.h deleted file mode 100644 index a48711b..0000000 --- a/src/libnx/wrapper/nx/include/switch/result.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @file result.h - * @brief Switch result code tools. - * @copyright libnx Authors - */ -#pragma once -#include "types.h" - -/// Checks whether a result code indicates success. -#define R_SUCCEEDED(res) ((res)==0) -/// Checks whether a result code indicates failure. -#define R_FAILED(res) ((res)!=0) -/// Returns the module ID of a result code. -#define R_MODULE(res) ((res)&0x1FF) -/// Returns the description of a result code. -#define R_DESCRIPTION(res) (((res)>>9)&0x1FFF) - -/// Builds a result code from its constituent components. -#define MAKERESULT(module,description) \ - ((((module)&0x1FF)) | ((description)&0x1FFF)<<9) - -/// Module values -enum { - Module_Kernel=1, - Module_Libnx=345, - Module_LibnxNvidia=348, -}; - -/// Kernel error codes -enum { - KernelError_Timeout=117, -}; - -/// libnx error codes -enum { - LibnxError_BadReloc=1, - LibnxError_OutOfMemory, - LibnxError_AlreadyMapped, - LibnxError_BadGetInfo_Stack, - LibnxError_BadGetInfo_Heap, - LibnxError_BadQueryMemory, - LibnxError_AlreadyInitialized, - LibnxError_NotInitialized, - LibnxError_NotFound, - LibnxError_IoError, - LibnxError_BadInput, - LibnxError_BadReent, - LibnxError_BufferProducerError, - LibnxError_HandleTooEarly, - LibnxError_HeapAllocFailed, - LibnxError_TooManyOverrides, - LibnxError_ParcelError, - LibnxError_BadGfxInit, - LibnxError_BadGfxEventWait, - LibnxError_BadGfxQueueBuffer, - LibnxError_BadGfxDequeueBuffer, - LibnxError_AppletCmdidNotFound, - LibnxError_BadAppletReceiveMessage, - LibnxError_BadAppletNotifyRunning, - LibnxError_BadAppletGetCurrentFocusState, - LibnxError_BadAppletGetOperationMode, - LibnxError_BadAppletGetPerformanceMode, - LibnxError_BadUsbCommsRead, - LibnxError_BadUsbCommsWrite, - LibnxError_InitFail_SM, - LibnxError_InitFail_AM, - LibnxError_InitFail_HID, - LibnxError_InitFail_FS, - LibnxError_BadGetInfo_Rng, - LibnxError_JitUnavailable, - LibnxError_WeirdKernel, - LibnxError_IncompatSysVer, - LibnxError_InitFail_Time, - LibnxError_TooManyDevOpTabs, - LibnxError_DomainMessageUnknownType, - LibnxError_DomainMessageTooManyObjectIds, -}; - -/// libnx nvidia error codes -enum { - LibnxNvidiaError_Unknown=1, - LibnxNvidiaError_NotImplemented, ///< Maps to Nvidia: 1 - LibnxNvidiaError_NotSupported, ///< Maps to Nvidia: 2 - LibnxNvidiaError_NotInitialized, ///< Maps to Nvidia: 3 - LibnxNvidiaError_BadParameter, ///< Maps to Nvidia: 4 - LibnxNvidiaError_Timeout, ///< Maps to Nvidia: 5 - LibnxNvidiaError_InsufficientMemory, ///< Maps to Nvidia: 6 - LibnxNvidiaError_ReadOnlyAttribute, ///< Maps to Nvidia: 7 - LibnxNvidiaError_InvalidState, ///< Maps to Nvidia: 8 - LibnxNvidiaError_InvalidAddress, ///< Maps to Nvidia: 9 - LibnxNvidiaError_InvalidSize, ///< Maps to Nvidia: 10 - LibnxNvidiaError_BadValue, ///< Maps to Nvidia: 11 - LibnxNvidiaError_AlreadyAllocated, ///< Maps to Nvidia: 13 - LibnxNvidiaError_Busy, ///< Maps to Nvidia: 14 - LibnxNvidiaError_ResourceError, ///< Maps to Nvidia: 15 - LibnxNvidiaError_CountMismatch, ///< Maps to Nvidia: 16 - LibnxNvidiaError_SharedMemoryTooSmall, ///< Maps to Nvidia: 0x1000 - LibnxNvidiaError_FileOperationFailed, ///< Maps to Nvidia: 0x30003 - LibnxNvidiaError_IoctlFailed, ///< Maps to Nvidia: 0x3000F -}; diff --git a/src/libnx/wrapper/nx/include/switch/runtime/devices/console.h b/src/libnx/wrapper/nx/include/switch/runtime/devices/console.h deleted file mode 100644 index 0d16a6a..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/devices/console.h +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @file console.h - * @brief Framebuffer text console. - * @author yellows8 - * @author WinterMute - * @copyright libnx Authors - * - * Provides stdio integration for printing to the Switch screen as well as debug print - * functionality provided by stderr. - * - * General usage is to initialize the console by: - * @code - * consoleDemoInit() - * @endcode - * or to customize the console usage by: - * @code - * consoleInit() - * @endcode - */ -#pragma once -#include "../../types.h" - -#define CONSOLE_ESC(x) "\x1b[" #x -#define CONSOLE_RESET CONSOLE_ESC(0m) -#define CONSOLE_BLACK CONSOLE_ESC(30m) -#define CONSOLE_RED CONSOLE_ESC(31;1m) -#define CONSOLE_GREEN CONSOLE_ESC(32;1m) -#define CONSOLE_YELLOW CONSOLE_ESC(33;1m) -#define CONSOLE_BLUE CONSOLE_ESC(34;1m) -#define CONSOLE_MAGENTA CONSOLE_ESC(35;1m) -#define CONSOLE_CYAN CONSOLE_ESC(36;1m) -#define CONSOLE_WHITE CONSOLE_ESC(37;1m) - -/// A callback for printing a character. -typedef bool(*ConsolePrint)(void* con, int c); - -/// A font struct for the console. -typedef struct ConsoleFont -{ - u16* gfx; ///< A pointer to the font graphics - u16 asciiOffset; ///< Offset to the first valid character in the font table - u16 numChars; ///< Number of characters in the font graphics -}ConsoleFont; - -/** - * @brief Console structure used to store the state of a console render context. - * - * Default values from consoleGetDefault(); - * @code - * PrintConsole defaultConsole = - * { - * //Font: - * { - * (u16*)default_font_bin, //font gfx - * 0, //first ascii character in the set - * 128, //number of characters in the font set - * }, - * 0,0, //cursorX cursorY - * 0,0, //prevcursorX prevcursorY - * 80, //console width - * 45, //console height - * 0, //window x - * 0, //window y - * 80, //window width - * 45, //window height - * 3, //tab size - * 0, //font character offset - * 0, //print callback - * false //console initialized - * }; - * @endcode - */ -typedef struct PrintConsole -{ - ConsoleFont font; ///< Font of the console - - u32 *frameBuffer; ///< Framebuffer address - u32 *frameBuffer2; ///< Framebuffer address - - int cursorX; ///< Current X location of the cursor (as a tile offset by default) - int cursorY; ///< Current Y location of the cursor (as a tile offset by default) - - int prevCursorX; ///< Internal state - int prevCursorY; ///< Internal state - - int consoleWidth; ///< Width of the console hardware layer in characters - int consoleHeight; ///< Height of the console hardware layer in characters - - int windowX; ///< Window X location in characters (not implemented) - int windowY; ///< Window Y location in characters (not implemented) - int windowWidth; ///< Window width in characters (not implemented) - int windowHeight; ///< Window height in characters (not implemented) - - int tabSize; ///< Size of a tab - int fg; ///< Foreground color - int bg; ///< Background color - int flags; ///< Reverse/bright flags - - ConsolePrint PrintChar; ///< Callback for printing a character. Should return true if it has handled rendering the graphics (else the print engine will attempt to render via tiles). - - bool consoleInitialised; ///< True if the console is initialized -}PrintConsole; - -#define CONSOLE_COLOR_BOLD (1<<0) ///< Bold text -#define CONSOLE_COLOR_FAINT (1<<1) ///< Faint text -#define CONSOLE_ITALIC (1<<2) ///< Italic text -#define CONSOLE_UNDERLINE (1<<3) ///< Underlined text -#define CONSOLE_BLINK_SLOW (1<<4) ///< Slow blinking text -#define CONSOLE_BLINK_FAST (1<<5) ///< Fast blinking text -#define CONSOLE_COLOR_REVERSE (1<<6) ///< Reversed color text -#define CONSOLE_CONCEAL (1<<7) ///< Concealed text -#define CONSOLE_CROSSED_OUT (1<<8) ///< Crossed out text - -/// Console debug devices supported by libnx. -typedef enum { - debugDevice_NULL, ///< Swallows prints to stderr - debugDevice_SVC, ///< Outputs stderr debug statements using svcOutputDebugString, which can then be captured by interactive debuggers - debugDevice_CONSOLE, ///< Directs stderr debug statements to Switch console window - debugDevice_3DMOO = debugDevice_SVC, -} debugDevice; - -/** - * @brief Loads the font into the console. - * @param console Pointer to the console to update, if NULL it will update the current console. - * @param font The font to load. - */ -void consoleSetFont(PrintConsole* console, ConsoleFont* font); - -/** - * @brief Sets the print window. - * @param console Console to set, if NULL it will set the current console window. - * @param x X location of the window. - * @param y Y location of the window. - * @param width Width of the window. - * @param height Height of the window. - */ -void consoleSetWindow(PrintConsole* console, int x, int y, int width, int height); - -/** - * @brief Gets a pointer to the console with the default values. - * This should only be used when using a single console or without changing the console that is returned, otherwise use consoleInit(). - * @return A pointer to the console with the default values. - */ -PrintConsole* consoleGetDefault(void); - -/** - * @brief Make the specified console the render target. - * @param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)). - * @return A pointer to the previous console. - */ -PrintConsole *consoleSelect(PrintConsole* console); - -/** - * @brief Initialise the console. - * @param console A pointer to the console data to initialize (if it's NULL, the default console will be used). - * @return A pointer to the current console. - */ -PrintConsole* consoleInit(PrintConsole* console); - -/** - * @brief Initializes debug console output on stderr to the specified device. - * @param device The debug device (or devices) to output debug print statements to. - */ -void consoleDebugInit(debugDevice device); - -/// Clears the screan by using iprintf("\x1b[2J"); -void consoleClear(void); diff --git a/src/libnx/wrapper/nx/include/switch/runtime/devices/fs_dev.h b/src/libnx/wrapper/nx/include/switch/runtime/devices/fs_dev.h deleted file mode 100644 index ac37e97..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/devices/fs_dev.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file fs_dev.h - * @brief FS driver, using devoptab. - * @author yellows8 - * @author mtheall - * @copyright libnx Authors - */ -#pragma once - -#include -#include "../../services/fs.h" - -#define FSDEV_DIRITER_MAGIC 0x66736476 ///< "fsdv" - -/// Open directory struct -typedef struct -{ - u32 magic; ///< "fsdv" - FsDir fd; ///< File descriptor - ssize_t index; ///< Current entry index - size_t size; ///< Current batch size - FsDirectoryEntry entry_data[32]; ///< Temporary storage for reading entries -} fsdev_dir_t; - -/// Initializes and mounts the sdmc device if accessible. Also initializes current working directory to point to the folder containing the path to the executable (argv[0]), if it is provided by the environment. -Result fsdevMountSdmc(void); - -/// Mounts the input fs with the specified device name. fsdev will handle closing the fs when required, including when fsdevMountDevice() fails. -/// Returns -1 when any errors occur. -int fsdevMountDevice(const char *name, FsFileSystem fs); - -/// Unmounts the specified device. -int fsdevUnmountDevice(const char *name); - -/// Uses fsFsCommit() with the specified device. This must be used after any savedata-write operations(not just file-write). This should be used after each file-close where file-writing was done. -/// This is not used automatically at device unmount. -Result fsdevCommitDevice(const char *name); - -/// Returns the FsFileSystem for the default device (SD card), if mounted. Used internally by romfs_dev. -FsFileSystem* fsdevGetDefaultFileSystem(void); - -/// Unmounts all devices and cleans up any resources used by the FS driver. -Result fsdevUnmountAll(void); diff --git a/src/libnx/wrapper/nx/include/switch/runtime/devices/romfs_dev.h b/src/libnx/wrapper/nx/include/switch/runtime/devices/romfs_dev.h deleted file mode 100644 index e6ce78b..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/devices/romfs_dev.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file romfs_dev.h - * @brief RomFS driver. - * @author yellows8 - * @author mtheall - * @author fincs - * @copyright libnx Authors - */ -#pragma once - -#include "../../types.h" -#include "../../services/fs.h" - -/// RomFS header. -typedef struct -{ - u64 headerSize; ///< Size of the header. - u64 dirHashTableOff; ///< Offset of the directory hash table. - u64 dirHashTableSize; ///< Size of the directory hash table. - u64 dirTableOff; ///< Offset of the directory table. - u64 dirTableSize; ///< Size of the directory table. - u64 fileHashTableOff; ///< Offset of the file hash table. - u64 fileHashTableSize; ///< Size of the file hash table. - u64 fileTableOff; ///< Offset of the file table. - u64 fileTableSize; ///< Size of the file table. - u64 fileDataOff; ///< Offset of the file data. -} romfs_header; - -/// RomFS directory. -typedef struct -{ - u32 parent; ///< Offset of the parent directory. - u32 sibling; ///< Offset of the next sibling directory. - u32 childDir; ///< Offset of the first child directory. - u32 childFile; ///< Offset of the first file. - u32 nextHash; ///< Directory hash table pointer. - u32 nameLen; ///< Name length. - uint8_t name[]; ///< Name. (UTF-8) -} romfs_dir; - -/// RomFS file. -typedef struct -{ - u32 parent; ///< Offset of the parent directory. - u32 sibling; ///< Offset of the next sibling file. - u64 dataOff; ///< Offset of the file's data. - u64 dataSize; ///< Length of the file's data. - u32 nextHash; ///< File hash table pointer. - u32 nameLen; ///< Name length. - uint8_t name[]; ///< Name. (UTF-8) -} romfs_file; - -struct romfs_mount; - -/** - * @brief Mounts the Application's RomFS. - * @param mount Output mount handle - */ -Result romfsMount(struct romfs_mount **mount); -static inline Result romfsInit(void) -{ - return romfsMount(NULL); -} - -/** - * @brief Mounts RomFS from an open file. - * @param file FsFile of the RomFS image. - * @param offset Offset of the RomFS within the file. - * @param mount Output mount handle - */ -Result romfsMountFromFile(FsFile file, u64 offset, struct romfs_mount **mount); -static inline Result romfsInitFromFile(FsFile file, u64 offset) -{ - return romfsMountFromFile(file, offset, NULL); -} - -/** - * @brief Mounts RomFS from an open storage. - * @param storage FsStorage of the RomFS image. - * @param offset Offset of the RomFS within the storage. - * @param mount Output mount handle - */ -Result romfsMountFromStorage(FsStorage storage, u64 offset, struct romfs_mount **mount); -static inline Result romfsInitFromStorage(FsStorage storage, u64 offset) -{ - return romfsMountFromStorage(storage, offset, NULL); -} - -/// Bind the RomFS mount -Result romfsBind(struct romfs_mount *mount); - -/// Unmounts the RomFS device. -Result romfsUnmount(struct romfs_mount *mount); -static inline Result romfsExit(void) -{ - return romfsUnmount(NULL); -} - diff --git a/src/libnx/wrapper/nx/include/switch/runtime/devices/socket.h b/src/libnx/wrapper/nx/include/switch/runtime/devices/socket.h deleted file mode 100644 index 155eea6..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/devices/socket.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "../../types.h" - -/// Configuration structure for socketInitalize -typedef struct { - u32 bsdsockets_version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0. - - u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed). - u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed). - u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value. - u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value. - - u32 udp_tx_buf_size; ///< Size of the UDP transfer (send) buffer (typically 0x2400 bytes). - u32 udp_rx_buf_size; ///< Size of the UDP receive buffer (typically 0xA500 bytes). - - u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8). - - size_t serialized_out_addrinfos_max_size; ///< For getaddrinfo. - size_t serialized_out_hostent_max_size; ///< For gethostbyname/gethostbyaddr. - bool bypass_nsd; ///< For name gethostbyname/getaddrinfo: bypass the Name Server Daemon. - int dns_timeout; ///< For DNS requests: timeout or 0. -} SocketInitConfig; - -/// Fetch the default configuration for the socket driver. -const SocketInitConfig *socketGetDefaultInitConfig(void); -/// Initalize the socket driver. -Result socketInitialize(const SocketInitConfig *config); -/// Fetch the last bsd:u/s Switch result code (thread-local). -Result socketGetLastBsdResult(void); -/// Fetch the last sfdnsres Switch result code (thread-local). -Result socketGetLastSfdnsresResult(void); -/// Deinitialize the socket driver. -void socketExit(void); - -/// Initalize the socket driver using the default configuration. -static inline Result socketInitializeDefault(void) { - return socketInitialize(socketGetDefaultInitConfig()); -} - diff --git a/src/libnx/wrapper/nx/include/switch/runtime/devices/usb_comms.h b/src/libnx/wrapper/nx/include/switch/runtime/devices/usb_comms.h deleted file mode 100644 index 5c11d8d..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/devices/usb_comms.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file usb_comms.h - * @brief USB comms. - * @author yellows8 - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../../types.h" - -Result usbCommsInitialize(void); -void usbCommsExit(void); - -/// Same as usbCommsInitialize, except this can be used after usbCommsInitialize (or instead of usbCommsInitialize), for creating new interface(s). -/// bInterface* are the values for the same fields in usb.h \ref usb_interface_descriptor. \ref usbCommsInitialize uses USB_CLASS_VENDOR_SPEC for all of these internally. -Result usbCommsInitializeEx(u32 *interface, u8 bInterfaceClass, u8 bInterfaceSubClass, u8 bInterfaceProtocol); - -/// Shutdown the specified interface. If no interfaces are remaining, this then uses \ref usbCommsExit internally. -void usbCommsExitEx(u32 interface); - -/// Read data with the default interface. -size_t usbCommsRead(void* buffer, size_t size); - -/// Write data with the default interface. -size_t usbCommsWrite(const void* buffer, size_t size); - -/// Same as usbCommsRead except with the specified interface. -size_t usbCommsReadEx(void* buffer, size_t size, u32 interface); - -/// Same as usbCommsWrite except with the specified interface. -size_t usbCommsWriteEx(const void* buffer, size_t size, u32 interface); diff --git a/src/libnx/wrapper/nx/include/switch/runtime/env.h b/src/libnx/wrapper/nx/include/switch/runtime/env.h deleted file mode 100644 index b21db61..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/env.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file env.h - * @brief Homebrew environment definitions and utilities. - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/// Structure representing an entry in the homebrew environment configuration. -typedef struct { - u32 Key; ///< Type of entry - u32 Flags; ///< Entry flags - u64 Value[2]; ///< Entry arguments (type-specific) -} ConfigEntry; - -/// Entry flags -enum { - EntryFlag_IsMandatory = BIT(0), ///< Specifies that the entry **must** be processed by the homebrew application. -}; - -///< Types of entry -enum { - EntryType_EndOfList=0, ///< Entry list terminator. - EntryType_MainThreadHandle=1, ///< Provides the handle to the main thread. - EntryType_NextLoadPath=2, ///< Provides a buffer containing information about the next homebrew application to load. - EntryType_OverrideHeap=3, ///< Provides heap override information. - EntryType_OverrideService=4, ///< Provides service override information. - EntryType_Argv=5, ///< Provides argv. - EntryType_SyscallAvailableHint=6, ///< Provides syscall availability hints. - EntryType_AppletType=7, ///< Provides APT applet type. - EntryType_AppletWorkaround=8, ///< Indicates that APT is broken and should not be used. - EntryType_StdioSockets=9, ///< Provides socket-based standard stream redirection information. - EntryType_ProcessHandle=10, ///< Provides the process handle. - EntryType_LastLoadResult=11 ///< Provides the last load result. -}; - -/// Loader return function. -typedef void NORETURN (*LoaderReturnFn)(int result_code); - -/** - * @brief Parses the homebrew loader environment block (internally called). - * @param ctx Reserved. - * @param main_thread Reserved. - * @param saved_lr Reserved. - */ -void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr); - -/// Retrieves the handle to the main thread. -Handle envGetMainThreadHandle(void); -/// Returns true if the application is running as NSO, otherwise NRO. -bool envIsNso(void); - -/// Returns true if the environment has a heap override. -bool envHasHeapOverride(void); -/// Returns the address of the overriden heap. -void* envGetHeapOverrideAddr(void); -/// Returns the size of the overriden heap. -u64 envGetHeapOverrideSize(void); - -/// Returns true if the environment has an argv array. -bool envHasArgv(void); -/// Returns the pointer to the argv array. -void* envGetArgv(void); - -/** - * @brief Returns whether a syscall is hinted to be available. - * @param svc Syscall number to test. - * @returns true if the syscall is available. - */ -bool envIsSyscallHinted(u8 svc); - -/// Returns the handle to the running homebrew process. -Handle envGetOwnProcessHandle(void); - -/// Returns the loader's return function, to be called on program exit. -LoaderReturnFn envGetExitFuncPtr(void); - -/** - * @brief Configures the next homebrew application to load. - * @param path Path to the next homebrew application to load (.nro). - * @param argv Argument string to pass. - */ -Result envSetNextLoad(const char* path, const char* argv); - -/// Returns true if the environment supports envSetNextLoad. -bool envHasNextLoad(void); - -/// Returns the Result from the last NRO. -Result envGetLastLoadResult(void); diff --git a/src/libnx/wrapper/nx/include/switch/runtime/nxlink.h b/src/libnx/wrapper/nx/include/switch/runtime/nxlink.h deleted file mode 100644 index 363ec25..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/nxlink.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -struct in_addr; - -extern struct in_addr __nxlink_host; - -#define NXLINK_SERVER_PORT 28280 -#define NXLINK_CLIENT_PORT 28771 - -int nxlinkStdio(void); diff --git a/src/libnx/wrapper/nx/include/switch/runtime/util/utf.h b/src/libnx/wrapper/nx/include/switch/runtime/util/utf.h deleted file mode 100644 index a9a08df..0000000 --- a/src/libnx/wrapper/nx/include/switch/runtime/util/utf.h +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @file utf.h - * @brief UTF conversion functions. - * @author mtheall - * @copyright libnx Authors - */ -#pragma once -#include -#include "../../types.h" - -/** Convert a UTF-8 sequence into a UTF-32 codepoint - * - * @param[out] out Output codepoint - * @param[in] in Input sequence - * - * @returns number of input code units consumed - * @returns -1 for error - */ -ssize_t decode_utf8 (uint32_t *out, const uint8_t *in); - -/** Convert a UTF-16 sequence into a UTF-32 codepoint - * - * @param[out] out Output codepoint - * @param[in] in Input sequence - * - * @returns number of input code units consumed - * @returns -1 for error - */ -ssize_t decode_utf16(uint32_t *out, const uint16_t *in); - -/** Convert a UTF-32 codepoint into a UTF-8 sequence - * - * @param[out] out Output sequence - * @param[in] in Input codepoint - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out must be able to store 4 code units - */ -ssize_t encode_utf8 (uint8_t *out, uint32_t in); - -/** Convert a UTF-32 codepoint into a UTF-16 sequence - * - * @param[out] out Output sequence - * @param[in] in Input codepoint - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out must be able to store 2 code units - */ -ssize_t encode_utf16(uint16_t *out, uint32_t in); - -/** Convert a UTF-8 sequence into a UTF-16 sequence - * - * Fills the output buffer up to \a len code units. - * Returns the number of code units that the input would produce; - * if it returns greater than \a len, the output has been - * truncated. - * - * @param[out] out Output sequence - * @param[in] in Input sequence (null-terminated) - * @param[in] len Output length - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out is not null-terminated - */ -ssize_t utf8_to_utf16(uint16_t *out, const uint8_t *in, size_t len); - -/** Convert a UTF-8 sequence into a UTF-32 sequence - * - * Fills the output buffer up to \a len code units. - * Returns the number of code units that the input would produce; - * if it returns greater than \a len, the output has been - * truncated. - * - * @param[out] out Output sequence - * @param[in] in Input sequence (null-terminated) - * @param[in] len Output length - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out is not null-terminated - */ -ssize_t utf8_to_utf32(uint32_t *out, const uint8_t *in, size_t len); - -/** Convert a UTF-16 sequence into a UTF-8 sequence - * - * Fills the output buffer up to \a len code units. - * Returns the number of code units that the input would produce; - * if it returns greater than \a len, the output has been - * truncated. - * - * @param[out] out Output sequence - * @param[in] in Input sequence (null-terminated) - * @param[in] len Output length - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out is not null-terminated - */ -ssize_t utf16_to_utf8(uint8_t *out, const uint16_t *in, size_t len); - -/** Convert a UTF-16 sequence into a UTF-32 sequence - * - * Fills the output buffer up to \a len code units. - * Returns the number of code units that the input would produce; - * if it returns greater than \a len, the output has been - * truncated. - * - * @param[out] out Output sequence - * @param[in] in Input sequence (null-terminated) - * @param[in] len Output length - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out is not null-terminated - */ -ssize_t utf16_to_utf32(uint32_t *out, const uint16_t *in, size_t len); - -/** Convert a UTF-32 sequence into a UTF-8 sequence - * - * Fills the output buffer up to \a len code units. - * Returns the number of code units that the input would produce; - * if it returns greater than \a len, the output has been - * truncated. - * - * @param[out] out Output sequence - * @param[in] in Input sequence (null-terminated) - * @param[in] len Output length - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out is not null-terminated - */ -ssize_t utf32_to_utf8(uint8_t *out, const uint32_t *in, size_t len); - -/** Convert a UTF-32 sequence into a UTF-16 sequence - * - * @param[out] out Output sequence - * @param[in] in Input sequence (null-terminated) - * @param[in] len Output length - * - * @returns number of output code units produced - * @returns -1 for error - * - * @note \a out is not null-terminated - */ -ssize_t utf32_to_utf16(uint16_t *out, const uint32_t *in, size_t len); - diff --git a/src/libnx/wrapper/nx/include/switch/services/acc.h b/src/libnx/wrapper/nx/include/switch/services/acc.h deleted file mode 100644 index 3548005..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/acc.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @file acc.h - * @brief Account (acc:*) service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "sm.h" - -typedef struct { - Service s; -} AccountProfile; - -typedef struct -{ - u32 unk_x0; - u32 iconID; ///< Icon ID. 0 = Mii, the rest are character icon IDs. - u8 iconBackgroundColorID; ///< Profile icon background color ID - u8 unk_x9[0x7]; - u8 miiID[0x10]; ///< Some ID related to the Mii? All zeros when a character icon is used. - u8 unk_x20[0x60]; ///< Usually zeros? -} PACKED AccountUserData; - -typedef struct -{ - u128 userID; - u64 lastEditTimestamp; ///< POSIX UTC timestamp, for the last account edit. - char username[0x20]; ///< UTF-8 Username. -} PACKED AccountProfileBase; - -Result accountInitialize(void); -void accountExit(void); -Service* accountGetService(void); - -/// Get the userID for the currently active user. The output userID is only valid when the output account_selected==1, otherwise no user is currently selected. -/// An user is only selected when the user-account selection applet was used to select an user at least once before. -Result accountGetActiveUser(u128 *userID, bool *account_selected); - -/// Get an AccountProfile for the specified userID. -Result accountGetProfile(AccountProfile* out, u128 userID); - -/// Get \ref AccountUserData and \ref AccountProfileBase for the specified profile, userdata is optional (can be NULL). -Result accountProfileGet(AccountProfile* profile, AccountUserData* userdata, AccountProfileBase* profilebase); - -/// Get the icon image size. -Result accountProfileGetImageSize(AccountProfile* profile, size_t* image_size); - -/// Load the JPEG profile icon, valid for both Miis and character icons. The output image_size is the same as the one from \ref accountProfileGetImageSize. -Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, size_t* image_size); - -void accountProfileClose(AccountProfile* profile); diff --git a/src/libnx/wrapper/nx/include/switch/services/apm.h b/src/libnx/wrapper/nx/include/switch/services/apm.h deleted file mode 100644 index ca00694..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/apm.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @file apm.h - * @brief Performance management (apm) service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -/// These are used internally by applet. - -Result apmInitialize(void); -void apmExit(void); - -Result apmSetPerformanceConfiguration(u32 PerformanceMode, u32 PerformanceConfiguration); -Result apmGetPerformanceConfiguration(u32 PerformanceMode, u32 *PerformanceConfiguration); diff --git a/src/libnx/wrapper/nx/include/switch/services/applet.h b/src/libnx/wrapper/nx/include/switch/services/applet.h deleted file mode 100644 index 74d32f8..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/applet.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @file applet.h - * @brief Applet (applet) service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -typedef enum { - AppletType_None = -2, - AppletType_Default = -1, - AppletType_Application = 0, - AppletType_SystemApplet = 1, - AppletType_LibraryApplet = 2, - AppletType_OverlayApplet = 3, - AppletType_SystemApplication = 4, -} AppletType; - -typedef enum { - AppletOperationMode_Handheld = 0, - AppletOperationMode_Docked = 1, -} AppletOperationMode; - -/// applet hook types. -typedef enum { - AppletHookType_OnFocusState = 0, ///< FocusState changed. - AppletHookType_OnOperationMode, ///< OperationMode changed. - AppletHookType_OnPerformanceMode, ///< PerformanceMode changed. - - AppletHookType_Max, ///< Number of applet hook types. -} AppletHookType; - -/// applet hook function. -typedef void (*AppletHookFn)(AppletHookType hook, void* param); - -/// applet hook cookie. -typedef struct AppletHookCookie AppletHookCookie; - -struct AppletHookCookie -{ - AppletHookCookie* next; ///< Next cookie. - AppletHookFn callback; ///< Hook callback. - void* param; ///< Callback parameter. -}; - -Result appletInitialize(void); -void appletExit(void); -Result appletGetAppletResourceUserId(u64 *out); - -void appletNotifyRunning(u8 *out); -Result appletCreateManagedDisplayLayer(u64 *out); - -Result appletGetDesiredLanguage(u64 *LanguageCode); - -/** - * @brief Controls whether screenshot-capture is allowed. - * @param val 0 = disable, 1 = enable. - */ -Result appletSetScreenShotPermission(s32 val); - -Result appletSetScreenShotImageOrientation(s32 val); - -/** - * @brief Processes the current applet status. Generally used within a main loop. - * @return Whether the application should continue running. - */ -bool appletMainLoop(void); - - -/** - * @brief Sets up an applet status hook. - * @param cookie Hook cookie to use. - * @param callback Function to call when applet's status changes. - * @param param User-defined parameter to pass to the callback. - */ -void appletHook(AppletHookCookie* cookie, AppletHookFn callback, void* param); - -/** - * @brief Removes an applet status hook. - * @param cookie Hook cookie to remove. - */ -void appletUnhook(AppletHookCookie* cookie); - -/// These return state which is updated by appletMainLoop() when notifications are received. -u8 appletGetOperationMode(void); -u32 appletGetPerformanceMode(void); -u8 appletGetFocusState(void); diff --git a/src/libnx/wrapper/nx/include/switch/services/audin.h b/src/libnx/wrapper/nx/include/switch/services/audin.h deleted file mode 100644 index 5815304..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/audin.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file audin.h - * @brief Audio input service. - * @author hexkyz - * @copyright libnx Authors - */ -#pragma once - -#include "../audio/audio.h" - -typedef enum { - AudioInState_Started = 0, - AudioInState_Stopped = 1, -} AudioInState; - -/// Audio input buffer format -typedef struct AudioInBuffer AudioInBuffer; - -struct AudioInBuffer -{ - AudioInBuffer* next; ///< Next buffer. (Unused) - void* buffer; ///< Sample buffer (aligned to 0x1000 bytes). - u64 buffer_size; ///< Sample buffer size (aligned to 0x1000 bytes). - u64 data_size; ///< Size of data inside the buffer. - u64 data_offset; ///< Offset of data inside the buffer. (Unused?) -}; - -Result audinInitialize(void); -void audinExit(void); - -Result audinListAudioIns(char *DeviceNames, u32 *DeviceNamesCount); -Result audinOpenAudioIn(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioInState *State); -Result audinGetAudioInState(AudioInState *State); -Result audinStartAudioIn(void); -Result audinStopAudioIn(void); -Result audinAppendAudioInBuffer(AudioInBuffer *Buffer); -Result audinGetReleasedAudioInBuffer(AudioInBuffer **Buffer, u32 *ReleasedBuffersCount); -Result audinContainsAudioInBuffer(AudioInBuffer *Buffer, bool *ContainsBuffer); - -/** - * @brief Submits an audio sample data buffer for capturing and waits for it to finish capturing. - * @brief Uses \ref audinAppendAudioInBuffer and \ref audinWaitCaptureFinish internally. - * @param source AudioInBuffer containing the buffer to hold the captured sample data. - * @param released AudioInBuffer to receive the captured buffer after being released. - */ -Result audinCaptureBuffer(AudioInBuffer *source, AudioInBuffer **released); - -/** - * @brief Waits for audio capture to finish. - * @param released AudioInBuffer to receive the first captured buffer after being released. - * @param released_count Pointer to receive the number of captured buffers. - * @param timeout Timeout value, use U64_MAX to wait until all finished. - */ -Result audinWaitCaptureFinish(AudioInBuffer **released, u32* released_count, u64 timeout); - -/// These return the state associated with the currently active audio input device. -u32 audinGetSampleRate(void); ///< Supported sample rate (48000Hz). -u32 audinGetChannelCount(void); ///< Supported channel count (2 channels). -PcmFormat audinGetPcmFormat(void); ///< Supported PCM format (Int16). -AudioInState audinGetDeviceState(void); ///< Initial device state (stopped). diff --git a/src/libnx/wrapper/nx/include/switch/services/audout.h b/src/libnx/wrapper/nx/include/switch/services/audout.h deleted file mode 100644 index fcb11b1..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/audout.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file audout.h - * @brief Audio output service. - * @author hexkyz - * @copyright libnx Authors - */ -#pragma once - -#include "../audio/audio.h" - -typedef enum { - AudioOutState_Started = 0, - AudioOutState_Stopped = 1, -} AudioOutState; - -/// Audio output buffer format -typedef struct AudioOutBuffer AudioOutBuffer; - -struct AudioOutBuffer -{ - AudioOutBuffer* next; ///< Next buffer. (Unused) - void* buffer; ///< Sample buffer (aligned to 0x1000 bytes). - u64 buffer_size; ///< Sample buffer size (aligned to 0x1000 bytes). - u64 data_size; ///< Size of data inside the buffer. - u64 data_offset; ///< Offset of data inside the buffer. (Unused?) -}; - -Result audoutInitialize(void); -void audoutExit(void); - -Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount); -Result audoutOpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State); -Result audoutGetAudioOutState(AudioOutState *State); -Result audoutStartAudioOut(void); -Result audoutStopAudioOut(void); -Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer); -Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount); -Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer); - -/** - * @brief Submits an audio sample data buffer for playing and waits for it to finish playing. - * @brief Uses \ref audoutAppendAudioOutBuffer and \ref audoutWaitPlayFinish internally. - * @param source AudioOutBuffer containing the source sample data to be played. - * @param released AudioOutBuffer to receive the played buffer after being released. - */ -Result audoutPlayBuffer(AudioOutBuffer *source, AudioOutBuffer **released); - -/** - * @brief Waits for audio playback to finish. - * @param released AudioOutBuffer to receive the first played buffer after being released. - * @param released_count Pointer to receive the number of played buffers. - * @param timeout Timeout value, use U64_MAX to wait until all finished. - */ -Result audoutWaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout); - -/// These return the state associated with the currently active audio output device. -u32 audoutGetSampleRate(void); ///< Supported sample rate (48000Hz). -u32 audoutGetChannelCount(void); ///< Supported channel count (2 channels). -PcmFormat audoutGetPcmFormat(void); ///< Supported PCM format (Int16). -AudioOutState audoutGetDeviceState(void); ///< Initial device state (stopped). diff --git a/src/libnx/wrapper/nx/include/switch/services/bsd.h b/src/libnx/wrapper/nx/include/switch/services/bsd.h deleted file mode 100644 index e21121d..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/bsd.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @file bsd.h - * @brief BSD sockets (bsd:u/s) service IPC wrapper. Please use socket.c instead. - * @author plutoo - * @author TuxSH - * @copyright libnx Authors - */ -#pragma once -#include // for socklen_t -#include // for fd_set -#include // for struct pollfd, ndfs_t - -#include "../types.h" -#include "../kernel/tmem.h" - -/// Configuration structure for bsdInitalize -typedef struct { - u32 version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0. - - u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed). - u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed). - u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value. - u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value. - - u32 udp_tx_buf_size; ///< Size of the UDP transfer (send) buffer (typically 0x2400 bytes). - u32 udp_rx_buf_size; ///< Size of the UDP receive buffer (typically 0xA500 bytes). - - u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8). -} BsdInitConfig; - -extern __thread Result g_bsdResult; ///< Last Switch "result", per-thread -extern __thread int g_bsdErrno; ///< Last errno, per-thread - -/// Fetch the default configuration for bsdInitialize. -const BsdInitConfig *bsdGetDefaultInitConfig(void); -/// Initialize the BSD service. -Result bsdInitialize(const BsdInitConfig *config); -/// Deinitialize the BSD service. -void bsdExit(void); - -int bsdSocket(int domain, int type, int protocol); -/// Like @ref bsdSocket but the newly created socket is immediately shut down. -int bsdSocketExempt(int domain, int type, int protocol); -int bsdOpen(const char *pathname, int flags); -int bsdSelect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); -int bsdPoll(struct pollfd *fds, nfds_t nfds, int timeout); -int bsdSysctl(const int *name, unsigned int namelen, void *oldp, size_t *oldlenp, const void *newp, size_t newlen); -ssize_t bsdRecv(int sockfd, void *buf, size_t len, int flags); -ssize_t bsdRecvFrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); -ssize_t bsdSend(int sockfd, const void* buf, size_t len, int flags); -ssize_t bsdSendTo(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); -int bsdAccept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int bsdBind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -int bsdConnect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -int bsdGetPeerName(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int bsdGetSockName(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int bsdGetSockOpt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); -int bsdListen(int sockfd, int backlog); -/// Made non-variadic for convenience. -int bsdIoctl(int fd, int request, void *data); -/// Made non-variadic for convenience. -int bsdFcntl(int fd, int cmd, int flags); -int bsdSetSockOpt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); -int bsdShutdown(int sockfd, int how); -int bsdShutdownAllSockets(int how); -ssize_t bsdWrite(int fd, const void *buf, size_t count); -ssize_t bsdRead(int fd, void *buf, size_t count); -int bsdClose(int fd); -/// Duplicate a socket (bsd:s). -int bsdDuplicateSocket(int sockfd); - -// TODO: Reverse-engineer GetResourceStatistics. Implement sendmmsg/recvmmsg (custom (un)serialization) - -/// Initialize the BSD service using the default configuration. -static inline Result bsdInitializeDefault(void) { - return bsdInitialize(bsdGetDefaultInitConfig()); -} diff --git a/src/libnx/wrapper/nx/include/switch/services/csrng.h b/src/libnx/wrapper/nx/include/switch/services/csrng.h deleted file mode 100644 index b97b11b..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/csrng.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @file csrng.h - * @brief Cryptographically-Secure Random Number Generation (csrng) service IPC wrapper. - * @author SciresM - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -Result csrngInitialize(void); -void csrngExit(void); - -Result csrngGetRandomBytes(void *out, size_t out_size); diff --git a/src/libnx/wrapper/nx/include/switch/services/fatal.h b/src/libnx/wrapper/nx/include/switch/services/fatal.h deleted file mode 100644 index e446fb9..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/fatal.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file fatal.h - * @brief Fatal error (fatal:u) service IPC wrapper. - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -typedef enum { - FatalType_ErrorReportAndErrorScreen = 0, - FatalType_ErrorReport = 1, - FatalType_ErrorScreen = 2 -} FatalType; - -/** - * @brief Triggers a system fatal error. - * @param err[in] Result code to throw. - * @note This function does not return. - */ -void NORETURN fatalSimple(Result err); - -/** - * @brief Triggers a system fatal error with a custom FatalType. - * @param err[in] Result code to throw. - * @param err[in] Type of fatal error to throw. - * @note This function does not return. - */ -void NORETURN fatalWithType(Result err, FatalType type); diff --git a/src/libnx/wrapper/nx/include/switch/services/fs.h b/src/libnx/wrapper/nx/include/switch/services/fs.h deleted file mode 100644 index 811edf7..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/fs.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @file fs.h - * @brief Filesystem (fsp-srv) service IPC wrapper. - * Normally applications should just use standard stdio not FS-serv directly. However this can be used if obtaining a FsFileSystem, FsFile, or FsStorage, for mounting with fs_dev/romfs_dev, etc. - * @author plutoo - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" - -// We use wrapped handles for type safety. - -#define FS_MAX_PATH 0x301 - -/// For use with FsSave. -#define FS_SAVEDATA_CURRENT_TITLEID 0 - -/// For use with \ref FsSave and \ref FsSaveDataInfo. -#define FS_SAVEDATA_USERID_COMMONSAVE 0 - -typedef struct { - Service s; -} FsFileSystem; - -typedef struct { - Service s; -} FsFile; - -typedef struct { - Service s; -} FsDir; - -typedef struct { - Service s; -} FsStorage; - -typedef struct { - Service s; -} FsSaveDataIterator; - -typedef struct { - Service s; -} FsEventNotifier; - -typedef struct { - Service s; -} FsDeviceOperator; - -/// Directory entry. -typedef struct -{ - char name[FS_MAX_PATH]; ///< Entry name. - u8 pad[3]; - s8 type; ///< See FsEntryType. - u8 pad2[3]; ///< ? - u64 fileSize; ///< File size. -} FsDirectoryEntry; - -/// Save Struct -typedef struct -{ - u64 titleID; ///< titleID of the savedata to access when accessing other titles' savedata via SaveData, otherwise FS_SAVEDATA_CURRENT_TITLEID. - u128 userID; ///< userID of the user-specific savedata to access, otherwise FS_SAVEDATA_USERID_COMMONSAVE. See account.h. - u64 saveID; ///< saveID, 0 for SaveData. - u64 SaveDataType; ///< See \ref FsSaveDataType. - u64 unk_x28; ///< 0 for SystemSaveData/SaveData. - u64 unk_x30; ///< 0 for SystemSaveData/SaveData. - u64 unk_x38; ///< 0 for SystemSaveData/SaveData. -} PACKED FsSave; - -typedef struct -{ - u64 saveID_unk; - u8 SaveDataSpaceId; ///< See \ref FsSaveDataSpaceId. - u8 SaveDataType; ///< See \ref FsSaveDataType. - u8 pad[6]; - u128 userID; ///< See userID for \ref FsSave. - u64 saveID; ///< See saveID for \ref FsSave. - u64 titleID; ///< titleID for FsSaveDataType_SaveData. - u64 size; ///< Raw saveimage size. - u8 unk_x38[0x28]; ///< Unknown. Usually zeros? -} PACKED FsSaveDataInfo; - -typedef enum { - ENTRYTYPE_DIR = 0, - ENTRYTYPE_FILE = 1 -} FsEntryType; - -typedef enum -{ - FS_OPEN_READ = BIT(0), ///< Open for reading. - FS_OPEN_WRITE = BIT(1), ///< Open for writing. - FS_OPEN_APPEND = BIT(2), ///< Append file. -} FsFileFlags; - -/// For use with fsFsOpenDirectory. -typedef enum -{ - FS_DIROPEN_DIRECTORY = BIT(0), ///< Enable reading directory entries. - FS_DIROPEN_FILE = BIT(1), ///< Enable reading file entries. -} FsDirectoryFlags; - -typedef enum -{ - FsStorageId_None = 0, - FsStorageId_Host = 1, - FsStorageId_GameCard = 2, - FsStorageId_NandSystem = 3, - FsStorageId_NandUser = 4, - FsStorageId_SdCard = 5, -} FsStorageId; - -typedef enum -{ - FS_CONTENTSTORAGEID_NandSystem = 0, - FS_CONTENTSTORAGEID_NandUser = 1, - FS_CONTENTSTORAGEID_SdCard = 2, -} FsContentStorageId; - -typedef enum -{ - FsSaveDataSpaceId_NandSystem = 0, - FsSaveDataSpaceId_NandUser = 1, - FsSaveDataSpaceId_SdCard = 2, - FsSaveDataSpaceId_TemporaryStorage = 3, - - FsSaveDataSpaceId_All = -1, ///< Pseudo value for fsOpenSaveDataIterator(). -} FsSaveDataSpaceId; - -typedef enum -{ - FsSaveDataType_SystemSaveData = 0, - FsSaveDataType_SaveData = 1, - FsSaveDataType_BcatDeliveryCacheStorage = 2, - FsSaveDataType_DeviceSaveData = 3, - FsSaveDataType_TemporaryStorage = 4, ///< [3.0.0+] - FsSaveDataType_CacheStorage = 5, ///< [3.0.0+] -} FsSaveDataType; - -Result fsInitialize(void); -void fsExit(void); - -Service* fsGetServiceSession(void); - -/// Do not call this directly, see fs_dev.h. -Result fsMountSdcard(FsFileSystem* out); - -Result fsMountSaveData(FsFileSystem* out, u8 inval, FsSave *save); -Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, FsSave *save); -Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 SaveDataSpaceId); -Result fsOpenDataStorageByCurrentProcess(FsStorage* out); -Result fsOpenDeviceOperator(FsDeviceOperator* out); -Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out); -// todo: Rest of commands here - -/// FsFileSystem can be mounted with fs_dev for use with stdio, see fs_dev.h. - -/// Wrapper(s) for fsMountSaveData. -/// See FsSave for titleID and userID. -Result fsMount_SaveData(FsFileSystem* out, u64 titleID, u128 userID); - -/// Wrapper for fsMountSystemSaveData. -/// WARNING: You can brick when writing to SystemSaveData, if the data is corrupted etc. -Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID); - -// IFileSystem -Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags); -Result fsFsDeleteFile(FsFileSystem* fs, const char* path); -Result fsFsCreateDirectory(FsFileSystem* fs, const char* path); -Result fsFsDeleteDirectory(FsFileSystem* fs, const char* path); -Result fsFsDeleteDirectoryRecursively(FsFileSystem* fs, const char* path); -Result fsFsRenameFile(FsFileSystem* fs, const char* path0, const char* path1); -Result fsFsRenameDirectory(FsFileSystem* fs, const char* path0, const char* path1); -Result fsFsGetEntryType(FsFileSystem* fs, const char* path, FsEntryType* out); -Result fsFsOpenFile(FsFileSystem* fs, const char* path, int flags, FsFile* out); -Result fsFsOpenDirectory(FsFileSystem* fs, const char* path, int flags, FsDir* out); -Result fsFsCommit(FsFileSystem* fs); -Result fsFsGetFreeSpace(FsFileSystem* fs, const char* path, u64* out); -Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, u64* out); -void fsFsClose(FsFileSystem* fs); - -// IFile -Result fsFileRead(FsFile* f, u64 off, void* buf, size_t len, size_t* out); -Result fsFileWrite(FsFile* f, u64 off, const void* buf, size_t len); -Result fsFileFlush(FsFile* f); -Result fsFileSetSize(FsFile* f, u64 sz); -Result fsFileGetSize(FsFile* f, u64* out); -void fsFileClose(FsFile* f); - -// IDirectory -Result fsDirRead(FsDir* d, u64 inval, size_t* total_entries, size_t max_entries, FsDirectoryEntry *buf); -Result fsDirGetEntryCount(FsDir* d, u64* count); -void fsDirClose(FsDir* d); - -// IStorage -Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len); -void fsStorageClose(FsStorage* s); - -// ISaveDataInfoReader - -/// Read FsSaveDataInfo data into the buf array. -Result fsSaveDataIteratorRead(FsSaveDataIterator *s, FsSaveDataInfo* buf, size_t max_entries, size_t* total_entries); -void fsSaveDataIteratorClose(FsSaveDataIterator *s); - -// IEventNotifier -Result fsEventNotifierGetEventHandle(FsEventNotifier* e, Handle* out); -void fsEventNotifierClose(FsEventNotifier* e); - -// IDeviceOperator -Result fsDeviceOperatorIsSdCardInserted(FsDeviceOperator* d, bool* out); -void fsDeviceOperatorClose(FsDeviceOperator* d); diff --git a/src/libnx/wrapper/nx/include/switch/services/fsldr.h b/src/libnx/wrapper/nx/include/switch/services/fsldr.h deleted file mode 100644 index 3703129..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/fsldr.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file fsldr.h - * @brief FilesystemProxy-ForLoader (fsp-ldr) service IPC wrapper. - * @author SciresM - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" -#include "../services/fs.h" - -Result fsldrInitialize(void); -void fsldrExit(void); - -Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out); -Result fsldrIsArchivedProgram(u64 pid, bool *out); -Result fsldrSetCurrentProcess(); \ No newline at end of file diff --git a/src/libnx/wrapper/nx/include/switch/services/fspr.h b/src/libnx/wrapper/nx/include/switch/services/fspr.h deleted file mode 100644 index 7809bee..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/fspr.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @file fspr.h - * @brief FilesystemProxy-ProgramRegistry (fsp-pr) service IPC wrapper. - * @author SciresM - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" -#include "../services/fs.h" - -Result fsprInitialize(void); -void fsprExit(void); - -Result fsprRegisterProgram(u64 pid, u64 titleID, FsStorageId storageID, const void *fs_access_header, size_t fah_size, const void *fs_access_control, size_t fac_size); -Result fsprUnregisterProgram(u64 pid); -Result fsprSetCurrentProcess(void); -Result fsprSetEnabledProgramVerification(bool enabled); diff --git a/src/libnx/wrapper/nx/include/switch/services/hid.h b/src/libnx/wrapper/nx/include/switch/services/hid.h deleted file mode 100644 index 130dbb1..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/hid.h +++ /dev/null @@ -1,627 +0,0 @@ -/** - * @file hid.h - * @brief Human input device (hid) service IPC wrapper. - * @author shinyquagsire23 - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include -#include "../types.h" -#include "../services/sm.h" - -// Begin enums and output structs - -typedef enum -{ - MOUSE_LEFT = BIT(0), - MOUSE_RIGHT = BIT(1), - MOUSE_MIDDLE = BIT(2), - MOUSE_FORWARD = BIT(3), - MOUSE_BACK = BIT(4), -} HidMouseButton; - -typedef enum -{ - KBD_MOD_LCTRL = BIT(0), - KBD_MOD_LSHIFT = BIT(1), - KBD_MOD_LALT = BIT(2), - KBD_MOD_LMETA = BIT(3), - KBD_MOD_RCTRL = BIT(4), - KBD_MOD_RSHIFT = BIT(5), - KBD_MOD_RALT = BIT(6), - KBD_MOD_RMETA = BIT(7), - KBD_MOD_CAPSLOCK = BIT(8), - KBD_MOD_SCROLLLOCK = BIT(9), - KBD_MOD_NUMLOCK = BIT(10), -} HidKeyboardModifier; - -typedef enum -{ - KBD_NONE = 0x00, - KBD_ERR_OVF = 0x01, - - KBD_A = 0x04, - KBD_B = 0x05, - KBD_C = 0x06, - KBD_D = 0x07, - KBD_E = 0x08, - KBD_F = 0x09, - KBD_G = 0x0a, - KBD_H = 0x0b, - KBD_I = 0x0c, - KBD_J = 0x0d, - KBD_K = 0x0e, - KBD_L = 0x0f, - KBD_M = 0x10, - KBD_N = 0x11, - KBD_O = 0x12, - KBD_P = 0x13, - KBD_Q = 0x14, - KBD_R = 0x15, - KBD_S = 0x16, - KBD_T = 0x17, - KBD_U = 0x18, - KBD_V = 0x19, - KBD_W = 0x1a, - KBD_X = 0x1b, - KBD_Y = 0x1c, - KBD_Z = 0x1d, - - KBD_1 = 0x1e, - KBD_2 = 0x1f, - KBD_3 = 0x20, - KBD_4 = 0x21, - KBD_5 = 0x22, - KBD_6 = 0x23, - KBD_7 = 0x24, - KBD_8 = 0x25, - KBD_9 = 0x26, - KBD_0 = 0x27, - - KBD_ENTER = 0x28, - KBD_ESC = 0x29, - KBD_BACKSPACE = 0x2a, - KBD_TAB = 0x2b, - KBD_SPACE = 0x2c, - KBD_MINUS = 0x2d, - KBD_EQUAL = 0x2e, - KBD_LEFTBRACE = 0x2f, - KBD_RIGHTBRACE = 0x30, - KBD_BACKSLASH = 0x31, - KBD_HASHTILDE = 0x32, - KBD_SEMICOLON = 0x33, - KBD_APOSTROPHE = 0x34, - KBD_GRAVE = 0x35, - KBD_COMMA = 0x36, - KBD_DOT = 0x37, - KBD_SLASH = 0x38, - KBD_CAPSLOCK = 0x39, - - KBD_F1 = 0x3a, - KBD_F2 = 0x3b, - KBD_F3 = 0x3c, - KBD_F4 = 0x3d, - KBD_F5 = 0x3e, - KBD_F6 = 0x3f, - KBD_F7 = 0x40, - KBD_F8 = 0x41, - KBD_F9 = 0x42, - KBD_F10 = 0x43, - KBD_F11 = 0x44, - KBD_F12 = 0x45, - - KBD_SYSRQ = 0x46, - KBD_SCROLLLOCK = 0x47, - KBD_PAUSE = 0x48, - KBD_INSERT = 0x49, - KBD_HOME = 0x4a, - KBD_PAGEUP = 0x4b, - KBD_DELETE = 0x4c, - KBD_END = 0x4d, - KBD_PAGEDOWN = 0x4e, - KBD_RIGHT = 0x4f, - KBD_LEFT = 0x50, - KBD_DOWN = 0x51, - KBD_UP = 0x52, - - KBD_NUMLOCK = 0x53, - KBD_KPSLASH = 0x54, - KBD_KPASTERISK = 0x55, - KBD_KPMINUS = 0x56, - KBD_KPPLUS = 0x57, - KBD_KPENTER = 0x58, - KBD_KP1 = 0x59, - KBD_KP2 = 0x5a, - KBD_KP3 = 0x5b, - KBD_KP4 = 0x5c, - KBD_KP5 = 0x5d, - KBD_KP6 = 0x5e, - KBD_KP7 = 0x5f, - KBD_KP8 = 0x60, - KBD_KP9 = 0x61, - KBD_KP0 = 0x62, - KBD_KPDOT = 0x63, - - KBD_102ND = 0x64, - KBD_COMPOSE = 0x65, - KBD_POWER = 0x66, - KBD_KPEQUAL = 0x67, - - KBD_F13 = 0x68, - KBD_F14 = 0x69, - KBD_F15 = 0x6a, - KBD_F16 = 0x6b, - KBD_F17 = 0x6c, - KBD_F18 = 0x6d, - KBD_F19 = 0x6e, - KBD_F20 = 0x6f, - KBD_F21 = 0x70, - KBD_F22 = 0x71, - KBD_F23 = 0x72, - KBD_F24 = 0x73, - - KBD_OPEN = 0x74, - KBD_HELP = 0x75, - KBD_PROPS = 0x76, - KBD_FRONT = 0x77, - KBD_STOP = 0x78, - KBD_AGAIN = 0x79, - KBD_UNDO = 0x7a, - KBD_CUT = 0x7b, - KBD_COPY = 0x7c, - KBD_PASTE = 0x7d, - KBD_FIND = 0x7e, - KBD_MUTE = 0x7f, - KBD_VOLUMEUP = 0x80, - KBD_VOLUMEDOWN = 0x81, - KBD_CAPSLOCK_ACTIVE = 0x82 , - KBD_NUMLOCK_ACTIVE = 0x83 , - KBD_SCROLLLOCK_ACTIVE = 0x84 , - KBD_KPCOMMA = 0x85, - - KBD_KPLEFTPAREN = 0xb6, - KBD_KPRIGHTPAREN = 0xb7, - - KBD_LEFTCTRL = 0xe0, - KBD_LEFTSHIFT = 0xe1, - KBD_LEFTALT = 0xe2, - KBD_LEFTMETA = 0xe3, - KBD_RIGHTCTRL = 0xe4, - KBD_RIGHTSHIFT = 0xe5, - KBD_RIGHTALT = 0xe6, - KBD_RIGHTMETA = 0xe7, - - KBD_MEDIA_PLAYPAUSE = 0xe8, - KBD_MEDIA_STOPCD = 0xe9, - KBD_MEDIA_PREVIOUSSONG = 0xea, - KBD_MEDIA_NEXTSONG = 0xeb, - KBD_MEDIA_EJECTCD = 0xec, - KBD_MEDIA_VOLUMEUP = 0xed, - KBD_MEDIA_VOLUMEDOWN = 0xee, - KBD_MEDIA_MUTE = 0xef, - KBD_MEDIA_WWW = 0xf0, - KBD_MEDIA_BACK = 0xf1, - KBD_MEDIA_FORWARD = 0xf2, - KBD_MEDIA_STOP = 0xf3, - KBD_MEDIA_FIND = 0xf4, - KBD_MEDIA_SCROLLUP = 0xf5, - KBD_MEDIA_SCROLLDOWN = 0xf6, - KBD_MEDIA_EDIT = 0xf7, - KBD_MEDIA_SLEEP = 0xf8, - KBD_MEDIA_COFFEE = 0xf9, - KBD_MEDIA_REFRESH = 0xfa, - KBD_MEDIA_CALC = 0xfb -} HidKeyboardScancode; - -typedef enum -{ - TYPE_PROCONTROLLER = BIT(0), - TYPE_HANDHELD = BIT(1), - TYPE_JOYCON_PAIR = BIT(2), - TYPE_JOYCON_LEFT = BIT(3), - TYPE_JOYCON_RIGHT = BIT(4), -} HidControllerType; - -typedef enum -{ - LAYOUT_PROCONTROLLER = 0, // Pro Controller or Hid gamepad - LAYOUT_HANDHELD = 1, // Two Joy-Con docked to rails - LAYOUT_SINGLE = 2, // Horizontal single Joy-Con or pair of Joy-Con, adjusted for orientation - LAYOUT_LEFT = 3, // Only raw left Joy-Con state, no orientation adjustment - LAYOUT_RIGHT = 4, // Only raw right Joy-Con state, no orientation adjustment - LAYOUT_DEFAULT_DIGITAL = 5, // Same as next, but sticks have 8-direction values only - LAYOUT_DEFAULT = 6, // Safe default, single Joy-Con have buttons/sticks rotated for orientation -} HidControllerLayoutType; - -typedef enum -{ - COLORS_NONEXISTENT = BIT(1), -} HidControllerColorDescription; - -typedef enum -{ - KEY_A = BIT(0), ///< A - KEY_B = BIT(1), ///< B - KEY_X = BIT(2), ///< X - KEY_Y = BIT(3), ///< Y - KEY_LSTICK = BIT(4), ///< Left Stick Button - KEY_RSTICK = BIT(5), ///< Right Stick Button - KEY_L = BIT(6), ///< L - KEY_R = BIT(7), ///< R - KEY_ZL = BIT(8), ///< ZL - KEY_ZR = BIT(9), ///< ZR - KEY_PLUS = BIT(10), ///< Plus - KEY_MINUS = BIT(11), ///< Minus - KEY_DLEFT = BIT(12), ///< D-Pad Left - KEY_DUP = BIT(13), ///< D-Pad Up - KEY_DRIGHT = BIT(14), ///< D-Pad Right - KEY_DDOWN = BIT(15), ///< D-Pad Down - KEY_LSTICK_LEFT = BIT(16), ///< Left Stick Left - KEY_LSTICK_UP = BIT(17), ///< Left Stick Up - KEY_LSTICK_RIGHT = BIT(18), ///< Left Stick Right - KEY_LSTICK_DOWN = BIT(19), ///< Left Stick Down - KEY_RSTICK_LEFT = BIT(20), ///< Right Stick Left - KEY_RSTICK_UP = BIT(21), ///< Right Stick Up - KEY_RSTICK_RIGHT = BIT(22), ///< Right Stick Right - KEY_RSTICK_DOWN = BIT(23), ///< Right Stick Down - KEY_SL = BIT(24), ///< SL - KEY_SR = BIT(25), ///< SR - - // Pseudo-key for at least one finger on the touch screen - KEY_TOUCH = BIT(26), - - // Buttons by orientation (for single Joy-Con), also works with Joy-Con pairs, Pro Controller - KEY_JOYCON_RIGHT = BIT(0), - KEY_JOYCON_DOWN = BIT(1), - KEY_JOYCON_UP = BIT(2), - KEY_JOYCON_LEFT = BIT(3), - - // Generic catch-all directions, also works for single Joy-Con - KEY_UP = KEY_DUP | KEY_LSTICK_UP | KEY_RSTICK_UP, ///< D-Pad Up or Sticks Up - KEY_DOWN = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN, ///< D-Pad Down or Sticks Down - KEY_LEFT = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT, ///< D-Pad Left or Sticks Left - KEY_RIGHT = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT, ///< D-Pad Right or Sticks Right -} HidControllerKeys; - -typedef enum -{ - JOYSTICK_LEFT = 0, - JOYSTICK_RIGHT = 1, - - JOYSTICK_NUM_STICKS = 2, -} HidControllerJoystick; - -typedef enum -{ - CONTROLLER_STATE_CONNECTED = BIT(0), - CONTROLLER_STATE_WIRED = BIT(1), -} HidControllerConnectionState; - -typedef enum -{ - CONTROLLER_PLAYER_1 = 0, - CONTROLLER_PLAYER_2 = 1, - CONTROLLER_PLAYER_3 = 2, - CONTROLLER_PLAYER_4 = 3, - CONTROLLER_PLAYER_5 = 4, - CONTROLLER_PLAYER_6 = 5, - CONTROLLER_PLAYER_7 = 6, - CONTROLLER_PLAYER_8 = 7, - CONTROLLER_HANDHELD = 8, - CONTROLLER_UNKNOWN = 9, - CONTROLLER_P1_AUTO = 10, /// Not an actual HID-sysmodule ID. Only for hidKeys*()/hidJoystickRead(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD. -} HidControllerID; - -typedef struct touchPosition -{ - u32 px; - u32 py; - u32 dx; - u32 dy; - u32 angle; -} touchPosition; - -typedef struct JoystickPosition -{ - s32 dx; - s32 dy; -} JoystickPosition; - -typedef struct MousePosition -{ - u32 x; - u32 y; - u32 velocityX; - u32 velocityY; - u32 scrollVelocityX; - u32 scrollVelocityY; -} MousePosition; - -#define JOYSTICK_MAX (0x8000) -#define JOYSTICK_MIN (-0x8000) - -// End enums and output structs - -// Begin HidTouchScreen - -typedef struct HidTouchScreenHeader -{ - u64 timestampTicks; - u64 numEntries; - u64 latestEntry; - u64 maxEntryIndex; - u64 timestamp; -} HidTouchScreenHeader; -static_assert(sizeof(HidTouchScreenHeader) == 0x28, "Hid touch screen header structure has incorrect size"); - -typedef struct HidTouchScreenEntryHeader -{ - u64 timestamp; - u64 numTouches; -} HidTouchScreenEntryHeader; -static_assert(sizeof(HidTouchScreenEntryHeader) == 0x10, "Hid touch screen entry header structure has incorrect size"); - -typedef struct HidTouchScreenEntryTouch -{ - u64 timestamp; - u32 padding; - u32 touchIndex; - u32 x; - u32 y; - u32 diameterX; - u32 diameterY; - u32 angle; - u32 padding_2; -} HidTouchScreenEntryTouch; -static_assert(sizeof(HidTouchScreenEntryTouch) == 0x28, "Hid touch screen touch structure has incorrect size"); - -typedef struct HidTouchScreenEntry -{ - HidTouchScreenEntryHeader header; - HidTouchScreenEntryTouch touches[16]; - u64 unk; -} HidTouchScreenEntry; -static_assert(sizeof(HidTouchScreenEntry) == 0x298, "Hid touch screen entry structure has incorrect size"); - -typedef struct HidTouchScreen -{ - HidTouchScreenHeader header; - HidTouchScreenEntry entries[17]; - u8 padding[0x3c0]; -} HidTouchScreen; -static_assert(sizeof(HidTouchScreen) == 0x3000, "Hid touch screen structure has incorrect size"); - -// End HidTouchScreen - -// Begin HidMouse - -typedef struct HidMouseHeader -{ - u64 timestampTicks; - u64 numEntries; - u64 latestEntry; - u64 maxEntryIndex; -} HidMouseHeader; -static_assert(sizeof(HidMouseHeader) == 0x20, "Hid mouse header structure has incorrect size"); - -typedef struct HidMouseEntry -{ - u64 timestamp; - u64 timestamp_2; - MousePosition position; - u64 buttons; -} HidMouseEntry; -static_assert(sizeof(HidMouseEntry) == 0x30, "Hid mouse entry structure has incorrect size"); - -typedef struct HidMouse -{ - HidMouseHeader header; - HidMouseEntry entries[17]; - u8 padding[0xB0]; -} HidMouse; -static_assert(sizeof(HidMouse) == 0x400, "Hid mouse structure has incorrect size"); - -// End HidMouse - -// Begin HidKeyboard - -typedef struct HidKeyboardHeader -{ - u64 timestampTicks; - u64 numEntries; - u64 latestEntry; - u64 maxEntryIndex; -} HidKeyboardHeader; -static_assert(sizeof(HidKeyboardHeader) == 0x20, "Hid keyboard header structure has incorrect size"); - -typedef struct HidKeyboardEntry -{ - u64 timestamp; - u64 timestamp_2; - u64 modifier; - u32 keys[8]; -} HidKeyboardEntry; -static_assert(sizeof(HidKeyboardEntry) == 0x38, "Hid keyboard entry structure has incorrect size"); - -typedef struct HidKeyboard -{ - HidKeyboardHeader header; - HidKeyboardEntry entries[17]; - u8 padding[0x28]; -} HidKeyboard; -static_assert(sizeof(HidKeyboard) == 0x400, "Hid keyboard structure has incorrect size"); - -// End HidKeyboard - -// Begin HidController - -typedef struct HidControllerMAC -{ - u64 timestamp; - u8 mac[0x8]; - u64 unk; - u64 timestamp_2; -} HidControllerMAC; -static_assert(sizeof(HidControllerMAC) == 0x20, "Hid controller MAC structure has incorrect size"); - -typedef struct HidControllerHeader -{ - u32 type; - u32 isHalf; - u32 singleColorsDescriptor; - u32 singleColorBody; - u32 singleColorButtons; - u32 splitColorsDescriptor; - u32 leftColorBody; - u32 leftColorButtons; - u32 rightColorBody; - u32 rightColorbuttons; -} HidControllerHeader; -static_assert(sizeof(HidControllerHeader) == 0x28, "Hid controller header structure has incorrect size"); - -typedef struct HidControllerLayoutHeader -{ - u64 timestampTicks; - u64 numEntries; - u64 latestEntry; - u64 maxEntryIndex; -} HidControllerLayoutHeader; -static_assert(sizeof(HidControllerLayoutHeader) == 0x20, "Hid controller layout header structure has incorrect size"); - -typedef struct HidControllerInputEntry -{ - u64 timestamp; - u64 timestamp_2; - u64 buttons; - JoystickPosition joysticks[JOYSTICK_NUM_STICKS]; - u64 connectionState; -} HidControllerInputEntry; -static_assert(sizeof(HidControllerInputEntry) == 0x30, "Hid controller input entry structure has incorrect size"); - -typedef struct HidControllerLayout -{ - HidControllerLayoutHeader header; - HidControllerInputEntry entries[17]; -} HidControllerLayout; -static_assert(sizeof(HidControllerLayout) == 0x350, "Hid controller layout structure has incorrect size"); - -typedef struct HidController -{ - HidControllerHeader header; - HidControllerLayout layouts[7]; - u8 unk_1[0x2A70]; - HidControllerMAC macLeft; - HidControllerMAC macRight; - u8 unk_2[0xDF8]; -} HidController; -static_assert(sizeof(HidController) == 0x5000, "Hid controller structure has incorrect size"); - -// End HidController - -typedef struct HidSharedMemory -{ - u8 header[0x400]; - HidTouchScreen touchscreen; - HidMouse mouse; - HidKeyboard keyboard; - u8 unkSection1[0x400]; - u8 unkSection2[0x400]; - u8 unkSection3[0x400]; - u8 unkSection4[0x400]; - u8 unkSection5[0x200]; - u8 unkSection6[0x200]; - u8 unkSection7[0x200]; - u8 unkSection8[0x800]; - u8 controllerSerials[0x4000]; - HidController controllers[10]; - u8 unkSection9[0x4600]; -} HidSharedMemory; -static_assert(sizeof(HidSharedMemory) == 0x40000, "Hid Shared Memory structure has incorrect size"); - -typedef struct HidVibrationDeviceInfo -{ - u32 unk_x0; - u32 unk_x4; ///< 0x1 for left-joycon, 0x2 for right-joycon. -} HidVibrationDeviceInfo; -static_assert(sizeof(HidVibrationDeviceInfo) == 0x8, "Hid VibrationDeviceInfo structure has incorrect size"); - -typedef struct HidVibrationValue -{ - float amp_low; ///< Low Band amplitude. 1.0f: Max amplitude. - float freq_low; ///< Low Band frequency in Hz. - float amp_high; ///< High Band amplitude. 1.0f: Max amplitude. - float freq_high; ///< High Band frequency in Hz. -} HidVibrationValue; -static_assert(sizeof(HidVibrationValue) == 0x10, "Hid VibrationValue structure has incorrect size"); - -Result hidInitialize(void); -void hidExit(void); -void hidReset(void); - -Service* hidGetSessionService(void); -void* hidGetSharedmemAddr(void); - -void hidSetControllerLayout(HidControllerID id, HidControllerLayoutType layoutType); -HidControllerLayoutType hidGetControllerLayout(HidControllerID id); -void hidScanInput(void); - -u64 hidKeysHeld(HidControllerID id); -u64 hidKeysDown(HidControllerID id); -u64 hidKeysUp(HidControllerID id); - -u64 hidMouseButtonsHeld(void); -u64 hidMouseButtonsDown(void); -u64 hidMouseButtonsUp(void); -void hidMouseRead(MousePosition *pos); - -bool hidKeyboardModifierHeld(HidKeyboardModifier modifier); -bool hidKeyboardModifierDown(HidKeyboardModifier modifier); -bool hidKeyboardModifierUp(HidKeyboardModifier modifier); - -bool hidKeyboardHeld(HidKeyboardScancode key); -bool hidKeyboardDown(HidKeyboardScancode key); -bool hidKeyboardUp(HidKeyboardScancode key); - -u32 hidTouchCount(void); -void hidTouchRead(touchPosition *pos, u32 point_id); - -void hidJoystickRead(JoystickPosition *pos, HidControllerID id, HidControllerJoystick stick); - -/// This can be used to check what CONTROLLER_P1_AUTO uses. -/// Returns 0 when CONTROLLER_PLAYER_1 is connected, otherwise returns 1 for handheld-mode. -bool hidGetHandheldMode(void); - -/// Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*. -/// When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example). -/// id must be CONTROLLER_PLAYER_*. -Result hidSetNpadJoyAssignmentModeSingleByDefault(HidControllerID id); - -/// Use this if you want to use a pair of joy-cons as a single CONTROLLER_PLAYER_*. Only necessary if you want to use this mode in your application after \ref hidSetNpadJoyAssignmentModeSingleByDefault was used with this pair of joy-cons. -/// Used automatically during app startup/exit for all controllers. -/// When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example). -/// id must be CONTROLLER_PLAYER_*. -Result hidSetNpadJoyAssignmentModeDual(HidControllerID id); - -/// Merge two single joy-cons into a dual-mode controller. Use this after \ref hidSetNpadJoyAssignmentModeDual, when \ref hidSetNpadJoyAssignmentModeSingleByDefault was previously used (this includes using this manually at application exit). -Result hidMergeSingleJoyAsDualJoy(HidControllerID id0, HidControllerID id1); - -Result hidInitializeVibrationDevices(u32 *VibrationDeviceHandles, size_t total_handles, HidControllerID id, HidControllerType type); - -/// Gets HidVibrationDeviceInfo for the specified VibrationDeviceHandle. -Result hidGetVibrationDeviceInfo(u32 *VibrationDeviceHandle, HidVibrationDeviceInfo *VibrationDeviceInfo); - -/// Send the VibrationValue to the specified VibrationDeviceHandle. -Result hidSendVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue); - -/// Gets the current HidVibrationValue for the specified VibrationDeviceHandle. -Result hidGetActualVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue); - -/// Sets whether vibration is allowed, this also affects the config displayed by System Settings. -Result hidPermitVibration(bool flag); - -/// Gets whether vibration is allowed. -Result hidIsVibrationPermitted(bool *flag); - -/// Send VibrationValues[index] to VibrationDeviceHandles[index], where count is the number of entries in the VibrationDeviceHandles/VibrationValues arrays. -Result hidSendVibrationValues(u32 *VibrationDeviceHandles, HidVibrationValue *VibrationValues, size_t count); diff --git a/src/libnx/wrapper/nx/include/switch/services/irs.h b/src/libnx/wrapper/nx/include/switch/services/irs.h deleted file mode 100644 index c4c566f..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/irs.h +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file irs.h - * @brief HID IR sensor (irs) service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once - -#include "../types.h" -#include "../services/sm.h" -#include "../services/hid.h" - -typedef struct { - u64 unk_x0; - u8 unk_x8; - u8 unk_x9; - u8 unk_xa; - u8 pad[5]; - u16 unk_x10; - u32 unk_x12; - u16 unk_x16; - u32 unk_constant;//offset 0x18 - u8 unk_x1c; - u8 unk_x1d; - u8 pad2[2]; -} PACKED IrsPackedMomentProcessorConfig; - -typedef struct { - u64 exposure; ///< IR Sensor exposure time in nanoseconds. - u32 ir_leds; ///< Controls the IR leds. 0: All leds, 1: Bright group, 2: Dim group, 3: None. - u32 digital_gain; ///< IR sensor signal's digital gain. - u8 color_invert; ///< Inverts the colors of the captured image. 0: Normal image, 1: Negative image. - u8 pad[7]; - u32 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80. -} IrsImageTransferProcessorConfig; - -typedef struct { - u64 exposure; ///< IR Sensor exposure time in nanoseconds. - u8 ir_leds; ///< Controls the IR leds. 0: All leds, 1: Bright group, 2: Dim group, 3: None. - u8 digital_gain; ///< IR sensor signal's digital gain. - u8 color_invert; ///< Inverts the colors of the captured image. 0: Normal image, 1: Negative image. - u8 pad[5]; - u32 unk_constant;//offset 0x10 - u8 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80. - u8 pad2[3]; -} IrsPackedImageTransferProcessorConfig; - -typedef struct { - u8 unk_x0[0x10]; -} PACKED IrsImageTransferProcessorState; - -Result irsInitialize(void); -void irsExit(void); - -Service* irsGetSessionService(void); -void* irsGetSharedmemAddr(void); - -/// (De)activate the IR sensor, this is automatically used by irsExit(). Must be called after irsInitialize() to activate the IR sensor. -Result irsActivateIrsensor(bool activate); - -Result irsGetIrCameraHandle(u32 *IrCameraHandle, HidControllerID id); - -/** - * @brief Start ImageTransferProcessor. - * @param[in] IrCameraHandle Camera handle. - * @param[in] config Input config. - * @param[in] size Work-buffer size, must be 0x1000-byte aligned. - * @note Do not use if already started. - */ -Result irsRunImageTransferProcessor(u32 IrCameraHandle, IrsImageTransferProcessorConfig *config, size_t size); - -Result irsGetImageTransferProcessorState(u32 IrCameraHandle, void* buffer, size_t size, IrsImageTransferProcessorState *state); - -/// Stop ImageTransferProcessor. Do not use if already stopped. -/// \ref irsExit calls this with all IrCameraHandles which were not already used with \ref irsStopImageProcessor. -Result irsStopImageProcessor(u32 IrCameraHandle); - -/// "Suspend" ImageTransferProcessor. -/// TODO: What does this really do? -Result irsSuspendImageProcessor(u32 IrCameraHandle); - -/** - * Gets the default configuration for Image Transfer mode. - * Defaults are exposure 300us, IR LEDs all ON, 8x digital gain, normal image and resolution 240 x 320. - */ -void irsGetDefaultImageTransferProcessorConfig(IrsImageTransferProcessorConfig *config); diff --git a/src/libnx/wrapper/nx/include/switch/services/ldr.h b/src/libnx/wrapper/nx/include/switch/services/ldr.h deleted file mode 100644 index e3df32f..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/ldr.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file ldr.h - * @brief Loader (ldr*) service IPC wrapper. - * @author SciresM - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" -#include "../services/fs.h" - -typedef struct { - u8 main_thread_priority; - u8 default_cpu_id; - u16 application_type; - u32 main_thread_stack_size; - u64 title_id; - u32 acid_sac_size; - u32 aci0_sac_size; - u32 acid_fac_size; - u32 aci0_fah_size; - u8 ac_buffer[0x3E0]; -} LoaderProgramInfo; - -typedef struct { - u64 base_address; - u64 size; - u8 build_id[0x20]; -} LoaderNsoInfo; - -Result ldrShellInitialize(void); -void ldrShellExit(void); - -Result ldrDmntInitialize(void); -void ldrDmntExit(void); - -Result ldrPmInitialize(void); -void ldrPmExit(void); - -Result ldrShellAddTitleToLaunchQueue(u64 tid, const void *args, size_t args_size); -Result ldrShellClearLaunchQueue(void); - -Result ldrDmntAddTitleToLaunchQueue(u64 tid, const void *args, size_t args_size); -Result ldrDmntClearLaunchQueue(void); -Result ldrDmntGetNsoInfos(u64 pid, LoaderNsoInfo *out_nso_infos, size_t out_size, u32 *num_out); - -Result ldrPmCreateProcess(u64 flags, u64 launch_index, Handle reslimit_h, Handle *out_process_h); -Result ldrPmGetProgramInfo(u64 title_id, FsStorageId storage_id, LoaderProgramInfo *out_program_info); -Result ldrPmRegisterTitle(u64 title_id, FsStorageId storage_id, u64 *out_index); -Result ldrPmUnregisterTitle(u64 launch_index); diff --git a/src/libnx/wrapper/nx/include/switch/services/lr.h b/src/libnx/wrapper/nx/include/switch/services/lr.h deleted file mode 100644 index da5f83f..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/lr.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file lr.h - * @brief Location Resolver (lr) service IPC wrapper. - * @author SciresM - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" -#include "../services/fs.h" - -typedef struct { - Service s; -} LrLocationResolver; - -typedef struct { - Service s; -} LrRegisteredLocationResolver; - -Result lrInitialize(void); -void lrExit(void); - -Result lrOpenLocationResolver(FsStorageId storage, LrLocationResolver* out); -Result lrOpenRegisteredLocationResolver(LrRegisteredLocationResolver* out); -// TODO: Other ILocationResolverManager commands - -// ILocationResolver -Result lrLrResolveProgramPath(LrLocationResolver* lr, u64 tid, char *out); -Result lrLrRedirectProgramPath(LrLocationResolver* lr, u64 tid, const char *path); -Result lrLrResolveApplicationControlPath(LrLocationResolver* lr, u64 tid, char *out); -Result lrLrResolveApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, char *out); -Result lrLrResolveDataPath(LrLocationResolver* lr, u64 tid, char *out); -Result lrLrRedirectApplicationControlPath(LrLocationResolver* lr, u64 tid, const char *path); -Result lrLrRedirectApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, const char *path); -Result lrLrResolveLegalInformationPath(LrLocationResolver* lr, u64 tid, char *out); -Result lrLrRedirectLegalInformationPath(LrLocationResolver* lr, u64 tid, const char *path); -Result lrLrRefresh(LrLocationResolver* lr); - -// IRegisteredLocationResolver -Result lrRegLrResolveProgramPath(LrRegisteredLocationResolver* reg, u64 tid, char *out); -// TODO: Other IRegisteredLocationResolver commands diff --git a/src/libnx/wrapper/nx/include/switch/services/nifm.h b/src/libnx/wrapper/nx/include/switch/services/nifm.h deleted file mode 100644 index ca5dce2..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/nifm.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @file nifm.h - * @brief Network interface service IPC wrapper. - * @author shadowninja108 - * @copyright libnx Authors - */ - -#pragma once - -#include "../kernel/ipc.h" -#include "../kernel/detect.h" - -#include "../services/sm.h" - -Result nifmInitialize(void); -void nifmExit(void); - -Result nifmGetCurrentIpAddress(u32* out); diff --git a/src/libnx/wrapper/nx/include/switch/services/ns.h b/src/libnx/wrapper/nx/include/switch/services/ns.h deleted file mode 100644 index 98c8358..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/ns.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file ns.h - * @brief NS service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../nacp.h" -#include "../services/fs.h" - -typedef struct { - NacpStruct nacp; - u8 icon[0x20000];//JPEG -} NsApplicationControlData; - -Result nsInitialize(void); -void nsExit(void); - -Result nsGetApplicationControlData(u8 flag, u64 titleID, NsApplicationControlData* buffer, size_t size, size_t* actual_size); - -/** - * @brief Returns the total storage capacity (used + free) from content manager services. - * @param storage_id Specified FsStorageId. (Must be FsStorageId_SdCard) - * @param size Pointer to output the total storage size to. - */ -Result nsGetTotalSpaceSize(FsStorageId storage_id, u64 *size); - -/** - * @brief Returns the available storage capacity from content manager services. - * @param storage_id Specified FsStorageId. (Must be FsStorageId_SdCard) - * @param size Pointer to output the free storage size to. - */ -Result nsGetFreeSpaceSize(FsStorageId storage_id, u64 *size); - -Result nsvmInitialize(void); -void nsvmExit(void); - -Result nsvmNeedsUpdateVulnerability(bool *out); -Result nsvmGetSafeSystemVersion(u16 *out); - -/* ns:dev */ -Result nsdevInitialize(); -void nsdevExit(); - -Result nsdevTerminateProcess(u64 pid); -Result nsdevTerminateProgram(u64 tid); \ No newline at end of file diff --git a/src/libnx/wrapper/nx/include/switch/services/nv.h b/src/libnx/wrapper/nx/include/switch/services/nv.h deleted file mode 100644 index ea3769a..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/nv.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file nv.h - * @brief NVIDIA low level driver (nvdrv*) service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -typedef enum { - NVSERVTYPE_Default = -1, - NVSERVTYPE_Application = 0, - NVSERVTYPE_Applet = 1, - NVSERVTYPE_Sysmodule = 2, - NVSERVTYPE_T = 3, -} nvServiceType; - -Result nvInitialize(nvServiceType servicetype, size_t sharedmem_size); -void nvExit(void); - -Result nvOpen(u32 *fd, const char *devicepath); -Result nvIoctl(u32 fd, u32 request, void* argp); -Result nvClose(u32 fd); -Result nvQueryEvent(u32 fd, u32 event_id, Handle *handle_out); - -Result nvConvertError(int rc); diff --git a/src/libnx/wrapper/nx/include/switch/services/pl.h b/src/libnx/wrapper/nx/include/switch/services/pl.h deleted file mode 100644 index fa016db..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/pl.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file pl.h - * @brief pl:u service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -typedef enum -{ - PlSharedFontType_Standard = 0, ///< Japan, US and Europe - PlSharedFontType_ChineseSimplified = 1, ///< Chinese Simplified - PlSharedFontType_ExtChineseSimplified = 2, ///< Extended Chinese Simplified - PlSharedFontType_ChineseTraditional = 3, ///< Chinese Traditional - PlSharedFontType_KO = 4, ///< Korean (Hangul) - PlSharedFontType_NintendoExt = 5, ///< Nintendo Extended - PlSharedFontType_Total, ///< Total fonts supported by this enum. -} PlSharedFontType; - -typedef struct { - u32 type; - u32 offset; - u32 size; - void* address; -} PlFontData; - -Result plInitialize(void); -void plExit(void); -void* plGetSharedmemAddr(void); - -///< Gets a specific shared-font via SharedFontType, see \ref PlSharedFontType. -Result plGetSharedFontByType(PlFontData* font, u32 SharedFontType); - -///< Gets shared font(s). -Result plGetSharedFont(u64 LanguageCode, PlFontData* fonts, size_t max_fonts, size_t* total_fonts); - diff --git a/src/libnx/wrapper/nx/include/switch/services/pm.h b/src/libnx/wrapper/nx/include/switch/services/pm.h deleted file mode 100644 index a55c7e7..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/pm.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file pm.h - * @brief Process management (pm*) service IPC wrapper. - * @author plutoo - * @author yellows8 - * @author mdbell - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -Result pmdmntInitialize(void); -void pmdmntExit(void); - -Result pminfoInitialize(void); -void pminfoExit(void); - -Result pmshellInitialize(void); -void pmshellExit(void); - -Result pmdmntStartProcess(u64 pid); -Result pmdmntGetTitlePid(u64* pid_out, u64 title_id); -Result pmdmntEnableDebugForTitleId(Handle* handle_out, u64 title_id); -Result pmdmntGetApplicationPid(u64* pid_out); -Result pmdmntEnableDebugForApplication(Handle* handle_out); - -Result pminfoGetTitleId(u64* title_id_out, u64 pid); - -Result pmshellLaunchProcess(u32 launch_flags, u64 titleID, u64 storageID, u64 *pid); -Result pmshellTerminateProcessByTitleId(u64 titleID); \ No newline at end of file diff --git a/src/libnx/wrapper/nx/include/switch/services/set.h b/src/libnx/wrapper/nx/include/switch/services/set.h deleted file mode 100644 index 2b40738..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/set.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @file set.h - * @brief Settings services IPC wrapper. - * @author plutoo - * @author yellows8 - * @copyright libnx Authors - */ -#include "../result.h" - -#define SET_MAX_NAME_SIZE 0x48 - -typedef enum { - ColorSetId_Light=0, - ColorSetId_Dark=1 -} ColorSetId; - -/// IDs for Language. -typedef enum -{ - SetLanguage_JA = 0, ///< Japanese - SetLanguage_ENUS = 1, ///< US English ("AmericanEnglish") - SetLanguage_FR = 2, ///< French - SetLanguage_DE = 3, ///< German - SetLanguage_IT = 4, ///< Italian - SetLanguage_ES = 5, ///< Spanish - SetLanguage_ZHCN = 6, ///< Simplified Chinese ("Chinese") - SetLanguage_KO = 7, ///< Korean - SetLanguage_NL = 8, ///< Dutch - SetLanguage_PT = 9, ///< Portuguese - SetLanguage_RU = 10, ///< Russian - SetLanguage_ZHTW = 11, ///< Traditional Chinese ("Taiwanese") - SetLanguage_ENGB = 12, ///< GB English ("BritishEnglish") - SetLanguage_FRCA = 13, ///< CA French ("CanadianFrench") - SetLanguage_ES419 = 14, ///< "LatinAmericanSpanish" - SetLanguage_Total, ///< Total languages supported by this enum. -} SetLanguage; - -/// Region codes. -typedef enum { - SetRegion_JPN = 0, ///< Japan - SetRegion_USA = 1, ///< The Americas - SetRegion_EUR = 2, ///< Europe - SetRegion_AUS = 3, ///< Australia/New Zealand -} SetRegion; - -/// Command IDs for setsysGetFlag/setsysSetFlag. -typedef enum { - SetSysFlag_LockScreen = 7, - SetSysFlag_ConsoleInformationUpload = 25, - SetSysFlag_AutomaticApplicationDownload = 27, - SetSysFlag_Quest = 47, - SetSysFlag_Usb30Enable = 65, - SetSysFlag_NfcEnable = 69, - SetSysFlag_WirelessLanEnable = 73, - SetSysFlag_BluetoothEnable = 88, - SetSysFlag_AutoUpdateEnable = 95, - SetSysFlag_BatteryPercentage = 99, - SetSysFlag_ExternalRtcReset = 101, - SetSysFlag_UsbFullKeyEnable = 103, - SetSysFlag_BluetoothAfhEnable = 111, - SetSysFlag_BluetoothBoostEnable = 113, - SetSysFlag_InRepairProcessEnable = 115, - SetSysFlag_HeadphoneVolumeUpdate = 117, -} SetSysFlag; - -Result setInitialize(void); -void setExit(void); - -/// Converts LanguageCode to Language. -Result setMakeLanguage(u64 LanguageCode, s32 *Language); - -/// Converts Language to LanguageCode. -Result setMakeLanguageCode(s32 Language, u64 *LanguageCode); - -/// Gets the current system LanguageCode. -/// Normally this should be used instead of \ref setGetLanguageCode. -/// LanguageCode is a string, see here: http://switchbrew.org/index.php?title=Settings_services#LanguageCode -Result setGetSystemLanguage(u64 *LanguageCode); - -/// Gets the current LanguageCode, \ref setGetSystemLanguage should be used instead normally. -Result setGetLanguageCode(u64 *LanguageCode); - -/// Gets available LanguageCodes. -/// On system-version <4.0.0, max_entries is set to the output from \ref setGetAvailableLanguageCodeCount if max_entries is larger than that. -Result setGetAvailableLanguageCodes(s32 *total_entries, u64 *LanguageCodes, size_t max_entries); - -/// Gets total available LanguageCodes. -/// Output total is overridden with value 0 if the total is <0. -Result setGetAvailableLanguageCodeCount(s32 *total); - -/// Gets the RegionCode. -Result setGetRegionCode(SetRegion *out); - -Result setsysInitialize(void); -void setsysExit(void); - -/// Gets the current system theme. -Result setsysGetColorSetId(ColorSetId *out); - -/// Sets the current system theme. -Result setsysSetColorSetId(ColorSetId id); - -/** - * @brief Gets the size of a settings item value. - * @param out Pointer to output the size to. - */ -Result setsysGetSettingsItemValueSize(const char *name, const char *item_key, u64 *size_out); - -/** - * @brief Gets the value of a settings item. - * @param out Pointer to output the value to. - */ -Result setsysGetSettingsItemValue(const char *name, const char *item_key, void *value_out, size_t value_out_size); - -/** - * @brief Gets the system's serial number. - * @param serial Pointer to output the serial to. (The buffer size needs to be at least 0x19 bytes) - */ -Result setsysGetSerialNumber(char *serial); - -/** - * @brief Gets the status of the specified settings flag. - * @param flag The specified settings flag. - * @param out Output pointer for the status. - */ -Result setsysGetFlag(SetSysFlag flag, bool *out); - -/** - * @brief Enables/disables the specified settings flag. - * @param flag The specified settings flag. - * @param enable To enable/disable the flag. - */ -Result setsysSetFlag(SetSysFlag flag, bool enable); \ No newline at end of file diff --git a/src/libnx/wrapper/nx/include/switch/services/sfdnsres.h b/src/libnx/wrapper/nx/include/switch/services/sfdnsres.h deleted file mode 100644 index 26ca14d..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/sfdnsres.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file sfdnsres.h - * @brief Domain name resolution service IPC wrapper. Please use socket.c instead. - * @author TuxSH - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -#include // For socklen_t, etc. - -/// Configuration structure for sfdnsres. -typedef struct { - size_t serialized_out_addrinfos_max_size; ///< For getaddrinfo. - size_t serialized_out_hostent_max_size; ///< For gethostbyname/gethostbyaddr. - bool bypass_nsd; ///< For name gethostbyname/getaddrinfo: bypass the Name Server Daemon. - int timeout; ///< For DNS requests: timeout or 0. -} SfdnsresConfig; - -/// Result values returned by the DNS request commands. -typedef struct { - int ret; ///< Return value (error code). - int errno_; ///< Errno. - ssize_t out_serialized_size; ///< Size of the serialized output buffer or -1 (?). -} SfdnsresRequestResults; - -// SetDnsAddressesPrivate & GetDnsAddressPrivate are stubbed - -Result sfdnsresGetHostByName(SfdnsresRequestResults *ret, const SfdnsresConfig *config, void *out_he_serialized, const char *name); -Result sfdnsresGetHostByAddr(SfdnsresRequestResults *ret, const SfdnsresConfig *config, void *out_he_serialized, const void *addr, socklen_t len, int type); - -Result sfdnsresGetHostStringError(int err, char *str, size_t str_size); -Result sfdnsresGetGaiStringError(int err, char *str, size_t str_size); - -Result sfdnsresGetAddrInfo(SfdnsresRequestResults *ret, const SfdnsresConfig *config, const char *node, const char *service, - const void *hints_serialized, size_t hints_serialized_size, void *res_serialized); -Result sfdnsresGetNameInfo(SfdnsresRequestResults *ret, const SfdnsresConfig *config, - const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, - char *serv, size_t servlen, int flags); - -/// Requests an handle for use with @ref sfdnsresCancelSocketCall. -Result sfdnsresRequestCancelHandle(u32 *out_handle); -/// Cancels a DNS request (how? which requests?). Bug: always sets errno? -Result sfdnsresCancelSocketCall(SfdnsresRequestResults *ret, u32 handle); -/// Cancels all DNS requests made by the current process (how? which requests?). Bug: always sets errno? -Result sfdnsresCancelAllSocketCalls(SfdnsresRequestResults *ret); -/// Clears up to 4 DNS server IPs registered by bsdcfg (DHCP client, etc.). -Result sfdnsresClearDnsIpServerAddressArray(void); diff --git a/src/libnx/wrapper/nx/include/switch/services/sm.h b/src/libnx/wrapper/nx/include/switch/services/sm.h deleted file mode 100644 index 2c78ec0..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/sm.h +++ /dev/null @@ -1,228 +0,0 @@ -/** - * @file sm.h - * @brief Service manager (sm) IPC wrapper. - * @author plutoo - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../kernel/svc.h" -#include "../kernel/ipc.h" - -/// Service type. -typedef enum { - ServiceType_Uninitialized, ///< Uninitialized service. - ServiceType_Normal, ///< Normal service. - ServiceType_Domain, ///< Domain. - ServiceType_DomainSubservice, ///< Domain subservice; - ServiceType_Override ///< Service overriden in the homebrew environment. -} ServiceType; - -/// Service object structure. -typedef struct { - Handle handle; - u32 object_id; - ServiceType type; -} Service; - -/** - * @brief Returns whether a service is overriden in the homebrew environment. - * @param[in] s Service object. - * @return true if overriden. - */ -static inline bool serviceIsOverride(Service* s) { - return s->type == ServiceType_Override; -} - -/** - * @brief Returns whether a service has been initialized. - * @param[in] s Service object. - * @return true if initialized. - */ -static inline bool serviceIsActive(Service* s) { - return s->type != ServiceType_Uninitialized; -} - -/** - * @brief Returns whether a service is a domain. - * @param[in] s Service object. - * @return true if a domain. - */ -static inline bool serviceIsDomain(Service* s) { - return s->type == ServiceType_Domain; -} - -/** - * @brief Returns whether a service is a domain subservice. - * @param[in] s Service object. - * @return true if a domain subservice. - */ -static inline bool serviceIsDomainSubservice(Service* s) { - return s->type == ServiceType_DomainSubservice; -} - -/** - * @brief For a domain/domain subservice, return the associated object ID. - * @param[in] s Service object, necessarily a domain or domain subservice. - * @return The object ID. - */ -static inline u32 serviceGetObjectId(Service* s) { - return s->object_id; -} - -/** - * @brief Closes a domain object by ID. - * @param[in] s Service object, necessarily a domain or domain subservice. - * @param object_id ID of the object to close. - * @return Result code. - */ -static inline Result serviceCloseObjectById(Service* s, u32 object_id) { - return ipcCloseObjectById(s->handle, object_id); -} - -/** - * @brief Dispatches an IPC request to a service. - * @param[in] s Service object. - * @return Result code. - */ -static inline Result serviceIpcDispatch(Service* s) { - return ipcDispatch(s->handle); -} - -/** - * @brief Creates a service object from an IPC session handle. - * @param[out] s Service object. - * @param[in] h IPC session handle. - */ -static inline void serviceCreate(Service* s, Handle h) { - s->handle = h; - s->type = ServiceType_Normal; - s->object_id = IPC_INVALID_OBJECT_ID; -} - -/** - * @brief Creates a domain subservice object from a parent service. - * @param[out] s Service object. - * @param[in] parent Parent service, necessarily a domain or domain subservice. - * @param[in] object_id Object ID for this subservice. - */ -static inline void serviceCreateDomainSubservice(Service* s, Service* parent, u32 object_id) { - s->handle = parent->handle; - s->type = ServiceType_DomainSubservice; - s->object_id = object_id; -} - -/** - * @brief Converts a regular service to a domain. - * @param[in] s Service object. - * @return Result code. - */ -static inline Result serviceConvertToDomain(Service* s) { - Result rc = ipcConvertSessionToDomain(s->handle, &s->object_id); - if(R_SUCCEEDED(rc)) - s->type = ServiceType_Domain; - return rc; -} - -/** - * @brief Closes a service. - * @param[in] s Service object. - */ -static inline void serviceClose(Service* s) { - switch (s->type) { - - case ServiceType_Normal: - case ServiceType_Domain: - ipcCloseSession(s->handle); - svcCloseHandle(s->handle); - break; - - case ServiceType_DomainSubservice: - serviceCloseObjectById(s, s->object_id); - break; - - case ServiceType_Override: - // Don't close because we don't own the overridden handle. - break; - - case ServiceType_Uninitialized: - break; - } - - s->type = ServiceType_Uninitialized; -} - -/** - * @brief Initializes SM. - * @return Result code. - * @note This function is already called in the default application startup code (before main() is called). - */ -Result smInitialize(void); - -/** - * @brief Uninitializes SM. - * @return Result code. - * @note This function is already handled in the default application exit code (after main() returns). - */ -void smExit(void); - -/** - * @brief Requests a service from SM. - * @param[out] service_out Service structure which will be filled in. - * @param[in] name Name of the service to request. - * @return Result code. - */ -Result smGetService(Service* service_out, const char* name); - -/** - * @brief Requests a service from SM, as an IPC session handle directly - * @param[out] handle_out Variable containing IPC session handle. - * @param[in] name Name of the service to request. - * @return Result code. - */ -Result smGetServiceOriginal(Handle* handle_out, u64 name); - -/** - * @brief Retrieves an overriden service in the homebrew environment. - * @param[in] name Name of the service to request (as 64-bit integer). - * @return IPC session handle. - */ -Handle smGetServiceOverride(u64 name); - -/** - * @brief Creates and registers a new service within SM. - * @param[out] handle_out Variable containing IPC port handle. - * @param[in] name Name of the service. - * @param[in] is_light "Is light" - * @param[in] max_sessions Maximum number of concurrent sessions that the service will accept. - * @return Result code. - */ -Result smRegisterService(Handle* handle_out, const char* name, bool is_light, int max_sessions); - -/** - * @brief Unregisters a previously registered service in SM. - * @param[in] name Name of the service. - * @return Result code. - */ -Result smUnregisterService(const char* name); - -/** - * @brief Check whether SM is initialized. - * @return true if initialized. - */ -bool smHasInitialized(void); - -/** - * @brief Encodes a service name as a 64-bit integer. - * @param[in] name Name of the service. - * @return Encoded name. - */ -u64 smEncodeName(const char* name); - -/** - * @brief Overrides a service with a custom IPC service handle. - * @param[in] name Name of the service (as 64-bit integer). - * @param[in] handle IPC session handle. - */ -void smAddOverrideHandle(u64 name, Handle handle); diff --git a/src/libnx/wrapper/nx/include/switch/services/smm.h b/src/libnx/wrapper/nx/include/switch/services/smm.h deleted file mode 100644 index 74beada..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/smm.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @file smm.h - * @brief ServiceManager-IManager (sm:m) service IPC wrapper. - * @author SciresM - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" -#include "../services/fs.h" - -Result smManagerInitialize(void); -void smManagerExit(void); - -Result smManagerRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size); -Result smManagerUnregisterProcess(u64 pid); diff --git a/src/libnx/wrapper/nx/include/switch/services/spl.h b/src/libnx/wrapper/nx/include/switch/services/spl.h deleted file mode 100644 index 79eb8e0..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/spl.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file spl.h - * @brief Security Processor Liaison (spl*) service IPC wrapper. - * @author SciresM - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" - -#define SPL_RSA_BUFFER_SIZE (0x100) - -typedef enum { - SplConfigItem_DisableProgramVerification = 1, - SplConfigItem_DramId = 2, - SplConfigItem_SecurityEngineIrqNumber = 3, - SplConfigItem_Version = 4, - SplConfigItem_HardwareType = 5, - SplConfigItem_IsRetail = 6, - SplConfigItem_IsRecoveryBoot = 7, - SplConfigItem_DeviceId = 8, - SplConfigItem_BootReason = 9, - SplConfigItem_MemoryArrange = 10, - SplConfigItem_IsDebugMode = 11, - SplConfigItem_KernelMemoryConfiguration = 12, - SplConfigItem_IsChargerHiZModeEnabled = 13, - SplConfigItem_IsKiosk = 14, - SplConfigItem_NewHardwareType = 15, - SplConfigItem_NewKeyGeneration = 16, - SplConfigItem_Package2Hash = 17, -} SplConfigItem; - -typedef enum { - RsaKeyVersion_Deprecated = 0, - RsaKeyVersion_Extended = 1, -} RsaKeyVersion; - -Result splInitialize(void); -void splExit(void); - -Result splCryptoInitialize(void); -void splCryptoExit(void); - -Result splSslInitialize(void); -void splSslExit(void); - -Result splEsInitialize(void); -void splEsExit(void); - -Result splFsInitialize(void); -void splFsExit(void); - -Result splManuInitialize(void); -void splManuExit(void); - -Result splGetConfig(SplConfigItem config_item, u64 *out_config); -Result splUserExpMod(const void *input, const void *modulus, const void *exp, size_t exp_size, void *dst); -Result splSetConfig(SplConfigItem config_item, u64 value); -Result splGetRandomBytes(void *out, size_t out_size); -Result splIsDevelopment(bool *out_is_development); -Result splSetSharedData(u32 value); -Result splGetSharedData(u32 *out_value); - -Result splCryptoGenerateAesKek(const void *wrapped_kek, u32 key_generation, u32 option, void *out_sealed_kek); -Result splCryptoLoadAesKey(const void *sealed_kek, const void *wrapped_key, u32 keyslot); -Result splCryptoGenerateAesKey(const void *sealed_kek, const void *wrapped_key, void *out_sealed_key); -Result splCryptoDecryptAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key); -Result splCryptoCryptAesCtr(const void *input, void *output, size_t size, const void *ctr); -Result splCryptoComputeCmac(const void *input, size_t size, u32 keyslot, void *out_cmac); -Result splCryptoLockAesEngine(u32 *out_keyslot); -Result splCryptoUnlockAesEngine(u32 keyslot); -Result splCryptoGetSecurityEngineEvent(Handle *out_event); - -Result splRsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size); - -Result splSslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); -Result splSslSecureExpMod(const void *input, const void *modulus, void *dst); - -Result splEsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); -Result splEsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey); -Result splEsUnwrapAesWrappedTitlekey(const void *aes_wrapped_titlekey, u32 key_generation, void *out_sealed_titlekey); -Result splEsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); -Result splEsSecureExpMod(const void *input, const void *modulus, void *dst); - -Result splFsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); -Result splFsSecureExpMod(const void *input, const void *modulus, void *dst); -Result splFsGenerateSpecificAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key); -Result splFsLoadTitlekey(const void *sealed_titlekey, u32 keyslot); -Result splFsGetPackage2Hash(void *out_hash); - -Result splManuEncryptRsaKeyForImport(const void *sealed_kek_pre, const void *wrapped_key_pre, const void *sealed_kek_post, const void *wrapped_kek_post, u32 option, const void *wrapped_rsa_key, void *out_wrapped_rsa_key, size_t rsa_key_size); diff --git a/src/libnx/wrapper/nx/include/switch/services/time.h b/src/libnx/wrapper/nx/include/switch/services/time.h deleted file mode 100644 index 0ef21a0..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/time.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file time.h - * @brief Time services IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once - -#include "../types.h" -#include "../services/sm.h" - -/// Time clock type. -typedef enum { - TimeType_UserSystemClock, - TimeType_NetworkSystemClock, - TimeType_LocalSystemClock, - TimeType_Default = TimeType_NetworkSystemClock, -} TimeType; - -Result timeInitialize(void); -void timeExit(void); - -Service* timeGetSessionService(void); - -Result timeGetCurrentTime(TimeType type, u64 *timestamp); - -/** - * @brief Sets the time for the specified clock. - * @param[in] type Clock to use. - * @param[in] timestamp POSIX UTC timestamp. - * @return Result code. - */ -Result timeSetCurrentTime(TimeType type, u64 timestamp); diff --git a/src/libnx/wrapper/nx/include/switch/services/usb.h b/src/libnx/wrapper/nx/include/switch/services/usb.h deleted file mode 100644 index 80e4b8d..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/usb.h +++ /dev/null @@ -1,190 +0,0 @@ -/** - * @file usb.h - * @brief USB (usb:*) service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" - -/// usb:ds Switch-as-device<>host USB comms, see also here: http://switchbrew.org/index.php?title=USB_services - -/// Names starting with "libusb" were changed to "usb" to avoid collision with actual libusb if it's ever used. - -#define USBDS_DEFAULT_InterfaceNumber 0x4 ///Value for usb_interface_descriptor bInterfaceNumber for automatically allocating the actual bInterfaceNumber. - -/// Imported from libusb with changed names. -/* Descriptor sizes per descriptor type */ -#define USB_DT_INTERFACE_SIZE 9 -#define USB_DT_ENDPOINT_SIZE 7 - -/// Imported from libusb, with some adjustments. -struct usb_endpoint_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; /// Must match USB_DT_ENDPOINT. - uint8_t bEndpointAddress; /// Should be one of the usb_endpoint_direction values, the endpoint-number is automatically allocated. - uint8_t bmAttributes; - uint16_t wMaxPacketSize; - uint8_t bInterval; -}; - -/// Imported from libusb, with some adjustments. -struct usb_interface_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; /// Must match USB_DT_INTERFACE. - uint8_t bInterfaceNumber; /// See also USBDS_DEFAULT_InterfaceNumber. - uint8_t bAlternateSetting; /// Must match 0. - uint8_t bNumEndpoints; /// Ignored. - uint8_t bInterfaceClass; - uint8_t bInterfaceSubClass; - uint8_t bInterfaceProtocol; - uint8_t iInterface; /// Ignored. -}; - -typedef struct { - u16 idVendor; /// VID - u16 idProduct; /// PID - u16 bcdDevice; - char Manufacturer[0x20]; - char Product[0x20]; - char SerialNumber[0x20]; -} UsbDsDeviceInfo; - -typedef struct { - u32 id; /// urbId from post-buffer cmds - u32 requestedSize; - u32 transferredSize; - u32 urb_status; -} UsbDsReportEntry; - -typedef struct { - UsbDsReportEntry report[8]; - u32 report_count; -} UsbDsReportData; - -typedef struct { - bool initialized; - u32 interface_index; - Service h; - - Handle SetupEvent; - Handle CtrlInCompletionEvent; - Handle CtrlOutCompletionEvent; -} UsbDsInterface; - -typedef struct { - bool initialized; - Service h; - Handle CompletionEvent; -} UsbDsEndpoint; - -typedef enum { - UsbComplexId_Default = 0x2 -} UsbComplexId; - -/// Imported from libusb, with changed names. -enum usb_class_code { - USB_CLASS_PER_INTERFACE = 0, - USB_CLASS_AUDIO = 1, - USB_CLASS_COMM = 2, - USB_CLASS_HID = 3, - USB_CLASS_PHYSICAL = 5, - USB_CLASS_PRINTER = 7, - USB_CLASS_PTP = 6, /* legacy name from libusb-0.1 usb.h */ - USB_CLASS_IMAGE = 6, - USB_CLASS_MASS_STORAGE = 8, - USB_CLASS_HUB = 9, - USB_CLASS_DATA = 10, - USB_CLASS_SMART_CARD = 0x0b, - USB_CLASS_CONTENT_SECURITY = 0x0d, - USB_CLASS_VIDEO = 0x0e, - USB_CLASS_PERSONAL_HEALTHCARE = 0x0f, - USB_CLASS_DIAGNOSTIC_DEVICE = 0xdc, - USB_CLASS_WIRELESS = 0xe0, - USB_CLASS_APPLICATION = 0xfe, - USB_CLASS_VENDOR_SPEC = 0xff -}; - -/// Imported from libusb, with changed names. -enum usb_descriptor_type { - USB_DT_DEVICE = 0x01, - USB_DT_CONFIG = 0x02, - USB_DT_STRING = 0x03, - USB_DT_INTERFACE = 0x04, - USB_DT_ENDPOINT = 0x05, - USB_DT_BOS = 0x0f, - USB_DT_DEVICE_CAPABILITY = 0x10, - USB_DT_HID = 0x21, - USB_DT_REPORT = 0x22, - USB_DT_PHYSICAL = 0x23, - USB_DT_HUB = 0x29, - USB_DT_SUPERSPEED_HUB = 0x2a, - USB_DT_SS_ENDPOINT_COMPANION = 0x30 -}; - -/// Imported from libusb, with changed names. -enum usb_endpoint_direction { - USB_ENDPOINT_IN = 0x80, - USB_ENDPOINT_OUT = 0x00 -}; - -/// Imported from libusb, with changed names. -enum usb_transfer_type { - USB_TRANSFER_TYPE_CONTROL = 0, - USB_TRANSFER_TYPE_ISOCHRONOUS = 1, - USB_TRANSFER_TYPE_BULK = 2, - USB_TRANSFER_TYPE_INTERRUPT = 3, - USB_TRANSFER_TYPE_BULK_STREAM = 4, -}; - -/// Imported from libusb, with changed names. -enum usb_iso_sync_type { - USB_ISO_SYNC_TYPE_NONE = 0, - USB_ISO_SYNC_TYPE_ASYNC = 1, - USB_ISO_SYNC_TYPE_ADAPTIVE = 2, - USB_ISO_SYNC_TYPE_SYNC = 3 -}; - -/// Imported from libusb, with changed names. -enum usb_iso_usage_type { - USB_ISO_USAGE_TYPE_DATA = 0, - USB_ISO_USAGE_TYPE_FEEDBACK = 1, - USB_ISO_USAGE_TYPE_IMPLICIT = 2, -}; - -Result usbDsInitialize(UsbComplexId complexId, const UsbDsDeviceInfo* deviceinfo); - -/// Exit usbDs. Any interfaces/endpoints which are left open are automatically closed, since otherwise usb-sysmodule won't fully reset usbds to defaults. -void usbDsExit(void); - -Service* usbDsGetServiceSession(void); -Handle usbDsGetStateChangeEvent(void); - -Result usbDsGetState(u32 *out); -Result usbDsGetDsInterface(UsbDsInterface** interface, struct usb_interface_descriptor* descriptor, const char *interface_name); - -/// Wait for initialization to finish where data-transfer is usable. -Result usbDsWaitReady(void); - -/// Parse usbDsReportData from the Get*ReportData commands, where urbId is from the post-buffer commands. Will return the converted urb_status result-value. -Result usbDsParseReportData(UsbDsReportData *reportdata, u32 urbId, u32 *requestedSize, u32 *transferredSize); - -/// IDsInterface -void usbDsInterface_Close(UsbDsInterface* interface); -Result usbDsInterface_GetDsEndpoint(UsbDsInterface* interface, UsbDsEndpoint** endpoint, struct usb_endpoint_descriptor* descriptor); -Result usbDsInterface_EnableInterface(UsbDsInterface* interface); -Result usbDsInterface_DisableInterface(UsbDsInterface* interface); -Result usbDsInterface_CtrlInPostBufferAsync(UsbDsInterface* interface, void* buffer, size_t size, u32 *urbId); -Result usbDsInterface_CtrlOutPostBufferAsync(UsbDsInterface* interface, void* buffer, size_t size, u32 *urbId); -Result usbDsInterface_GetCtrlInReportData(UsbDsInterface* interface, UsbDsReportData *out); -Result usbDsInterface_GetCtrlOutReportData(UsbDsInterface* interface, UsbDsReportData *out); -Result usbDsInterface_StallCtrl(UsbDsInterface* interface); - -/// IDsEndpoint - -void usbDsEndpoint_Close(UsbDsEndpoint* endpoint); -Result usbDsEndpoint_PostBufferAsync(UsbDsEndpoint* endpoint, void* buffer, size_t size, u32 *urbId); -Result usbDsEndpoint_GetReportData(UsbDsEndpoint* endpoint, UsbDsReportData *out); -Result usbDsEndpoint_StallCtrl(UsbDsEndpoint* endpoint); - diff --git a/src/libnx/wrapper/nx/include/switch/services/vi.h b/src/libnx/wrapper/nx/include/switch/services/vi.h deleted file mode 100644 index 9ed0d84..0000000 --- a/src/libnx/wrapper/nx/include/switch/services/vi.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file vi.h - * @brief Display (vi:*) service IPC wrapper. - * @author yellows8 - * @copyright libnx Authors - */ -#pragma once -#include "../types.h" -#include "../services/sm.h" - -typedef struct { - u64 display_id; - char display_name[0x40]; - bool initialized; -} ViDisplay; - -typedef struct { - u64 layer_id; - bool stray_layer; - bool initialized; -} ViLayer; - -typedef enum { - ViServiceType_Default = -1, - ViServiceType_Application = 0, - ViServiceType_System = 1, - ViServiceType_Manager = 2, -} ViServiceType; - -/// Used by viOpenLayer when CreateStrayLayer is used internally. -typedef enum { - ViLayerFlags_Default = 0x1, -} ViLayerFlags; - -/// Used with viSetLayerScalingMode. -typedef enum { - ViScalingMode_Default = 0x2, -} ViScalingMode; - -Result viInitialize(ViServiceType servicetype); -void viExit(void); - -Service* viGetSessionService(void); -Service* viGetSession_IApplicationDisplayService(void); -Service* viGetSession_IHOSBinderDriverRelay(void); -Service* viGetSession_ISystemDisplayService(void); -Service* viGetSession_IManagerDisplayService(void); -Service* viGetSession_IHOSBinderDriverIndirect(void); - -Result viOpenDisplay(const char *DisplayName, ViDisplay *display); -Result viCloseDisplay(ViDisplay *display); -Result viCreateManagedLayer(const ViDisplay *display, u32 LayerFlags, u64 AppletResourceUserId, u64 *layer_id); -Result viOpenLayer(u8 NativeWindow[0x100], u64 *NativeWindow_Size, const ViDisplay *display, ViLayer *layer, u32 LayerFlags, u64 LayerId); -Result viCloseLayer(ViLayer *layer); - -/// See ViScalingMode. -Result viSetLayerScalingMode(ViLayer *layer, u32 ScalingMode); - -Result viGetDisplayResolution(ViDisplay *display, u64 *width, u64 *height); -Result viGetDisplayVsyncEvent(ViDisplay *display, Handle *handle_out); diff --git a/src/libnx/wrapper/nx/include/switch/types.h b/src/libnx/wrapper/nx/include/switch/types.h deleted file mode 100644 index 7146e5b..0000000 --- a/src/libnx/wrapper/nx/include/switch/types.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file types.h - * @brief Various system types. - * @copyright libnx Authors - */ -#pragma once - -#include -#include -#include - -/// The maximum value of a u64. -#define U64_MAX UINT64_MAX - -#ifndef SSIZE_MAX -#ifdef SIZE_MAX -#define SSIZE_MAX ((SIZE_MAX) >> 1) -#endif -#endif - -typedef uint8_t u8; ///< 8-bit unsigned integer. -typedef uint16_t u16; ///< 16-bit unsigned integer. -typedef uint32_t u32; ///< 32-bit unsigned integer. -typedef uint64_t u64; ///< 64-bit unsigned integer. -typedef __uint128_t u128; ///< 128-bit unsigned integer. - -typedef int8_t s8; ///< 8-bit signed integer. -typedef int16_t s16; ///< 16-bit signed integer. -typedef int32_t s32; ///< 32-bit signed integer. -typedef int64_t s64; ///< 64-bit signed integer. -typedef __int128_t s128; ///< 128-bit unsigned integer. - -typedef volatile u8 vu8; ///< 8-bit volatile unsigned integer. -typedef volatile u16 vu16; ///< 16-bit volatile unsigned integer. -typedef volatile u32 vu32; ///< 32-bit volatile unsigned integer. -typedef volatile u64 vu64; ///< 64-bit volatile unsigned integer. -typedef volatile u128 vu128; ///< 128-bit volatile unsigned integer. - -typedef volatile s8 vs8; ///< 8-bit volatile signed integer. -typedef volatile s16 vs16; ///< 16-bit volatile signed integer. -typedef volatile s32 vs32; ///< 32-bit volatile signed integer. -typedef volatile s64 vs64; ///< 64-bit volatile signed integer. -typedef volatile s128 vs128; ///< 128-bit volatile signed integer. - -typedef u32 Handle; ///< Kernel object handle. -typedef u32 Result; ///< Function error code result type. -typedef void (*ThreadFunc)(void *); ///< Thread entrypoint function. -typedef void (*VoidFn)(void); ///< Function without arguments nor return value. - -/// Creates a bitmask from a bit number. -#define BIT(n) (1U<<(n)) - -/// Aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m. -#define ALIGN(m) __attribute__((aligned(m))) -/// Packs a struct (and other types?) so it won't include padding bytes. -#define PACKED __attribute__((packed)) - -#define NORETURN __attribute__((noreturn)) -#define IGNORE_ARG(x) (void)(x) - -#ifndef LIBNX_NO_DEPRECATION -/// Flags a function as deprecated. -#define DEPRECATED __attribute__ ((deprecated)) -#else -/// Flags a function as deprecated. -#define DEPRECATED -#endif - -#define INVALID_HANDLE ((Handle) 0) diff --git a/src/libnx/wrapper/nxlink.nim b/src/libnx/wrapper/nxlink.nim deleted file mode 100644 index fd6a323..0000000 --- a/src/libnx/wrapper/nxlink.nim +++ /dev/null @@ -1,14 +0,0 @@ -import strutils -import ospaths -const headernxlink = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/nxlink.h" -const - NXLINK_SERVER_PORT* = 28280 - NXLINK_CLIENT_PORT* = 28771 - -type - in_addr* {.importc: "in_addr", header: headernxlink, bycopy.} = object - - -var DUnxlink_host* {.importc: "__nxlink_host", header: headernxlink.}: in_addr - -proc nxlinkStdio*(): cint {.cdecl, importc: "nxlinkStdio", header: headernxlink.} \ No newline at end of file diff --git a/src/libnx/wrapper/parcel.nim b/src/libnx/wrapper/parcel.nim deleted file mode 100644 index cd0c372..0000000 --- a/src/libnx/wrapper/parcel.nim +++ /dev/null @@ -1,41 +0,0 @@ -import strutils -import ospaths -const headerparcel = currentSourcePath().splitPath().head & "/nx/include/switch/gfx/parcel.h" -import libnx/wrapper/types -import libnx/wrapper/result -import libnx/wrapper/binder -type - Parcel* {.importc: "Parcel", header: headerparcel, bycopy.} = object - payload* {.importc: "payload".}: array[0x00000400, uint8] - capacity* {.importc: "capacity".}: uint32 - size* {.importc: "size".}: uint32 - pos* {.importc: "pos".}: uint32 - ParcelObjects* {.importc: "ParcelObjects".}: ptr uint8 - ParcelObjectsSize* {.importc: "ParcelObjectsSize".}: uint32 - - -proc parcelInitialize*(ctx: ptr Parcel) {.cdecl, importc: "parcelInitialize", - header: headerparcel.} -proc parcelTransact*(session: ptr Binder; code: uint32; in_parcel: ptr Parcel; - reply_parcel: ptr Parcel): Result {.cdecl, - importc: "parcelTransact", header: headerparcel.} -proc parcelWriteData*(ctx: ptr Parcel; data: pointer; data_size: csize): pointer {. - cdecl, importc: "parcelWriteData", header: headerparcel.} -proc parcelReadData*(ctx: ptr Parcel; data: pointer; data_size: csize): pointer {. - cdecl, importc: "parcelReadData", header: headerparcel.} -proc parcelWriteInt32*(ctx: ptr Parcel; val: s32) {.cdecl, - importc: "parcelWriteInt32", header: headerparcel.} -proc parcelWriteUInt32*(ctx: ptr Parcel; val: uint32) {.cdecl, - importc: "parcelWriteUInt32", header: headerparcel.} -proc parcelWriteString16*(ctx: ptr Parcel; str: cstring) {.cdecl, - importc: "parcelWriteString16", header: headerparcel.} -proc parcelReadInt32*(ctx: ptr Parcel): s32 {.cdecl, importc: "parcelReadInt32", - header: headerparcel.} -proc parcelReadUInt32*(ctx: ptr Parcel): uint32 {.cdecl, importc: "parcelReadUInt32", - header: headerparcel.} -proc parcelWriteInterfaceToken*(ctx: ptr Parcel; str: cstring) {.cdecl, - importc: "parcelWriteInterfaceToken", header: headerparcel.} -proc parcelReadFlattenedObject*(ctx: ptr Parcel; size: ptr csize): pointer {.cdecl, - importc: "parcelReadFlattenedObject", header: headerparcel.} -proc parcelWriteFlattenedObject*(ctx: ptr Parcel; data: pointer; size: csize): pointer {. - cdecl, importc: "parcelWriteFlattenedObject", header: headerparcel.} \ No newline at end of file diff --git a/src/libnx/wrapper/pl.nim b/src/libnx/wrapper/pl.nim deleted file mode 100644 index 250604f..0000000 --- a/src/libnx/wrapper/pl.nim +++ /dev/null @@ -1,27 +0,0 @@ -import strutils -import ospaths -const headerpl = currentSourcePath().splitPath().head & "/nx/include/switch/services/pl.h" -import libnx/wrapper/types -type - PlSharedFontType* {.size: sizeof(cint).} = enum - PlSharedFontType_Standard = 0, PlSharedFontType_ChineseSimplified = 1, - PlSharedFontType_ExtChineseSimplified = 2, - PlSharedFontType_ChineseTraditional = 3, PlSharedFontType_KO = 4, - PlSharedFontType_NintendoExt = 5, PlSharedFontType_Total - PlFontData* {.importc: "PlFontData", header: headerpl, bycopy.} = object - `type`* {.importc: "type".}: uint32 - offset* {.importc: "offset".}: uint32 - size* {.importc: "size".}: uint32 - address* {.importc: "address".}: pointer - - - -proc plInitialize*(): Result {.cdecl, importc: "plInitialize", header: headerpl.} -proc plExit*() {.cdecl, importc: "plExit", header: headerpl.} -proc plGetSharedmemAddr*(): pointer {.cdecl, importc: "plGetSharedmemAddr", - header: headerpl.} -proc plGetSharedFontByType*(font: ptr PlFontData; SharedFontType: uint32): Result {. - cdecl, importc: "plGetSharedFontByType", header: headerpl.} -proc plGetSharedFont*(LanguageCode: uint64; fonts: ptr PlFontData; max_fonts: csize; - total_fonts: ptr csize): Result {.cdecl, - importc: "plGetSharedFont", header: headerpl.} \ No newline at end of file diff --git a/src/libnx/wrapper/pm.nim b/src/libnx/wrapper/pm.nim deleted file mode 100644 index b3ae23b..0000000 --- a/src/libnx/wrapper/pm.nim +++ /dev/null @@ -1,30 +0,0 @@ -import strutils -import ospaths -const headerpm = currentSourcePath().splitPath().head & "/nx/include/switch/services/pm.h" -import libnx/wrapper/types -proc pmdmntInitialize*(): Result {.cdecl, importc: "pmdmntInitialize", - header: headerpm.} -proc pmdmntExit*() {.cdecl, importc: "pmdmntExit", header: headerpm.} -proc pminfoInitialize*(): Result {.cdecl, importc: "pminfoInitialize", - header: headerpm.} -proc pminfoExit*() {.cdecl, importc: "pminfoExit", header: headerpm.} -proc pmshellInitialize*(): Result {.cdecl, importc: "pmshellInitialize", - header: headerpm.} -proc pmshellExit*() {.cdecl, importc: "pmshellExit", header: headerpm.} -proc pmdmntStartProcess*(pid: uint64): Result {.cdecl, importc: "pmdmntStartProcess", - header: headerpm.} -proc pmdmntGetTitlePid*(pid_out: ptr uint64; title_id: uint64): Result {.cdecl, - importc: "pmdmntGetTitlePid", header: headerpm.} -proc pmdmntEnableDebugForTitleId*(handle_out: ptr Handle; title_id: uint64): Result {. - cdecl, importc: "pmdmntEnableDebugForTitleId", header: headerpm.} -proc pmdmntGetApplicationPid*(pid_out: ptr uint64): Result {.cdecl, - importc: "pmdmntGetApplicationPid", header: headerpm.} -proc pmdmntEnableDebugForApplication*(handle_out: ptr Handle): Result {.cdecl, - importc: "pmdmntEnableDebugForApplication", header: headerpm.} -proc pminfoGetTitleId*(title_id_out: ptr uint64; pid: uint64): Result {.cdecl, - importc: "pminfoGetTitleId", header: headerpm.} -proc pmshellLaunchProcess*(launch_flags: uint32; titleID: uint64; storageID: uint64; - pid: ptr uint64): Result {.cdecl, - importc: "pmshellLaunchProcess", header: headerpm.} -proc pmshellTerminateProcessByTitleId*(titleID: uint64): Result {.cdecl, - importc: "pmshellTerminateProcessByTitleId", header: headerpm.} \ No newline at end of file diff --git a/src/libnx/wrapper/random.nim b/src/libnx/wrapper/random.nim deleted file mode 100644 index c2fa9e7..0000000 --- a/src/libnx/wrapper/random.nim +++ /dev/null @@ -1,7 +0,0 @@ -import strutils -import ospaths -const headerrandom = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/random.h" -import libnx/wrapper/types -proc randomGet*(buf: pointer; len: csize) {.cdecl, importc: "randomGet", - header: headerrandom.} -proc randomGet64*(): uint64 {.cdecl, importc: "randomGet64", header: headerrandom.} \ No newline at end of file diff --git a/src/libnx/wrapper/result.nim b/src/libnx/wrapper/result.nim deleted file mode 100644 index c3886ba..0000000 --- a/src/libnx/wrapper/result.nim +++ /dev/null @@ -1,116 +0,0 @@ -import strutils -import ospaths -const headerresult = currentSourcePath().splitPath().head & "/nx/include/switch/result.h" -## * -## @file result.h -## @brief Switch result code tools. -## @copyright libnx Authors -## - -import - types - -## / Checks whether a result code indicates success. - -template R_SUCCEEDED*(res: untyped): untyped = - ((res) == 0) - -## / Checks whether a result code indicates failure. - -template R_FAILED*(res: untyped): untyped = - ((res) != 0) - -## / Returns the module ID of a result code. - -template R_MODULE*(res: untyped): untyped = - ((res) and 0x000001FF) - -## / Returns the description of a result code. - -template R_DESCRIPTION*(res: untyped): untyped = - (((res) shr 9) and 0x00001FFF) - -## / Builds a result code from its constituent components. - -template MAKERESULT*(module, description: untyped): untyped = - ((((module) and 0x000001FF)) or ((description) and 0x00001FFF) shl 9) - -## / Module values - -const - Module_Kernel* = 1 - Module_Libnx* = 345 - Module_LibnxNvidia* = 348 - -## / Kernel error codes - -const - KernelError_Timeout* = 117 - -## / libnx error codes - -const - LibnxError_BadReloc* = 1 - LibnxError_OutOfMemory* = 2 - LibnxError_AlreadyMapped* = 3 - LibnxError_BadGetInfo_Stack* = 4 - LibnxError_BadGetInfo_Heap* = 5 - LibnxError_BadQueryMemory* = 6 - LibnxError_AlreadyInitialized* = 7 - LibnxError_NotInitialized* = 8 - LibnxError_NotFound* = 9 - LibnxError_IoError* = 10 - LibnxError_BadInput* = 11 - LibnxError_BadReent* = 12 - LibnxError_BufferProducerError* = 13 - LibnxError_HandleTooEarly* = 14 - LibnxError_HeapAllocFailed* = 15 - LibnxError_TooManyOverrides* = 16 - LibnxError_ParcelError* = 17 - LibnxError_BadGfxInit* = 18 - LibnxError_BadGfxEventWait* = 19 - LibnxError_BadGfxQueueBuffer* = 20 - LibnxError_BadGfxDequeueBuffer* = 21 - LibnxError_AppletCmdidNotFound* = 22 - LibnxError_BadAppletReceiveMessage* = 23 - LibnxError_BadAppletNotifyRunning* = 24 - LibnxError_BadAppletGetCurrentFocusState* = 25 - LibnxError_BadAppletGetOperationMode* = 26 - LibnxError_BadAppletGetPerformanceMode* = 27 - LibnxError_BadUsbCommsRead* = 28 - LibnxError_BadUsbCommsWrite* = 29 - LibnxError_InitFail_SM* = 30 - LibnxError_InitFail_AM* = 31 - LibnxError_InitFail_HID* = 32 - LibnxError_InitFail_FS* = 33 - LibnxError_BadGetInfo_Rng* = 34 - LibnxError_JitUnavailable* = 35 - LibnxError_WeirdKernel* = 36 - LibnxError_IncompatSysVer* = 37 - LibnxError_InitFail_Time* = 38 - LibnxError_TooManyDevOpTabs* = 39 - LibnxError_DomainMessageUnknownType* = 40 - LibnxError_DomainMessageTooManyObjectIds* = 41 - -## / libnx nvidia error codes - -const - LibnxNvidiaError_Unknown* = 1 - LibnxNvidiaError_NotImplemented* = 2 ## /< Maps to Nvidia: 1 - LibnxNvidiaError_NotSupported* = 3 ## /< Maps to Nvidia: 2 - LibnxNvidiaError_NotInitialized* = 4 ## /< Maps to Nvidia: 3 - LibnxNvidiaError_BadParameter* = 5 ## /< Maps to Nvidia: 4 - LibnxNvidiaError_Timeout* = 6 ## /< Maps to Nvidia: 5 - LibnxNvidiaError_InsufficientMemory* = 7 ## /< Maps to Nvidia: 6 - LibnxNvidiaError_ReadOnlyAttribute* = 8 ## /< Maps to Nvidia: 7 - LibnxNvidiaError_InvalidState* = 9 ## /< Maps to Nvidia: 8 - LibnxNvidiaError_InvalidAddress* = 10 ## /< Maps to Nvidia: 9 - LibnxNvidiaError_InvalidSize* = 11 ## /< Maps to Nvidia: 10 - LibnxNvidiaError_BadValue* = 12 ## /< Maps to Nvidia: 11 - LibnxNvidiaError_AlreadyAllocated* = 13 ## /< Maps to Nvidia: 13 - LibnxNvidiaError_Busy* = 14 ## /< Maps to Nvidia: 14 - LibnxNvidiaError_ResourceError* = 15 ## /< Maps to Nvidia: 15 - LibnxNvidiaError_CountMismatch* = 16 ## /< Maps to Nvidia: 16 - LibnxNvidiaError_SharedMemoryTooSmall* = 17 ## /< Maps to Nvidia: 0x1000 - LibnxNvidiaError_FileOperationFailed* = 18 ## /< Maps to Nvidia: 0x30003 - LibnxNvidiaError_IoctlFailed* = 19 ## /< Maps to Nvidia: 0x3000F diff --git a/src/libnx/wrapper/romfs_dev.nim b/src/libnx/wrapper/romfs_dev.nim deleted file mode 100644 index cf89377..0000000 --- a/src/libnx/wrapper/romfs_dev.nim +++ /dev/null @@ -1,101 +0,0 @@ -import strutils -import ospaths -const headerromfs_dev = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/devices/romfs_dev.h" -## * -## @file Romfs_dev.h -## @brief RomFS driver. -## @author yellows8 -## @author mtheall -## @author fincs -## @copyright libnx Authors -## - -import - ../libnx/wrapper/types, ../libnx/wrapper/fs - -## / RomFS header. - -type - Romfs_header* {.importc: "Romfs_header", header: headerromfs_dev, bycopy.} = object - headerSize* {.importc: "headerSize".}: uint64 ## /< Size of the header. - dirHashTableOff* {.importc: "dirHashTableOff".}: uint64 ## /< Offset of the directory hash table. - dirHashTableSize* {.importc: "dirHashTableSize".}: uint64 ## /< Size of the directory hash table. - dirTableOff* {.importc: "dirTableOff".}: uint64 ## /< Offset of the directory table. - dirTableSize* {.importc: "dirTableSize".}: uint64 ## /< Size of the directory table. - fileHashTableOff* {.importc: "fileHashTableOff".}: uint64 ## /< Offset of the file hash table. - fileHashTableSize* {.importc: "fileHashTableSize".}: uint64 ## /< Size of the file hash table. - fileTableOff* {.importc: "fileTableOff".}: uint64 ## /< Offset of the file table. - fileTableSize* {.importc: "fileTableSize".}: uint64 ## /< Size of the file table. - fileDataOff* {.importc: "fileDataOff".}: uint64 ## /< Offset of the file data. - - -## / RomFS directory. - -type - Romfs_dir* {.importc: "Romfs_dir", header: headerromfs_dev, bycopy.} = object - parent* {.importc: "parent".}: uint32 ## /< Offset of the parent directory. - sibling* {.importc: "sibling".}: uint32 ## /< Offset of the next sibling directory. - childDir* {.importc: "childDir".}: uint32 ## /< Offset of the first child directory. - childFile* {.importc: "childFile".}: uint32 ## /< Offset of the first file. - nextHash* {.importc: "nextHash".}: uint32 ## /< Directory hash table pointer. - nameLen* {.importc: "nameLen".}: uint32 ## /< Name length. - name* {.importc: "name".}: ptr uint8_t ## /< Name. (UTF-8) - - -## / RomFS file. - -type - Romfs_file* {.importc: "Romfs_file", header: headerromfs_dev, bycopy.} = object - parent* {.importc: "parent".}: uint32 ## /< Offset of the parent directory. - sibling* {.importc: "sibling".}: uint32 ## /< Offset of the next sibling file. - dataOff* {.importc: "dataOff".}: uint64 ## /< Offset of the file's data. - dataSize* {.importc: "dataSize".}: uint64 ## /< Length of the file's data. - nextHash* {.importc: "nextHash".}: uint32 ## /< File hash table pointer. - nameLen* {.importc: "nameLen".}: uint32 ## /< Name length. - name* {.importc: "name".}: ptr uint8_t ## /< Name. (UTF-8) - - Romfs_mount* {.importc: "Romfs_mount", header: headerromfs_dev, bycopy.} = object - - -## * -## @brief Mounts the Application's RomFS. -## @param mount Output mount handle -## - -proc romfsMount*(mount: ptr ptr Romfs_mount): Result {.cdecl, importc: "romfsMount", - header: headerromfs_dev.} -proc romfsInit*(): Result {.inline, cdecl, importc: "romfsInit", - header: headerromfs_dev.} -## * -## @brief Mounts RomFS from an open file. -## @param file FsFile of the RomFS image. -## @param offset Offset of the RomFS within the file. -## @param mount Output mount handle -## - -proc romfsMountFromFile*(file: FsFile; offset: uint64; mount: ptr ptr Romfs_mount): Result {. - cdecl, importc: "romfsMountFromFile", header: headerromfs_dev.} -proc romfsInitFromFile*(file: FsFile; offset: uint64): Result {.inline, cdecl, - importc: "romfsInitFromFile", header: headerromfs_dev.} -## * -## @brief Mounts RomFS from an open storage. -## @param storage FsStorage of the RomFS image. -## @param offset Offset of the RomFS within the storage. -## @param mount Output mount handle -## - -proc romfsMountFromStorage*(storage: FsStorage; offset: uint64; - mount: ptr ptr Romfs_mount): Result {.cdecl, - importc: "romfsMountFromStorage", header: headerromfs_dev.} -proc romfsInitFromStorage*(storage: FsStorage; offset: uint64): Result {.inline, cdecl, - importc: "romfsInitFromStorage", header: headerromfs_dev.} -## / Bind the RomFS mount - -proc romfsBind*(mount: ptr Romfs_mount): Result {.cdecl, importc: "romfsBind", - header: headerromfs_dev.} -## / Unmounts the RomFS device. - -proc romfsUnmount*(mount: ptr Romfs_mount): Result {.cdecl, importc: "romfsUnmount", - header: headerromfs_dev.} -proc romfsExit*(): Result {.inline, cdecl, importc: "romfsExit", - header: headerromfs_dev.} \ No newline at end of file diff --git a/src/libnx/wrapper/rwlock.nim b/src/libnx/wrapper/rwlock.nim deleted file mode 100644 index 71bb36c..0000000 --- a/src/libnx/wrapper/rwlock.nim +++ /dev/null @@ -1,19 +0,0 @@ -import strutils -import ospaths -const headerrwlock = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/rwlock.h" -import libnx/wrapper/mutex -type - RwLock* {.importc: "RwLock", header: headerrwlock, bycopy.} = object - r* {.importc: "r".}: RMutex - g* {.importc: "g".}: RMutex - b* {.importc: "b".}: uint64 - - -proc rwlockReadLock*(r: ptr RwLock) {.cdecl, importc: "rwlockReadLock", - header: headerrwlock.} -proc rwlockReadUnlock*(r: ptr RwLock) {.cdecl, importc: "rwlockReadUnlock", - header: headerrwlock.} -proc rwlockWriteLock*(r: ptr RwLock) {.cdecl, importc: "rwlockWriteLock", - header: headerrwlock.} -proc rwlockWriteUnlock*(r: ptr RwLock) {.cdecl, importc: "rwlockWriteUnlock", - header: headerrwlock.} \ No newline at end of file diff --git a/src/libnx/wrapper/set.nim b/src/libnx/wrapper/set.nim deleted file mode 100644 index d0d787e..0000000 --- a/src/libnx/wrapper/set.nim +++ /dev/null @@ -1,69 +0,0 @@ -import strutils -import ospaths -const headerset = currentSourcePath().splitPath().head & "/nx/include/switch/services/set.h" -import libnx/wrapper/types -import libnx/wrapper/result -const - SET_MAX_NAME_SIZE* = 0x00000048 - -type - ColorSetId* {.size: sizeof(cint).} = enum - ColorSetId_Light = 0, ColorSetId_Dark = 1 - SetLanguage* {.size: sizeof(cint).} = enum - SetLanguage_JA = 0, SetLanguage_ENUS = 1, SetLanguage_FR = 2, SetLanguage_DE = 3, - SetLanguage_IT = 4, SetLanguage_ES = 5, SetLanguage_ZHCN = 6, SetLanguage_KO = 7, - SetLanguage_NL = 8, SetLanguage_PT = 9, SetLanguage_RU = 10, SetLanguage_ZHTW = 11, - SetLanguage_ENGB = 12, SetLanguage_FRCA = 13, SetLanguage_ES419 = 14, - SetLanguage_Total - SetRegion* {.size: sizeof(cint).} = enum - SetRegion_JPN = 0, SetRegion_USA = 1, SetRegion_EUR = 2, SetRegion_AUS = 3 - SetSysFlag* {.size: sizeof(cint).} = enum - SetSysFlag_LockScreen = 7, SetSysFlag_ConsoleInformationUpload = 25, - SetSysFlag_AutomaticApplicationDownload = 27, SetSysFlag_Quest = 47, - SetSysFlag_Usb30Enable = 65, SetSysFlag_NfcEnable = 69, - SetSysFlag_WirelessLanEnable = 73, SetSysFlag_BluetoothEnable = 88, - SetSysFlag_AutoUpdateEnable = 95, SetSysFlag_BatteryPercentage = 99, - SetSysFlag_ExternalRtcReset = 101, SetSysFlag_UsbFullKeyEnable = 103, - SetSysFlag_BluetoothAfhEnable = 111, SetSysFlag_BluetoothBoostEnable = 113, - SetSysFlag_InRepairProcessEnable = 115, SetSysFlag_HeadphoneVolumeUpdate = 117 - - - - - -proc setInitialize*(): Result {.cdecl, importc: "setInitialize", header: headerset.} -proc setExit*() {.cdecl, importc: "setExit", header: headerset.} -proc setMakeLanguage*(LanguageCode: uint64; Language: ptr s32): Result {.cdecl, - importc: "setMakeLanguage", header: headerset.} -proc setMakeLanguageCode*(Language: s32; LanguageCode: ptr uint64): Result {.cdecl, - importc: "setMakeLanguageCode", header: headerset.} -proc setGetSystemLanguage*(LanguageCode: ptr uint64): Result {.cdecl, - importc: "setGetSystemLanguage", header: headerset.} -proc setGetLanguageCode*(LanguageCode: ptr uint64): Result {.cdecl, - importc: "setGetLanguageCode", header: headerset.} -proc setGetAvailableLanguageCodes*(total_entries: ptr s32; LanguageCodes: ptr uint64; - max_entries: csize): Result {.cdecl, - importc: "setGetAvailableLanguageCodes", header: headerset.} -proc setGetAvailableLanguageCodeCount*(total: ptr s32): Result {.cdecl, - importc: "setGetAvailableLanguageCodeCount", header: headerset.} -proc setGetRegionCode*(`out`: ptr SetRegion): Result {.cdecl, - importc: "setGetRegionCode", header: headerset.} -proc setsysInitialize*(): Result {.cdecl, importc: "setsysInitialize", - header: headerset.} -proc setsysExit*() {.cdecl, importc: "setsysExit", header: headerset.} -proc setsysGetColorSetId*(`out`: ptr ColorSetId): Result {.cdecl, - importc: "setsysGetColorSetId", header: headerset.} -proc setsysSetColorSetId*(id: ColorSetId): Result {.cdecl, - importc: "setsysSetColorSetId", header: headerset.} -proc setsysGetSettingsItemValueSize*(name: cstring; item_key: cstring; - size_out: ptr uint64): Result {.cdecl, - importc: "setsysGetSettingsItemValueSize", header: headerset.} -proc setsysGetSettingsItemValue*(name: cstring; item_key: cstring; - value_out: pointer; value_out_size: csize): Result {. - cdecl, importc: "setsysGetSettingsItemValue", header: headerset.} -proc setsysGetSerialNumber*(serial: cstring): Result {.cdecl, - importc: "setsysGetSerialNumber", header: headerset.} -proc setsysGetFlag*(flag: SetSysFlag; `out`: ptr bool): Result {.cdecl, - importc: "setsysGetFlag", header: headerset.} -proc setsysSetFlag*(flag: SetSysFlag; enable: bool): Result {.cdecl, - importc: "setsysSetFlag", header: headerset.} \ No newline at end of file diff --git a/src/libnx/wrapper/shmem.nim b/src/libnx/wrapper/shmem.nim deleted file mode 100644 index 89c037b..0000000 --- a/src/libnx/wrapper/shmem.nim +++ /dev/null @@ -1,80 +0,0 @@ -import strutils -import ospaths -const headershmem = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/shmem.h" -## * -## @file shmem.h -## @brief Shared memory object handling -## @author plutoo -## @copyright libnx Authors -## @remark Shared memory differs from transfer memory in the fact that the kernel (as opposed to the user process) allocates and owns its backing memory. -## - -import - libnx/wrapper/types - -## / Shared memory information structure. - -import libnx/wrapper/svc -type - SharedMemory* {.importc: "SharedMemory", header: headershmem, bycopy.} = object - handle* {.importc: "handle".}: Handle ## /< Kernel object handle. - size* {.importc: "size".}: csize ## /< Size of the shared memory object. - perm* {.importc: "perm".}: Permission ## /< Permissions. - map_addr* {.importc: "map_addr".}: pointer ## /< Address to which the shared memory object is mapped. - - -## * -## @brief Creates a shared memory object. -## @param s Shared memory information structure which will be filled in. -## @param size Size of the shared memory object to create. -## @param local_perm Permissions with which the shared memory object will be mapped in the local process. -## @param remote_perm Permissions with which the shared memory object will be mapped in the remote process (can be Perm_DontCare). -## @return Result code. -## @warning This is a privileged operation; in normal circumstances applications cannot use this function. -## - -proc shmemCreate*(s: ptr SharedMemory; size: csize; local_perm: Permission; - remote_perm: Permission): Result {.cdecl, importc: "shmemCreate", - header: headershmem.} -## * -## @brief Loads a shared memory object coming from a remote process. -## @param s Shared memory information structure which will be filled in. -## @param handle Handle of the shared memory object. -## @param size Size of the shared memory object that is being loaded. -## @param perm Permissions with which the shared memory object will be mapped in the local process. -## - -proc shmemLoadRemote*(s: ptr SharedMemory; handle: Handle; size: csize; perm: Permission) {. - cdecl, importc: "shmemLoadRemote", header: headershmem.} -## * -## @brief Maps a shared memory object. -## @param s Shared memory information structure. -## @return Result code. -## - -proc shmemMap*(s: ptr SharedMemory): Result {.cdecl, importc: "shmemMap", - header: headershmem.} -## * -## @brief Unmaps a shared memory object. -## @param s Shared memory information structure. -## @return Result code. -## - -proc shmemUnmap*(s: ptr SharedMemory): Result {.cdecl, importc: "shmemUnmap", - header: headershmem.} -## * -## @brief Retrieves the mapped address of a shared memory object. -## @param s Shared memory information structure. -## @return Mapped address of the shared memory object. -## - -proc shmemGetAddr*(s: ptr SharedMemory): pointer {.inline, cdecl, - importc: "shmemGetAddr", header: headershmem.} -## * -## @brief Frees up resources used by a shared memory object, unmapping and closing handles, etc. -## @param s Shared memory information structure. -## @return Result code. -## - -proc shmemClose*(s: ptr SharedMemory): Result {.cdecl, importc: "shmemClose", - header: headershmem.} \ No newline at end of file diff --git a/src/libnx/wrapper/sm.nim b/src/libnx/wrapper/sm.nim deleted file mode 100644 index 8b8d2d1..0000000 --- a/src/libnx/wrapper/sm.nim +++ /dev/null @@ -1,206 +0,0 @@ -import strutils -import ospaths -const headersm = currentSourcePath().splitPath().head & "/nx/include/switch/services/sm.h" -## * -## @file sm.h -## @brief Service manager (sm) IPC wrapper. -## @author plutoo -## @author yellows8 -## @copyright libnx Authors -## - -import - libnx/wrapper/types, libnx/wrapper/svc, libnx/wrapper/ipc - -## / Service type. - -type - ServiceType* {.size: sizeof(cint).} = enum - ServiceType_Uninitialized, ## /< Uninitialized service. - ServiceType_Normal, ## /< Normal service. - ServiceType_Domain, ## /< Domain. - ServiceType_DomainSubservice, ## /< Domain subservice; - ServiceType_Override ## /< Service overriden in the homebrew environment. - - -## / Service object structure. - -type - Service* {.importc: "Service", header: headersm, bycopy.} = object - handle* {.importc: "handle".}: Handle - object_id* {.importc: "object_id".}: uint32 - `type`* {.importc: "type".}: ServiceType - - -## * -## @brief Returns whether a service is overriden in the homebrew environment. -## @param[in] s Service object. -## @return true if overriden. -## - -proc serviceIsOverride*(s: ptr Service): bool {.inline, cdecl, - importc: "serviceIsOverride", header: headersm.} -## * -## @brief Returns whether a service has been initialized. -## @param[in] s Service object. -## @return true if initialized. -## - -proc serviceIsActive*(s: ptr Service): bool {.inline, cdecl, - importc: "serviceIsActive", header: headersm.} -## * -## @brief Returns whether a service is a domain. -## @param[in] s Service object. -## @return true if a domain. -## - -proc serviceIsDomain*(s: ptr Service): bool {.inline, cdecl, - importc: "serviceIsDomain", header: headersm.} -## * -## @brief Returns whether a service is a domain subservice. -## @param[in] s Service object. -## @return true if a domain subservice. -## - -proc serviceIsDomainSubservice*(s: ptr Service): bool {.inline, cdecl, - importc: "serviceIsDomainSubservice", header: headersm.} -## * -## @brief For a domain/domain subservice, return the associated object ID. -## @param[in] s Service object, necessarily a domain or domain subservice. -## @return The object ID. -## - -proc serviceGetObjectId*(s: ptr Service): uint32 {.inline, cdecl, - importc: "serviceGetObjectId", header: headersm.} -## * -## @brief Closes a domain object by ID. -## @param[in] s Service object, necessarily a domain or domain subservice. -## @param object_id ID of the object to close. -## @return Result code. -## - -proc serviceCloseObjectById*(s: ptr Service; object_id: uint32): Result {.inline, cdecl, - importc: "serviceCloseObjectById", header: headersm.} -## * -## @brief Dispatches an IPC request to a service. -## @param[in] s Service object. -## @return Result code. -## - -proc serviceIpcDispatch*(s: ptr Service): Result {.inline, cdecl, - importc: "serviceIpcDispatch", header: headersm.} -## * -## @brief Creates a service object from an IPC session handle. -## @param[out] s Service object. -## @param[in] h IPC session handle. -## - -proc serviceCreate*(s: ptr Service; h: Handle) {.inline, cdecl, - importc: "serviceCreate", header: headersm.} -## * -## @brief Creates a domain subservice object from a parent service. -## @param[out] s Service object. -## @param[in] parent Parent service, necessarily a domain or domain subservice. -## @param[in] object_id Object ID for this subservice. -## - -proc serviceCreateDomainSubservice*(s: ptr Service; parent: ptr Service; object_id: uint32) {. - inline, cdecl, importc: "serviceCreateDomainSubservice", header: headersm.} -## * -## @brief Converts a regular service to a domain. -## @param[in] s Service object. -## @return Result code. -## - -proc serviceConvertToDomain*(s: ptr Service): Result {.inline, cdecl, - importc: "serviceConvertToDomain", header: headersm.} -## * -## @brief Closes a service. -## @param[in] s Service object. -## - -proc serviceClose*(s: ptr Service) {.inline, cdecl, importc: "serviceClose", - header: headersm.} -## * -## @brief Initializes SM. -## @return Result code. -## @note This function is already called in the default application startup code (before main() is called). -## - -proc smInitialize*(): Result {.cdecl, importc: "smInitialize", header: headersm.} -## * -## @brief Uninitializes SM. -## @return Result code. -## @note This function is already handled in the default application exit code (after main() returns). -## - -proc smExit*() {.cdecl, importc: "smExit", header: headersm.} -## * -## @brief Requests a service from SM. -## @param[out] service_out Service structure which will be filled in. -## @param[in] name Name of the service to request. -## @return Result code. -## - -proc smGetService*(service_out: ptr Service; name: cstring): Result {.cdecl, - importc: "smGetService", header: headersm.} -## * -## @brief Requests a service from SM, as an IPC session handle directly -## @param[out] handle_out Variable containing IPC session handle. -## @param[in] name Name of the service to request. -## @return Result code. -## - -proc smGetServiceOriginal*(handle_out: ptr Handle; name: uint64): Result {.cdecl, - importc: "smGetServiceOriginal", header: headersm.} -## * -## @brief Retrieves an overriden service in the homebrew environment. -## @param[in] name Name of the service to request (as 64-bit integer). -## @return IPC session handle. -## - -proc smGetServiceOverride*(name: uint64): Handle {.cdecl, - importc: "smGetServiceOverride", header: headersm.} -## * -## @brief Creates and registers a new service within SM. -## @param[out] handle_out Variable containing IPC port handle. -## @param[in] name Name of the service. -## @param[in] is_light "Is light" -## @param[in] max_sessions Maximum number of concurrent sessions that the service will accept. -## @return Result code. -## - -proc smRegisterService*(handle_out: ptr Handle; name: cstring; is_light: bool; - max_sessions: cint): Result {.cdecl, - importc: "smRegisterService", header: headersm.} -## * -## @brief Unregisters a previously registered service in SM. -## @param[in] name Name of the service. -## @return Result code. -## - -proc smUnregisterService*(name: cstring): Result {.cdecl, - importc: "smUnregisterService", header: headersm.} -## * -## @brief Check whether SM is initialized. -## @return true if initialized. -## - -proc smHasInitialized*(): bool {.cdecl, importc: "smHasInitialized", - header: headersm.} -## * -## @brief Encodes a service name as a 64-bit integer. -## @param[in] name Name of the service. -## @return Encoded name. -## - -proc smEncodeName*(name: cstring): uint64 {.cdecl, importc: "smEncodeName", - header: headersm.} -## * -## @brief Overrides a service with a custom IPC service handle. -## @param[in] name Name of the service (as 64-bit integer). -## @param[in] handle IPC session handle. -## - -proc smAddOverrideHandle*(name: uint64; handle: Handle) {.cdecl, - importc: "smAddOverrideHandle", header: headersm.} \ No newline at end of file diff --git a/src/libnx/wrapper/smm.nim b/src/libnx/wrapper/smm.nim deleted file mode 100644 index ea82b46..0000000 --- a/src/libnx/wrapper/smm.nim +++ /dev/null @@ -1,14 +0,0 @@ -import strutils -import ospaths -const headersmm = currentSourcePath().splitPath().head & "/nx/include/switch/services/smm.h" -import libnx/wrapper/types -import libnx/wrapper/sm -import libnx/wrapper/fs -proc smManagerInitialize*(): Result {.cdecl, importc: "smManagerInitialize", - header: headersmm.} -proc smManagerExit*() {.cdecl, importc: "smManagerExit", header: headersmm.} -proc smManagerRegisterProcess*(pid: uint64; acid_sac: pointer; acid_sac_size: csize; - aci0_sac: pointer; aci0_sac_size: csize): Result {. - cdecl, importc: "smManagerRegisterProcess", header: headersmm.} -proc smManagerUnregisterProcess*(pid: uint64): Result {.cdecl, - importc: "smManagerUnregisterProcess", header: headersmm.} \ No newline at end of file diff --git a/src/libnx/wrapper/socket.nim b/src/libnx/wrapper/socket.nim deleted file mode 100644 index 7c5d0de..0000000 --- a/src/libnx/wrapper/socket.nim +++ /dev/null @@ -1,31 +0,0 @@ -import strutils -import ospaths -const headersocket = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/devices/socket.h" -import libnx/wrapper/types -type - SocketInitConfig* {.importc: "SocketInitConfig", header: headersocket, bycopy.} = object - bsdsockets_version* {.importc: "bsdsockets_version".}: uint32 - tcp_tx_buf_size* {.importc: "tcp_tx_buf_size".}: uint32 - tcp_rx_buf_size* {.importc: "tcp_rx_buf_size".}: uint32 - tcp_tx_buf_max_size* {.importc: "tcp_tx_buf_max_size".}: uint32 - tcp_rx_buf_max_size* {.importc: "tcp_rx_buf_max_size".}: uint32 - udp_tx_buf_size* {.importc: "udp_tx_buf_size".}: uint32 - udp_rx_buf_size* {.importc: "udp_rx_buf_size".}: uint32 - sb_efficiency* {.importc: "sb_efficiency".}: uint32 - serialized_out_addrinfos_max_size* {.importc: "serialized_out_addrinfos_max_size".}: csize - serialized_out_hostent_max_size* {.importc: "serialized_out_hostent_max_size".}: csize - bypass_nsd* {.importc: "bypass_nsd".}: bool - dns_timeout* {.importc: "dns_timeout".}: cint - - -proc socketGetDefaultInitConfig*(): ptr SocketInitConfig {.cdecl, - importc: "socketGetDefaultInitConfig", header: headersocket.} -proc socketInitialize*(config: ptr SocketInitConfig): Result {.cdecl, - importc: "socketInitialize", header: headersocket.} -proc socketGetLastBsdResult*(): Result {.cdecl, importc: "socketGetLastBsdResult", - header: headersocket.} -proc socketGetLastSfdnsresResult*(): Result {.cdecl, - importc: "socketGetLastSfdnsresResult", header: headersocket.} -proc socketExit*() {.cdecl, importc: "socketExit", header: headersocket.} -proc socketInitializeDefault*(): Result {.inline, cdecl.} = - return socketInitialize(socketGetDefaultInitConfig()) diff --git a/src/libnx/wrapper/spl.nim b/src/libnx/wrapper/spl.nim deleted file mode 100644 index 1619a39..0000000 --- a/src/libnx/wrapper/spl.nim +++ /dev/null @@ -1,125 +0,0 @@ -import strutils -import ospaths -const headerspl = currentSourcePath().splitPath().head & "/nx/include/switch/services/spl.h" -import libnx/wrapper/types -type - SplConfigItem* {.size: sizeof(cint).} = enum - SplConfigItem_DisableProgramVerification = 1, SplConfigItem_DramId = 2, - SplConfigItem_SecurityEngineIrqNumber = 3, SplConfigItem_Version = 4, - SplConfigItem_HardwareType = 5, SplConfigItem_IsRetail = 6, - SplConfigItem_IsRecoveryBoot = 7, SplConfigItem_DeviceId = 8, - SplConfigItem_BootReason = 9, SplConfigItem_MemoryArrange = 10, - SplConfigItem_IsDebugMode = 11, SplConfigItem_KernelMemoryConfiguration = 12, - SplConfigItem_IsChargerHiZModeEnabled = 13, SplConfigItem_IsKiosk = 14, - SplConfigItem_NewHardwareType = 15, SplConfigItem_NewKeyGeneration = 16, - SplConfigItem_Package2Hash = 17 - RsaKeyVersion* {.size: sizeof(cint).} = enum - RsaKeyVersion_Deprecated = 0, RsaKeyVersion_Extended = 1 - - - -proc splInitialize*(): Result {.cdecl, importc: "splInitialize", header: headerspl.} -proc splExit*() {.cdecl, importc: "splExit", header: headerspl.} -proc splCryptoInitialize*(): Result {.cdecl, importc: "splCryptoInitialize", - header: headerspl.} -proc splCryptoExit*() {.cdecl, importc: "splCryptoExit", header: headerspl.} -proc splSslInitialize*(): Result {.cdecl, importc: "splSslInitialize", - header: headerspl.} -proc splSslExit*() {.cdecl, importc: "splSslExit", header: headerspl.} -proc splEsInitialize*(): Result {.cdecl, importc: "splEsInitialize", - header: headerspl.} -proc splEsExit*() {.cdecl, importc: "splEsExit", header: headerspl.} -proc splFsInitialize*(): Result {.cdecl, importc: "splFsInitialize", - header: headerspl.} -proc splFsExit*() {.cdecl, importc: "splFsExit", header: headerspl.} -proc splManuInitialize*(): Result {.cdecl, importc: "splManuInitialize", - header: headerspl.} -proc splManuExit*() {.cdecl, importc: "splManuExit", header: headerspl.} -proc splGetConfig*(config_item: SplConfigItem; out_config: ptr uint64): Result {.cdecl, - importc: "splGetConfig", header: headerspl.} -proc splUserExpMod*(input: pointer; modulus: pointer; exp: pointer; exp_size: csize; - dst: pointer): Result {.cdecl, importc: "splUserExpMod", - header: headerspl.} -proc splSetConfig*(config_item: SplConfigItem; value: uint64): Result {.cdecl, - importc: "splSetConfig", header: headerspl.} -proc splGetRandomBytes*(`out`: pointer; out_size: csize): Result {.cdecl, - importc: "splGetRandomBytes", header: headerspl.} -proc splIsDevelopment*(out_is_development: ptr bool): Result {.cdecl, - importc: "splIsDevelopment", header: headerspl.} -proc splSetSharedData*(value: uint32): Result {.cdecl, importc: "splSetSharedData", - header: headerspl.} -proc splGetSharedData*(out_value: ptr uint32): Result {.cdecl, - importc: "splGetSharedData", header: headerspl.} -proc splCryptoGenerateAesKek*(wrapped_kek: pointer; key_generation: uint32; option: uint32; - out_sealed_kek: pointer): Result {.cdecl, - importc: "splCryptoGenerateAesKek", header: headerspl.} -proc splCryptoLoadAesKey*(sealed_kek: pointer; wrapped_key: pointer; keyslot: uint32): Result {. - cdecl, importc: "splCryptoLoadAesKey", header: headerspl.} -proc splCryptoGenerateAesKey*(sealed_kek: pointer; wrapped_key: pointer; - out_sealed_key: pointer): Result {.cdecl, - importc: "splCryptoGenerateAesKey", header: headerspl.} -proc splCryptoDecryptAesKey*(wrapped_key: pointer; key_generation: uint32; option: uint32; - out_sealed_key: pointer): Result {.cdecl, - importc: "splCryptoDecryptAesKey", header: headerspl.} -proc splCryptoCryptAesCtr*(input: pointer; output: pointer; size: csize; ctr: pointer): Result {. - cdecl, importc: "splCryptoCryptAesCtr", header: headerspl.} -proc splCryptoComputeCmac*(input: pointer; size: csize; keyslot: uint32; out_cmac: pointer): Result {. - cdecl, importc: "splCryptoComputeCmac", header: headerspl.} -proc splCryptoLockAesEngine*(out_keyslot: ptr uint32): Result {.cdecl, - importc: "splCryptoLockAesEngine", header: headerspl.} -proc splCryptoUnlockAesEngine*(keyslot: uint32): Result {.cdecl, - importc: "splCryptoUnlockAesEngine", header: headerspl.} -proc splCryptoGetSecurityEngineEvent*(out_event: ptr Handle): Result {.cdecl, - importc: "splCryptoGetSecurityEngineEvent", header: headerspl.} -proc splRsaDecryptPrivateKey*(sealed_kek: pointer; wrapped_key: pointer; - wrapped_rsa_key: pointer; - wrapped_rsa_key_size: csize; version: RsaKeyVersion; - dst: pointer; dst_size: csize): Result {.cdecl, - importc: "splRsaDecryptPrivateKey", header: headerspl.} -proc splSslLoadSecureExpModKey*(sealed_kek: pointer; wrapped_key: pointer; - wrapped_rsa_key: pointer; - wrapped_rsa_key_size: csize; version: RsaKeyVersion): Result {. - cdecl, importc: "splSslLoadSecureExpModKey", header: headerspl.} -proc splSslSecureExpMod*(input: pointer; modulus: pointer; dst: pointer): Result {. - cdecl, importc: "splSslSecureExpMod", header: headerspl.} -proc splEsLoadRsaOaepKey*(sealed_kek: pointer; wrapped_key: pointer; - wrapped_rsa_key: pointer; wrapped_rsa_key_size: csize; - version: RsaKeyVersion): Result {.cdecl, - importc: "splEsLoadRsaOaepKey", header: headerspl.} -proc splEsUnwrapRsaOaepWrappedTitlekey*(rsa_wrapped_titlekey: pointer; - modulus: pointer; label_hash: pointer; - label_hash_size: csize; - key_generation: uint32; - out_sealed_titlekey: pointer): Result {. - cdecl, importc: "splEsUnwrapRsaOaepWrappedTitlekey", header: headerspl.} -proc splEsUnwrapAesWrappedTitlekey*(aes_wrapped_titlekey: pointer; - key_generation: uint32; - out_sealed_titlekey: pointer): Result {.cdecl, - importc: "splEsUnwrapAesWrappedTitlekey", header: headerspl.} -proc splEsLoadSecureExpModKey*(sealed_kek: pointer; wrapped_key: pointer; - wrapped_rsa_key: pointer; - wrapped_rsa_key_size: csize; version: RsaKeyVersion): Result {. - cdecl, importc: "splEsLoadSecureExpModKey", header: headerspl.} -proc splEsSecureExpMod*(input: pointer; modulus: pointer; dst: pointer): Result {. - cdecl, importc: "splEsSecureExpMod", header: headerspl.} -proc splFsLoadSecureExpModKey*(sealed_kek: pointer; wrapped_key: pointer; - wrapped_rsa_key: pointer; - wrapped_rsa_key_size: csize; version: RsaKeyVersion): Result {. - cdecl, importc: "splFsLoadSecureExpModKey", header: headerspl.} -proc splFsSecureExpMod*(input: pointer; modulus: pointer; dst: pointer): Result {. - cdecl, importc: "splFsSecureExpMod", header: headerspl.} -proc splFsGenerateSpecificAesKey*(wrapped_key: pointer; key_generation: uint32; - option: uint32; out_sealed_key: pointer): Result {. - cdecl, importc: "splFsGenerateSpecificAesKey", header: headerspl.} -proc splFsLoadTitlekey*(sealed_titlekey: pointer; keyslot: uint32): Result {.cdecl, - importc: "splFsLoadTitlekey", header: headerspl.} -proc splFsGetPackage2Hash*(out_hash: pointer): Result {.cdecl, - importc: "splFsGetPackage2Hash", header: headerspl.} -proc splManuEncryptRsaKeyForImport*(sealed_kek_pre: pointer; - wrapped_key_pre: pointer; - sealed_kek_post: pointer; - wrapped_kek_post: pointer; option: uint32; - wrapped_rsa_key: pointer; - out_wrapped_rsa_key: pointer; - rsa_key_size: csize): Result {.cdecl, - importc: "splManuEncryptRsaKeyForImport", header: headerspl.} \ No newline at end of file diff --git a/src/libnx/wrapper/svc.nim b/src/libnx/wrapper/svc.nim deleted file mode 100644 index 20a1090..0000000 --- a/src/libnx/wrapper/svc.nim +++ /dev/null @@ -1,1150 +0,0 @@ -import strutils -import ospaths -const headersvc = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/svc.h" -## * -## @file svc.h -## @brief Wrappers for kernel syscalls. -## @copyright libnx Authors -## - -import - libnx/wrapper/types - -## / Pseudo handle for the current process. - -const - CUR_PROCESS_HANDLE* = 0xFFFF8001 - -## / Pseudo handle for the current thread. - -const - CUR_THREAD_HANDLE* = 0xFFFF8000 - -## / Memory type enumeration (lower 8 bits of \ref MemoryState) - -import libnx/wrapper/types -type - MemoryType* {.size: sizeof(cint).} = enum - MemType_Unmapped = 0x00000000, ## /< Unmapped memory. - MemType_Io = 0x00000001, ## /< Mapped by kernel capability parsing in \ref svcCreateProcess. - MemType_Normal = 0x00000002, ## /< Mapped by kernel capability parsing in \ref svcCreateProcess. - MemType_CodeStatic = 0x00000003, ## /< Mapped during \ref svcCreateProcess. - MemType_CodeMutable = 0x00000004, ## /< Transition from MemType_CodeStatic performed by \ref svcSetProcessMemoryPermission. - MemType_Heap = 0x00000005, ## /< Mapped using \ref svcSetHeapSize. - MemType_SharedMem = 0x00000006, ## /< Mapped using \ref svcMapSharedMemory. - MemType_WeirdMappedMem = 0x00000007, ## /< Mapped using \ref svcMapMemory. - MemType_ModuleCodeStatic = 0x00000008, ## /< Mapped using \ref svcMapProcessCodeMemory. - MemType_ModuleCodeMutable = 0x00000009, ## /< Transition from \ref MemType_ModuleCodeStatic performed by \ref svcSetProcessMemoryPermission. - MemType_IpcBuffer0 = 0x0000000A, ## /< IPC buffers with descriptor flags=0. - MemType_MappedMemory = 0x0000000B, ## /< Mapped using \ref svcMapMemory. - MemType_ThreadLocal = 0x0000000C, ## /< Mapped during \ref svcCreateThread. - MemType_TransferMemIsolated = 0x0000000D, ## /< Mapped using \ref svcMapTransferMemory when the owning process has perm=0. - MemType_TransferMem = 0x0000000E, ## /< Mapped using \ref svcMapTransferMemory when the owning process has perm!=0. - MemType_ProcessMem = 0x0000000F, ## /< Mapped using \ref svcMapProcessMemory. - MemType_Reserved = 0x00000010, ## /< Reserved. - MemType_IpcBuffer1 = 0x00000011, ## /< IPC buffers with descriptor flags=1. - MemType_IpcBuffer3 = 0x00000012, ## /< IPC buffers with descriptor flags=3. - MemType_KernelStack = 0x00000013, ## /< Mapped in kernel during \ref svcCreateThread. - MemType_CodeReadOnly = 0x00000014, ## /< Mapped in kernel during \ref svcControlCodeMemory. - MemType_CodeWritable = 0x00000015 ## /< Mapped in kernel during \ref svcControlCodeMemory. - - -## / Memory state bitmasks. - -type - MemoryState* {.size: sizeof(cint).} = enum - MemState_Type = 0x000000FF, ## /< Type field (see \ref MemoryType). - MemState_PermChangeAllowed = BIT(8), ## /< Permission change allowed. - MemState_ForceRwByDebugSyscalls = BIT(9), ## /< Force read/writable by debug syscalls. - MemState_IpcSendAllowed_Type0 = BIT(10), ## /< IPC type 0 send allowed. - MemState_IpcSendAllowed_Type3 = BIT(11), ## /< IPC type 3 send allowed. - MemState_IpcSendAllowed_Type1 = BIT(12), ## /< IPC type 1 send allowed. - MemState_ProcessPermChangeAllowed = BIT(14), ## /< Process permission change allowed. - MemState_MapAllowed = BIT(15), ## /< Map allowed. - MemState_UnmapProcessCodeMemAllowed = BIT(16), ## /< Unmap process code memory allowed. - MemState_TransferMemAllowed = BIT(17), ## /< Transfer memory allowed. - MemState_QueryPAddrAllowed = BIT(18), ## /< Query physical address allowed. - MemState_MapDeviceAllowed = BIT(19), ## /< Map device allowed (\ref svcMapDeviceAddressSpace and \ref svcMapDeviceAddressSpaceByForce). - MemState_MapDeviceAlignedAllowed = BIT(20), ## /< Map device aligned allowed. - MemState_IpcBufferAllowed = BIT(21), ## /< IPC buffer allowed. - MemState_IsPoolAllocated = BIT(22), ## /< Is pool allocated. - MemState_MapProcessAllowed = BIT(23), ## /< Map process allowed. - MemState_AttrChangeAllowed = BIT(24), ## /< Attribute change allowed. - MemState_CodeMemAllowed = BIT(25) ## /< Code memory allowed. - -const - MemState_IsRefCounted = MemState_IsPoolAllocated - -## / Memory attribute bitmasks. - -type - MemoryAttribute* {.size: sizeof(cint).} = enum - MemAttr_IsBorrowed = BIT(0), ## /< Is borrowed memory. - MemAttr_IsIpcMapped = BIT(1), ## /< Is IPC mapped (when IpcRefCount > 0). - MemAttr_IsDeviceMapped = BIT(2), ## /< Is device mapped (when DeviceRefCount > 0). - MemAttr_IsUncached = BIT(3) ## /< Is uncached. - - -## / Memory permission bitmasks. - -type - Permission* {.size: sizeof(cint).} = enum - Perm_None = 0, ## /< No permissions. - Perm_R = BIT(0), ## /< Read permission. - Perm_W = BIT(1), ## /< Write permission. - Perm_Rw = Perm_R.int or Perm_W.int, ## /< Read/write permissions. - Perm_X = BIT(2), ## /< Execute permission. - Perm_Rx = Perm_R.int or Perm_X.int, ## /< Read/execute permissions. - Perm_DontCare = BIT(28) ## /< Don't care - - -## / Memory information structure. - -type - MemoryInfo* {.importc: "MemoryInfo", header: headersvc, bycopy.} = object - `addr`* {.importc: "addr".}: uint64 ## /< Base address. - size* {.importc: "size".}: uint64 ## /< Size. - `type`* {.importc: "type".}: uint32 ## /< Memory type (see lower 8 bits of \ref MemoryState). - attr* {.importc: "attr".}: uint32 ## /< Memory attributes (see \ref MemoryAttribute). - perm* {.importc: "perm".}: uint32 ## /< Memory permissions (see \ref Permission). - device_refcount* {.importc: "device_refcount".}: uint32 ## /< Device reference count. - ipc_refcount* {.importc: "ipc_refcount".}: uint32 ## /< IPC reference count. - padding* {.importc: "padding".}: uint32 ## /< Padding. - - -## / Secure monitor arguments. - -type - SecmonArgs* {.importc: "SecmonArgs", header: headersvc, bycopy.} = object - X* {.importc: "X".}: array[8, uint64] ## /< Values of X0 through X7. - - -## / Code memory mapping operations - -type - CodeMapOperation* {.size: sizeof(cint).} = enum - CodeMapOperation_MapOwner = 0, ## /< Map owner. - CodeMapOperation_MapSlave = 1, ## /< Map slave. - CodeMapOperation_UnmapOwner = 2, ## /< Unmap owner. - CodeMapOperation_UnmapSlave = 3 ## /< Unmap slave. - - -## / Limitable Resources. - -type - LimitableResource* {.size: sizeof(cint).} = enum - LimitableResource_Memory = 0, ## /switchbrew.org Wiki for more details. -## @note Syscall number 0x02. -## - -proc svcSetMemoryAttribute*(`addr`: pointer; size: uint64; val0: uint32; val1: uint32): Result {. - cdecl, importc: "svcSetMemoryAttribute", header: headersvc.} -## * -## @brief Maps a memory range into a different range. Mainly used for adding guard pages around stack. -## Source range gets reprotected to Perm_None (it can no longer be accessed), and \ref MemAttr_IsBorrowed is set in the source \ref MemoryAttribute. -## @param[in] dst_addr Destination address. -## @param[in] src_addr Source address. -## @param[in] size Size of the range. -## @return Result code. -## @note Syscall number 0x04. -## - -proc svcMapMemory*(dst_addr: pointer; src_addr: pointer; size: uint64): Result {.cdecl, - importc: "svcMapMemory", header: headersvc.} -## * -## @brief Unmaps a region that was previously mapped with \ref svcMapMemory. -## @param[in] dst_addr Destination address. -## @param[in] src_addr Source address. -## @param[in] size Size of the range. -## @return Result code. -## @note Syscall number 0x05. -## - -proc svcUnmapMemory*(dst_addr: pointer; src_addr: pointer; size: uint64): Result {.cdecl, - importc: "svcUnmapMemory", header: headersvc.} -## * -## @brief Query information about an address. Will always fetch the lowest page-aligned mapping that contains the provided address. -## @param[out] meminfo_ptr \ref MemoryInfo structure which will be filled in. -## @param[out] page_info Page information which will be filled in. -## @param[in] addr Address to query. -## @return Result code. -## @note Syscall number 0x06. -## - -proc svcQueryMemory*(meminfo_ptr: ptr MemoryInfo; pageinfo: ptr uint32; `addr`: uint64): Result {. - cdecl, importc: "svcQueryMemory", header: headersvc.} -## /@} -## /@name Process and thread management -## /@{ -## * -## @brief Exits the current process. -## @note Syscall number 0x07. -## - -proc svcExitProcess*() {.cdecl, importc: "svcExitProcess", header: headersvc.} -## * -## @brief Creates a thread. -## @return Result code. -## @note Syscall number 0x08. -## - -proc svcCreateThread*(`out`: ptr Handle; entry: pointer; arg: pointer; - stack_top: pointer; prio: cint; cpuid: cint): Result {.cdecl, - importc: "svcCreateThread", header: headersvc.} -## * -## @brief Starts a freshly created thread. -## @return Result code. -## @note Syscall number 0x09. -## - -proc svcStartThread*(handle: Handle): Result {.cdecl, importc: "svcStartThread", - header: headersvc.} -## * -## @brief Exits the current thread. -## @note Syscall number 0x0A. -## - -proc svcExitThread*() {.cdecl, importc: "svcExitThread", header: headersvc.} -## * -## @brief Sleeps the current thread for the specified amount of time. -## @return Result code. -## @note Syscall number 0x0B. -## - -proc svcSleepThread*(nano: uint64): Result {.cdecl, importc: "svcSleepThread", - header: headersvc.} -## * -## @brief Gets a thread's priority. -## @return Result code. -## @note Syscall number 0x0C. -## - -proc svcGetThreadPriority*(priority: ptr uint32; handle: Handle): Result {.cdecl, - importc: "svcGetThreadPriority", header: headersvc.} -## * -## @brief Sets a thread's priority. -## @return Result code. -## @note Syscall number 0x0D. -## - -proc svcSetThreadPriority*(handle: Handle; priority: uint32): Result {.cdecl, - importc: "svcSetThreadPriority", header: headersvc.} -## * -## @brief Gets the current processor's number. -## @return The current processor's number. -## @note Syscall number 0x10. -## - -proc svcGetCurrentProcessorNumber*(): uint32 {.cdecl, - importc: "svcGetCurrentProcessorNumber", header: headersvc.} -## /@} -## /@name Synchronization -## /@{ -## * -## @brief Sets an event's signalled status. -## @return Result code. -## @note Syscall number 0x11. -## - -proc svcSignalEvent*(handle: Handle): Result {.cdecl, importc: "svcSignalEvent", - header: headersvc.} -## * -## @brief Clears an event's signalled status. -## @return Result code. -## @note Syscall number 0x12. -## - -proc svcClearEvent*(handle: Handle): Result {.cdecl, importc: "svcClearEvent", - header: headersvc.} -## /@} -## /@name Inter-process memory sharing -## /@{ -## * -## @brief Maps a block of shared memory. -## @return Result code. -## @note Syscall number 0x13. -## - -proc svcMapSharedMemory*(handle: Handle; `addr`: pointer; size: csize; perm: uint32): Result {. - cdecl, importc: "svcMapSharedMemory", header: headersvc.} -## * -## @brief Unmaps a block of shared memory. -## @return Result code. -## @note Syscall number 0x14. -## - -proc svcUnmapSharedMemory*(handle: Handle; `addr`: pointer; size: csize): Result {. - cdecl, importc: "svcUnmapSharedMemory", header: headersvc.} -## * -## @brief Creates a block of transfer memory. -## @return Result code. -## @note Syscall number 0x15. -## - -proc svcCreateTransferMemory*(`out`: ptr Handle; `addr`: pointer; size: csize; perm: uint32): Result {. - cdecl, importc: "svcCreateTransferMemory", header: headersvc.} -## /@} -## /@name Miscellaneous -## /@{ -## * -## @brief Closes a handle, decrementing the reference count of the corresponding kernel object. -## This might result in the kernel freeing the object. -## @param handle Handle to close. -## @return Result code. -## @note Syscall number 0x16. -## - -proc svcCloseHandle*(handle: Handle): Result {.cdecl, importc: "svcCloseHandle", - header: headersvc.} -## /@} -## /@name Synchronization -## /@{ -## * -## @brief Resets a signal. -## @return Result code. -## @note Syscall number 0x17. -## - -proc svcResetSignal*(handle: Handle): Result {.cdecl, importc: "svcResetSignal", - header: headersvc.} -## /@} -## /@name Synchronization -## /@{ -## * -## @brief Waits on one or more synchronization objects, optionally with a timeout. -## @return Result code. -## @note Syscall number 0x18. -## - -proc svcWaitSynchronization*(index: ptr s32; handles: ptr Handle; handleCount: s32; - timeout: uint64): Result {.cdecl, - importc: "svcWaitSynchronization", header: headersvc.} -## * -## @brief Waits on a single synchronization object, optionally with a timeout. -## @return Result code. -## @note Wrapper for \ref svcWaitSynchronization. -## - -proc svcWaitSynchronizationSingle*(handle: Handle; timeout: uint64): Result {.inline, - cdecl, importc: "svcWaitSynchronizationSingle", header: headersvc.} -## * -## @brief Waits a \ref svcWaitSynchronization operation being done on a synchronization object in another thread. -## @return Result code. -## @note Syscall number 0x19. -## - -proc svcCancelSynchronization*(thread: Handle): Result {.cdecl, - importc: "svcCancelSynchronization", header: headersvc.} -## * -## @brief Arbitrates a mutex lock operation in userspace. -## @return Result code. -## @note Syscall number 0x1A. -## - -proc svcArbitrateLock*(wait_tag: uint32; tag_location: ptr uint32; self_tag: uint32): Result {. - cdecl, importc: "svcArbitrateLock", header: headersvc.} -## * -## @brief Arbitrates a mutex unlock operation in userspace. -## @return Result code. -## @note Syscall number 0x1B. -## - -proc svcArbitrateUnlock*(tag_location: ptr uint32): Result {.cdecl, - importc: "svcArbitrateUnlock", header: headersvc.} -## * -## @brief Performs a condition variable wait operation in userspace. -## @return Result code. -## @note Syscall number 0x1C. -## - -proc svcWaitProcessWideKeyAtomic*(key: ptr uint32; tag_location: ptr uint32; self_tag: uint32; - timeout: uint64): Result {.cdecl, - importc: "svcWaitProcessWideKeyAtomic", header: headersvc.} -## * -## @brief Performs a condition variable wake-up operation in userspace. -## @return Result code. -## @note Syscall number 0x1D. -## - -proc svcSignalProcessWideKey*(key: ptr uint32; num: s32): Result {.cdecl, - importc: "svcSignalProcessWideKey", header: headersvc.} -## /@} -## /@name Miscellaneous -## /@{ -## * -## @brief Gets the current system tick. -## @return The current system tick. -## @note Syscall number 0x1E. -## - -proc svcGetSystemTick*(): uint64 {.cdecl, importc: "svcGetSystemTick", - header: headersvc.} -## /@} -## /@name Inter-process communication (IPC) -## /@{ -## * -## @brief Connects to a registered named port. -## @return Result code. -## @note Syscall number 0x1F. -## - -proc svcConnectToNamedPort*(session: ptr Handle; name: cstring): Result {.cdecl, - importc: "svcConnectToNamedPort", header: headersvc.} -## * -## @brief Sends an IPC synchronization request to a session. -## @return Result code. -## @note Syscall number 0x21. -## - -proc svcSendSyncRequest*(session: Handle): Result {.cdecl, - importc: "svcSendSyncRequest", header: headersvc.} -## * -## @brief Sends an IPC synchronization request to a session from an user allocated buffer. -## @return Result code. -## @remark size must be allocated to 0x1000 bytes. -## @note Syscall number 0x22. -## - -proc svcSendSyncRequestWithUserBuffer*(usrBuffer: pointer; size: uint64; session: Handle): Result {. - cdecl, importc: "svcSendSyncRequestWithUserBuffer", header: headersvc.} -## * -## @brief Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version). -## @return Result code. -## @remark size must be allocated to 0x1000 bytes. -## @note Syscall number 0x23. -## - -proc svcSendAsyncRequestWithUserBuffer*(handle: ptr Handle; usrBuffer: pointer; - size: uint64; session: Handle): Result {.cdecl, - importc: "svcSendAsyncRequestWithUserBuffer", header: headersvc.} -## /@} -## /@name Process and thread management -## /@{ -## * -## @brief Gets the PID associated with a process. -## @return Result code. -## @note Syscall number 0x24. -## - -proc svcGetProcessId*(processID: ptr uint64; handle: Handle): Result {.cdecl, - importc: "svcGetProcessId", header: headersvc.} -## * -## @brief Gets the TID associated with a process. -## @return Result code. -## @note Syscall number 0x25. -## - -proc svcGetThreadId*(threadID: ptr uint64; handle: Handle): Result {.cdecl, - importc: "svcGetThreadId", header: headersvc.} -## /@} -## /@name Miscellaneous -## /@{ -## * -## @brief Breaks execution. Panic. -## @param[in] breakReason Break reason. -## @param[in] inval1 First break parameter. -## @param[in] inval2 Second break parameter. -## @return Result code. -## @note Syscall number 0x26. -## - -proc svcBreak*(breakReason: uint32; inval1: uint64; inval2: uint64): Result {.cdecl, - importc: "svcBreak", header: headersvc.} -## /@} -## /@name Debugging -## /@{ -## * -## @brief Outputs debug text, if used during debugging. -## @param[in] str Text to output. -## @param[in] size Size of the text in bytes. -## @return Result code. -## @note Syscall number 0x27. -## - -proc svcOutputDebugString*(str: cstring; size: uint64): Result {.cdecl, - importc: "svcOutputDebugString", header: headersvc.} -## /@} -## /@name Miscellaneous -## /@{ -## * -## @brief Retrieves information about the system, or a certain kernel object. -## @param[out] out Variable to which store the information. -## @param[in] id0 First ID of the property to retrieve. -## @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system. -## @param[in] id1 Second ID of the property to retrieve. -## @return Result code. -## @remark The full list of property IDs can be found on the switchbrew.org wiki. -## @note Syscall number 0x29. -## - -proc svcGetInfo*(`out`: ptr uint64; id0: uint64; handle: Handle; id1: uint64): Result {.cdecl, - importc: "svcGetInfo", header: headersvc.} -## /@} -## /@name Memory management -## /@{ -## * -## @brief Maps new heap memory at the desired address. [3.0.0+] -## @return Result code. -## @note Syscall number 0x2A. -## - -proc svcMapPhysicalMemory*(address: pointer; size: uint64): Result {.cdecl, - importc: "svcMapPhysicalMemory", header: headersvc.} -## * -## @brief Undoes the effects of \ref svcMapPhysicalMemory. [3.0.0+] -## @return Result code. -## @note Syscall number 0x2B. -## - -proc svcUnmapPhysicalMemory*(address: pointer; size: uint64): Result {.cdecl, - importc: "svcUnmapPhysicalMemory", header: headersvc.} -## /@} -## /@name Process and thread management -## /@{ -## * -## @brief Configures the pause/unpause status of a thread. -## @return Result code. -## @note Syscall number 0x32. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcSetThreadActivity*(thread: Handle; paused: bool): Result {.cdecl, - importc: "svcSetThreadActivity", header: headersvc.} -## /@} -## /@name Resource Limit Management -## /@{ -## * -## @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle. -## @return Result code. -## @note Syscall number 0x30. -## - -proc svcGetResourceLimitLimitValue*(`out`: ptr uint64; reslimit_h: Handle; - which: LimitableResource): Result {.cdecl, - importc: "svcGetResourceLimitLimitValue", header: headersvc.} -## * -## @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle. -## @return Result code. -## @note Syscall number 0x31. -## - -proc svcGetResourceLimitCurrentValue*(`out`: ptr uint64; reslimit_h: Handle; - which: LimitableResource): Result {.cdecl, - importc: "svcGetResourceLimitCurrentValue", header: headersvc.} -## /@} -## /@name Inter-process communication (IPC) -## /@{ -## * -## @brief Creates an IPC session. -## @return Result code. -## @note Syscall number 0x40. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreateSession*(server_handle: ptr Handle; client_handle: ptr Handle; unk0: uint32; - unk1: uint64): Result {.cdecl, importc: "svcCreateSession", - header: headersvc.} -## unk* are normally 0? -## * -## @brief Accepts an IPC session. -## @return Result code. -## @note Syscall number 0x41. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcAcceptSession*(session_handle: ptr Handle; port_handle: Handle): Result {. - cdecl, importc: "svcAcceptSession", header: headersvc.} -## * -## @brief Performs IPC input/output. -## @return Result code. -## @note Syscall number 0x43. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcReplyAndReceive*(index: ptr s32; handles: ptr Handle; handleCount: s32; - replyTarget: Handle; timeout: uint64): Result {.cdecl, - importc: "svcReplyAndReceive", header: headersvc.} -## * -## @brief Performs IPC input/output from an user allocated buffer. -## @return Result code. -## @note Syscall number 0x44. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcReplyAndReceiveWithUserBuffer*(index: ptr s32; usrBuffer: pointer; size: uint64; - handles: ptr Handle; handleCount: s32; - replyTarget: Handle; timeout: uint64): Result {. - cdecl, importc: "svcReplyAndReceiveWithUserBuffer", header: headersvc.} -## /@} -## /@name Synchronization -## /@{ -## * -## @brief Creates a system event. -## @return Result code. -## @note Syscall number 0x45. -## - -proc svcCreateEvent*(server_handle: ptr Handle; client_handle: ptr Handle): Result {. - cdecl, importc: "svcCreateEvent", header: headersvc.} -## /@} -## /@name Memory management -## /@{ -## * -## @brief Maps unsafe memory (usable for GPU DMA) for a system module at the desired address. [5.0.0+] -## @return Result code. -## @note Syscall number 0x48. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcMapPhysicalMemoryUnsafe*(address: pointer; size: uint64): Result {.cdecl, - importc: "svcMapPhysicalMemoryUnsafe", header: headersvc.} -## * -## @brief Undoes the effects of \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] -## @return Result code. -## @note Syscall number 0x49. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcUnmapPhysicalMemoryUnsafe*(address: pointer; size: uint64): Result {.cdecl, - importc: "svcUnmapPhysicalMemoryUnsafe", header: headersvc.} -## * -## @brief Sets the system-wide limit for unsafe memory mappable using \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] -## @return Result code. -## @note Syscall number 0x4A. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcSetUnsafeLimit*(size: uint64): Result {.cdecl, importc: "svcSetUnsafeLimit", - header: headersvc.} -## /@} -## /@name Code memory / Just-in-time (JIT) compilation support -## /@{ -## * -## @brief Creates code memory in the caller's address space [4.0.0+]. -## @return Result code. -## @note Syscall number 0x4B. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreateCodeMemory*(code_handle: ptr Handle; src_addr: pointer; size: uint64): Result {. - cdecl, importc: "svcCreateCodeMemory", header: headersvc.} -## * -## @brief Maps code memory in the caller's address space [4.0.0+]. -## @return Result code. -## @note Syscall number 0x4C. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcControlCodeMemory*(code_handle: Handle; op: CodeMapOperation; - dst_addr: pointer; size: uint64; perm: uint64): Result {.cdecl, - importc: "svcControlCodeMemory", header: headersvc.} -## /@} -## /@name Device memory-mapped I/O (MMIO) -## /@{ -## * -## @brief Reads/writes a protected MMIO register. -## @return Result code. -## @note Syscall number 0x4E. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcReadWriteRegister*(outVal: ptr uint32; regAddr: uint64; rwMask: uint32; inVal: uint32): Result {. - cdecl, importc: "svcReadWriteRegister", header: headersvc.} -## /@} -## /@name Inter-process memory sharing -## /@{ -## * -## @brief Creates a block of shared memory. -## @return Result code. -## @note Syscall number 0x50. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreateSharedMemory*(`out`: ptr Handle; size: csize; local_perm: uint32; - other_perm: uint32): Result {.cdecl, - importc: "svcCreateSharedMemory", header: headersvc.} -## * -## @brief Maps a block of transfer memory. -## @return Result code. -## @note Syscall number 0x51. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcMapTransferMemory*(tmem_handle: Handle; `addr`: pointer; size: csize; perm: uint32): Result {. - cdecl, importc: "svcMapTransferMemory", header: headersvc.} -## * -## @brief Unmaps a block of transfer memory. -## @return Result code. -## @note Syscall number 0x52. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcUnmapTransferMemory*(tmem_handle: Handle; `addr`: pointer; size: csize): Result {. - cdecl, importc: "svcUnmapTransferMemory", header: headersvc.} -## /@} -## /@name Device memory-mapped I/O (MMIO) -## /@{ -## * -## @brief Creates an event and binds it to a specific hardware interrupt. -## @return Result code. -## @note Syscall number 0x53. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreateInterruptEvent*(handle: ptr Handle; irqNum: uint64; flag: uint32): Result {. - cdecl, importc: "svcCreateInterruptEvent", header: headersvc.} -## * -## @brief Queries information about a certain virtual address, including its physical address. -## @return Result code. -## @note Syscall number 0x54. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcQueryPhysicalAddress*(`out`: array[3, uint64]; virtaddr: uint64): Result {.cdecl, - importc: "svcQueryPhysicalAddress", header: headersvc.} -## * -## @brief Returns a virtual address mapped to a given IO range. -## @return Result code. -## @note Syscall number 0x55. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcQueryIoMapping*(virtaddr: ptr uint64; physaddr: uint64; size: uint64): Result {.cdecl, - importc: "svcQueryIoMapping", header: headersvc.} -## /@} -## /@name I/O memory management unit (IOMMU) -## /@{ -## * -## @brief Creates a virtual address space for binding device address spaces. -## @return Result code. -## @note Syscall number 0x56. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreateDeviceAddressSpace*(handle: ptr Handle; dev_addr: uint64; dev_size: uint64): Result {. - cdecl, importc: "svcCreateDeviceAddressSpace", header: headersvc.} -## * -## @brief Attaches a device address space to a device. -## @return Result code. -## @note Syscall number 0x57. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcAttachDeviceAddressSpace*(device: uint64; handle: Handle): Result {.cdecl, - importc: "svcAttachDeviceAddressSpace", header: headersvc.} -## * -## @brief Detaches a device address space from a device. -## @return Result code. -## @note Syscall number 0x58. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcDetachDeviceAddressSpace*(device: uint64; handle: Handle): Result {.cdecl, - importc: "svcDetachDeviceAddressSpace", header: headersvc.} -## * -## @brief Maps an attached device address space to an userspace address. -## @return Result code. -## @remark The userspace destination address must have the \ref MemState_MapDeviceAllowed bit set. -## @note Syscall number 0x59. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcMapDeviceAddressSpaceByForce*(handle: Handle; proc_handle: Handle; - map_addr: uint64; dev_size: uint64; dev_addr: uint64; - perm: uint32): Result {.cdecl, - importc: "svcMapDeviceAddressSpaceByForce", header: headersvc.} -## * -## @brief Maps an attached device address space to an userspace address. -## @return Result code. -## @remark The userspace destination address must have the \ref MemState_MapDeviceAlignedAllowed bit set. -## @note Syscall number 0x5A. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcMapDeviceAddressSpaceAligned*(handle: Handle; proc_handle: Handle; - map_addr: uint64; dev_size: uint64; dev_addr: uint64; - perm: uint32): Result {.cdecl, - importc: "svcMapDeviceAddressSpaceAligned", header: headersvc.} -## * -## @brief Unmaps an attached device address space from an userspace address. -## @return Result code. -## @note Syscall number 0x5C. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcUnmapDeviceAddressSpace*(handle: Handle; proc_handle: Handle; map_addr: uint64; - map_size: uint64; dev_addr: uint64): Result {.cdecl, - importc: "svcUnmapDeviceAddressSpace", header: headersvc.} -## /@} -## /@name Debugging -## /@{ -## * -## @brief Debugs an active process. -## @return Result code. -## @note Syscall number 0x60. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcDebugActiveProcess*(debug: ptr Handle; processID: uint64): Result {.cdecl, - importc: "svcDebugActiveProcess", header: headersvc.} -## * -## @brief Breaks an active debugging session. -## @return Result code. -## @note Syscall number 0x61. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcBreakDebugProcess*(debug: Handle): Result {.cdecl, - importc: "svcBreakDebugProcess", header: headersvc.} -## * -## @brief Gets an incoming debug event from a debugging session. -## @return Result code. -## @note Syscall number 0x63. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcGetDebugEvent*(event_out: ptr uint8; debug: Handle): Result {.cdecl, - importc: "svcGetDebugEvent", header: headersvc.} -## * -## @brief Continues a debugging session. -## @return Result code. -## @note Syscall number 0x64. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcContinueDebugEvent*(debug: Handle; flags: uint32; threadID: uint64): Result {.cdecl, - importc: "svcContinueDebugEvent", header: headersvc.} -## * -## @brief Gets the context of a thread in a debugging session. -## @return Result code. -## @note Syscall number 0x67. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcGetDebugThreadContext*(`out`: ptr uint8; debug: Handle; threadID: uint64; flags: uint32): Result {. - cdecl, importc: "svcGetDebugThreadContext", header: headersvc.} -## /@} -## /@name Process and thread management -## /@{ -## * -## @brief Retrieves a list of all running processes. -## @return Result code. -## @note Syscall number 0x65. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcGetProcessList*(num_out: ptr uint32; pids_out: ptr uint64; max_pids: uint32): Result {. - cdecl, importc: "svcGetProcessList", header: headersvc.} -## * -## @brief Retrieves a list of all threads for a debug handle (or zero). -## @return Result code. -## @note Syscall number 0x66. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcGetThreadList*(num_out: ptr uint32; tids_out: ptr uint64; max_tids: uint32; debug: Handle): Result {. - cdecl, importc: "svcGetThreadList", header: headersvc.} -## /@} -## /@name Debugging -## /@{ -## * -## @brief Queries memory information from a process that is being debugged. -## @return Result code. -## @note Syscall number 0x69. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcQueryDebugProcessMemory*(meminfo_ptr: ptr MemoryInfo; pageinfo: ptr uint32; - debug: Handle; `addr`: uint64): Result {.cdecl, - importc: "svcQueryDebugProcessMemory", header: headersvc.} -## * -## @brief Reads memory from a process that is being debugged. -## @return Result code. -## @note Syscall number 0x6A. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcReadDebugProcessMemory*(buffer: pointer; debug: Handle; `addr`: uint64; size: uint64): Result {. - cdecl, importc: "svcReadDebugProcessMemory", header: headersvc.} -## * -## @brief Writes to memory in a process that is being debugged. -## @return Result code. -## @note Syscall number 0x6B. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcWriteDebugProcessMemory*(debug: Handle; buffer: pointer; `addr`: uint64; size: uint64): Result {. - cdecl, importc: "svcWriteDebugProcessMemory", header: headersvc.} -## * -## @brief Gets parameters from a thread in a debugging session. -## @return Result code. -## @note Syscall number 0x6D. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcGetDebugThreadParam*(out_64: ptr uint64; out_32: ptr uint32; debug: Handle; - threadID: uint64; param: DebugThreadParam): Result {. - cdecl, importc: "svcGetDebugThreadParam", header: headersvc.} -## /@} -## /@name Miscellaneous -## /@{ -## * -## @brief Retrieves privileged information about the system, or a certain kernel object. -## @param[out] out Variable to which store the information. -## @param[in] id0 First ID of the property to retrieve. -## @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system. -## @param[in] id1 Second ID of the property to retrieve. -## @return Result code. -## @remark The full list of property IDs can be found on the switchbrew.org wiki. -## @note Syscall number 0x6F. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcGetSystemInfo*(`out`: ptr uint64; id0: uint64; handle: Handle; id1: uint64): Result {. - cdecl, importc: "svcGetSystemInfo", header: headersvc.} -## /@} -## /@name Inter-process communication (IPC) -## /@{ -## * -## @brief Creates a port. -## @return Result code. -## @note Syscall number 0x70. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreatePort*(portServer: ptr Handle; portClient: ptr Handle; max_sessions: s32; - is_light: bool; name: cstring): Result {.cdecl, - importc: "svcCreatePort", header: headersvc.} -## * -## @brief Manages a named port. -## @return Result code. -## @note Syscall number 0x71. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcManageNamedPort*(portServer: ptr Handle; name: cstring; maxSessions: s32): Result {. - cdecl, importc: "svcManageNamedPort", header: headersvc.} -## * -## @brief Manages a named port. -## @return Result code. -## @note Syscall number 0x72. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcConnectToPort*(session: ptr Handle; port: Handle): Result {.cdecl, - importc: "svcConnectToPort", header: headersvc.} -## /@} -## /@name Memory management -## /@{ -## * -## @brief Sets the memory permissions for the specified memory with the supplied process handle. -## @param[in] proc Process handle. -## @param[in] addr Address of the memory. -## @param[in] size Size of the memory. -## @param[in] perm Permissions (see \ref Permission). -## @return Result code. -## @remark This returns an error (0xD801) when \p perm is >0x5, hence -WX and RWX are not allowed. -## @note Syscall number 0x73. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcSetProcessMemoryPermission*(`proc`: Handle; `addr`: uint64; size: uint64; perm: uint32): Result {. - cdecl, importc: "svcSetProcessMemoryPermission", header: headersvc.} -## * -## @brief Maps the src address from the supplied process handle into the current process. -## @param[in] dst Address to which map the memory in the current process. -## @param[in] proc Process handle. -## @param[in] src Source mapping address. -## @param[in] size Size of the memory. -## @return Result code. -## @remark This allows mapping code and rodata with RW- permission. -## @note Syscall number 0x74. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcMapProcessMemory*(dst: pointer; `proc`: Handle; src: uint64; size: uint64): Result {. - cdecl, importc: "svcMapProcessMemory", header: headersvc.} -## * -## @brief Undoes the effects of \ref svcMapProcessMemory. -## @param[in] dst Destination mapping address -## @param[in] proc Process handle. -## @param[in] src Address of the memory in the process. -## @param[in] size Size of the memory. -## @return Result code. -## @remark This allows mapping code and rodata with RW- permission. -## @note Syscall number 0x75. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcUnmapProcessMemory*(dst: pointer; `proc`: Handle; src: uint64; size: uint64): Result {. - cdecl, importc: "svcUnmapProcessMemory", header: headersvc.} -## * -## @brief Maps normal heap in a certain process as executable code (used when loading NROs). -## @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE). -## @param[in] dst Destination mapping address. -## @param[in] src Source mapping address. -## @param[in] size Size of the mapping. -## @return Result code. -## @note Syscall number 0x77. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcMapProcessCodeMemory*(`proc`: Handle; dst: uint64; src: uint64; size: uint64): Result {. - cdecl, importc: "svcMapProcessCodeMemory", header: headersvc.} -## * -## @brief Undoes the effects of \ref svcMapProcessCodeMemory. -## @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE). -## @param[in] dst Destination mapping address. -## @param[in] src Source mapping address. -## @param[in] size Size of the mapping. -## @return Result code. -## @note Syscall number 0x78. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcUnmapProcessCodeMemory*(`proc`: Handle; dst: uint64; src: uint64; size: uint64): Result {. - cdecl, importc: "svcUnmapProcessCodeMemory", header: headersvc.} -## /@} -## /@name Process and thread management -## /@{ -## * -## @brief Creates a new process. -## @return Result code. -## @note Syscall number 0x79. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreateProcess*(`out`: ptr Handle; proc_info: pointer; caps: ptr uint32; cap_num: uint64): Result {. - cdecl, importc: "svcCreateProcess", header: headersvc.} -## * -## @brief Starts executing a freshly created process. -## @return Result code. -## @note Syscall number 0x7A. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcStartProcess*(`proc`: Handle; main_prio: s32; default_cpu: s32; stack_size: uint32): Result {. - cdecl, importc: "svcStartProcess", header: headersvc.} -## * -## @brief Terminates a running process. -## @return Result code. -## @note Syscall number 0x7B. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcTerminateProcess*(`proc`: Handle): Result {.cdecl, - importc: "svcTerminateProcess", header: headersvc.} -## * -## @brief Gets a \ref ProcessInfoType for a process. -## @return Result code. -## @note Syscall number 0x7C. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcGetProcessInfo*(`out`: ptr uint64; `proc`: Handle; which: ProcessInfoType): Result {. - cdecl, importc: "svcGetProcessInfo", header: headersvc.} -## /@} -## /@name Resource Limit Management -## /@{ -## * -## @brief Creates a new Resource Limit handle. -## @return Result code. -## @note Syscall number 0x7D. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCreateResourceLimit*(`out`: ptr Handle): Result {.cdecl, - importc: "svcCreateResourceLimit", header: headersvc.} -## * -## @brief Sets the value for a \ref LimitableResource for a Resource Limit handle. -## @return Result code. -## @note Syscall number 0x7E. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcSetResourceLimitLimitValue*(reslimit: Handle; which: LimitableResource; - value: uint64): Result {.cdecl, - importc: "svcSetResourceLimitLimitValue", header: headersvc.} -## /@} -## /@name ( ͡° ͜ʖ ͡°) -## /@{ -## * -## @brief Calls a secure monitor function (TrustZone, EL3). -## @param regs Arguments to pass to the secure monitor. -## @return Return value from the secure monitor. -## @note Syscall number 0x7F. -## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. -## - -proc svcCallSecureMonitor*(regs: ptr SecmonArgs): uint64 {.cdecl, - importc: "svcCallSecureMonitor", header: headersvc.} -## /@} diff --git a/src/libnx/wrapper/switch.nim b/src/libnx/wrapper/switch.nim deleted file mode 100644 index 3af3e44..0000000 --- a/src/libnx/wrapper/switch.nim +++ /dev/null @@ -1,62 +0,0 @@ -import strutils -import ospaths -const headerswitch = currentSourcePath().splitPath().head & "/nx/include/switch.h" -import libnx/wrapper/types -import libnx/wrapper/result -import libnx/wrapper/nro -import libnx/wrapper/nacp -import libnx/wrapper/tls -import libnx/wrapper/cache -import libnx/wrapper/svc -import libnx/wrapper/tmem -import libnx/wrapper/shmem -import libnx/wrapper/mutex -import libnx/wrapper/rwlock -import libnx/wrapper/condvar -import libnx/wrapper/thread -import libnx/wrapper/virtmem -import libnx/wrapper/detect -import libnx/wrapper/random -import libnx/wrapper/jit -import libnx/wrapper/ipc -import libnx/wrapper/sm -import libnx/wrapper/smm -import libnx/wrapper/fs -import libnx/wrapper/fsldr -import libnx/wrapper/fspr -import libnx/wrapper/acc -import libnx/wrapper/apm -import libnx/wrapper/applet -import libnx/wrapper/audin -import libnx/wrapper/audout -import libnx/wrapper/csrng -import libnx/wrapper/fatal -import libnx/wrapper/time -import libnx/wrapper/usb -import libnx/wrapper/hid -import libnx/wrapper/irs -import libnx/wrapper/pl -import libnx/wrapper/vi -import libnx/wrapper/nv -import libnx/wrapper/nifm -import libnx/wrapper/ns -import libnx/wrapper/ldr -import libnx/wrapper/pm -import libnx/wrapper/set -import libnx/wrapper/lr -import libnx/wrapper/spl -import libnx/wrapper/gfx -import libnx/wrapper/binder -import libnx/wrapper/parcel -import libnx/wrapper/buffer_producer -import libnx/wrapper/ioctl -import libnx/wrapper/nvioctl -import libnx/wrapper/nvgfx -import libnx/wrapper/env -import libnx/wrapper/nxlink -import libnx/wrapper/utf -import libnx/wrapper/console -import libnx/wrapper/usb_comms -import libnx/wrapper/fs_dev -import libnx/wrapper/romfs_dev -import libnx/wrapper/socket diff --git a/src/libnx/wrapper/thread.nim b/src/libnx/wrapper/thread.nim deleted file mode 100644 index 7450ad7..0000000 --- a/src/libnx/wrapper/thread.nim +++ /dev/null @@ -1,25 +0,0 @@ -import strutils -import ospaths -const headerthread = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/thread.h" -import libnx/wrapper/types -type - Thread* {.importc: "Thread", header: headerthread, bycopy.} = object - handle* {.importc: "handle".}: Handle - stack_mem* {.importc: "stack_mem".}: pointer - stack_mirror* {.importc: "stack_mirror".}: pointer - stack_sz* {.importc: "stack_sz".}: csize - - -proc threadCreate*(t: ptr Thread; entry: ThreadFunc; arg: pointer; stack_sz: csize; - prio: cint; cpuid: cint): Result {.cdecl, importc: "threadCreate", - header: headerthread.} -proc threadStart*(t: ptr Thread): Result {.cdecl, importc: "threadStart", - header: headerthread.} -proc threadWaitForExit*(t: ptr Thread): Result {.cdecl, - importc: "threadWaitForExit", header: headerthread.} -proc threadClose*(t: ptr Thread): Result {.cdecl, importc: "threadClose", - header: headerthread.} -proc threadPause*(t: ptr Thread): Result {.cdecl, importc: "threadPause", - header: headerthread.} -proc threadResume*(t: ptr Thread): Result {.cdecl, importc: "threadResume", - header: headerthread.} \ No newline at end of file diff --git a/src/libnx/wrapper/time.nim b/src/libnx/wrapper/time.nim deleted file mode 100644 index 5e6cecd..0000000 --- a/src/libnx/wrapper/time.nim +++ /dev/null @@ -1,22 +0,0 @@ -import strutils -import ospaths -const headertime = currentSourcePath().splitPath().head & "/nx/include/switch/services/time.h" -import libnx/wrapper/types -import libnx/wrapper/sm -type - TimeType* {.size: sizeof(cint).} = enum - TimeType_UserSystemClock, TimeType_NetworkSystemClock, - TimeType_LocalSystemClock - -const - TimeType_Default = TimeType_NetworkSystemClock - -proc timeInitialize*(): Result {.cdecl, importc: "timeInitialize", - header: headertime.} -proc timeExit*() {.cdecl, importc: "timeExit", header: headertime.} -proc timeGetSessionService*(): ptr Service {.cdecl, - importc: "timeGetSessionService", header: headertime.} -proc timeGetCurrentTime*(`type`: TimeType; timestamp: ptr uint64): Result {.cdecl, - importc: "timeGetCurrentTime", header: headertime.} -proc timeSetCurrentTime*(`type`: TimeType; timestamp: uint64): Result {.cdecl, - importc: "timeSetCurrentTime", header: headertime.} \ No newline at end of file diff --git a/src/libnx/wrapper/tls.nim b/src/libnx/wrapper/tls.nim deleted file mode 100644 index c0db58e..0000000 --- a/src/libnx/wrapper/tls.nim +++ /dev/null @@ -1,19 +0,0 @@ -import strutils -import ospaths -const headertls = currentSourcePath().splitPath().head & "/nx/include/switch/arm/tls.h" -## * -## @file tls.h -## @brief AArch64 thread local storage. -## @author plutoo -## @copyright libnx Authors -## - -import - libnx/wrapper/types - -## * -## @brief Gets the thread local storage buffer. -## @return The thread local storage buffer. -## - -proc armGetTls*(): pointer {.inline, cdecl, importc: "armGetTls", header: headertls.} \ No newline at end of file diff --git a/src/libnx/wrapper/tmem.nim b/src/libnx/wrapper/tmem.nim deleted file mode 100644 index e779136..0000000 --- a/src/libnx/wrapper/tmem.nim +++ /dev/null @@ -1,28 +0,0 @@ -import strutils -import ospaths -const headertmem = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/tmem.h" -import libnx/wrapper/types -import libnx/wrapper/svc -type - TransferMemory* {.importc: "TransferMemory", header: headertmem, bycopy.} = object - handle* {.importc: "handle".}: Handle - size* {.importc: "size".}: csize - perm* {.importc: "perm".}: Permission - src_addr* {.importc: "src_addr".}: pointer - map_addr* {.importc: "map_addr".}: pointer - - -proc tmemCreate*(t: ptr TransferMemory; size: csize; perm: Permission): Result {.cdecl, - importc: "tmemCreate", header: headertmem.} -proc tmemLoadRemote*(t: ptr TransferMemory; handle: Handle; size: csize; - perm: Permission) {.cdecl, importc: "tmemLoadRemote", - header: headertmem.} -proc tmemMap*(t: ptr TransferMemory): Result {.cdecl, importc: "tmemMap", - header: headertmem.} -proc tmemUnmap*(t: ptr TransferMemory): Result {.cdecl, importc: "tmemUnmap", - header: headertmem.} -proc tmemGetAddr*(t: ptr TransferMemory): pointer {.inline, cdecl.} = - return t.map_addr - -proc tmemClose*(t: ptr TransferMemory): Result {.cdecl, importc: "tmemClose", - header: headertmem.} \ No newline at end of file diff --git a/src/libnx/wrapper/types.nim b/src/libnx/wrapper/types.nim deleted file mode 100644 index 0aa4100..0000000 --- a/src/libnx/wrapper/types.nim +++ /dev/null @@ -1,39 +0,0 @@ -import strutils -import ospaths -const headertypes = currentSourcePath().splitPath().head & "/nx/include/switch/types.h" -import libnx/ext/integer128 -template BIT*(n): auto = (1.uint shl n) -type - u8* = uint8 - u16* = uint16 - u32* = uint32 - u64* = uint64 - int8_t* = int8 - int16_t* = int16 - int32_t* = int32 - int64_t* = int64 - ssize_t* = int - uint8_t* = uint8 - uint16_t* = uint16 - uint32_t* = uint32 - uint64_t* = uint64 - - s8* = int8_t - s16* = int16_t - s32* = int32_t - s64* = int64_t - - vuint8* = uint8 - vuint16* = uint16 - vuint32* = uint32 - vuint64* = uint64 - vu128* = u128 - vs8* = s8 - vs16* = s16 - vs32* = s32 - vs64* = s64 - vs128* = s128 - Handle* = uint32 - Result* = uint32 - ThreadFunc* = proc (a2: pointer) {.cdecl.} - VoidFn* = proc () {.cdecl.} diff --git a/src/libnx/wrapper/usb.nim b/src/libnx/wrapper/usb.nim deleted file mode 100644 index 81399df..0000000 --- a/src/libnx/wrapper/usb.nim +++ /dev/null @@ -1,166 +0,0 @@ -import strutils -import ospaths -const headerusb = currentSourcePath().splitPath().head & "/nx/include/switch/services/usb.h" -import libnx/wrapper/types -import libnx/wrapper/sm -const - USBDS_DEFAULT_InterfaceNumber* = 0x00000004 - USB_DT_INTERFACE_SIZE* = 9 - USB_DT_ENDPOINT_SIZE* = 7 - -type - usb_endpoint_descriptor* {.importc: "usb_endpoint_descriptor", header: headerusb, - bycopy.} = object - bLength* {.importc: "bLength".}: uint8_t - bDescriptorType* {.importc: "bDescriptorType".}: uint8_t - bEndpointAddress* {.importc: "bEndpointAddress".}: uint8_t - bmAttributes* {.importc: "bmAttributes".}: uint8_t - wMaxPacketSize* {.importc: "wMaxPacketSize".}: uint16_t - bInterval* {.importc: "bInterval".}: uint8_t - - usb_interface_descriptor* {.importc: "usb_interface_descriptor", - header: headerusb, bycopy.} = object - bLength* {.importc: "bLength".}: uint8_t - bDescriptorType* {.importc: "bDescriptorType".}: uint8_t - bInterfaceNumber* {.importc: "bInterfaceNumber".}: uint8_t - bAlternateSetting* {.importc: "bAlternateSetting".}: uint8_t - bNumEndpoints* {.importc: "bNumEndpoints".}: uint8_t - bInterfaceClass* {.importc: "bInterfaceClass".}: uint8_t - bInterfaceSubClass* {.importc: "bInterfaceSubClass".}: uint8_t - bInterfaceProtocol* {.importc: "bInterfaceProtocol".}: uint8_t - iInterface* {.importc: "iInterface".}: uint8_t - - UsbDsDeviceInfo* {.importc: "UsbDsDeviceInfo", header: headerusb, bycopy.} = object - idVendor* {.importc: "idVendor".}: uint16 - idProduct* {.importc: "idProduct".}: uint16 - bcdDevice* {.importc: "bcdDevice".}: uint16 - Manufacturer* {.importc: "Manufacturer".}: array[0x00000020, char] - Product* {.importc: "Product".}: array[0x00000020, char] - SerialNumber* {.importc: "SerialNumber".}: array[0x00000020, char] - - UsbDsReportEntry* {.importc: "UsbDsReportEntry", header: headerusb, bycopy.} = object - id* {.importc: "id".}: uint32 - requestedSize* {.importc: "requestedSize".}: uint32 - transferredSize* {.importc: "transferredSize".}: uint32 - urb_status* {.importc: "urb_status".}: uint32 - - UsbDsReportData* {.importc: "UsbDsReportData", header: headerusb, bycopy.} = object - report* {.importc: "report".}: array[8, UsbDsReportEntry] - report_count* {.importc: "report_count".}: uint32 - - UsbDsInterface* {.importc: "UsbDsInterface", header: headerusb, bycopy.} = object - initialized* {.importc: "initialized".}: bool - interface_index* {.importc: "interface_index".}: uint32 - h* {.importc: "h".}: Service - SetupEvent* {.importc: "SetupEvent".}: Handle - CtrlInCompletionEvent* {.importc: "CtrlInCompletionEvent".}: Handle - CtrlOutCompletionEvent* {.importc: "CtrlOutCompletionEvent".}: Handle - - UsbDsEndpoint* {.importc: "UsbDsEndpoint", header: headerusb, bycopy.} = object - initialized* {.importc: "initialized".}: bool - h* {.importc: "h".}: Service - CompletionEvent* {.importc: "CompletionEvent".}: Handle - - UsbComplexId* {.size: sizeof(cint).} = enum - UsbComplexId_Default = 0x00000002 - - -type - usb_class_code* {.size: sizeof(cint).} = enum - USB_CLASS_PER_INTERFACE = 0, USB_CLASS_AUDIO = 1, USB_CLASS_COMM = 2, - USB_CLASS_HID = 3, USB_CLASS_PHYSICAL = 5, USB_CLASS_PTP = 6, USB_CLASS_PRINTER = 7, - USB_CLASS_MASS_STORAGE = 8, USB_CLASS_HUB = 9, USB_CLASS_DATA = 10, - USB_CLASS_SMART_CARD = 0x0000000B, USB_CLASS_CONTENT_SECURITY = 0x0000000D, - USB_CLASS_VIDEO = 0x0000000E, USB_CLASS_PERSONAL_HEALTHCARE = 0x0000000F, - USB_CLASS_DIAGNOSTIC_DEVICE = 0x000000DC, USB_CLASS_WIRELESS = 0x000000E0, - USB_CLASS_APPLICATION = 0x000000FE, USB_CLASS_VENDOR_SPEC = 0x000000FF - -const - USB_CLASS_IMAGE = USB_CLASS_PTP - -type - usb_descriptor_type* {.size: sizeof(cint).} = enum - USB_DT_DEVICE = 0x00000001, USB_DT_CONFIG = 0x00000002, - USB_DT_STRING = 0x00000003, USB_DT_INTERFACE = 0x00000004, - USB_DT_ENDPOINT = 0x00000005, USB_DT_BOS = 0x0000000F, - USB_DT_DEVICE_CAPABILITY = 0x00000010, USB_DT_HID = 0x00000021, - USB_DT_REPORT = 0x00000022, USB_DT_PHYSICAL = 0x00000023, USB_DT_HUB = 0x00000029, - USB_DT_SUPERSPEED_HUB = 0x0000002A, USB_DT_SS_ENDPOINT_COMPANION = 0x00000030 - - -type - usb_endpoint_direction* {.size: sizeof(cint).} = enum - USB_ENDPOINT_OUT = 0x00000000, USB_ENDPOINT_IN = 0x00000080 - - -type - usb_transfer_type* {.size: sizeof(cint).} = enum - USB_TRANSFER_TYPE_CONTROL = 0, USB_TRANSFER_TYPE_ISOCHRONOUS = 1, - USB_TRANSFER_TYPE_BULK = 2, USB_TRANSFER_TYPE_INTERRUPT = 3, - USB_TRANSFER_TYPE_BULK_STREAM = 4 - - -type - usb_iso_sync_type* {.size: sizeof(cint).} = enum - USB_ISO_SYNC_TYPE_NONE = 0, USB_ISO_SYNC_TYPE_ASYNC = 1, - USB_ISO_SYNC_TYPE_ADAPTIVE = 2, USB_ISO_SYNC_TYPE_SYNC = 3 - - -type - usb_iso_usage_type* {.size: sizeof(cint).} = enum - USB_ISO_USAGE_TYPE_DATA = 0, USB_ISO_USAGE_TYPE_FEEDBACK = 1, - USB_ISO_USAGE_TYPE_IMPLICIT = 2 - - -proc usbDsInitialize*(complexId: UsbComplexId; deviceinfo: ptr UsbDsDeviceInfo): Result {. - cdecl, importc: "usbDsInitialize", header: headerusb.} -proc usbDsExit*() {.cdecl, importc: "usbDsExit", header: headerusb.} -proc usbDsGetServiceSession*(): ptr Service {.cdecl, - importc: "usbDsGetServiceSession", header: headerusb.} -proc usbDsGetStateChangeEvent*(): Handle {.cdecl, - importc: "usbDsGetStateChangeEvent", - header: headerusb.} -proc usbDsGetState*(`out`: ptr uint32): Result {.cdecl, importc: "usbDsGetState", - header: headerusb.} -proc usbDsGetDsInterface*(`interface`: ptr ptr UsbDsInterface; - descriptor: ptr usb_interface_descriptor; - interface_name: cstring): Result {.cdecl, - importc: "usbDsGetDsInterface", header: headerusb.} -proc usbDsWaitReady*(): Result {.cdecl, importc: "usbDsWaitReady", header: headerusb.} -proc usbDsParseReportData*(reportdata: ptr UsbDsReportData; urbId: uint32; - requestedSize: ptr uint32; transferredSize: ptr uint32): Result {. - cdecl, importc: "usbDsParseReportData", header: headerusb.} -proc usbDsInterface_Close*(`interface`: ptr UsbDsInterface) {.cdecl, - importc: "usbDsInterface_Close", header: headerusb.} -proc usbDsInterface_GetDsEndpoint*(`interface`: ptr UsbDsInterface; - endpoint: ptr ptr UsbDsEndpoint; - descriptor: ptr usb_endpoint_descriptor): Result {. - cdecl, importc: "usbDsInterface_GetDsEndpoint", header: headerusb.} -proc usbDsInterface_EnableInterface*(`interface`: ptr UsbDsInterface): Result {. - cdecl, importc: "usbDsInterface_EnableInterface", header: headerusb.} -proc usbDsInterface_DisableInterface*(`interface`: ptr UsbDsInterface): Result {. - cdecl, importc: "usbDsInterface_DisableInterface", header: headerusb.} -proc usbDsInterface_CtrlInPostBufferAsync*(`interface`: ptr UsbDsInterface; - buffer: pointer; size: csize; urbId: ptr uint32): Result {.cdecl, - importc: "usbDsInterface_CtrlInPostBufferAsync", header: headerusb.} -proc usbDsInterface_CtrlOutPostBufferAsync*(`interface`: ptr UsbDsInterface; - buffer: pointer; size: csize; urbId: ptr uint32): Result {.cdecl, - importc: "usbDsInterface_CtrlOutPostBufferAsync", header: headerusb.} -proc usbDsInterface_GetCtrlInReportData*(`interface`: ptr UsbDsInterface; - `out`: ptr UsbDsReportData): Result {. - cdecl, importc: "usbDsInterface_GetCtrlInReportData", header: headerusb.} -proc usbDsInterface_GetCtrlOutReportData*(`interface`: ptr UsbDsInterface; - `out`: ptr UsbDsReportData): Result {.cdecl, importc: "usbDsInterface_GetCtrlOutReportData", - header: headerusb.} -proc usbDsInterface_StallCtrl*(`interface`: ptr UsbDsInterface): Result {.cdecl, - importc: "usbDsInterface_StallCtrl", header: headerusb.} -proc usbDsEndpoint_Close*(endpoint: ptr UsbDsEndpoint) {.cdecl, - importc: "usbDsEndpoint_Close", header: headerusb.} -proc usbDsEndpoint_PostBufferAsync*(endpoint: ptr UsbDsEndpoint; buffer: pointer; - size: csize; urbId: ptr uint32): Result {.cdecl, - importc: "usbDsEndpoint_PostBufferAsync", header: headerusb.} -proc usbDsEndpoint_GetReportData*(endpoint: ptr UsbDsEndpoint; - `out`: ptr UsbDsReportData): Result {.cdecl, - importc: "usbDsEndpoint_GetReportData", header: headerusb.} -proc usbDsEndpoint_StallCtrl*(endpoint: ptr UsbDsEndpoint): Result {.cdecl, - importc: "usbDsEndpoint_StallCtrl", header: headerusb.} \ No newline at end of file diff --git a/src/libnx/wrapper/usb_comms.nim b/src/libnx/wrapper/usb_comms.nim deleted file mode 100644 index 546f97c..0000000 --- a/src/libnx/wrapper/usb_comms.nim +++ /dev/null @@ -1,20 +0,0 @@ -import strutils -import ospaths -const headerusb_comms = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/devices/usb_comms.h" -import libnx/wrapper/types -proc usbCommsInitialize*(): Result {.cdecl, importc: "usbCommsInitialize", - header: headerusb_comms.} -proc usbCommsExit*() {.cdecl, importc: "usbCommsExit", header: headerusb_comms.} -proc usbCommsInitializeEx*(`interface`: ptr uint32; bInterfaceClass: uint8; - bInterfaceSubClass: uint8; bInterfaceProtocol: uint8): Result {. - cdecl, importc: "usbCommsInitializeEx", header: headerusb_comms.} -proc usbCommsExitEx*(`interface`: uint32) {.cdecl, importc: "usbCommsExitEx", - header: headerusb_comms.} -proc usbCommsRead*(buffer: pointer; size: csize): csize {.cdecl, - importc: "usbCommsRead", header: headerusb_comms.} -proc usbCommsWrite*(buffer: pointer; size: csize): csize {.cdecl, - importc: "usbCommsWrite", header: headerusb_comms.} -proc usbCommsReadEx*(buffer: pointer; size: csize; `interface`: uint32): csize {.cdecl, - importc: "usbCommsReadEx", header: headerusb_comms.} -proc usbCommsWriteEx*(buffer: pointer; size: csize; `interface`: uint32): csize {.cdecl, - importc: "usbCommsWriteEx", header: headerusb_comms.} \ No newline at end of file diff --git a/src/libnx/wrapper/utf.nim b/src/libnx/wrapper/utf.nim deleted file mode 100644 index 8f8530a..0000000 --- a/src/libnx/wrapper/utf.nim +++ /dev/null @@ -1,24 +0,0 @@ -import strutils -import ospaths -const headerutf = currentSourcePath().splitPath().head & "/nx/include/switch/runtime/util/utf.h" -import libnx/wrapper/types -proc decode_utf8*(`out`: ptr uint32_t; `in`: ptr uint8_t): ssize_t {.cdecl, - importc: "decode_utf8", header: headerutf.} -proc decode_utf16*(`out`: ptr uint32_t; `in`: ptr uint16_t): ssize_t {.cdecl, - importc: "decode_utf16", header: headerutf.} -proc encode_utf8*(`out`: ptr uint8_t; `in`: uint32_t): ssize_t {.cdecl, - importc: "encode_utf8", header: headerutf.} -proc encode_utf16*(`out`: ptr uint16_t; `in`: uint32_t): ssize_t {.cdecl, - importc: "encode_utf16", header: headerutf.} -proc utf8_to_utf16*(`out`: ptr uint16_t; `in`: ptr uint8_t; len: csize): ssize_t {. - cdecl, importc: "utf8_to_utf16", header: headerutf.} -proc utf8_to_utf32*(`out`: ptr uint32_t; `in`: ptr uint8_t; len: csize): ssize_t {. - cdecl, importc: "utf8_to_utf32", header: headerutf.} -proc utf16_to_utf8*(`out`: ptr uint8_t; `in`: ptr uint16_t; len: csize): ssize_t {. - cdecl, importc: "utf16_to_utf8", header: headerutf.} -proc utf16_to_utf32*(`out`: ptr uint32_t; `in`: ptr uint16_t; len: csize): ssize_t {. - cdecl, importc: "utf16_to_utf32", header: headerutf.} -proc utf32_to_utf8*(`out`: ptr uint8_t; `in`: ptr uint32_t; len: csize): ssize_t {. - cdecl, importc: "utf32_to_utf8", header: headerutf.} -proc utf32_to_utf16*(`out`: ptr uint16_t; `in`: ptr uint32_t; len: csize): ssize_t {. - cdecl, importc: "utf32_to_utf16", header: headerutf.} \ No newline at end of file diff --git a/src/libnx/wrapper/vi.nim b/src/libnx/wrapper/vi.nim deleted file mode 100644 index 2a751d8..0000000 --- a/src/libnx/wrapper/vi.nim +++ /dev/null @@ -1,61 +0,0 @@ -import strutils -import ospaths -const headervi = currentSourcePath().splitPath().head & "/nx/include/switch/services/vi.h" -import libnx/wrapper/types -import libnx/wrapper/sm -type - ViDisplay* {.importc: "ViDisplay", header: headervi, bycopy.} = object - display_id* {.importc: "display_id".}: uint64 - display_name* {.importc: "display_name".}: array[0x00000040, char] - initialized* {.importc: "initialized".}: bool - - ViLayer* {.importc: "ViLayer", header: headervi, bycopy.} = object - layer_id* {.importc: "layer_id".}: uint64 - stray_layer* {.importc: "stray_layer".}: bool - initialized* {.importc: "initialized".}: bool - - ViServiceType* {.size: sizeof(cint).} = enum - ViServiceType_Default = -1, ViServiceType_Application = 0, - ViServiceType_System = 1, ViServiceType_Manager = 2 - ViLayerFlags* {.size: sizeof(cint).} = enum - ViLayerFlags_Default = 0x00000001 - ViScalingMode* {.size: sizeof(cint).} = enum - ViScalingMode_Default = 0x00000002 - - - - -proc viInitialize*(servicetype: ViServiceType): Result {.cdecl, - importc: "viInitialize", header: headervi.} -proc viExit*() {.cdecl, importc: "viExit", header: headervi.} -proc viGetSessionService*(): ptr Service {.cdecl, importc: "viGetSessionService", - header: headervi.} -proc viGetSession_IApplicationDisplayService*(): ptr Service {.cdecl, - importc: "viGetSession_IApplicationDisplayService", header: headervi.} -proc viGetSession_IHOSBinderDriverRelay*(): ptr Service {.cdecl, - importc: "viGetSession_IHOSBinderDriverRelay", header: headervi.} -proc viGetSession_ISystemDisplayService*(): ptr Service {.cdecl, - importc: "viGetSession_ISystemDisplayService", header: headervi.} -proc viGetSession_IManagerDisplayService*(): ptr Service {.cdecl, - importc: "viGetSession_IManagerDisplayService", header: headervi.} -proc viGetSession_IHOSBinderDriverIndirect*(): ptr Service {.cdecl, - importc: "viGetSession_IHOSBinderDriverIndirect", header: headervi.} -proc viOpenDisplay*(DisplayName: cstring; display: ptr ViDisplay): Result {.cdecl, - importc: "viOpenDisplay", header: headervi.} -proc viCloseDisplay*(display: ptr ViDisplay): Result {.cdecl, - importc: "viCloseDisplay", header: headervi.} -proc viCreateManagedLayer*(display: ptr ViDisplay; LayerFlags: uint32; - AppletResourceUserId: uint64; layer_id: ptr uint64): Result {. - cdecl, importc: "viCreateManagedLayer", header: headervi.} -proc viOpenLayer*(NativeWindow: array[0x00000100, uint8]; NativeWindow_Size: ptr uint64; - display: ptr ViDisplay; layer: ptr ViLayer; LayerFlags: uint32; - LayerId: uint64): Result {.cdecl, importc: "viOpenLayer", - header: headervi.} -proc viCloseLayer*(layer: ptr ViLayer): Result {.cdecl, importc: "viCloseLayer", - header: headervi.} -proc viSetLayerScalingMode*(layer: ptr ViLayer; ScalingMode: uint32): Result {.cdecl, - importc: "viSetLayerScalingMode", header: headervi.} -proc viGetDisplayResolution*(display: ptr ViDisplay; width: ptr uint64; height: ptr uint64): Result {. - cdecl, importc: "viGetDisplayResolution", header: headervi.} -proc viGetDisplayVsyncEvent*(display: ptr ViDisplay; handle_out: ptr Handle): Result {. - cdecl, importc: "viGetDisplayVsyncEvent", header: headervi.} \ No newline at end of file diff --git a/src/libnx/wrapper/virtmem.nim b/src/libnx/wrapper/virtmem.nim deleted file mode 100644 index 9254d03..0000000 --- a/src/libnx/wrapper/virtmem.nim +++ /dev/null @@ -1,12 +0,0 @@ -import strutils -import ospaths -const headervirtmem = currentSourcePath().splitPath().head & "/nx/include/switch/kernel/virtmem.h" -import libnx/wrapper/types -proc virtmemReserve*(size: csize): pointer {.cdecl, importc: "virtmemReserve", - header: headervirtmem.} -proc virtmemFree*(`addr`: pointer; size: csize) {.cdecl, importc: "virtmemFree", - header: headervirtmem.} -proc virtmemReserveMap*(size: csize): pointer {.cdecl, - importc: "virtmemReserveMap", header: headervirtmem.} -proc virtmemFreeMap*(`addr`: pointer; size: csize) {.cdecl, - importc: "virtmemFreeMap", header: headervirtmem.} \ No newline at end of file