Compare commits

...

1422 Commits

Author SHA1 Message Date
yellows8
dfee0c8ba2
ldn: Added ldnSetProtocol. 2025-06-18 18:17:05 -04:00
Dave Murphy
0a4ac1b87c
remove unused dist-bin target 2025-06-12 16:06:29 +01:00
Dave Murphy
638624cf02
actually install libs too. Closes #681 2025-06-12 08:40:44 +01:00
Dave Murphy
2f471a1c26
remove unused version number in Makefile (#679)
* remove unused version number in Makefile
* add dist-src target using git tag
2025-06-10 18:01:55 +01:00
ndeadly
d1dbd8db51 btdrv: fix struct alignment issue in BtdrvBleEventInfo 2025-06-09 21:26:36 +02:00
XorTroll
de7cfeb3d9
nfp: Improve types and enums 2025-05-18 01:09:53 +02:00
ndeadly
2fc81d8f35 btdrv: label proto_mode field in data_report event info 2025-05-18 01:08:51 +02:00
Luis Scheurenbrand
29f6f4fa7a update capsdc for 18.0.0 2025-05-07 23:19:48 +02:00
ndeadly
b88afc509c btmsys: add missing 13.0.0 commands 2025-05-07 23:19:05 +02:00
ndeadly
ceb7ee1cbf set: update SetSysBluetoothDevicesSettings with new fields found in recent firmwares 2025-05-07 23:18:38 +02:00
ndeadly
0ba4f96bfe btdrv: document timeout parameter to btdrvTriggerConnection 2025-05-07 23:18:16 +02:00
Michael Scire
17bcd07095 fsp-pr: update RegisterProgram for 20.0.0 change 2025-05-07 23:17:19 +02:00
Michael Scire
ce6bc0c3e8 ldr/fsldr: update for 20.0.0 2025-05-07 23:17:19 +02:00
Michael Scire
8f1cce6946 libnx: fix compilation with gcc15 2025-05-07 21:09:09 +02:00
ndeadly
60bf943ec1 btdrv: complete definition of BtdrvBleAdvertisePacketData struct and add supporting enums 2025-01-26 18:57:17 +01:00
ndeadly
0ae0792770 btdrv: update gatt server event names to better reflect usage 2025-01-26 18:57:17 +01:00
ndeadly
953c1b7a8a btdrv: fixed swapped permissions and property parameters for btdrvAddGattCharacteristic function 2025-01-26 18:57:17 +01:00
ndeadly
5da574f852 btdrv: add notes about broken gatt server function implementations 2025-01-26 18:57:17 +01:00
ndeadly
b2d7022e1b btdrv: change argument from service id to server interface for gatt server functions 2025-01-26 18:57:17 +01:00
ndeadly
29a6691b66 hidsys: add commands for setting/checking state of joycons attached via rails 2025-01-26 18:56:58 +01:00
averne
88de3cbea7 nvfence: expose nvhost-ctrl fd 2025-01-25 18:10:36 +01:00
averne
218e3f3a04 nvchannel: fix submit ioctl 2025-01-25 18:10:22 +01:00
MasaGratoR
a063ceb19c Fix wrong names in SetSysModeLine 2024-12-08 20:48:22 +01:00
MasaGratoR
e79dd7ac52
Update setsysEdid struct (#654) 2024-11-26 21:34:21 +01:00
Dave Murphy
2e2b110668
use nproc for max jobs on github workflow (#652) 2024-11-25 00:55:17 +00:00
yellows8
432b4e3900
hid: Use the Npad-revision for 18.0.0+. 2024-11-24 19:34:53 -05:00
ndeadly
eef44aa5e1
btm: add audio profile (#650)
Co-authored-by: ndeadly <24677491+ndeadly@users.noreply.github.com>
2024-11-25 00:31:32 +01:00
yellows8
688e4dd14e
hiddbg: Fixed crash when accessing Hdls tmem. Closes #653. 2024-11-24 16:46:45 -05:00
yellows8
d4f5f4b145
audctl: Updated sysver checks. 2024-11-24 16:19:59 -05:00
yellows8
6c430b273a
capsc: Pass CapsApplicationId/u64 for input as required by sysver. 2024-11-24 15:48:35 -05:00
Michael Scire
58f1fc6561 caps: add fields to AlbumFileId, simplify old invoke 2024-11-24 21:44:07 +01:00
Michael Scire
65c643f149 capsc: account for new command sizes 2024-11-24 21:44:07 +01:00
Michael Scire
73d79d4a0f fs: add GetContentStorageInfoIndex 2024-11-24 21:44:07 +01:00
Michael Scire
163fdddabf fs: add new outsize parameter to fsDeviceOperatorGetGameCardDeviceCertificate 2024-11-24 21:44:07 +01:00
Michael Scire
c7c9617290 switch.ld: fix absolute addressing, incompatible with relr relocations 2024-11-24 21:44:07 +01:00
Michael Scire
250a5777f7 ldr:pm: Update ProgramInfo 2024-11-24 21:44:07 +01:00
Michael Scire
5d5d13c9d6 svc: WaitIfEqual64 is value 3 2024-11-24 21:44:07 +01:00
Michael Scire
2bbf49377e svc: add new info type 2024-11-24 21:44:07 +01:00
Michael Scire
81bed00b5b svc: update WaitForAddress 2024-11-24 21:44:07 +01:00
fincs
8cff58d5af
dynamic: add support for ELF packed relocations (relr) 2024-08-31 00:40:56 +02:00
Irne Racoonovich
d66e3aa487 spl: add missing service header 2024-08-29 21:14:38 +02:00
fincs
7b4e02be35
nwindowReleaseBuffers: cancel dequeued buffer instead of failing 2024-08-19 17:43:51 +02:00
ndeadly
3c851a3443
bt: fill in unknowns and update function parameters to match their btdrv counterparts (#644) 2024-06-28 13:48:22 +01:00
ndeadly
df0508200b
Add missing hid shared memory structures and accessor functions for system buttons (#647)
* hid: add missing shared memory format structures
* hid: add functions for getting the state of the home, sleep and capture buttons from shmem
2024-06-28 13:48:02 +01:00
Dave Murphy
c769852631
update Makefile version 2024-05-31 17:28:15 +01:00
Dave Murphy
e8341a00fe
4.7.0 changelog 2024-05-31 17:22:52 +01:00
Dave Murphy
e570e67704
add changelog for 4.6.0 2024-05-31 17:20:52 +01:00
Michael Scire
bb65fec6eb hidsys: use hosversionBetween 2024-05-30 21:41:06 +02:00
Michael Scire
510d85bf48 hidsys: add version checking to removed commands 2024-05-30 21:41:06 +02:00
Michael Scire
ff2e76daf9 ns: Add version checking for ns:dev commands 2024-05-30 21:41:06 +02:00
Michael Scire
c8c4406467 svc: Add new InfoTypes 2024-05-30 21:41:06 +02:00
Pablo Curiel
b69d2fa95e fs: add GetFileSystemAttribute cmd 2024-05-07 14:58:51 -04:00
averne
919e3d3938 Update for review 2024-02-04 00:57:09 +01:00
averne
b615b01d44 nvchannel: Implement GET_CLK_RATE and SET_SUBMIT_TIMEOUT 2024-02-04 00:57:09 +01:00
averne
be45a91b9c nvchannel: Fix SET_CLK_RATE 2024-02-04 00:57:09 +01:00
Rambo6Glaz
827c6b6ddf Implement IFSDeviceOperator "ChallengeCardExistence" and "GetGameCardDeviceCertificate" 2024-02-04 00:56:19 +01:00
MasaGratoR
ce1f87050d Update SetSysProductModel_Aula comment 2024-02-04 00:11:36 +01:00
Dave Murphy
99edb1c0f0
libnx 4.6.0 2023-12-17 20:21:05 +00:00
ThisALV
7d68ad6bd4
fix: avoid segfault at static dtors (#638) 2023-12-17 14:15:33 +00:00
ITotalJustice
fda4e6b105
add fsDeviceOperatorGetGameCardUpdatePartitionInfo (#635) 2023-11-23 20:46:29 +01:00
yellows8
8d10ef8745
nv: Added __nx_nv_service_type. Closes #633. 2023-11-20 14:12:52 -05:00
Ghabry
a215ae2da2 Add NX_ prefix to PACKED, NORETURN, IGNORE_ARG and DEPRECATED macros 2023-11-20 19:22:12 +01:00
Michael Scire
933c5a12f0 svc: fix query/insecure names 2023-11-01 19:06:56 +01:00
fincs
bb0ae8ac74
libnx v4.5.0 2023-10-27 23:48:15 +02:00
fincs
1bb5a21453
socket: automatically detect and use latest bsdsockets version (fix #551) 2023-10-27 23:46:40 +02:00
yellows8
9439b39631
ssl: Updated sslConnectionSetPrivateOption for 17.0.0. 2023-10-26 14:47:07 -04:00
SciresM
386118d16b
fs: add commands needed for 17.x SubmitFsInfo (#629) 2023-10-26 17:35:37 +02:00
Michael Scire
08373603f7 sf: fix service macro C++ compat 2023-10-25 20:30:24 +02:00
ndeadly
412c48eab5 btdrv: add missing ble definitions
(cherry picked from commit f60935fcc2afc82f20a921284a520dab9c61caab)
2023-10-25 19:21:12 +02:00
liamadvance
0094af6d29 crypto: fix aes-cbc individual block decryption 2023-10-21 21:20:57 +02:00
p-sam
ae491ce57b Add GetPossibleClockRates method for pcv and clkrst 2023-10-21 16:55:34 +02:00
yellows8
94cfa2be1c
ns: Added nsEstimateSizeToMove. 2023-10-20 18:53:41 -04:00
fincs
4ff1c52869 crt0/dynamic: refactoring + add support for reprotecting relro segment 2023-10-21 00:18:04 +02:00
fincs
3a5d0dae35 Linker script refactoring, see details:
- Added separate relro "segment" (introduced by [17.0.0+])
- Reordered sections to better reflect official layout
- Fixed handling of TLS segment alignment
2023-10-21 00:18:04 +02:00
Michael Scire
288a09c4eb uart: use hosversionBetween when possible 2023-10-21 00:18:04 +02:00
Michael Scire
3bb619f46e restrict gpio/uart commands on 17.0.0 2023-10-21 00:18:04 +02:00
Michael Scire
3cb556acb3 ts: update for 17.0.0 2023-10-21 00:18:04 +02:00
Michael Scire
140400d566 svc: add PermissionLocked attribute 2023-10-21 00:18:04 +02:00
Michael Scire
6f9bc920c9 add capsdcShrinkJpeg 2023-10-21 00:18:04 +02:00
Michael Scire
e322bdf82d fs: fix GetProgramId 2023-10-21 00:18:04 +02:00
Michael Scire
e6626a7825 fsldr: update OpenCodeFileSystem for 17.0.0 2023-10-21 00:18:04 +02:00
Michael Scire
25a8f21796 ncm/fs: add new 17.0.0 commands 2023-10-21 00:18:04 +02:00
Michael Scire
cb6f366a2a add static_assert to fs macros 2023-10-12 01:29:03 +02:00
Michael Scire
edc000928b service: Static assert arguments aren't pointers to prevent failure-to-deref 2023-10-12 01:29:03 +02:00
Narr the Reg
4fcdb6eb34 service: hidsys: Implement functions needed by QLaunch 2023-08-12 16:51:58 +02:00
german77
e2424fd8bf service: pctl: Implement functions used by Qlaunch 2023-08-09 18:10:59 +02:00
Narr the Reg
af5072c096 service: nfc: add mifare guard 2023-07-04 23:16:56 +02:00
german77
6bd6fa8907 service: nfc: Implement all interfaces and function calls 2023-06-14 20:40:43 +02:00
Dave Murphy
b954aaf35d
dereference pointer. Closes #612 2023-06-07 16:16:37 +01:00
Dave Murphy
8ce306b9b6
4.4.2 release 2023-05-27 15:24:25 +01:00
Dave Murphy
2e80cf9bba quote timezone to allow +/- & alphanumerics 2023-05-27 16:16:37 +02:00
Dave Murphy
95f973fe98 ensure correct address for __bss_start__ 2023-05-27 16:16:31 +02:00
Dave Murphy
6602c440b4
end compile_commmands generation when elf linked 2023-05-27 10:25:44 +01:00
Dave Murphy
99a29b97ca
ignore more generated files 2023-05-27 10:18:45 +01:00
Dave Murphy
dc0de47eb1
libnx 4.4.1 2023-05-07 22:13:45 +01:00
Dave Murphy
77c2d18046 add missing separator to local path 2023-05-07 18:09:12 +02:00
Dave Murphy
a6686ae27a
libnx 4.4.0 2023-05-07 03:18:32 +01:00
Dave Murphy
8747689be1
gcc 13 fixes (#610) 2023-05-07 03:04:58 +01:00
MasaGratoR
d219884bfa
tmem: Add tmemCloseHandle(), tmemWaitForPermission(), use those functions in nv.c to fix a race condition (#606) 2023-04-14 18:33:16 +02:00
Liam
db592d8aeb usbcomms: expose VID:PID configuration 2023-04-08 17:24:53 +02:00
Liam
9d1fd27b62 usbcomms: add async API 2023-04-08 17:24:53 +02:00
Liam
2e2284109b applet: add appletGetMessageEvent 2023-04-08 17:22:26 +02:00
Dave Murphy
dca4fb772a
Changelog for 4.3.0 2023-04-02 19:19:41 +01:00
Dave Murphy
cbb49e2ce0
libnx v4.3.0 2023-04-02 16:57:13 +01:00
Vinogradov Daniil
4c0991dd88
Added CMSG macros to /sys/socket.h (#605) 2023-04-02 16:43:42 +01:00
Michael Theall
ab2c2fb256 Avoid long connection hang in nxlink 2023-04-02 16:37:05 +02:00
yellows8
c09a21d87d
socket: Fix building without bsd-headers. 2023-03-10 12:30:55 -05:00
yellows8
3332ee2f6f
ssl: minor fix 2023-03-09 23:15:22 -05:00
yellows8
f64d2059c4
ssl: Add support for the new 16.0.0 functionality. 2023-03-09 23:14:40 -05:00
yellows8
8d9959010f
ssl: Updated SslCaCertificateId. 2023-03-09 01:30:45 -05:00
yellows8
f7af27cd21
ssl: Add ssl:s support and sslClearTls12FallbackFlag. 2023-03-09 01:09:21 -05:00
yellows8
c3e110988a
pdm: Updated/fixed sysver compat, updated structs. 2023-03-08 16:31:44 -05:00
yellows8
4ece4e5b8f
pl: Add 16.0.0 sysver checks, etc. 2023-03-07 18:35:32 -05:00
Michael Scire
ee873e34d0 vi: Add 16.x Manager commands
vi: fix duplicate decl of Indirect service

vi: fix style

vi: use s32 over int

vi: fix argument names for FatalDrawRectangle
2023-03-07 23:36:02 +01:00
Michael Scire
b5e47b6b67 fs: update bindings for 16.0.0 changes
fs: add new ContentAttributes enum

fs: add version check

fs: use hosversionBetween
2023-03-07 23:36:02 +01:00
Michael Scire
6175293d0f ncm: Add ActivateFsContentStorage
ncm: update bindings for 16.0.0 changes

ncm: fix missing rename on GetPatchContentMetaId

ncm: they broke serialization ordering by changing type alignment

ncm: remove alignment on content id/placeholder id
2023-03-07 23:36:02 +01:00
averne
ada230a882 audctl: add GetActiveOutputTarget 2023-02-04 16:45:15 +01:00
averne
4d59d366a1 auddev: add GetActiveAudioDeviceName 2023-02-04 16:45:15 +01:00
ndeadly
dcebe96e71
hiddbg: modify hiddbgAttachHdlsWorkBuffer to accept a user-supplied buffer and size (#601)
Co-authored-by: ndeadly <24677491+ndeadly@users.noreply.github.com>
2023-02-02 00:20:48 +01:00
yellows8
174b5066a5
usbhs: Use an user-specified buffer for tmem, etc. 2023-02-01 14:00:33 -05:00
yellows8
7549d3b124
usbhs: Expose the id param, and update a struct. 2023-02-01 13:16:32 -05:00
yellows8
e768ac74f9
usbhs: Added the remaining cmds and expose more functionality, etc. 2023-01-31 21:32:45 -05:00
averne
6ee5d8d148 audctl: fix TargetVolume functions 2023-01-31 21:06:01 -05:00
Pablo Curiel
7caf74af76
Update ncm_types to 15.0.0. (#597) 2022-12-06 12:45:23 +01:00
yellows8
3b2d72a427
error: Add note for errorApplicationCreate. 2022-11-02 22:56:30 -04:00
yellows8
75290f912e
applet: Updated for 15.0.0. Various fixes and added __nx_applet_init_timeout. 2022-11-01 14:27:32 -04:00
yellows8
cea3018de6
result: Add LibnxError_Timeout. 2022-11-01 14:24:22 -04:00
yellows8
5ca15e7696
wlaninf: Add sysver check since this was removed in 15.0.0. 2022-10-22 16:30:42 -04:00
Michael Scire
09338f80b2 bpc: fix GetSleepButtonState/GetPowerButton 2022-10-21 23:51:40 +02:00
fincs
c4c9a6af3c
libnx v4.2.2 2022-10-16 19:39:20 +02:00
yellows8
ac414d2bc5
pdm: Updated sysver checks for 15.0.0. 2022-10-16 12:45:58 -04:00
yellows8
ea145a8d3c
setsys: Updated sysver check for setsysNeedsToUpdateHeadphoneVolume. 2022-10-16 12:45:58 -04:00
fincs
8b77139a04
env: Add support for svc 0x80..0xBF hinting 2022-10-12 19:42:37 +02:00
Michael Scire
de4d19df1a MapDeviceAddressSpace svcs now take option, not perm 2022-10-12 09:03:04 -07:00
Michael Scire
1543e84627 svc: add MapInsecureMemory/UnmapInsecureMemory 2022-10-11 20:18:30 -07:00
yellows8
328d041c5c
swkbd: Fixed height value in swkbdInlineGetTouchRectangles. 2022-10-06 15:22:47 -04:00
averne
1a05cb20a2 Fix typos in swkbd.h 2022-10-06 19:49:54 +02:00
averne
97fef5e48d Fix calculation of the inline swkbd touch rectangle 2022-10-06 19:49:54 +02:00
notaz
d8a4f33192 cache: need an isb barrier on icache invalidate
I don't have a switch but on r-pi4 it's easy to reproduce problems
without this Instruction Synchronization Barrier. Better be safe than
having "fun" dealing with super rare crashes.
2022-08-02 23:06:52 +02:00
averne
8b17648d0b nv: Implement ioctl GET_GPU_TIME 2022-07-02 16:02:01 +02:00
Michael Scire
62755bebe0 svc: fix wrong ids for (Un)MapIoRegion 2022-06-27 17:34:41 +02:00
yellows8
bb42eab289
nifm: Added nifmSetWowlDelayedWakeTime. 2022-06-06 01:50:33 -04:00
yellows8
d33bb0ad6a
nifm/socket: Add nifmRequest sleep/register-socket cmds. 2022-05-31 20:09:26 -04:00
fincs
3a508e13b1
libnx v4.2.1 2022-05-22 16:36:06 +02:00
Dave Murphy
d14f931eab payload can never be NULL 2022-05-02 23:12:56 +01:00
Dave Murphy
bf50bfdbbe disable array bounds checking for __tls_start 2022-05-02 23:11:24 +01:00
yellows8
9865dbf921
btdrv: Updated sysver check for removed cmds in 14.x. 2022-04-07 22:12:26 -04:00
MasaGratoR
a1d6b3be43
ts: Update tsGetTemperatureMilliC (#588)
* ts: Update tsGetTemperatureMilliC for 14.0.0
2022-04-07 21:47:04 -04:00
Michael Scire
d42ddeff78 bpc: add 6.0.0 bpcGetPowerButton, update accessible-firmware comments. 2022-04-07 21:43:32 -04:00
Michael Scire
cdba7dc808 pm: update for 14.0.0 2022-04-07 21:43:32 -04:00
Michael Scire
f9a27d6cc7 svc: add new info type 2022-04-07 21:43:32 -04:00
Michael Scire
f60f82856a cache: set flag in tlr when doing maintenance 2022-04-07 21:43:32 -04:00
yellows8
0a88426a6a
svc: ret for svcCallSecureMonitor is void. 2022-03-06 14:00:40 -05:00
Morph
e6c7ac7c0b fs: Add fsOpenSaveDataInfoReaderWithFilter 2022-03-06 19:20:40 +01:00
yellows8
04aa28c436
nv: Added nvIoctl3, updated _nvGetSessionForRequest, and:
* Check hosver in nvIoctl2.
2022-02-26 12:54:26 -05:00
averne
3d9e1a9c7b Fix MemoryInfo field order 2022-01-29 16:38:34 +01:00
Michael Theall
6d8d9fd2fc Don't apply bold/faint to bg console 2022-01-08 01:07:56 +01:00
yellows8
32370bd19c
fs: Added fsCreate_TemporaryStorage + fixed fsOpen_TemporaryStorage. 2022-01-06 12:20:19 -05:00
yellows8
587115f10a
btm: Fixed backwards sysver check in _btmCmdGetEventOutFlag. 2021-12-09 01:02:47 -05:00
yellows8
4a33b32f43
nfc: Added more cmds, etc. 2021-12-09 01:01:32 -05:00
fincs
74c639ec3a
random.c: Avoid UB type punning that results in miscompilation 2021-12-05 19:31:42 +01:00
Michael Theall
16f8547f4c Add support for SGR 38 and 48
This supports the escape sequences used by fmtlib
2021-11-10 20:38:30 +01:00
yellows8
c208dd0a57
hid: Added the new controllers to HidDeviceType. 2021-11-01 18:15:11 -04:00
fincs
431c99465c
switch.ld: Merge .crt0 into .text 2021-11-01 01:34:06 +01:00
yellows8
93db7abb03
hid: Updated various enums/etc, + support for new controllers. 2021-10-27 16:27:32 -04:00
yellows8
65b8ed5582
Added BITL. 2021-10-27 16:23:56 -04:00
ndeadly
cee75bbe13 hidsys: add some missing unique pad service wrappers 2021-10-04 21:35:15 +02:00
fincs
748cf5ab98
libnx v4.2.0 2021-10-02 16:57:22 +02:00
yellows8
c6dcbdfffb
btm: Updated structs/params for 13.0.0. 2021-09-25 11:01:30 -04:00
ndeadly
b5714296d6 setsys: update SetSysBluetoothDevicesSettings for 13.0.0 2021-09-24 22:59:54 +02:00
yellows8
8db41edc43
psel: Added pselShowUserQualificationPromoter for 13.0.0. 2021-09-24 11:56:15 -04:00
ndeadly
bf2e48e22a
btm: update GetDeviceCondition and GetDeviceInfo service wrappers and related types for 13.0.0 (#576) 2021-09-24 17:35:11 +02:00
p-sam
b35d42faaa hiddbg: fix IsHdlsVirtualDeviceAttached for 13.0.0 2021-09-22 17:32:38 +02:00
yellows8
0cc2da720c
setsys: Updated SetSysNxControllerSettings. 2021-09-19 16:14:17 -04:00
Michael Scire
8daccdf35a ncm: add new 13.0.0 commands 2021-09-18 21:55:14 +02:00
Michael Scire
49507b86a8 svc: add 13.0.0 svc changes 2021-09-18 12:34:58 +02:00
yellows8
369bb31311
btdrv: Added 13.0.0 cmds + minor improvements. 2021-09-18 00:31:53 -04:00
yellows8
0a64ff5af0
setsys: 13.0.0 support 2021-09-17 16:02:49 -04:00
yellows8
4ac0a9ffdc
hidsys: use hosversionBetween 2021-09-17 11:48:09 -04:00
yellows8
8e93933157
hiddbg: hdls 13.0.0 support 2021-09-17 11:23:11 -04:00
yellows8
4ac3b0cec5
hidsys: Check sysver for the removed cmds with 13.0.0. 2021-09-17 01:50:31 -04:00
Sean Maas
960599c4b5 btdrv: fix btdrvRespondToSspRequest for 12.0.0 2021-09-15 12:19:30 -04:00
XorTroll
ade5038282 Fix ldr:ro/ro:1 initialization 2021-09-15 12:18:18 -04:00
fincs
fc2aaefb0f
framebufferCreate: actually set NWindow dimensions (fix #568) 2021-09-13 19:01:34 +02:00
Michael Scire
d90afaacde thread: set arguments/fields before CreateThread 2021-07-20 18:13:10 +02:00
fincs
bee27ba607
libnx v4.1.3 2021-06-25 19:27:05 +02:00
Vicki Pfau
0aba35b3ed Fix inet_pton by passing in base instead of getting it out (#557) 2021-06-24 22:59:28 +02:00
fincs
3c9a623b24
switch.specs: ensure main() is referenced first (fix devkitPro/pacman-packages#237) 2021-06-22 19:45:06 +02:00
fincs
982aef9ea5
sessionmgr: fix deadlock with multiple waiters (fix #556) 2021-06-20 12:39:42 +02:00
fincs
b17873d071
libnx v4.1.0 2021-06-12 16:34:48 +02:00
fincs
cfdd847f11
Add doxygen generation workflow on tag 2021-06-11 17:52:16 +02:00
Dave Murphy
84b92d9e64
use correct badge for github workflow (#555) 2021-06-10 19:47:45 +02:00
ndeadly
373b13b7c0 btm: add BtmDeviceCondition definitions
(cherry picked from commit a598dca0e1d8cb4c4f3c053494048832c05a79ed)
(cherry picked from commit 9736386850dc4b987b095a43eceefc469996b2fa)
2021-06-09 21:32:47 +02:00
ndeadly
58885db2cd btdrv: update bluetooth hid connection event info for 12.0.0 2021-06-02 17:56:55 +02:00
ndeadly
8c8bd9debf btdrv: add bluetooth event info definition for connection event on fw < 9.0.0
(cherry picked from commit 1e7abd975fc906d1a483b33fa86969cb15e93ece)
2021-06-02 17:56:55 +02:00
fincs
4a850437f2
audctl/audrec: fixup 2021-05-31 17:43:02 +02:00
plutoo
5421d1d716 audrec: Fix typo 2021-05-30 17:54:26 -07:00
plutoo
5d95e17f9b switch: Fix documentation comments 2021-05-30 17:53:33 -07:00
plutoo
4b2d111859 audctl: Fix prefix on enum 2021-05-30 17:46:49 -07:00
plutoo
f893c043f7 switch: Add audrec/audctl to default header 2021-05-30 17:33:39 -07:00
plutoo
6ce881b013 audrec: Initial commit 2021-05-30 17:33:26 -07:00
plutoo
a1ddefd3ca audctl: Initial commit 2021-05-30 17:33:11 -07:00
yellows8
f486127615
Bluetooth pr rebased (#552 and #540)
* btdrv: expand upon and refine event data definitions

* btdrv changes for 12.0.0

* btdrv: Various fixes, added enums, etc.

Co-authored-by: ndeadly <24677491+ndeadly@users.noreply.github.com>
2021-05-30 13:47:36 -04:00
Dave Murphy
5d448a1048 remove broken doozer builds 2021-05-24 19:28:05 +01:00
fincs
f47e1d26ec
Remove obsolete reference to 3dmoo carried over from libctru 2021-05-21 23:03:54 +02:00
Pablo Curiel
e604350e9c
crc: allow checksum calculation in blocks. (#550) 2021-05-21 00:07:35 +02:00
Dave Murphy
4bd7863364 add github workflow building 2021-05-20 08:27:51 +01:00
Morph
08e2b2d945
swkbd: Fix several swkbd enums and structs (#549)
* swkbd: Provide more accurate SwkbdInline State descriptions

* swkbd: Correct stringLenMaxExt to stringLenMin

* swkbd: Add setters for stringLenMax/Min in SwkbdAppearArg
2021-05-10 18:16:40 +02:00
Narr the Reg
e2c3ae8e44 hid: Correct some gesture errors
I recently did some RE on touch gestures with the help of a nro I made. I have found that those values where incorrect.
2021-05-04 17:34:34 +02:00
fincs
95fca6753d
virtmem: Allow rng algorithm override 2021-05-02 18:26:40 +02:00
fincs
137f6d1ddc
Make argvSetup overridable 2021-05-02 15:18:11 +02:00
TurtleP
00d1a696b9 add audrvVoiceIsPaused 2021-04-26 20:33:10 +02:00
Pablo Curiel
d6c6431a22
Fix unused parameter warnings in tipc.h when -Wextra is used. (#545)
Removes unused TipcService parameter in tipcMakeRequest and tipcParseResponse.
2021-04-20 20:43:50 +02:00
Michael Scire
f7df9d578c pgl: fix argument order for LaunchProgram on 12.x 2021-04-20 17:38:31 +02:00
yellows8
5509f8f14b
hiddbg: Fix IPC params from the previous commit, closes #543. 2021-04-19 10:33:03 -04:00
yellows8
d54c9f9cc8
hiddbg: hdls 12.0.0 support, closes #542. 2021-04-18 18:35:36 -04:00
averne
5d644b6e82 Fix mm:u on 1.0.0 2021-04-18 19:20:02 +02:00
yellows8
2e2cf43cf5
btdrv: Added support for the new 12.0.0 cmds. 2021-04-16 16:46:45 -04:00
fincs
0d32a2c0d5
sm: docufix 2021-04-11 14:07:42 +02:00
Michael Scire
d6a1ef0af4
pgl: convert to cmif/tipc polyglot 2021-04-11 12:20:08 +02:00
Michael Scire
eb8ee97f1c
smm: support tipc/cmif 2021-04-11 12:20:08 +02:00
fincs
7416b23ef9
sm: update for 12.0.0, tipc 2021-04-11 12:20:07 +02:00
Michael Scire
ebb54a1224
tipc: add cmif-like wrapper 2021-04-11 12:20:06 +02:00
fincs
de97b82bce
envSetup: detect Atmosphère environment using EntryType_HosVersion 2021-04-11 12:20:06 +02:00
Jeremy S. Postelnek
ca9d007bd4
friends: ability to get Friend Code (#539) 2021-04-10 23:14:24 +02:00
Jeremy S. Postelnek
c5a9a909a9
set:sys: add ProductModel enums (#538) 2021-04-02 19:34:40 +02:00
Vicki Pfau
7e29719263 psm: Fix charger definitions 2021-03-30 17:40:05 +02:00
SciresM
f365c9b2b5
htcs: implement hipc bindings (#530) 2021-03-16 23:42:50 +01:00
averne
05744823ac Const request 2021-03-07 19:59:46 +01:00
averne
3374db38a2 Add mm:u service wrappers 2021-03-07 19:59:46 +01:00
averne
3bb44d77b7 Fix nvioctlChannel_Submit syncpt writeback 2021-03-07 19:59:46 +01:00
averne
0716ed6ffd
Add some nvchannel ioctls (#534) 2021-02-28 21:17:57 +01:00
Michael Scire
ae6f69d339 bsd: fix bsdRegisterClient 2021-02-26 17:43:20 +01:00
Michael Scire
c8f8145195 bsd: allow user-specified tmem backing buffer 2021-02-24 17:41:52 +01:00
Michael Scire
38ee48032f sf: add serialization fixes necessary for htcs 2021-02-20 13:16:10 +01:00
yellows8
d4542ec9b0
hiddbg: Added support for SleepButton AutoPilot. 2021-02-13 14:20:44 -05:00
Michael Scire
ae3271ba4c fs: add fsOpenHostFileSystem(WithOption) 2021-02-13 16:46:49 +01:00
yellows8
0f4f0ed039
btdrv: Updated BtdrvFatalReason. 2021-02-12 13:11:57 -05:00
yellows8
3fce0d49e2
time: Fixed signedness issue with time calculation, closes #522. 2021-02-12 12:33:24 -05:00
Michael Scire
c71cd80bcf psc: fix dependency argument on init 2021-02-10 17:31:51 +01:00
yellows8
15a5d1c44f
btdrv: Updated params/docs for btdrvSetBleVisibility. 2021-02-04 11:47:50 -05:00
yellows8
531f9d7921
Updated/added bluetooth structs/enums. Updated docs.
Moved btm types into a dedicated .h.
2021-02-03 14:02:38 -05:00
yellows8
7751df9356
btdrv: Updated param names + docs. 2021-02-02 15:51:31 -05:00
SciresM
e48f1c339f
add hosversionIsAtmosphere (#525) 2021-01-27 23:20:41 +01:00
fincs
076657fd31
Allow user override of dynamic memory allocation functions throughout libnx 2021-01-22 18:37:46 +01:00
yellows8
d813bef54b
btdrv: Added/updated structs/enums for events, etc. 2021-01-19 20:02:01 -05:00
fincs
5057a1912e
nv: Allow user override of transfer memory creation 2021-01-18 20:46:50 +01:00
fincs
d53150f855
thread: Allow user override of automatic stack memory allocation 2021-01-17 17:48:08 +01:00
fincs
109bd683df
hid: Add HidKeyboardKey & hidKeyboardStateGetKey 2021-01-17 17:45:48 +01:00
fincs
649f308d4b
Delete old virtmem API 🦀🦀 2021-01-17 17:05:29 +01:00
fincs
637dd12b2d
Delete old HID API 🦀🦀 2021-01-17 17:05:21 +01:00
yellows8
c8fdae9189
btdrv: Updated/added structs/enums for events, etc. 2021-01-16 13:34:12 -05:00
Luis Scheurenbrand
9e52e55177 avm: fix buffer size for version list import 2021-01-06 20:53:52 +01:00
Luis Scheurenbrand
a1a69ebe09 avm: fix more merge errors 2021-01-06 18:27:12 +01:00
HookedBehemoth
43202cc829
add application version manager service wrapper (#519) 2021-01-06 17:25:29 +01:00
yellows8
110c2f0622
btdrv: Updated docs. 2021-01-05 01:36:29 -05:00
yellows8
348b21def2
btdrv: Updated names for BtdrvHidReportEvent*. 2021-01-03 02:07:17 -05:00
yellows8
2f6fcf7fb2
btdrv: Updated param names/docs. 2020-12-29 20:31:06 -05:00
yellows8
e9ee0b2421
btm/btdrv: Updated param names. 2020-12-29 14:46:10 -05:00
yellows8
a35321b360
hid: Minor Palma improvements. 2020-12-27 00:58:15 -05:00
fincs
73feb933ce
libnx v4.0.0 2020-12-19 17:03:29 +01:00
Tim Gates
8cbd1cf03c docs: fix simple typo, recieve -> receive
There is a small typo in nx/include/switch/runtime/devices/socket.h, nx/include/switch/services/bsd.h.

Should read `receive` rather than `recieve`.
2020-12-19 13:35:29 +01:00
yellows8
3c9e4e2ebc
ns: Use ns:ro if available. 2020-12-17 15:01:46 -05:00
yellows8
d4014bde62
miiLa: Added for support for 10.2.0 functionality + various fixes. 2020-12-17 00:21:47 -05:00
yellows8
0d5dcde5b9
swkbd: Added swkbdInlineGetMiniaturizedHeight. 2020-12-16 20:32:42 -05:00
yellows8
c51918a605
hidLa: 11.0 support and fixed the arg_size value. 2020-12-16 13:24:48 -05:00
yellows8
06d38571b4
libapplet: Added the new 11.0 funcs. 2020-12-15 22:10:58 -05:00
yellows8
55179074cc
web: Added 11.0 webConfigSetTransferMemory(). 2020-12-15 19:22:24 -05:00
Pablo Curiel
41fc8bb17c
fs: Added fsCreateSaveDataFileSystem(), fsDeleteSaveDataFileSystem() and fsDeleteSaveDataFileSystemBySaveDataAttribute(). #518 2020-12-15 17:48:00 +01:00
yellows8
ccec5bd36c
apm/applet: Updated names/docs.
Added AppletWindowOriginMode.
2020-12-15 11:14:35 -05:00
yellows8
d406db725d
applet: Added 11.0 cmds. 2020-12-14 15:32:54 -05:00
yellows8
13716b5e7b
hidsys: Updated ButtonConfig cmds for 11.0.
Removed an extra param from hidsysIsAnyCustomButtonConfigEnabled.
2020-12-12 12:38:13 -05:00
yellows8
c365c1ae68
hid: Minor adjustments. 2020-12-11 15:42:01 -05:00
yellows8
16fb73cc96
hid: Fixed hidKeyboard{Held/Down/Up}. 2020-12-11 15:15:58 -05:00
yellows8
3d003aef39
lp2p: Updated docs. 2020-12-10 23:37:56 -05:00
yellows8
9ede39d15d
lp2p: Updated docs. 2020-12-10 19:44:47 -05:00
fincs
767a7a295c
switch.specs: Disable .interp section, shrink .dynamic section 2020-12-08 21:43:05 +01:00
yellows8
af837185d0
hiddbg: Added HiddbgNpadButton. 2020-12-08 15:24:57 -05:00
masagrator
c3aeb885e7 Fix svcSetHeapSize error in comment section 2020-12-08 12:25:47 +01:00
yellows8
d91a2e22e7
hid: Updated docs. 2020-12-05 01:09:13 -05:00
yellows8
de5e158545
hid: Updated Palma docs. 2020-12-05 00:46:49 -05:00
SciresM
c3b63e8723
svc: add new InfoType_FreeThreadCount (#514) 2020-12-05 03:11:49 +01:00
Michael Theall
1e9fe9b199 usbDsWaitReady: use deadline timeout 2020-12-05 02:42:45 +01:00
HookedBehemoth
f82d97f88a
Add capmtp service wrapper [11.0.0+] (#510) 2020-12-04 21:53:44 +01:00
SciresM
21b0613fa4
usb: add UsbState enum (#512) 2020-12-04 21:13:30 +01:00
yellows8
e8a4f22063
ssl: Updated for 11.0.0. 2020-12-04 13:42:42 -05:00
yellows8
49d7fe81b8
usbds: Fixed usbDsInterface_AppendConfigurationData for 11.0.0. 2020-12-03 23:11:28 -05:00
yellows8
0f38ec8a3d
hidbus: Adjusted out-of-bounds size handling. 2020-12-03 18:03:32 -05:00
SciresM
1291966976
ectx: add ectxrPullContext (#511) 2020-12-03 22:09:06 +01:00
yellows8
0fbbea2c77
lp2p: Updated for [11.0.0+]. 2020-12-03 14:39:55 -05:00
SciresM
2d470ee2af
sm: add smDetachClient (#509) 2020-12-02 17:42:09 +01:00
SciresM
83dc9203dc
usb: update for 11.0.0 (#508) 2020-12-02 17:06:24 +01:00
fincs
ab71d6033a
hid: Read SystemExt/System first in hidScanInput for compatibility with old homebrew 2020-12-01 21:07:03 +01:00
fincs
676f254be1
pad: Fix logic typo 2020-12-01 16:37:01 +01:00
fincs
e904bb05d4
hid: Deprecate old input interface 2020-12-01 13:50:00 +01:00
fincs
d290697bfd
Add pad.h - new wrapper API for reading controller input 2020-12-01 13:50:00 +01:00
yellows8
5551d42b29
hid: Added/updated Palma structs/enums. 2020-12-01 13:50:00 +01:00
yellows8
09bcd32fbc
hid: Updated structs/enums. 2020-12-01 13:50:00 +01:00
yellows8
a45b951db2
hiddbg/hidsys: Updated structs. 2020-12-01 13:50:00 +01:00
yellows8
3a11e1d309
hidbus: Updated structs/enums. 2020-12-01 13:50:00 +01:00
yellows8
5aa8986505
hid: Added support for the Palma cmds. 2020-12-01 13:49:59 +01:00
yellows8
49183c9953
hidsys: Updated the {Home/Sleep/Capture}Button cmds. 2020-12-01 13:49:59 +01:00
yellows8
4010c70b1e
hiddbg: Added support for AutoPilot with the following:
DebugPad, TouchScreen, Mouse, Keyboard.
2020-12-01 13:49:59 +01:00
yellows8
b7e1ec852c
hid: Added DebugPad structs/enums. 2020-12-01 13:49:59 +01:00
yellows8
527b813bcf
notif: Use hidLaShowControllerFirmwareUpdate if needed. 2020-12-01 13:49:59 +01:00
yellows8
baa9dab747
hidsys: Added the following cmds:
hidsysSendKeyboardLockKeyEvent, hidsysGetNpadInterfaceType, hidsysGetNpadLeftRightInterfaceType, hidsysHasBattery, hidsysHasLeftRightBattery, hidsysIsUsbFullKeyControllerEnabled, hidsysEnableUsbFullKeyController, hidsysIsUsbConnected, hidsysIsFirmwareUpdateNeededForNotification.
2020-12-01 13:49:59 +01:00
yellows8
9bc156a42e
hid: Adjusted param for hidSetNpadCaptureButtonAssignment. 2020-12-01 13:49:58 +01:00
yellows8
27b43dc53b
hid: Updated docs. 2020-12-01 13:49:58 +01:00
yellows8
089f9f18ac
hid: Added the following cmds:
hidSendKeyboardLockKeyEvent, hidDisconnectNpad, hidGetPlayerLedPattern, hidSetNpadJoyAssignmentModeSingle, hidStartLrAssignmentMode, hidStopLrAssignmentMode, hidSwapNpadAssignment, hidEnableUnintendedHomeButtonInputProtection, hidSetNpadJoyAssignmentModeSingleWithDestination, hidSetNpadAnalogStickUseCenterClamp, hidSetNpadCaptureButtonAssignment, hidClearNpadCaptureButtonAssignment, hidIsUsbFullKeyControllerEnabled, hidEnableUsbFullKeyController, hidIsUsbFullKeyControllerConnected, hidGetNpadOfHighestBatteryLevel, hidSetNpadCommunicationMode, hidGetNpadCommunicationMode, hidSetTouchScreenConfiguration, hidIsFirmwareUpdateNeededForNotification.
2020-12-01 13:49:58 +01:00
yellows8
004d2f4f63
hid: Moved funcs to match cmd order. 2020-12-01 13:49:58 +01:00
yellows8
d4ccf6ab03
hid: Added the following cmds:
hidIsSixAxisSensorFusionEnabled, hidEnableSixAxisSensorFusion, hidIsSixAxisSensorAtRest, hidIsFirmwareUpdateAvailableForSixAxisSensor.

Minor adjustments.
2020-12-01 13:49:58 +01:00
fincs
eaeabad315
hid: Add hid{Set,Get}NpadHandheldActivationMode 2020-12-01 13:49:58 +01:00
yellows8
639ba8ef78
hidsys: Updated Hidcfg. 2020-12-01 13:49:57 +01:00
yellows8
73768fffa7
hid: Updated docs. 2020-12-01 13:49:57 +01:00
yellows8
d4b3b1e90f
hidbus: Updated HidbusJoyPollingMode. 2020-12-01 13:49:57 +01:00
yellows8
141f1b6e5d
hid: Updated enums. 2020-12-01 13:49:57 +01:00
yellows8
01457fb3b1
hid: Added hidBeginPermitVibrationSession/hidEndPermitVibrationSession. 2020-12-01 13:49:57 +01:00
yellows8
5c7118a003
hid: Added support for GcErm vibration. Minor adjustments. 2020-12-01 13:49:56 +01:00
yellows8
88cae40620
hid: Added/updated enums and updated HidVibrationDeviceInfo. 2020-12-01 13:49:56 +01:00
fincs
8e0c514044
hid: Added pre-made HidNpadStyleSet values for common style sets 2020-12-01 13:49:56 +01:00
yellows8
1aa4ec82fb
hid: Updated docs. 2020-12-01 13:49:56 +01:00
yellows8
a5799c87ed
hid(dbg): Updated docs + minor adjustments. 2020-12-01 13:49:56 +01:00
yellows8
7a8d397d81
hid: Added HidAnalogStickState and updated structs. 2020-12-01 13:49:56 +01:00
yellows8
f784c9a3f3
hid: Updated structs. 2020-12-01 13:49:55 +01:00
yellows8
ff2846e481
hid: Updated docs + minor struct adjustment. 2020-12-01 13:49:55 +01:00
yellows8
9b808793fb
hid: Updated docs + various adjustments. 2020-12-01 13:49:55 +01:00
yellows8
2b7c3fee90
hiddbg: Use structs for handles and various adjustments. 2020-12-01 13:49:55 +01:00
yellows8
215d62966e
hidsys: Added HidsysUniquePadId/HidsysUniquePadSerialNumber.
These are now used where needed. Various adjustments.
2020-12-01 13:49:55 +01:00
yellows8
012e84d7bd
hid: Updated docs. 2020-12-01 13:49:55 +01:00
yellows8
f9f23bef8f
hid: Replaced the lifo layouts/sixaxis arrays with individual fields.
Use the Lark/Lucia enum in the GetNpadStates funcs.
2020-12-01 13:49:54 +01:00
fincs
aa77de9f71
hid: Added HidNpadButton enum 2020-12-01 13:49:54 +01:00
yellows8
3c13d353b0
hid: Updated _hidGetNpadPowerInfo(). 2020-12-01 13:49:54 +01:00
yellows8
9a2fab817d
hid: Fixed docs. 2020-12-01 13:49:54 +01:00
yellows8
7c64b5b70b
hid: Updated HidNpadSystemProperties. 2020-12-01 13:49:54 +01:00
yellows8
912713bda0
hid: Added XcdDeviceHandle. 2020-12-01 13:49:54 +01:00
yellows8
5e03104d1d
hid: Updated structs. 2020-12-01 13:49:53 +01:00
yellows8
dab3750c50
hid: Updated HidMouseButton/HidKeyboardModifier. 2020-12-01 13:49:53 +01:00
yellows8
4149481608
hid: Fix comment. 2020-12-01 13:49:53 +01:00
yellows8
d3838b8e08
hid: Gesture support. Updated HidNpadSystemProperties. 2020-12-01 13:49:53 +01:00
yellows8
324a835b0c
hid: Various fixes. 2020-12-01 13:49:53 +01:00
yellows8
d28776e4d9
hid: Updated/added structs/enums. 2020-12-01 13:49:52 +01:00
yellows8
902af6cce0
hid: Updated structs. 2020-12-01 13:49:52 +01:00
fincs
967a5054a3
hid: Expose InitializeNpad/TouchScreen/Keyboard/Mouse
- Moved hidScanInput-specific initialization code to hidScanInput
- TouchScreen/Keyboard/Mouse are now activated during hidScanInput
  initialization (previously this was not done, which is technically UB)
- Removed hidDeactivateNpad (not called by retail software)
- Tweaks and adjustments to reduce code size when features are not used
2020-12-01 13:49:52 +01:00
yellows8
e4c701dc19
hid: Use _hidGetStates in hidGetSevenSixAxisSensorStates. 2020-12-01 13:49:52 +01:00
yellows8
d4c1d069f1
hid: Added hidGetKeyboardStates, which hidScanInput now uses.
Struct adjustments.
2020-12-01 13:49:52 +01:00
yellows8
52bf73e047
hid: Added hidGetMouseStates, which hidScanInput/etc now uses.
Struct adjustments.
2020-12-01 13:49:52 +01:00
yellows8
dc0bc2ab7b
hid: Fixed memset in hidJoystickRead(). 2020-12-01 13:49:51 +01:00
yellows8
1c82758c03
hid: Added hidGetTouchScreenStates, which hidScanInput now uses.
Struct adjustments.
2020-12-01 13:49:51 +01:00
fincs
2c26092608
hid: Implement hidSixAxisSensorValuesRead using hidGetSixAxisSensorStates + other minor adjustments 2020-12-01 13:49:51 +01:00
yellows8
e32acbeb9f
hid: Added hidGetSixAxisSensorStates.
Internal improvements, etc.
2020-12-01 13:49:51 +01:00
yellows8
16ff35faea
hid: Use structs for vibration/SixAxis handles.
Various internal improvements, andpass vibration handles by value where needed.
2020-12-01 13:49:51 +01:00
fincs
c0ef14fcaa
hid: Changed hidGetNpadStates* to return total_out directly instead of using an output var 2020-12-01 13:49:51 +01:00
fincs
0640c9da76
hid: Introduce HidNpadIdType, see details:
- Replaced most usages of HidControllerID with HidNpadIdType
- HidControllerID still exists for now, and the following functions
  keep accepting it for compatibility with most homebrew:
  - hidIsControllerConnected
  - hidKeysHeld/Down/Up
  - hidJoystickRead
  - hidSixAxisSensorValuesRead
- hidControllerIDTo/FromOfficial renamed to ToNpadIdType/FromNpadIdType
- Updated some comments that were left untouched during previous hid refactoring
- Partial internal refactor of hidGetNpadStates*
2020-12-01 13:49:50 +01:00
fincs
40e5b08f70
Split hidGetNpadControllerColor/PowerInfo into Single/Split variants 2020-12-01 13:49:50 +01:00
yellows8
3f4f6dba44
hid: Handle NULL with hidGetNpadStates*() total_out.
Use const for hidSetSupportedNpadIdType().
2020-12-01 13:49:50 +01:00
yellows8
82bc8bf648
hid: Updated docs. 2020-12-01 13:49:50 +01:00
yellows8
a924fac0ab
hid: Filled in the Gc trigger fields. 2020-12-01 13:49:50 +01:00
yellows8
5aaf6905dd
hid: Docs updated. 2020-12-01 13:49:50 +01:00
yellows8
9f13045546
hid: Added support for NpadGc.
Struct adjustments.
2020-12-01 13:49:49 +01:00
yellows8
7340772267
hid: Internal state reading improvements.
Struct adjustments.
2020-12-01 13:49:49 +01:00
yellows8
21647a76c8
hid: Added support for *Lark/Lucia.
Struct adjustments.
2020-12-01 13:49:49 +01:00
yellows8
ce20e14034
hid: Added hidGetNpadStatesPalma. 2020-12-01 13:49:49 +01:00
yellows8
46377bc180
hid: Added handling for NpadSystem(Ext).
Added hidGetNpadStatesSystemExt/hidGetNpadStatesSystem, and functionality for using these in hidScanInput().

Updated a struct.
2020-12-01 13:49:49 +01:00
yellows8
db39de34c5
hid: Replaced various funcs with versions which read from sharedmem.
* Various struct adjustments.
* Removed HidControllerLayoutType/hidSetControllerLayout/hidGetControllerLayout, since these are no longer used.
* Added HidNpadJoyAssignmentMode and hidGetNpadJoyAssignment.
* Replaced hidGetControllerFlags with hidGetNpadSystemProperties/hidGetNpadSystemButtonProperties.
* Added hidGetAppletFooterUiAttributesSet/hidGetAppletFooterUiTypes.
* hidScanInput() now uses hidGetNpadStates*() as determined by the output from hidGetNpadStyleSet().
2020-12-01 13:49:48 +01:00
yellows8
1e3145f81d
hid: Struct adjustments. 2020-12-01 13:49:48 +01:00
yellows8
54a296bc69
hid: Updated HidSharedMemory. 2020-12-01 13:49:48 +01:00
yellows8
c3a6d29cf4
hid: Added KEY_NES_HANDHELD_LEFT_B. 2020-12-01 13:49:48 +01:00
yellows8
991a262e19
hid: Replaced HidControllerType with HidNpadStyleTag.
HidNpadStyleTag now includes more controllers.

Replaced hidGetControllerType with hidGetNpadStyleSet().

Improved _hidGetDeviceHandles(), more controllers are now supported.
2020-12-01 13:49:48 +01:00
yellows8
e74c605a91
hid: Fixed HidNpadInterfaceType. 2020-12-01 13:49:48 +01:00
yellows8
ddc9538b69
hid: Updated/added structs and added hidGetNpadStates*(). 2020-12-01 13:49:47 +01:00
fincs
74b295827f
Add svcGetResourceLimitPeakValue [11.0.0+] 2020-12-01 13:49:15 +01:00
SciresM
8ce231e7c9
ldr: update SetProgramArguments for 11.0.0 abi change (#507) 2020-12-01 12:01:33 +01:00
Michael Scire
e5ae43f4c2 results: use R_VALUE for comparisons 2020-12-01 02:26:26 +01:00
Luis Scheurenbrand
c95b46c053 news: fix structs 2020-11-18 19:16:32 +01:00
averne
2fdae0db52
Add service wrappers for ins:r and ins:s (#502) 2020-11-08 00:28:20 +01:00
fincs
091f88915d
virtmemRemoveReservation: add forgotten mutex note to docs 2020-10-31 14:06:48 +01:00
fincs
22a3efcbe1
virtmem: Deprecate virtmemReserve/virtmemFree 2020-10-30 16:10:52 +01:00
fincs
8310f438ca
virtmem: Add memory reservation system
jit: Use virtmemFindCodeMemory on both codepaths; use virtmem reservations
in order to support the JitType_SetProcessMemoryPermission codepath
2020-10-30 16:07:38 +01:00
fincs
490d96e6eb
virtmem: Add virtmemFindCodeMemory to work around a quirk in 1.x kernel 2020-10-30 00:16:03 +01:00
fincs
eecf2a9d32
Add detectMesosphere() 2020-10-29 16:52:16 +01:00
fincs
970d982e57
Add diagAbortWithResult, see details:
- This is a (weak/overridable) function meant to be called when the
  program encounters an unrecoverable error, but it's not fatal enough
  to bring down the entire system with it.
- The default implementation uses svcBreak, passing the result code
  in the user buffer.
- Replaced all usages of fatalThrow with diagAbortWithResult throughout
  the entire library.
2020-10-29 13:40:35 +01:00
fincs
a05a44fca8
virtmem: Major rewrite to support ASLR, see details:
- Added virtmemLock/Unlock, needed for atomic find-and-map operations
- Added virtmemFindAslr, which looks for a random free area in AslrRegion
  - virtmemReserve still exists for legacy callers who rely on sequential
    allocation in order to avoid race conditions from concurrent uses
- Added virtmemFindStack, which searches within StackRegion instead
  - Removed virtmemReserveStack/FreeStack
- Changed shmem/thread/tmem/codememory-jit to use the new virtmem API
  - Legacy jit still uses virtmemReserve
2020-10-27 12:27:32 +01:00
fincs
e655b48c41
crt0: clean up/refactor; envSetup: properly detect NSO/NRO environment... 2020-10-27 12:27:32 +01:00
fincs
7c6d7849f5
Remove obsolete kernel detection code 2020-10-27 12:27:32 +01:00
fincs
8d51f7de1c
jit: Transfer the responsibility of detecting whether CodeMemory syscalls are available/usable to the homebrew environment 2020-10-27 12:27:31 +01:00
fincs
d0d64ce1ce
fatalThrow: use hosversion instead of kerneldetect (and remove old alias) 2020-10-27 12:27:31 +01:00
fincs
4c6abe1e41
svcBreak: fix prototype, add and use BreakReason enum 2020-10-27 12:27:31 +01:00
fincs
e0c1dfe2ce
Add light event synchronization primitive [4.0.0+] 2020-10-27 12:27:20 +01:00
Michael Scire
dee3a7a241 gpio: loosen sysver restriction on OpenSession 2020-10-26 11:55:03 +01:00
Michael Scire
0ff42ee69e gpio: implement majority of the service 2020-10-26 11:48:07 +01:00
yellows8
8718c145f6
lp2p: Updated docs. 2020-10-25 19:55:33 -04:00
yellows8
8a31abeea7
Added lp2p. 2020-10-25 14:00:44 -04:00
averne
022887ac2d Fix event handle retrieval in spl 2020-10-04 00:20:16 +02:00
Vicki Pfau
4afec4016d psm: Add more battery functions 2020-09-28 00:36:35 +02:00
yellows8
f01fb21da5
Added uart. 2020-09-12 18:53:30 -04:00
yellows8
ab59dfb5bb
btdrv: Updated docs for BtdrvBluetoothPropertyType_Unknown3. 2020-09-04 11:59:35 -04:00
yellows8
625616bd44
btm: Update the right struct, BtmDeviceInfoList. 2020-08-26 19:10:38 -04:00
yellows8
9febf780b1
btm: Updated BtmDevicePropertyList. 2020-08-26 19:03:55 -04:00
yellows8
cc2be8375a
btm: Updated BtmHostDeviceProperty. 2020-08-26 12:28:32 -04:00
yellows8
cccef0c525
audout: Properly pass the aruid in audoutOpenAudioOut, fixes #197. 2020-08-21 13:32:31 -04:00
yellows8
ac8ac4919e
set: Updated for [10.1.0+], added more cmds, use struct for nickname. 2020-08-20 23:20:10 -04:00
yellows8
797cdffb14 btdrv: Updated BtdrvBleScanResult. 2020-08-20 18:38:55 -04:00
yellows8
5820178f56 btdrv: Updated param order. 2020-08-20 18:38:55 -04:00
yellows8
89358ba98c btdrv: Use const for btdrvWriteHidData/btdrvSetHidReport. 2020-08-20 18:38:55 -04:00
yellows8
c669589a35 bluetooth: Updated params, improved docs, etc. 2020-08-20 18:38:55 -04:00
yellows8
8718ea3659 Added btdev. 2020-08-20 18:38:55 -04:00
yellows8
4fae8554f7 btdrv/btm: Updated/added various structs. 2020-08-20 18:38:55 -04:00
yellows8
4db3c621e8 set: Use BtdrvAddress. 2020-08-20 18:38:55 -04:00
yellows8
3b670bc652 btdrv: Added the remaining cmds, various fixes, and added a types .h. 2020-08-20 18:38:55 -04:00
yellows8
ab9ce7c330 btdrv: Added support for pre-4.0.0, etc. 2020-08-20 18:38:55 -04:00
yellows8
8789077bb8 btm: Added the aruid cmds. 2020-08-20 18:38:55 -04:00
yellows8
070e959609 btm: Added more cmds. 2020-08-20 18:38:55 -04:00
yellows8
abf3600724 Added btm, moved btmu structs into btm, and updated docs. 2020-08-20 18:38:55 -04:00
yellows8
5551fcfab6 btmu/btdrv: Use bool flag where needed and updated docs. 2020-08-20 18:38:55 -04:00
yellows8
1442280447 btmu: g_btdrvIBtmUserCore -> g_btmuIBtmUserCore 2020-08-20 18:38:55 -04:00
yellows8
e7fbdf9eb1 Added btmsys. 2020-08-20 18:38:55 -04:00
yellows8
6ad9bd15d5 btmu: Updated docs. 2020-08-20 18:38:55 -04:00
yellows8
4e0fcb105d btdrv/btmu: Updated structs. 2020-08-20 18:38:55 -04:00
yellows8
94464baf38 btdrv/btmu: Various improvements. 2020-08-20 18:38:55 -04:00
yellows8
9439243649 Added btmu and added btdrv structs. 2020-08-20 18:38:55 -04:00
yellows8
a771f06a0e btdrv: Fixed btdrvGetHidReport IPC, updated docs, and added an enum. 2020-08-20 18:38:55 -04:00
yellows8
354e7d84fd btdrv: Added btdrvTriggerConnection. 2020-08-20 18:38:55 -04:00
yellows8
bc16eb227b btdrv: Updated the BtdrvBleAdvertisePacketData struct. 2020-08-20 18:38:55 -04:00
yellows8
045f6477d9 btdrv: Added cmds:
btdrvSetBleVisibility, btdrvSetBleAdvertiseData, btdrvSetBleAdvertiseParameter, btdrvRegisterGattClient, btdrvUnregisterGattClient, btdrvUnregisterAllGattClients, btdrvGetGattAttribute, btdrvGetGattService, btdrvRegisterGattServer, btdrvUnregisterGattServer, btdrvConnectGattClient, btdrvDisconnectGattClient, btdrvAddGattService, btdrvEnableGattService, btdrvAddGattCharacteristic, btdrvAddGattDescriptor, btdrvGetBleManagedEventInfo, btdrvGetGattFirstCharacteristic, btdrvGetGattNextCharacteristic, btdrvGetGattFirstDescriptor, btdrvGetGattNextDescriptor, btdrvRegisterGattManagedDataPath, btdrvUnregisterGattManagedDataPath, btdrvRegisterGattHidDataPath, btdrvUnregisterGattHidDataPath, btdrvRegisterGattDataPath, btdrvUnregisterGattDataPath.
2020-08-20 18:38:55 -04:00
yellows8
e0ee2ffc86 btdrv: Added btdrvGetEventInfo/btdrvGetHidEventInfo, etc. 2020-08-20 18:38:55 -04:00
yellows8
0075672b93 btdrvGetLeEventInfo -> btdrvGetLeHidEventInfo 2020-08-20 18:38:55 -04:00
yellows8
b15a583b80 btdrv: Added more cmds and the required enum:
btdrvGetLatestPlr, btdrvEnableTxPowerBoostSetting, btdrvIsTxPowerBoostSettingEnabled, btdrvEnableAfhSetting, btdrvIsAfhSettingEnabled, btdrvGetChannelMap, btdrvMoveToSecondaryPiconet, btdrvIsManufacturingMode, btdrvEmulateBluetoothCrash, btdrvGetBleChannelMap.
2020-08-20 18:38:55 -04:00
yellows8
b18912980e btdrv: Added HidReportEventInfo support. 2020-08-20 18:38:55 -04:00
yellows8
2878b97f3a btdrv: Added cmds:
btdrvGetAdapterProperties, btdrvGetAdapterProperty, btdrvSetAdapterProperty, btdrvWriteHidData, btdrvWriteHidData2, btdrvSetHidReport, btdrvGetHidReport.

Added/updated the required enum/struct.

bt(drv): Updated docs.
2020-08-20 18:38:55 -04:00
yellows8
7e06e0e657 btdrv: Use InitializeBluetoothDriver during init. 2020-08-20 18:38:55 -04:00
yellows8
a5e8572019 Added initial bluetooth support. 2020-08-20 18:38:55 -04:00
yellows8
bcc0f86aa3
hidbus/ringcon: Fixed cleanup, this also fixed a crash. 2020-08-20 13:28:26 -04:00
HookedBehemoth
9a1e3aeb47
add news service wrapper (#493) 2020-08-04 19:37:34 +02:00
fincs
1b95c09a27
switch.ld: update init_array/fini_array handling for latest devkitA64 2020-07-25 18:26:33 +02:00
Adubbz
ed16b7f948 hiddbg: implement DeactivateHomeButton 2020-07-07 12:35:37 +02:00
SciresM
b8a095ac2f
fs: add missing AccessLog functions. (#491) 2020-07-03 00:03:36 +02:00
Michael Scire
e36c7a760f err: add ErrorContextType enum 2020-06-27 12:52:01 +02:00
yellows8
e2db987144
web: Added WebSession support. 2020-06-24 10:39:18 -04:00
yellows8
6620dfaa6f
applet: Added get-event funcs:
appletHolderGetExitEvent and expose appletHolderGetPopInteractiveOutDataEvent.
2020-06-24 10:35:30 -04:00
yellows8
a0ce273019
ssl: Improved docs. 2020-06-21 13:16:34 -04:00
Ezekiel Bethel
d0a7c6a2a5
fix return value of romfs_stat for non-existent files/directories (#488) 2020-06-18 10:58:12 +01:00
yellows8
044eac2f3d
web: Updated for 10.x. 2020-06-15 15:40:05 -04:00
yellows8
3d4f61735a
swkbd: Updated for 10.x and added:
swkbdInlineGetMaxHeight, swkbdInlineGetTouchRectangles, swkbdInlineIsUsedTouchPointByKeyboard.
2020-06-14 00:03:19 -04:00
yellows8
42568d6af8
swkbd: Adjusted the order in the .h. 2020-06-11 22:51:48 -04:00
yellows8
857e2f5c4d
swkbd: Added proper support for using SwkbdInlineMode_UserDisplay. 2020-06-11 22:40:14 -04:00
yellows8
29dd63e5db
Added support for nifmLa. Added nifmRequestGetAppletInfo. 2020-06-11 19:00:07 -04:00
yellows8
05badbdc29
miiLa: Minor docs adjustment. 2020-06-09 22:03:17 -04:00
yellows8
7940d8e9e1
Added support for the miiLa libapplet (MiiEdit). 2020-06-09 22:01:15 -04:00
yellows8
9dc185ba3c
Added support for libapplet nfpLa (amiibo). 2020-06-06 22:40:28 -04:00
HookedBehemoth
ac468913e4
add commands for accessing process storage (#485) 2020-06-06 15:13:23 +02:00
yellows8
eb9d377320
hid: Implemented the remaining functionality for supporting SevenSixAxisSensor, and added the required structs. Updated hidInitializeSevenSixAxisSensor for the [10.0.0+] change. 2020-06-01 12:11:24 -04:00
fincs
bce0ea871d
libnx v3.3.0 2020-05-27 16:52:38 +02:00
Dave Murphy
db795f42ad fix stat for romfs directories 2020-05-27 14:59:43 +02:00
Ezekiel Bethel
573e2f772c add lstat to fs_dev and romfs_dev 2020-05-26 17:32:54 +02:00
yellows8
17ebe4104a
ldn: Updated structs. 2020-05-24 12:34:43 -04:00
yellows8
ff931da962
ldn: Updated structs etc. 2020-05-19 17:30:50 -04:00
yellows8
6e92692043
ldn: Updated LdnNetworkInfo struct. 2020-05-18 22:46:53 -04:00
yellows8
07ba98b702
ldn: Filled in LdnAcceptPolicy, updated LdnNetworkInfo, and updated docs. 2020-05-18 16:02:41 -04:00
yellows8
2f25c57d0e
ldn: Updated structs. 2020-05-18 14:57:22 -04:00
yellows8
55c0205de0
ldn: Updated structs and docs. 2020-05-18 12:51:14 -04:00
yellows8
7bf43fefea
ldn: Updated structs/docs. 2020-05-17 19:54:25 -04:00
yellows8
02ed902558
Added support for ldn. 2020-05-17 15:49:23 -04:00
Michael Scire
3d726ed78c mutex: rewrite to optimize 2020-05-17 17:46:59 +02:00
yellows8
3c08ce6936
nifm: Added support for IRequest. 2020-05-12 23:32:20 -04:00
fincs
d1f4b11f9a
libnx v3.2.0 2020-05-11 20:28:37 +02:00
Michael Scire
4f401256b0 psc: correct version for pscPmModuleAcknowledge 2020-05-07 12:29:43 +02:00
yellows8
3971f3e053
ssl: Updated docs. 2020-05-05 21:51:40 -04:00
yellows8
de27e7b171
ssl: Improved docs. 2020-05-03 12:43:29 -04:00
Dave Murphy
c7130a785a fix string truncation warning 2020-05-03 00:58:03 +02:00
Dave Murphy
5b879cbb0e remove unreferenced struct 2020-05-03 00:58:03 +02:00
yellows8
2e41795194
ssl: Improved docs. 2020-05-02 12:02:22 -04:00
yellows8
bcdbd89292
ssl: Updated docs. 2020-05-01 22:49:51 -04:00
yellows8
8fcd1b2afa
ssl: Improved docs. 2020-04-30 12:26:43 -04:00
yellows8
ea77c1d4cb
ssl: Improved the SslVersion enum and updated the param type for sslCreateContext. 2020-04-29 12:26:44 -04:00
yellows8
3f5362a7bb
ssl: Updated docs. 2020-04-28 00:36:24 -04:00
fincs
b0494c1acb
Update outdated comments and naming in jit.h/c 2020-04-27 13:46:55 +02:00
Adubbz
dbc4b759e2 set: fix GetGyroscopeOffset 2020-04-26 16:52:28 +02:00
yellows8
3b2b3ebad4 socket-ssl: Updated docs. Check for output sockfd=-1 from the cmd with socketSslConnectionSetSocketDescriptor. 2020-04-24 16:39:22 -04:00
yellows8
41e90ef8b5 ssl: Updated params and docs + various improvements. Added sslConnectionGetServerCertDetail and the required structs. 2020-04-24 16:39:22 -04:00
yellows8
41aefdc5ee ssl/socket: Added socketSslConnectionSetSocketDescriptor/socketSslConnectionGetSocketDescriptor wrappers, and updated ssl for this. 2020-04-24 16:39:22 -04:00
yellows8
613fa855da ssl: Implemented the remaining ISslConnection cmds. Expose the total_out param for sslGetCertificates. Various improvements / updated docs. 2020-04-24 16:39:22 -04:00
yellows8
60e4ee04b0 Added initial support for the ssl service. 2020-04-24 16:39:22 -04:00
HookedBehemoth
8e245a0ba8
add capssc 1201-1203 debug calls (#408) 2020-04-24 22:10:42 +02:00
SciresM
8cbac97466
capssc: Add CaptureJpegScreenShot (#407) 2020-04-23 00:07:03 +02:00
yellows8
20fd5bb9a2
nacp: Updated the nacp struct, and added/updated structs for it. 2020-04-20 20:05:31 -04:00
yellows8
cc7fb493e1
hidsys: Added support for all of the [10.0.0+] ButtonConfig cmds, and the required enum/structs. 2020-04-20 18:46:42 -04:00
SciresM
06bebed819
caps: correct CapsScreenShotDecodeOption (#406) 2020-04-20 18:56:31 +02:00
Michael Scire
6fae441714 ns: fix appman getter funcs on 3.0.0-5.0.2 2020-04-20 12:36:50 +02:00
fincs
a1af4494bf
Add nvGpuChannelGetErrorInfo, see details:
- Rename NvError(Type) to NvNotification(Type)
- Introduce NvError struct (output of GetErrorInfo)
- Add nvioctlChannel_GetErrorInfo
2020-04-19 22:18:45 +02:00
fincs
f5e4615a40
nvChannelClose: cleanup fixes 2020-04-19 22:15:32 +02:00
fincs
dc20bf67e9
nvGpuChannelCreate: make channel priority configurable 2020-04-19 22:14:53 +02:00
yellows8
0de0dfdd8d
swkbd: Use appletHolderPresetLibraryAppletGpuTimeSliceZero on [10.0.0+] in _swkbdInlineLaunch. In _swkbdInlineLaunch, use appletHolderClose if needed when errors occur. 2020-04-18 13:25:21 -04:00
yellows8
1925e32c6d
applet: Added support for most of the [10.0.0+] cmds: appletCancelCpuBoostMode, appletActivateMigrationService, appletDeactivateMigrationService, appletCreateManagedDisplaySeparableLayer, appletSetManagedDisplayLayerSeparationMode, appletHolderPresetLibraryAppletGpuTimeSliceZero, appletRequestToSleep, appletApplicationRequestApplicationSoftReset, appletApplicationRestartApplicationTimer, appletSetApplicationMemoryReservation, appletShouldSetGpuTimeSliceManually, appletIsHealthWarningRequired, appletIsHomeButtonShortPressedBlocked. 2020-04-18 13:21:39 -04:00
shchmue
e79c8a2467
Add new 10.0.0 settings calls (#404) 2020-04-18 00:45:53 +02:00
yellows8
b1b80f5493
pdm: Updated for [10.0.0+]. 2020-04-17 14:17:30 -04:00
fincs
4b7921a221
Make nxlink stdio more flexible, see details:
- Added nxlinkConnectToHost with separate flags for redirecting stdout/err
- Added nxlinkStdioForDebug, which only redirects stderr
- (nxlinkStdio now just calls nxlinkConnectToHost)
2020-04-17 16:46:54 +02:00
fincs
4c9b2ac048
Separate debug console code from normal console code, see details:
- consoleDebugInit now lives in a separate source code file
- The devoptab for debugDevice_CONSOLE is now loaded weakly, so that
  normal console code isn't linked in by explicit means
- consoleInit no longer sets up stderr. If stderr to console is desired,
  explicitly use consoleDebugInit(debugDevice_CONSOLE)
- This change makes it possible to use debugDevice_SVC without linking
  in the entire console runtime, which in turn also enabled default
  native window handling (and this can be undesirable)
2020-04-17 16:46:40 +02:00
XorTroll
763b1694ec
Add mii and miiimg services (#402) 2020-04-17 01:28:53 +02:00
Michael Scire
0b93435a44 lr: add lrLrEraseProgramRedirection 2020-04-16 21:24:49 +02:00
Michael Scire
d4c278cf00 pm: rename EnableApplicationExtraThread 2020-04-16 21:24:49 +02:00
Michael Scire
f86dc2ceba pgl: implement full api 2020-04-16 21:24:49 +02:00
yellows8
db14e06fb2
Added a sysver-check for appletOpenMainApplication, it was removed with [10.0.0+]. Added a required-sysver comment for ldrPmSetEnabledProgramVerification. 2020-04-16 13:54:44 -04:00
yellows8
ab715a9a49
bpc: Added a required-sysver check for bpcGetSleepButtonState which was missing. 2020-04-16 13:46:55 -04:00
yellows8
3a22332630
ns: Added/updated required-sysver checks as needed by [10.0.0+], and added nsdevLaunchApplicationFromHost. 2020-04-16 12:38:46 -04:00
HookedBehemoth
a272fa75b9
make pl:s accessible (#400) 2020-04-15 18:18:14 +02:00
Michael Scire
7e581f6110 fix if spacing 2020-04-14 21:29:38 +02:00
Michael Scire
e09ce419ac svc: real definition for 10.x QueryIoMapping 2020-04-14 21:29:38 +02:00
Michael Scire
cb7c1f87a8 svc: QueryIoMapping ABI change in 10.x 2020-04-14 21:29:38 +02:00
Michael Scire
02e4aad9dc pgl: add pglTerminateProcess 2020-04-14 21:29:38 +02:00
Michael Scire
27b34533ac ldr: add ldrPmSetEnabledProgramVerification 2020-04-14 21:29:38 +02:00
Michael Scire
af051c8301 fsp-pr: SetEnabledProgramVerification removed in 10.0.0 2020-04-14 21:29:38 +02:00
Michael Scire
fa0234efff fsldr: update for 10.0.0 2020-04-14 21:29:38 +02:00
yellows8
ca6a48d2b6
irs: Fixed the sysver handling in _irsInitialize(), previously only the values for [4.0.0+] would be used when running on [4.0.0+]. 2020-04-11 23:16:20 -04:00
SciresM
966edb1f0f
set: fix SetRegion, setsysGetSerialNumber (#397) 2020-04-12 03:14:36 +02:00
yellows8
0a9f8261cb
svc: Fixed off-by-one in syscall-number docs. 2020-04-11 15:25:00 -04:00
yellows8
f4c3b288fd
nifm: Added nifmGetCurrentNetworkProfile, nifmGetNetworkProfile, nifmSetNetworkProfile, nifmGetCurrentIpConfigInfo. Internal nifmGetCurrentIpAddress improvements. Added structs: NifmIpV4Address, NifmIpAddressSetting, NifmDnsSetting, NifmProxySetting, NifmIpSettingData, NifmWirelessSettingData, NifmSfWirelessSettingData, NifmSfNetworkProfileData, NifmNetworkProfileData. Various improvements / improved docs. 2020-04-11 13:00:06 -04:00
fincs
fbd97a1fc3
time: minor cleanup in steady clock timepoint calculation 2020-04-11 00:20:21 +02:00
fincs
39629f5a67
timeGetCurrentTime: add shared memory support [6.0.0+] 2020-04-11 00:16:07 +02:00
fincs
b0d96342e8
time: Add timeGetStandardSteadyClockInternalOffset [3.0.0+] 2020-04-11 00:13:21 +02:00
fincs
b4db31e536
time: Expose TimeStandardSteadyClockTimePointType, correct TimeSystemClockContext 2020-04-11 00:08:12 +02:00
fincs
b18ae1c884
time: Add timeGetStandardSteadyClockTimePoint (uses sharedmem on 6.x+, ISteadyClock prior to 6.x) 2020-04-10 19:42:31 +02:00
fincs
2edfb7cc56
time: Retrieve and expose shared memory [6.0.0+] 2020-04-10 17:18:12 +02:00
fincs
bf5331d178
shmemMap: Fix invalid libnx result 2020-04-10 17:16:57 +02:00
yellows8
5e95507cbc
bsd/sockets: Added actual support for recvmsg/sendmsg and sendmmsg/recvmmsg, on [7.0.0+]. 2020-04-09 13:15:07 -04:00
SciresM
4746827513
thread: add threadGetSelf(), add main thread to thread list. (#392) 2020-04-07 01:47:06 +02:00
HookedBehemoth
7dbb90ee66
add remaining IAudioOut commands (#393) 2020-04-06 23:29:27 +02:00
XorTroll
77022a6d11
Fix nfp OpenApplicationArea command (#391) 2020-04-05 13:54:47 -04:00
fincs
d9c3593183
libnx v3.1.0 2020-04-04 23:43:23 +02:00
yellows8
0723df74dd
irs: Updated the IrsPointingProcessorMarkerState struct. 2020-04-04 14:12:26 -04:00
yellows8
c82c8b8760
fs/fs_dev: Added fsOpenReadOnlySaveDataFileSystem and fsOpen_SaveDataReadOnly/fsdevMountSaveDataReadOnly. Minor adjustments. 2020-04-03 19:58:40 -04:00
yellows8
fa52f9b046
fs/fs_dev: Added fsOpen_TemporaryStorage/fsOpen_CacheStorage and fsdevMountTemporaryStorage/fsdevMountCacheStorage. Minor adjustments. 2020-04-03 19:16:26 -04:00
yellows8
918fe2b4d6
fs/fs_dev: Added fsOpen_BcatSaveData/fsOpen_SystemBcatSaveData and fsdevMountBcatSaveData/fsdevMountSystemBcatSaveData. 2020-04-03 11:04:05 -04:00
yellows8
014b02db97
irs: Major overhaul, irs is now properly supported. Functionality for newer system-versions is now supported.
* Updated structs: IrsPackedMomentProcessorConfig, IrsImageTransferProcessorConfig, IrsPackedImageTransferProcessorConfig, IrsImageTransferProcessorState.

* The u32 IrCameraHandle was replaced with struct IrsIrCameraHandle.

* Added various enums/structs, etc. Improved docs.

* irsActivateIrsensor() and irsSuspendImageProcessor() are no longer exposed, these are now used automatically when needed.

* Added the following: irsGetIrCameraStatus, irsCheckFirmwareUpdateNecessity, irsGetImageProcessorStatus, irsStopImageProcessorAsync, irsRunMomentProcessor, irsGetMomentProcessorStates, irsCalculateMomentRegionStatistic, irsRunClusteringProcessor, irsGetClusteringProcessorStates, irsRunImageTransferExProcessor, irsRunPointingProcessor, irsGetPointingProcessorMarkerStates, irsGetPointingProcessorStates, irsRunTeraPluginProcessor, irsGetTeraPluginProcessorStates, irsRunIrLedProcessor, irsRunAdaptiveClusteringProcessor, irsRunHandAnalysis, irsGetMomentProcessorDefaultConfig, irsGetClusteringProcessorDefaultConfig, irsGetDefaultImageTransferProcessorExConfig, irsGetIrLedProcessorDefaultConfig.
2020-04-02 18:38:55 -04:00
yellows8
33425de627
Added UtilFloat3. 2020-04-02 14:42:51 -04:00
SciresM
75c3d2eca4
nim: add ListSystemUpdateTask/DestroySystemUpdateTask (#390) 2020-03-31 21:41:05 +02:00
Michael Scire
5d57c70a3e fix calls to svcSetThreadActivity 2020-03-29 18:42:19 +02:00
Michael Scire
43549f4596 svc: fix definitions to better match kernel 2020-03-29 18:42:19 +02:00
yellows8
b50ac5b322
Added ringcon. (#388)
* Added ringcon.
2020-03-24 22:18:56 -04:00
玻璃兔
3dbafe6183
More keyboard types (#387) 2020-03-20 17:43:44 +01:00
yellows8
f0f21507db
fs/fsdev: Added fsdevMountDeviceSaveData/fsOpen_DeviceSaveData, and minor other adjustments. 2020-03-18 22:33:15 -04:00
cathery
31f871a74f hid: Update the value for JOYSTICK_MIN 2020-03-16 21:02:05 +01:00
fincs
6535d6f871
Remove U64_MAX in favor of using UINT64_MAX 2020-03-16 16:21:33 +01:00
fincs
cacf8615a8
Remove arm/atomics.h (use C <stdatomic.h> or C++ <atomic> instead) 2020-03-16 12:51:07 +01:00
fincs
2c19f13f74
nvFence/nvGpu/nvMap: use service guard instead of unsafe atomic refcnt 2020-03-16 12:48:08 +01:00
yellows8
91b4efb6f5
hidbus: Updated HidbusBusType. 2020-03-14 16:24:29 -04:00
yellows8
83f406b5cb
Added hidbus. 2020-03-14 12:10:50 -04:00
CTCaer
d7e6207708 ts: Add temperature location comments
Avert some confusion about the locations.
HOS uses TMP451 IC's internal thermistor for PCB temp readings and external is connected to a thermistor to SoC's package temp pins, so SoC temp readings.
2020-03-11 16:05:21 +01:00
fincs
8421863c78
applet: appletSetFocusHandlingMode should only be used with Application 2020-03-10 17:42:00 +01:00
shchmue
7ce58f84e0
Complete and correct all Settings calls (#383) 2020-03-10 16:35:11 +01:00
fincs
ccb79ff4b6
NWindow: don't use bqDetachBuffer as it's unnecessary and in fact does nothing in the place it's called (reported by @Thog) 2020-03-10 00:07:04 +01:00
yellows8
bf8f6ae5f5
ns: Use 'static ... const' with servarray. 2020-03-08 17:42:25 -04:00
Michael Scire
afbf2c6f71 fs: be consistent about no stack temps in fsFs 2020-03-08 00:47:01 +01:00
SciresM
c3b0b63471
fs: add IsSignedSystemPartitionOnSdCardValid (#381) 2020-03-07 12:40:02 +01:00
3096
1b1620f7bb apm: add apmGetPerformanceMode 2020-03-06 18:12:10 +01:00
yellows8
44ec13169d
pl: Removed unneeded plExit call from _plInitialize on errors, which is not needed with new-ipc. 2020-03-05 10:39:29 -05:00
yellows8
c85dd5fe2f
ns: Added nsGetDynamicRightsInterface, nsGetReadOnlyApplicationRecordInterface, nsGetApplicationVersionInterface, nsGetAccountProxyInterface, nsGetDocumentInterface. 2020-03-03 16:27:44 -05:00
yellows8
f589c95214
ns: Added support for using the other services as fallback on [3.0.0+] when ns:am2 isn't available. 2020-03-03 14:47:22 -05:00
yellows8
af2b4ab7c3
ns: Added nsGetApplicationManagerInterface(), and removed automatic IApplicationManagerInterface init on [3.0.0+]. Updated all IApplicationManagerInterface cmds to use service-session IApplicationManagerInterface on pre-3.0.0, otherwise nsGetApplicationManagerInterface() is used. Apps which use nsGetServiceSession_ApplicationManagerInterface must now use nsGetApplicationManagerInterface if running on [3.0.0+]. 2020-03-01 15:06:15 -05:00
yellows8
763b32060a
ns: Added nsGetApplicationDesiredLanguage. 2020-02-29 22:39:43 -05:00
yellows8
7822accc22
ns: Added nsGetReadOnlyApplicationControlDataInterface. Use IReadOnlyApplicationControlDataInterface with nsGetApplicationControlData when needed. 2020-02-28 20:10:29 -05:00
yellows8
fdb6aa1f15
ns: Added nsGetECommerceInterface. Added cmds: nsRequestLinkDevice, nsRequestSyncRights, nsRequestUnlinkDevice. Minor adjustments. 2020-02-28 14:36:10 -05:00
HookedBehemoth
7e07d1edf0
add fan service (#376) 2020-02-28 19:23:10 +01:00
HookedBehemoth
abc3522724
lbl: more commands (#377) 2020-02-28 19:13:27 +01:00
HookedBehemoth
23852ad932
add tc (#378) 2020-02-28 17:59:31 +01:00
yellows8
3ff12e7337
ns: Added nsGetDownloadTaskInterface. Added NsDownloadTaskStatus. Added support for IDownloadTaskInterface. 2020-02-27 20:52:14 -05:00
yellows8
424cd0fefe
ns: Check sysver in nsGetFactoryResetInterface, and added nsGetContentManagementInterface. Use IContentManagementInterface with the relevant cmds when needed. Added struct NsApplicationOccupiedSize. Added cmds: nsCalculateApplicationOccupiedSize, nsCheckSdCardMountStatus, nsCountApplicationContentMeta, nsIsAnyApplicationRunning. 2020-02-26 22:38:13 -05:00
yellows8
8ae9b5e1a9
ns: Added nsGetFactoryResetInterface(). Added support for IFactoryResetInterface. Improved docs, etc. 2020-02-26 17:36:15 -05:00
yellows8
4a493775b4
ns: Added support for nsDeleteUserSaveDataAll()/NsProgressMonitorForDeleteUserSaveDataAll. Added struct NsProgressForDeleteUserSaveDataAll. 2020-02-25 15:07:47 -05:00
yellows8
524e910268
ns: Added nsListApplicationTitle and nsListApplicationIcon. 2020-02-22 23:58:27 -05:00
yellows8
129b3a95b8
Added support for NsProgressAsyncResult and nsRequestVerifyAddOnContentsRights/nsRequestVerifyApplication. Updated docs. 2020-02-20 22:17:13 -05:00
HookedBehemoth
d8a50a46cf
add caps:c (#375) 2020-02-19 23:32:01 +01:00
shchmue
86a5aa4466
Correct structs and finish adding all set:cal calls (#373) 2020-02-18 19:56:31 +01:00
yellows8
0db4f8a953
ns: Added structs: NsApplicationViewDeprecated, NsApplicationView, NsPromotionInfo, NsApplicationViewWithPromotionInfo. Added cmds: nsGetApplicationViewDeprecated, nsGetApplicationView, nsGetApplicationViewDownloadErrorContext, nsGetApplicationViewWithPromotionInfo, nsGetPromotionInfo. 2020-02-18 10:26:35 -05:00
Michael Scire
73047b09fd spl: fix rsa key accessors on >= 5.x 2020-02-17 23:20:45 +01:00
yellows8
c570cd0a2f
ns: Added NsApplicationRightsOnClient/nsGetApplicationRightsOnClient(). 2020-02-17 15:46:02 -05:00
yellows8
d8d931fe25
ns: Added support for the following cmds: nsRequestApplicationUpdateInfo, nsRequestUpdateApplication2, nsRequestDownloadApplicationControlData, nsRequestCheckGameCardRegistration, nsRequestGameCardRegistrationGoldPoint, nsRequestRegisterGameCard, nsRequestDownloadApplicationPrepurchasedRights, nsRequestNoDownloadRightsErrorResolution, nsRequestResolveNoDownloadRightsError. 2020-02-16 21:33:24 -05:00
yellows8
9bf745524d
nifm: Added NifmClientId and nifmGetClientId/nifmIsAnyInternetRequestAccepted. 2020-02-15 12:32:50 -05:00
fincs
c4ebdb4cd8
Fix #371 2020-02-12 00:47:03 +01:00
yellows8
68d6260d72
ns: Actually check the required sysver for nsListApplicationContentMetaStatus. Updated param types for nsGetTotalSpaceSize/nsGetFreeSpaceSize + minor other improvements. Added support for the following:
* NsRequestServerStopper/nsRequestServerStopperClose().
* nsGetApplicationRecordUpdateSystemEvent, nsDeleteApplicationEntity, nsDeleteApplicationCompletely, nsDeleteRedundantApplicationEntity, nsIsApplicationEntityMovable, nsMoveApplicationEntity, nsCancelApplicationDownload, nsResumeApplicationDownload, nsCheckApplicationLaunchVersion, nsCalculateApplicationDownloadRequiredSize, nsCleanupSdCard, nsGetSdCardMountStatusChangedEvent, nsGetGameCardUpdateDetectionEvent, nsDisableApplicationAutoDelete, nsEnableApplicationAutoDelete, nsSetApplicationTerminateResult, nsClearApplicationTerminateResult, nsGetLastSdCardMountUnexpectedResult.
* nsGetRequestServerStopper, nsCancelApplicationApplyDelta, nsResumeApplicationApplyDelta, nsCalculateApplicationApplyDeltaRequiredSize, nsResumeAll, nsGetStorageSize, nsDeleteUserSystemSaveData, nsDeleteSaveData, nsUnregisterNetworkServiceAccount, nsUnregisterNetworkServiceAccountWithUserSaveDataDeletion, nsGetGameCardMountFailureEvent, nsIsGameCardInserted, nsEnsureGameCardAccess, nsGetLastGameCardMountFailureResult, nsListApplicationIdOnGameCard, nsTouchApplication, nsIsApplicationUpdateRequested, nsWithdrawApplicationUpdateRequest, nsIsAnyApplicationEntityInstalled, nsCleanupUnavailableAddOnContents, nsFormatSdCard, nsNeedsSystemUpdateToFormatSdCard, nsGetLastSdCardFormatUnexpectedResult, nsGetApplicationTerminateResult.
2020-02-10 12:14:40 -05:00
yellows8
52a892ca31
ns: Fixed cmd order. 2020-02-06 20:07:02 -05:00
HookedBehemoth
2486175f55
add jpegdec/caps:dc (#369) 2020-01-31 17:53:07 +01:00
HookedBehemoth
c28d736ff0 fs: add fsOpenImageDirectoryFileSystem and FsImageDirectoryId 2020-01-28 20:39:41 -05:00
yellows8
6c706d910f
set: Fixed the required sysver for setsysGetHomeMenuScheme. 2020-01-25 13:47:39 -05:00
yellows8
b83ddf8157
hid: Updated the value for JOYSTICK_MAX. 2020-01-23 18:54:51 -05:00
fincs
04214ea441
romfs_dev: fix reading into buffers with device mappable attribute 2020-01-22 00:56:34 +01:00
yellows8
5a751ea0c3
Fixed definitions for ldrShellFlushArguments/ldrDmntFlushArguments and spl*GetServiceSession. Removed fsldrSetCurrentProcess from the .h. Closes #366. 2020-01-21 16:09:28 -05:00
SciresM
e5c501e5b6 svc: Add all missing SVC stubs (#364) 2020-01-18 21:39:05 +01:00
HookedBehemoth
446aaf2a55 add capsa IAlbumAccessorSession and more capsa calls (#363)
* add capsa IAlbumAccessorSession

* add documentation for capsa and change parameter order and names for image loading

* add CapsLoadAlbumScreenShotImageOutput for caps:a

* add remaining LoadAlbumScreenShot- calls

* add more calls, add structs and add doc

* fix query and use count instead of size for listing
2020-01-16 19:29:28 -05:00
fincs
7e6ff7e486
Simplify appletGetAppletResourceUserId and related logic 2020-01-17 00:18:55 +01:00
yellows8
9c4ab7f09d
hid: Fixed cmd order. 2020-01-14 21:48:18 -05:00
yellows8
c8b8c7b0f0
hid: Added enum HidGyroscopeZeroDriftMode. Added hidSetGyroscopeZeroDriftMode, hidGetGyroscopeZeroDriftMode, and hidResetGyroscopeZeroDriftMode. 2020-01-14 21:45:04 -05:00
yellows8
583d6bb92d
hid: Fixed vibration, toggling vibration-enable off->on is no longer needed. Properly closes #148. 2020-01-12 12:25:16 -05:00
yellows8
cbe9fae600
hid: Added hidSetSixAxisSensorFusionParameters, hidGetSixAxisSensorFusionParameters, and hidResetSixAxisSensorFusionParameters. 2020-01-11 22:37:07 -05:00
yellows8
f040706743
In _hidActivateConsoleSixAxisSensor, use cmd ActivateConsoleSixAxisSensor instead of ActivateSevenSixAxisSensor. 2020-01-09 18:42:06 -05:00
HookedBehemoth
f34de8fb54 added caps:a (#358)
* added caps:a

* change struct names
2020-01-09 15:32:34 -05:00
Pablo Curiel
1719eda9fb Update documentation about fsdevMountDevice() to inform about trailing colons in device names. (#362) 2020-01-02 02:20:32 +01:00
yellows8
1bb1aef2f7
Only init/exit apm from applet with AppletType_Application. Closes #360. 2019-12-23 10:50:52 -05:00
yellows8
f043307e7f
In __libnx_init_time(), use 'NX' for the tzname instead of the actual timezone-name. Using the original tzname causes issues with certain timezones. Closes #353. 2019-12-19 16:22:45 -05:00
yellows8
fb01dd8196
psel: Removed TODO comment. 2019-12-19 16:16:58 -05:00
fincs
ce394330a8
svcSignalProcessWideKey doesn't actually return anything 2019-12-18 00:40:27 +01:00
ITotalJustice
0881fb9e0b Add set:cal service with a few cal functions. (#356)
* Add set:cal service with a few functions
* Added more cal structs`
2019-12-16 16:20:00 -05:00
yellows8
d25bcc486a
Properly fixed __nx_applet_exit_mode handling, previously appletExit() called by _appletExitProcess didn't run since refcount was already 0. Closes #355. 2019-12-14 11:52:40 -05:00
fincs
2f7d9bf026
Delete old IPC 🎉 2019-12-12 02:25:05 +01:00
fincs
d1e5a5d6c8
libnx v3.0.0 2019-12-11 00:40:38 +01:00
yellows8
15490b15f6
applet: Added support for using appletSetHandlingHomeButtonShortPressedEnabled with non-AppletType_OverlayApplet on [9.1.0+]. 2019-12-08 16:45:47 -05:00
yellows8
26876cec38
nacp: Updated field-name style to match rest of libnx. Added NacpSendReceiveConfiguration. Renamed version to display_version. Renamed reserved_x3141 to startup_user_account_option, and renamed reserved_x3142 to reserved_for_user_account_save_data_operation. Added fields send_data_configuration, receivable_data_configurations, jit_configuration_flag, and memory_size. 2019-12-07 18:00:17 -05:00
yellows8
6d75ce4f93
Updated docs for FsGameCardAttribute, and added FsGameCardAttribute_DifferentRegionCupToTerraDeviceFlag/FsGameCardAttribute_DifferentRegionCupToGlobalDeviceFlag. 2019-12-06 22:48:34 -05:00
yellows8
6900a0241c
applet/time/set: Added TimeSteadyClockTimePoint. Updated appletSetDesirableKeyboardLayout/appletGetDesirableKeyboardLayout for using TimeSteadyClockTimePoint.
* Added SetSysUserSelectorFlag, SetSysEulaVersionClockType, SetSysNotificationVolume, SetSysFriendPresenceOverlayPermission, SetSysPrimaryAlbumStorage, SetSysHandheldSleepPlan, SetSysConsoleSleepPlan, SetSysErrorReportSharePermission, SetKeyboardLayout, and SetChineseTraditionalInputMethod.

* Added SetBatteryLot, SetSysUserSelectorSettings, SetSysAccountSettings, SetSysEulaVersion, SetSysNotificationTime, SetSysNotificationSettings, SetSysAccountNotificationSettings, SetSysTvSettings, SetSysDataDeletionSettings, SetSysSleepSettings, SetSysInitialLaunchSettings, and SetSysRebootlessSystemUpdateVersion.

* Added setsysSetLanguageCode, setsysGetAccountSettings/setsysSetAccountSettings, setsysGetEulaVersions/setsysSetEulaVersions, setsysGetNotificationSettings/setsysSetNotificationSettings, setsysGetAccountNotificationSettings/setsysSetAccountNotificationSettings, setsysGetTvSettings/setsysSetTvSettings, setsysGetDataDeletionSettings/setsysSetDataDeletionSettings, setsysGetWirelessCertificationFileSize/setsysGetWirelessCertificationFile, setsysSetRegionCode, setsysGetPrimaryAlbumStorage/setsysSetPrimaryAlbumStorage, setsysGetBatteryLot, setsysGetSleepSettings/setsysSetSleepSettings, setsysGetInitialLaunchSettings/setsysSetInitialLaunchSettings, setsysGetProductModel, setsysGetMiiAuthorId, setsysGetErrorReportSharePermission/setsysSetErrorReportSharePermission, setsysGetAppletLaunchFlags/setsysSetAppletLaunchFlags, setsysGetKeyboardLayout/setsysSetKeyboardLayout, setsysGetRebootlessSystemUpdateVersion, and setsysGetChineseTraditionalInputMethod/setsysSetChineseTraditionalInputMethod.
2019-12-06 21:13:43 -05:00
yellows8
c4bc7b24a0
Added type Uuid and use it where needed. Renamed the c field in NcmPlaceHolderId to uuid. Removed PACKED from WebWifiPageArg/WebWifiReturnValue. 2019-12-03 23:31:01 -05:00
SciresM
afe030f08b rwlock: revamp completely (#350)
Implements rwlockTryReadLock and rwlockTryWriteLock.
Also implements rwlockIsWriteLockHeldByCurrentThread and
rwlockIsOwnedByCurrentThread.

Also re-designs RwLock to have semantics identical to
Nintendo's (nn::os::ReaderWriterLock). The upshot is mostly
that the lock is now fully recursive/write-preferring.
2019-12-03 23:16:40 +01:00
yellows8
4626b50341
ncm_types: Replaced the typedef for NcmContentMetaInfo with an actual struct. Closes #351. 2019-12-03 15:05:29 -05:00
yellows8
bbcabee29f
psel: Number of improvements. Added PselUiMode_NintendoAccountAuthorizationRequestContext. Various naming adjustments. Implemented pselShowUserSelector properly, and added pselShowUserSelectorForSystem/pselShowUserSelectorForLauncher. Use accountIsUserRegistrationRequestPermitted and accountTrySelectUserWithoutInteraction. Added PselUserSelectionPurpose, PselNintendoAccountStartupDialogType, PselUserSelectionSettings, and PselUserSelectionSettingsForSystemService. 2019-12-03 13:34:27 -05:00
yellows8
bd04667eda
Added LibnxError_ShouldNotHappen. 2019-12-03 13:13:32 -05:00
yellows8
42aa0800f7
account: Added accountIsUserRegistrationRequestPermitted and accountTrySelectUserWithoutInteraction. 2019-12-03 13:13:11 -05:00
yellows8
4078de1eff
psel: Various improvements, including proper version handling. Updated names. Renamed/added modes, with sysver docs. Don't use ptrs for input AccountUids. Added pselShowUserCreatorForStarter and pselShowNintendoAccountNnidLinker. Directly return the Result from PselUiReturnArg. Removed the output user param from pselShowUserCreator. 2019-12-01 18:34:50 -05:00
yellows8
5182b57a1d
fs/fs_dev: Added FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard, fsFsIsValidSignedSystemPartitionOnSdCard, and fsdevIsValidSignedSystemPartitionOnSdCard. Improved docs. 2019-11-28 18:51:52 -05:00
yellows8
dea3f140f1
Minor hidLa docs improvement. 2019-11-28 18:47:00 -05:00
yellows8
f00898c4d8
Improved hidLa docs. 2019-11-28 16:11:06 -05:00
yellows8
9f28d0002a
Added support for hidLa (controller libapplet). 2019-11-28 16:04:46 -05:00
yellows8
c9f6100e1c
hid: Added hidGetNpadJoyHoldType. 2019-11-28 15:01:42 -05:00
yellows8
8fe48e8eac
fs/fs_dev/romfs_dev: Updated various types to use s64. Removed the inval param from fsDirRead since it doesn't exist. Renamed fileSize in FsDirectoryEntry to file_size and updated the type. Renamed FsFileSystemQueryType to FsFileSystemQueryId, and renamed FsFileSystemQueryType_SetArchiveBit to FsFileSystemQueryId_SetConcatenationFileAttribute. Renamed fsFsSetArchiveBit to fsFsSetConcatenationFileAttribute. Renamed fsdevSetArchiveBit to fsdevSetConcatenationFileAttribute. Minor other changes. 2019-11-28 14:58:55 -05:00
XorTroll
3925e92828 Add psel (playerSelect) support (#335)
* Add psel (playerSelect) support
2019-11-27 12:50:34 -05:00
yellows8
d94be49cb3
Moved common includes for libapplets into a dedicated internal header + minor other changes. 2019-11-27 11:18:58 -05:00
yellows8
9029e9f38d
Added NcmPackagedContentInfo. 2019-11-23 20:22:29 -05:00
shchmue
1c883145a8 Add FsSaveDataFlag for BIT(3) 2019-11-24 02:17:55 +01:00
fincs
324a3624ac
new-ipc: Introduce serviceCreateNonDomainSubservice in order to avoid calling cmifQueryPointerBufferSize during response parsing and corrupting output data as a result [bug found by @SciresM] 2019-11-21 16:27:36 +01:00
The Dax
cd9f29fc8e Add support for setting/getting the Internet time sync flag.
(IsUserSystemClockAutomaticCorrectionEnabled and 	SetUserSystemClockAutomaticCorrectionEnabled.)
2019-11-20 01:16:23 +01:00
yellows8
bcac85852a
Added InfoType_IsApplication. 2019-11-18 22:30:19 -05:00
yellows8
170942a781
Updated docs for nssuControlSetupToReceiveSystemUpdate. 2019-11-18 16:50:12 -05:00
yellows8
2b6197a51a
hid: Use _hidActivateConsoleSixAxisSensor instead of _hidActivateSevenSixAxisSensor, and moved the code using this to near the start of hidInitializeSevenSixAxisSensor. 2019-11-18 12:38:12 -05:00
yellows8
167bd9e110
hid: Use ActivateNpadWithRevision with the sysver-specific revision value in _hidActivateNpad(), on [5.0.0+]. 2019-11-18 12:25:48 -05:00
yellows8
70ddae58ff
acc/nfc/nifm: Removed *SetServiceType and moved the service_type param into the actual {service}Initialize() funcs. Removed *ServiceType_NotInitialized and updated the *ServiceType enum values. Minor other changes / improved nifm docs. 2019-11-18 10:52:46 -05:00
yellows8
d4c0c2dfeb
Updated notif docs. 2019-11-17 18:40:37 -05:00
yellows8
fcd7e36a9d
Added actual support for notif + improved docs. 2019-11-17 18:25:57 -05:00
yellows8
f181807215
fs/fs_dev: Updated names to match wiki. Updated param names. Renamed FS_SAVEDATA_CURRENT_PROGRAMID to FS_SAVEDATA_CURRENT_APPLICATIONID. Updated field names in FsSaveDataAttribute, FsSaveDataExtraData, FsSaveDataCreationInfo, and FsSaveDataInfo. Updated names for the enum values for FsSaveDataSpaceId, FsSaveDataType, FsSaveDataFlags, and FsGameCardAttribute. Added FsSaveDataSpaceId_SdUser and FsSaveDataSpaceId_SafeMode. Added FsSaveDataType_SystemBcat. Added FsSaveDataRank. Fixed the name for FsGameCardPartition and added FsGameCardPartition_Logo. Renamed FsBisStorageId to FsBisPartitionId, updated the enum value names for it, and added FsBisPartitionId_SignedSystemPartitionOnSafeMode. Improved docs / minor other changes. 2019-11-16 16:07:10 -05:00
yellows8
8216043ea1
applet: Fixed the prefix for *PushToFriendInvitationStorageChannel/*PushToNotificationStorageChannel. Added support for all [9.0.0+] IDebugFunctions cmds. Minor internal changes + improved docs. 2019-11-15 18:08:46 -05:00
yellows8
1e58385bd5
Added appletGetFriendInvitationStorageChannelEvent, appletTryPopFromFriendInvitationStorageChannel, appletGetNotificationStorageChannelEvent, and appletTryPopFromNotificationStorageChannel. Added appletPushToFriendInvitationStorageChannel/appletPushToNotificationStorageChannel. Added friendsGetFriendInvitationNotificationEvent/friendsTryPopFriendInvitationNotificationInfo. Added notif, for adding notifGetNotificationSystemEvent/notifTryPopNotifiedApplicationParameter. 2019-11-15 14:26:29 -05:00
fincs
83649c9768
Fix #346 - sessionmgrClose did not actually close the extra sessions 2019-11-14 17:35:35 +01:00
yellows8
dda6194d0b
Added appletIsForceTerminateApplicationDisabledForDebug. Updated docs. 2019-11-14 11:34:41 -05:00
yellows8
c0115edca1
Added appletSetHealthWarningShowingState and appletGetHealthWarningDisappearedSystemEvent. 2019-11-13 23:41:43 -05:00
yellows8
d24f1ca611
Added appletSetInputDetectionPolicy and AppletInputDetectionPolicy. 2019-11-13 20:53:40 -05:00
yellows8
297e9d97a0
Added appletGetSettingsPlatformRegion/appletSetHdcpAuthenticationActivated and improved docs. 2019-11-13 20:07:26 -05:00
yellows8
d88f67fe30
Added appletPushToAppletBoundChannel and appletTryPopFromAppletBoundChannel. 2019-11-13 18:25:34 -05:00
yellows8
8fc57a4795
Added support for using appletSetTerminateResult via IAppletCommonFunctions, and for using appletGetLaunchStorageInfoForDebug/appletGetGpuErrorDetectedSystemEvent with AppletType_LibraryApplet, on [9.0.0+]. Moved these to a new section in the .h/.c. 2019-11-13 17:52:56 -05:00
yellows8
689430e578
fs: Updated names to match wiki. FsSave->FsSaveDataAttribute, FsSaveCreate->FsSaveDataCreationInfo, and renamed the save field in FsSaveDataExtraData to attr. Updated names for enum values in: FsContentStorageId, FsCustomStorageId, and FsSaveDataSpaceId. Added FsSaveDataSpaceId_ProperSystem and FsFileSystemType_RegisteredUpdate. Various improvements and improved docs. 2019-11-13 14:34:49 -05:00
yellows8
c40f8ecac6
Removed includes which are unneeded due to being included elsewhere, etc. Minor improvements. 2019-11-12 12:45:58 -05:00
yellows8
67eacc8034
Added support for the [9.0.0+] friendsLa functionality. Added AccountNetworkServiceAccountId (and updated friendsLa for this). Added FriendsFriendInvitationGameModeDescription, FriendsFriendInvitationId, and FriendsFriendInvitationGroupId. 2019-11-12 10:24:27 -05:00
yellows8
9ca626fd82
Improved docs. 2019-11-11 19:18:44 -05:00
yellows8
9888df18da
Moved most ncm types into ncm_types.h. Renamed FsStorageId to NcmStorageId, with updated names for some values (now located in ncm_types.h). Various improvements + improved docs. 2019-11-11 18:19:45 -05:00
yellows8
ce570a70f1
romfs_dev: Replaced the romFS_dir()/romFS_file() macros with funcs which have actual bounds-checking, this fixes crashes/hangs when the romfs tables are corrupted. Updated relevant code to handle this / various improvements, and return ENOENT instead of EEXIST where required. 2019-11-11 11:07:46 -05:00
yellows8
cc64ec7236
Added NsReceiveApplicationProgress/NsSendApplicationProgress, updated NsApplicationDeliveryInfo, and improved docs. Added the following: nsSelectLatestSystemDeliveryInfo, nsVerifyDeliveryProtocolVersion, nsHasAllContentsToDeliver, nsCompareApplicationDeliveryInfo, nsCanDeliverApplication, nsListContentMetaKeyToDeliverApplication, nsNeedsSystemUpdateToDeliverApplication, nsEstimateRequiredSize, nsRequestReceiveApplication, nsCommitReceiveApplication, nsGetReceiveApplicationProgress, nsRequestSendApplication, nsGetSendApplicationProgress, nsCompareSystemDeliveryInfo, nsListNotCommittedContentMeta, and nsGetApplicationDeliveryInfoHash. 2019-11-09 21:13:23 -05:00
yellows8
24f77642c9
Updated the NsSystemDeliveryInfo struct. Added nsGetApplicationDeliveryInfo and NsApplicationDeliveryInfo. 2019-11-08 16:11:05 -05:00
cathery
d4c5fbdf0f hiddbg: Add hiddbgIsHdlsVirtualDeviceAttached (#345) 2019-11-07 19:27:13 +01:00
yellows8
5a7f14409e
Updated nssu docs. 2019-11-05 22:34:08 -05:00
yellows8
09423066b0
Updated the type for the size param for ncmContentStorageCreatePlaceHolder. 2019-11-03 22:04:52 -05:00
yellows8
6c7ad3095c
Added setsysGetPctlReadyFlag/setsysSetPctlReadyFlag. Fixed ordering. 2019-11-03 16:39:29 -05:00
yellows8
454244602c
Added setsysGetTouchScreenMode/setsysSetTouchScreenMode and SetSysTouchScreenMode. Minor adjustment. 2019-11-02 16:32:12 -04:00
yellows8
8ee7afca99
Added setsysGetMemoryUsageRateFlag. 2019-11-02 16:08:08 -04:00
yellows8
e5dd8a741d
Added setsysGetHomeMenuScheme and setsysGetHomeMenuSchemeModel. Added SetSysHomeMenuScheme. Minor adjustment. 2019-11-02 15:29:38 -04:00
yellows8
ddafdbd2ac
Minor style adjustment. 2019-11-01 23:00:12 -04:00
yellows8
e6d687990c
Added setsysGetPlatformRegion/setsysSetPlatformRegion and SetSysPlatformRegion. 2019-11-01 22:57:29 -04:00
yellows8
df4bbcf2d7
Use const for various hid vibration funcs. 2019-11-01 19:11:18 -04:00
yellows8
e2b9b09b61
Added hidIsVibrationDeviceMounted. 2019-11-01 19:04:14 -04:00
yellows8
fa27331045
Initialize time by using TimeServiceType/__nx_time_service_type, with the default now being User. 2019-11-01 13:20:55 -04:00
yellows8
1f792cd92f
Various improvements/fixes and improved docs. Added nvGetServiceSession. Return an actual error when the value for determing which service to init is invalid, for services which use *ServiceType/AppletType. Improved cleanup handling. Fixed inverted logic in the spl cleanup define. 2019-10-31 22:53:42 -04:00
yellows8
4981ea02c0
Updated docs to use the updated name of a define. 2019-10-30 10:50:58 -04:00
yellows8
4ab50e3752
Use official naming instead of 'title(ID)'. Use 'uid(s)' instead of 'userID(s)'. Updated various struct field names. Improved docs + minor other improvements. 2019-10-30 10:38:05 -04:00
HookedBehemoth
4f72bc5342 Actually return values for ncmContentMetaDatabaseList and ncmContentMetaDatabaseListApplication (#344) 2019-10-30 02:16:19 +01:00
yellows8
28e06a94ec
usbhs: Swapped the INPUT/OUTPUT endpoint descriptors in UsbHsInterfaceInfo to support [8.0.0+], and convert that struct to the new layout internally when running on pre-8.0.0. Closes #341. 2019-10-29 16:48:20 -04:00
yellows8
ccea53c837
ns: Updated param names for nssuRequestSendSystemUpdate/nssuControlRequestReceiveSystemUpdate and improved docs. 2019-10-29 12:09:10 -04:00
fincs
f062c6ecab
resolver: Clean up and simplify gethostbyname/gethostbyaddr/getnameinfo 2019-10-28 14:04:25 +01:00
fincs
af4a025e9b
sfdnsres: Correct some more parameter names 2019-10-28 13:27:55 +01:00
fincs
0378d553e0
resolver: Minor codestyle fixes 2019-10-28 13:00:07 +01:00
fincs
1e0bcfbf87
resolver: Add commands to configure behavior (most not implemented) 2019-10-28 12:36:43 +01:00
fincs
a2c35fb2e7
sfdnsres: timeout parameter is actually cancel_handle 2019-10-28 12:36:43 +01:00
fincs
26f620dc0e
Split up socket.c + work in progress changes:
- DNS stuff moved to runtime/resolver.c & .h
- Address manipulation functions moved to runtime/util/inet_addr.c
- Removed sfdnsres/nifm handling in runtime/devices/socket.c
- Renamed socketGetLastBsdResult to socketGetLastResult
- Renamed socketGetLastSfdnsresResult to resolverGetLastResult
- gethostid now inits/deinits nifm as needed
- sfdnsres related configuration gone from SocketInitConfig
- Fixed bug in addrinfo deserialization
- getaddrinfo rewritten, hints can now be NULL
- TODO: add back a way to control service discovery/cancel handle
2019-10-28 12:36:29 +01:00
Michael Scire
989893721f ro: rename GetProcessModuleInfo 2019-10-28 12:18:14 +01:00
Michael Scire
8394986e19 ldr: update names 2019-10-28 12:18:14 +01:00
Michael Scire
07ad046acf svc: change TitleId to ProgramId 2019-10-28 12:17:55 +01:00
yellows8
4ecc597d0d
ncm: Renamed the titleID field in NcmProgramLocation to program_id. Minor docs adjustment. 2019-10-28 02:21:23 -04:00
yellows8
9d7f968773
NcmContentMetaKey title_id field renamed to id. 2019-10-27 21:19:49 -04:00
yellows8
622c0509a5
ncm: Added alignas within the NcmContentId struct, and added NcmPlaceHolderId. Use NcmPlaceHolderId instead of NcmContentId where needed. 2019-10-27 19:19:16 -04:00
yellows8
01133f7f6d
Use const for the location param with pmshellLaunchProgram. 2019-10-27 18:22:54 -04:00
fincs
1592b2892f
sfdnsres: Major rewrite using new-ipc, fixed numerous IPC bugs, removed phantom commands 2019-10-27 17:25:53 +01:00
yellows8
b6af00d908
Updated the NsSystemDeliveryInfo struct and added nsGetSystemDeliveryInfo. 2019-10-26 23:40:53 -04:00
yellows8
b0980e4c9f
Fixed the type for key_generation in NcmRightsId. 2019-10-26 22:15:23 -04:00
fincs
5340c7d7dc
Add multithreaded BSD/socket support; revise BSD service type handling so that bsd:u is the default (since it has 22 worker threads as opposed to bsd:s's 11) 2019-10-26 17:26:04 +02:00
fincs
bc13692938
Introduce SessionMgr for managing multiplexed services; change fs to use it 2019-10-26 16:44:32 +02:00
yellows8
051ad2dc60
Improved bool handling, clear IPC in-struct padding, and use serviceAssumeDomain prior to serviceClose in non-_{name}Cleanup funcs. Removed PACKED from the _usbHsIfCtrlXferAsync IPC in-struct. Fixed the code setting the IPC in-struct for _nsCmdRequestSendReceiveSystemUpdate, which is used by nssuRequestSendSystemUpdate/nssuControlRequestReceiveSystemUpdate. Minor other changes. Updated a param name for capsscCaptureRawImageWithTimeout. 2019-10-25 20:29:43 -04:00
yellows8
b4a003e176
fs: Minor improvements. Fixed cmd order. IPC improvements + clear padding in IPC in-struct. Improved bool handling. 2019-10-25 19:35:59 -04:00
yellows8
e833257b65
applet: Minor internal improvements. Updated param type for appletRequestLaunchApplicationWithUserAndArgumentForDebug. Clear IPC in-struct padding, improved bool handling, and use serviceAssumeDomain when closing Service objects outside of _appletCleanup. 2019-10-25 19:24:56 -04:00
yellows8
04179b286d
nfc: Replaced the handle within NfcDeviceHandle with an u8-array. Removed PACKED from the nfpCreateApplicationArea in-struct. Improved bool handling. 2019-10-25 19:11:03 -04:00
yellows8
5700b8f347
fsldr/ldr/spl: Improved bool handling and minor other changes. Fixed IPC input for _ldrAddTitleToLaunchQueue. 2019-10-25 18:56:41 -04:00
fincs
58e1e7e5b6
bsd: Update for new-ipc 2019-10-25 17:19:30 +02:00
yellows8
e5c1e35ede
vi: Renamed viGetDisplayMinimumZ to viGetZOrderCountMin, and renamed viGetDisplayMaximumZ to viGetZOrderCountMax. Updated param types. Clear IPC in-struct padding + minor other changes. 2019-10-24 18:06:33 -04:00
fincs
4ab2384449
fatal: Rename functions/types to match official names more closely 2019-10-24 23:25:07 +02:00
yellows8
a808c53efc
ncm/pm: Added NcmProgramLocation, which is now used by pmshellLaunchProgram (which was renamed). Updated pm names to match wiki. Adjusted order in pm.c/pm.h / minor changes. 2019-10-24 16:42:52 -04:00
yellows8
0d5e51757d
grc: Renamed grcdRead to grcdTransfer and updated the param names for it. 2019-10-23 23:32:33 -04:00
yellows8
e81b63ac00
ncm: Moved the cmd_id param for the internal IPC helper funcs to the last param. 2019-10-23 20:01:27 -04:00
yellows8
ea5dcfddfa
ncm: Renamed NcmNcaId to NcmContentId. Added NcmRightsId struct, which is now used by the RightsId funcs. Updated params / params types, this includes replacing array buf-byte-sizes with entry-count. Fixed handling for ncmContentStorageGetPath/ncmContentStorageGetPlaceHolderPath. Improved bool handling + clear IPC in-struct padding. Minor improvements. 2019-10-23 19:14:04 -04:00
yellows8
e4657c15ce
fspr: Use domains. Clear padding for the fsprRegisterProgram in-struct. 2019-10-23 18:41:01 -04:00
yellows8
42b6af8e07
lr: Use SfBufferAttr_FixedSize in _lrResolvePath(). 2019-10-22 18:53:20 -04:00
fincs
d025041e3d
sm: Introduce and use SmServiceName struct (with better codegen) 2019-10-22 20:10:52 +02:00
yellows8
7103b08740
sm: Minor improvements + IPC input improvements. Minor param type adjustment for smRegisterService. 2019-10-22 10:20:21 -04:00
fincs
e9e392bbe2
binder: Update for new-ipc 2019-10-22 16:11:10 +02:00
Michael Scire
145ad1ba87 virtmem: fix incorrect bounds check 2019-10-22 12:42:07 +02:00
fincs
9e83f82a62
Enhance fsOpen_SystemSaveData/fsdevMountSystemSaveData 2019-10-21 21:15:40 +02:00
fincs
47b0403333
Pass plain AccountUid inputs by value instead of by non-const pointer 2019-10-21 16:57:01 +02:00
fincs
13fbde91b0
fsdev: Added fsdevMountSaveData/SystemSaveData wrappers 2019-10-21 12:38:18 +02:00
fincs
54f6fa5420
fs: Use official method names, document min sysver, correct a few parameters 2019-10-21 12:37:38 +02:00
fincs
c77b88d868
Major cleanup and refactor of fsdev and romfsdev, see details:
fsdev:
- Removed fsdevGetDefaultFileSystem and default-fs handling
- Refactored CWD support to have (dynamically allocated) per-device CWDs
  (CWD support as a whole can be turned off with __nx_fsdev_support_cwd)
- Optimized calls by passing pointer to device through r->deviceData
- Use the per-thread path buffer directly as the argument to FS functions
- Removed redundant cross-device check in fsdev_rename
- Fixed string comparison logic in fsdevFindDevice
- fsdev_fixpath now accepts an input device in order to skip device
  lookup (extensively used along with r->deviceData)
- Mounting a filesystem now automatically sets the default device
  if there wasn't any previous default device (or if it's stdnull)
- fsdevMountSdmc no longer sets cwd to the folder containing the
  executable - this logic was moved to a new internal function
  called on startup by default (and it is now disabled for NSOs)
- Other miscellaneous optimizations

romfsdev:
- Cleaned up romfsMount* functions, removed unused/unnecessary logic
- Changed romfsMount* functions to return real result codes
- Renamed romfsMount to romfsMountSelf and improved documentation
- Removed romfsInitFromFile and romfsInitFromStorage (use Mount instead)
- Added documentation for romfsInit and romfsExit
2019-10-20 22:22:04 +02:00
yellows8
0403c988ba
hidsys: Fixed cmd order. Fixed output size for hidsysGetUniquePadSerialNumber. 2019-10-20 02:35:30 -04:00
fincs
26a0ee4af3
fsdev/romfsdev: Reduce TLS usage by sharing the path buffer 2019-10-20 02:48:04 +02:00
yellows8
a774fb81cc
Added hidsysSetNotificationLedPatternWithTimeout. Updated docs with sysver requirements which were previously missing. 2019-10-19 19:51:51 -04:00
Michael Scire
2e2d227ac7
vi: update for new-ipc 2019-10-20 01:13:40 +02:00
Michael Scire
23950cc10e
lr: update for new-ipc 2019-10-20 01:13:40 +02:00
Michael Scire
9e2df3ad53
ldr: update for new-ipc 2019-10-20 01:13:40 +02:00
Michael Scire
a3e7b1affb
smm: update for new-ipc 2019-10-20 01:13:40 +02:00
Michael Scire
71b44cfb02
psc: update for new-ipc 2019-10-20 01:13:39 +02:00
Michael Scire
61fabbe1bc
i2c: update for new-ipc 2019-10-20 01:13:39 +02:00
Michael Scire
861e9d7c3d
fsldr: assume domain 2019-10-20 01:13:23 +02:00
Michael Scire
7292ddfcd8
fspr: update for new-ipc 2019-10-20 01:11:27 +02:00
Michael Scire
77563f027a
bpc: update for new-ipc 2019-10-20 01:11:26 +02:00
Michael Scire
040767ce57
clkrst: update for new-ipc 2019-10-20 01:11:25 +02:00
Michael Scire
960f99e7a2
pcv: update for new-ipc 2019-10-20 01:11:24 +02:00
Michael Scire
16fde00323
spsm: update for new-ipc 2019-10-20 01:11:23 +02:00
Michael Scire
48905d70d2
gpio: update for new-ipc 2019-10-20 01:11:23 +02:00
yellows8
edcd25bdae
Added hiddbgWriteSerialFlash. 2019-10-19 18:42:45 -04:00
yellows8
ecd6cd73ca
Fixed hiddbgReadSerialFlash. Added hiddbgAcquireOperationEventHandle and hiddbgGetOperationResult. 2019-10-19 12:19:23 -04:00
yellows8
9b44261767
Fixed memset in usbHsEpClose() which was using sizeof() with the wrong struct. Closes #337. 2019-10-18 22:29:20 -04:00
SciresM
415adf5b93 threads: support using existing mem as stack (#336) 2019-10-19 04:25:23 +02:00
fincs
69a63bbee8
fsdev: Reduce TLS footprint for rarely used codepaths 2019-10-19 04:00:50 +02:00
yellows8
5f5d4c9785
pdm: Renamed PdmApplicationEvent to PdmAppletEvent, and renamed pdmqryQueryApplicationEvent to pdmqryQueryAppletEvent. Renamed *entryindex fields in various structs to *entry_index. Updated param types and minor param name adjustments. 2019-10-18 16:53:26 -04:00
fincs
3c610fb2cb
fsdev: Allow directory entry cache size to be configured dynamically 2019-10-18 21:23:11 +02:00
yellows8
d1c045f745
usbhs: Updated for new-ipc. Minor improvements and improved docs. 2019-10-17 23:23:06 -04:00
yellows8
e82819d8a4
usbds: Updated for new-ipc. Added sysver checking. Updated the intf_num param type for usbDsRegisterInterfaceEx, likewise with intf_num fields used elsewhere. Renamed the Service 'h' field in UsbDsInterface/UsbDsEndpoint to 's'. Minor improvements + improved docs.
usbComms: Fixed locking issue which caused a hang in usbCommsInitialize*() when init fails.
2019-10-17 17:34:36 -04:00
yellows8
45bf08bf8d
audren: Updated for new-ipc. Renamed audrenGetServiceSession to audrenGetServiceSession_AudioRenderer. Use the [3.0.0+] *Auto cmd with audrenRequestUpdateAudioRenderer when available. Minor adjustments + improved docs. 2019-10-16 10:14:57 -04:00
yellows8
d40cc55833
audin: Updated for new-ipc. Use the [3.0.0+] *Auto cmds when available. Added count param to audinListAudioIns. Added audinGetServiceSession and audinGetServiceSession_AudioIn. 2019-10-15 19:58:12 -04:00
yellows8
6fb5806d51
audout: Minor internal adjustment. 2019-10-15 19:07:55 -04:00
yellows8
80cc0bb86a
audout: Added audoutGetServiceSession and audoutGetServiceSession_AudioOut. Improved docs. 2019-10-15 18:13:22 -04:00
yellows8
dcafcd0d94
audout: Use the [3.0.0+] *Auto cmds when available. 2019-10-15 17:27:26 -04:00
yellows8
39a67c6c31
audout: Updated for new-ipc. Added count param to audoutListAudioOuts. 2019-10-15 14:07:28 -04:00
yellows8
1526e8e98e
Updated hwopus for new-ipc. Added types.h include to auddev.h/hwopus.h. 2019-10-14 21:07:38 -04:00
yellows8
f4ce807b1b
auddev: Updated for new-ipc and improved docs. 2019-10-14 19:59:04 -04:00
yellows8
98968b45f3
nfc: Replaced HidControllerID usage with struct NfcDeviceHandle. Updated params for nfpListDevices. Minor internal changes. 2019-10-14 17:21:38 -04:00
yellows8
a14cd3a70c
set: Replaced SetSysFlag/setsysGetFlag/setsysSetFlag with dedicated funcs for each flag, which also handles checking sysver now when needed. Fixed cmd order. Improved docs. 2019-10-14 14:31:22 -04:00
yellows8
a489a123c2
grc: Updated for new-ipc and fixed cmd order. 2019-10-13 22:49:06 -04:00
yellows8
67ccc66f15
Changed the nfpu prefix to nfp. Changed the nfcu prefix to nfc. Renamed nfpuIsNfcEnabled to nfcIsNfcEnabled. Added nfpSetServiceType/nfcSetServiceType and the enums for it. Moved nfc service init/exit into seperate funcs nfcInitialize/nfcExit. Renamed NfpuInitConfig to NfcRequiredMcuVersionData, removed it from nfpInitialize() input, and handle it properly as an array. Minor other changes. 2019-10-13 19:38:24 -04:00
yellows8
1a0b5569ab
nfc: Updated for new-ipc. Added sysver check for nfpuAttachAvailabilityChangeEvent which was missing. Fixed the order of cmds. Renamed nfpuGetInterface to nfpuGetServiceSession_Interface. Added nfpuGetServiceSession, nfcuGetServiceSession, and nfcuGetServiceSession_Interface. Various minor changes and improved docs. 2019-10-13 13:36:51 -04:00
yellows8
16e4e9e2b3
hid: Updated for new-ipc. Updated param types. Minor improvements and improved docs. 2019-10-12 12:29:51 -04:00
yellows8
58346564f7
irs: Updated for new-ipc. Improved docs. 2019-10-11 22:35:56 -04:00
yellows8
5b51efe4a8
hiddbg: Updated for new-ipc. Improved docs. 2019-10-11 21:27:32 -04:00
yellows8
55f769e0b8
hidsys: Updated for new-ipc. Updated param types. Fixed cmd order. Fixed _hidsysGetMaskedSupportedNpadStyleSet to actually use the input AppletResourceUserId, not g_hidsysAppletResourceUserId. Added hidsysAcquireSleepButtonEventHandle to the .h, which was previously missing. Minor changes + improved docs. 2019-10-11 15:34:34 -04:00
yellows8
d3376aa816
lbl: Updated for new-ipc and improved docs. 2019-10-11 11:18:51 -04:00
yellows8
d25144afbd
pl: Updated for new-ipc. Updated param types for plGetSharedFontByType and plGetSharedFont. Improved docs and minor other changes. 2019-10-11 01:47:23 -04:00
yellows8
44c45555cd
pctl: Updated for new-ipc. Added pctlGetServiceSession and pctlGetServiceSession_Service. 2019-10-10 22:03:22 -04:00
yellows8
1b610070f5
pdmqry: Updated for new-ipc and updated for using AccountUid. Renamed pdmqryGetUserPlayedApplications to pdmqryQueryRecentlyPlayedApplication. Renamed pdmqryGetUserAccountEvent to pdmqryGetRecentlyPlayedApplicationUpdateEvent. Minor param name adjustment. 2019-10-10 21:06:14 -04:00
yellows8
39288a832e
capssc: Updated for new-ipc. 2019-10-10 13:01:25 -04:00
yellows8
21e35ede7c
capsu: Updated for new-ipc. Updated param types for capsuGetAlbumFileList*(), and updated for using AccountUid. Improved docs. 2019-10-10 12:44:21 -04:00
yellows8
2940833a1b
caps(su): Updated for new-ipc. Updated for using AccountUid. 2019-10-08 22:01:37 -04:00
yellows8
3a1459cf4c
applet: Updated for using AccountUid and improved docs. 2019-10-08 21:05:00 -04:00
yellows8
3e5c129431
fs: Updated for using AccountUid and removed FS_SAVEDATA_USERID_COMMONSAVE. 2019-10-08 18:05:25 -04:00
yellows8
929990b7c8
web/friendsLa: Updated for using AccountUid. Renamed webConfigSetUserID to webConfigSetUid, and renamed WebArgType_UserID to WebArgType_Uid. 2019-10-08 17:44:53 -04:00
yellows8
95f91c431c
account: Updated for new-ipc. Renamed the username field in AccountProfileBase to nickname. Fixed various param types, and also removed the output bool from accountGetLastOpenedUser. Added struct AccountUid for proper userIDs, which replaces u128-userIDs. Added accountUidIsValid. Added accountSetServiceType()/AccountServiceType. Improved docs and minor improvements.
env: Updated UserIdStorage handling for using AccountUid.
2019-10-08 15:41:18 -04:00
yellows8
040b33c457
time: Updated for new-ipc. Renamed _timeGetClockSession to timeGetServiceSession_SystemClock, and added it to the .h. Added timeGetServiceSession_TimeZoneService. Fixed the order of cmds. Fixed param types for timeGetTotalLocationNameCount, timeLoadLocationNameList, timeToPosixTime, and timeToPosixTimeWithMyRule. The location_name_size param for timeLoadLocationNameList was replaced with location_name_max, which is max entries instead of buffer byte-size. Internal improvements and improved docs. 2019-10-06 22:06:22 -04:00
yellows8
ae582d8cb4
Changed the output of appletGetOperationMode/appletGetPerformanceMode to enums AppletOperationMode/ApmPerformanceMode. 2019-10-06 19:05:58 -04:00
yellows8
71e249e6a4
apm: Updated for new-ipc. Added enum ApmPerformanceMode. Added apmGetServiceSession_Session. Improved docs. 2019-10-06 19:02:05 -04:00
yellows8
ed2d72b9ff
csrng: Updated for new-ipc. Removed copyright comment-header in the .c (other .c don't have it and the .h has one anyway). 2019-10-06 15:49:36 -04:00
yellows8
e320f3cdf1
psm: Updated for new-ipc and minor internal improvements. 2019-10-06 12:24:29 -04:00
yellows8
f58c7fe786
Fixed includes in nifm.h/wlaninf.h. 2019-10-05 20:47:24 -04:00
yellows8
75795933a7
nifm: Updated for new-ipc. Added nifmGetServiceSession_StaticService and nifmGetServiceSession_GeneralService. Fixed order of cmds and improved docs. Improved _nifmCreateGeneralService. 2019-10-05 12:38:42 -04:00
yellows8
be2cb63722
wlaninf: Updated for new-ipc. 2019-10-04 20:36:51 -04:00
yellows8
1c334bafb9
set: Updated for new-ipc. Changed the type of the Language param for setMakeLanguage*() from s32 to SetLanguage. Added size_out param to setsysGetSettingsItemValue which was previously missing. Minor param name adjustment for setsysBindFatalDirtyFlagEvent. Improved docs. 2019-10-04 14:41:10 -04:00
yellows8
c8550c378b
Include sf/service.h instead of sm.h, in the service/ headers for services which were previously updated for new-ipc. 2019-10-04 10:20:15 -04:00
yellows8
62192cac0a
Removed sm.h include from applet.c which is no longer needed. 2019-10-03 21:48:36 -04:00
yellows8
c4b1a68269
applet: Added macros in applet.c for defining cmds' impl in a single line, using the ipc helper funcs. Some cmds which previously didn't have NotInitialized checks now do so via the macros. Fixed the order of some cmds. 2019-10-03 20:03:45 -04:00
XorTroll
9eb4bfca20 Add missing hidsys function in header 2019-10-03 17:28:35 +02:00
Adubbz
0395a4190e Adjust NcmApplicationMetaExtendedHeader for 9.0.0 2019-10-03 16:09:33 +02:00
yellows8
9916fe93a0
applet: Updated for new-ipc, various internal improvements, and changed the transfer_size param type for appletReadThemeStorage to u64. 2019-10-02 19:02:20 -04:00
yellows8
f17773c64f
Check for nullptr before copying to out_data in serviceDispatchImpl. 2019-10-01 20:50:09 -04:00
yellows8
127408a1f7
Fixed ipc output/etc for ncmContentStorageListPlaceHolder, nsvmGetSafeSystemVersion, and nsdevPrepareLaunchProgramFromHost (caused by new-ipc changes). 2019-10-01 20:43:03 -04:00
yellows8
2e56959916
Updated ts for new IPC. 2019-09-30 20:04:51 -04:00
yellows8
08272ed12e
Improved docs. Added nsGetServiceSession_GetterInterface, nsGetServiceSession_ApplicationManagerInterface, nsvmGetServiceSession, nsdevGetServiceSession, and nssuGetServiceSession. 2019-09-30 19:23:36 -04:00
Adubbz
33d8c83ddc ncm: Use u8 rather than actual types to ensure correct struct sizes 2019-09-30 16:11:55 +02:00
yellows8
e02f3a82b8
Minor docs fix. 2019-09-30 01:49:32 -04:00
yellows8
80880728e5
Updated NsSystemUpdateProgress docs. 2019-09-30 01:44:34 -04:00
yellows8
fe836e2145
Updated NsSystemDeliveryInfo docs. 2019-09-27 00:18:54 -04:00
yellows8
e0c72684c5
Minor comments alignment adjustment. 2019-09-26 23:48:25 -04:00
yellows8
ab1903e382
Updated the NsSystemUpdateProgress struct. 2019-09-26 23:47:08 -04:00
yellows8
ae9bd198a7
Updated the NsSystemDeliveryInfo struct. 2019-09-26 19:53:55 -04:00
yellows8
e483dc87a0
Added NsApplicationControlSource for use with nsGetApplicationControlData. Fixed actual_size handling for nsGetApplicationControlData. 2019-09-26 18:42:47 -04:00
yellows8
653a1a6b9a
Fixed the param and sysver-check for nsvmGetSafeSystemVersion, and updated docs. 2019-09-26 17:21:54 -04:00
yellows8
075a743cfb
Added support for nssu, and added the structs/enums for it. Added NSSU_CARDUPDATE_TMEM_SIZE_DEFAULT. Moved cmd_id param in the ns helper funcs to the last param. Improved docs. 2019-09-26 17:07:26 -04:00
yellows8
0749dfd67f
Added services/async. 2019-09-26 16:57:39 -04:00
Adubbz
8330f23d20 Updated ncm to new libnx ipc (#331)
* Updated to new libnx ipc
* Improved docs
* Added firmware req comments
* Improved ncmContentMetaDatabaseGetContentIdByType
* Fix ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset
2019-09-25 21:52:51 -04:00
yellows8
f9eb0c88ee
Use new IPC with ns. Updated the params for nsListApplicationRecord/nsListApplicationContentMetaStatus. Updated docs. 2019-09-23 21:01:10 -04:00
yellows8
c93fab39c8
Added ncm docs. 2019-09-23 17:00:16 -04:00
yellows8
66a4db694b
Added docs for FsStorageId. 2019-09-23 16:58:58 -04:00
fincs
b30b567228
fsdev: Convert time into proper POSIX UTC timestamps (FS reports local time instead) 2019-09-22 18:14:10 +02:00
fincs
c3f0210cf6
time: Correct timeToPosixTime(WithMyRule) to accept number of timestamps instead of raw byte size 2019-09-22 18:12:28 +02:00
fincs
ecbc77840e
fs: Update names of enum/flag types for style consistency and correctness 2019-09-21 19:54:21 +02:00
fincs
77888f8b1f
fs: Use new IPC interface + fixes, see details:
- Argument types corrected to better reflect their actual types
  (mostly several incorrect instances of size_t were changed to u64)
- Const correctness fixes
- fsEventNotifierGetEventHandle changed to output an Event (with
  user configurable autoclear) instead of a raw Handle
2019-09-21 16:27:15 +02:00
fincs
21d15b5a8e
cmif: Fix C++ warnings and errors 2019-09-21 14:15:19 +02:00
fincs
62d795a3c6
fs: Add support for setting priority through IPC context [5.0.0+] 2019-09-21 03:31:08 +02:00
fincs
8a0aef8824
Fix new compiler warnings raised by GCC 9.x 2019-09-21 00:58:33 +02:00
Michael Scire
76daefae78 ro: update to use new-ipc 2019-09-20 12:17:57 -07:00
Michael Scire
f5f768ea5c fsldr: update to use new-ipc 2019-09-20 12:17:46 -07:00
Michael Scire
aafbc310c2 spl: update to use new-ipc 2019-09-20 12:17:27 -07:00
Michael Scire
f465206082 pm: update to use new-ipc 2019-09-20 12:16:54 -07:00
fincs
10d07f3a8a
fs: Implement skeleton required for new IPC and multi-session support (no actual cmds converted yet to new IPC) 2019-09-20 19:39:32 +02:00
fincs
d7564ce80d
Add serviceAssumeDomain + minor codegen optimization in serviceDispatch* 2019-09-20 19:27:24 +02:00
fincs
96fc7dd8cd
Minor style fixes in new IPC code 2019-09-20 14:54:45 +02:00
fincs
5ab1219f40
Add internal service guard helper, needed for proper thread safe service init/exit 2019-09-20 02:28:46 +02:00
fincs
c3b920d210
cmif/service: Support passing optional 5.0.0+ context data to requests 2019-09-20 01:48:10 +02:00
fincs
4eda677b93
Add compiler optimization hint to remove unused domain handling code 2019-09-20 01:36:22 +02:00
fincs
2224be3f88
Add cmifCloneCurrentObject and serviceClone (i.e. non-Ex variants) 2019-09-20 00:11:44 +02:00
fincs
dedd29b431
sm: Remove smHasInitialized (use Initialize+GetService+Exit instead) 2019-09-19 23:47:37 +02:00
fincs
43ad77e8d2
nv: Use new IPC interface 2019-09-19 13:23:16 +02:00
fincs
20b26296af
Replace serviceClone with serviceCloneEx 2019-09-19 13:21:21 +02:00
fincs
99c325ed5b
Further cleanup in SM code; smEncodeName is now constexpr 2019-09-19 12:56:21 +02:00
fincs
51db782e7a
fatal: Use new IPC interface 2019-09-19 04:23:00 +02:00
fincs
6ad0042147
Introduce new IPC interface wrapper code, see details:
- Service object moved away from sm.h and into its own file (sf/service.h)
- Service object completely redesigned, but a (mostly)
  backwards compatible API was kept
- New low level HIPC request/response code
- New CMIF client-oriented code
- New service IPC dispatch functions
- Pointer buffer size automatically retrieved for all sessions
- Removed previous manual pointer buffer size query code
- SM rewritten with new IPC code
- All other services are still pending IPC rewrite
2019-09-19 03:50:28 +02:00
fincs
0a3592d4dd
Deprecate current IPC interface 2019-09-19 02:58:12 +02:00
fincs
02b5d3b474
Introduce NX_INLINE and NX_CONSTEXPR 2019-09-19 02:46:13 +02:00
yellows8
f4fe3376bd
Fixed the names for nsdevLaunchApplication, nsdevLaunchApplicationWithStorageId, nsdevGetRunningApplicationProcessId, and nsdevSetCurrentApplicationRightsEnvironmentCanBeActive. Updated the sysver checks for nsdevIsSystemMemoryResourceLimitBoosted since it was removed with [9.0.0+]. 2019-09-17 13:19:29 -04:00
yellows8
87332e2685
Added SetLanguage_ZHHANS/SetLanguage_ZHHANT. Added SetRegion_CHN, SetRegion_KOR, and SetRegion_TWN. 2019-09-15 23:39:42 -04:00
yellows8
ceab0a693c
Updated docs. 2019-09-14 22:55:25 -04:00
yellows8
b1317d3ff8
Added ts. 2019-09-14 20:46:37 -04:00
yellows8
fa25df27d0
Added support for friendsLa. Added friends.h. 2019-09-14 19:26:07 -04:00
fincs
3d682b6748
Release v2.5.0 2019-09-14 19:23:09 +02:00
yellows8
4ce9c0b038
Updated hdls to support [9.0.0+]. Added hiddbgGetUniquePadDeviceTypeSetInternal. Actually load the output rc from resp in AbstractedPad/VirtualPad funcs. 2019-09-14 11:13:56 -04:00
yellows8
042c756d72
Added HidDeviceTypeBits and HidDeviceType. Updated docs. 2019-09-14 11:05:16 -04:00
fincs
c10e70df3a
Fix typo 2019-09-13 13:16:54 +02:00
SciresM
c55383c973 lr: fix 9.x RedirectApplication* commands (#326)
* lr: fix 9.x RedirectApplication* commands

* lr: correct LegalInformation->ApplicationLegalInformation
2019-09-13 12:34:21 +02:00
yellows8
9d632b856d
Added HidNpadInterfaceType enum. 2019-09-13 02:47:53 -04:00
yellows8
326619c271
Added hidGetNpadInterfaceType. 2019-09-13 00:05:43 -04:00
yellows8
81781f0782
Use hidControllerIDToOfficial for the input id, with hidSetNpadJoyAssignmentModeSingleByDefault, hidSetNpadJoyAssignmentModeDual, and hidMergeSingleJoyAsDualJoy. 2019-09-12 23:28:07 -04:00
Michael Scire
1a676a68f5 hid: set SYSTEM/SYSTEM_EXT as supported styles.
Starting in 9.0.0, HID shared memory no longer populates
the SystemExt controller (which libnx calls LAYOUT_DEFAULT) unless
it is explicitly set as supported. This changes hidInitialize() to
set it and System as supported.
2019-09-12 12:48:27 +02:00
yellows8
b06a6ff29f
Updated sysver checks for the AbstractedPad cmds which were removed in [9.0.0+]. 2019-09-11 16:36:08 -04:00
yellows8
b89191c435
Added support for launching the Album applet via albumLa. 2019-09-09 11:10:33 -04:00
yellows8
76e86a9a80
Updated the AlbumReportOption enum. 2019-09-08 20:11:56 -04:00
yellows8
297f84c912
Updated docs. 2019-09-08 19:23:29 -04:00
yellows8
b7311b6ab1
Added support for capsu. Updated caps.h. Improved docs. Added enum CapsContentType. Added structs CapsScreenShotAttributeForApplication, CapsScreenShotDecodeOption, CapsApplicationAlbumFileEntry, and CapsLoadAlbumScreenShotImageOutputForApplication. Added capsGetDefaultStartDateTime, capsGetDefaultEndDateTime, capsConvertApplicationAlbumFileEntryToApplicationAlbumEntry, and capsConvertApplicationAlbumEntryToApplicationAlbumFileEntry. 2019-09-08 19:20:17 -04:00
yellows8
7d71d4f3a1
Use BufferType_Type1 in _capssuSaveScreenShotEx0, instead of a constant. 2019-09-02 16:46:21 -04:00
friedkeenan
fdb1605fc5 Require whole mount name to match when finding a romfs (#324) 2019-09-02 21:22:49 +02:00
yellows8
4f74aa1ad1
Updated docs for OffscreenRecordingParameter. Updated param names for grcMovieMakerFinish. 2019-08-31 19:07:11 -04:00
yellows8
7d08c7cc7c
Updated CapsAlbumFileDateTime. Updated docs. 2019-08-31 11:53:15 -04:00
yellows8
eeabd3bed0
Added capssuSaveScreenShotWithUserData, capssuSaveScreenShotWithUserIds, capssuSaveScreenShotEx1, and capssuSaveScreenShotEx2. Updated params for capssuSaveScreenShot and capssuSaveScreenShotEx0. Added enum AlbumReportOption, and structs CapsApplicationData/CapsUserIdList. Updated CapsScreenShotAttribute. Updated docs. 2019-08-30 23:17:58 -04:00
yellows8
5dc2fc0b7e
Removed AlbumFileEntry and reverted grcMovieMakerFinish back to using CapsApplicationAlbumEntry, since AlbumFileEntry is a duplicate of multiple other structs. 2019-08-30 12:55:50 -04:00
yellows8
7515bb4466
Use SetShimLibraryVersion with capssu. 2019-08-29 21:19:58 -04:00
yellows8
6d7d96a751
Added struct AlbumFileEntry, which grcMovieMakerFinish now uses. Updated CapsApplicationAlbumEntry. 2019-08-28 22:56:20 -04:00
yellows8
b269f58f8f
Renamed capsscCaptureScreenshot to capsscCaptureRawImageWithTimeout. 2019-08-28 22:38:12 -04:00
yellows8
318f2b33b6
Added appletCreateMovieMaker. Added support for grc MovieMaker. Improved grc docs. 2019-08-28 18:41:43 -04:00
yellows8
e7209bbcf5
Fixed the name of setsysGetServiceSession in the .c, so that it matches the .h. 2019-08-28 17:14:40 -04:00
yellows8
c790aa0fab
Added capsGetShimLibraryVersion. Added comments to audio.h. 2019-08-27 19:14:18 -04:00
yellows8
3999ec147e
Use serviceIpcPrepareHeader/serviceIpcParse with binder to support using domains. 2019-08-27 18:32:53 -04:00
yellows8
4177031ebe
Use the same style for all system-versions. 2019-08-26 13:05:49 -04:00
yellows8
6246f56305
Changed the type for NacpStruct.ratingAge to s8. 2019-08-26 11:56:24 -04:00
yellows8
0569ca7588
Updated docs. Use proper doxygen sections instead of plain comments, and use same style for all system-versions in applet docs. Internal applet.c improvements. Added appletGetServiceSession_*() funcs. 2019-08-26 10:40:24 -04:00
yellows8
bde3ae5a77
Added binder_session param to nwindowCreate(), which is now used with the binderInitSession() call instead of a hard-coded Service. Moved the viGetSession_IHOSBinderDriverRelay() call into nwindowCreateFromLayer(), for this new param. 2019-08-25 20:08:22 -04:00
yellows8
5e535bc2eb
Added support for grcd. 2019-08-24 23:30:30 -04:00
yellows8
c8b9120ba4
Updated docs. 2019-08-24 11:00:26 -04:00
yellows8
86ab999ee2
Added grc, for trimming videos. Added appletCreateGameMovieTrimmer, appletReserveResourceForMovieOperation, and appletUnreserveResourceForMovieOperation. Added structs CapsAlbumFileDateTime/CapsAlbumEntryId and updated CapsAlbumEntry. 2019-08-24 10:55:43 -04:00
yellows8
7c18df6d4c
Added appletRequestFlushGamePlayingMovieForDebug. 2019-08-22 10:27:49 -04:00
yellows8
c7cab0351c
Added appletExecuteProgram, appletJumpToSubApplicationProgramForDevelopment, appletRestartProgram, and appletGetPreviousProgramIndex. Added AppletProgramSpecifyKind. 2019-08-21 17:38:35 -04:00
yellows8
79e6db16be
Added appletPrepareForJit. 2019-08-21 12:14:29 -04:00
yellows8
c3b32581c9
Added appletGetLaunchStorageInfoForDebug. 2019-08-20 18:16:45 -04:00
yellows8
8135d6cbc5
Updated applet docs. 2019-08-20 15:17:41 -04:00
yellows8
487aed9a59
Added appletTerminateAllLibraryApplets/appletAreAnyLibraryAppletsLeft and appletApplicationTerminateAllLibraryApplets/appletApplicationAreAnyLibraryAppletsLeft. 2019-08-20 14:33:56 -04:00
yellows8
e069da4320
Added appletHolderTerminate. 2019-08-20 11:44:55 -04:00
yellows8
0f8e18573d
Added appletLaunchDevMenu. 2019-08-20 11:19:49 -04:00
yellows8
447ca35c29
Added appletPopRequestLaunchApplicationForDebug. 2019-08-19 22:08:19 -04:00
yellows8
579a5203b6
Added appletBeginToObserveHidInputForDevelop. 2019-08-19 21:19:47 -04:00
yellows8
7bcea54a65
Updated applet docs. 2019-08-19 19:11:22 -04:00
yellows8
ecd9127bed
Added appletHolderRequestExitOrTerminate and appletApplicationRequestExitLibraryAppletOrTerminate. Minor internal improvements. 2019-08-18 23:15:41 -04:00
yellows8
c34bea8d4c
Improved infinite-sleep-loop handling, and use it for appletStartShutdownSequenceForOverlay/appletStartRebootSequenceForOverlay. 2019-08-18 19:40:17 -04:00
WerWolv
ac75527491 Filled in missing NacpStruct fields (#322)
* Filled in missing NacpStruct fields
2019-08-18 19:23:41 -04:00
yellows8
f1dfb2c23b
Added support for AppletApplication. Added AppletApplicationExitReason. Added AppletApplicationLaunchProperty and AppletApplicationLaunchRequestInfo. Added appletCreateApplication, appletPopLaunchRequestedApplication, appletCreateSystemApplication, appletPopFloatingApplicationForDevelopment, and appletOpenMainApplication. Minor internal changes + updated docs. 2019-08-18 17:30:11 -04:00
Alex Barney
758db03ca4 Add some FS commands (#321)
* Implement fsOpenCustomStorageFileSystem
* Add more FS commands
fsExtendSaveDataFileSystem
fsSetGlobalAccessLogMode
fsGetGlobalAccessLogMode

* Savedata sizes are signed.
2019-08-17 11:36:43 -04:00
yellows8
e7a09f7be7
Added appletGetAppletResourceUsageInfo. Added struct AppletResourceUsageInfo. 2019-08-17 00:34:46 -04:00
yellows8
19741cb103
Added appletRequestLaunchApplicationWithUserAndArgumentForDebug. 2019-08-16 23:56:29 -04:00
yellows8
2f3fa0030e
Renamed AppletLaunchParameterKind_Application to AppletLaunchParameterKind_UserChannel. 2019-08-16 22:42:10 -04:00
yellows8
7cc9295684
Added appletInvalidateTransitionLayer. 2019-08-16 22:31:01 -04:00
yellows8
fc09340a42
Added appletPerformSystemButtonPressing and the enum types for it. Updated docs. 2019-08-16 22:05:34 -04:00
yellows8
b20147eeb7
Added appletExitAndRequestToShowThanksMessage. 2019-08-16 21:10:35 -04:00
yellows8
287bb00981
Enter an infinite-sleep-loop in _appletExitProcess when the exit cmds were successful, this is used with __nx_applet_exit_mode handling. Minor other changes. 2019-08-16 20:33:09 -04:00
yellows8
10e2e71ea2
Enter infinite-sleep-loop in appletRequestToShutdown/appletRequestToReboot. Minor change in appletHolderJump. 2019-08-16 20:19:50 -04:00
yellows8
112da06f37
Renamed AppletNotificationMessage to AppletMessage. Updated docs. 2019-08-16 15:42:04 -04:00
yellows8
eeaa63aa28
Added appletPushContext/appletPopContext. Added appletHolderJump. Added appletGetAppletInfo. Added libappletSetJumpFlag. Added structs AppletProcessLaunchReason and AppletInfo. 2019-08-15 21:43:09 -04:00
yellows8
8db92d48a5
Added libappletArgsPop. Improved docs. 2019-08-14 21:55:07 -04:00
yellows8
77961c6ede
Added appletPopInData, appletPushOutData, appletPopInteractiveInData, appletPushInteractiveOutData, appletGetPopInDataEvent, appletGetPopInteractiveInDataEvent, appletPopExtraStorage, appletGetPopExtraStorageEvent, appletUnpopInData, and appletUnpopExtraStorage. Improved docs. 2019-08-14 18:23:11 -04:00
fincs
067492ee17
nvAddressSpaceCreate: call InitializeEx with the proper page size value... 2019-08-14 21:02:56 +02:00
yellows8
5090c54654
Added appletGetMainAppletAvailableUsers. 2019-08-13 21:26:50 -04:00
yellows8
a17c73e783
Added appletGetMainAppletStorageId, appletGetDesirableKeyboardLayout, appletGetIndirectLayerProducerHandle, and appletGetCurrentApplicationId. 2019-08-13 19:06:39 -04:00
yellows8
b09b2deb2d
Added appletRequestExitToSelf. 2019-08-13 17:18:22 -04:00
yellows8
6017cba043
Added comment for NacpStruct. 2019-08-13 12:48:07 -04:00
yellows8
c516388ba0
Added appletCanUseApplicationCore, appletGetMainAppletApplicationControlProperty, and appletGetMainAppletApplicationDesiredLanguage. Added docs for appletGetDesiredLanguage. 2019-08-13 12:46:49 -04:00
yellows8
0137f582da
Added struct AppletAttribute. Use cmd OpenLibraryAppletProxy on [3.0.0+] when running appletInitialize for AppletType_LibraryApplet. 2019-08-12 11:14:58 -04:00
Robin Lambertz
37fdcb5726 svcGetInfo id0 should be an u32
svcGetInfo uses an u32 for id0 in the kernel (which moves W1 and not X1).
2019-08-09 21:18:57 +02:00
fincs
11e3bfd5ac
Release v2.4.0 2019-08-09 02:19:10 +02:00
yellows8
15b3181c93
Fixed docs. 2019-08-08 13:39:07 -04:00
yellows8
f9ccfb79d2
Added appletGetApplicationIdForLogo, appletSetGpuTimeSliceBoost, appletSetAutoSleepTimeAndDimmingTimeEnabled, appletTerminateApplicationAndSetReason, appletSetScreenShotPermissionGlobally, appletStartShutdownSequenceForOverlay, appletStartRebootSequenceForOverlay, and appletSetHandlingHomeButtonShortPressedEnabled. 2019-08-08 13:35:16 -04:00
yellows8
f5b24bd244
Added appletStartSleepSequence, appletStartShutdownSequence, appletStartRebootSequence, appletIsAutoPowerDownRequested, appletLoadAndApplyIdlePolicySettings, appletNotifyCecSettingsChanged, appletSetDefaultHomeButtonLongPressTime, appletUpdateDefaultDisplayResolution, appletShouldSleepOnBoot, and appletGetHdcpAuthenticationFailedEvent. 2019-08-08 11:32:27 -04:00
averne
f13d9ba6cc Added viDestroyManagedLayer (#316) 2019-08-08 12:41:10 +02:00
yellows8
3bbc181531
Added appletRequestToGetForeground, appletLockForeground, appletUnlockForeground, appletPopFromGeneralChannel, and appletGetPopFromGeneralChannelEvent. 2019-08-07 19:57:03 -04:00
SciresM
9049a12209 vi: add ViPowerState_On_Deprecated enum entry (#318) 2019-08-07 21:13:57 +02:00
yellows8
75c79e8d5e
Replaced appletHomeButtonReaderLockAccessorGetEvent with appletGetHomeButtonReaderLockAccessor. Added appletGetReaderLockAccessorEx, appletGetWriterLockAccessorEx, and appletGetHomeButtonWriterLockAccessor. Added support for AppletLockAccessor. 2019-08-05 22:40:14 -04:00
fincs
21de119c68
Run TLS destructor after clearing TLS value, as per standard 2019-08-04 21:03:04 +02:00
yellows8
6c194fc6a6
Added appletRequestToAcquireSleepLock, appletReleaseSleepLock, and appletReleaseSleepLockTransiently. 2019-08-03 20:53:42 -04:00
yellows8
d73e1a09b5
Minor docs change. 2019-08-02 14:28:02 -04:00
yellows8
1bb777afe7
Added support for IAppletCommonFunctions. Added appletReadThemeStorage, appletWriteThemeStorage, appletGetDisplayLogicalResolution, appletSetDisplayMagnification, appletSetHomeButtonDoubleClickEnabled, and appletGetHomeButtonDoubleClickEnabled. Minor other changes. 2019-08-02 14:16:59 -04:00
yellows8
98fbadc778
Added appletUpdateLastForegroundCaptureImage, appletUpdateCallerAppletCaptureImage, appletGetLastForegroundCaptureImageEx, appletGetLastApplicationCaptureImageEx, appletGetCallerAppletCaptureImageEx, appletTakeScreenShotOfOwnLayer, appletCopyBetweenCaptureBuffers, appletClearCaptureBuffer, appletClearAppletTransitionBuffer, appletAcquireLastApplicationCaptureSharedBuffer, appletReleaseLastApplicationCaptureSharedBuffer, appletAcquireLastForegroundCaptureSharedBuffer, appletReleaseLastForegroundCaptureSharedBuffer, appletAcquireCallerAppletCaptureSharedBuffer, appletReleaseCallerAppletCaptureSharedBuffer, and appletTakeScreenShotOfOwnLayerEx. 2019-08-01 12:24:22 -04:00
yellows8
f49e8cb217
Added struct LibAppletInfo. Added appletHolderGetLibraryAppletInfo and appletGetLibraryAppletInfo. 2019-07-30 20:03:24 -04:00
yellows8
64783b7cc2
Updated unk_x8 in the PdmPlayEvent struct. 2019-07-30 18:37:08 -04:00
yellows8
2257e3ccf4
Updated LibAppletMode enum and added appletHolderSetOutOfFocusApplicationSuspendingEnabled. 2019-07-30 17:34:05 -04:00
fincs
b3dd512253 Fix typo in nvAddressSpaceModify 2019-07-30 16:35:35 +02:00
yellows8
6df890c47b
Added appletSetExpectedMasterVolume, appletGetExpectedMasterVolume, appletChangeMainAppletMasterVolume, and appletSetTransparentVolumeRate. 2019-07-29 22:05:32 -04:00
yellows8
773111b3f2
Cache the preselected user in accountInitialize. Get/set the preselected userID in env, so that accountGetPreselectedUser() is usable multiple times. Renamed accountGetActiveUser to accountGetLastOpenedUser. Improved docs. 2019-07-29 19:00:52 -04:00
yellows8
4fa878f4b1
Added hidGetSupportedNpadStyleSet. Moved hidSetSupportedNpadStyleSet to match cmd order. Added hidsysGetSupportedNpadStyleSetOfCallerApplet. 2019-07-29 18:22:46 -04:00
yellows8
7310c8f880
Added appletGetAppletResourceUserIdOfCallerApplet, appletSetAppletWindowVisibility, and appletSetAppletGpuTimeSlice. Minor other change. 2019-07-29 18:18:19 -04:00
fincs
01d648e7ed Add support for new homebrew ABI keys + loader info 2019-07-29 21:17:09 +02:00
yellows8
409957c432
Added appletGetCradleFwVersion, appletIsInControllerFirmwareUpdateSection, appletSetPerformanceConfigurationChangedNotification, and appletGetOperationModeSystemInfo. Moved appletHomeButtonReaderLockAccessorGetEvent to match cmd order. Fixed a check in appletGetDefaultDisplayResolution. 2019-07-28 20:52:37 -04:00
yellows8
93eaa74131
Added appletGetCradleStatus and appletGetBootMode. Added _appletCmdNoInOutU8 for internal use, which _appletCmdNoInOutBool now uses. Fixed docs. 2019-07-27 12:33:56 -04:00
yellows8
79fa22fdbd
Improved pm docs. 2019-07-27 12:30:06 -04:00
yellows8
aeca9041d5
Added appletGetApplicationIdByContentActionName. 2019-07-25 23:47:03 -04:00
yellows8
31d34a6915
Added AppletTvPowerStateMatchingMode and AppletSystemButtonType. Added appletSetLcdBacklightOffEnabled, appletGetDefaultDisplayResolution, appletGetDefaultDisplayResolutionChangeEvent, appletGetHdcpAuthenticationState, appletGetHdcpAuthenticationStateChangeEvent, appletSetTvPowerStateMatchingMode, and appletPerformSystemButtonPressingIfInFocus. Minor other changes. 2019-07-25 21:40:42 -04:00
yellows8
3b2e484d88
Minor appletNotifyRunning improvements and added docs. 2019-07-25 20:26:34 -04:00
yellows8
493abc7703
Moved sections in applet.c/.h to match the order of the get-session cmds. Improved docs/comments. 2019-07-25 16:23:35 -04:00
yellows8
ed2f4a68f7
Added appletIsSystemBufferSharingEnabled, appletGetSystemSharedLayerHandle, and appletGetSystemSharedBufferHandle. 2019-07-24 19:45:39 -04:00
yellows8
974f5b9a1b
Added AppletIdentityInfo and AppletId_application. Moved sections in applet.h to match the applet.c order. Added/updated comments/docs. Check applet-type in _appletExitProcessAndReturn. Added appletSetScreenShotAppletIdentityInfo, appletGetMainAppletIdentityInfo, appletGetCallerAppletIdentityInfo, appletGetCallerAppletIdentityInfoStack, and appletGetNextReturnDestinationAppletIdentityInfo. 2019-07-24 16:20:52 -04:00
Adubbz
b59682652d Implement various SaveDataExtraData commands (#315)
* Implement fsReadSaveDataFileSystemExtraData

* Implement fsReadSaveDataFileSystemExtraDataBySaveDataSpaceId and fsWriteSaveDataFileSystemExtraData
2019-07-24 11:28:05 -04:00
yellows8
a5e4609be3
Added appletGetProgramTotalActiveTime. 2019-07-23 10:57:35 -04:00
averne
2b84eaeaed Fix nfc:user command ids 2019-07-22 22:13:32 +02:00
Adubbz
bc5d01400f Implement fsOpenGameCardFileSystem 2019-07-22 22:09:22 +02:00
yellows8
6942c8db75
Added AppletHookType_RequestToDisplay, AppletNotificationMessage_RequestToDisplay, and AlbumImageOrientation. Added appletSetControllerFirmwareUpdateSection, appletSetDesirableKeyboardLayout, appletSetHandlesRequestToDisplay, appletApproveToDisplay, appletOverrideAutoSleepTimeAndDimmingTime, appletSetIdleTimeDetectionExtension, appletGetIdleTimeDetectionExtension, appletSetInputDetectionSourceSet, appletReportUserIsActive, appletSetAutoSleepDisabled, appletIsAutoSleepDisabled, and appletSetWirelessPriorityMode. Improved docs. 2019-07-20 13:18:58 -04:00
XorTroll
c07a637e2c Fix typo in pdm GetServiceSession command 2019-07-19 19:56:54 +02:00
fincs
bf7479c2a5 Release v2.3.0 2019-07-19 16:06:44 +02:00
Thomas Guillemard
3f6cf66243 Make it possible to use the binder API with an arbitrary service (#309)
This is useful if you want to connect to "dispdrv" for example.
2019-07-18 19:12:03 +02:00
Thog
c73b8ceeb9 fix parcelReadData size checking 2019-07-18 19:11:48 +02:00
yellows8
74337842a0
Added AppletNotificationMessage enum and improved docs. Added support for appletSetRestartMessageEnabled, appletSetRequiresCaptureButtonShortPressedMessage, and appletSetAlbumImageTakenNotificationEnabled. Renamed appletSetScreenShotImageOrientation to appletSetAlbumImageOrientation. 2019-07-17 19:15:53 -04:00
yellows8
f760be337e
Minor internal applet.c improvements. 2019-07-17 17:27:01 -04:00
yellows8
c484b33995
Use InitializeApplicationInfo in accountInitialize when initializing with acc:u0. Handle cleanup on failure in accountInitialize. 2019-07-16 18:20:29 -04:00
yellows8
b896b33e3e
Added appletEnterFatalSection/appletLeaveFatalSection. 2019-07-16 15:47:47 -04:00
yellows8
f13b75d87c
Added appletGetPseudoDeviceId and appletSetApplicationAlbumUserData. Use ipcQueryPointerBufferSize for ISelfController in appletInitialize. Moved appletIsIlluminanceAvailable in applet.h to match cmd order. 2019-07-16 12:27:46 -04:00
Michael Scire
463c0f3379 vi: fix manager/system service init 2019-07-16 00:08:54 +02:00
yellows8
933cfb543d
Added support for applet ApplicationCopyright. Fixed a comment. 2019-07-14 17:42:46 -04:00
yellows8
333de18494
Added appletRequestToShutdown and appletRequestToReboot. 2019-07-13 20:04:26 -04:00
yellows8
3270bf3996
Reordered applet funcs to match cmdid order, improved docs, etc. Added appletBeginBlockingHomeButtonShortAndLongPressed and appletEndBlockingHomeButtonShortAndLongPressed. 2019-07-13 19:45:53 -04:00
yellows8
2262259984
Added appletGetDisplayVersion. 2019-07-13 18:57:37 -04:00
friedkeenan
da4c060278 Add a bunch of GetServiceSession functions (#305)
* Add a bunch of GetServiceSession functions
2019-07-13 15:09:28 -04:00
yellows8
40d7e0de51
Use an enum for appletSetScreenShotPermission with info from wiki. Improved applet docs. Use _appletIsApplication() instead of _appletIsRegularApplication() in appletQueryApplicationPlayStatistics/appletQueryApplicationPlayStatisticsByUid. Added appletGetGpuErrorDetectedSystemEvent. Added support for the [7.0.0+] CreateApplication*ToStartForQuest cmds. 2019-07-13 10:45:40 -04:00
Adubbz
0e724040ad Added fsDeleteSaveDataFileSystemBySaveDataSpaceId (#304) 2019-07-13 14:21:16 +02:00
yellows8
26544cba43
Uodated docs + the PdmAccountEvent struct. 2019-07-09 21:31:01 -04:00
yellows8
f418536e37
Added support for pdmqry. 2019-07-09 21:18:42 -04:00
Adubbz
4f441a4f28 Implement fsCreateSaveDataFileSystemBySystemSaveDataId (and wrappers) + fsDisableAutoSaveDataCreation (#302)
Also fixes everal cases of weird naming in fs
2019-07-05 03:56:52 +02:00
friedkeenan
61c0f4b2d9 Add hidsysGetUniquePadSerialNumber (#303) 2019-07-05 03:55:22 +02:00
Thomas Guillemard
2c1763c692 Add more ITimeZoneService related commands (#300)
This commit adds timeGetDeviceLocationName, timeSetDeviceLocationName, timeGetTotalLocationNameCount, timeLoadLocationNameList, timeLoadTimeZoneRule, timeToPosixTime, timeToPosixTimeWithMyRule, and timeToCalendarTime.
2019-07-03 21:29:24 +02:00
yellows8
9a607a369e
Properly convert the input id in irsGetIrCameraHandle(). 2019-07-01 22:04:48 -04:00
yellows8
ee7b30a7b4
Added KEY_HOME and KEY_CAPTURE for use with HiddbgHdlsState::buttons. 2019-07-01 20:08:10 -04:00
yellows8
015ca9652c
Filled in the PdmApplicationPlayStatistics struct. 2019-06-30 10:46:54 -04:00
yellows8
7f7ba17802
Fixed appletQueryApplicationPlayStatistics and added appletQueryApplicationPlayStatisticsByUid. Renamed AppletApplicationPlayStatistics to PdmApplicationPlayStatistics, updated it, and moved it to new file pdm.h. 2019-06-29 20:44:55 -04:00
yellows8
8147dca2a4
Updated the HiddbgHdlsNpadAssignment struct. 2019-06-28 23:02:39 -04:00
yellows8
b938016a67
Minor hiddbg fixes. 2019-06-28 21:39:33 -04:00
yellows8
156410b549
Added support for AbstractedPad. Improved hiddbgInitialize(). Updated hiddbg docs. 2019-06-28 21:36:53 -04:00
SciresM
950e1ec5ed pm: add bm cmds, BoostSystemThreadResourceLimit (#299) 2019-06-29 00:35:22 +02:00
Michael Scire
a7522f1d4c Mark arguments to svcCreateProcess as const. 2019-06-28 02:35:44 +02:00
yellows8
e1e2a05a34
Added hiddbgUpdateControllerColor and hiddbgUpdateDesignInfo. 2019-06-26 15:05:11 -04:00
Michael Scire
a065244e4b ldr: fix getter error 2019-06-26 19:16:10 +02:00
Michael Scire
48133f72ce ldr: add getters for shell/dmnt/pm 2019-06-26 17:33:10 +02:00
yellows8
74c102ed3f
Added hiddbgReadSerialFlash. 2019-06-25 22:40:49 -04:00
yellows8
a9c35dceb8
Updated comments for HiddbgHdlsDeviceInfo. 2019-06-25 18:41:11 -04:00
yellows8
cebc1bed33
Updated HiddbgHdlsDeviceInfo struct. 2019-06-25 11:33:35 -04:00
Michael Scire
18f977aa76 pm: add getters for pminfo, pmshell 2019-06-25 16:13:52 +02:00
yellows8
65e2e791a3
Updated Hdls structs. 2019-06-24 21:50:17 -04:00
Michael Scire
6978003c42 sm/smm: Add GetServiceSession 2019-06-24 21:43:45 +02:00
SciresM
e1a6a463c2 Add enums for GetInfo/GetSystemInfo (#292) 2019-06-22 00:05:56 +02:00
averne
9c887a13b4 Clear finalized field upon hmac context creation 2019-06-15 16:29:49 -04:00
yellows8
006ebc0633
Fixed romfsUnmount RemoveDevice handling. 2019-06-13 19:41:35 -04:00
yellows8
0d17c53d00
Updated HiddbgHdlsState struct. 2019-06-12 15:43:33 -04:00
yellows8
5a3eb542b2
Updated Hdls structs and docs. Added hidGetControllerDeviceType, hidGetControllerFlags, and hidGetControllerPowerInfo. Added/updated hid structs. 2019-06-08 21:51:46 -04:00
Pablo Curiel
e3d7b12c96 Remove RomFS devoptab device on unmount. 2019-06-08 17:16:55 +02:00
fincs
77f1d357e5 Fix stupid mistake in binderInitSession error cleanup code 2019-06-07 03:14:41 +02:00
yellows8
3e39f97fe5
Added support for hiddbg Hdls. 2019-06-06 20:52:33 -04:00
yellows8
9947048f8b
Added support for [8.0.0+] swkbd functionality: swkbdConfigSetUnkFlag, swkbdConfigSetTrigger, swkbdInlineSetChangedStringV2Callback, and swkbdInlineSetMovedCursorV2Callback. Added swkbdInlineLaunchForLibraryApplet and swkbdInlineSetDecidedCancelCallback. Moved initArg setup into swkbdInlineLaunch*. 2019-06-04 19:13:36 -04:00
thedax
133ffe92fd Implement setsys GetDeviceNickname/SetDeviceNickname (#289)
* Implement setsys(Get/Set)DeviceNickname.

Thanks to @shchmue & @thog for tips on the send/recv buffers!
2019-06-04 10:22:51 -04:00
Adubbz
8cf419802a Implement fsOpenContentStorageFileSystem, fsGetRightsIdByPath & fsGetRightsIdAndKeyGenerationByPath (#288)
* Implement fsOpenContentStorageFileSystem, fsGetRightsIdByPath & fsGetRightsIdAndKeyGenerationByPath
2019-06-03 14:51:21 -04:00
Michael Scire
3afc9ae371 Add FsBisStorageId enum 2019-06-03 14:48:45 -04:00
Michael Scire
4d049ee7c4 enum alignment fixes 2019-06-03 14:48:45 -04:00
Michael Scire
b68441e36f style fixes, note 4.0.0+ 2019-06-03 14:48:45 -04:00
Michael Scire
ac9d76f373 fs: fix file/storage API, add fsdevCreateFile, add fsOpenFileSystemWithPatch. 2019-06-03 14:48:45 -04:00
Ac_K
a3381d3d64 hidsysSetNotificationLedPattern cleanup
Fix a copy/paste issue in hidsysSetNotificationLedPattern
2019-06-01 16:00:28 -04:00
Alex Barney
bd1f9258b2 Fix fsFsCreateFile command parameters 2019-05-31 09:56:03 -04:00
yellows8
d2bfc032f8
Added support for the additional web [8.0.0+] functionality: webConfigSetMediaPlayerUi and webReplyGetMediaPlayerAutoClosedByCompletion. Various other changes. 2019-05-19 15:15:00 -04:00
yellows8
cf8bb1e045
Actually use the commonargs version for [6.0.0+] with web. 2019-05-17 21:35:33 -04:00
Thomas Guillemard
977bb9d7e8 i2c: add ReceiveAudo and ExecuteCommandList
Also make buf const in SendAuto.
2019-05-17 19:38:47 -04:00
fincs
d966bee9fa Const correctness in nvGpuZbcAddColor (and fix comment typo) 2019-05-17 21:20:11 +02:00
fincs
320b054f6e Added nvGpu* wrapper functions for zcull/zbc/tpc ioctls 2019-05-17 21:15:57 +02:00
fincs
f13c3cface Add/correct /dev/nvhost-ctrl-gpu ioctls 2019-05-17 20:03:05 +02:00
yellows8
90620daf05
Added romfsMountFromCurrentProcess(). 2019-05-17 11:15:43 -04:00
yellows8
f6f6adf1cb
Use the proper IPC buffer type for _usbHsEpGetXferReport with [3.0.0+]. 2019-05-16 18:48:19 -04:00
XorTroll
5452a4bd5f Fix ro services 2019-05-11 20:25:06 +02:00
yellows8
836bb367aa
Renamed ipc_buffer_size to pointer_buffer_size for ipcAddSendSmart/ipcAddRecvSmart. 2019-05-11 11:17:33 -04:00
Michael Scire
f92852fbe5 ncm: add NcmContentMetaType, NcmContentMetaAttribute enums 2019-05-09 12:42:50 +02:00
Michael Scire
a1861509f5 ncm: add ncmContentMetaDatabaseGetAttributes 2019-05-09 12:42:50 +02:00
Michael Scire
39db25c81d romfs_dev: fix unmounting/corruption when mounting multiple. 2019-05-09 12:42:15 +02:00
SciresM
e114a361be fsdev: add way of getting last returned result. (#276)
Adds fsdevGetLastResult, which returns a thread local Result updated by every call to fsdev_translate_error.

Also changes fsdev_translate_error to return EIO instead of raw results, when not translatable.
2019-05-08 16:44:17 +02:00
yellows8
e359010e75
Improved fs_dev docs. 2019-05-05 17:17:08 -04:00
Adubbz
1d3e208807 Added fsdevDeleteDirectoryRecursively 2019-05-05 18:26:08 +02:00
yellows8
afaa33df2e
Added partial support for SevenSixAxisSensor. 2019-05-03 18:38:37 -04:00
fincs
d911c47d2e Miscellaneous documentation fixes 2019-05-03 14:32:02 +02:00
Michael Scire
4094c014ff spl: fix BootReason command names 2019-05-03 03:33:56 +02:00
SciresM
c6e115fd1f i2c: flesh out I2cDevice enum (#273)
* i2c: flesh out I2cDevice enum
2019-05-02 17:38:10 -04:00
fincs
a346185801 Release v2.2.0 2019-05-01 19:26:45 +02:00
fincs
42878b603a Use eventActive instead of manually checking Event::revent 2019-04-30 02:31:47 +02:00
CTCaer
67cd70c00c [hid] Update NotificationLed structs (#272)
* [hid] Update NotificationLed structs
2019-04-27 18:11:01 -04:00
yellows8
aad6b55793
Filled in the HidsysNotificationLedPattern struct and added HidsysNotificationLedPatternCycle. Closes #240. 2019-04-26 21:47:02 -04:00
yellows8
46d5771312
const for hidsysSetNotificationLedPattern input pattern. 2019-04-25 19:30:10 -04:00
yellows8
bed9213f41
Added hidsysSetNotificationLedPattern and the struct for it. 2019-04-25 19:27:45 -04:00
yellows8
d4789c37c9
Added hidsysGetUniquePadsFromNpad and hidsysGetUniquePadIds. 2019-04-25 14:31:00 -04:00
SciresM
d6ba6d9625 sm: add retry loop in smInitialize (#270) 2019-04-25 17:43:39 +02:00
Michael Scire
0666e4651e spl: fix cryptAesCtr definition 2019-04-25 14:39:10 +02:00
SciresM
ee34c620f7 pcv: add pcvGetModuleId (#269)
* pcv: add pcvGetModuleId
2019-04-24 19:44:13 -04:00
Samuel P
bc1786b7b0 pcv Set/GetClockRate changes in 8.0.0 (#266)
* version check on pre-8.0.0 pcv funcs
* clkrst API
* Add PcvModuleId enum
2019-04-24 13:36:19 -04:00
yellows8
1dd057ac09
Added pctlConfirmStereoVisionPermission and pctlResetConfirmedStereoVisionPermission. 2019-04-22 12:33:01 -04:00
Michael Scire
9884ce0462 ldr: change ldrDmntGetModuleInfos to match roDmnt 2019-04-22 16:57:03 +02:00
Michael Scire
50db74a15b Implement ro:1 2019-04-22 16:57:03 +02:00
Michael Scire
23bd10f6db ro: add ldrRoLoadNrrEx, fix roDmnt 2019-04-22 16:57:03 +02:00
yellows8
76b6f521fe
Added appletIsVrModeEnabled and appletSetVrModeEnabled. 2019-04-21 13:45:49 -04:00
Michael Scire
6b50fddd9b Implement svcQueryProcessMemory 2019-04-21 13:48:59 +02:00
Michael Scire
4448b354dd loader: fix LoaderModuleInfo definition 2019-04-21 12:15:03 +02:00
yellows8
3b0f2014e3
Added appletGetCurrentIlluminance, appletGetCurrentIlluminanceEx, and appletIsIlluminanceAvailable. 2019-04-20 16:11:05 -04:00
yellows8
2916bd631a
Added pctlIsStereoVisionPermitted. 2019-04-20 16:09:35 -04:00
fincs
1c832bebd6 Avoid overwriting TLS[0x100] and TLS[0x102] as per 8.0.0 2019-04-20 19:19:34 +02:00
fincs
2f70ee6a92 Remove apm:p support as per 8.0.0 2019-04-16 17:45:12 +02:00
Lioncash
896c81246e kernel/ipc: Resolve missing initializer warnings
In C++ projects with higher warning levels, this header can cause some
missing initializer warnings to leak over. This silences those from
occurring.
2019-04-16 00:54:20 +02:00
yellows8
3dde2148cc
Added appletSetCpuBoostMode, appletGetCurrentPerformanceConfiguration, and ApmCpuBoostMode enum. Updated comments / various minor changes. 2019-04-14 12:16:37 -04:00
yellows8
d4de738dfd
Added support for [6.0.0+] web functionality. Various minor changes. 2019-04-12 21:37:53 -04:00
Ezekiel Bethel
26458fc1e8 add 0x402 (path exists) => EEXIST mapping in fs_dev 2019-04-09 22:16:34 -04:00
yellows8
57b028fec5
Added support for swkbd [6.0.0+] functionality. Added swkbdConfigSet*() funcs which should now be used instead of accessing the arg structs directly. Added version checking for some swkbdInlineSet*() funcs. Various other changes. 2019-04-09 18:32:54 -04:00
fincs
a469a68b20 Add custom extension to MOD0 header & a few other useful symbols 2019-04-08 16:36:45 +02:00
yellows8
31dee5072a
Sync FsSave/FsSaveDataInfo with wiki. 2019-04-04 22:31:02 -04:00
yellows8
8a3f105bab
Removed PACKED from FsSaveDataInfo/FsTimeStampRaw and fixed FsSave alignment. 2019-04-04 18:32:45 -04:00
Michael Scire
d2e2c15937 fix makefile arch 2019-04-04 20:13:36 +02:00
Michael Scire
16f8255fd5 crypto: guard #defines with #ifndef 2019-04-04 20:13:36 +02:00
Michael Scire
c3a94f5bce crc: fix -Wsign-compare warning 2019-04-04 20:13:36 +02:00
Michael Scire
408ae95120 cleanup headers, add crc32 acceleration 2019-04-04 20:13:36 +02:00
Michael Scire
e4481e12cb Implement AES-(128, 192, 256)-CMAC 2019-04-04 20:13:36 +02:00
Michael Scire
13a690a5a8 hmac: expose HMAC_*_KEY_MAX defines 2019-04-04 20:13:36 +02:00
Michael Scire
048a0508bf sha1: unroll all the loops inside processing block 2019-04-04 20:13:36 +02:00
Michael Scire
21a704f0b6 Implement accelerated sha1 + hmac-sha1 2019-04-04 20:13:36 +02:00
Michael Scire
0dde100135 Implement accelerated SHA256, HMAC-SHA256 2019-04-04 20:13:36 +02:00
Michael Scire
e4dda8fa46 minor style fixes 2019-04-04 20:13:36 +02:00
Michael Scire
017b47151d Implement accelerated AES-XTS 2019-04-04 20:13:36 +02:00
Michael Scire
82ae0f0c9e cbc/ctr: expose iv/ctr reset 2019-04-04 20:13:36 +02:00
Michael Scire
3eb6dd45a6 Implement accelerated AES-CTR 2019-04-04 20:13:36 +02:00
Michael Scire
9eb74bc9e0 crypto: fix style in aes_cbc, mark handlers inline. 2019-04-04 20:13:36 +02:00
Michael Scire
9c7adf0c44 crypto: add aes-cbc apis. 2019-04-04 20:13:36 +02:00
Michael Scire
f8375c46c0 crypto: add aes-ecb block enc/dec 2019-04-04 20:13:36 +02:00
yellows8
4f0aa0a589
Updated pctlauth docs. 2019-04-01 21:31:46 -04:00
yellows8
39f40b26ae
Added pctl. 2019-04-01 21:29:51 -04:00
yellows8
7b25d55342
Added pctlauth. 2019-03-31 22:01:48 -04:00
yellows8
9bbcee9bcf
Added libappletStart and libappletLaunch. Updated comments. 2019-03-31 21:59:04 -04:00
yellows8
fd9e02b271
Added romfsMountFromFsdev and fsdevTranslatePath. Internal romfs_dev improvements. 2019-03-29 19:49:08 -04:00
fincs
b7a0aaef09 Release v2.1.0 2019-03-29 18:40:27 +01:00
fincs
1096d7ee8f Add --nx-module-name to linker flags 2019-03-29 18:40:27 +01:00
fincs
56471670ee Remove old C11 threads implementation 2019-03-29 18:40:26 +01:00
fincs
9d9b2efe29 devkitA64 r13 support changes, including pthread support 2019-03-29 18:40:26 +01:00
fincs
626b07fac8 Implement TLS slot support (with destructors) 2019-03-29 18:40:26 +01:00
yellows8
2729cafbe0
Updated ErrorContext struct. 2019-03-29 13:36:40 -04:00
yellows8
3a14e9094a
Fixed error handling with appletHolderPushInData() for tmem-storage in swkbdShow(). 2019-03-28 21:01:04 -04:00
yellows8
b463693094 Changed errorApplicationSetNumber to static inline. 2019-03-28 20:19:38 -04:00
yellows8
8b5a4d580d Various minor changes + changed some error* funcs to static inline. Removed errorResultBacktraceClose, errorSystemClose, and errorApplicationClose. 2019-03-28 20:19:38 -04:00
yellows8
b91bc09c57 Added ErrorType enum. errorCode* funcs are now static inline + minor changes. Updated docs. 2019-03-28 20:19:38 -04:00
yellows8
505042bc73 Added ErrorCode and the funcs for it, funcs which use low/desc now use this instead. Updated docs. 2019-03-28 20:19:38 -04:00
yellows8
71a711e5d7 Updated ErrorContext. 2019-03-28 20:19:38 -04:00
yellows8
0ea16ae8c7 Added errorResultRecordShow/errorCodeRecordShow. 2019-03-28 20:19:38 -04:00
yellows8
f6287086d3 Added errorResultShow/errorCodeShow. Updated ErrorCommonHeader and added ErrorPctlArg. 2019-03-28 20:19:38 -04:00
yellows8
6be5ad949e In errorSystemSetContext(), return immediately on pre-4.0.0. 2019-03-28 20:19:38 -04:00
yellows8
68e3204a88 Added support for errorResultBacktrace*. Updated/added error structs. 2019-03-28 20:19:38 -04:00
yellows8
018441a1f6 Added support for errorEulaShow/errorSystemUpdateEulaShow. 2019-03-28 20:19:38 -04:00
yellows8
1ec8e3b29e Added support for error Application. Allow passing NULL to errorSystemCreate() for fullscreen_message, and minor other adjustments. 2019-03-28 20:19:38 -04:00
yellows8
3995447de7 Renamed error funcs and updated/added structs. Updated errorSystemCreate. Merged errorConfigSetShortDescription/errorConfigSetDetailedDescription into errorSystemCreate. Replaced errorConfigSetModule/errorConfigSetDescription with errorSystemSetCode, and added an errorSystemSetResult wrapper. Added errorSystemSetLanguageCode and errorSystemSetContext. 2019-03-28 20:19:38 -04:00
yellows8
9bf699f712 Improved error-applet launching handling. Updated ErrorConfig and added ErrorContext. 2019-03-28 20:19:38 -04:00
Liam Minopulos
ecfc8f8966 Added error LibraryApplet wrapper (#243)
* Implement error applet
2019-03-28 20:19:38 -04:00
plutoo
b7fe92f3a2 rwlock: Move over to condvar implementation. (#255)
This one is superior to the previous because it is write-preferring.
2019-03-28 23:53:04 +01:00
fincs
a4c23a0314 switch_rules: Make sure BUILD_EXEFS_SRC is non-empty before testing it 2019-03-26 13:28:49 +01:00
Michael Scire
5575966d0c fix fsdev bug 2019-03-25 00:02:18 +01:00
Michael Scire
1bea504732 Added fsOpenDataStorageByDataId and romfsMountFromDataArchive 2019-03-25 00:02:18 +01:00
Michael Scire
43128b613b romfs: refactor to allow specifying mount name 2019-03-25 00:02:18 +01:00
yellows8
b897c3a650 Updated web docs. 2019-03-22 20:51:09 -04:00
yellows8
afdd8d07e8 Updated usbhs docs regarding 7.0.0+. 2019-03-21 11:19:20 -04:00
natinusala
9c016a4cee Implemented nifmGetInternetConnectionStatus 2019-03-19 12:35:52 -04:00
Michael Theall
b49cb8a1a6 const params for usbDs 2019-03-16 00:07:39 +01:00
exelix
093471609d Change nifm initialization mode and add SetWirelessCommunicationEnabled (#247)
* Init nifm in the proper context, add SetWirelessCommunicationEnabled
* add nifmSetServiceType to set which nifm service to init
2019-03-15 17:11:40 -04:00
natinusala
a7facade0a Implement wlaninfGetState and wlaninfGetRSSI 2019-03-15 11:35:02 -04:00
yellows8
5d121a20b9 Changed types for fields in MousePosition to s32. 2019-03-12 16:21:22 -04:00
yellows8
c542d3ab8a Added hidMouseMultiRead + mouse handling adjustments. Closes #235. 2019-03-11 23:34:58 -04:00
Lioncash
03143cbadc hwopus: Document second member of HwopusHeader
This second member indicates the Opus encoder's entropy coder's final
range. While nothing in the service actually does anything with the
final range as far as I can tell, this is specified within RFC 6716
(https://tools.ietf.org/html/rfc6716, see section "6. Conformance") as a
means of ensuring decoder conformance. States as follows:

"In addition, a compliant decoder implementation MUST have
 the same final range decoder state as that of the reference decoder."

So what is likely done when performing compliance testing is the data is
encoded, and then the final range of the encoder is sent via this
header, then during decoding, the final range would be checked against
to ensure that it's valid.
2019-03-10 21:34:54 -04:00
yellows8
ef370fd33a Fixed WebWifi docs. 2019-03-09 21:51:32 -05:00
yellows8
275a61a2e2 Improved WebWifi, including handling for NULL conntest_url. 2019-03-09 16:18:10 -05:00
rsn8887
1135047a3a Fixed ifr_flags type by introducing ifr_flagshigh (fixes #248) 2019-03-09 16:37:33 +01:00
yellows8
bf3673c19f Added WebFooterFixedKind enum. Actually check sysver in webConfigSetFooterFixedKind. Updated web docs. 2019-03-07 21:36:48 -05:00
yellows8
c193337d9b Added WebExitReason_ErrorDialog. 2019-03-06 23:57:47 -05:00
yellows8
4160622165 Support passing NULL for webConfigShow out. Minor docs adjustment. 2019-03-06 23:46:46 -05:00
yellows8
9e52d7c4df Check for sysver [3.0.0+] for viSetDisplayMagnification. 2019-03-06 13:56:36 -05:00
yellows8
9d0603845a Updated WebBootDisplayKind and added WebBackgroundKind + WebLeftStickMode. Improved web docs. 2019-03-05 23:33:54 -05:00
exelix
2d1116743e Add wrappers for brightness-related functions (#246)
* Add wrappers for brightness-related functions
2019-03-04 21:37:33 -05:00
yellows8
966d554e7d Use PACKED for raw in _binderTransactParcelAuto. 2019-03-04 20:21:38 -05:00
yellows8
18a4351330 Use the actual enum for webConfigSetBootDisplayKind instead of u32. Improved web docs. 2019-03-04 17:20:18 -05:00
yellows8
7479be4256 Added WebShimKind_Shop and removed a comment. 2019-03-04 12:26:54 -05:00
yellows8
a897b9a836 Moved web common AppletHolder into WebCommonConfig, _webShow now takes AppletHolder as a param. Added webConfigRequestExit. Renamed WebExitReason_Unknown2 to WebExitReason_Requested. 2019-03-04 10:46:19 -05:00
yellows8
d353213d72 Added appletHolderRequestExit. 2019-03-04 10:42:07 -05:00
yellows8
c10508d95e Added WebExitReason enum and improved LastUrl/CallbackUrl docs. 2019-03-03 23:30:06 -05:00
yellows8
142811f943 Improved web docs. 2019-03-03 21:50:26 -05:00
yellows8
ded540e5f1 Implemented full support for web Offline-applet + minor other changes. Improved web docs. 2019-03-03 20:37:14 -05:00
yellows8
b19c35fe2c Added webReplyGet* funcs. Added WebReplyType enum and _webTLVReadVarSize. 2019-03-02 20:44:22 -05:00
yellows8
2ed160624a webConfigShow now uses new struct WebCommonReply as the output, for supporting WebCommonTLVStorage reply data. 2019-03-02 11:11:39 -05:00
yellows8
e55dfd69c7 Mention capssu.h in the webConfigSetApplicationAlbumEntry docs. 2019-03-01 23:04:28 -05:00
yellows8
bc7b178036 Added webConfigSetAdditionalCommentText, webConfigSetAdditionalMediaData, and webConfigSetMediaCreatorApplicationRatingAge. Improved web docs. 2019-03-01 22:49:01 -05:00
yellows8
166652a0eb Removed version check from webShareCreate. 2019-03-01 22:25:23 -05:00
yellows8
dc3cf7084e Added webConfigSetAlbumEntry and webConfigSetApplicationAlbumEntry. 2019-03-01 22:17:11 -05:00
yellows8
bbd0dcbd2b Added CapsAlbumEntry + comments. 2019-03-01 22:16:05 -05:00
yellows8
fbf1aab792 Initial support for web ShareApplet. Check shim-kind in webConfigSetDisplayUrlKind. 2019-03-01 21:54:45 -05:00
yellows8
6211510b21 In webConfigSetBootAsMediaPlayer with News on 3.0.0+, set WebArgType_BootAsMediaPlayerInverted. Added _webTLVRead/_webConfigGet*. Improved web docs. 2019-03-01 16:33:13 -05:00
yellows8
ff3a4f9844 Renamed usbDsEndpoint_StallCtrl to *Stall. 2019-03-01 12:40:23 -05:00
yellows8
121f2cf868 Added webConfigSetScreenShot, and minor other web changes. 2019-02-28 22:15:18 -05:00
yellows8
4ef0dd09f0 Added webConfigSetMediaPlayerUserGestureRestriction, webConfigSetJsExtension, webConfigSetTouchEnabledOnContents, webConfigSetPageCache, webConfigSetWebAudio, webConfigSetFooterFixedKind, webConfigSetPageFade, webConfigSetBootLoadingIcon, and webConfigSetPageScrollIndicator. Minor other changes. 2019-02-28 21:54:08 -05:00
yellows8
5f9264df16 Added webConfigSetFooter and webConfigSetKeyRepeatFrame. 2019-02-28 17:54:57 -05:00
yellows8
b58bc0a5dc Document what webConfigSetUserAgentAdditionalString is used for. 2019-02-28 16:50:45 -05:00
yellows8
344d87a3e4 Added support for web Lobby applet. Added webConfigSetBackgroundKind, webConfigSetPointer, and webConfigSetLeftStickMode. Fixed order of web funcs. Minor other web adjustments. 2019-02-28 13:07:56 -05:00
yellows8
6736053ae1 Added webConfigSetUserID, and internal web adjustments. 2019-02-27 22:48:48 -05:00
yellows8
526441a547 Added webYouTubeVideoCreate and improved web docs. 2019-02-27 20:44:11 -05:00
yellows8
81ce04eb7b In nxlinkStdio(), return sock on success instead of ret. 2019-02-27 19:15:31 -05:00
yellows8
6dea82a668 Moved applet notification-msg handling code into new funcs appletGetMessage and appletProcessMessage (with some improvements), which appletMainLoop now calls. 2019-02-27 19:03:35 -05:00
yellows8
eb750b641b Added webNewsCreate, webConfigSetEcClientCert, and webConfigSetShopJump. Improved web docs. 2019-02-27 17:52:00 -05:00
exelix
ad5b8c019f Add some functions from IOverlayAppletProxy and hid:sys (#242) 2019-02-27 16:17:03 +01:00
Michael Scire
d2c24bbe10 pm: Add pmdmntGetServiceSession() 2019-02-27 12:44:44 +01:00
yellows8
ef71282f31 Added webConfigSetBootAsMediaPlayer and webConfigSetMediaPlayerAutoClose. Updated WebBootDisplayKind. Removed 'Enabled' from WebArgType enums. 2019-02-26 21:54:47 -05:00
yellows8
a48f7c3502 Added webConfigSetBootDisplayKind and enum WebBootDisplayKind. Added enum WebShimKind_Offline. Minor other web adjustments. 2019-02-26 19:40:20 -05:00
yellows8
9e11dd1bd7 Added error handling for web TLVs. webPageCreate and webConfigSet* now return Result. Moved webWifiCreate/webWifiShow immediately after _webShow in web.c. 2019-02-26 17:55:16 -05:00
yellows8
904deeec10 Updated @brief in the web.h docs-header. 2019-02-26 15:23:01 -05:00
yellows8
2cd9825074 Added webConfigSetCallbackUrl, webConfigSetCallbackableUrl, and webConfigSetUserAgentAdditionalString. Improved web docs. 2019-02-26 15:16:26 -05:00
yellows8
6aa2640e4a Fixed comment alignment for WebArgType. 2019-02-25 23:24:29 -05:00
yellows8
50e2d43b70 Added WebArgType enum. 2019-02-25 23:22:49 -05:00
yellows8
91bf06653e Added webConfigSetDisplayUrlKind. Added more _webConfigSet* funcs. 2019-02-25 21:23:53 -05:00
yellows8
708ad83ead Renamed webShow to webConfigShow. Added webConfigSetWhitelist. 2019-02-25 20:12:36 -05:00
yellows8
7ccc29f397 Internal web arg handling improvements. 2019-02-25 19:38:15 -05:00
yellows8
ec5f1dc17f Renamed WebPageConfig to WebCommonConfig with more fields. Renamed webPageShow to webShow. Various web improvements including version handling. 2019-02-25 19:08:49 -05:00
yellows8
9f45bb4d7e Fixed IPC issues with bsdRead. 2019-02-24 22:17:27 -05:00
yellows8
4b8e501fdb Various web improvements, changed/added some structs. 2019-02-23 17:00:10 -05:00
fincs
bf13da990a Critical fix in new barrier impl 2019-02-23 21:09:41 +01:00
plutooo
e8f3964475 barrier: More efficient impl, maybe 2019-02-23 21:05:39 +01:00
yellows8
0a230bae65 Fixed issue in _webTLVWrite. Updated web docs. The url param for webPageCreate is no longer optional. 2019-02-21 00:15:09 -05:00
yellows8
601c76b508 Initial support for WebApplet/non-webWifi. 2019-02-20 23:42:17 -05:00
yellows8
425df41e7e Improved internal web applet launching/exit handling. 2019-02-20 18:34:16 -05:00
yellows8
d61c2d07b6 Added appletRequestLaunchApplication and appletRequestLaunchApplicationForQuest. 2019-02-19 23:12:29 -05:00
yellows8
d90893c566 Expose libappletCreateWriteStorage. 2019-02-19 21:46:53 -05:00
Luke Street
1415df75e4 Update svcSleepThread definition 2019-02-19 18:18:50 -05:00
yellows8
567828f44e Fixed doxygen issues / improved docs. Closes #230. 2019-02-19 16:56:33 -05:00
yellows8
e2f05654dd Moved web applet-exit handling into a dedicated func, which can optionally handle reading the applet reply storage. Added out param to webWifiShow for the applet reply data. 2019-02-18 22:32:18 -05:00
yellows8
f392dc0ce2 Added libappletReadStorage and libappletPopOutData. 2019-02-18 22:29:53 -05:00
yellows8
821c46539d Added 7.0.0+ support for _viCreateStrayLayer. 2019-02-18 22:26:22 -05:00
yellows8
e3f021bab3 Verify that the version is 2.0.0+ in swkbdInlineCreate. 2019-02-18 16:42:12 -05:00
fincs
11b7bece4a Change all services except fatal to use hosversion* instead of kernelAboveXYZ 2019-02-18 21:48:49 +01:00
fincs
61cc738730 Introduce hosversion.h - HOS version detection utilities
- Simplify kernel/detect.h logic; introduce detectKernelVersion()
- Use set:sys (if available) during __appInit in order to initialize
  the current HOS version
2019-02-18 21:48:41 +01:00
yellows8
6c3f72929d Fixed WebWifiPageArg struct, improved web-wifi handling and added docs. 2019-02-18 12:29:40 -05:00
fincs
ee2e19ce38 Improve names/documentation for jit kernel patch functions in detect.h/c + codestylefixes 2019-02-16 16:42:08 +01:00
yellows8
1cb2c18fa5 Added capssc. 2019-02-15 20:30:39 -05:00
averne
7d9601810d Added nfp:user services wrappers. (#237)
* hid: move official/libnx controller converters to hid.h
2019-02-15 19:06:41 +01:00
plutooo
17731d750e Add function to test OFW behavior under CFW 2019-02-14 22:03:47 +01:00
plutooo
fc557cbf2a Detect and use the CFW jit patch. 2019-02-13 22:40:00 +01:00
yellows8
16cbf1c9f6 Fixed minimum required sysver for capssu. 2019-02-11 20:36:41 -05:00
yellows8
e02b6c167a Added capssu and caps.h. 2019-02-08 19:47:13 -05:00
Lioncash
224ba8a87d hwopus: Provide a better name for the flag parameter of _hwopusDecodeInterleaved()
This is a flag that determines whether or not a request to reset the
decoder context should occur prior to decoding. This is an analogue to the
libopus ctl:

opus_decoder_ctl(decoder, OPUS_RESET_STATE);

which is generally used when switching streams to keep decoder state
consistent.
2019-01-30 18:00:48 +01:00
yellows8
b3b5816fd0 Added swkbdInlineAppearArgSetLeftButtonText and swkbdInlineAppearArgSetRightButtonText. 2019-01-28 21:15:45 -05:00
yellows8
2ebac06061 Updated swkbdInlineMakeAppearArg, this now just writes defaults and sets type to the input param. Added swkbdInlineAppearArgSetOkButtonText. 2019-01-28 16:54:38 -05:00
shibbs
131b92a8c8 Add in more NIFM functionality (#236) 2019-01-27 00:12:15 +01:00
yellows8
6b91ac26a5 Added swkbdInlineSetUserWordInfo/swkbdInlineUnsetUserWordInfo. Handle storage-tmem closing in _swkbdProcessReply. Better CustomizeDic handling. Other changes. 2019-01-22 22:29:48 -05:00
yellows8
4a119e4028 Added swkbdInlineSetCustomizeDic/swkbdInlineUnsetCustomizeDic. Updated SwkbdChangedStringArg struct. 2019-01-21 18:33:15 -05:00
yellows8
be8e196eb0 Moved state field from swkbdInlineUpdate into SwkbdInline, and added out_state param. Removed unused State param from _swkbdProcessReply. Added SwkbdState enum. 2019-01-18 23:48:31 -05:00
yellows8
dbadcd76ed Implemented _swkbdProcessReply() with actual handling. Added set-callback funcs. Automatically call swkbdInlineSetUtf8Mode in swkbdInlineCreate. 2019-01-18 22:11:41 -05:00
Samuel P
8360e561c5 Added WifiWebAuthApplet launching (#233)
* Added WifiWebAuthApplet launching
2019-01-18 20:00:34 -05:00
yellows8
40d5fb8587 Added SwkbdReplyType. Added initial impl for _swkbdProcessReply. 2019-01-17 21:31:18 -05:00
yellows8
4250fb3752 Updated SwkbdInlineCalcArg struct. Added: swkbdInlineSetKeytopBgAlpha, swkbdInlineSetFooterBgAlpha, swkbdInlineSetKeytopScale, and swkbdInlineSetKeytopTranslate. Implemented field updating in swkbdInlineUpdate. 2019-01-16 20:34:53 -05:00
yellows8
8cc321d0f1 Allocate tmp-buffers for swkbd-inline, for use in swkbdInlineUpdate. Moved code for writing bool flags into dedicated funcs. Added: swkbdInlineSetInputModeFadeType, swkbdInlineSetAlphaEnabledInInputMode, swkbdInlineSetKeytopAsFloating, swkbdInlineSetFooterScalable. Removed a comment. 2019-01-15 21:31:02 -05:00
yellows8
74683089a0 Fixed+updated swkbd-inline structs. Added: swkbdInlineSetVolume, swkbdInlineSetInputText, swkbdInlineSetCursorPos, swkbdInlineSetUtf8Mode, swkbdInlineSetTouchFlag, swkbdInlineSetUSBKeyboardFlag, swkbdInlineSetDirectionalButtonAssignFlag, swkbdInlineSetSeGroup, and swkbdInlineSetBackspaceFlag. Added some storage reading to swkbdInlineUpdate. 2019-01-15 16:51:19 -05:00
yellows8
1a91c10c19 Added SwkbdInlineMode enum. 2019-01-14 14:57:28 -05:00
yellows8
9d5127d37d Improved keySetDisableBitmask handling in swkbdInlineMakeAppearArg. 2019-01-14 11:14:50 -05:00
yellows8
203aa2b368 Added viGetIndirectLayerImageMap and viGetIndirectLayerImageRequiredMemoryInfo. 2019-01-14 11:12:49 -05:00
yellows8
a812587a31 Updated SwkbdAppearArg. Updated comments. 2019-01-13 19:51:01 -05:00
yellows8
8cd2808eff Added swkbdInlineAppear, swkbdInlineDisappear, and swkbdInlineMakeAppearArg. Updated SwkbdAppearArg. 2019-01-11 18:24:14 -05:00
Cpasjuste
855a719728 c11-threads: return thrd_timedout on cnd_timedwait timeout (#232) 2019-01-09 13:33:23 +01:00
yellows8
2e3fd9bd9f Use const for appletQueryApplicationPlayStatistics. 2019-01-05 14:47:42 -05:00
yellows8
2ccaa302a1 Added appletQueryApplicationPlayStatistics. Use BufferType_Normal instead of 0 in _appletGetSessionProxy. 2019-01-05 14:34:18 -05:00
yellows8
9aa0f901d1 Fixed doxygen for swkbd.h. 2019-01-04 22:07:10 -05:00
yellows8
2900622cb5 Initial SwkbdInline impl, minor swkbd adjustments. 2019-01-04 22:05:06 -05:00
fincs
06733c4750 Fix NvColorFormat enum 2019-01-04 22:30:52 +01:00
fincs
50baeeaa80 nwindowGetDefault: Explicitly initialize dimensions to 1280x720 because 1.x reports a default size of 1x1 2019-01-04 20:41:05 +01:00
yellows8
82e526c72f Added appletHolderActive and appletHolderCheckFinished. 2019-01-04 11:46:36 -05:00
XProger
f589310ef2 fix unusable touch by adding touch identifier into touchPosition 2019-01-03 21:16:06 +01:00
fincs
e708372dca Finally remove deprecated old gfx API 2019-01-03 21:13:20 +01:00
Andreas Smas
e04f311dd4 doozer: Adjust so docs-target is only trigged from Doozer's CD script 2019-01-03 11:32:30 -08:00
fincs
a182f3b496 Release v2.0.0 2019-01-02 00:16:49 +01:00
fincs
49efa74e70 Remove static_asserts from hid.h in order to avoid a hard dependency on C11 2019-01-01 03:27:43 +01:00
yellows8
e59036d4c8 Added PsmSession, which is now an additional param for: psmBindStateChangeEvent, psmWaitStateChangeEvent, and psmUnbindStateChangeEvent. Hence, the psm session is now handled with this object instead of libnx automatically handling it internally. psmBindStateChangeEvent no longer calls psmUnbindStateChangeEvent. Other adjustments. 2018-12-31 19:36:07 -05:00
yellows8
2c89aed2b9 Swapped the order of the buffers used in usbHsAcquireUsbIf on 3.0.0+. 2018-12-29 19:13:53 -05:00
yellows8
e9cc565e92 Fixed usbhs 3.0.0+ support with usbHsAcquireUsbIf. 2018-12-26 11:18:09 -05:00
yellows8
36a2404e4b Updated applet/swkbd comments. 2018-12-24 20:13:09 -05:00
yellows8
e03c23e126 Added comments for SwkbdTextDrawType_DownloadCode/unk_x3e0. 2018-12-24 20:03:23 -05:00
yellows8
584b856299 Removed typedef for SwkbdKeyDisableBitmask. Changed the type for SwkbdArgV0 type and textDrawType to the enums. 2018-12-24 11:23:30 -05:00
yellows8
653bcb27c9 Added SwkbdTextDrawType and replaced unk_x3b8 with textDrawType. 2018-12-24 01:00:39 -05:00
yellows8
21e01dfd68 Added SwkbdKeyDisableBitmask. 2018-12-23 22:55:19 -05:00
yellows8
715b597ef1 Removed comment from swkbdConfigSetInitialText, since the previous tmem commit fixed this. 2018-12-23 22:19:49 -05:00
yellows8
00d0174c0a Removed the buffer memset from tmemCreateFromMemory, tmemCreateFromMemory should not write to the user buffer. 2018-12-23 22:18:24 -05:00
yellows8
6355ead6d3 Fixed dicFlag type. 2018-12-23 01:47:11 -05:00
yellows8
477058d28a Added SwkbdType. Specifically set the type to SwkbdType_Normal in the Preset funcs which use it. Set type properly on 5.0.0+ for swkbdConfigMakePresetDownloadCode. Improved swkbd docs, including documenting what fields are set by the Preset funcs. 2018-12-23 01:26:00 -05:00
yellows8
56b767efbf Implemented actual swkbd TextCheck support. Moved strbuf alloc from _swkbdProcessOutput into swkbdShow(), so that it can be used for TextCheck. Added validation for the out_string* params in swkbdShow(). The out_string buffer is now cleared before calling _swkbdProcessOutput. 2018-12-23 00:39:06 -05:00
yellows8
e8482f7581 Improved SwkbdArgV0, and updated swkbd docs. 2018-12-22 19:26:38 -05:00
yellows8
e892e91360 Moved swkbd version init into swkbdCreate, and use the newer swkbd versions. Added swkbdConfigMakePreset*(). Changed unk_x3e0 to u32, and various other adjustments. 2018-12-22 16:50:20 -05:00
yellows8
901dc817e7 Handle <=3.0.0 swkbd versions, and filled in the arg struct. Handle the workbuf. Added a param to swkbdCreate and added swkbdClose. Added swkbdConfigSet*Text and swkbdConfigSet*OptionalSymbolKey. Various other changes. 2018-12-22 11:51:51 -05:00
yellows8
854e3058ba Replaced appletSetMediaPlaybackStateForApplication with appletSetMediaPlaybackState, which now supports non-Application. Added _appletCmdInU8/_appletCmdInBool, the latter is now used by appletSetMediaPlaybackState. 2018-12-21 11:33:56 -05:00
Cpasjuste
8be5cad7f8 Added appletSetMediaPlaybackStateForApplication 2018-12-21 10:30:28 -05:00
yellows8
59382cab1f Added LibnxError_LibAppletBadExit, which is now used in swkbd. 2018-12-20 21:08:36 -05:00
yellows8
58cbacc76f Handle the output swkbd storage. 2018-12-20 20:49:50 -05:00
yellows8
32f93bef5d Added initial swkbd impl. 2018-12-20 13:06:20 -05:00
yellows8
d821185e3d Added buffer param to appletCreateTransferMemoryStorage and appletCreateHandleStorageTmem, tmemCreateFromMemory will now be used with this when buffer is not NULL. 2018-12-20 12:59:59 -05:00
yellows8
2d5000ba57 Added libappletPushInData. Moved common storage creation+writing code into 1 func, in libapplet.c. 2018-12-20 12:57:35 -05:00
Dave Murphy
2405872b16 redirect sys/poll.h to poll.h for compatibility 2018-12-20 16:16:12 +01:00
fincs
252e8ef9ff Add tmemCreateFromMemory 2018-12-20 16:12:22 +01:00
yellows8
0bab302c3b Added libappletRequestHomeMenu and libappletRequestJumpToSystemUpdate. 2018-12-19 20:37:19 -05:00
yellows8
6e10568589 Added applets/libapplet. Added appletSetThemeColorType and appletGetThemeColorType. 2018-12-19 19:49:57 -05:00
fincs
f448b0fbad nvioctlMap_Param -> nvioctlNvmap_Param 2018-12-19 19:33:31 +01:00
fincs
5039c0815e console_sw: Switch to PIXEL_FORMAT_RGB_565, optimize scrollWindow 2018-12-19 19:33:31 +01:00
fincs
ccf85a134b Added more RGB*() helper macros & fixed a few typos 2018-12-19 19:33:31 +01:00
fincs
e7c58fe59e Deprecate old gfx API; scheduled for removal at a later date. 2018-12-19 19:33:31 +01:00
fincs
1b18a3b056 console_sw: Use Framebuffer object instead of old gfx api. Moved RGBA8/_MAXALPHA to framebuffer.h. 2018-12-19 19:33:31 +01:00
fincs
f37518d848 Add framebufferMakeLinear - linear shadow buffer support 2018-12-19 19:33:31 +01:00
fincs
dbc960a24f NWindow: Internal rework to fix resource leak in nwindowReleaseBuffers 2018-12-19 19:33:31 +01:00
fincs
3a77a7ace8 Introduce nwindowGetDefault 2018-12-19 19:33:31 +01:00
fincs
12af73e9d2 Document NWindow and Framebuffer objects 2018-12-19 19:33:31 +01:00
fincs
f381066a43 Add NvColorFormat enum 2018-12-19 19:33:31 +01:00
fincs
b1600c9add gfxGetFramebufferHandle: return id instead of handle 2018-12-19 19:33:31 +01:00
fincs
d87f9541d1 NvMap: added support for loading remote NvMap objects (from id) 2018-12-19 19:33:31 +01:00
fincs
72a48f6598 Add nvioctlMap_Param and NvMapParam enum 2018-12-19 19:33:31 +01:00
fincs
260f34fa4e NWindow: add several new functions:
- nwindowIsValid
- nwindowGetDimensions
- nwindowSetDimensions
- nwindowSetCrop
- nwindowSetTransform
- nwindowIsConsumerRunningBehind
2018-12-19 19:33:31 +01:00
fincs
bf43284c9f Misc code style fixes, rename NvGraphicBuffer::layers to planes 2018-12-19 19:33:31 +01:00
Michael Scire
7c01659953 vi: Improve ViScalingMode enum 2018-12-19 19:33:31 +01:00
Michael Scire
798d8ff50c Add vi wrappers for system StrayLayer usage. 2018-12-19 19:33:31 +01:00
fincs
4879937946 Introduce Framebuffer, experimental wrapper object around a framebuffer queue for use by software rendering clients 2018-12-19 19:33:31 +01:00
fincs
62aa8e8b23 NWindow: add nwindowReleaseBuffers, which is also done automatically on Close 2018-12-19 19:33:31 +01:00
fincs
412c84d5f9 Rename NvInfo to NvGpu 2018-12-19 19:33:31 +01:00
fincs
c5f8275978 Rename nvMapFree to nvMapClose for consistency reasons 2018-12-19 19:33:31 +01:00
fincs
a9cbd9116a Introduce NWindow, an experimental replacement for the GFX API 2018-12-19 19:33:31 +01:00
fincs
b188f5fb33 gfx.c: fix two single-line bugs 2018-12-19 19:33:31 +01:00
fincs
2af9531f5b Const correctness in bqCancelBuffer 2018-12-19 19:33:31 +01:00
fincs
ec6d878d12 Major buffer producer refactor, see details:
- Introduced NativeHandle (display/types.h)
- Introduced NvGraphicBuffer (nvidia/graphic_buffer.h)
- Renamed BqQueueBufferInput to BqBufferInput
- Renamed BqQueueBufferOutput to BqBufferOutput
- BqGraphicBuffer is now defined and marshalled in a way that matches
  official sw more closely, with a pointer to a NativeHandle instead of
  inline flattened data and other miscellaneous junk
- Const correctness fixes
- bqSetPreallocatedBuffer now has flattening logic for BqGraphicBuffer
- bqRequestBuffer doesn't have this logic for now, passing anything other
  than NULL will fail
- gfx.c updated to use the refactored buffer producer
2018-12-19 19:33:31 +01:00
fincs
d717507541 display/parcel.h: Const correctness fixes 2018-12-19 19:33:31 +01:00
fincs
ae77cbea97 gfx/hid/irs/nv/vi: changes related to sysmodule users, see details:
- Removed hard dependency on applet
- Allow appletGetAppletResourceUserId to fail (using default zero in that case)
- nvInitialize uses nvdrv:s for AppletType_None
- gfx now uses weak global __nx_gfx_vi_service_type for the ViServiceType passed to viInitialize
2018-12-19 19:33:31 +01:00
fincs
3a31df429e gfx: finally get rid of nvgfx, replaced with an NvMap object 2018-12-19 19:33:31 +01:00
fincs
5fe01c065a Major refactor and redesign of nvidia wrapper objects, see details:
- NvBuffer replaced with NvMap, which only manages the creation of
  raw nvmap objects. Users must map these objects manually to
  address spaces.
- nvAddressSpaceBindToChannel removed.
- nvChannelSetNvmapFd is now automatic and has been removed.
- Nv3DContext, NvCmdList, NvErrorNotifier, NvGpfifo, NvGpu and
  NvZcullContext have all been removed.
- Introduced NvGpuChannel, which provides all functionality that was
  part of said removed objects.
- Other miscellaneous changes and fixes.
2018-12-19 19:33:31 +01:00
fincs
85a20f43dc NvAddressSpace: major overhaul, see details:
- Now contains a 'page_size' field, used throughout the functions
- Removed NvPageSize
- Removed nvAddressSpaceReserveAlign/AtFixedAddr/Full
- Added nvAddressSpaceAlloc/AllocFixed/Free (replacing above functions)
- Removed nvAddressSpaceMapBuffer/UnmapBuffer
- Added nvAddressSpaceMap/MapFixed/Modify/Unmap (replacing above functions)
- Adapted NvBuffer/NvGpu to use the new functions
2018-12-19 19:33:31 +01:00
fincs
22499d8ddf nvhost-as-gpu.c: fix some mistakes, add nvioctlNvhostAsGpu_FreeSpace, add NvAllocSpaceFlags, add NvMapBufferFlags_Modify 2018-12-19 19:33:31 +01:00
fincs
f0de0c869d Added nvInfoGetGpuCharacteristics 2018-12-19 19:33:31 +01:00
yellows8
9f63f29988 Use eventActive for g_appletLibraryAppletLaunchableEvent. Fixed _appletWaitLibraryAppletLaunchableEvent, and set rc to eventWait ret in _appletWaitLibraryAppletLaunchableEvent. Added appletHolderWaitInteractiveOut. 2018-12-19 13:00:40 -05:00
yellows8
63e0e3502c Added eventActive(). 2018-12-19 12:56:01 -05:00
yellows8
ced4f16ee1 Fixed+enabled appletSetTerminateResult and added it to applet.h. 2018-12-18 21:45:13 -05:00
yellows8
d8683ea188 Added appletHolderPopOutData and appletHolderPopInteractiveOutData. 2018-12-18 20:07:29 -05:00
yellows8
a6e1413712 Added storage pushing for AppletHolder. Verify that the input storage is initialized in _appletCmdInStorage(). 2018-12-18 19:37:07 -05:00
yellows8
5874a272d0 Added appletHolderJoin and appletHolderGetExitReason. 2018-12-18 19:03:22 -05:00
yellows8
bca797afc2 Use LibraryAppletLaunchableEvent and handle LibraryApplet self-creation. Implemented LibraryApplet starting. 2018-12-17 20:23:43 -05:00
yellows8
8f22e9e213 Initial impl for LibraryApplet creation. 2018-12-17 12:16:46 -05:00
natinusala
c8f732fda8 Add missing applet focus states and handling modes 2018-12-17 11:03:49 -05:00
fincs
50d16023eb Fix typo 2018-12-17 16:18:28 +01:00
fincs
beeeb057d2 Finishing touches to user-mode synchronization primitives 2018-12-17 16:06:23 +01:00
fincs
8c786c610e Fix waitMulti/waitMultiHandle for C++ 2018-12-17 16:06:23 +01:00
fincs
21f69bfa57 Add, document, and use MAX_WAIT_OBJECTS 2018-12-17 16:06:23 +01:00
fincs
33dad9b893 UTimer: use an actual 'started' flag instead of a magic tick value 2018-12-17 16:06:23 +01:00
fincs
8d813ee666 Generalize Waitable, moving UEvent/UTimer specific code into a vtable. 2018-12-17 16:06:23 +01:00
fincs
1d14cad1cf Separate WaiterNode initialization again, which is now done in waitImpl 2018-12-17 16:06:23 +01:00
fincs
a23d38ac77 Move waiterForXyz() functions to Xyz's header file. Implement waiter for (kernel mode) Event, and use it instead. 2018-12-17 16:06:23 +01:00
fincs
c9ee12ce20 Simplify WaiterNode, make it private. Improve UEvent autoclear logic. 2018-12-17 16:06:23 +01:00
fincs
47b786bcea Synchronize eventWait and _waitLoop code 2018-12-17 16:06:23 +01:00
fincs
2e76b2b150 waitN: Fix index bug when there are handles before UEvents in the array 2018-12-17 16:06:23 +01:00
fincs
3c9a84fe68 wait.c: Fix no-timeout handling; use new kernel error result codes 2018-12-17 16:06:23 +01:00
fincs
9144d78031 Stylefixes, part 1 2018-12-17 16:06:23 +01:00
plutooo
eb7d835a79 wait: Rename UsermodeEvent and UsermodeTimer 2018-12-17 16:06:23 +01:00
plutooo
376add30a4 wait: Introduce wait for raw handles too 2018-12-17 16:06:23 +01:00
plutooo
68b4d323a0 utimer: Add TimerType_OneShot 2018-12-17 16:06:23 +01:00
plutooo
0c0261bf2f wait: Improve timer calculation, thanks derrek 2018-12-17 16:06:23 +01:00
plutooo
b38983c1b7 wait: Fix a race 2018-12-17 16:06:23 +01:00
plutooo
eb01ccd097 wait: Doxygen 2018-12-17 16:06:23 +01:00
plutooo
6a6f654526 wait: Final implementation 2018-12-17 16:06:23 +01:00
plutooo
03ddd464a0 arm: Rename armTickToNs(), etc 2018-12-17 16:06:23 +01:00
plutooo
26b17cdae5 kernel: Review comments (move to private interface to private headers, atomics) 2018-12-17 16:06:23 +01:00
plutooo
9da123f916 wait: Check for disabled timer 2018-12-17 16:06:23 +01:00
plutooo
c6fc6a41e5 wait: Bug-fixes and lock-free utimer stop/start 2018-12-17 16:06:23 +01:00
plutooo
370d78453e kernel: Introduce utimer, uevent, and waitN 2018-12-17 16:06:23 +01:00
yellows8
42e7cf44cb Implemented applet IPC code for pushing storages/objects. Added appletPushToGeneralChannel(). 2018-12-16 18:16:01 -05:00
yellows8
3dce07d78c Fixed broken object sending in ipcPrepareHeaderForDomain(), and added serviceSendObject(). 2018-12-16 18:10:37 -05:00
yellows8
f61e9237e6 Added accountGetPreselectedUser. 2018-12-15 21:50:27 -05:00
yellows8
41e75d0b7d Removed AppletStorage.isHandleStorage since it's not usable for storages not created by the current process. Hence, appletStorageGetSize no longer supports HandleStorage. 2018-12-15 18:11:21 -05:00
yellows8
10826dda13 Added appletPopLaunchParameter. 2018-12-15 17:31:36 -05:00
yellows8
3af857575c Added comment to appletStorageMap. 2018-12-15 16:43:53 -05:00
yellows8
d65c2ec94b Added support for tmem with AppletStorage, and added HandleStorage support. applet IPC improvements. 2018-12-15 16:34:23 -05:00
fincs
f5682b267e Add more kernel error result codes 2018-12-14 14:36:36 +01:00
yellows8
1077cc2b46 Implemented AppletStorage. Various IPC improvements in applet.c, etc. 2018-12-13 22:48:48 -05:00
yellows8
8b86e4ecb8 Use domains for applet. 2018-12-12 21:13:01 -05:00
Michael Scire
3cff199b42 Add remaining pm:shell services, address issues 2018-12-10 00:12:46 +01:00
Michael Scire
0fad4244da Add ro:dmnt, ldr:ro. 2018-12-10 00:12:46 +01:00
Michael Scire
8e1ba23b83 pm: Add remaining pm:dmnt services 2018-12-10 00:12:46 +01:00
Michael Scire
0a92b0eb07 ns: Implement all of ns:dev 2018-12-10 00:12:46 +01:00
plutooo
bfad4d4557 Fix whitespace 2018-12-09 19:07:39 +01:00
plutooo
d3da66e418 Fix const specifier 2018-12-09 17:06:58 +01:00
plutooo
c328a74f71 Add fsIsExFatSupported() 2018-12-09 17:06:47 +01:00
Lioncash
69a98dc0cb kernel/svc: Correct SVC instruction values for svcMapPhysicalMemory and svcUnmapPhysicalMemory
0x2A corresponds to svcFlushEntireDataCache, while 0x2B corresponds to
svcFlushDataCache.
2018-12-07 12:19:16 +01:00
Michael Scire
40bccd7838 Add svcTerminateDebugProcess 2018-12-06 13:18:06 +01:00
yellows8
bc2dff0361 Added hidAcquireNpadStyleSetUpdateEventHandle. 2018-12-02 16:48:59 -05:00
Michael Scire
2a831c6196 Fix struct definition for splSetConfig 2018-12-01 21:29:41 +01:00
yellows8
b7b64858a6 Added usb_standard_request from libusb. 2018-11-30 20:13:58 -05:00
yellows8
e986799784 Updated usbhs comments and added usbHsIfIsActive/usbHsIfGetID. 2018-11-30 20:13:58 -05:00
yellows8
ee066a27ee Implemented usbhs endpoints, other adjustments. Updated field name in UsbHsXferReport. Added defines in usb.h from libusb. 2018-11-30 20:13:58 -05:00
yellows8
31cea3a6b6 Implemented usbhs control transfers. Fixed eventCtrlXfer init. Updated a field name in UsbHsXferReport. 2018-11-30 20:13:58 -05:00
yellows8
2049ff081d Updated usbhs comments and store the interface ID in UsbHsClientIfSession. Added: usbHsIfSetInterface, usbHsIfGetInterface, usbHsIfGetAlternateInterface, usbHsIfGetCurrentFrame, and usbHsIfResetDevice. 2018-11-30 20:13:58 -05:00
yellows8
83dfc58adb Moved interface-specific data from UsbHsInterface into UsbHsInterfaceInfo. Added usbHsAcquireUsbIf/usbHsIfClose and the related structs. 2018-11-30 20:13:58 -05:00
yellows8
f1ba199d1c Initial usbhs support. 2018-11-30 20:13:58 -05:00
yellows8
ba68e198db Use PACKED for usb_endpoint_descriptor and usb_config_descriptor. 2018-11-29 17:25:46 -05:00
rsn8887
b2bee550ff Improve documentation of hidMergeSingleJoyAsDualJoy 2018-11-29 11:09:14 -05:00
yellows8
f373b3ca23 Added usbds.h to switch.h. 2018-11-28 21:56:34 -05:00
yellows8
725ac9f00a Moved usb code specific to usbds into seperate .c/.h. 2018-11-28 17:34:53 -05:00
yellows8
528b17c9b5 Added usb_config_descriptor in usb.h. 2018-11-28 17:11:11 -05:00
yellows8
3726eb8950 Use PACKED for _usbDsGetSession resp, required for domains. Use domains for usbds, with changes from @SciresM. 2018-11-28 16:40:45 -05:00
yellows8
68846af044 Removed alignment for object_ids in ipcParseDomainResponse, since official sw doesn't have this. 2018-11-28 16:37:33 -05:00
yellows8
7ae659c2cb Handle the output u8 in _usbDsGetSession, without using it in the callers. 2018-11-28 15:03:06 -05:00
fincs
07cd134d24 Release v1.6.0 2018-11-28 02:09:20 +01:00
yellows8
36bed9f8fc Added support for getting file timestamps via 3.0.0+ fsFsGetFileTimeStampRaw, *stat() timestamps are now set when fsFsGetFileTimeStampRaw is successful. This is now used in fsdev_open() for supporting fstat. The sysver is now checked in fsFsCleanDirectoryRecursively(). Closes #204. 2018-11-20 14:22:19 -05:00
pixel-stuck
a7577f7b56 Add pcvSetVoltageEnabled and pcvGetVoltageEnabled (#208)
* Add pcvSetVoltageEnabled and pcvGetVoltageEnabled
2018-11-19 10:37:59 -05:00
yellows8
8767ea798b Determine whether to use AUDREN_REVISION_1-4 via the sysver, instead of hard-coding it for the 3.0+ rev. Updated comments and added AUDREN_REVISION_5/AUDREN_REVISION_6 defines. 2018-11-17 11:43:24 -05:00
yellows8
e7117a7903 Added enum for hidSetNpadJoyHoldType. Improved hid docs. Use hidSetNpadJoyHoldType during hid init/exit. Closes #206. 2018-11-15 21:36:34 -05:00
rsn8887
33364a8271 support SL/SR buttons on right JoyCons 2018-11-16 00:18:19 +01:00
yellows8
12ee6e502e Fixed register corruption in crt0 introduced by the exception commit. Only handle exceptions when __libnx_exception_handler is defined by the user, and updated comments. 2018-11-14 20:55:17 -05:00
Michael Scire
4e4d5ef320 fatal: Implement fatalWithContext 2018-11-14 19:52:40 -05:00
Michael Scire
e943eb6ea5 Add fs gamecard attribute retrieve commands 2018-11-14 19:52:40 -05:00
Michael Scire
4581e597c0 Add SetSysFlag_RequiresRunRepairTimeReviser 2018-11-14 19:52:40 -05:00
Michael Scire
8bef0e6298 Add GpioPadName_ButtonVol[UpDown] 2018-11-14 19:52:40 -05:00
Michael Scire
7b7bd9dd9d Add setsys fatal commands 2018-11-14 19:52:40 -05:00
Michael Scire
5386edef4f Add gpio wrapper 2018-11-14 19:52:40 -05:00
Michael Scire
dec6f1ffe1 Add i2cOpenSession, i2csessionSendAuto 2018-11-14 19:52:40 -05:00
Michael Scire
3ba8a5aa87 Add lblSwitchBacklightOn and lblSwitchBacklightOff 2018-11-14 19:52:40 -05:00
Michael Scire
8cb9004a2f Add pcvGetClockRate/pcvSetClockRate 2018-11-14 19:52:40 -05:00
Michael Scire
27936900d0 Add enum for PsmBatteryVoltageState 2018-11-14 19:52:40 -05:00
Michael Scire
94dc8f75f9 Add bpcGetSleepButtonState 2018-11-14 19:52:40 -05:00
Michael Scire
ee55b63f79 Add spsm wrapper. 2018-11-14 19:52:40 -05:00
yellows8
5e69f760fb Added support for exception-handling. 2018-11-14 16:17:02 -05:00
SciresM
e19765445d fs: Add fsFsQueryEntry (and fsFsSetArchiveBit helper) (#202)
* fs: Add fsFsSetArchiveBit

* Add fsdevSetArchiveBit wrapper
2018-11-09 22:03:47 -05:00
natinusala
fd4afacb01 Expose appletSetFocusHandlingMode 2018-11-08 19:27:56 -05:00
yellows8
5a078b1205 Use 6.0.0+ _hwopusDecodeInterleaved cmds. 2018-11-06 23:02:40 -05:00
yellows8
6a8dba4eb4 Added support for hwopus multistream. Minor adjustments in hwopus.h. 2018-11-06 15:10:54 -05:00
yellows8
c99518643c Use _hwopusDecodeInterleavedWithPerfOld on 4.0.0+. Use the multistream cmdid when a bool flag is set in HwopusDecoder, which is currently not set. 2018-11-06 10:47:09 -05:00
yellows8
b25be27525 Use BufferType_Normal in auddev. 2018-11-05 11:34:30 -05:00
yellows8
c5d3f0dfb5 Added HwopusHeader struct. 2018-11-04 22:03:25 -05:00
yellows8
a6412e1e3a Fixed swapped output raw fields in hwopusDecodeInterleaved, and also swapped those in the params. 2018-11-04 20:29:38 -05:00
yellows8
34e99d53c2 Added hwopus. 2018-11-04 18:39:04 -05:00
SciresM
7c2d89dc71 psc: Add PmModule support (#200)
* psc: Add PmModule support
2018-11-03 21:40:15 -04:00
yellows8
576302444d Added auddev and AudioDeviceName. 2018-11-02 16:04:09 -04:00
fincs
480174753a Release v1.5.0 2018-10-27 17:42:06 +02:00
fincs
ede79862fb Add threadGetCurHandle 2018-10-27 17:34:44 +02:00
yellows8
ccfb1fd4d2 Use Event in applet instead of raw handles. 2018-10-26 14:00:13 -04:00
yellows8
3b0348654e Use Event in audout/audin instead of raw handles. 2018-10-26 13:41:26 -04:00
yellows8
5dc7505139 Fixed swapped params for svcCreateEvent in eventCreate. 2018-10-26 13:08:45 -04:00
yellows8
49e4e31fcc Added support for psm StateChangeEvent. Added psmGetBatteryVoltageState. Code style adjustments, use serviceIpc*, etc. 2018-10-26 13:07:10 -04:00
yellows8
de79614a12 Added info regarding timeout to the appletLockExit comments. 2018-10-25 12:34:33 -04:00
SciresM
ac853db5f0 set:sys: Add GetFirmwareVersion(2) (#190)
* set:sys: Add GetFirmwareVersion
2018-10-24 17:16:35 -04:00
yellows8
bcddc1ea35 Only allow using video-recording with regular-application, since it's not usable with SystemApplication. Added _appletIsRegularApplication() for this. 2018-10-23 16:23:14 -04:00
tatehaga
b130d96445 barrier implementation using semaphores (#186) 2018-10-23 21:19:26 +02:00
yellows8
318562d13b Init/exit nifm in socketInitialize/socketExit, the user app no longer has to manually handle this when using gethostid/gethostname. Use domains for nifm. Style adjustments in nifm.c. 2018-10-23 14:04:58 -04:00
plutooo
6977cb24f5 virtmem: Fix minor regression
We need to fetch alias region to make sure virtmemReserve() avoids returning addresses inside of it
2018-10-23 04:07:01 +02:00
Michael Scire
e942b9cc25 virtmem: Fix stack region mapping on 1.0.0 2018-10-22 22:34:11 +02:00
yellows8
a15c9945a7 Updated comments regarding requirements for using video-recording, etc. Changed appletInitializeGamePlayRecording to (void) since the sysmodule only supports a fixed size. 2018-10-22 13:37:25 -04:00
yellows8
0fb0f67d2e hidGetControllerConnected -> hidIsControllerConnected 2018-10-22 12:20:28 -04:00
yellows8
0370140c12 Added hidGetControllerConnected() and updated CONTROLLER_P1_AUTO comment. 2018-10-22 12:13:59 -04:00
yellows8
a62e29d5cf Added support for applet video-recording, currently not usable. In appletExit, only call appletSetFocusHandlingMode when g_appletExitProcessFlag is zero, so that it isn't called twice during proc-exit. 2018-10-21 22:24:54 -04:00
yellows8
cfbc3e9278 Added usbCommsSetErrorHandling, don't throw fatalSimple for usbComms by default. 2018-10-19 12:34:17 -04:00
Cpasjuste
493d433ac2 netinet: fix missing declarations (#187) 2018-10-19 17:15:24 +02:00
yellows8
319cc578ca Fixed swapped params for memalign in jitCreate(). 2018-10-17 14:47:14 -04:00
fincs
8e1736c480 Add RandomSeed (14) homebrew ABI key and related handling 2018-10-17 17:17:05 +02:00
yellows8
6a9d194fe3 Added hidGetControllerColors and HidControllerColors. Changed rightColorbuttons to rightColorButtons in HidControllerHeader. Updated CONTROLLER_P1_AUTO comment. 2018-10-16 22:45:44 -04:00
TuxSH
052fb34397 Reduce usage of malloc in select and poll. Fix poll not acceping -1 fds 2018-10-16 18:53:05 -04:00
fincs
fba43b0f10 nvBufferCreate: use separate is_cpu_cacheable/is_gpu_cacheable parameters 2018-10-17 00:32:47 +02:00
Michael Scire
86a25e1edd Make fsp-ldr use domains 2018-10-16 17:56:39 -04:00
Michael Scire
d67ae02bc5 Add domain support to fsp-srv 2018-10-16 17:56:39 -04:00
Michael Scire
40e0bf4db7 Refactor service IPC to support domains. 2018-10-16 17:56:39 -04:00
yellows8
cde495241c Added _hidActivateNpad/_hidDeactivateNpad for internal use in hidInitialize/hidExit. Added hidSetNpadJoyHoldType. Added _hidCmdWithInputU64 and _hidCmdWithNoInput. 2018-10-15 12:10:07 -04:00
yellows8
d4277b6d32 Added hidSetSupportedNpadIdType(), which is automatically called during init. Closes #148, however vibration disable+enable in system-settings is still needed. 2018-10-14 21:47:26 -04:00
yellows8
57ad3cc1d2 Clarified comments for appletLockExit. 2018-10-14 16:05:24 -04:00
yellows8
52686826d1 Added fsdevGetDeviceFileSystem(). 2018-10-12 22:13:14 -04:00
yellows8
c1b4b95bd7 Updated wiki URLs. 2018-10-11 21:44:51 -04:00
yellows8
42d3c32b37 Use FatalType_ErrorReportAndErrorScreen instead of FatalType_ErrorScreen, on pre-3.0.0. FatalType_ErrorScreen is only available with 3.0.0+, this fixes a regression where using fatalSimple on pre-3.0.0 caused a system hang. 2018-10-11 15:41:05 -04:00
SciresM
347e3b3156 Refactor usb:ds, add 5.0.0+ support to usbComms. (#181)
* Refactor usb:ds, add support for 5.0.0+. Closes #109.
2018-10-11 15:35:22 -04:00
yellows8
25052190d2 Added comment regarding PlSharedFontType_NintendoExt. 2018-10-09 11:25:25 -04:00
Samuel P
74ebf370dd add an exit request hook type, allow to delay exit (#183)
* add an exit request hook type, allow to delay exit
* appletMainLoop: return false on exit request msg
2018-10-09 11:04:33 -04:00
Thog
8178c0fa45 _socketDeserializeHostent: fix usage of uninitialized h_name 2018-10-08 21:44:30 -04:00
fincs
420d5d4e61 C11 thread support: address standard compilance issues
Also fixes #158
2018-10-06 22:00:31 +02:00
fincs
1563df3921 Refactor console device, see details:
- Added ConsoleRenderer interface, which abstracts all relevant
  operations needed to set up and write characters to a text mode display
- ConsoleFont now has tileWidth/tileHeight parameters
- PrintConsole now holds a pointer to a ConsoleRenderer
- Added consoleExit for deinitializing the console
- Added consoleUpdate for updating the display every frame
- Corrected lots of obsolete/outdated comments
- Separated console software renderer into its own file (console_sw.c)
- Added getDefaultConsoleRenderer weak function, for selecting the
  default console renderer when none (NULL) is specified in PrintConsole
- Software renderer now takes care of gfxInitDefault/gfxExit
- All these changes are backwards compatible with older programs because:
  - gfxInitDefault has double-init protection
  - Old programs don't call consoleUpdate/Exit, but their implementation
    in the software renderer is identical to what old programs were
    already doing anyway
2018-10-06 16:48:03 +02:00
fincs
cc70f19e61 nvservices: increase default tmem size to 8MB 2018-10-06 16:47:53 +02:00
fincs
20204e3c48 NvFence: fix regression on 1.x 2018-10-06 16:47:25 +02:00
yellows8
4fb364060c Added support for timezones, hence localtime() will now return actual localtime. Added timeToCalendarTimeWithMyRule and TimeCalendarTime/TimeCalendarAdditionalInfo, which are used for timezones support. 2018-10-05 19:59:24 -04:00
yellows8
dc011024f9 Call appletSetFocusHandlingMode in appletExit for AppletType_Application. 2018-10-04 22:19:58 -04:00
yellows8
6d2699b38d Added pmshellGetApplicationPid(). 2018-10-04 18:44:45 -04:00
yellows8
b4859873ec Added env AppletFlags handling. Don't enter the msg-loop for AppletType_Application when the output from _appletGetCurrentFocusState is already 1. This fixes the hang issue with AppletType_Application where applet init with AppletType_Application was previously done. Moved AppletType_*Application checks into a dedicated function which also checks for AppletType_SystemApplication, hence some of these funcs which didn't check for AppletType_SystemApplication now support it. 2018-10-04 18:06:00 -04:00
yellows8
96dce1a8b6 In __libnx_gtod set errno to EIO instead of EINVAL when __boottime is invalid due to timeGetCurrentTime() failing during time init, and added this to __libnx_clock_gettime. Set errno to ENOSYS in __libnx_clock_settime. 2018-10-03 20:55:58 -04:00
yellows8
0b1b7039ca Changed the value of TimeType_Default to TimeType_UserSystemClock. When timeGetCurrentTime fails where __nx_time_type isn't TimeType_Default, call it again with TimeType_Default. 2018-10-03 19:48:33 -04:00
yellows8
16bbf3411e Added automatic process exit handling with applet cmds, see __nx_applet_exit_mode. appletSelfExit is no longer user-accessible, see __nx_applet_exit_mode instead. Added envSetExitFuncPtr. Added disabled _appletSetTerminateResult func. 2018-10-03 19:04:48 -04:00
yellows8
beef09a27e Removed appletSelfExit and replaced it with the previously disabled _appletSelfExit, now renamed to appletSelfExit. 2018-10-01 18:35:49 -04:00
Vicki Pfau
7a952ab39b hid: Uncomment function that works now 2018-09-30 16:39:51 -04:00
Vicki Pfau
8add42378b hid: Add SixAxis sensor support 2018-09-30 16:39:51 -04:00
Vicki Pfau
68b2ad0c1e hid: Call SetSupportedNpadStyleSet to enable additional Npad features 2018-09-27 16:23:37 -04:00
fincs
eb11e25dc5 Add Module_HomebrewAbi/Loader. Reassign Module_LibnxBinder, as it inadvertently collided with Module_HomebrewLoader. 2018-09-27 21:03:29 +02:00
yellows8
1cc3547990 Removed TODO comment in _hidGetDeviceHandles(). 2018-09-27 12:01:58 -04:00
yellows8
1267019d83 Added partial support for hid SixAxisSensor. Moved some hid ipc code into a single func for using cmds with an input u32. Moved handle-generation code from hidInitializeVibrationDevices into a new func, with some improvements + support for SixAxisSensor. 2018-09-26 22:28:40 -04:00
TuxSH
3bd7ca5f7e Reword ProcessState enum fields 2018-09-26 21:11:02 +02:00
fincs
67886bb3df nvGpuClose: correct order of operations 2018-09-26 21:08:30 +02:00
leo60228
1c948e2d32 applet: Add appletSelfExit() 2018-09-21 15:55:06 -04:00
384 changed files with 83044 additions and 18649 deletions

View File

@ -1,34 +0,0 @@
{
"targets": {
"lib": {
"buildenv": "docker:devkitpro/devkita64",
"buildcmd": [
"sudo -E make -j${PARALLEL} -C nx install"
]
},
"docs": {
// Only invoke docs target when building from master branch
"branch": "master",
"buildenv": "xenial-amd64",
"builddeps": [
"doxygen"
],
"buildcmd": [
"cd nx", "doxygen"
],
"artifacts": [{
"source": "nx/docs/html",
"destination": {
"type": "git",
"branch": "gh-pages"
}
}]
}
}
}

22
.github/workflows/build.yaml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Build libnx
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: Test build
runs-on: ubuntu-latest
container:
image: 'devkitpro/devkita64'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: build
run: make -C nx -j$(nproc)

39
.github/workflows/doxygen.yaml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Build documentation
on:
push:
tags: [ v* ]
jobs:
build:
name: Build documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Get current tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
- name: Set up Doxygen
run: sudo apt-get install -y doxygen
- name: Display Doxygen version
run: echo "Doxygen version $(doxygen -v)"
- name: Build documentation
run: |
cd nx
LIBNX_VERSION=${{ steps.vars.outputs.tag }} doxygen Doxyfile
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: nx/docs/html
CLEAN: true
SINGLE_COMMIT: true

3
.gitignore vendored
View File

@ -8,7 +8,10 @@
*.pfs0
Thumbs.db
.*/
!.github/
debug/
release/
lib/
docs/
compile_commands.json
.clangd

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
# Nintendo Switch AArch64-only userland library.
Based on libctru.
[![Build status](https://doozer.io/badge/switchbrew/libnx/buildstatus/master)](https://doozer.io/switchbrew/libnx)
![Build status](https://github.com/switchbrew/libnx/actions/workflows/build.yaml/badge.svg)
# Install instructions
See [Switchbrew](http://switchbrew.org/index.php?title=Setting_up_Development_Environment).
See [Switchbrew](https://switchbrew.org/wiki/Setting_up_Development_Environment).

View File

@ -38,7 +38,7 @@ PROJECT_NAME = "libnx"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "$(TRAVIS_TAG)"
PROJECT_NUMBER = "$(LIBNX_VERSION)"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -8,13 +8,6 @@ endif
include $(DEVKITPRO)/devkitA64/base_rules
export LIBNX_MAJOR := 1
export LIBNX_MINOR := 4
export LIBNX_PATCH := 1
VERSION := $(LIBNX_MAJOR).$(LIBNX_MINOR).$(LIBNX_PATCH)
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
@ -24,14 +17,14 @@ VERSION := $(LIBNX_MAJOR).$(LIBNX_MINOR).$(LIBNX_PATCH)
#---------------------------------------------------------------------------------
TARGET := nx
#BUILD := build
SOURCES := source/arm source/kernel source/services source/nvidia source/nvidia/ioctl source/nvidia/gpu source/display source/audio source/runtime source/runtime/devices source/runtime/util/utf
SOURCES := source/arm source/kernel source/sf source/services source/crypto source/nvidia source/nvidia/ioctl source/display source/audio source/applets source/runtime source/runtime/devices source/runtime/util source/runtime/util/utf
DATA := data
INCLUDES := include external/bsd/include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
CFLAGS := -g -Wall -Werror \
-ffunction-sections \
@ -39,7 +32,7 @@ CFLAGS := -g -Wall -Werror \
$(ARCH) \
$(BUILD_CFLAGS)
CFLAGS += $(INCLUDE) -DSWITCH
CFLAGS += $(INCLUDE) -D__SWITCH__ -DLIBNX_NO_DEPRECATION
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
@ -95,17 +88,14 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
#---------------------------------------------------------------------------------
all: lib/libnx.a lib/libnxd.a
dist-bin: all
@tar --exclude=*~ -cjf libnx-$(VERSION).tar.bz2 include lib default_icon.jpg switch_rules switch.ld switch.specs -C external/bsd include
install: lib/libnx.a lib/libnxd.a
@mkdir -p $(DESTDIR)$(DEVKITPRO)/libnx
@cp -v default_icon.jpg switch_rules switch.ld switch.specs $(DESTDIR)$(DEVKITPRO)/libnx/
@cp -rv include lib $(DESTDIR)$(DEVKITPRO)/libnx/
@cp -rv external/bsd/include $(DESTDIR)$(DEVKITPRO)/libnx/
dist-src:
@tar --exclude=*~ -cjf libnx-src-$(VERSION).tar.bz2 include source data external Makefile default_icon.jpg switch_rules switch.ld switch.specs
dist: dist-src dist-bin
install: dist-bin
mkdir -p $(DESTDIR)$(DEVKITPRO)/libnx
bzip2 -cd libnx-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/libnx
@tar -cjf libnx-`git describe --tags | sed 's/^v//'`.tar.bz2 include source data external Makefile default_icon.jpg switch_rules switch.ld switch.specs
#dox:
# @doxygen Doxyfile

View File

@ -373,7 +373,8 @@ struct ifreq {
struct sockaddr ifr_dstaddr; /* other end of p-to-p link */
struct sockaddr ifr_broadaddr; /* broadcast address */
struct ifreq_buffer ifr_buffer; /* user supplied buffer with its length */
short ifr_flags[2]; /* flags (low 16 bits) */
short ifr_flags; /* flags (low 16 bits) */
short ifr_flagshigh; /* flags (high 16 bits) */
short ifr_index; /* interface index */
int ifr_jid; /* jail/vnet */
int ifr_metric; /* metric */

View File

@ -45,6 +45,15 @@
#include <sys/types.h>
#include <machine/endian.h>
#ifndef _IN_ADDR_T_DECLARED
typedef __uint32_t in_addr_t;
#define _IN_ADDR_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED
typedef __uint16_t in_port_t;
#define _IN_PORT_T_DECLARED
#endif
/* Protocols common to RFC 1700, POSIX, and X/Open. */
#define IPPROTO_IP 0 /* dummy for IP */
#define IPPROTO_ICMP 1 /* control message protocol */

2
nx/external/bsd/include/sys/poll.h vendored Normal file
View File

@ -0,0 +1,2 @@
#include <poll.h>

View File

@ -437,8 +437,35 @@ struct cmsghdr {
/* followed by u_char cmsg_data[]; */
};
// socket credential stuff, we don't need this
// cmsg macros, uses some obscure macro
#define _ALIGNBYTES (sizeof(long) - 1)
#define _ALIGN(p) (((unsigned long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
/* given pointer to struct cmsghdr, return pointer to data */
#define CMSG_DATA(cmsg) \
((unsigned char *)(cmsg) + _ALIGN(sizeof(struct cmsghdr)))
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
#define CMSG_NXTHDR(mhdr, cmsg) \
(((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
_ALIGN(sizeof(struct cmsghdr)) > \
((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen) ? \
(struct cmsghdr *)NULL : \
(struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
/*
* RFC 2292 requires to check msg_controllen, in case that the kernel returns
* an empty list for some reasons.
*/
#define CMSG_FIRSTHDR(mhdr) \
((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
(struct cmsghdr *)(mhdr)->msg_control : \
(struct cmsghdr *)NULL)
/* Length of the contents of a control message of length len */
#define CMSG_LEN(len) (_ALIGN(sizeof(struct cmsghdr)) + (len))
/* Length of the space taken up by a padded control message of length len */
#define CMSG_SPACE(len) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(len))
/* "Socket"-level control message types: */
#define SCM_RIGHTS 0x01 /* access rights (array of int) */

View File

@ -1,33 +0,0 @@
#pragma once
#include "../switch/types.h"
#include "../switch/result.h"
#include "../switch/kernel/mutex.h"
#include "../switch/kernel/condvar.h"
#include "../switch/kernel/thread.h"
#define TSS_DTOR_ITERATIONS 1
typedef struct {
Thread thr;
int rc;
} __thrd_t;
typedef CondVar cnd_t;
typedef __thrd_t* thrd_t;
typedef u32 tss_t;
#define _MTX_INITIALIZER_NP {mtx_plain, {0}}
typedef struct mtx_t {
int type;
union {
Mutex mutex;
RMutex rmutex;
};
} mtx_t;
#define ONCE_FLAG_INIT {0,_MTX_INITIALIZER_NP,0}
typedef struct once_flag_t {
int status;
mtx_t mutex;
cnd_t cond;
} once_flag;

View File

@ -17,14 +17,17 @@ extern "C" {
#include "switch/arm/tls.h"
#include "switch/arm/cache.h"
#include "switch/arm/atomics.h"
#include "switch/arm/counter.h"
#include "switch/kernel/svc.h"
#include "switch/kernel/wait.h"
#include "switch/kernel/tmem.h"
#include "switch/kernel/shmem.h"
#include "switch/kernel/mutex.h"
#include "switch/kernel/event.h"
#include "switch/kernel/levent.h"
#include "switch/kernel/uevent.h"
#include "switch/kernel/utimer.h"
#include "switch/kernel/rwlock.h"
#include "switch/kernel/condvar.h"
#include "switch/kernel/thread.h"
@ -33,7 +36,13 @@ extern "C" {
#include "switch/kernel/detect.h"
#include "switch/kernel/random.h"
#include "switch/kernel/jit.h"
#include "switch/kernel/ipc.h"
#include "switch/kernel/barrier.h"
#include "switch/sf/hipc.h"
#include "switch/sf/cmif.h"
#include "switch/sf/service.h"
#include "switch/sf/sessionmgr.h"
#include "switch/sf/tipc.h"
#include "switch/services/sm.h"
#include "switch/services/smm.h"
@ -43,53 +52,124 @@ extern "C" {
#include "switch/services/acc.h"
#include "switch/services/apm.h"
#include "switch/services/applet.h"
#include "switch/services/async.h"
#include "switch/services/audctl.h"
#include "switch/services/audin.h"
#include "switch/services/audout.h"
#include "switch/services/audrec.h"
#include "switch/services/audren.h"
#include "switch/services/auddev.h"
#include "switch/services/hwopus.h"
#include "switch/services/csrng.h"
#include "switch/services/lbl.h"
#include "switch/services/i2c.h"
#include "switch/services/gpio.h"
#include "switch/services/uart.h"
#include "switch/services/bpc.h"
#include "switch/services/pcv.h"
#include "switch/services/clkrst.h"
#include "switch/services/fan.h"
#include "switch/services/pgl.h"
#include "switch/services/psm.h"
//#include "switch/services/bsd.h" Use switch/runtime/devices/socket.h instead
#include "switch/services/spsm.h"
//#include "switch/services/bsd.h" Use <sys/socket.h> instead
//#include "switch/services/sfdnsres.h" Use <netdb.h> instead
//#include "switch/services/htcs.h"
#include "switch/services/fatal.h"
#include "switch/services/time.h"
#include "switch/services/usb.h"
#include "switch/services/usbds.h"
#include "switch/services/usbhs.h"
#include "switch/services/hid.h"
#include "switch/services/hidbus.h"
#include "switch/services/hiddbg.h"
#include "switch/services/hidsys.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/nim.h"
#include "switch/services/ns.h"
#include "switch/services/ldr.h"
#include "switch/services/ro.h"
#include "switch/services/tc.h"
#include "switch/services/ts.h"
#include "switch/services/pm.h"
#include "switch/services/set.h"
#include "switch/services/ssl.h"
#include "switch/services/lr.h"
#include "switch/services/bt.h"
#include "switch/services/btdrv.h"
#include "switch/services/btm.h"
#include "switch/services/btmu.h"
#include "switch/services/btmsys.h"
#include "switch/services/spl.h"
#include "switch/services/ncm.h"
#include "switch/services/psc.h"
#include "switch/services/caps.h"
#include "switch/services/capsa.h"
#include "switch/services/capsc.h"
#include "switch/services/capsdc.h"
#include "switch/services/capsu.h"
#include "switch/services/capssc.h"
#include "switch/services/capssu.h"
#include "switch/services/capmtp.h"
#include "switch/services/nfc.h"
#include "switch/services/wlaninf.h"
#include "switch/services/pctl.h"
#include "switch/services/pdm.h"
#include "switch/services/grc.h"
#include "switch/services/friends.h"
#include "switch/services/notif.h"
#include "switch/services/mii.h"
#include "switch/services/miiimg.h"
#include "switch/services/ldn.h"
#include "switch/services/lp2p.h"
#include "switch/services/news.h"
#include "switch/services/ins.h"
#include "switch/services/ectx.h"
#include "switch/services/avm.h"
#include "switch/services/mm.h"
#include "switch/display/gfx.h"
#include "switch/display/binder.h"
#include "switch/display/parcel.h"
#include "switch/display/buffer_producer.h"
#include "switch/display/nvgfx.h"
#include "switch/display/native_window.h"
#include "switch/display/framebuffer.h"
#include "switch/nvidia/ioctl.h"
#include "switch/nvidia/buffer.h"
#include "switch/nvidia/graphic_buffer.h"
#include "switch/nvidia/fence.h"
#include "switch/nvidia/map.h"
#include "switch/nvidia/address_space.h"
#include "switch/nvidia/channel.h"
#include "switch/nvidia/info.h"
#include "switch/nvidia/fence.h"
#include "switch/nvidia/gpu/cmd_list.h"
#include "switch/nvidia/gpu/gpfifo.h"
#include "switch/nvidia/gpu/zcull_ctx.h"
#include "switch/nvidia/gpu/3d_ctx.h"
#include "switch/nvidia/gpu/error_notifier.h"
#include "switch/nvidia/gpu/gpu.h"
#include "switch/nvidia/gpu.h"
#include "switch/nvidia/gpu_channel.h"
#include "switch/audio/driver.h"
#include "switch/applets/libapplet.h"
#include "switch/applets/album_la.h"
#include "switch/applets/friends_la.h"
#include "switch/applets/hid_la.h"
#include "switch/applets/mii_la.h"
#include "switch/applets/nfp_la.h"
#include "switch/applets/nifm_la.h"
#include "switch/applets/pctlauth.h"
#include "switch/applets/psel.h"
#include "switch/applets/error.h"
#include "switch/applets/swkbd.h"
#include "switch/applets/web.h"
#include "switch/runtime/env.h"
#include "switch/runtime/hosversion.h"
#include "switch/runtime/diag.h"
#include "switch/runtime/nxlink.h"
#include "switch/runtime/resolver.h"
#include "switch/runtime/pad.h"
#include "switch/runtime/ringcon.h"
#include "switch/runtime/btdev.h"
#include "switch/runtime/util/utf.h"
@ -99,6 +179,18 @@ extern "C" {
#include "switch/runtime/devices/romfs_dev.h"
#include "switch/runtime/devices/socket.h"
#include "switch/crypto/aes.h"
#include "switch/crypto/aes_cbc.h"
#include "switch/crypto/aes_ctr.h"
#include "switch/crypto/aes_xts.h"
#include "switch/crypto/cmac.h"
#include "switch/crypto/sha256.h"
#include "switch/crypto/sha1.h"
#include "switch/crypto/hmac.h"
#include "switch/crypto/crc.h"
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,31 @@
/**
* @file album_la.h
* @brief Wrapper for using the Album LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// Arg type values pushed for the applet input storage, stored as an u8.
typedef enum {
AlbumLaArg_ShowAlbumFiles = 0, ///< ShowAlbumFiles. Only displays AlbumFiles associated with the application which launched the Album applet, with the filter button disabled.
AlbumLaArg_ShowAllAlbumFiles = 1, ///< ShowAllAlbumFiles. Displays all AlbumFiles, with filtering allowed.
AlbumLaArg_ShowAllAlbumFilesForHomeMenu = 2, ///< ShowAllAlbumFilesForHomeMenu. Similar to ::AlbumLaArg_ShowAllAlbumFiles.
} AlbumLaArg;
/**
* @brief Launches the applet with ::AlbumLaArg_ShowAlbumFiles and playStartupSound=false.
*/
Result albumLaShowAlbumFiles(void);
/**
* @brief Launches the applet with ::AlbumLaArg_ShowAllAlbumFiles and playStartupSound=false.
*/
Result albumLaShowAllAlbumFiles(void);
/**
* @brief Launches the applet with ::AlbumLaArg_ShowAllAlbumFilesForHomeMenu and playStartupSound=true.
*/
Result albumLaShowAllAlbumFilesForHomeMenu(void);

View File

@ -0,0 +1,314 @@
/**
* @file error.h
* @brief Wrapper for using the error LibraryApplet.
* @author StuntHacks, yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/set.h"
/// Error type for ErrorCommonHeader.type.
typedef enum {
ErrorType_Normal = 0, ///< Normal
ErrorType_System = 1, ///< System
ErrorType_Application = 2, ///< Application
ErrorType_Eula = 3, ///< EULA
ErrorType_Pctl = 4, ///< Parental Controls
ErrorType_Record = 5, ///< Record
ErrorType_SystemUpdateEula = 8, ///< SystemUpdateEula
} ErrorType;
/// Stores error-codes which are displayed as XXXX-XXXX, low for the former and desc for the latter.
typedef struct {
u32 low; ///< The module portion of the error, normally this should be set to module + 2000.
u32 desc; ///< The error description.
} ErrorCode;
/// Error type for ErrorContext.type
typedef enum {
ErrorContextType_None = 0, ///< None
ErrorContextType_Http = 1, ///< Http
ErrorContextType_FileSystem = 2, ///< FileSystem
ErrorContextType_WebMediaPlayer = 3, ///< WebMediaPlayer
ErrorContextType_LocalContentShare = 4, ///< LocalContentShare
} ErrorContextType;
/// Error context.
typedef struct {
u8 type; ///< Type, see \ref ErrorContextType.
u8 pad[7]; ///< Padding
u8 data[0x1f4]; ///< Data
Result res; ///< Result
} ErrorContext;
/// Common header for the start of the arg storage.
typedef struct {
u8 type; ///< Type, see \ref ErrorType.
u8 jumpFlag; ///< When clear, this indicates WithoutJump.
u8 unk_x2[3]; ///< Unknown
u8 contextFlag; ///< When set with ::ErrorType_Normal, indicates that an additional storage is pushed for \ref ErrorResultBacktrace. [4.0.0+] Otherwise, when set indicates that an additional storage is pushed for \ref ErrorContext.
u8 resultFlag; ///< ErrorCommonArg: When clear, errorCode is used, otherwise the applet generates the error-code from res.
u8 contextFlag2; ///< Similar to contextFlag except for ErrorCommonArg, indicating \ref ErrorContext is used.
} ErrorCommonHeader;
/// Common error arg data.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
ErrorCode errorCode; ///< \ref ErrorCode
Result res; ///< Result
} ErrorCommonArg;
/// Error arg data for certain errors with module PCTL.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
Result res; ///< Result
} ErrorPctlArg;
/// ResultBacktrace
typedef struct {
s32 count; ///< Total entries in the backtrace array.
Result backtrace[0x20]; ///< Result backtrace.
} ErrorResultBacktrace;
/// Error arg data for EULA.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
SetRegion regionCode; ///< \ref SetRegion
} ErrorEulaArg;
/// Additional input storage data for \ref errorSystemUpdateEulaShow.
typedef struct {
u8 data[0x20000]; ///< data
} ErrorEulaData;
/// Error arg data for Record.
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
ErrorCode errorCode; ///< \ref ErrorCode
u64 timestamp; ///< POSIX timestamp.
} ErrorRecordArg;
/// SystemErrorArg
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
ErrorCode errorCode; ///< \ref ErrorCode
u64 languageCode; ///< See set.h.
char dialogMessage[0x800]; ///< UTF-8 Dialog message.
char fullscreenMessage[0x800]; ///< UTF-8 Fullscreen message (displayed when the user clicks on "Details").
} ErrorSystemArg;
/// Error system config.
typedef struct {
ErrorSystemArg arg; ///< Arg data.
ErrorContext ctx; ///< Optional error context.
} ErrorSystemConfig;
/// ApplicationErrorArg
typedef struct {
ErrorCommonHeader hdr; ///< Common header.
u32 errorNumber; ///< Raw decimal error number which is displayed in the dialog.
u64 languageCode; ///< See set.h.
char dialogMessage[0x800]; ///< UTF-8 Dialog message.
char fullscreenMessage[0x800]; ///< UTF-8 Fullscreen message (displayed when the user clicks on "Details").
} NX_PACKED ErrorApplicationArg;
/// Error application config.
typedef struct {
ErrorApplicationArg arg; ///< Arg data.
} ErrorApplicationConfig;
/**
* @brief Creates an \ref ErrorCode.
* @param low The module portion of the error, normally this should be set to module + 2000.
* @param desc The error description.
*/
static inline ErrorCode errorCodeCreate(u32 low, u32 desc) {
return (ErrorCode){low, desc};
}
/**
* @brief Creates an \ref ErrorCode with the input Result. Wrapper for \ref errorCodeCreate.
* @param res Input Result.
*/
static inline ErrorCode errorCodeCreateResult(Result res) {
return errorCodeCreate(2000 + R_MODULE(res), R_DESCRIPTION(res));
}
/**
* @brief Creates an invalid \ref ErrorCode.
*/
static inline ErrorCode errorCodeCreateInvalid(void) {
return (ErrorCode){0};
}
/**
* @brief Checks whether the input ErrorCode is valid.
* @param errorCode \ref ErrorCode
*/
static inline bool errorCodeIsValid(ErrorCode errorCode) {
return errorCode.low!=0;
}
/**
* @brief Launches the applet for displaying the specified Result.
* @param res Result
* @param jumpFlag Jump flag, normally this is true.
* @param ctx Optional \ref ErrorContext, can be NULL. Unused when jumpFlag=false. Ignored on pre-4.0.0, since it's only available for [4.0.0+].
* @note Sets the following fields: jumpFlag and contextFlag2. Uses ::ErrorType_Normal normally.
* @note For module=PCTL errors with desc 100-119 this sets uses ::ErrorType_Pctl, in which case the applet will display the following special dialog: "This software is restricted by Parental Controls".
* @note If the input Result is 0xC8A2, the applet will display a special dialog regarding the current application requiring a software update, with buttons "Later" and "Restart".
* @note [3.0.0+] If the input Result is 0xCAA2, the applet will display a special dialog related to DLC version.
* @warning This applet creates an error report that is logged in the system, when not handling the above special dialogs. Proceed at your own risk!
*/
Result errorResultShow(Result res, bool jumpFlag, const ErrorContext* ctx);
/**
* @brief Launches the applet for displaying the specified ErrorCode.
* @param errorCode \ref ErrorCode
* @param jumpFlag Jump flag, normally this is true.
* @param ctx Optional \ref ErrorContext, can be NULL. Unused when jumpFlag=false. Ignored on pre-4.0.0, since it's only available for [4.0.0+].
* @note Sets the following fields: jumpFlag and contextFlag2. resultFlag=1. Uses ::ErrorType_Normal.
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorCodeShow(ErrorCode errorCode, bool jumpFlag, const ErrorContext* ctx);
/**
* @brief Creates an ErrorResultBacktrace struct.
* @param backtrace \ref ErrorResultBacktrace struct.
* @param count Total number of entries.
* @param entries Input array of Result.
*/
Result errorResultBacktraceCreate(ErrorResultBacktrace* backtrace, s32 count, const Result* entries);
/**
* @brief Launches the applet for \ref ErrorResultBacktrace.
* @param backtrace ErrorResultBacktrace struct.
* @param res Result
* @note Sets the following fields: jumpFlag=1, contextFlag=1, and uses ::ErrorType_Normal.
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorResultBacktraceShow(Result res, const ErrorResultBacktrace* backtrace);
/**
* @brief Launches the applet for displaying the EULA.
* @param RegionCode \ref SetRegion
* @note Sets the following fields: jumpFlag=1, regionCode, and uses ::ErrorType_Eula.
*/
Result errorEulaShow(SetRegion RegionCode);
/**
* @brief Launches the applet for displaying the system-update EULA.
* @param RegionCode \ref SetRegion
* @param eula EULA data. Address must be 0x1000-byte aligned.
* @note Sets the following fields: jumpFlag=1, regionCode, and uses ::ErrorType_SystemUpdateEula.
*/
Result errorSystemUpdateEulaShow(SetRegion RegionCode, const ErrorEulaData* eula);
/**
* @brief Launches the applet for displaying an error full-screen, using the specified ErrorCode and timestamp.
* @param errorCode \ref ErrorCode
* @param timestamp POSIX timestamp.
* @note Sets the following fields: jumpFlag=1, errorCode, timestamp, and uses ::ErrorType_Record.
* @note The applet does not log an error report for this. error*RecordShow is used by qlaunch for displaying previously logged error reports.
*/
Result errorCodeRecordShow(ErrorCode errorCode, u64 timestamp);
/**
* @brief Launches the applet for displaying an error full-screen, using the specified Result and timestamp.
* @param res Result
* @param timestamp POSIX timestamp.
* @note Wrapper for \ref errorCodeRecordShow, see \ref errorCodeRecordShow notes.
*/
static inline Result errorResultRecordShow(Result res, u64 timestamp) {
return errorCodeRecordShow(errorCodeCreateResult(res), timestamp);
}
/**
* @brief Creates an ErrorSystemConfig struct.
* @param c ErrorSystemConfig struct.
* @param dialog_message UTF-8 dialog message.
* @param fullscreen_message UTF-8 fullscreen message, displayed when the user clicks on "Details". Optional, can be NULL (which disables displaying Details).
* @note Sets the following fields: {strings}, and uses ::ErrorType_System. The rest are cleared.
* @note On pre-5.0.0 this will initialize languageCode by using: setInitialize(), setMakeLanguageCode(SetLanguage_ENUS, ...), and setExit(). This is needed since an empty languageCode wasn't supported until [5.0.0+] (which would also use SetLanguage_ENUS).
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorSystemCreate(ErrorSystemConfig* c, const char* dialog_message, const char* fullscreen_message);
/**
* @brief Launches the applet with the specified config.
* @param c ErrorSystemConfig struct.
*/
Result errorSystemShow(ErrorSystemConfig* c);
/**
* @brief Sets the error code.
* @param c ErrorSystemConfig struct.
* @param errorCode \ref ErrorCode
*/
static inline void errorSystemSetCode(ErrorSystemConfig* c, ErrorCode errorCode) {
c->arg.errorCode = errorCode;
}
/**
* @brief Sets the error code, using the input Result. Wrapper for \ref errorSystemSetCode.
* @param c ErrorSystemConfig struct.
* @param res The Result to set.
*/
static inline void errorSystemSetResult(ErrorSystemConfig* c, Result res) {
errorSystemSetCode(c, errorCodeCreateResult(res));
}
/**
* @brief Sets the LanguageCode.
* @param c ErrorSystemConfig struct.
* @param LanguageCode LanguageCode, see set.h.
*/
static inline void errorSystemSetLanguageCode(ErrorSystemConfig* c, u64 LanguageCode) {
c->arg.languageCode = LanguageCode;
}
/**
* @brief Sets the ErrorContext.
* @note Only available on [4.0.0+], on older versions this will return without setting the context.
* @param c ErrorSystemConfig struct.
* @param ctx ErrorContext, NULL to clear it.
*/
void errorSystemSetContext(ErrorSystemConfig* c, const ErrorContext* ctx);
/**
* @brief Creates an ErrorApplicationConfig struct.
* @param c ErrorApplicationConfig struct.
* @param dialog_message UTF-8 dialog message.
* @param fullscreen_message UTF-8 fullscreen message, displayed when the user clicks on "Details". Optional, can be NULL (which disables displaying Details).
* @note Sets the following fields: jumpFlag=1, {strings}, and uses ::ErrorType_Application. The rest are cleared.
* @note On pre-5.0.0 this will initialize languageCode by using: setInitialize(), setMakeLanguageCode(SetLanguage_ENUS, ...), and setExit(). This is needed since an empty languageCode wasn't supported until [5.0.0+] (which would also use SetLanguage_ENUS).
* @note With [10.0.0+] this must only be used when running under an Application, since otherwise the applet will trigger a fatalerr.
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
*/
Result errorApplicationCreate(ErrorApplicationConfig* c, const char* dialog_message, const char* fullscreen_message);
/**
* @brief Launches the applet with the specified config.
* @param c ErrorApplicationConfig struct.
*/
Result errorApplicationShow(ErrorApplicationConfig* c);
/**
* @brief Sets the error code number.
* @param c ErrorApplicationConfig struct.
* @param errorNumber Error code number. Raw decimal error number which is displayed in the dialog.
*/
static inline void errorApplicationSetNumber(ErrorApplicationConfig* c, u32 errorNumber) {
c->arg.errorNumber = errorNumber;
}
/**
* @brief Sets the LanguageCode.
* @param c ErrorApplicationConfig struct.
* @param LanguageCode LanguageCode, see set.h.
*/
static inline void errorApplicationSetLanguageCode(ErrorApplicationConfig* c, u64 LanguageCode) {
c->arg.languageCode = LanguageCode;
}

View File

@ -0,0 +1,172 @@
/**
* @file friends_la.h
* @brief Wrapper for using the MyPage (friends) LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/acc.h"
#include "../services/friends.h"
/// Arg type values used with \ref FriendsLaArg.
typedef enum {
FriendsLaArgType_ShowFriendList = 0, ///< ShowFriendList. Launches the applet with the "Friend List" menu initially selected.
FriendsLaArgType_ShowUserDetailInfo = 1, ///< ShowUserDetailInfo
FriendsLaArgType_StartSendingFriendRequest = 2, ///< StartSendingFriendRequest
FriendsLaArgType_ShowMethodsOfSendingFriendRequest = 3, ///< ShowMethodsOfSendingFriendRequest. Launches the applet with the "Add Friend" menu initially selected.
FriendsLaArgType_StartFacedFriendRequest = 4, ///< StartFacedFriendRequest. Launches the applet where the "Search for Local Users" menu is initially shown. Returning from this menu will exit the applet.
FriendsLaArgType_ShowReceivedFriendRequestList = 5, ///< ShowReceivedFriendRequestList. Launches the applet where the "Received Friend Requests" menu is initially shown. Returning from this menu will exit the applet.
FriendsLaArgType_ShowBlockedUserList = 6, ///< ShowBlockedUserList. Launches the applet where the "Blocked-User List" menu is initially shown. Returning from this menu will exit the applet.
FriendsLaArgType_ShowMyProfile = 7, ///< ShowMyProfile. Launches the applet with the "Profile" menu initially selected. ShowMyProfileForHomeMenu is identical to this except for playStartupSound=true.
FriendsLaArgType_StartFriendInvitation = 8, ///< [9.0.0+] StartFriendInvitation. Launches the applet for sending online-play invites to friends, where the friends are selected via the UI.
FriendsLaArgType_StartSendingFriendInvitation = 9, ///< [9.0.0+] StartSendingFriendInvitation.
FriendsLaArgType_ShowReceivedInvitationDetail = 10, ///< [9.0.0+] ShowReceivedInvitationDetail.
} FriendsLaArgType;
/// Header for the arg struct.
typedef struct {
u32 type; ///< \ref FriendsLaArgType
u32 pad; ///< Padding.
AccountUid uid; ///< \ref AccountUid
} FriendsLaArgHeader;
/// Common data for the arg struct, for the pre-9.0.0 types.
/// This is only set for ::FriendsLaArgType_ShowUserDetailInfo/::FriendsLaArgType_StartSendingFriendRequest, for everything else this is cleared.
typedef struct {
AccountNetworkServiceAccountId id; ///< \ref AccountNetworkServiceAccountId for the other account.
FriendsInAppScreenName first_inAppScreenName; ///< First InAppScreenName.
FriendsInAppScreenName second_inAppScreenName; ///< Second InAppScreenName.
} FriendsLaArgCommonData;
/// Arg struct pushed for the applet input storage, for pre-9.0.0.
typedef struct {
FriendsLaArgHeader hdr; ///< \ref FriendsLaArgHeader
FriendsLaArgCommonData data; ///< \ref FriendsLaArgCommonData
} FriendsLaArgV1;
/// Arg struct pushed for the applet input storage, for [9.0.0+].
typedef struct {
FriendsLaArgHeader hdr; ///< \ref FriendsLaArgHeader
union {
u8 raw[0x1090]; ///< Raw data.
FriendsLaArgCommonData common; ///< \ref FriendsLaArgCommonData
struct {
s32 id_count; ///< \ref AccountNetworkServiceAccountId count, must be 1-15.
u32 pad; ///< Padding.
u64 userdata_size; ///< User-data size, must be <=0x400.
u8 userdata[0x400]; ///< Arbitrary user-data, see above size.
FriendsFriendInvitationGameModeDescription desc; ///< \ref FriendsFriendInvitationGameModeDescription
} start_friend_invitation; ///< Data for ::FriendsLaArgType_StartFriendInvitation.
struct {
s32 id_count; ///< \ref AccountNetworkServiceAccountId count, must be 1-15.
u32 pad; ///< Padding.
AccountNetworkServiceAccountId id_list[16]; ///< \ref AccountNetworkServiceAccountId list, see above count.
u64 userdata_size; ///< User-data size, must be <=0x400.
u8 userdata[0x400]; ///< Arbitrary user-data, see above size.
FriendsFriendInvitationGameModeDescription desc; ///< \ref FriendsFriendInvitationGameModeDescription
} start_sending_friend_invitation; ///< Data for ::FriendsLaArgType_StartSendingFriendInvitation.
struct {
FriendsFriendInvitationId invitation_id; ///< \ref FriendsFriendInvitationId
FriendsFriendInvitationGroupId invitation_group_id; ///< \ref FriendsFriendInvitationGroupId
} show_received_invitation_detail; ///< Data for ::FriendsLaArgType_ShowReceivedInvitationDetail.
} data; ///< Data for each \ref FriendsLaArgType.
} FriendsLaArg;
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowFriendList, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowFriendList(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowUserDetailInfo, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
* @param[in] id \ref AccountNetworkServiceAccountId for the user to show UserDetailInfo for.
* @param[in] first_inAppScreenName First \ref FriendsInAppScreenName.
* @param[in] second_inAppScreenName Second \ref FriendsInAppScreenName.
*/
Result friendsLaShowUserDetailInfo(AccountUid uid, AccountNetworkServiceAccountId id, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartSendingFriendRequest, the specified input, and playStartupSound=false. On success, this will load the output Result from the output storage.
* @param[in] uid \ref AccountUid
* @param[in] id \ref AccountNetworkServiceAccountId to send the friend request to.
* @param[in] first_inAppScreenName First \ref FriendsInAppScreenName.
* @param[in] second_inAppScreenName Second \ref FriendsInAppScreenName.
*/
Result friendsLaStartSendingFriendRequest(AccountUid uid, AccountNetworkServiceAccountId id, const FriendsInAppScreenName *first_inAppScreenName, const FriendsInAppScreenName *second_inAppScreenName);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowMethodsOfSendingFriendRequest, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowMethodsOfSendingFriendRequest(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartFacedFriendRequest, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaStartFacedFriendRequest(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowReceivedFriendRequestList, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowReceivedFriendRequestList(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowBlockedUserList, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowBlockedUserList(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowMyProfile, the specified input, and playStartupSound=false.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowMyProfile(AccountUid uid);
/**
* @brief Same as \ref friendsLaShowMyProfile except with playStartupSound=true.
* @param[in] uid \ref AccountUid
*/
Result friendsLaShowMyProfileForHomeMenu(AccountUid uid);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartFriendInvitation, the specified input, and playStartupSound=false. On success, this will load the output Result from the output storage.
* @note Only available on [9.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] id_count \ref AccountNetworkServiceAccountId count, must be 1-15. Number of friends to invite.
* @param[in] desc \ref FriendsFriendInvitationGameModeDescription
* @param[in] userdata Arbitrary user-data. Can be NULL.
* @param[in] userdata_size User-data size, must be <=0x400. Can be 0 if userdata is NULL.
*/
Result friendsLaStartFriendInvitation(AccountUid uid, s32 id_count, const FriendsFriendInvitationGameModeDescription *desc, const void* userdata, u64 userdata_size);
/**
* @brief Launches the applet with ::FriendsLaArgType_StartSendingFriendInvitation, the specified input, and playStartupSound=false. On success, this will load the output Result from the output storage.
* @note Only available on [9.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] id_list \ref AccountNetworkServiceAccountId list.
* @param[in] id_count Size of the id_list array in entries, must be 1-15. Number of friends to invite.
* @param[in] desc \ref FriendsFriendInvitationGameModeDescription
* @param[in] userdata Arbitrary user-data. Can be NULL.
* @param[in] userdata_size User-data size, must be <=0x400. Can be 0 if userdata is NULL.
*/
Result friendsLaStartSendingFriendInvitation(AccountUid uid, const AccountNetworkServiceAccountId *id_list, s32 id_count, const FriendsFriendInvitationGameModeDescription *desc, const void* userdata, u64 userdata_size);
/**
* @brief Launches the applet with ::FriendsLaArgType_ShowReceivedInvitationDetail, the specified input, and playStartupSound=false.
* @note Only available on [9.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] invitation_id \ref FriendsFriendInvitationId
* @param[in] invitation_group_id \ref FriendsFriendInvitationGroupId
*/
Result friendsLaShowReceivedInvitationDetail(AccountUid uid, FriendsFriendInvitationId invitation_id, FriendsFriendInvitationGroupId invitation_group_id);

View File

@ -0,0 +1,175 @@
/**
* @file hid_la.h
* @brief Wrapper for using the controller LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/hid.h"
/// Mode values for HidLaControllerSupportArgPrivate::mode.
typedef enum {
HidLaControllerSupportMode_ShowControllerSupport = 0, ///< ShowControllerSupport
HidLaControllerSupportMode_ShowControllerStrapGuide = 1, ///< [3.0.0+] ShowControllerStrapGuide
HidLaControllerSupportMode_ShowControllerFirmwareUpdate = 2, ///< [3.0.0+] ShowControllerFirmwareUpdate
HidLaControllerSupportMode_ShowControllerKeyRemappingForSystem = 4, ///< [11.0.0+] ShowControllerKeyRemappingForSystem
} HidLaControllerSupportMode;
/// ControllerSupportCaller
typedef enum {
HidLaControllerSupportCaller_Application = 0, ///< Application, this is the default.
HidLaControllerSupportCaller_System = 1, ///< System. Skips the firmware-update confirmation dialog. This has the same affect as using the controller-update option from qlaunch System Settings.
} HidLaControllerSupportCaller;
/// ControllerSupportArgPrivate
typedef struct {
u32 private_size; ///< Size of this ControllerSupportArgPrivate struct.
u32 arg_size; ///< Size of the storage following this one (\ref HidLaControllerSupportArg or \ref HidLaControllerFirmwareUpdateArg).
u8 flag0; ///< Flag0
u8 flag1; ///< Flag1
u8 mode; ///< \ref HidLaControllerSupportMode
u8 controller_support_caller; ///< \ref HidLaControllerSupportCaller. Always zero except with \ref hidLaShowControllerFirmwareUpdateForSystem, which sets this to the input param.
u32 npad_style_set; ///< Output from \ref hidGetSupportedNpadStyleSet. With ShowControllerSupportForSystem on pre-3.0.0 this is value 0.
u32 npad_joy_hold_type; ///< Output from \ref hidGetNpadJoyHoldType. With ShowControllerSupportForSystem on pre-3.0.0 this is value 1.
} HidLaControllerSupportArgPrivate;
/// Common header used by HidLaControllerSupportArg*.
/// max_supported_players is 4 on pre-8.0.0, 8 on [8.0.0+]. player_count_min and player_count_max are overriden with value 4 when larger than value 4, during conversion handling for \ref HidLaControllerSupportArg on pre-8.0.0.
typedef struct {
s8 player_count_min; ///< playerCountMin. Must be >=0 and <=max_supported_players.
s8 player_count_max; ///< playerCountMax. Must be >=1 and <=max_supported_players.
u8 enable_take_over_connection; ///< enableTakeOverConnection, non-zero to enable. Disconnects the controllers when not enabled.
u8 enable_left_justify; ///< enableLeftJustify, non-zero to enable.
u8 enable_permit_joy_dual; ///< enablePermitJoyDual, non-zero to enable.
u8 enable_single_mode; ///< enableSingleMode, non-zero to enable. Enables using a single player in handheld-mode, dual-mode, or single-mode (player_count_* are overridden). Using handheld-mode is not allowed if this is not enabled.
u8 enable_identification_color; ///< When non-zero enables using identification_color.
} HidLaControllerSupportArgHeader;
/// Identification color used by HidLaControllerSupportArg*. When HidLaControllerSupportArgHeader::enable_identification_color is set this controls the color of the UI player box outline.
typedef struct {
u8 r; ///< Red color component.
u8 g; ///< Green color component.
u8 b; ///< Blue color component.
u8 a; ///< Alpha color component.
} HidLaControllerSupportArgColor;
/// ControllerSupportArg for [1.0.0+].
typedef struct {
HidLaControllerSupportArgHeader hdr; ///< \ref HidLaControllerSupportArgHeader
HidLaControllerSupportArgColor identification_color[4]; ///< \ref HidLaControllerSupportArgColor for each player, see HidLaControllerSupportArgHeader::enable_identification_color.
u8 enable_explain_text; ///< Enables using the ExplainText data when non-zero.
char explain_text[4][0x81]; ///< ExplainText for each player, NUL-terminated UTF-8 strings.
} HidLaControllerSupportArgV3;
/// ControllerSupportArg for [8.0.0+], converted to \ref HidLaControllerSupportArgV3 on pre-8.0.0.
typedef struct {
HidLaControllerSupportArgHeader hdr; ///< \ref HidLaControllerSupportArgHeader
HidLaControllerSupportArgColor identification_color[8]; ///< \ref HidLaControllerSupportArgColor for each player, see HidLaControllerSupportArgHeader::enable_identification_color.
u8 enable_explain_text; ///< Enables using the ExplainText data when non-zero.
char explain_text[8][0x81]; ///< ExplainText for each player, NUL-terminated UTF-8 strings.
} HidLaControllerSupportArg;
/// ControllerFirmwareUpdateArg
typedef struct {
u8 enable_force_update; ///< enableForceUpdate, non-zero to enable. Default is 0. Forces a firmware update when enabled, without an UI option to skip it.
u8 pad[3]; ///< Padding.
} HidLaControllerFirmwareUpdateArg;
/// ControllerKeyRemappingArg
typedef struct {
u64 unk_x0; ///< Unknown
u32 unk_x8; ///< Unknown
u8 pad[0x4]; ///< Padding
} HidLaControllerKeyRemappingArg;
/// ControllerSupportResultInfo. First 8-bytes from the applet output storage.
typedef struct {
s8 player_count; ///< playerCount.
u8 pad[3]; ///< Padding.
u32 selected_id; ///< \ref HidNpadIdType, selectedId.
} HidLaControllerSupportResultInfo;
/// Struct for the applet output storage.
typedef struct {
HidLaControllerSupportResultInfo info; ///< \ref HidLaControllerSupportResultInfo
u32 res; ///< Output res value.
} HidLaControllerSupportResultInfoInternal;
/**
* @brief Initializes a \ref HidLaControllerSupportArg with the defaults.
* @note This clears the arg, then does: HidLaControllerSupportArgHeader::player_count_min = 0, HidLaControllerSupportArgHeader::player_count_max = 4, HidLaControllerSupportArgHeader::enable_take_over_connection = 1, HidLaControllerSupportArgHeader::enable_left_justify = 1, and HidLaControllerSupportArgHeader::enable_permit_joy_dual = 1.
* @note If preferred, you can also memset \ref HidLaControllerSupportArg manually and initialize it yourself.
* @param[out] arg \ref HidLaControllerSupportArg
*/
void hidLaCreateControllerSupportArg(HidLaControllerSupportArg *arg);
/**
* @brief Initializes a \ref HidLaControllerFirmwareUpdateArg with the defaults.
* @note This just uses memset() with the arg.
* @param[out] arg \ref HidLaControllerFirmwareUpdateArg
*/
void hidLaCreateControllerFirmwareUpdateArg(HidLaControllerFirmwareUpdateArg *arg);
/**
* @brief Initializes a \ref HidLaControllerKeyRemappingArg with the defaults.
* @note This just uses memset() with the arg.
* @param[out] arg \ref HidLaControllerKeyRemappingArg
*/
void hidLaCreateControllerKeyRemappingArg(HidLaControllerKeyRemappingArg *arg);
/**
* @brief Sets the ExplainText for the specified player and \ref HidLaControllerSupportArg.
* @note This string is displayed in the UI box for the player.
* @note HidLaControllerSupportArg::enable_explain_text must be set, otherwise this ExplainText is ignored.
* @param arg \ref HidLaControllerSupportArg
* @param[in] str Input ExplainText UTF-8 string, max length is 0x80 excluding NUL-terminator.
+ @oaram[in] id Player controller, must be <8.
*/
Result hidLaSetExplainText(HidLaControllerSupportArg *arg, const char *str, HidNpadIdType id);
/**
* @brief Launches the applet for ControllerSupport.
* @note This seems to only display the applet UI when doing so is actually needed? This doesn't apply to \ref hidLaShowControllerSupportForSystem.
* @param[out] result_info \ref HidLaControllerSupportResultInfo. Optional, can be NULL.
* @param[in] arg \ref HidLaControllerSupportArg
*/
Result hidLaShowControllerSupport(HidLaControllerSupportResultInfo *result_info, const HidLaControllerSupportArg *arg);
/**
* @brief Launches the applet for ControllerStrapGuide.
* @note Only available on [3.0.0+].
*/
Result hidLaShowControllerStrapGuide(void);
/**
* @brief Launches the applet for ControllerFirmwareUpdate.
* @note Only available on [3.0.0+].
* @param[in] arg \ref HidLaControllerFirmwareUpdateArg
*/
Result hidLaShowControllerFirmwareUpdate(const HidLaControllerFirmwareUpdateArg *arg);
/**
* @brief This is the system version of \ref hidLaShowControllerSupport.
* @param[out] result_info \ref HidLaControllerSupportResultInfo. Optional, can be NULL.
* @param[in] arg \ref HidLaControllerSupportArg
* @param[in] flag Input flag. When true, the applet displays the menu as if launched by qlaunch.
*/
Result hidLaShowControllerSupportForSystem(HidLaControllerSupportResultInfo *result_info, const HidLaControllerSupportArg *arg, bool flag);
/**
* @brief This is the system version of \ref hidLaShowControllerFirmwareUpdate.
* @note Only available on [3.0.0+].
* @param[in] arg \ref HidLaControllerFirmwareUpdateArg
* @param[in] caller \ref HidLaControllerSupportCaller
*/
Result hidLaShowControllerFirmwareUpdateForSystem(const HidLaControllerFirmwareUpdateArg *arg, HidLaControllerSupportCaller caller);
/**
* @brief Launches the applet for ControllerKeyRemappingForSystem.
* @note Only available on [11.0.0+].
* @param[in] arg \ref HidLaControllerKeyRemappingArg
* @param[in] caller \ref HidLaControllerSupportCaller
*/
Result hidLaShowControllerKeyRemappingForSystem(const HidLaControllerKeyRemappingArg *arg, HidLaControllerSupportCaller caller);

View File

@ -0,0 +1,136 @@
/**
* @file libapplet.h
* @brief LibraryApplet wrapper.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/applet.h"
#include "../services/acc.h"
/// CommonArguments
typedef struct {
u32 CommonArgs_version; ///< \ref libappletArgsCreate sets this to 1, and \ref libappletArgsPop requires value 1. v0 is not supported.
u32 CommonArgs_size; ///< Size of this struct.
u32 LaVersion; ///< LibraryApplet API version.
s32 ExpectedThemeColor; ///< Set to the output from \ref appletGetThemeColorType by \ref libappletArgsCreate.
u8 PlayStartupSound; ///< bool flag, default is false.
u8 pad[7]; ///< Padding.
u64 tick; ///< System tick. Set to the output from \ref armGetSystemTick during \ref libappletArgsPush.
} LibAppletArgs;
/**
* @brief Creates a LibAppletArgs struct.
* @param a LibAppletArgs struct.
* @param version LaVersion for \ref LibAppletArgs.
*/
void libappletArgsCreate(LibAppletArgs* a, u32 version);
/**
* @brief Sets the PlayStartupSound field in \ref LibAppletArgs.
* @param a LibAppletArgs struct.
* @param flag Value for \ref LibAppletArgs PlayStartupSound.
*/
void libappletArgsSetPlayStartupSound(LibAppletArgs* a, bool flag);
/**
* @brief Creates an AppletStorage with the specified size and writes the buffer contents to that storage at offset 0.
* @param[out] s Storage object.
* @param buffer Input buffer.
* @param size Size to write.
*/
Result libappletCreateWriteStorage(AppletStorage* s, const void* buffer, size_t size);
/**
* @brief Reads data from offset 0 from the specified storage into the buffer. If the storage-size is smaller than the size param, the storage-size is used instead.
* @param s Storage object.
* @param buffer Output buffer.
* @param size Size to read.
* @param transfer_size Optional output size field for the actual size used for the read, can be NULL.
*/
Result libappletReadStorage(AppletStorage* s, void* buffer, size_t size, size_t *transfer_size);
/**
* @brief Sets the tick field in LibAppletArgs, then creates a storage with it which is pushed to the AppletHolder via \ref appletHolderPushInData.
* @param a LibAppletArgs struct.
* @param h AppletHolder object.
*/
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h);
/**
* @brief Uses \ref appletPopInData and reads it to the specified LibAppletArgs. The LibAppletArgs is validated, an error is thrown when invalid.
* @param[out] a LibAppletArgs struct.
*/
Result libappletArgsPop(LibAppletArgs* a);
/**
* @brief Creates a storage using the input buffer which is pushed to the AppletHolder via \ref appletHolderPushInData.
* @param h AppletHolder object.
* @param buffer Input data buffer.
* @param size Input data size.
*/
Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size);
/**
* @brief Pops a storage via \ref appletHolderPopOutData, uses \ref libappletReadStorage, then closes the storage.
* @param h AppletHolder object.
* @param buffer Output buffer.
* @param size Size to read.
* @param transfer_size Optional output size field for the actual size used for the read, can be NULL.
*/
Result libappletPopOutData(AppletHolder *h, void* buffer, size_t size, size_t *transfer_size);
/**
* @brief Sets whether \ref libappletStart uses \ref appletHolderJump.
* @param flag Flag. Value true should not be used unless running as AppletType_LibraryApplet.
*/
void libappletSetJumpFlag(bool flag);
/**
* @brief If the flag from \ref libappletSetJumpFlag is set, this just uses \ref appletHolderJump. Otherwise, starts the applet and waits for it to finish, then checks the \ref LibAppletExitReason.
* @note Uses \ref appletHolderStart and \ref appletHolderJoin.
* @param h AppletHolder object.
*/
Result libappletStart(AppletHolder *h);
/**
* @brief Creates a LibraryApplet with the specified input storage data, uses \ref libappletStart, and reads the output storage reply data via \ref libappletPopOutData.
* @param id \ref AppletId
* @param commonargs \ref LibAppletArgs struct.
* @param arg Input storage data buffer. Optional, can be NULL.
* @param arg_size Size of the arg buffer.
* @param reply Output storage data buffer. Optional, can be NULL.
* @param reply_size Size to read for the reply buffer.
* @param out_reply_size Actual read reply data size, see \ref libappletPopOutData.
*/
Result libappletLaunch(AppletId id, LibAppletArgs *commonargs, const void* arg, size_t arg_size, void* reply, size_t reply_size, size_t *out_reply_size);
/// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
/// Returns to the main Home Menu, equivalent to pressing the HOME button.
Result libappletRequestHomeMenu(void);
/// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
/// Equivalent to entering "System Update" under System Settings. When leaving this, it returns to the main Home Menu.
Result libappletRequestJumpToSystemUpdate(void);
/**
* @brief Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
* @note Only available on [11.0.0+].
* @param[in] application_id ApplicationId
* @param[in] uid \ref AccountUid
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size.
* @param[in] sender LaunchApplicationRequestSender
*/
Result libappletRequestToLaunchApplication(u64 application_id, AccountUid uid, const void* buffer, size_t size, u32 sender);
/**
* @brief Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
* @note Only available on [11.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] application_id Optional ApplicationId, can be 0.
*/
Result libappletRequestJumpToStory(AccountUid uid, u64 application_id);

View File

@ -0,0 +1,101 @@
/**
* @file mii_la.h
* @brief Wrapper for using the MiiEdit LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/mii.h"
/// AppletMode
typedef enum {
MiiLaAppletMode_ShowMiiEdit = 0, ///< ShowMiiEdit
MiiLaAppletMode_AppendMii = 1, ///< AppendMii
MiiLaAppletMode_AppendMiiImage = 2, ///< AppendMiiImage
MiiLaAppletMode_UpdateMiiImage = 3, ///< UpdateMiiImage
MiiLaAppletMode_CreateMii = 4, ///< [10.2.0+] CreateMii
MiiLaAppletMode_EditMii = 5, ///< [10.2.0+] EditMii
} MiiLaAppletMode;
/// AppletInput
typedef struct {
s32 version; ///< Version
u32 mode; ///< \ref MiiLaAppletMode
s32 special_key_code; ///< \ref MiiSpecialKeyCode
union {
Uuid valid_uuid_array[8]; ///< ValidUuidArray. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_AppendMiiImage / ::NfpLaMiiLaAppletMode_UpdateMiiImage.
struct {
MiiCharInfo char_info; ///< \ref MiiCharInfo
u8 unused_x64[0x28]; ///< Unused
} char_info;
};
Uuid used_uuid; ///< UsedUuid. Only used with \ref MiiLaAppletMode ::NfpLaMiiLaAppletMode_UpdateMiiImage.
u8 unk_x9C[0x64]; ///< Unused
} MiiLaAppletInput;
/// AppletOutput
typedef struct {
u32 res; ///< Result: 0 = Success, 1 = Cancel.
s32 index; ///< Index. Only set when Result is Success, where \ref MiiLaAppletMode isn't ::NfpLaMiiLaAppletMode_ShowMiiEdit.
u8 unk_x8[0x18]; ///< Unused
} MiiLaAppletOutput;
/// AppletOutputForCharInfoEditing
typedef struct {
u32 res; ///< MiiLaAppletOutput::res
MiiCharInfo char_info; ///< \ref MiiCharInfo
u8 unused[0x24]; ///< Unused
} MiiLaAppletOutputForCharInfoEditing;
/**
* @brief Launches the applet for ShowMiiEdit.
* @param[in] special_key_code \ref MiiSpecialKeyCode
*/
Result miiLaShowMiiEdit(MiiSpecialKeyCode special_key_code);
/**
* @brief Launches the applet for AppendMii.
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[out] index Output Index.
*/
Result miiLaAppendMii(MiiSpecialKeyCode special_key_code, s32 *index);
/**
* @brief Launches the applet for AppendMiiImage.
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[in] valid_uuid_array Input array of Uuid.
* @param[in] count Total entries for the valid_uuid_array. Must be 0-8.
* @param[out] index Output Index.
*/
Result miiLaAppendMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, s32 *index);
/**
* @brief Launches the applet for UpdateMiiImage.
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[in] valid_uuid_array Input array of Uuid.
* @param[in] count Total entries for the valid_uuid_array. Must be 0-8.
* @param[in] used_uuid UsedUuid
* @param[out] index Output Index.
*/
Result miiLaUpdateMiiImage(MiiSpecialKeyCode special_key_code, const Uuid *valid_uuid_array, s32 count, Uuid used_uuid, s32 *index);
/**
* @brief Launches the applet for CreateMii.
* @note This creates a Mii and returns it, without saving it in the database.
* @note Only available on [10.2.0+].
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[out] out_char \ref MiiCharInfo
*/
Result miiLaCreateMii(MiiSpecialKeyCode special_key_code, MiiCharInfo *out_char);
/**
* @brief Launches the applet for EditMii.
* @note This edits the specified Mii and returns it, without saving it in the database.
* @note Only available on [10.2.0+].
* @param[in] special_key_code \ref MiiSpecialKeyCode
* @param[in] in_char \ref MiiCharInfo
* @param[out] out_char \ref MiiCharInfo
*/
Result miiLaEditMii(MiiSpecialKeyCode special_key_code, const MiiCharInfo *in_char, MiiCharInfo *out_char);

View File

@ -0,0 +1,89 @@
/**
* @file nfp_la.h
* @brief Wrapper for using the cabinet (amiibo) LibraryApplet.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/nfc.h"
/// Values for NfpLaStartParamForAmiiboSettings::type.
typedef enum {
NfpLaStartParamTypeForAmiiboSettings_NicknameAndOwnerSettings = 0, ///< NicknameAndOwnerSettings
NfpLaStartParamTypeForAmiiboSettings_GameDataEraser = 1, ///< GameDataEraser
NfpLaStartParamTypeForAmiiboSettings_Restorer = 2, ///< Restorer
NfpLaStartParamTypeForAmiiboSettings_Formatter = 3, ///< Formatter
} NfpLaStartParamTypeForAmiiboSettings;
/// AmiiboSettingsStartParam
typedef struct {
u8 unk_x0[0x8]; ///< Unknown
u8 unk_x8[0x20]; ///< Unknown
u8 unk_x28; ///< Unknown
} NfpLaAmiiboSettingsStartParam;
/// StartParamForAmiiboSettings
typedef struct {
u8 unk_x0; ///< Unknown
u8 type; ///< \ref NfpLaStartParamTypeForAmiiboSettings
u8 flags; ///< Flags
u8 unk_x3; ///< NfpLaAmiiboSettingsStartParam::unk_x28
u8 unk_x4[0x8]; ///< NfpLaAmiiboSettingsStartParam::unk_x0
NfpTagInfo tag_info; ///< \ref NfpTagInfo, only enabled when flags bit1 is set.
NfpRegisterInfo register_info; ///< \ref NfpRegisterInfo, only enabled when flags bit2 is set.
u8 unk_x164[0x20]; ///< NfpLaAmiiboSettingsStartParam::unk_x8
u8 unk_x184[0x24]; ///< Unknown
} NfpLaStartParamForAmiiboSettings;
/// ReturnValueForAmiiboSettings
typedef struct {
u8 flags; ///< 0 = error, non-zero = success.
u8 pad[3]; ///< Padding
NfcDeviceHandle handle; ///< \ref NfcDeviceHandle
NfpTagInfo tag_info; ///< \ref NfpTagInfo
NfpRegisterInfo register_info; ///< \ref NfpRegisterInfo, only available when flags bit2 is set.
u8 unk_x164[0x24]; ///< Unknown
} NfpLaReturnValueForAmiiboSettings;
/**
* @brief Launches the applet for NicknameAndOwnerSettings.
* @note Official sw does not expose functionality for using input/output \ref NfpTagInfo at the same time.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[in] in_tag_info \ref NfpTagInfo. Optional, can be NULL. If specified, this must match the scanned amiibo.
* @param[in] in_reg_info \ref NfpRegisterInfo. Optional, can be NULL. If specified, this sets the \ref NfpRegisterInfo which will be used for writing, with an option for the user to change it.
* @param[out] out_tag_info \ref NfpTagInfo. Optional, can be NULL.
* @param[out] handle \ref NfcDeviceHandle
* @param[out] reg_info_flag Flag indicating whether the data for out_reg_info is set. Optional, can be NULL.
* @param[out] out_reg_info \ref NfpRegisterInfo, see reg_info_flag. Optional, can be NULL.
*/
Result nfpLaStartNicknameAndOwnerSettings(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, const NfpRegisterInfo *in_reg_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle, bool *reg_info_flag, NfpRegisterInfo *out_reg_info);
/**
* @brief Launches the applet for GameDataEraser.
* @note Official sw does not expose functionality for using input/output \ref NfpTagInfo at the same time.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[in] in_tag_info \ref NfpTagInfo. Optional, can be NULL. If specified, this must match the scanned amiibo.
* @param[out] out_tag_info \ref NfpTagInfo. Optional, can be NULL.
* @param[out] handle \ref NfcDeviceHandle
*/
Result nfpLaStartGameDataEraser(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle);
/**
* @brief Launches the applet for Restorer.
* @note Official sw does not expose functionality for using input/output \ref NfpTagInfo at the same time.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[in] in_tag_info \ref NfpTagInfo. Optional, can be NULL. If specified, this must match the scanned amiibo.
* @param[out] out_tag_info \ref NfpTagInfo. Optional, can be NULL.
* @param[out] handle \ref NfcDeviceHandle
*/
Result nfpLaStartRestorer(const NfpLaAmiiboSettingsStartParam *in_param, const NfpTagInfo *in_tag_info, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle);
/**
* @brief Launches the applet for Formatter.
* @param[in] in_param \ref NfpLaAmiiboSettingsStartParam
* @param[out] out_tag_info \ref NfpTagInfo
* @param[out] handle \ref NfcDeviceHandle
*/
Result nfpLaStartFormatter(const NfpLaAmiiboSettingsStartParam *in_param, NfpTagInfo *out_tag_info, NfcDeviceHandle *handle);

View File

@ -0,0 +1,16 @@
/**
* @file nifm_la.h
* @brief Wrapper for using the nifm LibraryApplet (the launched applet varies).
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/nifm.h"
/**
* @brief Uses \ref nifmGetResult, then on failure launches the applet.
* @param r \ref NifmRequest
*/
Result nifmLaHandleNetworkRequestResult(NifmRequest* r);

View File

@ -0,0 +1,58 @@
/**
* @file pctlauth.h
* @brief Wrapper for using the Parental Controls authentication LibraryApplet. This applet is used by qlaunch.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// Type values for PctlAuthArg::type.
typedef enum {
PctlAuthType_Show = 0, ///< ShowParentalAuthentication
PctlAuthType_RegisterPasscode = 1, ///< RegisterParentalPasscode
PctlAuthType_ChangePasscode = 2, ///< ChangeParentalPasscode
} PctlAuthType;
/// Input arg storage for the applet.
typedef struct {
u32 unk_x0; ///< Always set to 0 by the user-process.
PctlAuthType type; ///< \ref PctlAuthType
u8 arg0; ///< Arg0
u8 arg1; ///< Arg1
u8 arg2; ///< Arg2
u8 pad; ///< Padding
} PctlAuthArg;
/**
* @brief Launches the applet.
* @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled.
* @param flag Input flag. false = temporarily disable Parental Controls. true = validate the input PIN.
*/
Result pctlauthShow(bool flag);
/**
* @brief Launches the applet. Only available with [4.0.0+].
* @param arg0 Value for PctlAuthArg.arg0.
* @param arg1 Value for PctlAuthArg.arg1.
* @param arg2 Value for PctlAuthArg.arg2.
*/
Result pctlauthShowEx(u8 arg0, u8 arg1, u8 arg2);
/**
* @brief Just calls: pctlauthShowEx(1, 0, 1). Launches the applet for checking the PIN, used when changing system-settings.
* @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled.
*/
Result pctlauthShowForConfiguration(void);
/**
* @brief Launches the applet for registering the Parental Controls PIN.
*/
Result pctlauthRegisterPasscode(void);
/**
* @brief Launches the applet for changing the Parental Controls PIN.
* @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled.
*/
Result pctlauthChangePasscode(void);

View File

@ -0,0 +1,210 @@
/**
* @file psel.h
* @brief Wrapper for using the playerSelect (user selection) LibraryApplet.
* @author XorTroll, yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/acc.h"
/// playerSelect UI modes.
typedef enum {
PselUiMode_UserSelector = 0, ///< UserSelector
PselUiMode_UserCreator = 1, ///< UserCreator
PselUiMode_EnsureNetworkServiceAccountAvailable = 2, ///< EnsureNetworkServiceAccountAvailable
PselUiMode_UserIconEditor = 3, ///< UserIconEditor
PselUiMode_UserNicknameEditor = 4, ///< UserNicknameEditor
PselUiMode_UserCreatorForStarter = 5, ///< UserCreatorForStarter
PselUiMode_NintendoAccountAuthorizationRequestContext = 6, ///< NintendoAccountAuthorizationRequestContext
PselUiMode_IntroduceExternalNetworkServiceAccount = 7, ///< IntroduceExternalNetworkServiceAccount
PselUiMode_IntroduceExternalNetworkServiceAccountForRegistration = 8, ///< [6.0.0+] IntroduceExternalNetworkServiceAccountForRegistration
PselUiMode_NintendoAccountNnidLinker = 9, ///< [6.0.0+] NintendoAccountNnidLinker
PselUiMode_LicenseRequirementsForNetworkService = 10, ///< [6.0.0+] LicenseRequirementsForNetworkService
PselUiMode_LicenseRequirementsForNetworkServiceWithUserContextImpl = 11, ///< [7.0.0+] LicenseRequirementsForNetworkServiceWithUserContextImpl
PselUiMode_UserCreatorForImmediateNaLoginTest = 12, ///< [7.0.0+] UserCreatorForImmediateNaLoginTest
PselUiMode_UserQualificationPromoter = 13, ///< [13.0.0+] UserQualificationPromoter
} PselUiMode;
/// UI message text to display with ::PselUiMode_UserSelector. Invalid values are handled as ::PselUserSelectionPurpose_General.
typedef enum {
PselUserSelectionPurpose_General = 0, ///< "Select a user."
PselUserSelectionPurpose_GameCardRegistration = 1, ///< [2.0.0+] "Who will receive the points?"
PselUserSelectionPurpose_EShopLaunch = 2, ///< [2.0.0+] "Who is using Nintendo eShop?"
PselUserSelectionPurpose_EShopItemShow = 3, ///< [2.0.0+] "Who is making this purchase?"
PselUserSelectionPurpose_PicturePost = 4, ///< [2.0.0+] "Who is posting?"
PselUserSelectionPurpose_NintendoAccountLinkage = 5, ///< [2.0.0+] "Select a user to link to a Nintendo Account."
PselUserSelectionPurpose_SettingsUpdate = 6, ///< [2.0.0+] "Change settings for which user?"
PselUserSelectionPurpose_SaveDataDeletion = 7, ///< [2.0.0+] "Format data for which user?"
PselUserSelectionPurpose_UserMigration = 8, ///< [4.0.0+] "Which user will be transferred to another console?"
PselUserSelectionPurpose_SaveDataTransfer = 9, ///< [8.0.0+] "Send save data for which user?"
} PselUserSelectionPurpose;
/// NintendoAccountStartupDialogType
typedef enum {
PselNintendoAccountStartupDialogType_LoginAndCreate = 0, ///< LoginAndCreate
PselNintendoAccountStartupDialogType_Login = 1, ///< Login
PselNintendoAccountStartupDialogType_Create = 2, ///< Create
} PselNintendoAccountStartupDialogType;
/// Base UI settings for playerSelect.
typedef struct {
u32 mode; ///< \ref PselUiMode
u32 pad; ///< Padding.
AccountUid invalid_uid_list[ACC_USER_LIST_SIZE]; ///< List of \ref AccountUid. TODO: This is only correct for ::PselUiMode_UserSelector, for other modes this is a single uid, followed by mode-specific data (if any).
u64 application_id; ///< ApplicationId with \ref pselShowUserSelectorForLauncher.
u8 is_network_service_account_required; ///< PselUserSelectionSettings::is_network_service_account_required.
u8 is_skip_enabled; ///< PselUserSelectionSettings::is_skip_enabled
u8 unk_x92; ///< Set to value 1 by \ref pselShowUserSelectorForSystem / \ref pselShowUserSelectorForLauncher.
u8 is_permitted; ///< isPermitted. With ::PselUiMode_UserSelector: enables the option to create a new user. Set to the output from \ref accountIsUserRegistrationRequestPermitted with pselShowUserSelector*. When not set, a dialog will be displayed when the user attempts to create an user.
u8 show_skip_button; ///< PselUserSelectionSettings::show_skip_button
u8 additional_select; ///< PselUserSelectionSettings::additional_select
u8 unk_x96; ///< [2.0.0+] Set to PselUserSelectionSettingsForSystemService::enable_user_creation_button. \ref pselShowUserSelectorForLauncher / \ref pselShowUserSelector sets this to value 1.
u8 unk_x97; ///< [6.0.0+] Set to PselUserSelectionSettings::is_unqualified_user_selectable ^ 1.
} PselUiSettingsV1;
/// UI settings for versions starting with 0x10000.
typedef struct {
PselUiSettingsV1 settings; ///< \ref PselUiSettingsV1
u32 unk_x98; ///< [2.0.0+] Set to PselUserSelectionSettingsForSystemService::purpose.
u8 unk_x9c[0x4]; ///< Unknown.
} PselUiSettings;
/// UserSelectionSettings
typedef struct {
AccountUid invalid_uid_list[ACC_USER_LIST_SIZE]; ///< invalidUidList.
u8 is_skip_enabled; ///< isSkipEnabled. When set, the first user in invalid_uid_list must not be set, and additional_select must be 0. When enabled \ref accountTrySelectUserWithoutInteraction will be used to select the user, in this case the applet will only be launched if \ref accountTrySelectUserWithoutInteraction doesn't return an user.
u8 is_network_service_account_required; ///< isNetworkServiceAccountRequired. Whether the user needs to be linked to a Nintendo account.
u8 show_skip_button; ///< showSkipButton. Enables the option to skip user selection with a button.
u8 additional_select; ///< additionalSelect.
u8 is_unqualified_user_selectable; ///< [6.0.0+] isUnqualifiedUserSelectable
} PselUserSelectionSettings;
/// [2.0.0+] UserSelectionSettingsForSystemService
typedef struct {
u32 purpose; ///< \ref PselUserSelectionPurpose
u8 enable_user_creation_button; ///< Enables the user-creation button when set. Whether user-creation when pressing the button is actually allowed is controlled by PselUiSettingsV1::is_permitted.
u8 pad[0x3]; ///< Padding.
} PselUserSelectionSettingsForSystemService;
/// Return data sent after execution.
typedef struct {
Result res; ///< Result.
AccountUid user_id; ///< Selected \ref AccountUid.
} PselUiReturnArg;
/**
* @brief Creates a new UI config for the playerSelect applet with the specified mode.
* @param ui PseluiSettings struct.
* @param mode playerSelect UI mode.
*/
Result pselUiCreate(PselUiSettings *ui, PselUiMode mode);
/**
* @brief Adds an user to the user list of the applet.
* @param ui PselUiSettings struct.
* @param[in] user_id user ID.
* @note The users will be treated as invalid users for user selection mode, and as the input user for other modes.
*/
void pselUiAddUser(PselUiSettings *ui, AccountUid user_id);
/**
* @brief Sets whether users can be created in the applet.
* @param ui PselUiSettings struct.
* @param flag Flag value.
* @note Only used for ::PselUiMode_SelectUser.
*/
NX_CONSTEXPR void pselUiSetAllowUserCreation(PselUiSettings *ui, bool flag) {
if(ui->settings.mode == PselUiMode_UserSelector) {
ui->settings.is_permitted = flag!=0;
}
}
/**
* @brief Sets whether users need to be linked to a Nintendo account.
* @param ui PselUiSettings struct.
* @param flag Flag value.
*/
NX_CONSTEXPR void pselUiSetNetworkServiceRequired(PselUiSettings *ui, bool flag) {
ui->settings.is_network_service_account_required = flag;
}
/**
* @brief Sets whether selection can be skipped with a button.
* @param ui PselUiSettings struct.
* @param flag Flag value.
*/
NX_CONSTEXPR void pselUiSetSkipButtonEnabled(PselUiSettings *ui, bool flag) {
ui->settings.show_skip_button = flag!=0;
}
/**
* @brief Shows the applet with the specified UI settings.
* @param ui PselUiSettings struct.
* @param out_user Selected user ID.
* @note If user skips (see \ref pselUiSetSkipEnabled) this will return successfully but the output ID will be 0.
*/
Result pselUiShow(PselUiSettings *ui, AccountUid *out_user);
/**
* @brief This is the System version of \ref pselShowUserSelector.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. See also the docs for PselUserSelectionSettings::is_skip_enabled.
* @param[out] out_user Returned selected user ID.
* @param[in] settings \ref PselUserSelectionSettings
* @param[in] settings_system [2.0.0+] \ref PselUserSelectionSettingsForSystemService, ignored on prior versions.
*/
Result pselShowUserSelectorForSystem(AccountUid *out_user, const PselUserSelectionSettings *settings, const PselUserSelectionSettingsForSystemService *settings_system);
/**
* @brief This is the Launcher version of \ref pselShowUserSelector.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. See also the docs for PselUserSelectionSettings::is_skip_enabled.
* @param[out] out_user Returned selected user ID.
* @param[in] settings \ref PselUserSelectionSettings
* @param[in] application_id ApplicationId
*/
Result pselShowUserSelectorForLauncher(AccountUid *out_user, const PselUserSelectionSettings *settings, u64 application_id);
/**
* @brief Shows the applet to select a user.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. See also the docs for PselUserSelectionSettings::is_skip_enabled.
* @param[out] out_user Returned selected user ID.
* @param[in] settings \ref PselUserSelectionSettings
*/
Result pselShowUserSelector(AccountUid *out_user, const PselUserSelectionSettings *settings);
/**
* @brief Shows the applet to create a user.
* @note This uses \ref accountIsUserRegistrationRequestPermitted, hence \ref accountInitialize must be used prior to this. If the output flag is 0, an error will be thrown.
*/
Result pselShowUserCreator(void);
/**
* @brief Shows the applet to change a user's icon.
* @param[in] user Input user ID.
*/
Result pselShowUserIconEditor(AccountUid user);
/**
* @brief Shows the applet to change a user's nickname.
* @param[in] user Input user ID.
*/
Result pselShowUserNicknameEditor(AccountUid user);
/**
* @brief Shows the applet to create a user. Used by the starter applet during system setup.
*/
Result pselShowUserCreatorForStarter(void);
/**
* @brief Shows the applet for Nintendo Account Nnid linking.
* @note Only available on [6.0.0+].
* @param[in] user Input user ID.
*/
Result pselShowNintendoAccountNnidLinker(AccountUid user);
/**
* @brief Shows the applet for UserQualificationPromoter.
* @note Only available on [13.0.0+].
* @param[in] user Input user ID.
*/
Result pselShowUserQualificationPromoter(AccountUid user);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,862 @@
/**
* @file web.h
* @brief Wrapper for using the web LibraryApplets. See also: https://switchbrew.org/wiki/Internet_Browser
* @author p-sam, yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/applet.h"
#include "../services/caps.h"
#include "../services/acc.h"
#include "../kernel/mutex.h"
/// This indicates the type of web-applet.
typedef enum {
WebShimKind_Shop = 1,
WebShimKind_Login = 2,
WebShimKind_Offline = 3,
WebShimKind_Share = 4,
WebShimKind_Web = 5,
WebShimKind_Wifi = 6,
WebShimKind_Lobby = 7,
} WebShimKind;
/// ExitReason
typedef enum {
WebExitReason_ExitButton = 0x0, ///< User pressed the X button to exit.
WebExitReason_BackButton = 0x1, ///< User pressed the B button to exit, on the initial page.
WebExitReason_Requested = 0x2, ///< The applet exited since \ref webConfigRequestExit was used.
WebExitReason_LastUrl = 0x3, ///< The applet exited due to LastUrl handling, see \ref webReplyGetLastUrl.
WebExitReason_ErrorDialog = 0x7, ///< The applet exited after displaying an error dialog.
WebExitReason_UnknownE = 0xE, ///< Unknown
} WebExitReason;
/// Button values for \ref webConfigSetBootFooterButtonVisible.
typedef enum {
WebFooterButtonId_None = 0, ///< None, for empty \ref WebBootFooterButtonEntry. Invalid for \ref webConfigSetBootFooterButtonVisible input.
WebFooterButtonId_Type1 = 1, ///< Unknown button Id 1.
WebFooterButtonId_Type2 = 2, ///< Unknown button Id 2.
WebFooterButtonId_Type3 = 3, ///< Unknown button Id 3.
WebFooterButtonId_Type4 = 4, ///< Unknown button Id 4.
WebFooterButtonId_Type5 = 5, ///< Unknown button Id 5.
WebFooterButtonId_Type6 = 6, ///< Unknown button Id 6.
WebFooterButtonId_Max, ///< Values starting with this are invalid.
} WebFooterButtonId;
/// WebSessionBootMode
typedef enum {
WebSessionBootMode_AllForeground = 0, ///< AllForeground. This is the default.
WebSessionBootMode_AllForegroundInitiallyHidden = 1, ///< AllForegroundInitiallyHidden
} WebSessionBootMode;
/// WebSessionSendMessageKind
typedef enum {
WebSessionSendMessageKind_BrowserEngineContent = 0x0, ///< BrowserEngine Content
WebSessionSendMessageKind_SystemMessageAppear = 0x100, ///< SystemMessage Appear
WebSessionSendMessageKind_Ack = 0x1000, ///< Ack
} WebSessionSendMessageKind;
/// WebSessionReceiveMessageKind
typedef enum {
WebSessionReceiveMessageKind_BrowserEngineContent = 0x0, ///< BrowserEngine Content
WebSessionReceiveMessageKind_AckBrowserEngine = 0x1000, ///< Ack BrowserEngine
WebSessionReceiveMessageKind_AckSystemMessage = 0x1001, ///< Ack SystemMessage
} WebSessionReceiveMessageKind;
/// Struct for the WebWifi applet input storage.
typedef struct {
u32 unk_x0; ///< Official sw sets this to 0 with appletStorageWrite, separately from the rest of the config struct.
char conntest_url[0x100]; ///< Connection-test URL.
char initial_url[0x400]; ///< Initial URL navigated to by the applet.
Uuid uuid; ///< NIFM Network UUID. Only used by the applet when conntest_url is set.
u32 rev; ///< Input value for nifm cmd SetRequirementByRevision. Only used by the applet when conntest_url is set.
} WebWifiPageArg;
/// Struct for the WebWifi applet output storage.
typedef struct {
u32 unk_x0; ///< Unknown.
Result res; ///< Result
} WebWifiReturnValue;
/// Config for WebWifi.
typedef struct {
WebWifiPageArg arg; ///< Arg data.
} WebWifiConfig;
/// TLV storage, starts with \ref WebArgHeader followed by \ref WebArgTLV entries.
typedef struct {
u8 data[0x2000]; ///< Raw TLV data storage.
} WebCommonTLVStorage;
/// Common struct for the applet output storage, for non-TLV-storage.
typedef struct {
WebExitReason exitReason; ///< ExitReason
u32 pad; ///< Padding
char lastUrl[0x1000]; ///< LastUrl string
u64 lastUrlSize; ///< Size of LastUrl, including NUL-terminator.
} NX_PACKED WebCommonReturnValue;
/// Header struct at offset 0 in the web Arg storage (non-webWifi).
typedef struct {
u16 total_entries; ///< Total \ref WebArgTLV entries following this struct.
u16 pad; ///< Padding
WebShimKind shimKind; ///< ShimKind
} NX_PACKED WebArgHeader;
/// Web TLV used in the web Arg storage.
typedef struct {
u16 type; ///< Type of this arg.
u16 size; ///< Size of the arg data following this struct.
u8 pad[4]; ///< Padding
} NX_PACKED WebArgTLV;
/// Config struct for web applets, non-WebWifi.
typedef struct {
WebCommonTLVStorage arg; ///< TLV storage.
AppletId appletid; ///< AppletId
u32 version; ///< CommonArgs applet version.
AppletHolder holder; ///< AppletHolder
} WebCommonConfig;
/// Common container struct for applets' reply data, from the output storage.
typedef struct {
bool type; ///< Type of reply: false = ret, true = storage.
WebShimKind shimKind; ///< ShimKind
WebCommonReturnValue ret; ///< Reply data for reply=false.
WebCommonTLVStorage storage; ///< Reply data for reply=true.
} WebCommonReply;
/// Entry data for ::WebArgType_BootFooterButton.
typedef struct {
WebFooterButtonId id;
u8 visible;
u16 unk_x5;
u8 unk_x7;
} NX_PACKED WebBootFooterButtonEntry;
/// StorageHandleQueue
typedef struct {
s32 read_pos;
s32 write_pos;
s32 max_storages;
bool is_full;
AppletStorage storages[0x10];
} WebSessionStorageHandleQueue;
/// WebSession
typedef struct {
Mutex mutex;
WebCommonConfig *config;
struct {
u32 count;
u32 cur_size;
} queue[2];
WebSessionStorageHandleQueue storage_queue;
} WebSession;
/// SessionMessageHeader
typedef struct {
u32 kind; ///< Message Kind (\ref WebSessionSendMessageKind / \ref WebSessionReceiveMessageKind)
u32 size; ///< Data size following the header.
u8 reserved[0x8]; ///< Unused
} WebSessionMessageHeader;
/// Types for \ref WebArgTLV, input storage.
typedef enum {
WebArgType_Url = 0x1, ///< [1.0.0+] String, size 0xC00. Initial URL.
WebArgType_CallbackUrl = 0x3, ///< [1.0.0+] String, size 0x400.
WebArgType_CallbackableUrl = 0x4, ///< [1.0.0+] String, size 0x400.
WebArgType_ApplicationId = 0x5, ///< [1.0.0+] Offline-applet, u64 ApplicationId
WebArgType_DocumentPath = 0x6, ///< [1.0.0+] Offline-applet, string with size 0xC00.
WebArgType_DocumentKind = 0x7, ///< [1.0.0+] Offline-applet, u32 enum \WebDocumentKind.
WebArgType_SystemDataId = 0x8, ///< [1.0.0+] Offline-applet, u64 SystemDataId
WebArgType_ShareStartPage = 0x9, ///< [1.0.0+] u32 enum \WebShareStartPage
WebArgType_Whitelist = 0xA, ///< [1.0.0+] String, size 0x1000.
WebArgType_NewsFlag = 0xB, ///< [1.0.0+] u8 bool
WebArgType_UnknownC = 0xC, ///< [1.0.0+] u8
WebArgType_UnknownD = 0xD, ///< [1.0.0+] u8
WebArgType_Uid = 0xE, ///< [1.0.0+] \ref AccountUid, controls which user-specific savedata to mount.
WebArgType_AlbumEntry0 = 0xF, ///< [1.0.0+] Share-applet caps AlbumEntry, entry 0.
WebArgType_ScreenShot = 0x10, ///< [1.0.0+] u8 bool
WebArgType_EcClientCert = 0x11, ///< [1.0.0+] u8 bool
WebArgType_Unknown12 = 0x12, ///< [1.0.0+] u8
WebArgType_PlayReport = 0x13, ///< [1.0.0+] u8 bool
WebArgType_Unknown14 = 0x14, ///< [1.0.0+] u8
WebArgType_Unknown15 = 0x15, ///< [1.0.0+] u8
WebArgType_BootDisplayKind = 0x17, ///< [1.0.0+] u32 enum \ref WebBootDisplayKind
WebArgType_BackgroundKind = 0x18, ///< [1.0.0+] u32 enum \ref WebBackgroundKind
WebArgType_Footer = 0x19, ///< [1.0.0+] u8 bool
WebArgType_Pointer = 0x1A, ///< [1.0.0+] u8 bool
WebArgType_LeftStickMode = 0x1B, ///< [1.0.0+] u32 enum \ref WebLeftStickMode
WebArgType_KeyRepeatFrame0 = 0x1C, ///< [1.0.0+] s32 KeyRepeatFrame, first param
WebArgType_KeyRepeatFrame1 = 0x1D, ///< [1.0.0+] s32 KeyRepeatFrame, second param
WebArgType_BootAsMediaPlayerInverted = 0x1E, ///< [1.0.0+] u8 bool. With News on [3.0.0+] this is set after BootAsMediaPlayer with the value inverted.
WebArgType_DisplayUrlKind = 0x1F, ///< [1.0.0+] u8 bool, DisplayUrlKind (value = (input_enumval==0x1)).
WebArgType_BootAsMediaPlayer = 0x21, ///< [2.0.0+] u8 bool
WebArgType_ShopJump = 0x22, ///< [2.0.0+] u8 bool
WebArgType_MediaPlayerUserGestureRestriction = 0x23, ///< [2.0.0-5.1.0] u8 bool
WebArgType_MediaAutoPlay = 0x23, ///< [6.0.0+] u8 bool
WebArgType_LobbyParameter = 0x24, ///< [2.0.0+] String, size 0x100.
WebArgType_ApplicationAlbumEntry = 0x26, ///< [3.0.0+] Share-applet caps ApplicationAlbumEntry
WebArgType_JsExtension = 0x27, ///< [3.0.0+] u8 bool
WebArgType_AdditionalCommentText = 0x28, ///< [4.0.0+] String, size 0x100. Share-applet AdditionalCommentText.
WebArgType_TouchEnabledOnContents = 0x29, ///< [4.0.0+] u8 bool
WebArgType_UserAgentAdditionalString = 0x2A, ///< [4.0.0+] String, size 0x80.
WebArgType_AdditionalMediaData0 = 0x2B, ///< [4.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 0. If the user-input size is less than 0x10, the remaining data used for the TLV is cleared.
WebArgType_MediaPlayerAutoClose = 0x2C, ///< [4.0.0+] u8 bool
WebArgType_PageCache = 0x2D, ///< [4.0.0+] u8 bool
WebArgType_WebAudio = 0x2E, ///< [4.0.0+] u8 bool
WebArgType_2F = 0x2F, ///< [5.0.0+] u8
WebArgType_YouTubeVideoFlag = 0x31, ///< [5.0.0+] u8 bool Indicates that the built-in whitelist for YouTubeVideo should be used.
WebArgType_FooterFixedKind = 0x32, ///< [5.0.0+] u32 enum \ref WebFooterFixedKind
WebArgType_PageFade = 0x33, ///< [5.0.0+] u8 bool
WebArgType_MediaCreatorApplicationRatingAge = 0x34, ///< [5.0.0+] Share-applet 0x20-byte s8 array, MediaCreatorApplicationRatingAge.
WebArgType_BootLoadingIcon = 0x35, ///< [5.0.0+] u8 bool
WebArgType_PageScrollIndicator = 0x36, ///< [5.0.0+] u8 bool
WebArgType_MediaPlayerSpeedControl = 0x37, ///< [6.0.0+] u8 bool
WebArgType_AlbumEntry1 = 0x38, ///< [6.0.0+] Share-applet caps AlbumEntry, entry 1.
WebArgType_AlbumEntry2 = 0x39, ///< [6.0.0+] Share-applet caps AlbumEntry, entry 2.
WebArgType_AlbumEntry3 = 0x3A, ///< [6.0.0+] Share-applet caps AlbumEntry, entry 3.
WebArgType_AdditionalMediaData1 = 0x3B, ///< [6.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 1.
WebArgType_AdditionalMediaData2 = 0x3C, ///< [6.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 2.
WebArgType_AdditionalMediaData3 = 0x3D, ///< [6.0.0+] Share-applet 0x10-byte u8 array, AdditionalMediaData. Entry 3.
WebArgType_BootFooterButton = 0x3E, ///< [6.0.0+] Array of \ref WebBootFooterButtonEntry with 0x10 entries.
WebArgType_OverrideWebAudioVolume = 0x3F, ///< [6.0.0+] float
WebArgType_OverrideMediaAudioVolume = 0x40, ///< [6.0.0+] float
WebArgType_SessionBootMode = 0x41, ///< [7.0.0+] u32 enum \ref WebSessionBootMode
WebArgType_SessionFlag = 0x42, ///< [7.0.0+] u8 bool, enables using WebSession when set.
WebArgType_MediaPlayerUi = 0x43, ///< [8.0.0+] u8 bool
WebArgType_TransferMemory = 0x44, ///< [11.0.0+] u8 bool
} WebArgType;
/// Types for \ref WebArgTLV, output storage.
typedef enum {
WebReplyType_ExitReason = 0x1, ///< [3.0.0+] u32 ExitReason
WebReplyType_LastUrl = 0x2, ///< [3.0.0+] string
WebReplyType_LastUrlSize = 0x3, ///< [3.0.0+] u64
WebReplyType_SharePostResult = 0x4, ///< [3.0.0+] u32 SharePostResult
WebReplyType_PostServiceName = 0x5, ///< [3.0.0+] string
WebReplyType_PostServiceNameSize = 0x6, ///< [3.0.0+] u64
WebReplyType_PostId = 0x7, ///< [3.0.0+] string
WebReplyType_PostIdSize = 0x8, ///< [3.0.0+] u64
WebReplyType_MediaPlayerAutoClosedByCompletion = 0x9, ///< [8.0.0+] u8 bool
} WebReplyType;
/// This controls the kind of content to mount with Offline-applet.
typedef enum {
WebDocumentKind_OfflineHtmlPage = 0x1, ///< Use the HtmlDocument NCA content from the application.
WebDocumentKind_ApplicationLegalInformation = 0x2, ///< Use the LegalInformation NCA content from the application.
WebDocumentKind_SystemDataPage = 0x3, ///< Use the Data NCA content from the specified SystemData, see also: https://switchbrew.org/wiki/Title_list#System_Data_Archives
} WebDocumentKind;
/// This controls the initial page for ShareApplet, used by \ref webShareCreate.
typedef enum {
WebShareStartPage_Default = 0, ///< The default "/" page.
WebShareStartPage_Settings = 1, ///< The "/settings/" page.
} WebShareStartPage;
/// Kind values for \ref webConfigSetBootDisplayKind. Controls the background color while displaying the loading screen during applet boot. Also controls the BackgroundKind when value is non-zero.
typedef enum {
WebBootDisplayKind_Default = 0, ///< Default. BackgroundKind is controlled by \ref WebBackgroundKind.
WebBootDisplayKind_White = 1, ///< White background. Used by \ref webOfflineCreate for docKind ::WebDocumentKind_ApplicationLegalInformation/::WebDocumentKind_SystemDataPage.
WebBootDisplayKind_Black = 2, ///< Black background.
WebBootDisplayKind_Unknown3 = 3, ///< Unknown. Used by \ref webShareCreate.
WebBootDisplayKind_Unknown4 = 4, ///< Unknown. Used by \ref webLobbyCreate.
} WebBootDisplayKind;
/// Kind values for \ref webConfigSetBackgroundKind. Controls the background color while displaying the loading screen during applet boot. Only used when \ref WebBootDisplayKind is ::WebBootDisplayKind_Default. If the applet was not launched by an Application, the applet will only use WebBackgroundKind_Default.
typedef enum {
WebBackgroundKind_Default = 0, ///< Default. Same as ::WebBootDisplayKind_White/::WebBootDisplayKind_Black, determined via ::WebArgType_BootAsMediaPlayer.
WebBackgroundKind_Unknown1 = 1, ///< Unknown. Same as ::WebBootDisplayKind_Unknown3.
WebBackgroundKind_Unknown2 = 2, ///< Unknown. Same as ::WebBootDisplayKind_Unknown4. Used by \ref webLobbyCreate.
} WebBackgroundKind;
/// Mode values for \ref webConfigSetLeftStickMode. Controls the initial mode, this can be toggled by the user via the pressing the left-stick button. If the Pointer flag is set to false (\ref webConfigSetPointer), only ::WebLeftStickMode_Cursor will be used and mode toggle by the user is disabled (input value ignored).
typedef enum {
WebLeftStickMode_Pointer = 0, ///< The user can directly control the pointer via the left-stick.
WebLeftStickMode_Cursor = 1, ///< The user can only select elements on the page via the left-stick.
} WebLeftStickMode;
/// Kind values for \ref webConfigSetFooterFixedKind. Controls UI footer display behaviour.
typedef enum {
WebFooterFixedKind_Default = 0, ///< Default. Footer is hidden while scrolling.
WebFooterFixedKind_Always = 1, ///< Footer is always displayed regardless of scrolling.
WebFooterFixedKind_Hidden = 2, ///< Footer is hidden regardless of scrolling.
} WebFooterFixedKind;
/**
* @brief Creates the config for WifiWebAuthApplet. This is the captive portal applet.
* @param config WebWifiConfig object.
* @param conntest_url URL used for the connection-test requests. When empty/NULL the applet will test the connection with nifm and throw an error on failure.
* @param initial_url Initial URL navigated to by the applet.
* @param uuid NIFM Network UUID, for nifm cmd SetNetworkProfileId. Value 0 can be used. Only used by the applet when conntest_url is set.
* @param rev Input value for nifm cmd SetRequirementByRevision. Value 0 can be used. Only used by the applet when conntest_url is set.
*/
void webWifiCreate(WebWifiConfig* config, const char* conntest_url, const char* initial_url, Uuid uuid, u32 rev);
/**
* @brief Launches WifiWebAuthApplet with the specified config and waits for it to exit.
* @param config WebWifiConfig object.
* @param out Optional output applet reply data, can be NULL.
*/
Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out);
/**
* @brief Creates the config for WebApplet. This applet uses an URL whitelist loaded from the user-process host Application, which is only loaded when running under an Application.
* @note Sets ::WebArgType_UnknownD, and ::WebArgType_Unknown12 on pre-3.0.0, to value 1.
* @param config WebCommonConfig object.
* @param url Initial URL navigated to by the applet.
*/
Result webPageCreate(WebCommonConfig* config, const char* url);
/**
* @brief Creates the config for WebApplet. This is based on \ref webPageCreate, for News. Hence other functions referencing \ref webPageCreate also apply to this.
* @note The domain from the input URL is automatically whitelisted, in addition to any already loaded whitelist.
* @note Sets ::WebArgType_UnknownD to value 1, and sets ::WebArgType_NewsFlag to true. Also uses \ref webConfigSetEcClientCert and \ref webConfigSetShopJump with flag=true.
* @param config WebCommonConfig object.
* @param url Initial URL navigated to by the applet.
*/
Result webNewsCreate(WebCommonConfig* config, const char* url);
/**
* @brief Creates the config for WebApplet. This is based on \ref webPageCreate, for YouTubeVideo. Hence other functions referencing \ref webPageCreate also apply to this. This uses a whitelist which essentially only allows youtube embed/ URLs (without mounting content from the host Application).
* @note This is only available on [5.0.0+].
* @note Sets ::WebArgType_UnknownD to value 1, and sets ::WebArgType_YouTubeVideoFlag to true. Also uses \ref webConfigSetBootAsMediaPlayer with flag=true.
* @param config WebCommonConfig object.
* @param url Initial URL navigated to by the applet.
*/
Result webYouTubeVideoCreate(WebCommonConfig* config, const char* url);
/**
* @brief Creates the config for Offline-applet. This applet uses data loaded from content.
* @note Uses \ref webConfigSetLeftStickMode with ::WebLeftStickMode_Cursor and sets ::WebArgType_BootAsMediaPlayerInverted to false. Uses \ref webConfigSetPointer with flag = docKind == ::WebDocumentKind_OfflineHtmlPage.
* @note For docKind ::WebDocumentKind_ApplicationLegalInformation / ::WebDocumentKind_SystemDataPage, uses \ref webConfigSetFooter with flag=true and \ref webConfigSetBackgroundKind with ::WebBackgroundKind_Default.
* @note For docKind ::WebDocumentKind_SystemDataPage, uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_White.
* @note Sets ::WebArgType_Unknown14/::WebArgType_Unknown15 to value 1. With docKind ::WebDocumentKind_ApplicationLegalInformation, uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_White.
* @note Sets ::WebArgType_UnknownC to value 1.
* @note With docKind ::WebDocumentKind_ApplicationLegalInformation, uses \ref webConfigSetEcClientCert with flag=true.
* @note With docKind ::WebDocumentKind_OfflineHtmlPage on pre-3.0.0, sets ::WebArgType_Unknown12 to value 1.
* @note Lastly, sets the TLVs as needed for the input params.
* @param config WebCommonConfig object.
* @param docKind \ref WebDocumentKind
* @param id Id to load the content from. With docKind = ::WebDocumentKind_OfflineHtmlPage, id=0 should be used to specify the user-process application (non-zero is ignored with this docKind).
* @param docPath Initial document path in RomFS, without the leading '/'. For ::WebDocumentKind_OfflineHtmlPage, this is relative to "html-document/" in RomFS. For the other docKind values, this is relative to "/" in RomFS. This path must contain ".htdocs/".
*/
Result webOfflineCreate(WebCommonConfig* config, WebDocumentKind docKind, u64 id, const char* docPath);
/**
* @brief Creates the config for ShareApplet. This applet is for social media posting/settings.
* @note If a non-zero uid isn't set with \ref webConfigSetUid prior to using \ref webConfigShow, the applet will launch the profile-selector applet to select an account.
* @note An error will be displayed if neither \ref webConfigSetAlbumEntry, nor \ref webConfigSetApplicationAlbumEntry, nor \ref webConfigAddAlbumEntryAndMediaData are used prior to using \ref webConfigShow, with ::WebShareStartPage_Default.
* @note Uses \ref webConfigSetLeftStickMode with ::WebLeftStickMode_Cursor, \ref webConfigSetUid with uid=0, \ref webConfigSetDisplayUrlKind with kind=true, and sets ::WebArgType_Unknown14/::WebArgType_Unknown15 to value 1. Uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_Unknown3.
* @param config WebCommonConfig object.
* @param page \ref WebShareStartPage
*/
Result webShareCreate(WebCommonConfig* config, WebShareStartPage page);
/**
* @brief Creates the config for LobbyApplet. This applet is for "Nintendo Switch Online Lounge".
* @note Only available on [2.0.0+].
* @note If a non-zero uid isn't set with \ref webConfigSetUid prior to using \ref webConfigShow, the applet will launch the profile-selector applet to select an account.
* @note Uses \ref webConfigSetLeftStickMode with ::WebLeftStickMode_Cursor, \ref webConfigSetPointer with flag=false on [3.0.0+], \ref webConfigSetUid with uid=0, and sets ::WebArgType_Unknown14/::WebArgType_Unknown15 to value 1. Uses \ref webConfigSetBootDisplayKind with ::WebBootDisplayKind_Unknown4, \ref webConfigSetBackgroundKind with ::WebBackgroundKind_Unknown2, and sets ::WebArgType_BootAsMediaPlayerInverted to false.
* @param config WebCommonConfig object.
*/
Result webLobbyCreate(WebCommonConfig* config);
/**
* @brief Sets the CallbackUrl. See also \ref webReplyGetLastUrl.
* @note With Offline-applet for LastUrl handling, it compares the domain with "localhost" instead.
* @note Only available with config created by \ref webPageCreate or with Share-applet.
* @param config WebCommonConfig object.
* @param url URL
*/
Result webConfigSetCallbackUrl(WebCommonConfig* config, const char* url);
/**
* @brief Sets the CallbackableUrl.
* @note Only available with config created by \ref webPageCreate.
* @param config WebCommonConfig object.
* @param url URL
*/
Result webConfigSetCallbackableUrl(WebCommonConfig* config, const char* url);
/**
* @brief Sets the whitelist.
* @note Only available with config created by \ref webPageCreate.
* @note If the whitelist isn't formatted properly, the applet will exit briefly after the applet is launched.
* @param config WebCommonConfig object.
* @param whitelist Whitelist string, each line is a regex for each whitelisted URL.
*/
Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist);
/**
* @brief Sets the account uid. Controls which user-specific savedata to mount.
* @note Only available with config created by \ref webPageCreate, \ref webLobbyCreate, or with Share-applet.
* @note Used automatically by \ref webShareCreate and \ref webLobbyCreate with uid=0.
* @param config WebCommonConfig object.
* @param uid \ref AccountUid
*/
Result webConfigSetUid(WebCommonConfig* config, AccountUid uid);
/**
* @brief Sets the Share CapsAlbumEntry.
* @note Only available with config created by \ref webShareCreate.
* @param config WebCommonConfig object.
* @param entry \ref CapsAlbumEntry
*/
Result webConfigSetAlbumEntry(WebCommonConfig* config, const CapsAlbumEntry *entry);
/**
* @brief Sets the ScreenShot flag, which controls whether screen-shot capture is allowed.
* @note Only available with config created by \ref webPageCreate.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetScreenShot(WebCommonConfig* config, bool flag);
/**
* @brief Sets the EcClientCert flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate.
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @note Used automatically by \ref webNewsCreate with flag=true.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetEcClientCert(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether PlayReport is enabled.
* @note Only available with config created by \ref webOfflineCreate.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPlayReport(WebCommonConfig* config, bool flag);
/**
* @brief Sets the BootDisplayKind.
* @note Only available with config created by \ref webOfflineCreate, \ref webShareCreate, \ref webPageCreate, or \ref webLobbyCreate..
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @note Used automatically by \ref webShareCreate with kind=::WebBootDisplayKind_Unknown3.
* @note Used automatically by \ref webLobbyCreate with kind=::WebBootDisplayKind_Unknown4.
* @param config WebCommonConfig object.
* @param kind \ref WebBootDisplayKind
*/
Result webConfigSetBootDisplayKind(WebCommonConfig* config, WebBootDisplayKind kind);
/**
* @brief Sets the BackgroundKind.
* @note Only available with config created by \ref webOfflineCreate, \ref webPageCreate, or \ref webLobbyCreate.
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @note Used automatically by \ref webLobbyCreate with kind=2.
* @param config WebCommonConfig object.
* @param kind \ref WebBackgroundKind
*/
Result webConfigSetBackgroundKind(WebCommonConfig* config, WebBackgroundKind kind);
/**
* @brief Sets the whether the UI footer is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate.
* @note Used automatically by \ref webOfflineCreate, depending on the docKind.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetFooter(WebCommonConfig* config, bool flag);
/**
* @brief Sets the whether the Pointer is enabled. See also \ref WebLeftStickMode.
* @note Only available with config created by \ref webOfflineCreate, \ref webPageCreate, or \ref webLobbyCreate.
* @note Used automatically by \ref webOfflineCreate.
* @note Used automatically by \ref webLobbyCreate with flag=false on [3.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPointer(WebCommonConfig* config, bool flag);
/**
* @brief Sets the LeftStickMode.
* @note Only available with config created by \ref webOfflineCreate, \ref webShareCreate, \ref webPageCreate, or \ref webLobbyCreate.
* @note Used automatically by \ref webOfflineCreate, \ref webShareCreate, and \ref webLobbyCreate with ::WebLeftStickMode_Cursor.
* @param config WebCommonConfig object.
* @param mode Mode, different enums for Web and Offline.
*/
Result webConfigSetLeftStickMode(WebCommonConfig* config, WebLeftStickMode mode);
/**
* @brief Sets the KeyRepeatFrame.
* @note Only available with config created by \ref webOfflineCreate.
* @param config WebCommonConfig object.
* @param inval0 First input param.
* @param inval1 Second input param.
*/
Result webConfigSetKeyRepeatFrame(WebCommonConfig* config, s32 inval0, s32 inval1);
/**
* @brief Sets the DisplayUrlKind.
* @note Only available with config created by \ref webShareCreate or \ref webPageCreate.
* @param config WebCommonConfig object.
* @note Used automatically by \ref webShareCreate with kind=true.
* @param kind Kind
*/
Result webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind);
/**
* @brief Sets the BootAsMediaPlayer flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [2.0.0+].
* @note With config created by \ref webNewsCreate on [3.0.0+], this also sets ::WebArgType_BootAsMediaPlayerInverted to !flag.
* @param config WebCommonConfig object.
* @param flag Flag. true = BootAsMediaPlayer, false = BootAsWebPage.
*/
Result webConfigSetBootAsMediaPlayer(WebCommonConfig* config, bool flag);
/**
* @brief Sets the ShopJump flag.
* @note Only available with config created by \ref webPageCreate on [2.0.0+].
* @note Used automatically by \ref webNewsCreate with flag=true.
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetShopJump(WebCommonConfig* config, bool flag);
/**
* @brief Sets the MediaPlayerUserGestureRestriction flag.
* @note Only available with config created by \ref webPageCreate on [2.0.0-5.1.0].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerUserGestureRestriction(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether MediaAutoPlay is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaAutoPlay(WebCommonConfig* config, bool flag);
/**
* @brief Sets the LobbyParameter.
* @note Only available with config created by \ref webLobbyCreate.
* @param config WebCommonConfig object.
* @param str String
*/
Result webConfigSetLobbyParameter(WebCommonConfig* config, const char* str);
/**
* @brief Sets the Share CapsApplicationAlbumEntry.
* @note Only available with config created by \ref webShareCreate on [3.0.0+].
* @param config WebCommonConfig object.
* @param entry \ref CapsApplicationAlbumEntry, see also capssu.h.
*/
Result webConfigSetApplicationAlbumEntry(WebCommonConfig* config, CapsApplicationAlbumEntry *entry);
/**
* @brief Sets whether JsExtension is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [3.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetJsExtension(WebCommonConfig* config, bool flag);
/**
* @brief Sets the Share AdditionalCommentText.
* @note Only available with config created by \ref webShareCreate on [4.0.0+].
* @param config WebCommonConfig object.
* @param str String
*/
Result webConfigSetAdditionalCommentText(WebCommonConfig* config, const char* str);
/**
* @brief Sets the TouchEnabledOnContents flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetTouchEnabledOnContents(WebCommonConfig* config, bool flag);
/**
* @brief Sets the UserAgentAdditionalString. " " followed by this string are appended to the normal User-Agent string.
* @note Only available with config created by \ref webPageCreate on [4.0.0+].
* @param config WebCommonConfig object.
* @param str String
*/
Result webConfigSetUserAgentAdditionalString(WebCommonConfig* config, const char* str);
/**
* @brief Sets the Share AdditionalMediaData.
* @note Only available with config created by \ref webShareCreate on [4.0.0+].
* @param config WebCommonConfig object.
* @param data Input data
* @param size Size of the input data, max size is 0x10.
*/
Result webConfigSetAdditionalMediaData(WebCommonConfig* config, const u8* data, size_t size);
/**
* @brief Sets the MediaPlayerAutoClose flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerAutoClose(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether PageCache is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPageCache(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether WebAudio is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [4.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetWebAudio(WebCommonConfig* config, bool flag);
/**
* @brief Sets the FooterFixedKind.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [5.0.0+].
* @param config WebCommonConfig object.
* @param kind \ref WebFooterFixedKind
*/
Result webConfigSetFooterFixedKind(WebCommonConfig* config, WebFooterFixedKind kind);
/**
* @brief Sets the PageFade flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [5.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPageFade(WebCommonConfig* config, bool flag);
/**
* @brief Sets the Share MediaCreatorApplicationRatingAge.
* @note Only available with config created by \ref webShareCreate on [5.0.0+].
* @param config WebCommonConfig object.
* @param data 0x20-byte input data
*/
Result webConfigSetMediaCreatorApplicationRatingAge(WebCommonConfig* config, const s8 *data);
/**
* @brief Sets the BootLoadingIcon flag.
* @note Only available with config created by \ref webOfflineCreate on [5.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetBootLoadingIcon(WebCommonConfig* config, bool flag);
/**
* @brief Sets the PageScrollIndicator flag.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [5.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetPageScrollIndicator(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether MediaPlayerSpeedControl is enabled.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerSpeedControl(WebCommonConfig* config, bool flag);
/**
* @brief Adds a pair of Share CapsAlbumEntry + optionally AdditionalMediaData. This can be used up to 4 times, for setting multiple pairs.
* @note Only available with config created by \ref webShareCreate on [6.0.0+].
* @param config WebCommonConfig object.
* @param entry \ref CapsAlbumEntry
* @param data Input data for AdditionalMediaData. Optional, can be NULL.
* @param size Size of the input data, max size is 0x10. Optional, can be 0.
*/
Result webConfigAddAlbumEntryAndMediaData(WebCommonConfig* config, const CapsAlbumEntry *entry, const u8* data, size_t size);
/**
* @brief Sets whether the specified BootFooterButton is visible.
* @note Only available with config created by \ref webOfflineCreate on [6.0.0+].
* @param config WebCommonConfig object.
* @param button \ref WebFooterButtonId
* @param visible Visible flag.
*/
Result webConfigSetBootFooterButtonVisible(WebCommonConfig* config, WebFooterButtonId button, bool visible);
/**
* @brief Sets OverrideWebAudioVolume.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param value Value
*/
Result webConfigSetOverrideWebAudioVolume(WebCommonConfig* config, float value);
/**
* @brief Sets OverrideMediaAudioVolume.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [6.0.0+].
* @param config WebCommonConfig object.
* @param value Value
*/
Result webConfigSetOverrideMediaAudioVolume(WebCommonConfig* config, float value);
/**
* @brief Sets \ref WebSessionBootMode.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [7.0.0+].
* @param config WebCommonConfig object.
* @param mode \ref WebSessionBootMode
*/
Result webConfigSetBootMode(WebCommonConfig* config, WebSessionBootMode mode);
/**
* @brief Sets whether MediaPlayerUi is enabled.
* @note Only available with config created by \ref webOfflineCreate on [8.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerUi(WebCommonConfig* config, bool flag);
/**
* @brief Sets whether TransferMemory is enabled.
* @note Only available with config created by \ref webPageCreate on [11.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetTransferMemory(WebCommonConfig* config, bool flag);
/**
* @brief Launches the {web applet} with the specified config and waits for it to exit.
* @param config WebCommonConfig object.
* @param out Optional output applet reply data, can be NULL.
*/
Result webConfigShow(WebCommonConfig* config, WebCommonReply *out);
/**
* @brief Request the applet to exit after \ref webConfigShow was used, while the applet is still running. This is for use from another thread.
* @param config WebCommonConfig object.
*/
Result webConfigRequestExit(WebCommonConfig* config);
/**
* @brief Gets the ExitReason from the specified reply.
* @param reply WebCommonReply object.
* @param exitReason Output \ref WebExitReason
*/
Result webReplyGetExitReason(WebCommonReply *reply, WebExitReason *exitReason);
/**
* @brief Gets the LastUrl from the specified reply. When the applet loads a page where the beginning of the URL matches the URL from \ref webConfigSetCallbackUrl, the applet will exit and set LastUrl to that URL (exit doesn't occur when \ref webConfigSetCallbackableUrl was used).
* @note This is only available with ::WebExitReason_LastUrl (string is empty otherwise).
* @note If you want to allocate a string buffer on heap, you can call this with outstr=NULL/outstr_maxsize=0 to get the out_size, then call it again with the allocated buffer.
* @param reply WebCommonReply object.
* @param outstr Output string buffer. If NULL, the string is not loaded.
* @param outstr_maxsize Size of the buffer, including NUL-terminator. If outstr is set, this size must be >1. The size used for the actual string-copy is this size-1, to make sure the output is NUL-terminated (the entire buffer is cleared first).
* @param out_size Output string length including NUL-terminator, for the original input string in the reply loaded from a separate size field.
*/
Result webReplyGetLastUrl(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the SharePostResult from the specified reply.
* @note Only available with reply data from ShareApplet on [3.0.0+].
* @param reply WebCommonReply object.
* @param sharePostResult Output sharePostResult
*/
Result webReplyGetSharePostResult(WebCommonReply *reply, u32 *sharePostResult);
/**
* @brief Gets the PostServiceName from the specified reply.
* @note Only available with reply data from ShareApplet on [3.0.0+].
* @note If you want to allocate a string buffer on heap, you can call this with outstr=NULL/outstr_maxsize=0 to get the out_size, then call it again with the allocated buffer.
* @param reply WebCommonReply object.
* @param outstr Output string buffer. If NULL, the string is not loaded.
* @param outstr_maxsize Size of the buffer, including NUL-terminator. If outstr is set, this size must be >1. The size used for the actual string-copy is this size-1, to make sure the output is NUL-terminated (the entire buffer is cleared first).
* @param out_size Output string length including NUL-terminator, for the original input string in the reply loaded from a separate size field.
*/
Result webReplyGetPostServiceName(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the PostId from the specified reply.
* @note Only available with reply data from ShareApplet on [3.0.0+].
* @note If you want to allocate a string buffer on heap, you can call this with outstr=NULL/outstr_maxsize=0 to get the out_size, then call it again with the allocated buffer.
* @param reply WebCommonReply object.
* @param outstr Output string buffer. If NULL, the string is not loaded.
* @param outstr_maxsize Size of the buffer, including NUL-terminator. If outstr is set, this size must be >1. The size used for the actual string-copy is this size-1, to make sure the output is NUL-terminated (the entire buffer is cleared first).
* @param out_size Output string length including NUL-terminator, for the original input string in the reply loaded from a separate size field.
*/
Result webReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the MediaPlayerAutoClosedByCompletion flag from the specified reply.
* @note Only available with reply data from Web on [8.0.0+].
* @param reply WebCommonReply object.
* @param flag Output flag
*/
Result webReplyGetMediaPlayerAutoClosedByCompletion(WebCommonReply *reply, bool *flag);
/**
* @brief Creates a \ref WebSession object.
* @param s \ref WebSession
* @param config WebCommonConfig object.
*/
void webSessionCreate(WebSession *s, WebCommonConfig* config);
/**
* @brief Closes a \ref WebSession object.
* @param s \ref WebSession
*/
void webSessionClose(WebSession *s);
/**
* @brief Launches the applet for \ref WebSession.
* @note Only available with config created by \ref webOfflineCreate or \ref webPageCreate, on [7.0.0+].
* @note Do not use \ref webConfigShow when using WebSession.
* @param s \ref WebSession
* @param[out] out_event Output Event with autoclear=false, from \ref appletHolderGetExitEvent. Optional, can be NULL.
*/
Result webSessionStart(WebSession *s, Event **out_event);
/**
* @brief Waits for the applet to exit.
* @note This must be used before \ref webSessionClose, when \ref webSessionStart was used successfully.
* @param s \ref WebSession
* @param out Optional output applet reply data, can be NULL.
*/
Result webSessionWaitForExit(WebSession *s, WebCommonReply *out);
/**
* @brief Request the applet to exit.
* @note Use this instead of \ref webConfigRequestExit, when using WebSession.
* @param s \ref WebSession
*/
Result webSessionRequestExit(WebSession *s);
/**
* @brief Request the applet to Appear, this is only needed with ::WebSessionBootMode_AllForegroundInitiallyHidden.
* @note This should not be used before \ref webSessionStart.
* @param s \ref WebSession
* @param[out] flag Whether the message was sent successfully.
*/
Result webSessionAppear(WebSession *s, bool *flag);
/**
* @brief TrySendContentMessage
* @note This should not be used before \ref webSessionStart.
* @note The JS-side for this is only available when JsExtension is enabled via \ref webConfigSetJsExtension.
* @note The JS-side may ignore this if it's sent too soon after the applet launches.
* @param s \ref WebSession
* @param[in] content Input content NUL-terminated string.
* @param[in] size Size of content.
* @param[out] flag Whether the message was sent successfully.
*/
Result webSessionTrySendContentMessage(WebSession *s, const char *content, u32 size, bool *flag);
/**
* @brief TryReceiveContentMessage
* @note This should not be used before \ref webSessionStart.
* @note The JS-side for this is only available when JsExtension is enabled via \ref webConfigSetJsExtension.
* @param s \ref WebSession
* @param[out] content Output content string, always NUL-terminated.
* @param[in] size Max size of content.
* @param[out] out_size Original content size, prior to being clamped to the specified size param.
* @param[out] flag Whether the message was received successfully.
*/
Result webSessionTryReceiveContentMessage(WebSession *s, char *content, u64 size, u64 *out_size, bool *flag);

View File

@ -1,18 +0,0 @@
#pragma once
#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);
}

View File

@ -26,3 +26,21 @@ static inline u64 armGetSystemTickFreq(void) {
__asm__ ("mrs %x[data], cntfrq_el0" : [data] "=r" (ret));
return ret;
}
/**
* @brief Converts from nanoseconds to CPU ticks unit.
* @param ns Time in nanoseconds.
* @return Time in CPU ticks.
*/
static inline u64 armNsToTicks(u64 ns) {
return (ns * 12) / 625;
}
/**
* @brief Converts from CPU ticks unit to nanoseconds.
* @param tick Time in ticks.
* @return Time in nanoseconds.
*/
static inline u64 armTicksToNs(u64 tick) {
return (tick * 625) / 12;
}

View File

@ -34,6 +34,17 @@ typedef enum {
RegisterGroup_All = RegisterGroup_CpuAll | RegisterGroup_FpuAll, ///< All registers.
} RegisterGroup;
/// This is for \ref ThreadExceptionDump error_desc.
typedef enum {
ThreadExceptionDesc_InstructionAbort = 0x100, ///< Instruction abort
ThreadExceptionDesc_MisalignedPC = 0x102, ///< Misaligned PC
ThreadExceptionDesc_MisalignedSP = 0x103, ///< Misaligned SP
ThreadExceptionDesc_SError = 0x106, ///< SError [not in 1.0.0?]
ThreadExceptionDesc_BadSVC = 0x301, ///< Bad SVC
ThreadExceptionDesc_Trap = 0x104, ///< Uncategorized, CP15RTTrap, CP15RRTTrap, CP14RTTrap, CP14RRTTrap, IllegalState, SystemRegisterTrap
ThreadExceptionDesc_Other = 0x101, ///< None of the above, EC <= 0x34 and not a breakpoint
} ThreadExceptionDesc;
/// Thread context structure (register dump)
typedef struct {
CpuRegister cpu_gprs[29]; ///< GPRs 0..28. Note: also contains AArch32 SPRs.
@ -50,6 +61,54 @@ typedef struct {
u64 tpidr; ///< EL0 Read/Write Software Thread ID Register.
} ThreadContext;
/// Thread exception dump structure.
typedef struct {
u32 error_desc; ///< See \ref ThreadExceptionDesc.
u32 pad[3];
CpuRegister cpu_gprs[29]; ///< GPRs 0..28. Note: also contains AArch32 registers.
CpuRegister fp; ///< Frame pointer.
CpuRegister lr; ///< Link register.
CpuRegister sp; ///< Stack pointer.
CpuRegister pc; ///< Program counter (elr_el1).
u64 padding;
FpuRegister fpu_gprs[32]; ///< 32 general-purpose NEON registers.
u32 pstate; ///< pstate & 0xFF0FFE20
u32 afsr0;
u32 afsr1;
u32 esr;
CpuRegister far; ///< Fault Address Register.
} ThreadExceptionDump;
typedef struct {
u64 cpu_gprs[9]; ///< GPRs 0..8.
u64 lr;
u64 sp;
u64 elr_el1;
u32 pstate; ///< pstate & 0xFF0FFE20
u32 afsr0;
u32 afsr1;
u32 esr;
u64 far;
} ThreadExceptionFrameA64;
typedef struct {
u32 cpu_gprs[8]; ///< GPRs 0..7.
u32 sp;
u32 lr;
u32 elr_el1;
u32 tpidr_el0; ///< tpidr_el0 = 1
u32 cpsr; ///< cpsr & 0xFF0FFE20
u32 afsr0;
u32 afsr1;
u32 esr;
u32 far;
} ThreadExceptionFrameA32;
/**
* @brief Determines whether a thread context belong to an AArch64 process based on the PSR.
* @param[in] ctx Thread context to which PSTATE/cspr has been dumped to.
@ -59,3 +118,13 @@ static inline bool threadContextIsAArch64(const ThreadContext *ctx)
{
return (ctx->psr & 0x10) == 0;
}
/**
* @brief Determines whether a ThreadExceptionDump belongs to an AArch64 process based on the PSTATE.
* @param[in] ctx ThreadExceptionDump.
* @return true if and only if the ThreadExceptionDump belongs to an AArch64 process.
*/
static inline bool threadExceptionIsAArch64(const ThreadExceptionDump *ctx)
{
return (ctx->pstate & 0x10) == 0;
}

View File

@ -8,6 +8,7 @@
#include "../types.h"
/// PcmFormat
typedef enum {
PcmFormat_Invalid = 0,
PcmFormat_Int8 = 1,
@ -17,3 +18,8 @@ typedef enum {
PcmFormat_Float = 5,
PcmFormat_Adpcm = 6,
} PcmFormat;
/// AudioDeviceName
typedef struct {
char name[0x100];
} AudioDeviceName;

View File

@ -62,6 +62,7 @@ struct AudioDriverWaveBuf {
bool audrvVoiceInit(AudioDriver* d, int id, int num_channels, PcmFormat format, int sample_rate);
void audrvVoiceDrop(AudioDriver* d, int id);
void audrvVoiceStop(AudioDriver* d, int id);
bool audrvVoiceIsPaused(AudioDriver* d, int id);
bool audrvVoiceIsPlaying(AudioDriver* d, int id);
bool audrvVoiceAddWaveBuf(AudioDriver* d, int id, AudioDriverWaveBuf* wavebuf);
u32 audrvVoiceGetWaveBufSeq(AudioDriver* d, int id);

View File

@ -0,0 +1,74 @@
/**
* @file aes.h
* @brief Hardware accelerated AES-ECB implementation.
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#ifndef AES_BLOCK_SIZE
#define AES_BLOCK_SIZE 0x10
#endif
#ifndef AES_128_KEY_SIZE
#define AES_128_KEY_SIZE 0x10
#endif
#ifndef AES_128_U32_PER_KEY
#define AES_128_U32_PER_KEY (AES_128_KEY_SIZE / sizeof(u32))
#endif
#ifndef AES_128_NUM_ROUNDS
#define AES_128_NUM_ROUNDS 10
#endif
#ifndef AES_192_KEY_SIZE
#define AES_192_KEY_SIZE 0x18
#endif
#ifndef AES_192_U32_PER_KEY
#define AES_192_U32_PER_KEY (AES_192_KEY_SIZE / sizeof(u32))
#endif
#ifndef AES_192_NUM_ROUNDS
#define AES_192_NUM_ROUNDS 12
#endif
#ifndef AES_256_KEY_SIZE
#define AES_256_KEY_SIZE 0x20
#endif
#ifndef AES_256_U32_PER_KEY
#define AES_256_U32_PER_KEY (AES_256_KEY_SIZE / sizeof(u32))
#endif
#ifndef AES_256_NUM_ROUNDS
#define AES_256_NUM_ROUNDS 14
#endif
/// Context for AES-128 operations.
typedef struct {
u8 round_keys[AES_128_NUM_ROUNDS+1][AES_BLOCK_SIZE];
} Aes128Context;
/// Context for AES-192 operations.
typedef struct {
u8 round_keys[AES_192_NUM_ROUNDS+1][AES_BLOCK_SIZE];
} Aes192Context;
/// Context for AES-256 operations.
typedef struct {
u8 round_keys[AES_256_NUM_ROUNDS+1][AES_BLOCK_SIZE];
} Aes256Context;
/// Initialize a 128-bit AES context.
void aes128ContextCreate(Aes128Context *out, const void *key, bool is_encryptor);
/// Encrypt using an AES context (Requires is_encryptor when initializing)
void aes128EncryptBlock(const Aes128Context *ctx, void *dst, const void *src);
/// Decrypt using an AES context (Requires !is_encryptor when initializing)
void aes128DecryptBlock(const Aes128Context *ctx, void *dst, const void *src);
/// Initialize a 192-bit AES context.
void aes192ContextCreate(Aes192Context *out, const void *key, bool is_encryptor);
/// Encrypt using an AES context (Requires is_encryptor when initializing)
void aes192EncryptBlock(const Aes192Context *ctx, void *dst, const void *src);
/// Decrypt using an AES context (Requires !is_encryptor when initializing)
void aes192DecryptBlock(const Aes192Context *ctx, void *dst, const void *src);
/// Initialize a 256-bit AES context.
void aes256ContextCreate(Aes256Context *out, const void *key, bool is_encryptor);
/// Encrypt using an AES context (Requires is_encryptor when initializing)
void aes256EncryptBlock(const Aes256Context *ctx, void *dst, const void *src);
/// Decrypt using an AES context (Requires !is_encryptor when initializing)
void aes256DecryptBlock(const Aes256Context *ctx, void *dst, const void *src);

View File

@ -0,0 +1,49 @@
/**
* @file aes_cbc.h
* @brief Hardware accelerated AES-CBC implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 CBC.
typedef struct {
Aes128Context aes_ctx;
u8 iv[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes128CbcContext;
/// Context for AES-192 CBC.
typedef struct {
Aes192Context aes_ctx;
u8 iv[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes192CbcContext;
/// Context for AES-256 CBC.
typedef struct {
Aes256Context aes_ctx;
u8 iv[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes256CbcContext;
/// 128-bit CBC API.
void aes128CbcContextCreate(Aes128CbcContext *out, const void *key, const void *iv, bool is_encryptor);
void aes128CbcContextResetIv(Aes128CbcContext *ctx, const void *iv);
size_t aes128CbcEncrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size);
size_t aes128CbcDecrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size);
/// 192-bit CBC API.
void aes192CbcContextCreate(Aes192CbcContext *out, const void *key, const void *iv, bool is_encryptor);
void aes192CbcContextResetIv(Aes192CbcContext *ctx, const void *iv);
size_t aes192CbcEncrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size);
size_t aes192CbcDecrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size);
/// 256-bit CBC API.
void aes256CbcContextCreate(Aes256CbcContext *out, const void *key, const void *iv, bool is_encryptor);
void aes256CbcContextResetIv(Aes256CbcContext *ctx, const void *iv);
size_t aes256CbcEncrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size);
size_t aes256CbcDecrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size);

View File

@ -0,0 +1,46 @@
/**
* @file aes_ctr.h
* @brief Hardware accelerated AES-CTR implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 CTR.
typedef struct {
Aes128Context aes_ctx;
u8 ctr[AES_BLOCK_SIZE];
u8 enc_ctr_buffer[AES_BLOCK_SIZE];
size_t buffer_offset;
} Aes128CtrContext;
/// Context for AES-192 CTR.
typedef struct {
Aes192Context aes_ctx;
u8 ctr[AES_BLOCK_SIZE];
u8 enc_ctr_buffer[AES_BLOCK_SIZE];
size_t buffer_offset;
} Aes192CtrContext;
/// Context for AES-256 CTR.
typedef struct {
Aes256Context aes_ctx;
u8 ctr[AES_BLOCK_SIZE];
u8 enc_ctr_buffer[AES_BLOCK_SIZE];
size_t buffer_offset;
} Aes256CtrContext;
/// 128-bit CTR API.
void aes128CtrContextCreate(Aes128CtrContext *out, const void *key, const void *ctr);
void aes128CtrContextResetCtr(Aes128CtrContext *ctx, const void *ctr);
void aes128CtrCrypt(Aes128CtrContext *ctx, void *dst, const void *src, size_t size);
/// 192-bit CTR API.
void aes192CtrContextCreate(Aes192CtrContext *out, const void *key, const void *ctr);
void aes192CtrContextResetCtr(Aes192CtrContext *ctx, const void *ctr);
void aes192CtrCrypt(Aes192CtrContext *ctx, void *dst, const void *src, size_t size);
/// 256-bit CTR API.
void aes256CtrContextCreate(Aes256CtrContext *out, const void *key, const void *ctr);
void aes256CtrContextResetCtr(Aes256CtrContext *ctx, const void *ctr);
void aes256CtrCrypt(Aes256CtrContext *ctx, void *dst, const void *src, size_t size);

View File

@ -0,0 +1,55 @@
/**
* @file aes_xts.h
* @brief Hardware accelerated AES-XTS implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 XTS.
typedef struct {
Aes128Context aes_ctx;
Aes128Context tweak_ctx;
u8 tweak[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes128XtsContext;
/// Context for AES-192 XTS.
typedef struct {
Aes192Context aes_ctx;
Aes192Context tweak_ctx;
u8 tweak[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes192XtsContext;
/// Context for AES-256 XTS.
typedef struct {
Aes256Context aes_ctx;
Aes256Context tweak_ctx;
u8 tweak[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
} Aes256XtsContext;
/// 128-bit XTS API.
void aes128XtsContextCreate(Aes128XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
void aes128XtsContextResetTweak(Aes128XtsContext *ctx, const void *tweak);
void aes128XtsContextResetSector(Aes128XtsContext *ctx, uint64_t sector, bool is_nintendo);
size_t aes128XtsEncrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size);
size_t aes128XtsDecrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size);
/// 192-bit XTS API.
void aes192XtsContextCreate(Aes192XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
void aes192XtsContextResetTweak(Aes192XtsContext *ctx, const void *tweak);
void aes192XtsContextResetSector(Aes192XtsContext *ctx, uint64_t sector, bool is_nintendo);
size_t aes192XtsEncrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size);
size_t aes192XtsDecrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size);
/// 256-bit XTS API.
void aes256XtsContextCreate(Aes256XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
void aes256XtsContextResetTweak(Aes256XtsContext *ctx, const void *tweak);
void aes256XtsContextResetSector(Aes256XtsContext *ctx, uint64_t sector, bool is_nintendo);
size_t aes256XtsEncrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size);
size_t aes256XtsDecrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size);

View File

@ -0,0 +1,67 @@
/**
* @file cmac.h
* @brief Hardware accelerated AES-CMAC implementation.
* @copyright libnx Authors
*/
#pragma once
#include "aes.h"
/// Context for AES-128 CMAC.
typedef struct {
Aes128Context ctx;
u8 subkey[AES_BLOCK_SIZE];
u8 mac[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
bool finalized;
} Aes128CmacContext;
/// Context for AES-192 CMAC.
typedef struct {
Aes192Context ctx;
u8 subkey[AES_BLOCK_SIZE];
u8 mac[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
bool finalized;
} Aes192CmacContext;
/// Context for AES-256 CMAC.
typedef struct {
Aes256Context ctx;
u8 subkey[AES_BLOCK_SIZE];
u8 mac[AES_BLOCK_SIZE];
u8 buffer[AES_BLOCK_SIZE];
size_t num_buffered;
bool finalized;
} Aes256CmacContext;
/// Initialize an AES-128-CMAC context.
void cmacAes128ContextCreate(Aes128CmacContext *out, const void *key);
/// Updates AES-128-CMAC context with data to hash
void cmacAes128ContextUpdate(Aes128CmacContext *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void cmacAes128ContextGetMac(Aes128CmacContext *ctx, void *dst);
/// Simple all-in-one AES-128-CMAC calculator.
void cmacAes128CalculateMac(void *dst, const void *key, const void *src, size_t size);
/// Initialize an AES-192-CMAC context.
void cmacAes192ContextCreate(Aes192CmacContext *out, const void *key);
/// Updates AES-192-CMAC context with data to hash
void cmacAes192ContextUpdate(Aes192CmacContext *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void cmacAes192ContextGetMac(Aes192CmacContext *ctx, void *dst);
/// Simple all-in-one AES-192-CMAC calculator.
void cmacAes192CalculateMac(void *dst, const void *key, const void *src, size_t size);
/// Initialize an AES-256-CMAC context.
void cmacAes256ContextCreate(Aes256CmacContext *out, const void *key);
/// Updates AES-256-CMAC context with data to hash
void cmacAes256ContextUpdate(Aes256CmacContext *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void cmacAes256ContextGetMac(Aes256CmacContext *ctx, void *dst);
/// Simple all-in-one AES-256-CMAC calculator.
void cmacAes256CalculateMac(void *dst, const void *key, const void *src, size_t size);

View File

@ -0,0 +1,86 @@
/**
* @file crc.h
* @brief Hardware accelerated CRC32 implementation.
* @copyright libnx Authors
*/
#pragma once
#include <arm_acle.h>
#include "../types.h"
#define _CRC_ALIGN(sz, insn) \
do { \
if (((uintptr_t)src_u8 & sizeof(sz)) && (u64)len >= sizeof(sz)) { \
crc = __crc32##insn(crc, *((const sz *)src_u8)); \
src_u8 += sizeof(sz); \
len -= sizeof(sz); \
} \
} while (0)
#define _CRC_REMAINDER(sz, insn) \
do { \
if (len & sizeof(sz)) { \
crc = __crc32##insn(crc, *((const sz *)src_u8)); \
src_u8 += sizeof(sz); \
} \
} while (0)
/// Calculate a CRC32 over data using a seed.
/// Can be used to calculate a CRC32 in chunks using an initial seed of zero for the first chunk.
static inline u32 crc32CalculateWithSeed(u32 seed, const void *src, size_t size) {
const u8 *src_u8 = (const u8 *)src;
u32 crc = ~seed;
s64 len = size;
_CRC_ALIGN(u8, b);
_CRC_ALIGN(u16, h);
_CRC_ALIGN(u32, w);
while ((len -= sizeof(u64)) >= 0) {
crc = __crc32d(crc, *((const u64 *)src_u8));
src_u8 += sizeof(u64);
}
_CRC_REMAINDER(u32, w);
_CRC_REMAINDER(u16, h);
_CRC_REMAINDER(u8, b);
return ~crc;
}
/// Calculate a CRC32 over data.
static inline u32 crc32Calculate(const void *src, size_t size) {
return crc32CalculateWithSeed(0, src, size);
}
/// Calculate a CRC32C over data using a seed.
/// Can be used to calculate a CRC32C in chunks using an initial seed of zero for the first chunk.
static inline u32 crc32cCalculateWithSeed(u32 seed, const void *src, size_t size) {
const u8 *src_u8 = (const u8 *)src;
u32 crc = ~seed;
s64 len = size;
_CRC_ALIGN(u8, cb);
_CRC_ALIGN(u16, ch);
_CRC_ALIGN(u32, cw);
while ((len -= sizeof(u64)) >= 0) {
crc = __crc32cd(crc, *((const u64 *)src_u8));
src_u8 += sizeof(u64);
}
_CRC_REMAINDER(u32, cw);
_CRC_REMAINDER(u16, ch);
_CRC_REMAINDER(u8, cb);
return ~crc;
}
/// Calculate a CRC32C over data.
static inline u32 crc32cCalculate(const void *src, size_t size) {
return crc32cCalculateWithSeed(0, src, size);
}
#undef _CRC_REMAINDER
#undef _CRC_ALIGN

View File

@ -0,0 +1,51 @@
/**
* @file hmac.h
* @brief Hardware accelerated HMAC-SHA(1, 256) implementation.
* @copyright libnx Authors
*/
#pragma once
#include "sha1.h"
#include "sha256.h"
/// Context for HMAC-SHA1 operations.
typedef struct {
Sha1Context sha_ctx;
u32 key[SHA1_BLOCK_SIZE / sizeof(u32)];
u32 mac[SHA1_HASH_SIZE / sizeof(u32)];
bool finalized;
} HmacSha1Context;
/// Context for HMAC-SHA256 operations.
typedef struct {
Sha256Context sha_ctx;
u32 key[SHA256_BLOCK_SIZE / sizeof(u32)];
u32 mac[SHA256_HASH_SIZE / sizeof(u32)];
bool finalized;
} HmacSha256Context;
#ifndef HMAC_SHA1_KEY_MAX
#define HMAC_SHA1_KEY_MAX (sizeof(((HmacSha1Context *)NULL)->key))
#endif
#ifndef HMAC_SHA256_KEY_MAX
#define HMAC_SHA256_KEY_MAX (sizeof(((HmacSha256Context *)NULL)->key))
#endif
/// Initialize a HMAC-SHA256 context.
void hmacSha256ContextCreate(HmacSha256Context *out, const void *key, size_t key_size);
/// Updates HMAC-SHA256 context with data to hash
void hmacSha256ContextUpdate(HmacSha256Context *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void hmacSha256ContextGetMac(HmacSha256Context *ctx, void *dst);
/// Simple all-in-one HMAC-SHA256 calculator.
void hmacSha256CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size);
/// Initialize a HMAC-SHA1 context.
void hmacSha1ContextCreate(HmacSha1Context *out, const void *key, size_t key_size);
/// Updates HMAC-SHA1 context with data to hash
void hmacSha1ContextUpdate(HmacSha1Context *ctx, const void *src, size_t size);
/// Gets the context's output mac, finalizes the context.
void hmacSha1ContextGetMac(HmacSha1Context *ctx, void *dst);
/// Simple all-in-one HMAC-SHA1 calculator.
void hmacSha1CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size);

View File

@ -0,0 +1,34 @@
/**
* @file sha1.h
* @brief Hardware accelerated SHA1 implementation.
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#ifndef SHA1_HASH_SIZE
#define SHA1_HASH_SIZE 0x14
#endif
#ifndef SHA1_BLOCK_SIZE
#define SHA1_BLOCK_SIZE 0x40
#endif
/// Context for SHA1 operations.
typedef struct {
u32 intermediate_hash[SHA1_HASH_SIZE / sizeof(u32)];
u8 buffer[SHA1_BLOCK_SIZE];
u64 bits_consumed;
size_t num_buffered;
bool finalized;
} Sha1Context;
/// Initialize a SHA1 context.
void sha1ContextCreate(Sha1Context *out);
/// Updates SHA1 context with data to hash
void sha1ContextUpdate(Sha1Context *ctx, const void *src, size_t size);
/// Gets the context's output hash, finalizes the context.
void sha1ContextGetHash(Sha1Context *ctx, void *dst);
/// Simple all-in-one SHA1 calculator.
void sha1CalculateHash(void *dst, const void *src, size_t size);

View File

@ -0,0 +1,35 @@
/**
* @file sha256.h
* @brief Hardware accelerated SHA256 implementation.
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#ifndef SHA256_HASH_SIZE
#define SHA256_HASH_SIZE 0x20
#endif
#ifndef SHA256_BLOCK_SIZE
#define SHA256_BLOCK_SIZE 0x40
#endif
/// Context for SHA256 operations.
typedef struct {
u32 intermediate_hash[SHA256_HASH_SIZE / sizeof(u32)];
u8 buffer[SHA256_BLOCK_SIZE];
u64 bits_consumed;
size_t num_buffered;
bool finalized;
} Sha256Context;
/// Initialize a SHA256 context.
void sha256ContextCreate(Sha256Context *out);
/// Updates SHA256 context with data to hash
void sha256ContextUpdate(Sha256Context *ctx, const void *src, size_t size);
/// Gets the context's output hash, finalizes the context.
void sha256ContextGetHash(Sha256Context *ctx, void *dst);
/// Simple all-in-one SHA256 calculator.
void sha256CalculateHash(void *dst, const void *src, size_t size);

View File

@ -1,22 +1,23 @@
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../sf/service.h"
#define BINDER_FIRST_CALL_TRANSACTION 0x1
typedef struct {
bool created : 1;
bool initialized : 1;
bool has_transact_auto : 1;
s32 id;
size_t ipc_buffer_size;
bool created;
bool initialized;
s32 id;
size_t dummy;
Service* relay;
} Binder;
// Note: binderClose will not close the session_handle provided to binderCreate.
void binderCreate(Binder* b, s32 id);
void binderClose(Binder* b);
Result binderInitSession(Binder* b);
Result binderInitSession(Binder* b, Service* relay);
Result binderTransactParcel(
Binder* b, u32 code,

View File

@ -1,5 +1,6 @@
#pragma once
#include "types.h"
#include "binder.h"
#include "../nvidia/fence.h"
typedef struct {
@ -10,7 +11,7 @@ typedef struct {
} BqRect;
typedef struct {
struct { s64 timestamp; } PACKED;
struct { s64 timestamp; } NX_PACKED;
s32 isAutoTimestamp;
BqRect crop;
s32 scalingMode;
@ -19,69 +20,30 @@ typedef struct {
u32 unk;
u32 swapInterval;
NvMultiFence fence;
} BqQueueBufferInput;
} BqBufferInput;
typedef struct {
u32 width;
u32 height;
u32 transformHint;
u32 numPendingBuffers;
} BqQueueBufferOutput;
} BqBufferOutput;
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.
struct { u64 timestamp; } PACKED; // unused
} data;
NativeHandle* native_handle;
} BqGraphicBuffer;
Result bqRequestBuffer(Binder *b, s32 bufferIdx, BqGraphicBuffer *buf);
Result bqDequeueBuffer(Binder *b, bool async, u32 width, u32 height, s32 format, u32 usage, s32 *buf, NvMultiFence *fence);
Result bqDetachBuffer(Binder *b, s32 slot);
Result bqQueueBuffer(Binder *b, s32 buf, BqQueueBufferInput *input, BqQueueBufferOutput *output);
Result bqCancelBuffer(Binder *b, s32 buf, NvMultiFence *fence);
Result bqQueueBuffer(Binder *b, s32 buf, const BqBufferInput *input, BqBufferOutput *output);
Result bqCancelBuffer(Binder *b, s32 buf, const NvMultiFence *fence);
Result bqQuery(Binder *b, s32 what, s32* value);
Result bqConnect(Binder *b, s32 api, bool producerControlledByApp, BqQueueBufferOutput *output);
Result bqConnect(Binder *b, s32 api, bool producerControlledByApp, BqBufferOutput *output);
Result bqDisconnect(Binder *b, s32 api);
Result bqSetPreallocatedBuffer(Binder *b, s32 buf, BqGraphicBuffer *input);
Result bqSetPreallocatedBuffer(Binder *b, s32 buf, const BqGraphicBuffer *input);

View File

@ -0,0 +1,104 @@
/**
* @file framebuffer.h
* @brief Framebuffer wrapper object, providing support for software rendered graphics.
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../nvidia/map.h"
#include "native_window.h"
/// Converts red/green/blue/alpha components to packed RGBA8 (i.e. \ref PIXEL_FORMAT_RGBA_8888).
#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)
/// Converts red/green/blue to packed RGBX8 (i.e. \ref PIXEL_FORMAT_RGBX_8888).
#define RGBX8(r,g,b) RGBA8((r),(g),(b),0)
/// Converts red/green/blue components to packed RGB565 (i.e. \ref PIXEL_FORMAT_RGB_565)
#define RGB565(r,g,b) (((b)&0x1f)|(((g)&0x3f)<<5)|(((r)&0x1f)<<11))
/// Same as \ref RGB565 but accepting 8-bit components as input instead.
#define RGB565_FROM_RGB8(r,g,b) RGB565((r)>>3,(g)>>2,(b)>>3)
/// Converts red/green/blue/alpha components to packed BGR8 (i.e. \ref PIXEL_FORMAT_BGRA_8888).
#define BGRA8(r,g,b,a) RGBA8((b),(g),(r),(a))
/// Same as \ref BGRA8 except with alpha=0xff.
#define BGRA8_MAXALPHA(r,g,b) RGBA8((b),(g),(r),0xff)
/// Converts red/green/blue/alpha components to packed RGBA4 (i.e. \ref PIXEL_FORMAT_RGBA_4444).
#define RGBA4(r,g,b,a) (((r)&0xf)|(((g)&0xf)<<4)|(((b)&0xf)<<8)|(((a)&0xf)<<12))
/// Same as \ref RGBA4 except with alpha=0xf.
#define RGBA4_MAXALPHA(r,g,b) RGBA4((r),(g),(b),0xf)
/// Same as \ref RGBA4 but accepting 8-bit components as input instead.
#define RGBA4_FROM_RGBA8(r,g,b,a) RGBA4((r)>>4,(g)>>4,(b)>>4,(a)>>4)
/// Same as \ref RGBA4_MAXALPHA except with alpha=0xff.
#define RGBA4_FROM_RGBA8_MAXALPHA(r,g,b) RGBA4_MAXALPHA((r)>>4,(g)>>4,(b)>>4)
/// Framebuffer structure.
typedef struct Framebuffer {
NWindow *win;
NvMap map;
void* buf;
void* buf_linear;
u32 stride;
u32 width_aligned;
u32 height_aligned;
u32 num_fbs;
u32 fb_size;
bool has_init;
} Framebuffer;
/**
* @brief Creates a \ref Framebuffer object.
* @param[out] fb Output \ref Framebuffer structure.
* @param[in] win Pointer to the \ref NWindow to which the \ref Framebuffer will be registered.
* @param[in] width Desired width of the framebuffer (usually 1280).
* @param[in] height Desired height of the framebuffer (usually 720).
* @param[in] format Desired pixel format (see PIXEL_FORMAT_* enum).
* @param[in] num_fbs Number of buffers to create. Pass 1 for single-buffering, 2 for double-buffering or 3 for triple-buffering.
* @note Framebuffer images are stored in Tegra block linear format with 16Bx2 sector ordering, read TRM chapter 20.1 for more details.
* In order to use regular linear layout, consider calling \ref framebufferMakeLinear after the \ref Framebuffer object is created.
* @note Presently, only the following pixel formats are supported:
* \ref PIXEL_FORMAT_RGBA_8888
* \ref PIXEL_FORMAT_RGBX_8888
* \ref PIXEL_FORMAT_RGB_565
* \ref PIXEL_FORMAT_BGRA_8888
* \ref PIXEL_FORMAT_RGBA_4444
*/
Result framebufferCreate(Framebuffer* fb, NWindow *win, u32 width, u32 height, u32 format, u32 num_fbs);
/// Enables linear framebuffer mode in a \ref Framebuffer, allocating a shadow buffer in the process.
Result framebufferMakeLinear(Framebuffer* fb);
/// Closes a \ref Framebuffer object, freeing all resources associated with it.
void framebufferClose(Framebuffer* fb);
/**
* @brief Begins rendering a frame in a \ref Framebuffer.
* @param[in] fb Pointer to \ref Framebuffer structure.
* @param[out] out_stride Output variable containing the distance in bytes between rows of pixels in memory.
* @return Pointer to buffer to which new graphics data should be written to.
* @note When this function is called, a buffer will be dequeued from the corresponding \ref NWindow.
* @note This function will return pointers to different buffers, depending on the number of buffers it was initialized with.
* @note If \ref framebufferMakeLinear was used, this function will instead return a pointer to the shadow linear buffer.
* In this case, the offset of a pixel is \p y * \p out_stride + \p x * \p bytes_per_pixel.
* @note Each call to \ref framebufferBegin must be paired with a \ref framebufferEnd call.
*/
void* framebufferBegin(Framebuffer* fb, u32* out_stride);
/**
* @brief Finishes rendering a frame in a \ref Framebuffer.
* @param[in] fb Pointer to \ref Framebuffer structure.
* @note When this function is called, the written image data will be flushed and queued (presented) in the corresponding \ref NWindow.
* @note If \ref framebufferMakeLinear was used, this function will copy the image from the shadow linear buffer to the actual framebuffer,
* converting it in the process to the layout expected by the compositor.
* @note Each call to \ref framebufferBegin must be paired with a \ref framebufferEnd call.
*/
void framebufferEnd(Framebuffer* fb);

View File

@ -1,119 +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"
#include "../nvidia/fence.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_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.
*/
Result 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.
/// 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);
/// Appends one or more fences that the display service will wait on before rendering the current framebuffer. Note that only up to 4 fences can be submitted.
void gfxAppendFence(NvMultiFence* mf);
/// Swaps the framebuffers.
void gfxSwapBuffers(void);
/// Get the specified framebuffer nvmap handle where index specifies the buffer number beginning with the back buffer, with optional output ptr for the offset in the buffer.
u32 gfxGetFramebufferHandle(u32 index, u32* offset);
/// 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);
/// Use this to get the actual byte-pitch of the framebuffer for use with memset/etc.
u32 gfxGetFramebufferPitch(void);
/// Sets the \ref GfxMode.
void gfxSetMode(GfxMode mode);
/// Configures transform. See the NATIVE_WINDOW_TRANSFORM_* enums in buffer_producer.h. The default is 0.
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;
//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)
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;
}

View File

@ -0,0 +1,190 @@
/**
* @file native_window.h
* @brief Native window (NWindow) wrapper object, used for presenting images to the display (or other sinks).
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../kernel/mutex.h"
#include "../kernel/event.h"
#include "../services/vi.h"
#include "../nvidia/graphic_buffer.h"
#include "types.h"
#include "binder.h"
#include "buffer_producer.h"
/// Native window structure.
typedef struct NWindow {
u32 magic;
Binder bq;
Event event;
Mutex mutex;
u64 slots_configured;
u64 slots_requested;
s32 cur_slot;
u32 width;
u32 height;
u32 format;
u32 usage;
BqRect crop;
u32 scaling_mode;
u32 transform;
u32 sticky_transform;
u32 default_width;
u32 default_height;
u32 swap_interval;
bool is_connected;
bool producer_controlled_by_app;
bool consumer_running_behind;
} NWindow;
///@name Basic functions
///@{
/// Checks whether a pointer refers to a valid \ref NWindow object.
bool nwindowIsValid(NWindow* nw);
/**
* @brief Retrieves the default \ref NWindow object.
* @return Pointer to the default \ref NWindow object.
* @note When this function is used/referenced, libnx will initialize VI services
* and create a \ref NWindow object from a \ref ViLayer created on the default \ref ViDisplay;
* all of this happening automatically during application startup (i.e. before main is called).
* If creating the default \ref NWindow fails, libnx will throw a LibnxError_BadGfxInit fatal error.
* Likewise, after main returns (or exit is called) libnx will clean up all resources used by it.
*/
NWindow* nwindowGetDefault(void);
/**
* @brief Creates a \ref NWindow.
* @param[out] nw Output \ref NWindow structure.
* @param[in] binder_session Service object for the Android IGraphicBufferProducer binder session.
* @param[in] binder_id Android IGraphicBufferProducer binder session ID.
* @param[in] producer_controlled_by_app Specifies whether the producer is controlled by the application.
*/
Result nwindowCreate(NWindow* nw, Service* binder_session, s32 binder_id, bool producer_controlled_by_app);
/**
* @brief Creates a \ref NWindow operating on a \ref ViLayer.
* @param[out] nw Output \ref NWindow structure.
* @param[in] layer Pointer to \ref ViLayer structure (such as the one returned by \ref viCreateLayer).
*/
Result nwindowCreateFromLayer(NWindow* nw, const ViLayer* layer);
/// Closes a \ref NWindow, freeing all resources associated with it.
void nwindowClose(NWindow* nw);
///@}
///@name Window configuration
///@{
/**
* @brief Retrieves the dimensions of a \ref NWindow.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[out] out_width Output variable containing the width of the \ref NWindow.
* @param[out] out_height Output variable containing the height of the \ref NWindow.
* @note After creation, a \ref NWindow reports a default size (usually 1280x720).
* This size can be overriden by calling \ref nwindowSetDimensions.
*/
Result nwindowGetDimensions(NWindow* nw, u32* out_width, u32* out_height);
/**
* @brief Sets the dimensions of a \ref NWindow.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[in] width Desired width of the \ref NWindow.
* @param[in] height Desired width of the \ref NWindow.
* @note This function cannot be called when there are buffers registered with the \ref NWindow.
*/
Result nwindowSetDimensions(NWindow* nw, u32 width, u32 height);
/**
* @brief Configures the crop applied to images presented through a \ref NWindow.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[in] left X coordinate of the left margin of the crop bounding box.
* @param[in] top Y coordinate of the top margin of the crop bounding box.
* @param[in] right X coordinate of the right margin of the crop bounding box.
* @param[in] bottom Y coordinate of the bottom margin of the crop bounding box.
* @note Passing zero to all parameters disables the crop functionality. This is also the default.
* @note The bounding box defined by the parameters will be adjusted to fit within the dimensions of the \ref NWindow.
* @note \p left must be less or equal than \p right.
* @note \p top must be less or equal than \p bottom.
*/
Result nwindowSetCrop(NWindow* nw, s32 left, s32 top, s32 right, s32 bottom);
/**
* @brief Configures the transformation applied to images presented through a \ref NWindow.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[in] transform Android transformation mode (see NATIVE_WINDOW_TRANSFORM_* enum)
* @note The default transformation is 0 (i.e. no transformation applied)
*/
Result nwindowSetTransform(NWindow* nw, u32 transform);
/**
* @brief Configures the swap interval of a \ref NWindow.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[in] swap_interval Value specifying the number of display refreshes (VBlanks) that must occur between presenting images.
* @note The default swap interval is 1.
* @note If the \ref NWindow has three or more buffers configured (with \ref nwindowConfigureBuffer), it is possible to pass 0
* to disable the swap interval feature and present images as fast as allowed by the compositor. Otherwise, the system
* enforces a minimum of 1 as the swap interval.
*/
Result nwindowSetSwapInterval(NWindow* nw, u32 swap_interval);
/// Checks whether the consumer of a \ref NWindow is running behind.
static inline bool nwindowIsConsumerRunningBehind(NWindow* nw)
{
return nw->consumer_running_behind;
}
///@}
///@name Buffer configuration and presentation
///@{
/**
* @brief Registers a \ref NvGraphicBuffer with a \ref NWindow.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[in] slot ID of the slot to configure (starting from 0).
* @param[in] buf Pointer to \ref NvGraphicBuffer structure.
* @note When a buffer is registered, it is added to the internal queue of buffers used for presenting.
* @note All buffers registered with a \ref NWindow must have the same dimensions, format and usage.
* If \ref nwindowSetDimensions has not been previously called, the \ref NWindow will automatically
* adopt the dimensions of the first buffer registered with it. Otherwise, said buffer will need
* to match the dimensions that were previously configured.
*/
Result nwindowConfigureBuffer(NWindow* nw, s32 slot, NvGraphicBuffer* buf);
/**
* @brief Dequeues a buffer from a \ref NWindow.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[out] out_slot Output variable containing the ID of the slot that has been dequeued.
* @param[out] out_fence Output variable containing a \ref NvMultiFence that will be signalled by
* the compositor when the buffer is ready to be written to. Pass NULL to wait instead
* on this fence before this function returns.
* @note For \p out_fence=NULL to work, \ref nvFenceInit must have been previously called.
*/
Result nwindowDequeueBuffer(NWindow* nw, s32* out_slot, NvMultiFence* out_fence);
/**
* @brief Cancels a buffer previously dequeued with \ref nwindowDequeueBuffer.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[in] slot ID of the slot to cancel. This must match the output of the previous \ref nwindowDequeueBuffer call.
* @param[in] fence Pointer to the \ref NvMultiFence that will be waited on by the compositor before cancelling the buffer.
* Pass NULL if there is no such fence.
*/
Result nwindowCancelBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence);
/**
* @brief Queues a buffer previously dequeued with \ref nwindowDequeueBuffer, making it ready for presentation.
* @param[in] nw Pointer to \ref NWindow structure.
* @param[in] slot ID of the slot to queue. This must match the output of the previous \ref nwindowDequeueBuffer call.
* @param[in] fence Pointer to the \ref NvMultiFence that will be waited on by the compositor before queuing/presenting the buffer.
* Pass NULL if there is no such fence.
*/
Result nwindowQueueBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence);
/// Releases all buffers registered with a \ref NWindow.
Result nwindowReleaseBuffers(NWindow* nw);
///@}

View File

@ -1,7 +0,0 @@
#pragma once
#include "../types.h"
Result nvgfxInitialize(void);
void nvgfxExit(void);
Result nvgfxSubmitGpfifo(void);
Result nvgfxGetFramebuffer(u8 **buffer, size_t *size, u32 *handle);

View File

@ -24,7 +24,7 @@ typedef struct {
void parcelCreate(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* parcelWriteData(Parcel *ctx, const void* data, size_t data_size);
void* parcelReadData(Parcel *ctx, void* data, size_t data_size);
void parcelWriteInt32(Parcel *ctx, s32 val);
@ -36,5 +36,5 @@ 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);
void* parcelWriteFlattenedObject(Parcel *ctx, const void* data, size_t size);

View File

@ -1,3 +1,8 @@
/**
* @file display/types.h
* @brief Definitions for Android-related types and enumerations.
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
@ -133,3 +138,10 @@ enum {
/* rotate source image 270 degrees clock-wise */
NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
};
// From Android native_handle.h.
typedef struct {
int version;
int num_fds;
int num_ints;
} NativeHandle;

View File

@ -0,0 +1,30 @@
/**
* @file barrier.h
* @brief Multi-threading Barrier
* @author tatehaga
* @copyright libnx Authors
*/
#pragma once
#include "mutex.h"
#include "condvar.h"
/// Barrier structure.
typedef struct Barrier {
u64 count; ///< Number of threads to reach the barrier.
u64 total; ///< Number of threads to wait on.
Mutex mutex;
CondVar condvar;
} Barrier;
/**
* @brief Initializes a barrier and the number of threads to wait on.
* @param b Barrier object.
* @param thread_count Initial value for the number of threads the barrier must wait for.
*/
void barrierInit(Barrier *b, u64 thread_count);
/**
* @brief Forces threads to wait until all threads have called barrierWait.
* @param b Barrier object.
*/
void barrierWait(Barrier *b);

View File

@ -40,7 +40,7 @@ Result condvarWaitTimeout(CondVar* c, Mutex* m, u64 timeout);
*/
static inline Result condvarWait(CondVar* c, Mutex* m)
{
return condvarWaitTimeout(c, m, U64_MAX);
return condvarWaitTimeout(c, m, UINT64_MAX);
}
/**
@ -51,7 +51,8 @@ static inline Result condvarWait(CondVar* c, Mutex* m)
*/
static inline Result condvarWake(CondVar* c, int num)
{
return svcSignalProcessWideKey(c, num);
svcSignalProcessWideKey(c, num);
return 0;
}
/**

View File

@ -1,21 +1,24 @@
/**
* @file detect.h
* @brief Kernel version detection
* @brief Kernel capability detection
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
#include "svc.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 kernel version is equal to or above 6.0.0.
bool kernelAbove600(void);
/// Returns true if the process has a debugger attached.
bool detectDebugger(void);
NX_INLINE bool detectDebugger(void) {
u64 tmp = 0;
Result rc = svcGetInfo(&tmp, InfoType_DebuggerAttached, INVALID_HANDLE, 0);
return R_SUCCEEDED(rc) && tmp != 0;
}
/// Returns true if the underlying kernel is Mesosphère.
NX_INLINE bool detectMesosphere(void) {
u64 dummy = 0;
Result rc = svcGetInfo(&dummy, 65000, INVALID_HANDLE, 0); // InfoType_MesosphereMeta
return R_SUCCEEDED(rc);
}

View File

@ -1,19 +1,84 @@
// Copyright 2018 plutoo
/**
* @file event.h
* @brief Kernel-mode event synchronization primitive.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
#include "../kernel/svc.h"
#include "wait.h"
/// Kernel-mode event structure.
typedef struct {
Handle revent;
Handle wevent;
bool autoclear;
Handle revent; ///< Read-only event handle
Handle wevent; ///< Write-only event handle
bool autoclear; ///< Autoclear flag
} Event;
/// Creates a \ref Waiter for a kernel-mode event.
static inline Waiter waiterForEvent(Event* t)
{
Waiter wait_obj;
wait_obj.type = t->autoclear ? WaiterType_HandleWithClear : WaiterType_Handle;
wait_obj.handle = t->revent;
return wait_obj;
}
/**
* @brief Creates a kernel-mode event.
* @param[out] t Pointer to \ref Event structure.
* @param[in] autoclear Autoclear flag.
* @return Result code.
* @warning This is a privileged operation; in normal circumstances applications shouldn't use this function.
*/
Result eventCreate(Event* t, bool autoclear);
/**
* @brief Loads a kernel-mode event obtained from IPC.
* @param[out] t Pointer to \ref Event structure.
* @param[in] handle Read-only event handle.
* @param[in] autoclear Autoclear flag.
*/
void eventLoadRemote(Event* t, Handle handle, bool autoclear);
/**
* @brief Closes a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
*/
void eventClose(Event* t);
/**
* @brief Returns whether an \ref Event is initialized.
* @param[in] t Pointer to \ref Event structure.
* @return Initialization status.
*/
static inline bool eventActive(Event* t)
{
return t->revent != INVALID_HANDLE;
}
/**
* @brief Waits on a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @param[in] timeout Timeout in nanoseconds (pass UINT64_MAX to wait indefinitely).
* @return Result code.
*/
Result eventWait(Event* t, u64 timeout);
/**
* @brief Signals a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @return Result code.
* @note This function only works for events initialized with \ref eventCreate, it doesn't work with events initialized with \ref eventLoadRemote.
* @warning This is a privileged operation; in normal circumstances applications shouldn't use this function.
*/
Result eventFire(Event* t);
/**
* @brief Clears a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @return Result code.
* @note This function shouldn't be used on autoclear events.
*/
Result eventClear(Event* t);

View File

@ -1,716 +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; i<cmd->NumStaticIn; 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; i<cmd->NumStaticOut; 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; i<cmd->NumStaticOut; 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; i<num_handles; i++)
{
r->Handles[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; i<num_statics; i++, buf+=2) {
IpcStaticSendDescriptor* desc = (IpcStaticSendDescriptor*) buf;
u64 packed = (u64) desc->Packed;
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; i<num_bufs; i++, buf+=3) {
IpcBufferDescriptor* desc = (IpcBufferDescriptor*) buf;
u64 packed = (u64) desc->Packed;
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);
}
/**
* @brief Clones an IPC session.
* @param session IPC session handle.
* @param unk Unknown.
* @param new_session_out Output cloned IPC session handle.
* @return Result code.
*/
static inline Result ipcCloneSession(Handle session, u32 unk, Handle* new_session_out) {
u32* buf = (u32*)armGetTls();
buf[0] = IpcCommandType_Control;
buf[1] = 9;
buf[2] = 0;
buf[3] = 0;
buf[4] = SFCI_MAGIC;
buf[5] = 0;
buf[6] = 4;
buf[7] = 0;
buf[8] = unk;
Result rc = ipcDispatch(session);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct ipcCloneSessionResponse {
u64 magic;
u64 result;
} *raw = (struct ipcCloneSessionResponse*)r.Raw;
rc = raw->result;
if (R_SUCCEEDED(rc) && new_session_out) {
*new_session_out = r.Handles[0];
}
}
return rc;
}
///@}
///@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
}
///@}

View File

@ -6,11 +6,12 @@
*/
#pragma once
#include "../types.h"
#include "virtmem.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_SetProcessMemoryPermission, ///< JIT supported using svcSetProcessMemoryPermission
JitType_CodeMemory, ///< JIT supported using [4.0.0+] CodeMemory syscalls
} JitType;
/// JIT buffer object.
@ -21,7 +22,10 @@ typedef struct {
void* rx_addr;
void* rw_addr;
bool is_executable;
Handle handle;
union {
Handle handle;
VirtmemReservation* rv;
};
} Jit;
/**
@ -58,11 +62,15 @@ Result jitClose(Jit* j);
* @param j JIT buffer.
* @return Pointer to alias of the JIT buffer that can be written to.
*/
void* jitGetRwAddr(Jit* j);
NX_CONSTEXPR void* jitGetRwAddr(Jit* j) {
return j->rw_addr;
}
/**
* @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);
NX_CONSTEXPR void* jitGetRxAddr(Jit* j) {
return j->rx_addr;
}

View File

@ -0,0 +1,54 @@
/**
* @file levent.h
* @brief Light event synchronization primitive [4.0.0+]
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
#include "svc.h"
/// User-mode light event structure.
typedef struct LEvent {
u32 counter;
bool autoclear;
} LEvent;
/**
* @brief Initializes a user-mode light event.
* @param[out] le Pointer to \ref LEvent structure.
* @param[in] signaled Whether the event starts off in signaled state.
* @param[in] autoclear Autoclear flag.
*/
NX_CONSTEXPR void leventInit(LEvent* le, bool signaled, bool autoclear) {
le->counter = signaled ? 2 : 0;
le->autoclear = autoclear;
}
/**
* @brief Waits on a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
* @param[in] timeout_ns Timeout in nanoseconds (pass UINT64_MAX to wait indefinitely).
* @return true if wait succeeded, false if wait timed out.
*/
bool leventWait(LEvent* le, u64 timeout_ns);
/**
* @brief Polls a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
* @return true if event is signaled, false otherwise.
*/
bool leventTryWait(LEvent* le);
/**
* @brief Signals a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
*/
void leventSignal(LEvent* le);
/**
* @brief Clears a user-mode light event.
* @param[in] le Pointer to \ref LEvent structure.
*/
void leventClear(LEvent* le);

View File

@ -20,7 +20,7 @@ typedef _LOCK_RECURSIVE_T RMutex;
*/
static inline void mutexInit(Mutex* m)
{
*m = 0;
*m = INVALID_HANDLE;
}
/**
@ -42,6 +42,13 @@ bool mutexTryLock(Mutex* m);
*/
void mutexUnlock(Mutex* m);
/**
* @brief Gets whether the current thread owns the mutex.
* @param m Mutex object.
* @return 1 if the mutex is locked by the current thread, and 0 otherwise.
*/
bool mutexIsLockedByCurrentThread(const Mutex* m);
/**
* @brief Initializes a recursive mutex.
* @param m Recursive mutex object.

View File

@ -1,17 +1,23 @@
/**
* @file rwlock.h
* @brief Read/write lock synchronization primitive.
* @author plutoo
* @author plutoo, SciresM
* @copyright libnx Authors
*/
#pragma once
#include "../kernel/mutex.h"
#include "../kernel/condvar.h"
/// Read/write lock structure.
typedef struct {
RMutex r;
RMutex g;
u64 b;
Mutex mutex;
CondVar condvar_reader_wait;
CondVar condvar_writer_wait;
u32 read_lock_count;
u32 read_waiter_count;
u32 write_lock_count;
u32 write_waiter_count;
u32 write_owner_tag;
} RwLock;
/**
@ -26,6 +32,13 @@ void rwlockInit(RwLock* r);
*/
void rwlockReadLock(RwLock* r);
/**
* @brief Attempts to lock the read/write lock for reading without waiting.
* @param r Read/write lock object.
* @return 1 if the mutex has been acquired successfully, and 0 on contention.
*/
bool rwlockTryReadLock(RwLock* r);
/**
* @brief Unlocks the read/write lock for reading.
* @param r Read/write lock object.
@ -38,8 +51,30 @@ void rwlockReadUnlock(RwLock* r);
*/
void rwlockWriteLock(RwLock* r);
/**
* @brief Attempts to lock the read/write lock for writing without waiting.
* @param r Read/write lock object.
* @return 1 if the mutex has been acquired successfully, and 0 on contention.
*/
bool rwlockTryWriteLock(RwLock* r);
/**
* @brief Unlocks the read/write lock for writing.
* @param r Read/write lock object.
*/
void rwlockWriteUnlock(RwLock* r);
/**
* @brief Checks if the write lock is held by the current thread.
* @param r Read/write lock object.
* @return 1 if the current hold holds the write lock, and 0 if it does not.
*/
bool rwlockIsWriteLockHeldByCurrentThread(RwLock* r);
/**
* @brief Checks if the read/write lock is owned by the current thread.
* @param r Read/write lock object.
* @return 1 if the current hold holds the write lock or if it holds read locks acquired
* while it held the write lock, and 0 if it does not.
*/
bool rwlockIsOwnedByCurrentThread(RwLock* r);

View File

@ -13,6 +13,9 @@
/// Pseudo handle for the current thread.
#define CUR_THREAD_HANDLE 0xFFFF8000
/// Maximum number of objects that can be waited on by \ref svcWaitSynchronization (Horizon kernel limitation).
#define MAX_WAIT_OBJECTS 0x40
/// Memory type enumeration (lower 8 bits of \ref MemoryState)
typedef enum {
MemType_Unmapped=0x00, ///< Unmapped memory.
@ -37,6 +40,8 @@ typedef enum {
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.
MemType_Coverage=0x16, ///< Not available.
MemType_Insecure=0x17, ///< Mapped in kernel during \ref svcMapInsecurePhysicalMemory.
} MemoryType;
/// Memory state bitmasks.
@ -64,10 +69,11 @@ typedef enum {
/// 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.
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.
MemAttr_IsPermissionLocked=BIT(4), ///< Is permission locked.
} MemoryAttribute;
/// Memory permission bitmasks.
@ -88,15 +94,36 @@ typedef struct {
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 device_refcount; ///< Device reference count.
u32 padding; ///< Padding.
} MemoryInfo;
/// Physical memory information structure.
typedef struct {
u64 physical_address; ///< Physical address.
u64 virtual_address; ///< Virtual address.
u64 size; ///< Size.
} PhysicalMemoryInfo;
/// Secure monitor arguments.
typedef struct {
u64 X[8]; ///< Values of X0 through X7.
} PACKED SecmonArgs;
} NX_PACKED SecmonArgs;
/// Break reasons
typedef enum {
BreakReason_Panic = 0,
BreakReason_Assert = 1,
BreakReason_User = 2,
BreakReason_PreLoadDll = 3,
BreakReason_PostLoadDll = 4,
BreakReason_PreUnloadDll = 5,
BreakReason_PostUnloadDll = 6,
BreakReason_CppException = 7,
BreakReason_NotificationOnlyFlag = 0x80000000,
} BreakReason;
/// Code memory mapping operations
typedef enum {
@ -115,6 +142,12 @@ typedef enum {
LimitableResource_Sessions=4, ///<How many sessions can a process own.
} LimitableResource;
/// Thread Activity.
typedef enum {
ThreadActivity_Runnable = 0, ///< Thread can run.
ThreadActivity_Paused = 1, ///< Thread is paused.
} ThreadActivity;
/// Process Information.
typedef enum {
ProcessInfoType_ProcessState=0, ///<What state is a process in.
@ -122,16 +155,22 @@ typedef enum {
/// Process States.
typedef enum {
ProcessState_Created=0, ///<Newly-created process.
ProcessState_DebugAttached=1, ///<Process attached to debugger.
ProcessState_DebugDetached=2, ///<Process detached from debugger.
ProcessState_Crashed=3, ///<Process that has just creashed.
ProcessState_Running=4, ///<Process executing normally.
ProcessState_Exiting=5, ///<Process has begun exiting.
ProcessState_Exited=6, ///<Process has finished exiting.
ProcessState_DebugSuspended=7, ///<Process execution suspended by debugger.
ProcessState_Created=0, ///<Newly-created process, not yet started.
ProcessState_CreatedAttached=1, ///<Newly-created process, not yet started but attached to debugger.
ProcessState_Running=2, ///<Process that is running normally (and detached from any debugger).
ProcessState_Crashed=3, ///<Process that has just crashed.
ProcessState_RunningAttached=4, ///<Process that is running normally, attached to a debugger.
ProcessState_Exiting=5, ///<Process has begun exiting.
ProcessState_Exited=6, ///<Process has finished exiting.
ProcessState_DebugSuspended=7, ///<Process execution suspended by debugger.
} ProcessState;
/// Process Activity.
typedef enum {
ProcessActivity_Runnable = 0, ///< Process can run.
ProcessActivity_Paused = 1, ///< Process is paused.
} ProcessActivity;
/// Debug Thread Parameters.
typedef enum {
DebugThreadParam_ActualPriority=0,
@ -141,15 +180,125 @@ typedef enum {
DebugThreadParam_CoreMask=4,
} DebugThreadParam;
/// GetInfo IDs.
typedef enum {
InfoType_CoreMask = 0, ///< Bitmask of allowed Core IDs.
InfoType_PriorityMask = 1, ///< Bitmask of allowed Thread Priorities.
InfoType_AliasRegionAddress = 2, ///< Base of the Alias memory region.
InfoType_AliasRegionSize = 3, ///< Size of the Alias memory region.
InfoType_HeapRegionAddress = 4, ///< Base of the Heap memory region.
InfoType_HeapRegionSize = 5, ///< Size of the Heap memory region.
InfoType_TotalMemorySize = 6, ///< Total amount of memory available for process.
InfoType_UsedMemorySize = 7, ///< Amount of memory currently used by process.
InfoType_DebuggerAttached = 8, ///< Whether current process is being debugged.
InfoType_ResourceLimit = 9, ///< Current process's resource limit handle.
InfoType_IdleTickCount = 10, ///< Number of idle ticks on CPU.
InfoType_RandomEntropy = 11, ///< [2.0.0+] Random entropy for current process.
InfoType_AslrRegionAddress = 12, ///< [2.0.0+] Base of the process's address space.
InfoType_AslrRegionSize = 13, ///< [2.0.0+] Size of the process's address space.
InfoType_StackRegionAddress = 14, ///< [2.0.0+] Base of the Stack memory region.
InfoType_StackRegionSize = 15, ///< [2.0.0+] Size of the Stack memory region.
InfoType_SystemResourceSizeTotal = 16, ///< [3.0.0+] Total memory allocated for process memory management.
InfoType_SystemResourceSizeUsed = 17, ///< [3.0.0+] Amount of memory currently used by process memory management.
InfoType_ProgramId = 18, ///< [3.0.0+] Program ID for the process.
InfoType_InitialProcessIdRange = 19, ///< [4.0.0-4.1.0] Min/max initial process IDs.
InfoType_UserExceptionContextAddress = 20, ///< [5.0.0+] Address of the process's exception context (for break).
InfoType_TotalNonSystemMemorySize = 21, ///< [6.0.0+] Total amount of memory available for process, excluding that for process memory management.
InfoType_UsedNonSystemMemorySize = 22, ///< [6.0.0+] Amount of memory used by process, excluding that for process memory management.
InfoType_IsApplication = 23, ///< [9.0.0+] Whether the specified process is an Application.
InfoType_FreeThreadCount = 24, ///< [11.0.0+] The number of free threads available to the process's resource limit.
InfoType_ThreadTickCount = 25, ///< [13.0.0+] Number of ticks spent on thread.
InfoType_IsSvcPermitted = 26, ///< [14.0.0+] Does process have access to SVC (only usable with \ref svcSynchronizePreemptionState at present).
InfoType_IoRegionHint = 27, ///< [16.0.0+] Low bits of the physical address for a KIoRegion.
InfoType_AliasRegionExtraSize = 28, ///< [18.0.0+] Extra size added to the reserved region.
InfoType_TransferMemoryHint = 34, ///< [19.0.0+] Low bits of the process address for a KTransferMemory.
InfoType_ThreadTickCountDeprecated = 0xF0000002, ///< [1.0.0-12.1.0] Number of ticks spent on thread.
} InfoType;
/// GetSystemInfo IDs.
typedef enum {
SystemInfoType_TotalPhysicalMemorySize = 0, ///< Total amount of DRAM available to system.
SystemInfoType_UsedPhysicalMemorySize = 1, ///< Current amount of DRAM used by system.
SystemInfoType_InitialProcessIdRange = 2, ///< Min/max initial process IDs.
} SystemInfoType;
/// GetInfo Idle/Thread Tick Count Sub IDs.
typedef enum {
TickCountInfo_Core0 = 0, ///< Tick count on core 0.
TickCountInfo_Core1 = 1, ///< Tick count on core 1.
TickCountInfo_Core2 = 2, ///< Tick count on core 2.
TickCountInfo_Core3 = 3, ///< Tick count on core 3.
TickCountInfo_Total = UINT64_MAX, ///< Tick count on all cores.
} TickCountInfo;
/// GetInfo InitialProcessIdRange Sub IDs.
typedef enum {
InitialProcessIdRangeInfo_Minimum = 0, ///< Lowest initial process ID.
InitialProcessIdRangeInfo_Maximum = 1, ///< Highest initial process ID.
} InitialProcessIdRangeInfo;
/// GetSystemInfo PhysicalMemory Sub IDs.
typedef enum {
PhysicalMemorySystemInfo_Application = 0, ///< Memory allocated for application usage.
PhysicalMemorySystemInfo_Applet = 1, ///< Memory allocated for applet usage.
PhysicalMemorySystemInfo_System = 2, ///< Memory allocated for system usage.
PhysicalMemorySystemInfo_SystemUnsafe = 3, ///< Memory allocated for unsafe system usage (accessible to devices).
} PhysicalMemorySystemInfo;
/// SleepThread yield types.
typedef enum {
YieldType_WithoutCoreMigration = 0l, ///< Yields to another thread on the same core.
YieldType_WithCoreMigration = -1l, ///< Yields to another thread (possibly on a different core).
YieldType_ToAnyThread = -2l, ///< Yields and performs forced load-balancing.
} YieldType;
/// SignalToAddress behaviors.
typedef enum {
SignalType_Signal = 0, ///< Signals the address.
SignalType_SignalAndIncrementIfEqual = 1, ///< Signals the address and increments its value if equal to argument.
SignalType_SignalAndModifyBasedOnWaitingThreadCountIfEqual = 2, ///< Signals the address and updates its value if equal to argument.
} SignalType;
/// WaitForAddress behaviors.
typedef enum {
ArbitrationType_WaitIfLessThan = 0, ///< Wait if the 32-bit value is less than argument.
ArbitrationType_DecrementAndWaitIfLessThan = 1, ///< Decrement the 32-bit value and wait if it is less than argument.
ArbitrationType_WaitIfEqual = 2, ///< Wait if the 32-bit value is equal to argument.
ArbitrationType_WaitIfEqual64 = 3, ///< [19.0.0+] Wait if the 64-bit value is equal to argument.
} ArbitrationType;
/// Context of a scheduled thread.
typedef struct {
u64 fp; ///< Frame Pointer for the thread.
u64 sp; ///< Stack Pointer for the thread.
u64 lr; ///< Link Register for the thread.
u64 pc; ///< Program Counter for the thread.
} LastThreadContext;
/// Memory mapping type.
typedef enum {
MemoryMapping_IoRegister = 0, ///< Mapping IO registers.
MemoryMapping_Uncached = 1, ///< Mapping normal memory without cache.
MemoryMapping_Memory = 2, ///< Mapping normal memory.
} MemoryMapping;
/// Io Pools.
typedef enum {
IoPoolType_PcieA2 = 0, ///< Physical address range 0x12000000-0x1FFFFFFF
} IoPoolType;
///@name Memory management
///@{
/**
* @brief Set the process heap to a given size. It can both extend and shrink the heap.
* @param[out] out_addr Variable to which write the address of the heap (which is randomized and fixed by the kernel)
* @param[in] size Size of the heap, must be a multiple of 0x2000000 and [2.0.0+] less than 0x18000000.
* @param[in] size Size of the heap, must be a multiple of 0x200000 and [2.0.0+] less than 0x18000000.
* @return Result code.
* @note Syscall number 0x00.
* @note Syscall number 0x01.
*/
Result svcSetHeapSize(void** out_addr, u64 size);
@ -161,7 +310,7 @@ Result svcSetHeapSize(void** out_addr, u64 size);
* @return Result code.
* @remark Perm_X is not allowed. Setting write-only is not allowed either (Perm_W).
* This can be used to move back and forth between Perm_None, Perm_R and Perm_Rw.
* @note Syscall number 0x01.
* @note Syscall number 0x02.
*/
Result svcSetMemoryPermission(void* addr, u64 size, u32 perm);
@ -172,8 +321,8 @@ Result svcSetMemoryPermission(void* addr, u64 size, u32 perm);
* @param[in] val0 State0
* @param[in] val1 State1
* @return Result code.
* @remark See <a href="http://switchbrew.org/index.php?title=SVC#svcSetMemoryAttribute">switchbrew.org Wiki</a> for more details.
* @note Syscall number 0x02.
* @remark See <a href="https://switchbrew.org/wiki/SVC#svcSetMemoryAttribute">switchbrew.org Wiki</a> for more details.
* @note Syscall number 0x03.
*/
Result svcSetMemoryAttribute(void* addr, u64 size, u32 val0, u32 val1);
@ -201,7 +350,7 @@ 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[out] pageinfo Page information which will be filled in.
* @param[in] addr Address to query.
* @return Result code.
* @note Syscall number 0x06.
@ -218,7 +367,7 @@ Result svcQueryMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, u64 addr);
* @note Syscall number 0x07.
*/
void NORETURN svcExitProcess(void);
void NX_NORETURN svcExitProcess(void);
/**
* @brief Creates a thread.
@ -238,21 +387,21 @@ Result svcStartThread(Handle handle);
* @brief Exits the current thread.
* @note Syscall number 0x0A.
*/
void NORETURN svcExitThread(void);
void NX_NORETURN svcExitThread(void);
/**
* @brief Sleeps the current thread for the specified amount of time.
* @return Result code.
* @param[in] nano Number of nanoseconds to sleep, or \ref YieldType for yield.
* @note Syscall number 0x0B.
*/
Result svcSleepThread(u64 nano);
void svcSleepThread(s64 nano);
/**
* @brief Gets a thread's priority.
* @return Result code.
* @note Syscall number 0x0C.
*/
Result svcGetThreadPriority(u32* priority, Handle handle);
Result svcGetThreadPriority(s32* priority, Handle handle);
/**
* @brief Sets a thread's priority.
@ -266,7 +415,7 @@ Result svcSetThreadPriority(Handle handle, u32 priority);
* @return Result code.
* @note Syscall number 0x0E.
*/
Result svcGetThreadCoreMask(s32* preferred_core, u32* affinity_mask, Handle handle);
Result svcGetThreadCoreMask(s32* preferred_core, u64* affinity_mask, Handle handle);
/**
* @brief Sets a thread's core mask.
@ -362,6 +511,8 @@ Result svcResetSignal(Handle handle);
* @brief Waits on one or more synchronization objects, optionally with a timeout.
* @return Result code.
* @note Syscall number 0x18.
* @note \p handleCount must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
* @note This is the raw syscall, which can be cancelled by \ref svcCancelSynchronization or other means. \ref waitHandles or \ref waitMultiHandle should normally be used instead.
*/
Result svcWaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout);
@ -369,6 +520,7 @@ Result svcWaitSynchronization(s32* index, const Handle* handles, s32 handleCount
* @brief Waits on a single synchronization object, optionally with a timeout.
* @return Result code.
* @note Wrapper for \ref svcWaitSynchronization.
* @note This is the raw syscall, which can be cancelled by \ref svcCancelSynchronization or other means. \ref waitSingleHandle should normally be used instead.
*/
static inline Result svcWaitSynchronizationSingle(Handle handle, u64 timeout) {
s32 tmp;
@ -405,10 +557,9 @@ Result svcWaitProcessWideKeyAtomic(u32* key, u32* tag_location, u32 self_tag, u6
/**
* @brief Performs a condition variable wake-up operation in userspace.
* @return Result code.
* @note Syscall number 0x1D.
*/
Result svcSignalProcessWideKey(u32* key, s32 num);
void svcSignalProcessWideKey(u32* key, s32 num);
///@}
@ -434,6 +585,13 @@ u64 svcGetSystemTick(void);
*/
Result svcConnectToNamedPort(Handle* session, const char* name);
/**
* @brief Sends a light IPC synchronization request to a session.
* @return Result code.
* @note Syscall number 0x20.
*/
Result svcSendSyncRequestLight(Handle session);
/**
* @brief Sends an IPC synchronization request to a session.
* @return Result code.
@ -482,14 +640,14 @@ Result svcGetThreadId(u64 *threadID, Handle handle);
///@{
/**
* @brief Breaks execution. Panic.
* @param[in] breakReason Break reason.
* @param[in] inval1 First break parameter.
* @param[in] inval2 Second break parameter.
* @brief Breaks execution.
* @param[in] breakReason Break reason (see \ref BreakReason).
* @param[in] address Address of the buffer to pass to the debugger.
* @param[in] size Size of the buffer to pass to the debugger.
* @return Result code.
* @note Syscall number 0x26.
*/
Result svcBreak(u32 breakReason, u64 inval1, u64 inval2);
Result svcBreak(u32 breakReason, uintptr_t address, uintptr_t size);
///@}
@ -510,6 +668,13 @@ Result svcOutputDebugString(const char *str, u64 size);
///@name Miscellaneous
///@{
/**
* @brief Returns from an exception.
* @param[in] res Result code.
* @note Syscall number 0x28.
*/
void NX_NORETURN svcReturnFromException(Result res);
/**
* @brief Retrieves information about the system, or a certain kernel object.
* @param[out] out Variable to which store the information.
@ -517,10 +682,32 @@ Result svcOutputDebugString(const char *str, u64 size);
* @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 <a href="http://switchbrew.org/index.php?title=SVC#svcGetInfo">switchbrew.org wiki</a>.
* @remark The full list of property IDs can be found on the <a href="https://switchbrew.org/wiki/SVC#svcGetInfo">switchbrew.org wiki</a>.
* @note Syscall number 0x29.
*/
Result svcGetInfo(u64* out, u64 id0, Handle handle, u64 id1);
Result svcGetInfo(u64* out, u32 id0, Handle handle, u64 id1);
///@}
///@name Cache Management
///@{
/**
* @brief Flushes the entire data cache (by set/way).
* @note Syscall number 0x2A.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @warning This syscall is dangerous, and should not be used.
*/
void svcFlushEntireDataCache(void);
/**
* @brief Flushes data cache for a virtual address range.
* @param[in] address Address of region to flush.
* @param[in] size Size of region to flush.
* @remark armDCacheFlush should be used instead of this syscall whenever possible.
* @note Syscall number 0x2B.
*/
Result svcFlushDataCache(void *address, size_t size);
///@}
@ -530,21 +717,46 @@ Result svcGetInfo(u64* out, u64 id0, Handle handle, u64 id1);
/**
* @brief Maps new heap memory at the desired address. [3.0.0+]
* @return Result code.
* @note Syscall number 0x2A.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @note Syscall number 0x2C.
*/
Result svcMapPhysicalMemory(void *address, u64 size);
/**
* @brief Undoes the effects of \ref svcMapPhysicalMemory. [3.0.0+]
* @return Result code.
* @note Syscall number 0x2B.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @note Syscall number 0x2D.
*/
Result svcUnmapPhysicalMemory(void *address, u64 size);
///@}
///@name Process and thread management
///@{
/**
* @brief Gets information about a thread that will be scheduled in the future. [5.0.0+]
* @param[out] out_context Output \ref LastThreadContext for the thread that will be scheduled.
* @param[out] out_thread_id Output thread id for the thread that will be scheduled.
* @param[in] debug Debug handle.
* @param[in] ns Nanoseconds in the future to get scheduled thread at.
* @return Result code.
* @note Syscall number 0x2E.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetDebugFutureThreadInfo(LastThreadContext *out_context, u64 *out_thread_id, Handle debug, s64 ns);
/**
* @brief Gets information about the previously-scheduled thread.
* @param[out] out_context Output \ref LastThreadContext for the previously scheduled thread.
* @param[out] out_tls_address Output tls address for the previously scheduled thread.
* @param[out] out_flags Output flags for the previously scheduled thread.
* @return Result code.
* @note Syscall number 0x2F.
*/
Result svcGetLastThreadInfo(LastThreadContext *out_context, u64 *out_tls_address, u32 *out_flags);
///@}
///@name Resource Limit Management
///@{
@ -554,7 +766,7 @@ Result svcUnmapPhysicalMemory(void *address, u64 size);
* @note Syscall number 0x30.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetResourceLimitLimitValue(u64 *out, Handle reslimit_h, LimitableResource which);
Result svcGetResourceLimitLimitValue(s64 *out, Handle reslimit_h, LimitableResource which);
/**
* @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
@ -562,7 +774,7 @@ Result svcGetResourceLimitLimitValue(u64 *out, Handle reslimit_h, LimitableResou
* @note Syscall number 0x31.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetResourceLimitCurrentValue(u64 *out, Handle reslimit_h, LimitableResource which);
Result svcGetResourceLimitCurrentValue(s64 *out, Handle reslimit_h, LimitableResource which);
///@}
@ -574,7 +786,7 @@ Result svcGetResourceLimitCurrentValue(u64 *out, Handle reslimit_h, LimitableRes
* @return Result code.
* @note Syscall number 0x32.
*/
Result svcSetThreadActivity(Handle thread, bool paused);
Result svcSetThreadActivity(Handle thread, ThreadActivity paused);
/**
* @brief Dumps the registers of a thread paused by @ref svcSetThreadActivity (register groups: all).
@ -588,6 +800,110 @@ Result svcGetThreadContext3(ThreadContext* ctx, Handle thread);
///@}
///@name Synchronization
///@{
/**
* @brief Arbitrates an address depending on type and value. [4.0.0+]
* @param[in] address Address to arbitrate.
* @param[in] arb_type \ref ArbitrationType to use.
* @param[in] value Value to arbitrate on.
* @param[in] timeout Maximum time in nanoseconds to wait.
* @return Result code.
* @note Syscall number 0x34.
*/
Result svcWaitForAddress(void *address, u32 arb_type, s64 value, s64 timeout);
/**
* @brief Signals (and updates) an address depending on type and value. [4.0.0+]
* @param[in] address Address to arbitrate.
* @param[in] signal_type \ref SignalType to use.
* @param[in] value Value to arbitrate on.
* @param[in] count Number of waiting threads to signal.
* @return Result code.
* @note Syscall number 0x35.
*/
Result svcSignalToAddress(void *address, u32 signal_type, s32 value, s32 count);
///@}
///@name Miscellaneous
///@{
/**
* @brief Sets thread preemption state (used during abort/panic). [8.0.0+]
* @note Syscall number 0x36.
*/
void svcSynchronizePreemptionState(void);
///@}
///@name Resource Limit Management
///@{
/**
* @brief Gets the peak value a LimitableResource has had, for a Resource Limit handle. [11.0.0+]
* @return Result code.
* @note Syscall number 0x37.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcGetResourceLimitPeakValue(s64 *out, Handle reslimit_h, LimitableResource which);
///@}
///@name Memory Management
///@{
/**
* @brief Creates an IO Pool. [13.0.0+]
* @return Result code.
* @note Syscall number 0x39.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcCreateIoPool(Handle *out_handle, u32 pool_type);
/**
* @brief Creates an IO Region. [13.0.0+]
* @return Result code.
* @note Syscall number 0x3A.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcCreateIoRegion(Handle *out_handle, Handle io_pool_h, u64 physical_address, u64 size, u32 memory_mapping, u32 perm);
///@}
///@name Debugging
///@{
/**
* @brief Causes the kernel to dump debug information. [1.0.0-3.0.2]
* @param[in] dump_info_type Type of information to dump.
* @param[in] arg0 Argument to the debugging operation.
* @note Syscall number 0x3C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcDumpInfo(u32 dump_info_type, u64 arg0);
/**
* @brief Performs a debugging operation on the kernel. [4.0.0+]
* @param[in] kern_debug_type Type of debugging operation to perform.
* @param[in] arg0 First argument to the debugging operation.
* @param[in] arg1 Second argument to the debugging operation.
* @param[in] arg2 Third argument to the debugging operation.
* @note Syscall number 0x3C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcKernelDebug(u32 kern_debug_type, u64 arg0, u64 arg1, u64 arg2);
/**
* @brief Performs a debugging operation on the kernel. [4.0.0+]
* @param[in] kern_trace_state Type of tracing the kernel should perform.
* @note Syscall number 0x3D.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcChangeKernelTraceState(u32 kern_trace_state);
///@}
\
///@name Inter-process communication (IPC)
///@{
@ -607,6 +923,15 @@ Result svcCreateSession(Handle *server_handle, Handle *client_handle, u32 unk0,
*/
Result svcAcceptSession(Handle *session_handle, Handle port_handle);
/**
* @brief Performs light IPC input/output.
* @return Result code.
* @param[in] handle Server or port handle to act on.
* @note Syscall number 0x42.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcReplyAndReceiveLight(Handle handle);
/**
* @brief Performs IPC input/output.
* @return Result code.
@ -641,6 +966,22 @@ Result svcCreateEvent(Handle* server_handle, Handle* client_handle);
///@name Memory management
///@{
/**
* @brief Maps an IO Region. [13.0.0+]
* @return Result code.
* @note Syscall number 0x46.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcMapIoRegion(Handle io_region_h, void *address, u64 size, u32 perm);
/**
* @brief Undoes the effects of \ref svcMapIoRegion. [13.0.0+]
* @return Result code.
* @note Syscall number 0x47.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcUnmapIoRegion(Handle io_region_h, void *address, u64 size);
/**
* @brief Maps unsafe memory (usable for GPU DMA) for a system module at the desired address. [5.0.0+]
* @return Result code.
@ -689,6 +1030,18 @@ Result svcControlCodeMemory(Handle code_handle, CodeMapOperation op, void* dst_a
///@}
///@name Power Management
///@{
/**
* @brief Causes the system to enter deep sleep.
* @note Syscall number 0x4D.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
void svcSleepSystem(void);
///@}
///@name Device memory-mapped I/O (MMIO)
///@{
@ -702,6 +1055,19 @@ Result svcReadWriteRegister(u32* outVal, u64 regAddr, u32 rwMask, u32 inVal);
///@}
///@name Process and thread management
///@{
/**
* @brief Configures the pause/unpause status of a process.
* @return Result code.
* @note Syscall number 0x4F.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcSetProcessActivity(Handle process, ProcessActivity paused);
///@}
///@name Inter-process memory sharing
///@{
@ -748,15 +1114,25 @@ Result svcCreateInterruptEvent(Handle* handle, u64 irqNum, u32 flag);
* @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);
Result svcQueryPhysicalAddress(PhysicalMemoryInfo *out, 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.
* @warning Only exists on [10.0.0+]. For older versions use \ref svcLegacyQueryIoMapping.
*/
Result svcQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size);
Result svcQueryMemoryMapping(u64* virtaddr, u64* out_size, u64 physaddr, u64 size);
/**
* @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.
* @warning Only exists on [1.0.0-9.2.0]. For newer versions use \ref svcQueryMemoryMapping.
*/
Result svcLegacyQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size);
///@}
@ -794,7 +1170,7 @@ Result svcDetachDeviceAddressSpace(u64 device, Handle handle);
* @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);
Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option);
/**
* @brief Maps an attached device address space to an userspace address.
@ -803,7 +1179,16 @@ Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 ma
* @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);
Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option);
/**
* @brief Maps an attached device address space to an userspace address. [1.0.0-12.1.0]
* @return Result code.
* @remark The userspace destination address must have the \ref MemState_MapDeviceAlignedAllowed bit set.
* @note Syscall number 0x5B.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcMapDeviceAddressSpace(u64 *out_mapped_size, 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.
@ -815,6 +1200,38 @@ Result svcUnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_add
///@}
///@name Cache Management
///@{
/**
* @brief Invalidates data cache for a virtual address range within a process.
* @param[in] address Address of region to invalidate.
* @param[in] size Size of region to invalidate.
* @note Syscall number 0x5D.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcInvalidateProcessDataCache(Handle process, uintptr_t address, size_t size);
/**
* @brief Stores data cache for a virtual address range within a process.
* @param[in] address Address of region to store.
* @param[in] size Size of region to store.
* @note Syscall number 0x5E.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcStoreProcessDataCache(Handle process, uintptr_t address, size_t size);
/**
* @brief Flushes data cache for a virtual address range within a process.
* @param[in] address Address of region to flush.
* @param[in] size Size of region to flush.
* @note Syscall number 0x5F.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcFlushProcessDataCache(Handle process, uintptr_t address, size_t size);
///@}
///@name Debugging
///@{
@ -834,20 +1251,28 @@ Result svcDebugActiveProcess(Handle* debug, u64 processID);
*/
Result svcBreakDebugProcess(Handle debug);
/**
* @brief Terminates the process of an active debugging session.
* @return Result code.
* @note Syscall number 0x62.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcTerminateDebugProcess(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);
Result svcGetDebugEvent(void* 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.
* @warning Only exists on 3.0.0+. For older versions use \ref svcContinueDebugEventPre300.
* @warning Only exists on [3.0.0+]. For older versions use \ref svcLegacyContinueDebugEvent.
*/
Result svcContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tids);
@ -856,7 +1281,7 @@ Result svcContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tid
* @return Result code.
* @note Syscall number 0x64.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
* @warning Only exists on 1.0.0-2.3.0. For newer versions use \ref svcContinueDebugEvent.
* @warning Only exists on [1.0.0-2.3.0]. For newer versions use \ref svcContinueDebugEvent.
*/
Result svcLegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID);
@ -865,7 +1290,7 @@ Result svcLegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID);
* @return Result code.
* @param[out] ctx Output thread context (register dump).
* @param[in] debug Debug handle.
* @param[in] threadId ID of the thread to dump the context of.
* @param[in] threadID ID of the thread to dump the context of.
* @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
* @note Syscall number 0x67.
* @warning Official kernel will not dump any CPU GPR if the thread is currently executing a system call (except @ref svcBreak and @ref svcReturnFromException).
@ -877,7 +1302,7 @@ Result svcGetDebugThreadContext(ThreadContext* ctx, Handle debug, u64 threadID,
* @brief Gets the context (dump the registers) of a thread in a debugging session.
* @return Result code.
* @param[in] debug Debug handle.
* @param[in] threadId ID of the thread to set the context of.
* @param[in] threadID ID of the thread to set the context of.
* @param[in] ctx Input thread context (register dump).
* @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
* @note Syscall number 0x68.
@ -897,7 +1322,7 @@ Result svcSetDebugThreadContext(Handle debug, u64 threadID, const ThreadContext*
* @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);
Result svcGetProcessList(s32 *num_out, u64 *pids_out, u32 max_pids);
/**
* @brief Retrieves a list of all threads for a debug handle (or zero).
@ -905,7 +1330,7 @@ Result svcGetProcessList(u32 *num_out, u64 *pids_out, u32 max_pids);
* @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);
Result svcGetThreadList(s32 *num_out, u64 *tids_out, u32 max_tids, Handle debug);
///@}
@ -934,7 +1359,15 @@ Result svcReadDebugProcessMemory(void* buffer, Handle debug, u64 addr, u64 size)
* @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);
Result svcWriteDebugProcessMemory(Handle debug, const void* buffer, u64 addr, u64 size);
/**
* @brief Sets one of the hardware breakpoints.
* @return Result code.
* @note Syscall number 0x6C.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcSetHardwareBreakPoint(u32 which, u64 flags, u64 value);
/**
* @brief Gets parameters from a thread in a debugging session.
@ -956,7 +1389,7 @@ Result svcGetDebugThreadParam(u64* out_64, u32* out_32, Handle debug, u64 thread
* @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 <a href="http://switchbrew.org/index.php?title=SVC#svcGetSystemInfo">switchbrew.org wiki</a>.
* @remark The full list of property IDs can be found on the <a href="https://switchbrew.org/wiki/SVC#svcGetSystemInfo">switchbrew.org wiki</a>.
* @note Syscall number 0x6F.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
@ -1035,6 +1468,18 @@ Result svcMapProcessMemory(void* dst, Handle proc, u64 src, u64 size);
*/
Result svcUnmapProcessMemory(void* dst, Handle proc, u64 src, u64 size);
/**
* @brief Equivalent to \ref svcQueryMemory, for another process.
* @param[out] meminfo_ptr \ref MemoryInfo structure which will be filled in.
* @param[out] pageinfo Page information which will be filled in.
* @param[in] proc Process handle.
* @param[in] addr Address to query.
* @return Result code.
* @note Syscall number 0x76.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcQueryProcessMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, Handle proc, u64 addr);
/**
* @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).
@ -1070,7 +1515,7 @@ Result svcUnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size);
* @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);
Result svcCreateProcess(Handle* out, const void* proc_info, const u32* caps, u64 cap_num);
/**
* @brief Starts executing a freshly created process.
@ -1094,7 +1539,7 @@ Result svcTerminateProcess(Handle proc);
* @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);
Result svcGetProcessInfo(s64 *out, Handle proc, ProcessInfoType which);
///@}
@ -1125,10 +1570,28 @@ Result svcSetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u
/**
* @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);
void svcCallSecureMonitor(SecmonArgs* regs);
///@}
///@name Memory management
///@{
/**
* @brief Maps new insecure memory at the desired address. [15.0.0+]
* @return Result code.
* @note Syscall number 0x90.
*/
Result svcMapInsecurePhysicalMemory(void *address, u64 size);
/**
* @brief Undoes the effects of \ref svcMapInsecureMemory. [15.0.0+]
* @return Result code.
* @note Syscall number 0x91.
*/
Result svcUnmapInsecurePhysicalMemory(void *address, u64 size);
///@}

View File

@ -7,28 +7,40 @@
#pragma once
#include "../types.h"
#include "../arm/thread_context.h"
#include "wait.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.
typedef struct Thread {
Handle handle; ///< Thread handle.
bool owns_stack_mem; ///< Whether the stack memory is automatically allocated.
void* stack_mem; ///< Pointer to stack memory.
void* stack_mirror; ///< Pointer to stack memory mirror.
size_t stack_sz; ///< Stack size.
void** tls_array;
struct Thread* next;
struct Thread** prev_next;
} Thread;
/// Creates a \ref Waiter for a \ref Thread.
static inline Waiter waiterForThread(Thread* t)
{
return waiterForHandle(t->handle);
}
/**
* @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 stack_mem Memory to use as backing for stack/tls/reent. Must be page-aligned. NULL argument means to allocate new memory.
* @param stack_sz If stack_mem is NULL, size to use for stack. If stack_mem is non-NULL, size to use for stack + reent + tls (must be page-aligned).
* @param prio Thread priority (0x00~0x3F); 0x2C is the usual priority of the main thread, 0x3B is a special priority on cores 0..2 that enables preemptive multithreading (0x3F on core 3).
* @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);
Thread* t, ThreadFunc entry, void* arg, void *stack_mem, size_t stack_sz,
int prio, int cpuid);
/**
* @brief Starts the execution of a thread.
@ -37,6 +49,11 @@ Result threadCreate(
*/
Result threadStart(Thread* t);
/**
* @brief Exits the current thread immediately.
*/
void NX_NORETURN threadExit(void);
/**
* @brief Waits for a thread to finish executing.
* @param t Thread information structure.
@ -73,3 +90,42 @@ Result threadResume(Thread* t);
* @warning Official kernel will not dump x0..x18 if the thread is currently executing a system call, and prior to 6.0.0 doesn't dump TPIDR_EL0.
*/
Result threadDumpContext(ThreadContext* ctx, Thread* t);
/**
* @brief Gets a pointer to the current thread structure.
* @return Thread information structure.
*/
Thread *threadGetSelf(void);
/**
* @brief Gets the raw handle to the current thread.
* @return The current thread's handle.
*/
Handle threadGetCurHandle(void);
/**
* @brief Allocates a TLS slot.
* @param destructor Function to run automatically when a thread exits.
* @return TLS slot ID on success, or a negative value on failure.
*/
s32 threadTlsAlloc(void (* destructor)(void*));
/**
* @brief Retrieves the value stored in a TLS slot.
* @param slot_id TLS slot ID.
* @return Value.
*/
void* threadTlsGet(s32 slot_id);
/**
* @brief Stores the specified value into a TLS slot.
* @param slot_id TLS slot ID.
* @param value Value.
*/
void threadTlsSet(s32 slot_id, void* value);
/**
* @brief Frees a TLS slot.
* @param slot_id TLS slot ID.
*/
void threadTlsFree(s32 slot_id);

View File

@ -27,6 +27,16 @@ typedef struct {
*/
Result tmemCreate(TransferMemory* t, size_t size, Permission perm);
/**
* @brief Creates a transfer memory object from existing memory.
* @param t Transfer memory information structure that will be filled in.
* @param buf Pointer to a page-aligned buffer.
* @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 tmemCreateFromMemory(TransferMemory* t, void* buf, 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.
@ -62,6 +72,21 @@ static inline void* tmemGetAddr(TransferMemory* t){
return t->map_addr;
}
/**
* @brief Closes handle of a transfer memory object.
* @param t Transfer memory information structure.
* @return Result code.
*/
Result tmemCloseHandle(TransferMemory* t);
/**
* @brief Waits until source backing memory permissions match perm.
* @param t Transfer memory information structure.
* @param perm Permissions which the source backing memory is expected to have before return.
* @return Result code.
*/
Result tmemWaitForPermission(TransferMemory* t, Permission perm);
/**
* @brief Frees up resources used by a transfer memory object, unmapping and closing handles, etc.
* @param t Transfer memory information structure.

View File

@ -0,0 +1,47 @@
/**
* @file uevent.h
* @brief User-mode event synchronization primitive.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "wait.h"
typedef struct UEvent UEvent;
/// User-mode event object.
struct UEvent {
Waitable waitable;
bool signal;
bool auto_clear;
};
/// Creates a waiter for a user-mode event.
static inline Waiter waiterForUEvent(UEvent* e)
{
Waiter wait_obj;
wait_obj.type = WaiterType_Waitable;
wait_obj.waitable = &e->waitable;
return wait_obj;
}
/**
* @brief Creates a user-mode event.
* @param[out] e UEvent object.
* @param[in] auto_clear Whether to automatically clear the event.
* @note It is safe to wait on this event with several threads simultaneously.
* @note If more than one thread is listening on it, at least one thread will get the signal. No other guarantees.
*/
void ueventCreate(UEvent* e, bool auto_clear);
/**
* @brief Clears the event signal.
* @param[in] e UEvent object.
*/
void ueventClear(UEvent* e);
/**
* @brief Signals the event.
* @param[in] e UEvent object.
*/
void ueventSignal(UEvent* e);

View File

@ -0,0 +1,58 @@
/**
* @file utimer.h
* @brief User-mode timer synchronization primitive.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "wait.h"
typedef struct UTimer UTimer;
/// Valid types for a user-mode timer.
typedef enum {
TimerType_OneShot, ///< Timers of this kind fire once and then stop automatically.
TimerType_Repeating, ///< Timers of this kind fire periodically.
} TimerType;
/// User-mode timer object.
struct UTimer {
Waitable waitable;
TimerType type : 8;
bool started : 1;
u64 next_tick;
u64 interval;
};
/// Creates a waiter for a user-mode timer.
static inline Waiter waiterForUTimer(UTimer* t)
{
Waiter wait_obj;
wait_obj.type = WaiterType_Waitable;
wait_obj.waitable = &t->waitable;
return wait_obj;
}
/**
* @brief Creates a user-mode timer.
* @param[out] t UTimer object.
* @param[in] interval Interval (in nanoseconds).
* @param[in] type Type of timer to create (see \ref TimerType).
* @note The timer is stopped when it is created. Use \ref utimerStart to start it.
* @note It is safe to wait on this timer with several threads simultaneously.
* @note If more than one thread is listening on it, at least one thread will get the signal. No other guarantees.
* @note For a repeating timer: If the timer triggers twice before you wait on it, you will only get one signal.
*/
void utimerCreate(UTimer* t, u64 interval, TimerType type);
/**
* @brief Starts the timer.
* @param[in] t UTimer object.
*/
void utimerStart(UTimer* t);
/**
* @brief Stops the timer.
* @param[in] t UTimer object.
*/
void utimerStop(UTimer* t);

View File

@ -7,30 +7,55 @@
#pragma once
#include "../types.h"
/// Address space reservation type (see \ref virtmemAddReservation)
typedef struct VirtmemReservation VirtmemReservation;
/// Locks the virtual memory manager mutex.
void virtmemLock(void);
/// Unlocks the virtual memory manager mutex.
void virtmemUnlock(void);
/**
* @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).
* @brief Finds a random slice of free general purpose address space.
* @param size Desired size of the slice (rounded up to page alignment).
* @param guard_size Desired size of the unmapped guard areas surrounding the slice (rounded up to page alignment).
* @return Pointer to the slice of address space, or NULL on failure.
* @note The virtual memory manager mutex must be held during the find-and-map process (see \ref virtmemLock and \ref virtmemUnlock).
*/
void* virtmemReserve(size_t size);
void* virtmemFindAslr(size_t size, size_t guard_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).
* @brief Finds a random slice of free stack address space.
* @param size Desired size of the slice (rounded up to page alignment).
* @param guard_size Desired size of the unmapped guard areas surrounding the slice (rounded up to page alignment).
* @return Pointer to the slice of address space, or NULL on failure.
* @note The virtual memory manager mutex must be held during the find-and-map process (see \ref virtmemLock and \ref virtmemUnlock).
*/
void* virtmemReserveMap(size_t size);
void* virtmemFindStack(size_t size, size_t guard_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.
* @brief Finds a random slice of free code memory address space.
* @param size Desired size of the slice (rounded up to page alignment).
* @param guard_size Desired size of the unmapped guard areas surrounding the slice (rounded up to page alignment).
* @return Pointer to the slice of address space, or NULL on failure.
* @note The virtual memory manager mutex must be held during the find-and-map process (see \ref virtmemLock and \ref virtmemUnlock).
*/
void virtmemFreeMap(void* addr, size_t size);
void* virtmemFindCodeMemory(size_t size, size_t guard_size);
/**
* @brief Reserves a range of memory address space.
* @param mem Pointer to the address space slice.
* @param size Size of the slice.
* @return Pointer to a reservation object, or NULL on failure.
* @remark This function is intended to be used in lieu of a memory map operation when the memory won't be mapped straight away.
* @note The virtual memory manager mutex must be held during the find-and-reserve process (see \ref virtmemLock and \ref virtmemUnlock).
*/
VirtmemReservation* virtmemAddReservation(void* mem, size_t size);
/**
* @brief Releases a memory address space reservation.
* @param rv Reservation to release.
* @note The virtual memory manager mutex must be held before calling this function (see \ref virtmemLock and \ref virtmemUnlock).
*/
void virtmemRemoveReservation(VirtmemReservation* rv);

View File

@ -0,0 +1,118 @@
/**
* @file wait.h
* @brief User mode synchronization primitive waiting operations.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "mutex.h"
// Implementation details.
typedef struct Waitable Waitable;
typedef struct WaitableMethods WaitableMethods;
typedef struct WaitableNode WaitableNode;
struct WaitableNode {
WaitableNode* prev;
WaitableNode* next;
};
struct Waitable {
const WaitableMethods* vt;
WaitableNode list;
Mutex mutex;
};
typedef enum {
WaiterType_Handle,
WaiterType_HandleWithClear,
WaiterType_Waitable,
} WaiterType;
// User-facing API starts here.
/// Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user-mode.
typedef struct {
WaiterType type;
union {
Handle handle;
Waitable* waitable;
};
} Waiter;
/// Creates a \ref Waiter for a kernel-mode \ref Handle.
static inline Waiter waiterForHandle(Handle h)
{
Waiter wait_obj;
wait_obj.type = WaiterType_Handle;
wait_obj.handle = h;
return wait_obj;
}
/**
* @brief Waits for an arbitrary number of generic waitable synchronization objects, optionally with a timeout.
* @param[out] idx_out Variable that will received the index of the signalled object.
* @param[in] objects Array containing \ref Waiter structures.
* @param[in] num_objects Number of objects in the array.
* @param[in] timeout Timeout (in nanoseconds).
* @return Result code.
* @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
*/
Result waitObjects(s32* idx_out, const Waiter* objects, s32 num_objects, u64 timeout);
/**
* @brief Waits for an arbitrary number of kernel synchronization objects, optionally with a timeout. This function replaces \ref svcWaitSynchronization.
* @param[out] idx_out Variable that will received the index of the signalled object.
* @param[in] handles Array containing handles.
* @param[in] num_handles Number of handles in the array.
* @param[in] timeout Timeout (in nanoseconds).
* @return Result code.
* @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
*/
Result waitHandles(s32* idx_out, const Handle* handles, s32 num_handles, u64 timeout);
/**
* @brief Helper macro for \ref waitObjects that accepts \ref Waiter structures as variadic arguments instead of as an array.
* @param[out] idx_out The index of the signalled waiter.
* @param[in] timeout Timeout (in nanoseconds).
* @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
*/
#define waitMulti(idx_out, timeout, ...) ({ \
Waiter __objects[] = { __VA_ARGS__ }; \
waitObjects((idx_out), __objects, sizeof(__objects) / sizeof(Waiter), (timeout)); \
})
/**
* @brief Helper macro for \ref waitHandles that accepts handles as variadic arguments instead of as an array.
* @param[out] idx_out The index of the signalled handle.
* @param[in] timeout Timeout (in nanoseconds).
* @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
*/
#define waitMultiHandle(idx_out, timeout, ...) ({ \
Handle __handles[] = { __VA_ARGS__ }; \
waitHandles((idx_out), __handles, sizeof(__handles) / sizeof(Handle), (timeout)); \
})
/**
* @brief Waits on a single generic waitable synchronization object, optionally with a timeout.
* @param[in] w \ref Waiter structure.
* @param[in] timeout Timeout (in nanoseconds).
*/
static inline Result waitSingle(Waiter w, u64 timeout)
{
s32 idx;
return waitObjects(&idx, &w, 1, timeout);
}
/**
* @brief Waits for a single kernel synchronization object, optionally with a timeout.
* @param[in] h \ref Handle of the object.
* @param[in] timeout Timeout (in nanoseconds).
*/
static inline Result waitSingleHandle(Handle h, u64 timeout)
{
s32 idx;
return waitHandles(&idx, &h, 1, timeout);
}

View File

@ -12,40 +12,83 @@ typedef struct {
char author[0x100];
} NacpLanguageEntry;
/// ApplicationNeighborDetectionGroupConfiguration
typedef struct {
NacpLanguageEntry lang[16];
u64 group_id; ///< GroupId
u8 key[0x10];
} NacpApplicationNeighborDetectionGroupConfiguration;
u8 x3000_unk[0x24];////Normally all-zero?
u32 x3024_unk;
u32 x3028_unk;
u32 x302C_unk;
u32 x3030_unk;
u32 x3034_unk;
u64 titleID0;
/// NeighborDetectionClientConfiguration
typedef struct {
NacpApplicationNeighborDetectionGroupConfiguration send_group_configuration; ///< SendGroupConfiguration
NacpApplicationNeighborDetectionGroupConfiguration receivable_group_configurations[0x10]; ///< ReceivableGroupConfigurations
} NacpNeighborDetectionClientConfiguration;
u8 x3040_unk[0x20];
char version[0x10];
/// ApplicationJitConfiguration
typedef struct {
u64 flags; ///< Flags
u64 memory_size; ///< MemorySize
} NacpApplicationJitConfiguration;
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?
/// ns ApplicationControlProperty
typedef struct {
NacpLanguageEntry lang[16]; ///< \ref NacpLanguageEntry
u8 isbn[0x25]; ///< Isbn
u8 startup_user_account; ///< StartupUserAccount
u8 user_account_switch_lock; ///< UserAccountSwitchLock
u8 add_on_content_registration_type; ///< AddOnContentRegistrationType
u32 attribute_flag; ///< AttributeFlag
u32 supported_language_flag; ///< SupportedLanguageFlag
u32 parental_control_flag; ///< ParentalControlFlag
u8 screenshot; ///< Screenshot
u8 video_capture; ///< VideoCapture
u8 data_loss_confirmation; ///< DataLossConfirmation
u8 play_log_policy; ///< PlayLogPolicy
u64 presence_group_id; ///< PresenceGroupId
s8 rating_age[0x20]; ///< RatingAge
char display_version[0x10]; ///< DisplayVersion
u64 add_on_content_base_id; ///< AddOnContentBaseId
u64 save_data_owner_id; ///< SaveDataOwnerId
u64 user_account_save_data_size; ///< UserAccountSaveDataSize
u64 user_account_save_data_journal_size; ///< UserAccountSaveDataJournalSize
u64 device_save_data_size; ///< DeviceSaveDataSize
u64 device_save_data_journal_size; ///< DeviceSaveDataJournalSize
u64 bcat_delivery_cache_storage_size; ///< BcatDeliveryCacheStorageSize
u64 application_error_code_category; ///< ApplicationErrorCodeCategory
u64 local_communication_id[0x8]; ///< LocalCommunicationId
u8 logo_type; ///< LogoType
u8 logo_handling; ///< LogoHandling
u8 runtime_add_on_content_install; ///< RuntimeAddOnContentInstall
u8 runtime_parameter_delivery; ///< RuntimeParameterDelivery
u8 reserved_x30f4[0x2]; ///< Reserved
u8 crash_report; ///< CrashReport
u8 hdcp; ///< Hdcp
u64 pseudo_device_id_seed; ///< SeedForPseudoDeviceId
char bcat_passphrase[0x41]; ///< BcatPassphrase
u8 startup_user_account_option; ///< StartupUserAccountOption
u8 reserved_for_user_account_save_data_operation[0x6]; ///< ReservedForUserAccountSaveDataOperation
u64 user_account_save_data_size_max; ///< UserAccountSaveDataSizeMax
u64 user_account_save_data_journal_size_max; ///< UserAccountSaveDataJournalSizeMax
u64 device_save_data_size_max; ///< DeviceSaveDataSizeMax
u64 device_save_data_journal_size_max; ///< DeviceSaveDataJournalSizeMax
u64 temporary_storage_size; ///< TemporaryStorageSize
u64 cache_storage_size; ///< CacheStorageSize
u64 cache_storage_journal_size; ///< CacheStorageJournalSize
u64 cache_storage_data_and_journal_size_max; ///< CacheStorageDataAndJournalSizeMax
u16 cache_storage_index_max; ///< CacheStorageIndexMax
u8 reserved_x318a[0x6]; ///< Reserved
u64 play_log_queryable_application_id[0x10]; ///< PlayLogQueryableApplicationId
u8 play_log_query_capability; ///< PlayLogQueryCapability
u8 repair_flag; ///< RepairFlag
u8 program_index; ///< ProgramIndex
u8 required_network_service_license_on_launch; ///< RequiredNetworkServiceLicenseOnLaunchFlag
u32 reserved_x3214; ///< Reserved
NacpNeighborDetectionClientConfiguration neighbor_detection_client_configuration; ///< NeighborDetectionClientConfiguration
NacpApplicationJitConfiguration jit_configuration; ///< JitConfiguration
u8 reserved_x33c0[0xc40]; ///< Reserved
} 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.
/// If you're using ns you may want to use \ref nsGetApplicationDesiredLanguage instead.
Result nacpGetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry);

View File

@ -1,25 +1,21 @@
#pragma once
#include "types.h"
#include "ioctl.h"
typedef struct NvAddressSpace {
u32 fd;
u32 page_size;
bool has_init;
} NvAddressSpace;
typedef enum {
NvPageSize_4K = 0x1000,
NvPageSize_64K = 0x10000
} NvPageSize;
Result nvAddressSpaceCreate(NvAddressSpace* a);
Result nvAddressSpaceCreate(NvAddressSpace* a, u32 page_size);
void nvAddressSpaceClose(NvAddressSpace* a);
Result nvAddressSpaceReserveAlign(NvAddressSpace* a, NvPageSize align, u32 pages, NvPageSize page_sz, iova_t* iova_out);
Result nvAddressSpaceReserveAtFixedAddr(NvAddressSpace* a, iova_t addr, u32 pages, NvPageSize page_sz);
Result nvAddressSpaceReserveFull(NvAddressSpace* a);
Result nvAddressSpaceAlloc(NvAddressSpace* a, bool sparse, u64 size, iova_t* iova_out);
Result nvAddressSpaceAllocFixed(NvAddressSpace* a, bool sparse, u64 size, iova_t iova);
Result nvAddressSpaceFree(NvAddressSpace* a, iova_t iova, u64 size);
Result nvAddressSpaceMapBuffer(NvAddressSpace* a, u32 fd, u32 flags, NvKind kind, iova_t* iova_out);
Result nvAddressSpaceUnmapBuffer(NvAddressSpace* a, iova_t iova);
struct NvChannel;
Result nvAddressSpaceBindToChannel(NvAddressSpace* a, struct NvChannel* channel);
Result nvAddressSpaceMap(NvAddressSpace* a, u32 nvmap_handle, bool is_gpu_cacheable, NvKind kind, iova_t* iova_out);
Result nvAddressSpaceMapFixed(NvAddressSpace* a, u32 nvmap_handle, bool is_gpu_cacheable, NvKind kind, iova_t iova);
Result nvAddressSpaceModify(NvAddressSpace* a, iova_t iova, u64 offset, u64 size, NvKind kind);
Result nvAddressSpaceUnmap(NvAddressSpace* a, iova_t iova);

View File

@ -1,30 +0,0 @@
#pragma once
#include "types.h"
#include "address_space.h"
typedef struct NvAddressSpace NvAddressSpace;
typedef struct NvBuffer {
u32 fd;
u32 size;
void* cpu_addr;
iova_t gpu_addr;
iova_t gpu_addr_texture;
NvAddressSpace* addr_space;
NvKind kind;
bool has_init;
bool is_cacheable;
} NvBuffer;
Result nvBufferInit(void);
u32 nvBufferGetNvmapFd(void);
void nvBufferExit(void);
Result nvBufferCreate(NvBuffer* m, size_t size, u32 align, bool is_cacheable, NvKind kind, NvAddressSpace* as);
void nvBufferFree(NvBuffer* m);
void* nvBufferGetCpuAddr(NvBuffer* m);
iova_t nvBufferGetGpuAddr(NvBuffer* m);
Result nvBufferMapAsTexture(NvBuffer* m, NvKind kind);
iova_t nvBufferGetGpuAddrTexture(NvBuffer* m);

View File

@ -1,5 +1,6 @@
#pragma once
#include "types.h"
#include "ioctl.h"
typedef struct NvChannel {
u32 fd;
@ -11,4 +12,3 @@ void nvChannelClose(NvChannel* c);
Result nvChannelSetPriority(NvChannel* c, NvChannelPriority prio);
Result nvChannelSetTimeout(NvChannel* c, u32 timeout);
Result nvChannelSetNvmapFd(NvChannel* c);

View File

@ -10,6 +10,7 @@ typedef struct {
Result nvFenceInit(void);
void nvFenceExit(void);
u32 nvFenceGetFd(void);
Result nvFenceWait(NvFence* f, s32 timeout_us);

View File

@ -0,0 +1,16 @@
#pragma once
#include "types.h"
#include "ioctl.h"
Result nvGpuInit(void);
void nvGpuExit(void);
const nvioctl_gpu_characteristics* nvGpuGetCharacteristics(void);
u32 nvGpuGetZcullCtxSize(void);
const nvioctl_zcull_info* nvGpuGetZcullInfo(void);
const u32* nvGpuGetTpcMasks(u32 *num_masks_out);
Result nvGpuZbcGetActiveSlotMask(u32 *out_slot, u32 *out_mask);
Result nvGpuZbcAddColor(const u32 color_l2[4], const u32 color_ds[4], u32 format);
Result nvGpuZbcAddDepth(float depth);
Result nvGpuGetTimestamp(u64 *ts);

View File

@ -1,11 +0,0 @@
#pragma once
typedef struct NvGpu NvGpu;
typedef struct {
NvGpu* parent;
u64 obj_id;
} Nv3DContext;
Result nv3DContextCreate(Nv3DContext* t, NvGpu* parent);
void nv3DContextClose(Nv3DContext* t);

View File

@ -1,20 +0,0 @@
#pragma once
typedef struct NvGpu NvGpu;
typedef struct {
NvBuffer buffer;
size_t offset;
size_t num_cmds;
size_t max_cmds;
NvGpu* parent;
} NvCmdList;
Result nvCmdListCreate(NvCmdList* c, NvGpu* parent, size_t max_cmds);
void nvCmdListClose(NvCmdList* c);
iova_t nvCmdListGetGpuAddr(NvCmdList* c);
u64 nvCmdListGetListSize(NvCmdList* c);
void nvCmdListReset(NvCmdList* c);
u32* nvCmdListInsert(NvCmdList* c, size_t num_cmds);

View File

@ -1,14 +0,0 @@
#pragma once
typedef struct NvGpu NvGpu;
typedef struct {
NvGpu* parent;
Event event;
bool has_init;
} NvErrorNotifier;
Result nvErrorNotifierCreate(NvErrorNotifier* t, NvGpu* parent);
void nvErrorNotifierClose(NvErrorNotifier* t);
Result nvErrorNotifierWait(NvErrorNotifier* t, u64 timeout);
Result nvErrorNotifierGetError(NvErrorNotifier* t, NvError* out);

View File

@ -1,19 +0,0 @@
#pragma once
#define GPFIFO_QUEUE_SIZE 0x800
#define GPFIFO_ENTRY_NOT_MAIN BIT(9)
#define GPFIFO_ENTRY_NO_PREFETCH BIT(31)
typedef struct {
NvChannel* parent;
u32 syncpt_id;
u32 num_entries;
nvioctl_gpfifo_entry entries[GPFIFO_QUEUE_SIZE];
} NvGpfifo;
Result nvGpfifoCreate(NvGpfifo* f, NvChannel* parent);
void nvGpfifoClose(NvGpfifo* f);
Result nvGpfifoAppendEntry(NvGpfifo* f, iova_t start, size_t num_cmds, u32 flags);
Result nvGpfifoAppendCmdList(NvGpfifo* f, NvCmdList* cmd_list, u32 flags);
Result nvGpfifoFlush(NvGpfifo* f, u32 fence_incr, NvFence* fence_out);

View File

@ -1,13 +0,0 @@
#pragma once
typedef struct NvGpu {
NvAddressSpace addr_space;
NvChannel gpu_channel;
NvGpfifo gpfifo;
NvZcullContext zcull_ctx;
Nv3DContext _3d_ctx;
NvErrorNotifier error_notifier;
} NvGpu;
Result nvGpuCreate(NvGpu* g);
void nvGpuClose(NvGpu* g);

View File

@ -1,11 +0,0 @@
#pragma once
typedef struct NvGpu NvGpu;
typedef struct {
NvGpu* parent;
NvBuffer ctx_buf;
} NvZcullContext;
Result nvZcullContextCreate(NvZcullContext* z, NvGpu* parent);
void nvZcullContextClose(NvZcullContext* z);

View File

@ -0,0 +1,44 @@
#pragma once
#include "../kernel/event.h"
#include "channel.h"
#include "fence.h"
#define GPFIFO_QUEUE_SIZE 0x800
#define GPFIFO_ENTRY_NOT_MAIN BIT(9)
#define GPFIFO_ENTRY_NO_PREFETCH BIT(31)
typedef struct NvGpuChannel
{
NvChannel base;
Event error_event;
u64 object_id;
NvFence fence;
u32 fence_incr;
nvioctl_gpfifo_entry entries[GPFIFO_QUEUE_SIZE];
u32 num_entries;
} NvGpuChannel;
Result nvGpuChannelCreate(NvGpuChannel* c, struct NvAddressSpace* as, NvChannelPriority prio);
void nvGpuChannelClose(NvGpuChannel* c);
Result nvGpuChannelZcullBind(NvGpuChannel* c, iova_t iova);
Result nvGpuChannelAppendEntry(NvGpuChannel* c, iova_t start, size_t num_cmds, u32 flags, u32 flush_threshold);
Result nvGpuChannelKickoff(NvGpuChannel* c);
Result nvGpuChannelGetErrorNotification(NvGpuChannel* c, NvNotification* notif);
Result nvGpuChannelGetErrorInfo(NvGpuChannel* c, NvError* error);
static inline u32 nvGpuChannelGetSyncpointId(NvGpuChannel* c)
{
return c->fence.id;
}
static inline void nvGpuChannelGetFence(NvGpuChannel* c, NvFence* fence_out)
{
fence_out->id = c->fence.id;
fence_out->value = c->fence.value + c->fence_incr;
}
static inline void nvGpuChannelIncrFence(NvGpuChannel* c)
{
++c->fence_incr;
}

View File

@ -0,0 +1,39 @@
#pragma once
#include "../display/types.h"
#include "types.h"
typedef struct {
u32 width;
u32 height;
NvColorFormat color_format;
NvLayout layout;
u32 pitch;
u32 unused; // usually this field contains the nvmap handle, but it's completely unused/overwritten during marshalling
u32 offset;
NvKind kind;
u32 block_height_log2;
NvDisplayScanFormat scan;
u32 second_field_offset;
u64 flags;
u64 size;
u32 unk[6]; // compression related
} NvSurface;
typedef struct {
NativeHandle header;
s32 unk0; // -1
s32 nvmap_id; // nvmap object id
u32 unk2; // 0
u32 magic; // 0xDAFFCAFF
u32 pid; // 42
u32 type; // ?
u32 usage; // GRALLOC_USAGE_* bitmask
u32 format; // PIXEL_FORMAT_*
u32 ext_format; // copy of the above (in most cases)
u32 stride; // in pixels!
u32 total_size; // in bytes
u32 num_planes; // usually 1
u32 unk12; // 0
NvSurface planes[3];
u64 unused; // official sw writes a pointer to bookkeeping data here, but it's otherwise completely unused/overwritten during marshalling
} NvGraphicBuffer;

View File

@ -1,7 +0,0 @@
#pragma once
#include "types.h"
Result nvInfoInit(void);
void nvInfoExit(void);
u32 nvInfoGetZcullCtxSize(void);

View File

@ -44,6 +44,29 @@
#define __nv_out
#define __nv_inout
typedef struct {
u32 width_align_pixels; // 0x20 (32)
u32 height_align_pixels; // 0x20 (32)
u32 pixel_squares_by_aliquots; // 0x400 (1024)
u32 aliquot_total; // 0x800 (2048)
u32 region_byte_multiplier; // 0x20 (32)
u32 region_header_size; // 0x20 (32)
u32 subregion_header_size; // 0xC0 (192)
u32 subregion_width_align_pixels; // 0x20 (32)
u32 subregion_height_align_pixels; // 0x40 (64)
u32 subregion_count; // 0x10 (16)
} nvioctl_zcull_info;
typedef struct {
u32 color_ds[4];
u32 color_l2[4];
u32 depth;
u32 ref_cnt;
u32 format;
u32 type;
u32 size;
} nvioctl_zbc_entry;
typedef struct {
u32 arch; // 0x120 (NVGPU_GPU_ARCH_GM200)
u32 impl; // 0xB (NVGPU_GPU_IMPL_GM20B)
@ -90,9 +113,14 @@ typedef struct {
} nvioctl_va_region;
typedef struct {
u32 mask; // always 0x07
u32 flush; // active flush bit field
} nvioctl_l2_state;
u32 slot; // always 0x07 (?)
u32 mask;
} nvioctl_zbc_slot_mask;
typedef struct {
u64 timestamp;
u64 reserved;
} nvioctl_gpu_time;
typedef struct {
u32 id;
@ -106,6 +134,54 @@ typedef struct {
};
} nvioctl_gpfifo_entry;
typedef struct {
u32 mem;
u32 offset;
u32 words;
} nvioctl_cmdbuf;
typedef struct {
u32 cmdbuf_mem;
u32 cmdbuf_offset;
u32 target;
u32 target_offset;
} nvioctl_reloc;
typedef struct {
u32 shift;
} nvioctl_reloc_shift;
typedef struct {
u32 syncpt_id;
u32 syncpt_incrs;
u32 waitbase_id; // Always -1
u32 next; //< Next valid incr index, or -1
u32 prev; //< Previous valid incr index, or -1
} nvioctl_syncpt_incr;
typedef struct {
u32 handle;
u32 iova;
} nvioctl_command_buffer_map;
typedef struct {
u32 rate;
u32 moduleid;
} nvioctl_clk_rate;
#define NVGPU_ZBC_TYPE_INVALID 0
#define NVGPU_ZBC_TYPE_COLOR 1
#define NVGPU_ZBC_TYPE_DEPTH 2
// Used with nvioctlNvmap_Param().
typedef enum nvioctl_map_param {
NvMapParam_Size = 1,
NvMapParam_Alignment = 2,
NvMapParam_Base = 3,
NvMapParam_Heap = 4,
NvMapParam_Kind = 5
} NvMapParam;
// Used with nvioctlChannel_AllocObjCtx().
typedef enum nvioctl_channel_obj_classnum {
NvClassNumber_2D = 0x902D,
@ -131,28 +207,40 @@ typedef enum {
NvZcullConfig_PartOfRegularBuffer = 3
} NvZcullConfig;
// Used with nvioctlNvhostAsGpu_AllocSpace().
typedef enum {
NvAllocSpaceFlags_FixedOffset = 1,
NvAllocSpaceFlags_Sparse = 2,
} NvAllocSpaceFlags;
// Used with nvioctlNvhostAsGpu_MapBufferEx().
typedef enum {
NvMapBufferFlags_FixedOffset = 1,
NvMapBufferFlags_IsCacheable = 4,
NvMapBufferFlags_Modify = 0x100,
} NvMapBufferFlags;
typedef enum {
NvErrorType_FifoErrorIdleTimeout=8,
NvErrorType_GrErrorSwNotify=13,
NvErrorType_GrSemaphoreTimeout=24,
NvErrorType_GrIllegalNotify=25,
NvErrorType_FifoErrorMmuErrFlt=31,
NvErrorType_PbdmaError=32,
NvErrorType_ResetChannelVerifError=43,
NvErrorType_PbdmaPushbufferCrcMismatch=80
} NvErrorType;
NvNotificationType_FifoErrorIdleTimeout=8,
NvNotificationType_GrErrorSwNotify=13,
NvNotificationType_GrSemaphoreTimeout=24,
NvNotificationType_GrIllegalNotify=25,
NvNotificationType_FifoErrorMmuErrFlt=31,
NvNotificationType_PbdmaError=32,
NvNotificationType_ResetChannelVerifError=43,
NvNotificationType_PbdmaPushbufferCrcMismatch=80
} NvNotificationType;
typedef struct {
u64 tickstamp;
u32 error_type;
u16 unk16;
u64 timestamp;
u32 info32; // see NvNotificationType
u16 info16;
u16 status; // always -1
} NvNotification;
typedef struct {
u32 type;
u32 info[31];
} NvError;
Result nvioctlNvhostCtrl_SyncptRead(u32 fd, u32 id, u32* out);
@ -165,22 +253,27 @@ Result nvioctlNvhostCtrl_EventRegister(u32 fd, u32 event_id);
Result nvioctlNvhostCtrl_EventUnregister(u32 fd, u32 event_id);
Result nvioctlNvhostCtrlGpu_ZCullGetCtxSize(u32 fd, u32 *out);
Result nvioctlNvhostCtrlGpu_ZCullGetInfo(u32 fd, u32 out[40>>2]);
Result nvioctlNvhostCtrlGpu_ZCullGetInfo(u32 fd, nvioctl_zcull_info *out);
Result nvioctlNvhostCtrlGpu_ZbcSetTable(u32 fd, const u32 color_ds[4], const u32 color_l2[4], u32 depth, u32 format, u32 type);
Result nvioctlNvhostCtrlGpu_ZbcQueryTable(u32 fd, u32 index, nvioctl_zbc_entry *out);
Result nvioctlNvhostCtrlGpu_GetCharacteristics(u32 fd, nvioctl_gpu_characteristics *out);
Result nvioctlNvhostCtrlGpu_GetTpcMasks(u32 fd, u32 inval, u32 out[24>>2]);
Result nvioctlNvhostCtrlGpu_GetL2State(u32 fd, nvioctl_l2_state *out);
Result nvioctlNvhostCtrlGpu_GetTpcMasks(u32 fd, void *buffer, size_t size);
Result nvioctlNvhostCtrlGpu_ZbcGetActiveSlotMask(u32 fd, nvioctl_zbc_slot_mask *out);
Result nvioctlNvhostCtrlGpu_GetGpuTime(u32 fd, nvioctl_gpu_time *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_AllocSpace(u32 fd, u32 pages, u32 page_size, u32 flags, u64 align_or_offset, u64 *offset);
Result nvioctlNvhostAsGpu_FreeSpace(u32 fd, u64 offset, u32 pages, u32 page_size);
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_UnmapBuffer(u32 fd, u64 offset);
Result nvioctlNvhostAsGpu_GetVARegions(u32 fd, nvioctl_va_region regions[2]);
Result nvioctlNvhostAsGpu_InitializeEx(u32 fd, u32 big_page_size, u32 flags);
Result nvioctlNvhostAsGpu_InitializeEx(u32 fd, u32 flags, u32 big_page_size);
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_Free(u32 fd, u32 nvmap_handle);
Result nvioctlNvmap_Param(u32 fd, u32 nvmap_handle, NvMapParam param, u32 *result);
Result nvioctlNvmap_GetId(u32 fd, u32 nvmap_handle, u32 *id);
Result nvioctlChannel_SetNvmapFd(u32 fd, u32 nvmap_fd);
@ -189,8 +282,17 @@ Result nvioctlChannel_KickoffPb(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_e
Result nvioctlChannel_AllocObjCtx(u32 fd, u32 class_num, u32 flags, u64* id_out);
Result nvioctlChannel_ZCullBind(u32 fd, u64 gpu_va, u32 mode);
Result nvioctlChannel_SetErrorNotifier(u32 fd, u32 enable);
Result nvioctlChannel_GetErrorNotification(u32 fd, NvError* out);
Result nvioctlChannel_GetErrorInfo(u32 fd, NvError* out);
Result nvioctlChannel_GetErrorNotification(u32 fd, NvNotification* out);
Result nvioctlChannel_SetPriority(u32 fd, u32 priority);
Result nvioctlChannel_SetTimeout(u32 fd, u32 timeout);
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);
Result nvioctlChannel_Submit(u32 fd, const nvioctl_cmdbuf *cmdbufs, u32 num_cmdbufs, const nvioctl_reloc *relocs, const nvioctl_reloc_shift *reloc_shifts, u32 num_relocs,
const nvioctl_syncpt_incr *syncpt_incrs, u32 num_syncpt_incrs, nvioctl_fence *fences, u32 num_fences);
Result nvioctlChannel_GetSyncpt(u32 fd, u32 module_id, u32 *syncpt);
Result nvioctlChannel_GetModuleClockRate(u32 fd, u32 module_id, u32 *freq);
Result nvioctlChannel_SetModuleClockRate(u32 fd, u32 module_id, u32 freq);
Result nvioctlChannel_MapCommandBuffer(u32 fd, nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed);
Result nvioctlChannel_UnmapCommandBuffer(u32 fd, const nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed);
Result nvioctlChannel_SetSubmitTimeout(u32 fd, u32 timeout);

View File

@ -0,0 +1,50 @@
#pragma once
#include "types.h"
typedef struct NvMap {
u32 handle;
u32 id;
u32 size;
void* cpu_addr;
NvKind kind;
bool has_init;
bool is_cpu_cacheable;
} NvMap;
Result nvMapInit(void);
u32 nvMapGetFd(void);
void nvMapExit(void);
Result nvMapCreate(NvMap* m, void* cpu_addr, u32 size, u32 align, NvKind kind, bool is_cpu_cacheable);
Result nvMapLoadRemote(NvMap* m, u32 id);
void nvMapClose(NvMap* m);
static inline u32 nvMapGetHandle(NvMap* m)
{
return m->handle;
}
static inline u32 nvMapGetId(NvMap* m)
{
return m->id;
}
static inline u32 nvMapGetSize(NvMap* m)
{
return m->size;
}
static inline void* nvMapGetCpuAddr(NvMap* m)
{
return m->cpu_addr;
}
static inline bool nvMapIsRemote(NvMap* m)
{
return !m->cpu_addr;
}
static inline NvKind nvMapGetKind(NvMap* m)
{
return m->kind;
}

View File

@ -249,3 +249,236 @@ typedef enum {
NvKind_Generic_16BX2 = 0xfe,
NvKind_Invalid = 0xff,
} NvKind;
typedef enum {
NvColorFormat_Unspecified = 0x0000000000UL,
NvColorFormat_NonColor8 = 0x0009200408UL,
NvColorFormat_NonColor16 = 0x0009200A10UL,
NvColorFormat_NonColor24 = 0x0009201A18UL,
NvColorFormat_NonColor32 = 0x0009201C20UL,
NvColorFormat_X4C4 = 0x0009210508UL,
NvColorFormat_A4L4 = 0x0100490508UL,
NvColorFormat_A8L8 = 0x0100490E10UL,
NvColorFormat_Float_A16L16 = 0x0100495D20UL,
NvColorFormat_A1B5G5R5 = 0x0100531410UL,
NvColorFormat_A4B4G4R4 = 0x0100531510UL,
NvColorFormat_A5B5G5R1 = 0x0100531810UL,
NvColorFormat_A2B10G10R10 = 0x0100532020UL,
NvColorFormat_A8B8G8R8 = 0x0100532120UL,
NvColorFormat_A16B16G16R16 = 0x0100532740UL,
NvColorFormat_Float_A16B16G16R16 = 0x0100536740UL,
NvColorFormat_A1R5G5B5 = 0x0100D11410UL,
NvColorFormat_A4R4G4B4 = 0x0100D11510UL,
NvColorFormat_A5R1G5B5 = 0x0100D11610UL,
NvColorFormat_A2R10G10B10 = 0x0100D12020UL,
NvColorFormat_A8R8G8B8 = 0x0100D12120UL,
NvColorFormat_A1 = 0x0101240101UL,
NvColorFormat_A2 = 0x0101240202UL,
NvColorFormat_A4 = 0x0101240304UL,
NvColorFormat_A8 = 0x0101240408UL,
NvColorFormat_A16 = 0x0101240A10UL,
NvColorFormat_A32 = 0x0101241C20UL,
NvColorFormat_Float_A16 = 0x0101244A10UL,
NvColorFormat_L4A4 = 0x0102000508UL,
NvColorFormat_L8A8 = 0x0102000E10UL,
NvColorFormat_B4G4R4A4 = 0x01060A1510UL,
NvColorFormat_B5G5R1A5 = 0x01060A1710UL,
NvColorFormat_B5G5R5A1 = 0x01060A1810UL,
NvColorFormat_B8G8R8A8 = 0x01060A2120UL,
NvColorFormat_B10G10R10A2 = 0x01060A2320UL,
NvColorFormat_R1G5B5A5 = 0x0106881410UL,
NvColorFormat_R4G4B4A4 = 0x0106881510UL,
NvColorFormat_R5G5B5A1 = 0x0106881810UL,
NvColorFormat_R8G8B8A8 = 0x0106882120UL,
NvColorFormat_R10G10B10A2 = 0x0106882320UL,
NvColorFormat_L1 = 0x010A000101UL,
NvColorFormat_L2 = 0x010A000202UL,
NvColorFormat_L4 = 0x010A000304UL,
NvColorFormat_L8 = 0x010A000408UL,
NvColorFormat_L16 = 0x010A000A10UL,
NvColorFormat_L32 = 0x010A001C20UL,
NvColorFormat_Float_L16 = 0x010A004A10UL,
NvColorFormat_B5G6R5 = 0x010A0A1210UL,
NvColorFormat_B6G5R5 = 0x010A0A1310UL,
NvColorFormat_B5G5R5X1 = 0x010A0A1810UL,
NvColorFormat_B8_G8_R8 = 0x010A0A1918UL,
NvColorFormat_B8G8R8X8 = 0x010A0A2120UL,
NvColorFormat_Float_B10G11R11 = 0x010A0A5E20UL,
NvColorFormat_X1B5G5R5 = 0x010A531410UL,
NvColorFormat_X8B8G8R8 = 0x010A532120UL,
NvColorFormat_X16B16G16R16 = 0x010A532740UL,
NvColorFormat_Float_X16B16G16R16 = 0x010A536740UL,
NvColorFormat_R3G3B2 = 0x010A880608UL,
NvColorFormat_R5G5B6 = 0x010A881110UL,
NvColorFormat_R5G6B5 = 0x010A881210UL,
NvColorFormat_R5G5B5X1 = 0x010A881810UL,
NvColorFormat_R8_G8_B8 = 0x010A881918UL,
NvColorFormat_R8G8B8X8 = 0x010A882120UL,
NvColorFormat_X1R5G5B5 = 0x010AD11410UL,
NvColorFormat_X8R8G8B8 = 0x010AD12120UL,
NvColorFormat_RG8 = 0x010B080E10UL,
NvColorFormat_R16G16 = 0x010B081D20UL,
NvColorFormat_Float_R16G16 = 0x010B085D20UL,
NvColorFormat_R8 = 0x010B200408UL,
NvColorFormat_R16 = 0x010B200A10UL,
NvColorFormat_Float_R16 = 0x010B204A10UL,
NvColorFormat_A2B10G10R10_sRGB = 0x0200532020UL,
NvColorFormat_A8B8G8R8_sRGB = 0x0200532120UL,
NvColorFormat_A16B16G16R16_sRGB = 0x0200532740UL,
NvColorFormat_A2R10G10B10_sRGB = 0x0200D12020UL,
NvColorFormat_B10G10R10A2_sRGB = 0x02060A2320UL,
NvColorFormat_R10G10B10A2_sRGB = 0x0206882320UL,
NvColorFormat_X8B8G8R8_sRGB = 0x020A532120UL,
NvColorFormat_X16B16G16R16_sRGB = 0x020A532740UL,
NvColorFormat_A2B10G10R10_709 = 0x0300532020UL,
NvColorFormat_A8B8G8R8_709 = 0x0300532120UL,
NvColorFormat_A16B16G16R16_709 = 0x0300532740UL,
NvColorFormat_A2R10G10B10_709 = 0x0300D12020UL,
NvColorFormat_B10G10R10A2_709 = 0x03060A2320UL,
NvColorFormat_R10G10B10A2_709 = 0x0306882320UL,
NvColorFormat_X8B8G8R8_709 = 0x030A532120UL,
NvColorFormat_X16B16G16R16_709 = 0x030A532740UL,
NvColorFormat_A2B10G10R10_709_Linear = 0x0400532020UL,
NvColorFormat_A8B8G8R8_709_Linear = 0x0400532120UL,
NvColorFormat_A16B16G16R16_709_Linear = 0x0400532740UL,
NvColorFormat_A2R10G10B10_709_Linear = 0x0400D12020UL,
NvColorFormat_B10G10R10A2_709_Linear = 0x04060A2320UL,
NvColorFormat_R10G10B10A2_709_Linear = 0x0406882320UL,
NvColorFormat_X8B8G8R8_709_Linear = 0x040A532120UL,
NvColorFormat_X16B16G16R16_709_Linear = 0x040A532740UL,
NvColorFormat_Float_A16B16G16R16_scRGB_Linear = 0x0500536740UL,
NvColorFormat_A2B10G10R10_2020 = 0x0600532020UL,
NvColorFormat_A8B8G8R8_2020 = 0x0600532120UL,
NvColorFormat_A16B16G16R16_2020 = 0x0600532740UL,
NvColorFormat_A2R10G10B10_2020 = 0x0600D12020UL,
NvColorFormat_B10G10R10A2_2020 = 0x06060A2320UL,
NvColorFormat_R10G10B10A2_2020 = 0x0606882320UL,
NvColorFormat_X8B8G8R8_2020 = 0x060A532120UL,
NvColorFormat_X16B16G16R16_2020 = 0x060A532740UL,
NvColorFormat_A2B10G10R10_2020_Linear = 0x0700532020UL,
NvColorFormat_A8B8G8R8_2020_Linear = 0x0700532120UL,
NvColorFormat_A16B16G16R16_2020_Linear = 0x0700532740UL,
NvColorFormat_Float_A16B16G16R16_2020_Linear = 0x0700536740UL,
NvColorFormat_A2R10G10B10_2020_Linear = 0x0700D12020UL,
NvColorFormat_B10G10R10A2_2020_Linear = 0x07060A2320UL,
NvColorFormat_R10G10B10A2_2020_Linear = 0x0706882320UL,
NvColorFormat_X8B8G8R8_2020_Linear = 0x070A532120UL,
NvColorFormat_X16B16G16R16_2020_Linear = 0x070A532740UL,
NvColorFormat_Float_A16B16G16R16_2020_PQ = 0x0800536740UL,
NvColorFormat_A4I4 = 0x0901210508UL,
NvColorFormat_A8I8 = 0x0901210E10UL,
NvColorFormat_I4A4 = 0x0903200508UL,
NvColorFormat_I8A8 = 0x0903200E10UL,
NvColorFormat_I1 = 0x0909200101UL,
NvColorFormat_I2 = 0x0909200202UL,
NvColorFormat_I4 = 0x0909200304UL,
NvColorFormat_I8 = 0x0909200408UL,
NvColorFormat_A8Y8U8V8 = 0x0A00D12120UL,
NvColorFormat_A16Y16U16V16 = 0x0A00D12740UL,
NvColorFormat_Y8U8V8A8 = 0x0A06882120UL,
NvColorFormat_V8_U8 = 0x0A080C0710UL,
NvColorFormat_V8U8 = 0x0A080C0E10UL,
NvColorFormat_V10U10 = 0x0A08142220UL,
NvColorFormat_V12U12 = 0x0A08142420UL,
NvColorFormat_V8 = 0x0A08240408UL,
NvColorFormat_V10 = 0x0A08240F10UL,
NvColorFormat_V12 = 0x0A08241010UL,
NvColorFormat_U8_V8 = 0x0A08440710UL,
NvColorFormat_U8V8 = 0x0A08440E10UL,
NvColorFormat_U10V10 = 0x0A08842220UL,
NvColorFormat_U12V12 = 0x0A08842420UL,
NvColorFormat_U8 = 0x0A09040408UL,
NvColorFormat_U10 = 0x0A09040F10UL,
NvColorFormat_U12 = 0x0A09041010UL,
NvColorFormat_Y8 = 0x0A09200408UL,
NvColorFormat_Y10 = 0x0A09200F10UL,
NvColorFormat_Y12 = 0x0A09201010UL,
NvColorFormat_YVYU = 0x0A0A500810UL,
NvColorFormat_VYUY = 0x0A0A500910UL,
NvColorFormat_YUYV = 0x0A0A880810UL,
NvColorFormat_UYVY = 0x0A0A880910UL,
NvColorFormat_Y8_U8_V8 = 0x0A0A881918UL,
NvColorFormat_V8_U8_RR = 0x0B080C0710UL,
NvColorFormat_V8U8_RR = 0x0B080C0E10UL,
NvColorFormat_V8_RR = 0x0B08240408UL,
NvColorFormat_U8_V8_RR = 0x0B08440710UL,
NvColorFormat_U8V8_RR = 0x0B08440E10UL,
NvColorFormat_U8_RR = 0x0B09040408UL,
NvColorFormat_Y8_RR = 0x0B09200408UL,
NvColorFormat_V8_U8_ER = 0x0C080C0710UL,
NvColorFormat_V8U8_ER = 0x0C080C0E10UL,
NvColorFormat_V8_ER = 0x0C08240408UL,
NvColorFormat_U8_V8_ER = 0x0C08440710UL,
NvColorFormat_U8V8_ER = 0x0C08440E10UL,
NvColorFormat_U8_ER = 0x0C09040408UL,
NvColorFormat_Y8_ER = 0x0C09200408UL,
NvColorFormat_V8_U8_709 = 0x0D080C0710UL,
NvColorFormat_V8U8_709 = 0x0D080C0E10UL,
NvColorFormat_V10U10_709 = 0x0D08142220UL,
NvColorFormat_V12U12_709 = 0x0D08142420UL,
NvColorFormat_V8_709 = 0x0D08240408UL,
NvColorFormat_V10_709 = 0x0D08240F10UL,
NvColorFormat_V12_709 = 0x0D08241010UL,
NvColorFormat_U8_V8_709 = 0x0D08440710UL,
NvColorFormat_U8V8_709 = 0x0D08440E10UL,
NvColorFormat_U10V10_709 = 0x0D08842220UL,
NvColorFormat_U12V12_709 = 0x0D08842420UL,
NvColorFormat_U8_709 = 0x0D09040408UL,
NvColorFormat_U10_709 = 0x0D09040F10UL,
NvColorFormat_U12_709 = 0x0D09041010UL,
NvColorFormat_Y8_709 = 0x0D09200408UL,
NvColorFormat_Y10_709 = 0x0D09200F10UL,
NvColorFormat_Y12_709 = 0x0D09201010UL,
NvColorFormat_V8_U8_709_ER = 0x0E080C0710UL,
NvColorFormat_V8U8_709_ER = 0x0E080C0E10UL,
NvColorFormat_V10U10_709_ER = 0x0E08142220UL,
NvColorFormat_V12U12_709_ER = 0x0E08142420UL,
NvColorFormat_V8_709_ER = 0x0E08240408UL,
NvColorFormat_V10_709_ER = 0x0E08240F10UL,
NvColorFormat_V12_709_ER = 0x0E08241010UL,
NvColorFormat_U8_V8_709_ER = 0x0E08440710UL,
NvColorFormat_U8V8_709_ER = 0x0E08440E10UL,
NvColorFormat_U10V10_709_ER = 0x0E08842220UL,
NvColorFormat_U12V12_709_ER = 0x0E08842420UL,
NvColorFormat_U8_709_ER = 0x0E09040408UL,
NvColorFormat_U10_709_ER = 0x0E09040F10UL,
NvColorFormat_U12_709_ER = 0x0E09041010UL,
NvColorFormat_Y8_709_ER = 0x0E09200408UL,
NvColorFormat_Y10_709_ER = 0x0E09200F10UL,
NvColorFormat_Y12_709_ER = 0x0E09201010UL,
NvColorFormat_V10U10_2020 = 0x0F08142220UL,
NvColorFormat_V12U12_2020 = 0x0F08142420UL,
NvColorFormat_V10_2020 = 0x0F08240F10UL,
NvColorFormat_V12_2020 = 0x0F08241010UL,
NvColorFormat_U10V10_2020 = 0x0F08842220UL,
NvColorFormat_U12V12_2020 = 0x0F08842420UL,
NvColorFormat_U10_2020 = 0x0F09040F10UL,
NvColorFormat_U12_2020 = 0x0F09041010UL,
NvColorFormat_Y10_2020 = 0x0F09200F10UL,
NvColorFormat_Y12_2020 = 0x0F09201010UL,
NvColorFormat_Bayer8RGGB = 0x1009200408UL,
NvColorFormat_Bayer16RGGB = 0x1009200A10UL,
NvColorFormat_BayerS16RGGB = 0x1009208A10UL,
NvColorFormat_X2Bayer14RGGB = 0x1009210B10UL,
NvColorFormat_X4Bayer12RGGB = 0x1009210C10UL,
NvColorFormat_X6Bayer10RGGB = 0x1009210D10UL,
NvColorFormat_Bayer8BGGR = 0x1109200408UL,
NvColorFormat_Bayer16BGGR = 0x1109200A10UL,
NvColorFormat_BayerS16BGGR = 0x1109208A10UL,
NvColorFormat_X2Bayer14BGGR = 0x1109210B10UL,
NvColorFormat_X4Bayer12BGGR = 0x1109210C10UL,
NvColorFormat_X6Bayer10BGGR = 0x1109210D10UL,
NvColorFormat_Bayer8GRBG = 0x1209200408UL,
NvColorFormat_Bayer16GRBG = 0x1209200A10UL,
NvColorFormat_BayerS16GRBG = 0x1209208A10UL,
NvColorFormat_X2Bayer14GRBG = 0x1209210B10UL,
NvColorFormat_X4Bayer12GRBG = 0x1209210C10UL,
NvColorFormat_X6Bayer10GRBG = 0x1209210D10UL,
NvColorFormat_Bayer8GBRG = 0x1309200408UL,
NvColorFormat_Bayer16GBRG = 0x1309200A10UL,
NvColorFormat_BayerS16GBRG = 0x1309208A10UL,
NvColorFormat_X2Bayer14GBRG = 0x1309210B10UL,
NvColorFormat_X4Bayer12GBRG = 0x1309210C10UL,
NvColorFormat_X6Bayer10GBRG = 0x1309210D10UL,
NvColorFormat_XYZ = 0x140A886640UL,
} NvColorFormat;

View File

@ -14,22 +14,65 @@
#define R_MODULE(res) ((res)&0x1FF)
/// Returns the description of a result code.
#define R_DESCRIPTION(res) (((res)>>9)&0x1FFF)
/// Masks out unused bits in a result code, retrieving the actual value for use in comparisons.
#define R_VALUE(res) ((res)&0x3FFFFF)
/// Builds a result code from its constituent components.
#define MAKERESULT(module,description) \
((((module)&0x1FF)) | ((description)&0x1FFF)<<9)
/// Builds a kernel error result code.
#define KERNELRESULT(description) \
MAKERESULT(Module_Kernel, KernelError_##description)
/// Module values
enum {
Module_Kernel=1,
Module_Libnx=345,
Module_LibnxBinder=347,
Module_HomebrewAbi=346,
Module_HomebrewLoader=347,
Module_LibnxNvidia=348,
Module_LibnxBinder=349,
};
/// Kernel error codes
enum {
KernelError_Timeout=117,
KernelError_OutOfSessions=7,
KernelError_InvalidCapabilityDescriptor=14,
KernelError_NotImplemented=33,
KernelError_ThreadTerminating=59,
KernelError_OutOfDebugEvents=70,
KernelError_InvalidSize=101,
KernelError_InvalidAddress=102,
KernelError_ResourceExhausted=103,
KernelError_OutOfMemory=104,
KernelError_OutOfHandles=105,
KernelError_InvalidMemoryState=106,
KernelError_InvalidMemoryPermissions=108,
KernelError_InvalidMemoryRange=110,
KernelError_InvalidPriority=112,
KernelError_InvalidCoreId=113,
KernelError_InvalidHandle=114,
KernelError_InvalidUserBuffer=115,
KernelError_InvalidCombination=116,
KernelError_TimedOut=117,
KernelError_Cancelled=118,
KernelError_OutOfRange=119,
KernelError_InvalidEnumValue=120,
KernelError_NotFound=121,
KernelError_AlreadyExists=122,
KernelError_ConnectionClosed=123,
KernelError_UnhandledUserInterrupt=124,
KernelError_InvalidState=125,
KernelError_ReservedValue=126,
KernelError_InvalidHwBreakpoint=127,
KernelError_FatalUserException=128,
KernelError_OwnedByAnotherProcess=129,
KernelError_ConnectionRefused=131,
KernelError_OutOfResource=132,
KernelError_IpcMapFailed=259,
KernelError_IpcCmdbufTooSmall=260,
KernelError_NotDebugged=520,
};
/// libnx error codes
@ -79,6 +122,10 @@ enum {
LibnxError_ApmFailedToInitialize,
LibnxError_NvinfoFailedToInitialize,
LibnxError_NvbufFailedToInitialize,
LibnxError_LibAppletBadExit,
LibnxError_InvalidCmifOutHeader,
LibnxError_ShouldNotHappen,
LibnxError_Timeout,
};
/// libnx binder error codes

View File

@ -0,0 +1,445 @@
/**
* @file btdev.h
* @brief Wrapper around the bt/btmu services for using bluetooth BLE.
* @note Only available on [5.0.0+].
* @note See also: https://switchbrew.org/wiki/BTM_services
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../kernel/event.h"
#include "../services/btdrv_types.h"
/// GattAttribute
typedef struct {
u8 type; ///< Type
BtdrvGattAttributeUuid uuid; ///< \ref BtdrvGattAttributeUuid
u16 handle; ///< Handle
u32 connection_handle; ///< ConnectionHandle
} BtdevGattAttribute;
/// GattService
typedef struct {
BtdevGattAttribute attr; ///< \ref BtdevGattAttribute
u16 instance_id; ///< InstanceId
u16 end_group_handle; ///< EndGroupHandle
bool primary_service; ///< PrimaryService
} BtdevGattService;
/// GattCharacteristic
typedef struct {
BtdevGattAttribute attr; ///< \ref BtdevGattAttribute
u16 instance_id; ///< InstanceId
u8 properties; ///< Properties
u64 value_size; ///< Size of value.
u8 value[0x200]; ///< Value
} BtdevGattCharacteristic;
/// GattDescriptor
typedef struct {
BtdevGattAttribute attr; ///< \ref BtdevGattAttribute
u64 value_size; ///< Size of value.
u8 value[0x200]; ///< Value
} BtdevGattDescriptor;
/// Initialize bt/btmu.
Result btdevInitialize(void);
/// Exit bt/btmu.
void btdevExit(void);
/// Compares two \ref BtdrvGattAttributeUuid, returning whether these match.
bool btdevGattAttributeUuidIsSame(const BtdrvGattAttributeUuid *a, const BtdrvGattAttributeUuid *b);
/// Wrapper for \ref btmuAcquireBleScanEvent.
Result btdevAcquireBleScanEvent(Event* out_event);
/// Wrapper for \ref btmuGetBleScanFilterParameter.
Result btdevGetBleScanParameter(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out);
/// Wrapper for \ref btmuGetBleScanFilterParameter2.
Result btdevGetBleScanParameter2(u16 parameter_id, BtdrvGattAttributeUuid *out);
/// Wrapper for \ref btdevStartBleScanGeneral.
Result btdevStartBleScanGeneral(BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuStopBleScanForGeneral.
Result btdevStopBleScanGeneral(void);
/**
* @brief Wrapper for \ref btmuGetBleScanResultsForGeneral and \ref btmuGetBleScanResultsForSmartDevice.
* @param[out] results Output array of \ref BtdrvBleScanResult.
* @param[in] count Size of the results array in entries.
* @param[out] total_out Total output entries.
*/
Result btdevGetBleScanResult(BtdrvBleScanResult *results, u8 count, u8 *total_out);
/// Wrapper for \ref btmuStartBleScanForPaired.
Result btdevEnableBleAutoConnection(BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuStopBleScanForPaired.
Result btdevDisableBleAutoConnection(void);
/// Wrapper for \ref btmuStartBleScanForSmartDevice.
Result btdevStartBleScanSmartDevice(const BtdrvGattAttributeUuid *uuid);
/// Wrapper for \ref btmuStopBleScanForSmartDevice.
Result btdevStopBleScanSmartDevice(void);
/// Wrapper for \ref btmuAcquireBleConnectionEvent.
Result btdevAcquireBleConnectionStateChangedEvent(Event* out_event);
/// Wrapper for \ref btmuBleConnect.
Result btdevConnectToGattServer(BtdrvAddress addr);
/// Wrapper for \ref btmuBleDisconnect.
Result btdevDisconnectFromGattServer(u32 connection_handle);
/// Wrapper for \ref btmuBleGetConnectionState.
Result btdevGetBleConnectionInfoList(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out);
/// Wrapper for \ref btmuAcquireBleServiceDiscoveryEvent.
Result btdevAcquireBleServiceDiscoveryEvent(Event* out_event);
/**
* @brief Wrapper for \ref btmuGetGattServices.
* @param[in] connection_handle ConnectionHandle
* @param[out] services Output array of \ref BtdevGattService.
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGetGattServices(u32 connection_handle, BtdevGattService *services, u8 count, u8 *total_out);
/**
* @brief Wrapper for \ref btmuGetGattService.
* @param[in] connection_handle ConnectionHandle
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] service \ref BtdevGattService
* @param[out] flag Whether a \ref BtdevGattService was returned.
*/
Result btdevGetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtdevGattService *service, bool *flag);
/// Wrapper for \ref btmuAcquireBlePairingEvent.
Result btdevAcquireBlePairingEvent(Event* out_event);
/// Wrapper for \ref btmuBlePairDevice.
Result btdevPairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuBleUnPairDevice.
Result btdevUnpairGattServer(u32 connection_handle, BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuBleUnPairDevice2.
Result btdevUnpairGattServer2(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param);
/// Wrapper for \ref btmuBleGetPairedDevices.
Result btdevGetPairedGattServerAddress(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out);
/// Wrapper for \ref btmuAcquireBleMtuConfigEvent.
Result btdevAcquireBleMtuConfigEvent(Event* out_event);
/**
* @brief Wrapper for \ref btmuConfigureBleMtu.
* @param[in] connection_handle Same as \ref btmuBleDisconnect.
* @param[in] mtu MTU, must be 0x18-0x200.
*/
Result btdevConfigureBleMtu(u32 connection_handle, u16 mtu);
/// Wrapper for \ref btmuGetBleMtu.
Result btdevGetBleMtu(u32 connection_handle, u16 *out);
/// Wrapper for \ref btRegisterBleEvent.
Result btdevAcquireBleGattOperationEvent(Event* out_event);
/**
* @brief Wrapper for \ref btmuRegisterBleGattDataPath.
* @param[in] uuid \ref BtdrvGattAttributeUuid
*/
Result btdevRegisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid);
/**
* @brief Wrapper for \ref btmuUnregisterBleGattDataPath.
* @param[in] uuid \ref BtdrvGattAttributeUuid
*/
Result btdevUnregisterGattOperationNotification(const BtdrvGattAttributeUuid *uuid);
/**
* @brief Wrapper for \ref btGetLeEventInfo.
* @param[out] out \ref BtdrvBleClientGattOperationInfo
*/
Result btdevGetGattOperationResult(BtdrvBleClientGattOperationInfo *out);
/**
* @brief Wrapper for \ref btLeClientReadCharacteristic.
* @note An error is thrown if the properties from \ref btdevGattCharacteristicGetProperties don't allow using this.
* @param c \ref BtdevGattCharacteristic
*/
Result btdevReadGattCharacteristic(BtdevGattCharacteristic *c);
/**
* @brief Wrapper for \ref btLeClientWriteCharacteristic.
* @note An error is thrown if the properties from \ref btdevGattCharacteristicGetProperties don't allow using this.
* @note This uses the Value from \ref btdevGattCharacteristicSetValue.
* @param c \ref BtdevGattCharacteristic
*/
Result btdevWriteGattCharacteristic(BtdevGattCharacteristic *c);
/**
* @brief Wrapper for \ref btLeClientRegisterNotification / \ref btLeClientDeregisterNotification.
* @note An error is thrown if the properties from \ref btdevGattCharacteristicGetProperties don't allow using this.
* @param c \ref BtdevGattCharacteristic
* @param[in] flag Whether to enable/disable, controls which func to call.
*/
Result btdevEnableGattCharacteristicNotification(BtdevGattCharacteristic *c, bool flag);
/**
* @brief Wrapper for \ref btLeClientReadDescriptor.
* @param d \ref BtdevGattDescriptor
*/
Result btdevReadGattDescriptor(BtdevGattDescriptor *d);
/**
* @brief Wrapper for \ref btLeClientWriteDescriptor.
* @note This uses the Value from \ref btdevGattDescriptorSetValue.
* @param d \ref BtdevGattDescriptor
*/
Result btdevWriteGattDescriptor(BtdevGattDescriptor *d);
///@name GattAttribute
///@{
/**
* @brief Creates a \ref BtdevGattAttribute object. This is intended for internal use.
* @param a \ref BtdevGattAttribute
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
*/
void btdevGattAttributeCreate(BtdevGattAttribute *a, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle);
/**
* @brief Gets the Type.
* @param a \ref BtdevGattAttribute
*/
NX_CONSTEXPR u8 btdevGattAttributeGetType(BtdevGattAttribute *a) {
return a->type;
}
/**
* @brief Gets the Uuid.
* @param a \ref BtdevGattAttribute
* @param[out] out \ref BtdrvGattAttributeUuid
*/
NX_CONSTEXPR void btdevGattAttributeGetUuid(BtdevGattAttribute *a, BtdrvGattAttributeUuid *out) {
*out = a->uuid;
}
/**
* @brief Gets the Handle.
* @param a \ref BtdevGattAttribute
*/
NX_CONSTEXPR u16 btdevGattAttributeGetHandle(BtdevGattAttribute *a) {
return a->handle;
}
/**
* @brief Gets the ConnectionHandle.
* @param a \ref BtdevGattAttribute
*/
NX_CONSTEXPR u32 btdevGattAttributeGetConnectionHandle(BtdevGattAttribute *a) {
return a->connection_handle;
}
///@}
///@name GattService
///@{
/**
* @brief Creates a \ref BtdevGattService object. This is intended for internal use.
* @param s \ref BtdevGattService
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
* @param[in] instance_id InstanceId
* @param[in] end_group_handle EndGroupHandle
* @param[in] primary_service PrimaryService
*/
void btdevGattServiceCreate(BtdevGattService *s, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle, u16 instance_id, u16 end_group_handle, bool primary_service);
/**
* @brief Gets the InstanceId.
* @param s \ref BtdevGattService
*/
NX_CONSTEXPR u16 btdevGattServiceGetInstanceId(BtdevGattService *s) {
return s->instance_id;
}
/**
* @brief Gets the EndGroupHandle.
* @param s \ref BtdevGattService
*/
NX_CONSTEXPR u16 btdevGattServiceGetEndGroupHandle(BtdevGattService *s) {
return s->end_group_handle;
}
/**
* @brief Gets whether this is the PrimaryService.
* @param s \ref BtdevGattService
*/
NX_CONSTEXPR u16 btdevGattServiceIsPrimaryService(BtdevGattService *s) {
return s->primary_service;
}
/**
* @brief Wrapper for \ref btmuGetGattIncludedServices.
* @param s \ref BtdevGattService
* @param[out] services Output array of \ref BtdevGattService.
* @param[in] count Size of the services array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGattServiceGetIncludedServices(BtdevGattService *s, BtdevGattService *services, u8 count, u8 *total_out);
/**
* @brief Wrapper for \ref btmuGetGattCharacteristics.
* @param s \ref BtdevGattService
* @param[out] characteristics Output array of \ref BtdevGattCharacteristic.
* @param[in] count Size of the characteristics array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGattServiceGetCharacteristics(BtdevGattService *s, BtdevGattCharacteristic *characteristics, u8 count, u8 *total_out);
/**
* @brief Same as \ref btdevGattServiceGetCharacteristics except this only returns the \ref BtdevGattCharacteristic which contains a matching \ref BtdrvGattAttributeUuid.
* @param s \ref BtdevGattService
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] characteristic \ref BtdevGattCharacteristic
* @param[out] flag Whether a \ref BtdevGattService was returned.
*/
Result btdevGattServiceGetCharacteristic(BtdevGattService *s, const BtdrvGattAttributeUuid *uuid, BtdevGattCharacteristic *characteristic, bool *flag);
///@}
///@name GattCharacteristic
///@{
/**
* @brief Creates a \ref BtdevGattCharacteristic object. This is intended for internal use.
* @param c \ref BtdevGattCharacteristic
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
* @param[in] instance_id InstanceId
* @param[in] properties Properties
*/
void btdevGattCharacteristicCreate(BtdevGattCharacteristic *c, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle, u16 instance_id, u8 properties);
/**
* @brief Gets the InstanceId.
* @param c \ref BtdevGattCharacteristic
*/
NX_CONSTEXPR u16 btdevGattCharacteristicGetInstanceId(BtdevGattCharacteristic *c) {
return c->instance_id;
}
/**
* @brief Gets the Properties.
* @param c \ref BtdevGattCharacteristic
*/
NX_CONSTEXPR u8 btdevGattCharacteristicGetProperties(BtdevGattCharacteristic *c) {
return c->properties;
}
/**
* @brief Wrapper for \ref btmuGetBelongingGattService.
* @note Gets the \ref BtdevGattService which belongs to this object.
* @param c \ref BtdevGattCharacteristic.
* @param[out] service \ref BtdevGattService
*/
Result btdevGattCharacteristicGetService(BtdevGattCharacteristic *c, BtdevGattService *service);
/**
* @brief Wrapper for \ref btmuGetGattDescriptors.
* @note Gets the descriptors which belongs to this object.
* @param c \ref BtdevGattCharacteristic
* @param[out] descriptors Output array of \ref BtdevGattDescriptor.
* @param[in] count Size of the descriptors array in entries. The max is 100.
* @param[out] total_out Total output entries.
*/
Result btdevGattCharacteristicGetDescriptors(BtdevGattCharacteristic *c, BtdevGattDescriptor *descriptors, u8 count, u8 *total_out);
/**
* @brief Same as \ref btdevGattCharacteristicGetDescriptors except this only returns a \ref BtdevGattDescriptor which contains a matching \ref BtdrvGattAttributeUuid.
* @param c \ref BtdevGattCharacteristic
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[out] descriptor \ref BtdevGattDescriptor
* @param[out] flag Whether a \ref BtdevGattDescriptor was returned.
*/
Result btdevGattCharacteristicGetDescriptor(BtdevGattCharacteristic *c, const BtdrvGattAttributeUuid *uuid, BtdevGattDescriptor *descriptor, bool *flag);
/**
* @brief Sets the Value in the object.
* @note See also \ref btdevWriteGattCharacteristic.
* @param c \ref BtdevGattCharacteristic
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, max is 0x200.
*/
void btdevGattCharacteristicSetValue(BtdevGattCharacteristic *c, const void* buffer, size_t size);
/**
* @brief Gets the Value in the object, returns the copied value size.
* @param c \ref BtdevGattCharacteristic
* @param[out] buffer Output buffer.
* @param[in] size Output buffer size, max is 0x200.
*/
u64 btdevGattCharacteristicGetValue(BtdevGattCharacteristic *c, void* buffer, size_t size);
///@}
///@name GattDescriptor
///@{
/**
* @brief Creates a \ref BtdevGattDescriptor object. This is intended for internal use.
* @param d \ref BtdevGattDescriptor
* @param[in] uuid \ref BtdrvGattAttributeUuid
* @param[in] handle Handle
* @param[in] connection_handle ConnectionHandle
*/
void btdevGattDescriptorCreate(BtdevGattDescriptor *d, const BtdrvGattAttributeUuid *uuid, u16 handle, u32 connection_handle);
/**
* @brief Wrapper for \ref btmuGetBelongingGattService.
* @note Gets the \ref BtdevGattService which belongs to this object.
* @param d \ref BtdevGattDescriptor
* @param[out] service \ref BtdevGattService
*/
Result btdevGattDescriptorGetService(BtdevGattDescriptor *d, BtdevGattService *service);
/**
* @brief Wrapper for \ref btmuGetGattCharacteristics.
* @note Gets the \ref BtdevGattCharacteristic which belongs to this object.
* @param d \ref BtdevGattDescriptor
* @param[out] characteristic \ref BtdevGattCharacteristic
*/
Result btdevGattDescriptorGetCharacteristic(BtdevGattDescriptor *d, BtdevGattCharacteristic *characteristic);
/**
* @brief Sets the Value in the object.
* @note See also \ref btdevWriteGattDescriptor.
* @param d \ref BtdevGattDescriptor
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size, max is 0x200.
*/
void btdevGattDescriptorSetValue(BtdevGattDescriptor *d, const void* buffer, size_t size);
/**
* @brief Gets the Value in the object, returns the copied value size.
* @param d \ref BtdevGattDescriptor
* @param[out] buffer Output buffer.
* @param[in] size Output buffer size, max is 0x200.
*/
u64 btdevGattDescriptorGetValue(BtdevGattDescriptor *d, void* buffer, size_t size);
///@}

View File

@ -10,12 +10,9 @@
*
* General usage is to initialize the console by:
* @code
* consoleDemoInit()
* @endcode
* or to customize the console usage by:
* @code
* consoleInit()
* consoleInit(NULL)
* @endcode
* optionally customizing the console usage by passing a pointer to a custom PrintConsole struct.
*/
#pragma once
#include "../../types.h"
@ -31,15 +28,27 @@
#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);
// Forward declaration
typedef struct PrintConsole PrintConsole;
/// Renderer interface for the console.
typedef struct ConsoleRenderer
{
bool (*init)(PrintConsole* con);
void (*deinit)(PrintConsole* con);
void (*drawChar)(PrintConsole* con, int x, int y, int c);
void (*scrollWindow)(PrintConsole* con);
void (*flushAndSwap)(PrintConsole* con);
} ConsoleRenderer;
/// A font struct for the console.
typedef struct ConsoleFont
{
u16* gfx; ///< A pointer to the font graphics
const void* 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
u16 tileWidth;
u16 tileHeight;
}ConsoleFont;
/**
@ -51,10 +60,13 @@ typedef struct ConsoleFont
* {
* //Font:
* {
* (u16*)default_font_bin, //font gfx
* default_font_bin, //font gfx
* 0, //first ascii character in the set
* 128, //number of characters in the font set
* 256, //number of characters in the font set
* 16, //tile width
* 16, //tile height
* },
* NULL, //renderer
* 0,0, //cursorX cursorY
* 0,0, //prevcursorX prevcursorY
* 80, //console width
@ -64,18 +76,17 @@ typedef struct ConsoleFont
* 80, //window width
* 45, //window height
* 3, //tab size
* 0, //font character offset
* 0, //print callback
* 7, // foreground color
* 0, // background color
* 0, // flags
* false //console initialized
* };
* @endcode
*/
typedef struct PrintConsole
struct PrintConsole
{
ConsoleFont font; ///< Font of the console
u32 *frameBuffer; ///< Framebuffer address
u32 *frameBuffer2; ///< Framebuffer address
ConsoleRenderer* renderer; ///< Renderer of the console
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)
@ -86,20 +97,18 @@ typedef struct PrintConsole
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 windowX; ///< Window X location in characters
int windowY; ///< Window Y location in characters
int windowWidth; ///< Window width in characters
int windowHeight; ///< Window height in characters
int tabSize; ///< Size of a tab
int fg; ///< Foreground color
int bg; ///< Background color
u16 fg; ///< Foreground color
u16 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
@ -110,13 +119,14 @@ typedef struct PrintConsole
#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
#define CONSOLE_FG_CUSTOM (1<<9) ///< Foreground custom color
#define CONSOLE_BG_CUSTOM (1<<10) ///< Background custom color
/// 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;
/**
@ -157,11 +167,24 @@ PrintConsole *consoleSelect(PrintConsole* console);
*/
PrintConsole* consoleInit(PrintConsole* console);
/**
* @brief Deinitialise the console.
* @param console A pointer to the console data to initialize (if it's NULL, the default console will be used).
*/
void consoleExit(PrintConsole* console);
/**
* @brief Updates the console, submitting a new frame to the display.
* @param console A pointer to the console data to initialize (if it's NULL, the default console will be used).
* @remark This function should be called periodically. Failure to call this function will result in lack of screen updating.
*/
void consoleUpdate(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");
/// Clears the screan by using printf("\x1b[2J");
void consoleClear(void);

View File

@ -19,14 +19,48 @@ typedef struct
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.
/// Retrieves a pointer to temporary stage for reading entries
NX_CONSTEXPR FsDirectoryEntry* fsdevDirGetEntries(fsdev_dir_t *dir)
{
return (FsDirectoryEntry*)(void*)(dir+1);
}
/// Initializes and mounts the sdmc device if accessible.
Result fsdevMountSdmc(void);
/// Mounts the specified SaveData.
Result fsdevMountSaveData(const char *name, u64 application_id, AccountUid uid);
/// Mounts the specified SaveData as ReadOnly.
/// Only available on [2.0.0+].
Result fsdevMountSaveDataReadOnly(const char *name, u64 application_id, AccountUid uid);
/// Mounts the specified BcatSaveData.
Result fsdevMountBcatSaveData(const char *name, u64 application_id);
/// Mounts the specified DeviceSaveData.
Result fsdevMountDeviceSaveData(const char *name, u64 application_id);
/// Mounts the TemporaryStorage for the current process.
/// Only available on [3.0.0+].
Result fsdevMountTemporaryStorage(const char *name);
/// Mounts the specified CacheStorage.
/// Only available on [3.0.0+].
Result fsdevMountCacheStorage(const char *name, u64 application_id, u16 save_data_index);
/// Mounts the specified SystemSaveData.
Result fsdevMountSystemSaveData(const char *name, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid);
/// Mounts the specified SystemBcatSaveData.
/// Only available on [4.0.0+].
Result fsdevMountSystemBcatSaveData(const char *name, u64 system_save_data_id);
/// 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.
/// Input device name string shouldn't exceed 31 characters, and shouldn't have a trailing colon.
int fsdevMountDevice(const char *name, FsFileSystem fs);
/// Unmounts the specified device.
@ -36,8 +70,26 @@ int fsdevUnmountDevice(const char *name);
/// 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);
/// Returns the FsFileSystem for the specified device. Returns NULL when the specified device isn't found.
FsFileSystem* fsdevGetDeviceFileSystem(const char *name);
/// Writes the FS-path to outpath (which has buffer size FS_MAX_PATH), for the input path (as used in stdio). The FsFileSystem is also written to device when not NULL.
int fsdevTranslatePath(const char *path, FsFileSystem** device, char *outpath);
/// This calls fsFsSetConcatenationFileAttribute on the filesystem specified by the input path (as used in stdio).
Result fsdevSetConcatenationFileAttribute(const char *path);
// Uses \ref fsFsIsValidSignedSystemPartitionOnSdCard with the specified device.
Result fsdevIsValidSignedSystemPartitionOnSdCard(const char *name, bool *out);
/// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio).
Result fsdevCreateFile(const char* path, size_t size, u32 flags);
/// Recursively deletes the directory specified by the input path (as used in stdio).
Result fsdevDeleteDirectoryRecursively(const char *path);
/// Unmounts all devices and cleans up any resources used by the FS driver.
Result fsdevUnmountAll(void);
/// Retrieves the last native result code generated during a failed fsdev operation.
Result fsdevGetLastResult(void);

View File

@ -10,6 +10,7 @@
#include "../../types.h"
#include "../../services/fs.h"
#include "../../services/ncm_types.h"
/// RomFS header.
typedef struct
@ -50,49 +51,72 @@ typedef struct
uint8_t name[]; ///< Name. (UTF-8)
} romfs_file;
struct romfs_mount;
/**
* @brief Mounts the Application's RomFS.
* @param mount Output mount handle
* @param name Device mount name.
* @remark This function is intended to be used to access one's own RomFS.
* If the application is running as NRO, it mounts the embedded RomFS section inside the NRO.
* If on the other hand it's an NSO, it behaves identically to \ref romfsMountFromCurrentProcess.
*/
Result romfsMount(struct romfs_mount **mount);
static inline Result romfsInit(void)
{
return romfsMount(NULL);
}
Result romfsMountSelf(const char *name);
/**
* @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
* @param name Device mount name.
*/
Result romfsMountFromFile(FsFile file, u64 offset, struct romfs_mount **mount);
static inline Result romfsInitFromFile(FsFile file, u64 offset)
{
return romfsMountFromFile(file, offset, NULL);
}
Result romfsMountFromFile(FsFile file, u64 offset, const char *name);
/**
* @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
* @param name Device mount name.
*/
Result romfsMountFromStorage(FsStorage storage, u64 offset, struct romfs_mount **mount);
static inline Result romfsInitFromStorage(FsStorage storage, u64 offset)
{
return romfsMountFromStorage(storage, offset, NULL);
}
Result romfsMountFromStorage(FsStorage storage, u64 offset, const char *name);
/// Bind the RomFS mount
Result romfsBind(struct romfs_mount *mount);
/**
* @brief Mounts RomFS using the current process host program RomFS.
* @param name Device mount name.
*/
Result romfsMountFromCurrentProcess(const char *name);
/**
* @brief Mounts RomFS of a running program.
* @note Permission needs to be set in the NPDM.
* @param program_id ProgramId to mount.
* @param name Device mount name.
*/
Result romfsMountDataStorageFromProgram(u64 program_id, const char *name);
/**
* @brief Mounts RomFS from a file path in a mounted fsdev device.
* @param path File path.
* @param offset Offset of the RomFS within the file.
* @param name Device mount name.
*/
Result romfsMountFromFsdev(const char *path, u64 offset, const char *name);
/**
* @brief Mounts RomFS from SystemData.
* @param dataId SystemDataId to mount.
* @param storageId Storage ID to mount from.
* @param name Device mount name.
*/
Result romfsMountFromDataArchive(u64 dataId, NcmStorageId storageId, const char *name);
/// Unmounts the RomFS device.
Result romfsUnmount(struct romfs_mount *mount);
static inline Result romfsExit(void)
Result romfsUnmount(const char *name);
/// Wrapper for \ref romfsMountSelf with the default "romfs" device name.
static inline Result romfsInit(void)
{
return romfsUnmount(NULL);
return romfsMountSelf("romfs");
}
/// Wrapper for \ref romfsUnmount with the default "romfs" device name.
static inline Result romfsExit(void)
{
return romfsUnmount("romfs");
}

View File

@ -1,12 +1,17 @@
#pragma once
#include "../../types.h"
/// BSD service type used by the socket driver.
typedef enum {
BsdServiceType_User = BIT(0), ///< Uses bsd:u (default).
BsdServiceType_System = BIT(1), ///< Uses bsd:s.
BsdServiceType_Auto = BsdServiceType_User | BsdServiceType_System, ///< Tries to use bsd:s first, and if that fails uses bsd:u (official software behavior).
} BsdServiceType;
/// 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_rx_buf_size; ///< Size of the TCP receive 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.
@ -15,10 +20,8 @@ typedef struct {
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.
u32 num_bsd_sessions; ///< Number of BSD service sessions (typically 3).
BsdServiceType bsd_service_type; ///< BSD service type (typically \ref BsdServiceType_User).
} SocketInitConfig;
/// Fetch the default configuration for the socket driver.
@ -26,14 +29,30 @@ 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);
Result socketGetLastResult(void);
/// Deinitialize the socket driver.
void socketExit(void);
/// Initalize the socket driver using the default configuration.
static inline Result socketInitializeDefault(void) {
return socketInitialize(socketGetDefaultInitConfig());
NX_INLINE Result socketInitializeDefault(void) {
return socketInitialize(NULL);
}
/// Wrapper for \ref sslConnectionSetSocketDescriptor. Returns the output sockfd on success and -1 on error. errno==ENOENT indicates that no sockfd was returned, this error must be ignored.
int socketSslConnectionSetSocketDescriptor(SslConnection *c, int sockfd);
/// Wrapper for \ref sslConnectionGetSocketDescriptor. Returns the output sockfd on success and -1 on error.
int socketSslConnectionGetSocketDescriptor(SslConnection *c);
#ifdef _SOCKLEN_T_DECLARED
struct sockaddr;
/// Wrapper for \ref sslConnectionSetDtlsSocketDescriptor. Returns the output sockfd on success and -1 on error. errno==ENOENT indicates that no sockfd was returned, this error must be ignored.
int socketSslConnectionSetDtlsSocketDescriptor(SslConnection *c, int sockfd, const struct sockaddr *addr, socklen_t addrlen);
#endif
/// Wrapper for \ref nifmRequestRegisterSocketDescriptor. Returns 0 on success and -1 on error.
int socketNifmRequestRegisterSocketDescriptor(NifmRequest* r, int sockfd);
/// Wrapper for \ref nifmRequestUnregisterSocketDescriptor. Returns 0 on success and -1 on error.
int socketNifmRequestUnregisterSocketDescriptor(NifmRequest* r, int sockfd);

View File

@ -8,15 +8,26 @@
#pragma once
#include "../../types.h"
typedef struct {
u8 bInterfaceClass;
u8 bInterfaceSubClass;
u8 bInterfaceProtocol;
} UsbCommsInterfaceInfo;
/// Initializes usbComms with the default number of interfaces (1)
Result usbCommsInitialize(void);
/// Initializes usbComms with a specific number of interfaces.
Result usbCommsInitializeEx(u32 num_interfaces, const UsbCommsInterfaceInfo *infos, u16 idVendor, u16 idProduct);
/// Exits usbComms.
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);
/// Sets whether to throw a fatal error in usbComms{Read/Write}* on failure, or just return the transferred size. By default (false) the latter is used.
void usbCommsSetErrorHandling(bool flag);
/// Shutdown the specified interface. If no interfaces are remaining, this then uses \ref usbCommsExit internally.
void usbCommsExitEx(u32 interface);
///@name Synchronous API
///@{
/// Read data with the default interface.
size_t usbCommsRead(void* buffer, size_t size);
@ -29,3 +40,31 @@ 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);
///@}
///@name Asynchronous API
///@{
/// Retrieve event used for read completion with the given interface.
Event *usbCommsGetReadCompletionEvent(u32 interface);
/// Start an asynchronous read. The completion event will be signaled when the read completes.
/// The buffer must be page-aligned and no larger than one page.
Result usbCommsReadAsync(void *buffer, size_t size, u32 *urbId, u32 interface);
/// Complete an asynchronous read, clearing the completion event, and return the amount of data which was read.
Result usbCommsGetReadResult(u32 urbId, u32 *transferredSize, u32 interface);
/// Retrieve event used for write completion with the given interface.
Event *usbCommsGetWriteCompletionEvent(u32 interface);
/// Start an asynchronous write. The completion event will be signaled when the write completes.
/// The buffer must be page-aligned and no larger than one page.
Result usbCommsWriteAsync(void *buffer, size_t size, u32 *urbId, u32 interface);
/// Complete an asynchronous write, clearing the completion event, and return the amount of data which was written.
Result usbCommsGetWriteResult(u32 urbId, u32 *transferredSize, u32 interface);
///@}

View File

@ -0,0 +1,15 @@
/**
* @file diag.h
* @brief Debugging and diagnostics utilities
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
/**
* @brief Aborts program execution with a result code.
* @param[in] res Result code.
*/
void NX_NORETURN diagAbortWithResult(Result res);

View File

@ -6,6 +6,7 @@
*/
#pragma once
#include "../types.h"
#include "../services/acc.h"
/// Structure representing an entry in the homebrew environment configuration.
typedef struct {
@ -27,16 +28,24 @@ enum {
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_SyscallAvailableHint=6, ///< Provides syscall availability hints (SVCs 0x00..0x7F).
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_Reserved9=9, ///< Unused/reserved entry type, formerly used by StdioSockets.
EntryType_ProcessHandle=10, ///< Provides the process handle.
EntryType_LastLoadResult=11 ///< Provides the last load result.
EntryType_LastLoadResult=11, ///< Provides the last load result.
EntryType_RandomSeed=14, ///< Provides random data used to seed the pseudo-random number generator.
EntryType_UserIdStorage=15, ///< Provides persistent storage for the preselected user id.
EntryType_HosVersion=16, ///< Provides the currently running Horizon OS version.
EntryType_SyscallAvailableHint2=17, ///< Provides syscall availability hints (SVCs 0x80..0xBF).
};
enum {
EnvAppletFlags_ApplicationOverride = BIT(0) ///< Use AppletType_Application instead of AppletType_SystemApplication.
};
/// Loader return function.
typedef void NORETURN (*LoaderReturnFn)(int result_code);
typedef void NX_NORETURN (*LoaderReturnFn)(int result_code);
/**
* @brief Parses the homebrew loader environment block (internally called).
@ -46,6 +55,11 @@ typedef void NORETURN (*LoaderReturnFn)(int result_code);
*/
void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr);
/// Returns information text about the loader, if present.
const char* envGetLoaderInfo(void);
/// Returns the size of the loader information text.
u64 envGetLoaderInfoSize(void);
/// Retrieves the handle to the main thread.
Handle envGetMainThreadHandle(void);
/// Returns true if the application is running as NSO, otherwise NRO.
@ -68,7 +82,7 @@ void* envGetArgv(void);
* @param svc Syscall number to test.
* @returns true if the syscall is available.
*/
bool envIsSyscallHinted(u8 svc);
bool envIsSyscallHinted(unsigned svc);
/// Returns the handle to the running homebrew process.
Handle envGetOwnProcessHandle(void);
@ -76,6 +90,9 @@ Handle envGetOwnProcessHandle(void);
/// Returns the loader's return function, to be called on program exit.
LoaderReturnFn envGetExitFuncPtr(void);
/// Sets the return function to be called on program exit.
void envSetExitFuncPtr(LoaderReturnFn addr);
/**
* @brief Configures the next homebrew application to load.
* @param path Path to the next homebrew application to load (.nro).
@ -88,3 +105,15 @@ bool envHasNextLoad(void);
/// Returns the Result from the last NRO.
Result envGetLastLoadResult(void);
/// Returns true if the environment provides a random seed.
bool envHasRandomSeed(void);
/**
* @brief Retrieves the random seed provided by the environment.
* @param out Pointer to a u64[2] buffer which will contain the random seed on return.
*/
void envGetRandomSeed(u64 out[2]);
/// Returns a pointer to the user id storage area (if present).
AccountUid* envGetUserIdStorage(void);

View File

@ -0,0 +1,45 @@
/**
* @file hosversion.h
* @brief Horizon OS (HOS) version detection utilities.
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// Builds a HOS version value from its constituent components.
#define MAKEHOSVERSION(_major,_minor,_micro) (((u32)(_major) << 16) | ((u32)(_minor) << 8) | (u32)(_micro))
/// Extracts the major number from a HOS version value.
#define HOSVER_MAJOR(_version) (((_version) >> 16) & 0xFF)
/// Extracts the minor number from a HOS version value.
#define HOSVER_MINOR(_version) (((_version) >> 8) & 0xFF)
/// Extracts the micro number from a HOS version value.
#define HOSVER_MICRO(_version) ( (_version) & 0xFF)
/// Returns the current HOS version that was previously set with \ref hosversionSet. If version initialization fails during startup (such as in the case set:sys is not available), this function returns zero.
u32 hosversionGet(void);
/// Sets or overrides the current HOS version. This function is normally called automatically by libnx on startup with the version info obtained with \ref setsysGetFirmwareVersion.
void hosversionSet(u32 version);
/// Returns whether the current HOS version is augmented by running the Atmosphère custom firmware.
bool hosversionIsAtmosphere(void);
/// Returns true if the current HOS version is equal to or above the specified major/minor/micro version.
static inline bool hosversionAtLeast(u8 major, u8 minor, u8 micro) {
return hosversionGet() >= MAKEHOSVERSION(major,minor,micro);
}
/// Returns true if the current HOS version is earlier than the specified major/minor/micro version.
static inline bool hosversionBefore(u8 major, u8 minor, u8 micro) {
return !hosversionAtLeast(major, minor, micro);
}
/// Returns true if the current HOS version is between the two specified major versions, i.e. [major1, major2).
static inline bool hosversionBetween(u8 major1, u8 major2) {
u32 ver = hosversionGet();
return ver >= MAKEHOSVERSION(major1,0,0) && ver < MAKEHOSVERSION(major2,0,0);
}

View File

@ -1,10 +1,35 @@
/**
* @file nxlink.h
* @brief Netloader (nxlink) utilities
* @author WinterMute
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
struct in_addr;
/// Address of the host connected through nxlink
extern struct in_addr __nxlink_host;
#define NXLINK_SERVER_PORT 28280
#define NXLINK_CLIENT_PORT 28771
#define NXLINK_SERVER_PORT 28280 ///< nxlink TCP server port
#define NXLINK_CLIENT_PORT 28771 ///< nxlink TCP client port
int nxlinkStdio(void);
/**
* @brief Connects to the nxlink host, setting up an output stream.
* @param[in] redirStdout Whether to redirect stdout to nxlink output.
* @param[in] redirStderr Whether to redirect stderr to nxlink output.
* @return Socket fd on success, negative number on failure.
* @note The socket should be closed with close() during application cleanup.
*/
int nxlinkConnectToHost(bool redirStdout, bool redirStderr);
/// Same as \ref nxlinkConnectToHost but redirecting both stdout/stderr.
NX_INLINE int nxlinkStdio(void) {
return nxlinkConnectToHost(true, true);
}
/// Same as \ref nxlinkConnectToHost but redirecting only stderr.
NX_INLINE int nxlinkStdioForDebug(void) {
return nxlinkConnectToHost(false, true);
}

View File

@ -0,0 +1,224 @@
/**
* @file pad.h
* @brief Simple wrapper for the HID Npad API.
* @author fincs
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/hid.h"
/// Mask including all existing controller IDs.
#define PAD_ANY_ID_MASK 0x1000100FFUL
/// Pad state object.
typedef struct {
u8 id_mask;
u8 active_id_mask;
bool read_handheld;
bool active_handheld;
u32 style_set;
u32 attributes;
u64 buttons_cur;
u64 buttons_old;
HidAnalogStickState sticks[2];
u32 gc_triggers[2];
} PadState;
/// Pad button repeater state object.
typedef struct {
u64 button_mask;
s32 counter;
u16 delay;
u16 repeat;
} PadRepeater;
/**
* @brief Configures the input layout supported by the application.
* @param[in] max_players The maximum supported number of players (1 to 8).
* @param[in] style_set Bitfield of supported controller styles (see \ref HidNpadStyleTag).
*/
void padConfigureInput(u32 max_players, u32 style_set);
/**
* @brief Initializes a \ref PadState object to read input from one or more controller input sources.
* @param[in] _pad Pointer to \ref PadState.
* @remarks This is a variadic macro, pass the \ref HidNpadIdType value of each controller to add to the set.
*/
#define padInitialize(_pad, ...) ({ \
const HidNpadIdType _pad_ids[] = { __VA_ARGS__ }; \
u64 _pad_mask = 0; \
for (unsigned _pad_i = 0; _pad_i < (sizeof(_pad_ids)/sizeof(_pad_ids[0])); ++_pad_i) \
_pad_mask |= 1UL << (_pad_ids[_pad_i]); \
padInitializeWithMask((_pad), _pad_mask); \
})
/**
* @brief Same as \ref padInitialize, but taking a bitfield of controller IDs directly.
* @param[in] pad Pointer to \ref PadState.
* @param[in] mask Bitfield of controller IDs (each bit's position indicates a different \ref HidNpadIdType value).
*/
void padInitializeWithMask(PadState* pad, u64 mask);
/**
* @brief Same as \ref padInitialize, but including every single controller input source.
* @param[in] pad Pointer to \ref PadState.
* @remark Use this function if you want to accept input from any controller.
*/
NX_INLINE void padInitializeAny(PadState* pad) {
padInitializeWithMask(pad, PAD_ANY_ID_MASK);
}
/**
* @brief Same as \ref padInitialize, but including \ref HidNpadIdType_No1 and \ref HidNpadIdType_Handheld.
* @param[in] pad Pointer to \ref PadState.
* @remark Use this function if you just want to accept input for a single-player application.
*/
NX_INLINE void padInitializeDefault(PadState* pad) {
padInitialize(pad, HidNpadIdType_No1, HidNpadIdType_Handheld);
}
/**
* @brief Updates pad state by reading from the controller input sources specified during initialization.
* @param[in] pad Pointer to \ref PadState.
*/
void padUpdate(PadState* pad);
/**
* @brief Retrieves whether \ref HidNpadIdType_Handheld is an active input source (i.e. it was possible to read from it).
* @param[in] pad Pointer to \ref PadState.
* @return Boolean value.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR bool padIsHandheld(const PadState* pad) {
return pad->active_handheld;
}
/**
* @brief Retrieves whether the specified controller is an active input source (i.e. it was possible to read from it).
* @param[in] pad Pointer to \ref PadState.
* @param[in] id ID of the controller input source (see \ref HidNpadIdType)
* @return Boolean value.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR bool padIsNpadActive(const PadState* pad, HidNpadIdType id) {
if (id <= HidNpadIdType_No8)
return pad->active_id_mask & BIT(id);
else if (id == HidNpadIdType_Handheld)
return pad->active_handheld;
else
return false;
}
/**
* @brief Retrieves the set of input styles supported by the selected controller input sources.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadStyleTag.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u32 padGetStyleSet(const PadState* pad) {
return pad->style_set;
}
/**
* @brief Retrieves the set of attributes reported by the system for the selected controller input sources.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadAttribute.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u32 padGetAttributes(const PadState* pad) {
return pad->attributes;
}
/**
* @brief Retrieves whether any of the selected controller input sources is connected.
* @param[in] pad Pointer to \ref PadState.
* @return Boolean value.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR bool padIsConnected(const PadState* pad) {
return pad->attributes & HidNpadAttribute_IsConnected;
}
/**
* @brief Retrieves the current set of pressed buttons across all selected controller input sources.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadButton.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u64 padGetButtons(const PadState* pad) {
return pad->buttons_cur;
}
/**
* @brief Retrieves the set of buttons that are newly pressed.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadButton.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u64 padGetButtonsDown(const PadState* pad) {
return ~pad->buttons_old & pad->buttons_cur;
}
/**
* @brief Retrieves the set of buttons that are newly released.
* @param[in] pad Pointer to \ref PadState.
* @return Bitfield of \ref HidNpadButton.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR u64 padGetButtonsUp(const PadState* pad) {
return pad->buttons_old & ~pad->buttons_cur;
}
/**
* @brief Retrieves the position of an analog stick in a controller.
* @param[in] pad Pointer to \ref PadState.
* @param[in] i ID of the analog stick to read (0=left, 1=right).
* @return \ref HidAnalogStickState.
* @remark \ref padUpdate must have been previously called.
*/
NX_CONSTEXPR HidAnalogStickState padGetStickPos(const PadState* pad, unsigned i) {
return pad->sticks[i];
}
/**
* @brief Retrieves the position of an analog trigger in a GameCube controller.
* @param[in] pad Pointer to \ref PadState.
* @param[in] i ID of the analog trigger to read (0=left, 1=right).
* @return Analog trigger position (range is 0 to 0x7fff).
* @remark \ref padUpdate must have been previously called.
* @remark \ref HidNpadStyleTag_NpadGc must have been previously configured as a supported style in \ref padConfigureInput for GC trigger data to be readable.
*/
NX_CONSTEXPR u32 padGetGcTriggerPos(const PadState* pad, unsigned i) {
return pad->gc_triggers[i];
}
/**
* @brief Initializes a \ref PadRepeater object with the specified settings.
* @param[in] r Pointer to \ref PadRepeater.
* @param[in] delay Number of input updates between button presses being first detected and them being considered for repeat.
* @param[in] repeat Number of input updates between autogenerated repeat button presses.
*/
NX_CONSTEXPR void padRepeaterInitialize(PadRepeater* r, u16 delay, u16 repeat) {
r->button_mask = 0;
r->counter = 0;
r->delay = delay;
r->repeat = repeat;
}
/**
* @brief Updates pad repeat state.
* @param[in] r Pointer to \ref PadRepeater.
* @param[in] button_mask Bitfield of currently pressed \ref HidNpadButton that will be considered for repeat.
*/
void padRepeaterUpdate(PadRepeater* r, u64 button_mask);
/**
* @brief Retrieves the set of buttons that are being repeated according to the parameters specified in \ref padRepeaterInitialize.
* @param[in] r Pointer to \ref PadRepeater.
* @return Bitfield of \ref HidNpadButton.
* @remark It is suggested to bitwise-OR the return value of this function with that of \ref padGetButtonsDown.
*/
NX_CONSTEXPR u64 padRepeaterGetButtons(const PadRepeater* r) {
return r->counter == 0 ? r->button_mask : 0;
}

View File

@ -0,0 +1,29 @@
#pragma once
#include "../types.h"
/// Fetches the last resolver Switch result code of the current thread.
Result resolverGetLastResult(void);
/// Retrieves a handle used to cancel the next resolver command on the current thread.
u32 resolverGetCancelHandle(void);
/// Retrieves whether service discovery is enabled for resolver commands on the current thread.
bool resolverGetEnableServiceDiscovery(void);
/// [5.0.0+] Retrieves whether the DNS cache is used to resolve queries on the current thread (not implemented).
bool resolverGetEnableDnsCache(void);
/// Enables or disables service discovery for the current thread.
void resolverSetEnableServiceDiscovery(bool enable);
/// [5.0.0+] Enables or disables the usage of the DNS cache on the current thread (not implemented).
void resolverSetEnableDnsCache(bool enable);
/// Cancels a previous resolver command (handle obtained with \ref resolverGetCancelHandle prior to calling the command).
Result resolverCancel(u32 handle);
/// [5.0.0+] Removes a hostname from the DNS cache (not implemented).
Result resolverRemoveHostnameFromCache(const char* hostname);
/// [5.0.0+] Removes an IP address from the DNS cache (not implemented).
Result resolverRemoveIpAddressFromCache(u32 ip);

View File

@ -0,0 +1,257 @@
/**
* @file ringcon.h
* @brief Wrapper for using the Ring-Con attached to a Joy-Con, with hidbus. See also: https://switchbrew.org/wiki/Ring-Con
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../services/hidbus.h"
#define RINGCON_CAL_MAGIC -0x3502 // 0xCAFE
/// Whether the output data is valid.
typedef enum {
RingConDataValid_Ok = 0, ///< Valid.
RingConDataValid_CRC = 1, ///< Bad CRC.
RingConDataValid_Cal = 2, ///< Only used with \ref ringconReadUserCal. Calibration is needed via \ref ringconUpdateUserCal.
} RingConDataValid;
typedef enum {
RingConErrorFlag_BadUserCalUpdate = 0, ///< The output from \ref ringconReadUserCal doesn't match the input used with \ref ringconWriteUserCal, or the \ref RingConDataValid is not ::RingConDataValid_Ok.
RingConErrorFlag_BadFlag = 4, ///< The output flag from \ref ringconCmdx00020105 when successful is invalid.
RingConErrorFlag_BadUserCal = 5, ///< BadUserCal
RingConErrorFlag_BadManuCal = 6, ///< BadManuCal
} RingConErrorFlag;
/// Ring-Con firmware version.
typedef struct {
u8 fw_main_ver; ///< Main firmware version.
u8 fw_sub_ver; ///< Sub firmware version.
} RingConFwVersion;
/// Ring-Con manufacturer calibration.
typedef struct {
s16 os_max; ///< (manu_)os_max
s16 hk_max; ///< (manu_)hk_max
s16 zero_min; ///< (manu_)zero_min
s16 zero_max; ///< (manu_)zero_max
} RingConManuCal;
/// Ring-Con user calibration.
typedef struct {
s16 os_max; ///< (user_)os_max
s16 hk_max; ///< (user_)hk_max
s16 zero; ///< (user_)zero
RingConDataValid data_valid; ///< \ref RingConDataValid
} RingConUserCal;
/// Polling data extracted from \ref HidbusJoyPollingReceivedData.
typedef struct {
s16 data; ///< Sensor state data.
u64 sampling_number; ///< SamplingNumber
} RingConPollingData;
/// Ring-Con state object.
typedef struct {
bool bus_initialized;
HidbusBusHandle handle;
void* workbuf;
size_t workbuf_size;
u64 polling_last_sampling_number;
u32 error_flags;
u64 id_l, id_h;
RingConFwVersion fw_ver;
u32 flag;
s16 unk_cal;
s32 total_push_count;
RingConManuCal manu_cal;
RingConUserCal user_cal;
} RingCon;
/**
* @brief Creates a \ref RingCon object, and handles the various initialization for it.
* @param c \ref RingCon
* @param[in] id \ref HidNpadIdType. A Ring-Con must be attached to this controller.
*/
Result ringconCreate(RingCon *c, HidNpadIdType id);
/**
* @brief Close a \ref RingCon.
* @param c \ref RingCon
*/
void ringconClose(RingCon *c);
/**
* @brief Gets the error flags field.
* @param c \ref RingCon
*/
NX_CONSTEXPR u32 ringconGetErrorFlags(RingCon *c) {
return c->error_flags;
}
/**
* @brief Gets the value of an error flag, set by \ref ringconSetErrorFlag.
* @param c \ref RingCon
* @param[in] flag \ref RingConErrorFlag
*/
NX_CONSTEXPR bool ringconGetErrorFlag(RingCon *c, RingConErrorFlag flag) {
return (c->error_flags & BIT(flag)) != 0;
}
/**
* @brief Gets the \ref RingConFwVersion previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out \ref RingConFwVersion
*/
NX_CONSTEXPR RingConFwVersion ringconGetFwVersion(RingCon *c) {
return c->fw_ver;
}
/**
* @brief Gets the Id previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] id_l Id low.
* @param[out] id_h Id high.
*/
NX_CONSTEXPR void ringconGetId(RingCon *c, u64 *id_l, u64 *id_h) {
*id_l = c->id_l;
*id_h = c->id_h;
}
/**
* @brief Gets the unk_cal previously loaded by \ref ringconCreate with \ref ringconReadUnkCal. Only valid when the output flag from \ref ringconCmdx00020105 is valid.
* @param c \ref RingCon
*/
NX_CONSTEXPR s16 ringconGetUnkCal(RingCon *c) {
return c->unk_cal;
}
/**
* @brief Gets the total-push-count previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out total_push_count
*/
NX_CONSTEXPR s32 ringconGetTotalPushCount(RingCon *c) {
return c->total_push_count;
}
/**
* @brief Gets the \ref RingConManuCal previously loaded by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out \ref RingConManuCal
*/
NX_CONSTEXPR void ringconGetManuCal(RingCon *c, RingConManuCal *out) {
*out = c->manu_cal;
}
/**
* @brief Gets the \ref RingConUserCal previously loaded by \ref ringconCreate.
* @note The Ring-Con UserCal doesn't seem to be calibrated normally?
* @param c \ref RingCon
* @param[out] out \ref RingConUserCal
*/
NX_CONSTEXPR void ringconGetUserCal(RingCon *c, RingConUserCal *out) {
*out = c->user_cal;
}
/**
* @brief Updates the \ref RingConUserCal.
* @note The input \ref RingConUserCal is used with \ref ringconWriteUserCal, and the output from \ref ringconReadUserCal is verified with the input \ref RingConUserCal. This does not update the \ref RingConUserCal returned by \ref ringconGetUserCal.
* @note The Ring-Con UserCal doesn't seem to be calibrated normally?
* @param c \ref RingCon
* @param[in] cal \ref RingConUserCal
*/
Result ringconUpdateUserCal(RingCon *c, RingConUserCal cal);
/**
* @brief Reads the \ref RingConFwVersion.
* @note This is used internally by \ref ringconCreate. Normally you should use \ref ringconGetFwVersion instead.
* @param c \ref RingCon
* @param[out] out \ref RingConFwVersion
*/
Result ringconReadFwVersion(RingCon *c, RingConFwVersion *out);
/**
* @brief Reads the Id.
* @note This is used internally by \ref ringconCreate. Normally you should use \ref ringconGetId instead.
* @param c \ref RingCon
* @param[out] id_l Id low.
* @param[out] id_h Id high.
*/
Result ringconReadId(RingCon *c, u64 *id_l, u64 *id_h);
/**
* @brief Gets the \ref RingConPollingData. Only returns entries which are new since the last time this was called (or if not previously called, all available entries up to count).
* @param c \ref RingCon
* @param[out] out Output array of \ref RingConPollingData. Entry order is newest -> oldest.
* @param[in] count Total size of the out array in entries, max value is 0x9.
* @param[out] total_out Total output entries.
*/
Result ringconGetPollingData(RingCon *c, RingConPollingData *out, s32 count, s32 *total_out);
/**
* @brief Uses cmd 0x00020105.
* @note Used internally by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out Output value.
*/
Result ringconCmdx00020105(RingCon *c, u32 *out);
/**
* @brief Reads the \ref RingConManuCal.
* @note Used internally by \ref ringconCreate and \ref ringconReadUnkCal.
* @param c \ref RingCon
* @param[out] out \ref RingConManuCal
*/
Result ringconReadManuCal(RingCon *c, RingConManuCal *out);
/**
* @brief Gets the unknown value derived from the output of cmd 0x00020504 and \ref ringconReadManuCal.
* @note Used internally by \ref ringconCreate.
* @param c \ref RingCon
* @param[out] out Output value.
*/
Result ringconReadUnkCal(RingCon *c, s16 *out);
/**
* @brief Reads the \ref RingConUserCal.
* @note Used internally by \ref ringconCreate and \ref ringconUpdateUserCal.
* @param c \ref RingCon
* @param[out] out \ref RingConUserCal
*/
Result ringconReadUserCal(RingCon *c, RingConUserCal *out);
/**
* @brief Reads the rep-count for Multitask Mode.
* @param c \ref RingCon
* @param[out] out Output value. Official sw using this clamps the output to range 0-500.
* @param[out] data_valid \ref RingConDataValid
*/
Result ringconReadRepCount(RingCon *c, s32 *out, RingConDataValid *data_valid);
/**
* @brief Reads the total-push-count, for Multitask Mode.
* @note Used internally by \ref ringconCreate. Normally \ref ringconGetTotalPushCount should be used instead.
* @param c \ref RingCon
* @param[out] out Output value.
* @param[out] data_valid \ref RingConDataValid
*/
Result ringconReadTotalPushCount(RingCon *c, s32 *out, RingConDataValid *data_valid);
/**
* @brief This resets the value returned by \ref ringconReadRepCount to 0.
* @param c \ref RingCon
*/
Result ringconResetRepCount(RingCon *c);
/**
* @brief Writes the \ref RingConUserCal.
* @note Used internally by \ref ringconUpdateUserCal.
* @param c \ref RingCon
* @param[in] cal \ref RingConUserCal
*/
Result ringconWriteUserCal(RingCon *c, RingConUserCal cal);

View File

@ -6,60 +6,101 @@
*/
#pragma once
#include "../types.h"
#include "sm.h"
#include "../sf/service.h"
#define ACC_USER_LIST_SIZE 8
typedef enum {
AccountServiceType_Application = 0, ///< Initializes acc:u0.
AccountServiceType_System = 1, ///< Initializes acc:u1.
AccountServiceType_Administrator = 2, ///< Initializes acc:su.
} AccountServiceType;
/// Profile
typedef struct {
Service s;
Service s; ///< IProfile
} 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.
/// Account UserId.
typedef struct {
u64 uid[2]; ///< UserId. All-zero is invalid / Uid not set. See also \ref accountUidIsValid.
} AccountUid;
/// UserData
typedef struct {
u32 unk_x0; ///< Unknown.
u32 iconID; ///< Icon ID. 0 = Mii, the rest are character icon IDs.
u8 iconBackgroundColorID; ///< Profile icon background color ID
u8 unk_x9[0x7]; ///< Unknown.
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;
} AccountUserData;
typedef struct
{
u128 userID;
/// ProfileBase
typedef struct {
AccountUid uid; ///< \ref AccountUid
u64 lastEditTimestamp; ///< POSIX UTC timestamp, for the last account edit.
char username[0x20]; ///< UTF-8 Username.
} PACKED AccountProfileBase;
char nickname[0x20]; ///< UTF-8 Nickname.
} AccountProfileBase;
Result accountInitialize(void);
/// NetworkServiceAccountId
typedef struct {
u64 id; ///< Id.
} AccountNetworkServiceAccountId;
/// Initialize account.
Result accountInitialize(AccountServiceType service_type);
/// Exit account.
void accountExit(void);
Service* accountGetService(void);
/// Get the total number of user profiles
/// Gets the Service object for the actual account service session.
Service* accountGetServiceSession(void);
/// Get the total number of user profiles.
Result accountGetUserCount(s32* user_count);
/**
* @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE.
* @param userIDs Pointer to array of user IDs.
* @param max_userIDs Maximum number of user IDs to return.
* @param actual_total The actual total number of user IDs found.
* @brief Get a list of all userIds. The returned list will never be larger than ACC_USER_LIST_SIZE.
* @param uids Pointer to array of userIds.
* @param max_uids Maximum number of userIds to return.
* @param actual_total The actual total number of userIds found.
*/
Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total);
Result accountListAllUsers(AccountUid* uids, s32 max_uids, s32 *actual_total);
/// 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 the userId for the last opened user.
Result accountGetLastOpenedUser(AccountUid *uid);
/// Get an AccountProfile for the specified userID.
Result accountGetProfile(AccountProfile* out, u128 userID);
/// Get an AccountProfile for the specified userId.
Result accountGetProfile(AccountProfile* out, AccountUid uid);
/// IsUserRegistrationRequestPermitted
Result accountIsUserRegistrationRequestPermitted(bool *out);
/// TrySelectUserWithoutInteraction
Result accountTrySelectUserWithoutInteraction(AccountUid *uid, bool is_network_service_account_required);
/// Close the AccountProfile.
void accountProfileClose(AccountProfile* profile);
/// 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);
Result accountProfileGetImageSize(AccountProfile* profile, u32* 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);
Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, u32* image_size);
/// Gets the userId which was selected by the profile-selector applet (if any), prior to launching the currently running Application.
/// This gets the cached PreselectedUser loaded during accountInitialize, when PreselectedUser is available.
Result accountGetPreselectedUser(AccountUid *uid);
/**
* @brief Checks whether the specified \ref AccountUid is valid/set (non-zero).
* @param[in] Uid \ref AccountUid
*/
NX_CONSTEXPR bool accountUidIsValid(const AccountUid *Uid) {
return Uid->uid[0]!=0 || Uid->uid[1]!=0;
}
void accountProfileClose(AccountProfile* profile);

View File

@ -1,16 +1,55 @@
/**
* @file apm.h
* @brief Performance management (apm) service IPC wrapper.
* @brief Performance management (apm) service IPC wrapper. This is used internally by applet with __nx_applet_PerformanceConfiguration, however if you prefer non-init/exit can be used manually. See also: https://switchbrew.org/wiki/PTM_services#apm:am
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
/// These are used internally by applet.
/// PerformanceMode
typedef enum {
ApmPerformanceMode_Invalid = -1, ///< Invalid
ApmPerformanceMode_Normal = 0, ///< Normal
ApmPerformanceMode_Boost = 1, ///< Boost
} ApmPerformanceMode;
/// CpuBoostMode. With \ref appletSetCpuBoostMode, only values 0/1 are available. This allows using higher clock rates.
typedef enum {
ApmCpuBoostMode_Normal = 0, ///< Default, boost-mode disabled.
ApmCpuBoostMode_FastLoad = 1, ///< Boost CPU. Additionally, throttle GPU to minimum. Use performance configurations 0x92220009 (Docked) and 0x9222000A (Handheld), or 0x9222000B and 0x9222000C.
ApmCpuBoostMode_Type2 = 2, ///< Conserve power. Only throttle GPU to minimum. Use performance configurations 0x9222000B and 0x9222000C.
} ApmCpuBoostMode;
/// Initialize apm. Used automatically by \ref appletInitialize with AppletType_Application.
Result apmInitialize(void);
/// Exit apm. Used automatically by \ref appletExit with AppletType_Application.
void apmExit(void);
Result apmSetPerformanceConfiguration(u32 PerformanceMode, u32 PerformanceConfiguration);
Result apmGetPerformanceConfiguration(u32 PerformanceMode, u32 *PerformanceConfiguration);
/// Gets the Service object for the actual apm service session.
Service* apmGetServiceSession(void);
/// Gets the Service object for ISession.
Service* apmGetServiceSession_Session(void);
/**
* @brief Gets the current ApmPerformanceMode.
* @param[out] out_performanceMode ApmPerformanceMode
*/
Result apmGetPerformanceMode(ApmPerformanceMode* out_performanceMode);
/**
* @brief Sets the PerformanceConfiguration for the specified PerformanceMode.
* @param[in] PerformanceMode \ref ApmPerformanceMode
* @param[in] PerformanceConfiguration PerformanceConfiguration
*/
Result apmSetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 PerformanceConfiguration);
/**
* @brief Gets the PerformanceConfiguration for the specified PerformanceMode.
* @param[in] PerformanceMode \ref ApmPerformanceMode
* @param[out] PerformanceConfiguration PerformanceConfiguration
*/
Result apmGetPerformanceConfiguration(ApmPerformanceMode PerformanceMode, u32 *PerformanceConfiguration);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
/**
* @file async.h
* @brief NS/NIM IAsync* IPC wrapper.
* @author yellows8
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
#include "../applets/error.h"
#include "../kernel/event.h"
/// AsyncValue
typedef struct {
Service s; ///< IAsyncValue
Event event; ///< Event with autoclear=false.
} AsyncValue;
/// AsyncResult
typedef struct {
Service s; ///< IAsyncResult
Event event; ///< Event with autoclear=false.
} AsyncResult;
///@name IAsyncValue
///@{
/**
* @brief Close a \ref AsyncValue.
* @note When the object is initialized, this uses \ref asyncValueCancel then \ref asyncValueWait with timeout=UINT64_MAX.
* @param a \ref AsyncValue
*/
void asyncValueClose(AsyncValue *a);
/**
* @brief Waits for the async operation to finish using the specified timeout.
* @param a \ref AsyncValue
* @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout.
*/
Result asyncValueWait(AsyncValue *a, u64 timeout);
/**
* @brief Gets the value size.
* @param a \ref AsyncValue
* @param[out] size Output size.
*/
Result asyncValueGetSize(AsyncValue *a, u64 *size);
/**
* @brief Gets the value.
* @note Prior to using the cmd, this uses \ref asyncResultWait with timeout=UINT64_MAX.
* @param a \ref AsyncValue
* @param[out] buffer Output buffer.
* @param[in] size Output buffer size.
*/
Result asyncValueGet(AsyncValue *a, void* buffer, size_t size);
/**
* @brief Cancels the async operation.
* @note Used automatically by \ref asyncValueClose.
* @param a \ref AsyncValue
*/
Result asyncValueCancel(AsyncValue *a);
/**
* @brief Gets the \ref ErrorContext.
* @note Only available on [4.0.0+].
* @param a \ref AsyncValue
* @param[out] context \ref ErrorContext
*/
Result asyncValueGetErrorContext(AsyncValue *a, ErrorContext *context);
///@}
///@name IAsyncResult
///@{
/**
* @brief Close a \ref AsyncResult.
* @note When the object is initialized, this uses \ref asyncResultCancel then \ref asyncResultWait with timeout=UINT64_MAX.
* @param a \ref AsyncResult
*/
void asyncResultClose(AsyncResult *a);
/**
* @brief Waits for the async operation to finish using the specified timeout.
* @param a \ref AsyncResult
* @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout.
*/
Result asyncResultWait(AsyncResult *a, u64 timeout);
/**
* @brief Gets the Result.
* @note Prior to using the cmd, this uses \ref asyncResultWait with timeout=UINT64_MAX.
* @param a \ref AsyncResult
*/
Result asyncResultGet(AsyncResult *a);
/**
* @brief Cancels the async operation.
* @note Used automatically by \ref asyncResultClose.
* @param a \ref AsyncResult
*/
Result asyncResultCancel(AsyncResult *a);
/**
* @brief Gets the \ref ErrorContext.
* @note Only available on [4.0.0+].
* @param a \ref AsyncResult
* @param[out] context \ref ErrorContext
*/
Result asyncResultGetErrorContext(AsyncResult *a, ErrorContext *context);
///@}

Some files were not shown because too many files have changed in this diff Show More