Compare commits

...
Author SHA1 Message Date
TuxSH 020cfb89c6 thermosphere: minor refactor 2021-02-19 21:52:39 +00:00
TuxSH f40c064e80 thermosphere: reload debug registers (refactored) 2021-02-19 21:52:39 +00:00
TuxSH 6bcb5aca60 thermosphere: remove dead code 2021-02-19 21:52:38 +00:00
TuxSH 548367453b thermosphere: fix uart pinmuxing. As it's now possible to init all uarts at the same time, do it.
Thanks to @CTCaer

See dumped values from HOS: https://gitlab.com/switchroot/kernel/l4t-platform-t210-switch/-/blob/ccaa47ee045671208eb404eecfedab97a3e29373/kernel-dts/icosa-platforms/tegra210-icosa-pinmux.dtsi
2021-02-19 21:52:38 +00:00
TuxSH 6790895487 thermosphere: shiny new tegra 210 gpio rewrite 2021-02-19 21:52:38 +00:00
TuxSH 41d98b5e48 thermosphere: oops 2021-02-19 21:52:37 +00:00
TuxSH b6dbdfe82d thermosphere: car driver rewrite 2021-02-19 21:52:37 +00:00
TuxSH 30b79c2fe7 thermosphere: pinmux driver C++ 2021-02-19 21:52:37 +00:00
TuxSH 3a79a7a961 thermosphere: tegra uart driver rewrite 2021-02-19 21:52:36 +00:00
TuxSH cefd66e7af thermosphere: refactor pl011 driver a bit more 2021-02-19 21:52:36 +00:00
TuxSH a8f28ab96d thermosphere: pl011 driver rewrite 2021-02-19 21:52:35 +00:00
TuxSH 2986967f2a thermosphere: guest mem rewrite 2021-02-19 21:52:35 +00:00
TuxSH fc8a596409 thermosphere: safe io copy 2021-02-19 21:52:35 +00:00
TuxSH 36f48748a4 thermosphere: clean up start.s & exception_vector.s 2021-02-19 21:52:34 +00:00
TuxSH 6f423fcfab thermosphere: rewrite (host) memory map (wip, need to update start.s anyway) 2021-02-19 21:52:34 +00:00
TuxSH fccadfdbf6 thermosphere: add TCR_TG0 back 2021-02-19 21:52:34 +00:00
TuxSH 47f343cda6 thermosphere: mmu: fix shareability 2021-02-19 21:52:33 +00:00
TuxSH 987731ea43 thermosphere: mmu table builder 2021-02-19 21:52:33 +00:00
TuxSH d4bbb78a27 thermosphere: static inline -> inline 2021-02-19 21:52:33 +00:00
TuxSH 0126a6417f thermosphere: fix off by 1 in wp mgr 2021-02-19 21:52:32 +00:00
TuxSH 7ecb3a4aaf thermosphere: cleanup again 2021-02-19 21:52:32 +00:00
TuxSH 56d764d09c thermosphere: rewrite semihosting 2021-02-19 21:52:31 +00:00
TuxSH 0cb5eab933 thermosphere: generic timer rewrite 2021-02-19 21:52:31 +00:00
TuxSH d15154f668 thermosphere: cleanup again 2021-02-19 21:52:30 +00:00
TuxSH ea830bb5ab thermosphere: propagate changes 2021-02-19 21:52:30 +00:00
TuxSH e8435784a7 thermosphere: rewrite smc traps 2021-02-19 21:52:30 +00:00
TuxSH 0437867449 thermosphere: sysreg traps 2021-02-19 21:52:29 +00:00
TuxSH 797cea0ac8 thermosphere: trap refactor WIP 2021-02-19 21:52:29 +00:00
TuxSH 874d1432be thermosphere: exception dispatcher rewrite 2021-02-19 21:52:29 +00:00
TuxSH e8bfe8a311 thermosphere: guest timer header 2021-02-19 21:52:28 +00:00
TuxSH 036883c30f thermosphere: propagate some changes 2021-02-19 21:52:28 +00:00
TuxSH 5b56d05e11 thermosphere: move EnterInterruptibleHypervisorCode into IrqManager 2021-02-19 21:52:27 +00:00
TuxSH 4adb675072 thermosphere: hvisor_exception_frame.hpp 2021-02-19 21:52:27 +00:00
TuxSH 77fbbb4c68 thermosphere: singleton ctors should be private 2021-02-19 21:52:27 +00:00
TuxSH f6793139c1 thermosphere: fix exception vector regression 2021-02-19 21:52:26 +00:00
TuxSH 37a889ccb2 thermosphere: rewrite core_ctx 2021-02-19 21:52:26 +00:00
TuxSH ea7d161755 thermosphere: start corectx/exception stuff rewrite 2021-02-19 21:52:26 +00:00
TuxSH d72fc3e8b9 thermosphere: cleanup cache trap 2021-02-19 21:52:25 +00:00
TuxSH c7eaf71896 thermosphere: fpu register cache 2021-02-19 21:52:25 +00:00
TuxSH 5a445e9394 thermosphere: cache rewrite 2021-02-19 21:52:25 +00:00
TuxSH 613402121a thermosphere: file cleanup 2021-02-19 21:52:24 +00:00
TuxSH 2574f68484 thermopshere: interrupt refactoring 2021-02-19 21:52:24 +00:00
TuxSH 1ee289f5f1 thermosphere: C++ vgic 2021-02-19 21:52:24 +00:00
TuxSH 31e5ff7c1d thermosphere: continue vgic rewrite 2021-02-19 21:52:23 +00:00
TuxSH 02bbe1bb40 thermosphere: begin to write virtual gic code in C++ 2021-02-19 21:52:23 +00:00
TuxSH b21c75b22b thermosphere: add singleton define 2021-02-19 21:52:22 +00:00
TuxSH c99a77a0c3 thermosphere: interrupt mask guard 2021-02-19 21:52:22 +00:00
TuxSH dd9b3ddb0d thermosphere: irq manager wip 2021-02-19 21:52:22 +00:00
TuxSH 785b7e1a37 thermosphere: mostly rewrite sw breakpoint manager 2021-02-19 21:52:21 +00:00
TuxSH 1eda049ada thermosphere: hw breakpoint/watchpoint managers 2021-02-19 21:52:21 +00:00
TuxSH 493a3c92e2 thermosphere: cpu intrinsics + synchronization primitives 2021-02-19 21:52:21 +00:00
TuxSH dad84ac017 thermosphere: sysreg stuff 2021-02-19 21:52:20 +00:00
TuxSH eab46ab1b6 thermosphere: C++ify gdb/verbose 2021-02-19 21:52:20 +00:00
TuxSH 192d2db4a9 thermospshere: c++ify xfer, query, etc. More string parsing utilities 2021-02-19 21:52:19 +00:00
TuxSH ff2c835b0a thermosphere: introduce GDB_TEST_NO_CMD_DATA 2021-02-19 21:52:19 +00:00
TuxSH dd7f0b805b thermosphere: partially rewrite gdb context top-level 2021-02-19 21:52:19 +00:00
TuxSH fdd5481f63 thermosphere: C++ gdb/rcmd 2021-02-19 21:52:19 +00:00
TuxSH 0b8d0035b9 thermosphère: C++ gdb/regs 2021-02-19 21:52:18 +00:00
TuxSH bfa917edf5 thermosphere: rewrite gdb/stop points in c++ 2021-02-19 21:52:18 +00:00
TuxSH 61a972abf3 thermosphere: rewrite gdb/mem in c++. Remove SearchMemory handler 2021-02-19 21:52:18 +00:00
TuxSH 697e61850f thermosphere: rewrite packet comms 2021-02-19 21:52:17 +00:00
TuxSH 2077062b79 thermosphere: cpp rewrite: constexpr string parsing, rewrote gdb/thread 2021-02-19 21:52:17 +00:00
TuxSH b445fe1bf4 wip 2021-02-19 21:52:16 +00:00
TuxSH b65f11d205 wip 2021-02-19 21:52:16 +00:00
TuxSH 5de560be30 thermosphere: fix watchpoint creation, fix wp&bp allocation 2021-02-19 21:52:16 +00:00
TuxSH be6253d6ad thermosphere: rewrite watchpoints.c 2021-02-19 21:52:15 +00:00
TuxSH 78eea8a373 thermosphere: suppress potential unused variable warnings 2021-02-19 21:52:15 +00:00
TuxSH 53850a5976 thermosphere: reduce gdb work buf to least acceptable limit 2021-02-19 21:52:15 +00:00
TuxSH 788f331de0 thermosphere: the fpu cache is only being really modified by gdb anyway 2021-02-19 21:52:14 +00:00
TuxSH edf2bbc30e thermosphere: I wish ld wasn't dumb (also, bugfix). This saves 4K 2021-02-19 21:52:14 +00:00
TuxSH e4d189eee3 thermosphere: rewhoops 2021-02-19 21:52:14 +00:00
TuxSH e6fdd6bc98 thermosphere: fix software breakpoints 2021-02-19 21:52:13 +00:00
TuxSH 3556c12960 thermosphere: gdb: fix IsThreadAlive 2021-02-19 21:52:13 +00:00
TuxSH 67daf5a73e thermosphère: fix deadlock 2021-02-19 21:52:12 +00:00
TuxSH f1a241ffef thermosphere: fix sending bug when handling ctrl-c 2021-02-19 21:52:12 +00:00
TuxSH bf7f077432 thermosphere: fix continue logic for full-stop & some refactoring 2021-02-19 21:52:12 +00:00
TuxSH ebf8053b42 thermosphere: rewrite condition in debugManagerDoPauseCores 2021-02-19 21:52:11 +00:00
TuxSH 914790be01 thermosphere: fix bug in debug.c 2021-02-19 21:52:11 +00:00
TuxSH 036882f162 thermosphere: oops 2021-02-19 21:52:11 +00:00
TuxSH b0ae19a6f9 thermosphere: better self-debug fault reporting 2021-02-19 21:52:10 +00:00
TuxSH 0b7efc0501 thermosphere: fix bug in exceptionReturnPreprocess 2021-02-19 21:52:10 +00:00
TuxSH c67ff366ea thermosphere: forgot compiler barrier in get_sysreg 2021-02-19 21:52:10 +00:00
TuxSH 63e3f40fa5 thermosphere: fix gdb/regs.c assertions 2021-02-19 21:52:09 +00:00
TuxSH 3fe7c7537e thermopshere: GDB_ParseExceptionFrame: fix format error 2021-02-19 21:52:09 +00:00
TuxSH 256201922b thermosphere: fix bug where x0 isn't saved 2021-02-19 21:52:09 +00:00
TuxSH 46c82e2d77 thermosphere: fix thread reporting logic, etc 2021-02-19 21:52:08 +00:00
TuxSH cb4d898579 thermosphere: fix reporting logic of initial break event 2021-02-19 21:52:08 +00:00
TuxSH 7acd5a9ec7 thermosphere: fix target.xml generation 2021-02-19 21:52:08 +00:00
TuxSH 7f7e4e8310 thermosphere: fix irq buffer overflow 2021-02-19 21:52:07 +00:00
TuxSH 8f25d4f77f thermosphere: add more debugging strings 2021-02-19 21:52:07 +00:00
TuxSH e1a8bdd495 thermosphere: gdb: fix a few bugs 2021-02-19 21:52:07 +00:00
TuxSH ef23db21e6 thermosphere: pl011: fix uartSetInterruptStatus
We don't need to forcefully clear the line level
2021-02-19 21:52:06 +00:00
TuxSH 46954a5359 thermosphere: actually report the debug events 2021-02-19 21:52:06 +00:00
TuxSH 6499d36722 thermosphere: gdb: fix GDB_SendStopReply 2021-02-19 21:52:06 +00:00
TuxSH 66ba05b302 thermosphere: pause at start, some cleanup, etc. 2021-02-19 21:52:05 +00:00
TuxSH 7a774adbc3 thermosphere: libc: fix missing macro 2021-02-19 21:52:05 +00:00
TuxSH ce1df0ac23 thermosphere: qemu: make serial go through a socket 2021-02-19 21:52:04 +00:00
TuxSH fc5d81dca3 thermosphere: oops 2021-02-19 21:52:04 +00:00
TuxSH 23ef4b94d6 thermosphere: reduce usage of nonvolatile memory by around 4KB 2021-02-19 21:52:04 +00:00
TuxSH e4de512e6f thermosphere: gdb: add debugManagerInit 2021-02-19 21:52:03 +00:00
TuxSH cf0b052590 thermosphere: gdb: add missing command list entries, fix warnings again 2021-02-19 21:52:03 +00:00
TuxSH 0509fa57ca thermosphere: add src/gdb to build list, fix subsequent warnings and errors 2021-02-19 21:52:03 +00:00
TuxSH 175f16627b thermosphere: fix break/continue (?), fix attach/detach 2021-02-19 21:52:02 +00:00
TuxSH f0b9162d5e thermosphere: gdb: remove currentThreadId; migrate rx irq 2021-02-19 21:52:02 +00:00
TuxSH 02e2a1efa2 thermosphere: gdb: add core_on and core_off handling 2021-02-19 21:52:01 +00:00
TuxSH ed5736e8d2 thermosphere: forgot to call exceptionReturnPreprocess in start.s 2021-02-19 21:52:01 +00:00
TuxSH b0ca29d18e thermosphere: gdb: properly handle vStopped ack sequence 2021-02-19 21:52:01 +00:00
TuxSH 36ca87491d thermosphere: gdb/debug: avoid pause/unpause race condition in vCont + bugfix 2021-02-19 21:52:00 +00:00
TuxSH 9ef2532b9d thermosphere: gdb: fix parsing errors in vCont and hex decode 2021-02-19 21:52:00 +00:00
TuxSH cbf3b305ca thermosphere: gdb add break & vCont handling 2021-02-19 21:52:00 +00:00
TuxSH c0252e07f6 thermosphere: GDB_TrySignalDebugEvent, do nothing if not attached 2021-02-19 21:51:59 +00:00
TuxSH 71401b0731 thermosphere: add structural changes needed for range step 2021-02-19 21:51:59 +00:00
TuxSH ff1aac0ab5 thermosphere: resend debug event if not handled 2021-02-19 21:51:59 +00:00
TuxSH 984f6776c6 thermosphere: impl. debug event dispatching, vStopped, "?" 2021-02-19 21:51:58 +00:00
TuxSH 0e47f7f46b thermosphere: debug manager wip 2021-02-19 21:51:58 +00:00
TuxSH c00672654a thermosphere: gdb: remove server, rewrite data processing in gdb/context and gdb/net 2021-02-19 21:51:58 +00:00
TuxSH 8538fed043 thermosphere: optimize barrier and core_ctx 2021-02-19 21:51:57 +00:00
TuxSH 1f2b8e7918 thermopshere: add spinlock try lock 2021-02-19 21:51:57 +00:00
TuxSH 30a4a0d4c1 thermosphere: rewrite gdb/reg 2021-02-19 21:51:57 +00:00
TuxSH 97c4595a3a thermosphere: rework fpu register handling 2021-02-19 21:51:56 +00:00
TuxSH 5b545f89f5 thermosphere: introduce "ENSURE" 2021-02-19 21:51:56 +00:00
TuxSH 310048a32c thermosphere: small spinlock improvements 2021-02-19 21:51:56 +00:00
TuxSH 5473443057 thermosphere: refactor gdb/thread 2021-02-19 21:51:55 +00:00
TuxSH 78723164c1 thermosphere: gdb: target xml + various refactoring 2021-02-19 21:51:55 +00:00
TuxSH 58d52675cd thermosphere: rewrite gdb/mem 2021-02-19 21:51:55 +00:00
TuxSH bd36796d5f thermosphere: gdb/net: reduce stack/memory usage by using memmove 2021-02-19 21:51:54 +00:00
TuxSH 779aeaa538 thermopshere: gdb: rewrite stop point handling 2021-02-19 21:51:54 +00:00
TuxSH 5de05ed8a8 thermosphere: retrieve wp direction 2021-02-19 21:51:54 +00:00
TuxSH abeaa72f94 thermosphere: some gdb/debug refactor 2021-02-19 21:51:53 +00:00
TuxSH c89ce085a6 thermopshère: rewrite some gdb/net functions 2021-02-19 21:51:53 +00:00
TuxSH 418cabbd53 thermosphere: add esr_el2 to exception frame 2021-02-19 21:51:53 +00:00
TuxSH 744491ca33 thermosphere: allow each core to pause itself in a lock-free manner & fix bugs 2021-02-19 21:51:52 +00:00
TuxSH 9ebf3c9580 thermosphere: wip gdb 2021-02-19 21:51:52 +00:00
TuxSH f23fb45956 thermosphere: copy paste lots of gdb luma files (but don't build them yet) 2021-02-19 21:51:51 +00:00
TuxSH 61fec56c6e thermosphere: minor changes 2021-02-19 21:51:51 +00:00
TuxSH a665f49b93 thermosphere: incl pattern utils 2021-02-19 21:51:51 +00:00
TuxSH 3e8bd764d5 thermosphere: unfuck sw breakpoint logic 2021-02-19 21:51:51 +00:00
TuxSH c64ccd86ee thermosphere: uninline recursive lock funcs 2021-02-19 21:51:50 +00:00
TuxSH 217c1ad054 thermosphere: implement reading and writing guest memory 2021-02-19 21:51:50 +00:00
TuxSH 0f0228e240 thermosphere: we expose a GICv2, not a GICv1 2021-02-19 21:51:49 +00:00
TuxSH 3ca3e094fe thermosphere: use ish instead of sy in most places 2021-02-19 21:51:49 +00:00
TuxSH d1cd17a9df thermosphere: fix fmt.c "l" handling 2021-02-19 21:51:49 +00:00
TuxSH 626f0ecb98 thermosphere: major refactor of memory map
- use recursive stage 1 page table (thanks @fincs for this idea)
- NULL now unmapped
- no identity mapping
- image + GICv2 now mapped at the same address for every platform
- tempbss mapped just after "real" bss, can now steal unused mem from
the latter
- no hardcoded VAs for other MMIO devices
- tegra: remove timers, use the generic timer instead
2021-02-19 21:51:48 +00:00
TuxSH 92a291cd41 thermosphere: disable interrupts in debugPauseCores 2021-02-19 21:51:48 +00:00
TuxSH 906d6a4f20 thermosphere: rewrite debug pause & fix single step state machine 2021-02-19 21:51:48 +00:00
TuxSH 6b8a843ffb thermosphere: trap set/way dcache access
note: qemu does not implement the trap
2021-02-19 21:51:47 +00:00
TuxSH 72d1992eec thermosphere: use barriers and caches *properly*. Cache code refactoring
- set/way cache ops create losses of coherency, do not broadcast and are only meant to be used on boot, period.

Cache ops by VA are **the only way** to do data cache maintenance.

Fix a bug where the L2 cache was evicted by each core. It shouldn't have.

- Cleaning dcache to PoU and invalidating icache to PoU, by VA is sufficient for self-modifying code

- Since we operate within a single cluster and don't do DMA, we almost always operate within the inner shareability domain

(commit untested on real hw)
2021-02-19 21:51:47 +00:00
TuxSH 1369697058 thermosphere: add debug pause logic 2021-02-19 21:51:47 +00:00
TuxSH b6a130547a thermosphere: add common asm macros 2021-02-19 21:51:46 +00:00
TuxSH 067770334e thermosphere: add fpu regs save/restore 2021-02-19 21:51:46 +00:00
TuxSH a7741c8576 thermosphere: add cctx->userFrame 2021-02-19 21:51:46 +00:00
TuxSH dd96c8b32b thermosphere: fix ptimer time freezing (again) 2021-02-19 21:51:45 +00:00
TuxSH 68a1ce6dd2 thermosphere: properly implement guest timer stuff 2021-02-19 21:51:45 +00:00
TuxSH 388c245ce4 thermosphere: add TransportInterface abstraction layer 2021-02-19 21:51:45 +00:00
TuxSH 1086c0612c thermosphere: refactor tegra uart code, etc. 2021-02-19 21:51:44 +00:00
TuxSH 8dc9be9f8e thermosphere: pl011 uart refactor 2021-02-19 21:51:44 +00:00
TuxSH 018260645a thermosphere: fix pl101 uart reg definitions 2021-02-19 21:51:44 +00:00
TuxSH a6d191bf4b thermosphere: add proper memory/instruction barriers for breakpoint stuff 2021-02-19 21:51:43 +00:00
TuxSH 1eb60a2a52 thermosphere: add hypervisor timer code 2021-02-19 21:51:43 +00:00
TuxSH 3d3a9925b9 thermosphere: qemu: get rid of arm tf
qemu impls psci anyway
2021-02-19 21:51:42 +00:00
TuxSH 501472324f thermosphere: refactor exception handlers & add stolen time/emulated ptimer logic 2021-02-19 21:51:42 +00:00
TuxSH b9d07fccd6 thermosphere: rewrite sysreg trapping code, add skeleton code for timer val trap handling; support A32 EL1 once again 2021-02-19 21:51:42 +00:00
TuxSH d42d9e60b9 thermosphere: don't trap memory register writes/don't migrate sw breakpoints
Makes no sense on a system with ASLR
2021-02-19 21:51:41 +00:00
TuxSH 28552da099 thermosphere: vgic: largely reduce the number of mmio accesses
since we have to use 64 bits for VirqState anyway
2021-02-19 21:51:41 +00:00
TuxSH d56185e432 thermosphere: make the pending virq list ordering stable 2021-02-19 21:51:41 +00:00
TuxSH c42aef6ba7 thermosphere: fix wrong icfgr shift; fix list handling bug 2021-02-19 21:51:40 +00:00
TuxSH 03fe744bc4 thermosphere: vgic: fix OOB accesses, fix icfgr and itargetsr handling
qemu actually allows SPIs to use the N-N model
2021-02-19 21:51:40 +00:00
TuxSH e49a035455 thermosphere: fix is/ic registers usage; fix offset calculation 2021-02-19 21:51:40 +00:00
TuxSH 0811572889 thermosphere: fix truncation in vgicCleanupPendingList 2021-02-19 21:51:39 +00:00
TuxSH 76a5e745e4 thermosphere: honor irq config for ppis 2021-02-19 21:51:39 +00:00
TuxSH 7130b6efd1 thermosphere: yikes 2021-02-19 21:51:39 +00:00
TuxSH 37b14bc4b8 thermosphere: use strict volatile bitfields just in case 2021-02-19 21:51:38 +00:00
TuxSH 13174e7458 thermosphere: vgic: fix critical bug in vgicUpdateState, add more checks
Yikes.
2021-02-19 21:51:38 +00:00
TuxSH ef79908594 thermosphere: add CFI where needed, add PANIC macro, etc. 2021-02-19 21:51:38 +00:00
TuxSH 3a13ab2e46 thermosphere: vgic: mostly fix vSGI handling, remove unimplementable/unused stuff + bugfixes
Still somewhat broken, though
2021-02-19 21:51:37 +00:00
TuxSH 676a895cca thermosphere: fix guest access to irq 25, etc; we don't need to raise VI manually
See Armv8a TRM "Virtual IRQ exception"
2021-02-19 21:51:37 +00:00
TuxSH cdf3bc6942 thermosphere: add PPI definitions 2021-02-19 21:51:37 +00:00
TuxSH fe0662a75d vgic: fix multiple bugs 2021-02-19 21:51:36 +00:00
TuxSH f3ad62d1b8 thermosphere: fix various vgic bugs; fix register access OOB bug (xzr) 2021-02-19 21:51:36 +00:00
TuxSH 27859a7541 thermosphere: vgic: fix enabled state of virqs 2021-02-19 21:51:36 +00:00
TuxSH e3b6d64f1b thermosphere: fix multiple bugs 2021-02-19 21:51:35 +00:00
TuxSH c17b81aaf6 thermosphere: vgic code draft 2021-02-19 21:51:35 +00:00
TuxSH 176be2386d thermosphere: also trap GICH (to deny access) 2021-02-19 21:51:35 +00:00
TuxSH f9ec21e99e thermosphere: handle stage2 data aborts, trap gicd accesses 2021-02-19 21:51:34 +00:00
TuxSH 1775d59977 thermosphere: implement stop point broadcast 2021-02-19 21:51:34 +00:00
TuxSH b2c5ef2611 thermopshere: add "execute function" sgi 2021-02-19 21:51:34 +00:00
TuxSH 0b69407f8e thermosphere: barrier & active core mask 2021-02-19 21:51:33 +00:00
TuxSH 0a9a8c2f15 thermosphere: handle physical IRQs 2021-02-19 21:51:33 +00:00
TuxSH 271d2a0ddb thermosphere: add gicv2 register definitions 2021-02-19 21:51:33 +00:00
TuxSH 6289d2e398 thermosphere: sw breakpoint code, etc. 2021-02-19 21:51:32 +00:00
TuxSH f8266775f6 thermosphere: remove breakpoint/watchpoint reg dump functions 2021-02-19 21:51:32 +00:00
TuxSH 83c6e2f0e7 thermosphere: add watchpoint + watchpoint merging code 2021-02-19 21:51:31 +00:00
TuxSH 9bc0ed2f70 thermosphere: refactor crt0 + watchpoint init 2021-02-19 21:51:31 +00:00
TuxSH dc3f87a715 thermosphere: add actual breakpoint code 2021-02-19 21:51:31 +00:00
TuxSH 3649b94b5d thermosphere: add breakpoint/watchpoint enable/reset code 2021-02-19 21:51:30 +00:00
TuxSH a3da478089 thermopshere: refactor & fix single-stepping code 2021-02-19 21:51:30 +00:00
TuxSH ff9714d4f6 thermopshere: refactor jump-to-kernel ,add single-step code
not working under qemu yet though
2021-02-19 21:51:30 +00:00
TuxSH cc232ef4f8 thermosphere: add spinlock code 2021-02-19 21:51:29 +00:00
TuxSH b742b861ab thermometer: yeet most a32 support code 👌 2021-02-19 21:51:29 +00:00
TuxSH eb27c36709 thermosphere: impl stage2 translation 2021-02-19 21:51:29 +00:00
TuxSH e0339049b3 thermosphere: rework linkscrips, use discardable sections, better sp pivot on crash 2021-02-19 21:51:28 +00:00
TuxSH e6c5eb3928 thermosphere: add shadow page table hooks
note: HCR.TVM not supported by qemu yet
2021-02-19 21:51:28 +00:00
TuxSH 045f556f80 thermosphere: enable EL2 stage1 translation (doesn't take much space)
Identity map using 1GB L1 blocks
2021-02-19 21:51:27 +00:00
TuxSH a11b0b6e0e thermosphere: fix x18 init, etc. 2021-02-19 21:51:27 +00:00
TuxSH 3fa9133814 thermosphere: add semihosting support & load a kernel using it when needed
basically host i/o
2021-02-19 21:51:27 +00:00
TuxSH ecb4857cbb thermosphere: seriaLog => debugLog, add DEBUG macro 2021-02-19 21:51:26 +00:00
TuxSH 6d33ebceef thermosphere: cpu_on hook & skeleton for other PSCI functions 2021-02-19 21:51:26 +00:00
TuxSH 4a5d05f32b thermosphere: add smc trap handler 2021-02-19 21:51:26 +00:00
TuxSH b686af2008 thermosphere: use adrp 2021-02-19 21:51:25 +00:00
TuxSH a291bddcc1 thermosphere: enable traps, works around qemu brk bug 2021-02-19 21:51:25 +00:00
TuxSH ad6db14526 thermosphere: Fix wrong register allocation 2021-02-19 21:51:25 +00:00
TuxSH 61b6f06766 thermosphere: unfuck qemu JIT, fix exc. handling bug, add cache funcs 2021-02-19 21:51:24 +00:00
TuxSH 16cfa1305d thermosphere: use x18 but qemu shits the bed 2021-02-19 21:51:24 +00:00
TuxSH af8e0f2519 thermosphere: add core_ctx.c/h 2021-02-19 21:51:24 +00:00
TuxSH a560de8465 fml coke spilled all over this laptop's keyboard 2021-02-19 21:51:23 +00:00
TuxSH 3009438e54 thermosphere: sysreg stuff, continued 2021-02-19 21:51:23 +00:00
TuxSH 9af9408feb thermosphere: add remaining sysreg passthrough stuff 2021-02-19 21:51:23 +00:00
TuxSH 68469ea862 thermosphere: more sysreg code 2021-02-19 21:51:22 +00:00
TuxSH ffa216c8c7 thermosphere: add some basic sysreg trapping code 2021-02-19 21:51:22 +00:00
TuxSH 1db0502b35 thermosphere: proper uart_reset impl for uart-b 2021-02-19 21:51:22 +00:00
TuxSH 6665245640 thermosphere: fix uart fifo init/flushing 2021-02-19 21:51:21 +00:00
TuxSH 9d6089dc86 thermosphere: rebase, fix some bugs
uart now works except for fifo flush
2021-02-19 21:51:21 +00:00
TuxSH 70a9caa7e9 thermosphere: add more sysreg stuff & start writing trap stuff 2021-02-19 21:51:21 +00:00
TuxSH 4952b3c9bf thermosphere: add sysreg list 2021-02-19 21:51:20 +00:00
TuxSH bcc72896fd thermosphere: add hypercall support... even if unused 2021-02-19 21:51:20 +00:00
TuxSH b5c6b06dad thermosphere: add ExceptionSyndromeRegister definition 2021-02-19 21:51:20 +00:00
TuxSH 4e0eef2784 thermosphere: start exception handling 2021-02-19 21:51:19 +00:00
TuxSH ada6b180cc thermosphere: add qemu support 2021-02-19 21:51:19 +00:00
TuxSH e6adccce6e thermosphere: uart fixes/ still not working 2021-02-19 21:51:19 +00:00
TuxSH f6e1cff5f8 thermosphere: rebase, doesn't work 2021-02-19 21:51:18 +00:00
TuxSH 88382f4fc3 thermosphere: uart refactor, now it doesn't work at all 2021-02-19 21:51:18 +00:00
TuxSH 66b047255b thermosphere: set correct gpio config for uart (thanks @hexkyz) 2021-02-19 21:51:18 +00:00
TuxSH 076c988796 thermosphere: attempt to output to uart-c 2021-02-19 21:51:17 +00:00
TuxSH 4e6108839d thermosphere: fix bugs:
- missing barriers after setting elr/spsr
- .text.start* matching .text.startup (which contains main, thanks @fincs)
2021-02-19 21:51:17 +00:00
TuxSH 1d58ba8d52 thermosphere: attempt to run 2021-02-19 21:51:17 +00:00
TuxSH bd9152215f thermosphere: "write" placeholder code 2021-02-19 21:51:16 +00:00
TuxSH 1f7a1f71d6 thermosphere: remove legacy code 2021-02-19 21:51:16 +00:00
Michael Scire 1545fa9d44 git subrepo push libraries
subrepo:
  subdir:   "libraries"
  merged:   "bc08912d"
upstream:
  origin:   "https://github.com/Atmosphere-NX/Atmosphere-libs"
  branch:   "master"
  commit:   "bc08912d"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"
2021-02-15 19:52:28 -08:00
Michael Scire 71add1add8 ams: bump version to 0.18.1 2021-02-15 19:51:48 -08:00
Michael Scire a96786fd2c ams: add kernel to debug elf zip 2021-02-15 19:40:00 -08:00
Michael Scire 74e4e70053 fs.mitm: fix cache of non-current-process data storages (closes #1371) 2021-02-15 19:39:32 -08:00
znxDomain 26b6216fa0 Correct ams_mitm.md formatting
Move set_mitm H3's under correct H2 element
2021-02-11 05:47:31 -08:00
Michael Scire fe5c850e69 psc: fix pm module init 2021-02-10 02:57:22 -08:00
Michael Scire 2b825d56dc usb: fix wrong command id for AppendConfigurationData 2021-02-07 17:14:48 -08:00
Michael Scire 13b17a5848 usb: add ds client api 2021-02-07 16:29:38 -08:00
Michael Scire 621520c30b kern: fix support for virtual core IDs 2021-02-05 14:59:03 -08:00
Michael Scire 846cc0b47a util: add FixedSet 2021-02-04 02:29:54 -08:00
Michael Scire e82ad1cdc5 util: add FixedMap::clear 2021-02-04 02:16:37 -08:00
Michael Scire b40da8f445 ams: add transient unit testing sysmodule to gitignore 2021-02-04 02:08:49 -08:00
Michael Scire a9c6476416 util: various FixedMap fixes 2021-02-04 02:08:21 -08:00
Michael Scire c1d93a9495 util: add FixedMap/FixedTree 2021-02-04 01:00:19 -08:00
Michael Scire 201b17f100 util: impl::AvailableIndexFinder 2021-02-03 17:47:32 -08:00
Michael Scire c0e3cee657 dns.mitm: allow nullptr for port string (closes #1352) 2021-02-03 12:41:23 -08:00
Michael Scire 26d8db74f8 git subrepo push libraries
subrepo:
  subdir:   "libraries"
  merged:   "17960517"
upstream:
  origin:   "https://github.com/Atmosphere-NX/Atmosphere-libs"
  branch:   "master"
  commit:   "17960517"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"
2021-02-02 18:33:22 -08:00
Michael Scire ee2e9d50fd hid: fix sm usage 2021-02-02 18:32:29 -08:00
Michael Scire fd1a39996e ncm: fix ContentStorageImplBase constructor 2021-02-02 17:12:02 -08:00
Michael Scire 8eb65ab401 dns.mitm: fix hosts file parsing bug 2021-02-02 17:11:53 -08:00
Michael Scire bcda834980 dns.mitm: make line ordering explicit, rather than implicit.
This doesn't actually change functionality, because this is how std::unordered_map worked anyway...

...but it's better for us to be explicit, I think.
2021-02-02 13:48:40 -08:00
Michael Scire 408b81b881 docs: fix missing meme (important) 2021-02-02 12:17:00 -08:00
Michael Scire d854b94382 git subrepo push libraries
subrepo:
  subdir:   "libraries"
  merged:   "90d85295"
upstream:
  origin:   "https://github.com/Atmosphere-NX/Atmosphere-libs"
  branch:   "master"
  commit:   "90d85295"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"
2021-02-02 12:16:49 -08:00
Michael Scire 63440cab18 ams: bump version to 0.18.0 2021-02-02 12:15:53 -08:00
Michael Scire 4fa585a23f docs: expand dns_mitm wildcard wording 2021-02-02 11:41:49 -08:00
Michael Scire e521ae805d dns.mitm: add documentation 2021-02-02 11:41:49 -08:00
Michael Scire 6950989552 dns.mitm: support % in hosts file as stand-in for environment identifier 2021-02-02 11:41:49 -08:00
Michael Scire ffbdf29c10 dns.mitm: fix ABORT_UNLESS -> ABORT 2021-02-02 11:41:49 -08:00
Michael Scire 135d42ffee dns.mitm: hint = {} fix in options 2021-02-02 11:41:49 -08:00
Michael Scire 1306d03136 dns.mitm: add GetAddrInfo redir, AtmosphereReloadHostsFile, debug logging control 2021-02-02 11:41:49 -08:00
Michael Scire 97aa209c43 dns.mitm: fix inverted hostname detection 2021-02-02 11:41:49 -08:00
Michael Scire 4ce2a6deb3 meso: update for new fatal encoding 2021-02-02 11:41:49 -08:00
Michael Scire e45d8cd7d8 ams: take three tries to edit a structure 2021-02-02 11:41:49 -08:00
Michael Scire 79211e1159 ams: afsr0 -> 32 bits in fatal error 2021-02-02 11:41:49 -08:00
Michael Scire ca8e8ce487 ams: fix fatal error context 2021-02-02 11:41:49 -08:00
Michael Scire b30311be65 dns.mitm: support wildcards in hosts 2021-02-02 11:41:49 -08:00
Michael Scire 6694d8c2d9 dns.mitm: edit default behavior/hosts filenames 2021-02-02 11:41:49 -08:00
Michael Scire 658389fc60 dns.mitm: fix issue in host file parsing 2021-02-02 11:41:49 -08:00
Michael Scire d6477cf024 dns.mitm: parse redirections from hosts file 2021-02-02 11:41:49 -08:00
Michael Scire 400f5142ee dns: implement GetHostByName redirection (backend TODO) 2021-02-02 11:41:49 -08:00
Michael Scire 8bf8df43e2 dns: skeleton passthrough mitm 2021-02-02 11:41:49 -08:00
Michael Scire a28c60970f kern: fix scheduler update semantics in KLightLock::LockSlowPath 2021-01-28 17:47:26 -08:00
Michael Scire b5f72b9f20 fssystem: fix bug in BufferedStorage 2021-01-28 14:28:45 -08:00
Michael Scire 8d10584a51 result: always prefer diag::Abort to fatal 2021-01-28 00:15:24 -08:00
Michael Scire 366c265ab2 dd: fix include, note gcc-11 TODO 2021-01-27 23:41:35 -08:00
Michael Scire 42964992d1 dmnt: ro:dmnt available on all sysvers 2021-01-27 14:44:25 -08:00
Michael Scire 4a82d9bf28 sm: supercede ams extension via DetachClient 2021-01-27 14:36:15 -08:00
Michael Scire 4190281b2f ams: communicate status to libnx 2021-01-27 14:20:30 -08:00
Michael Scire 48830d190f timespan: explicitly require TimeSpanType as is_pod 2021-01-25 08:27:42 -08:00
Michael Scire 3389aaefc3 strat: update for revised libnx weak alloc funcs 2021-01-22 03:52:10 -08:00
Michael Scire f8f987aa8d boot: remove references to memalign/malloc 2021-01-20 23:39:31 -08:00
Michael Scire e87e146112 ams_mitm: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire 5751bcc117 dmnt: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire eb1e979257 creport: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire 204539664b boot2: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire f5c6736431 boot: update for new sf-semantics 2021-01-20 23:39:31 -08:00
Michael Scire d00ebaa28a fatal: update screen task to use native window directly 2021-01-20 23:39:31 -08:00
Michael Scire 402e4d1adb fatal: wip (pending libnx pr) update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire ed7c0605f9 jpegdec: note libjpeg-turbo TODO 2021-01-20 23:39:31 -08:00
Michael Scire c848a830ee libstrat: move weak HasLaunchedBootProgram to non-lto object file 2021-01-20 23:39:31 -08:00
Michael Scire dbe8add4f4 loader: fix failure-to-early-return in launch record management 2021-01-20 23:39:31 -08:00
Michael Scire e4e278bb3d util::unique_lock, update loader to new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire 3761f80592 string_view: remove now unecessary comment 2021-01-20 23:39:31 -08:00
Michael Scire 9878c18e47 ncm: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire 3bb94aa146 util::string_view, update pgl for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire 83c04fa5d7 pm: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire dc4ee1a5bc erpt: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire 5191f0e305 ro: reduce memory usage by excising (unused) std::malloc 2021-01-20 23:39:31 -08:00
Michael Scire 170034aed3 ro: update for new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire 21236020cb sm, spl: update to use new sf semantics 2021-01-20 23:39:31 -08:00
Michael Scire f06de12bea libstrat: convert to experimental new (super-accurate) sf allocation semantics 2021-01-20 23:39:31 -08:00
474 changed files with 29198 additions and 5658 deletions

No files matched your search

+2
View File
@@ -95,3 +95,5 @@ sept/sept-secondary/KEYS.py
**/build_nintendo_nx_arm
**/build_nintendo_nx_x64
**/build_nintendo_nx_x86
stratosphere/test/
+1
View File
@@ -135,6 +135,7 @@ dist: dist-no-debug
cp exosphere/program/sc7fw/sc7fw.elf atmosphere-$(AMSVER)-debug/exosphere-sc7fw.elf
cp exosphere/program/rebootstub/rebootstub.elf atmosphere-$(AMSVER)-debug/exosphere-rebootstub.elf
cp mesosphere/kernel_ldr/kernel_ldr.elf atmosphere-$(AMSVER)-debug/kernel_ldr.elf
cp mesosphere/kernel/kernel.elf atmosphere-$(AMSVER)-debug/kernel.elf
cp stratosphere/ams_mitm/ams_mitm.elf atmosphere-$(AMSVER)-debug/ams_mitm.elf
cp stratosphere/boot/boot.elf atmosphere-$(AMSVER)-debug/boot.elf
cp stratosphere/boot2/boot2.elf atmosphere-$(AMSVER)-debug/boot2.elf
+10
View File
@@ -42,6 +42,16 @@
; enabled or disabled.
; 0 = Disabled (not debug mode), 1 = Enabled (debug mode)
; enable_am_debug_mode = u8!0x0
; Controls whether dns.mitm is enabled
; 0 = Disabled, 1 = Enabled
; enable_dns_mitm = u8!0x1
; Controls whether dns.mitm uses the default redirections in addition to
; whatever is specified in the user's hosts file.
; 0 = Disabled (use hosts file contents), 1 = Enabled (use defaults and hosts file contents)
; add_defaults_to_dns_hosts = u8!0x1
; Controls whether dns.mitm logs to the sd card for debugging
; 0 = Disabled, 1 = Enabled
; enable_dns_mitm_debug_log = u8!0x0
[hbloader]
; Controls the size of the homebrew heap when running as applet.
; If set to zero, all available applet memory is used as heap.
+26
View File
@@ -1,4 +1,30 @@
# Changelog
## 0.18.1
+ A number of minor issues were fixed, including:
+ The new `dns.mitm` module added in 0.18.0 no longer fatal errors when receiving port=nullptr.
+ This fixes youtube ad-blocking, and possibly other usecases.
+ A bug was fixed that caused ams.mitm to incorrectly cache data storages.
+ This potentially broke DLC when using romfs mods, and could have caused other issues (e.g. with custom themes, and maybe other cases).
+ A bug was fixed in power state control module registration.
+ This might fix a weird edge case with system module dependencies on sleep/wake, but probably nobody should notice any differences.
+ A bug was fixed where mesosphere sometimes treated virtual core IDs as though they were physical core IDs.
+ This had zero impact, because for Switch virtual core == physical core, but it could have affected future platforms if it had remained unresolved.
+ Several issues were fixed, and usability and stability were improved.
## 0.18.0
+ A new mitm module was added (`dns.mitm`).
+ This provides a highly configurable mechanism for redirecting DNS resolution requests.
+ By default atmosphère redirects resolution requests for official telemetry servers to a loopback address.
+ Documentation on how to configure `dns.mitm` to meet your more specific needs may be found [here](https://github.com/Atmosphere-NX/Atmosphere/blob/master/docs/features/dns_mitm.md).
+ The service framework API (`sf`) was refactored to be more accurate to official logic and greatly reduce memory requirements.
+ The comparison of atmosphère module memory usage versus Nintendo's found [here](https://github.com/Atmosphere-NX/Atmosphere/wiki/Memory-Comparisons) was updated to reflect this.
+ **Please Note**: If you are a developer using the libstratosphere service APIs, some updating may be required. Contact SciresM#0524 on discord for assistance if required.
+ A number of deprecations were removed, following a general codebase cleanup:
+ The `sm` extension to not unregister services on connection close was superseded by official opt-in logic in 11.0.0, and has been removed in favor of official logic.
+ This should have zero impact on users.
+ The temporary `hid-mitm` added in 0.9.0 has finally been removed, following over a year of deprecation.
+ There shouldn't be any homebrew in use still affected by this, but the situation will be monitored.
+ If this is somehow still a real issue, an unaffiliated hid mitm sysmodule providing the same functionality can be created and released, separate from atmosphère itself.
+ Several issues were fixed, and usability and stability were improved.
## 0.17.1
+ A number of atmosphère's modules were using more memory than their Nintendo equivalent's in 0.17.0; a number of code generatio tweaks have been applied to fix this across the board.
+ A detailed comparison of atmosphère module memory usage versus Nintendo's was made and can be found [here](https://github.com/Atmosphere-NX/Atmosphere/wiki/Memory-Comparisons).
+5
View File
@@ -33,3 +33,8 @@ in settings as `#.#.#|AMS #.#.#|?` with `? = S` when running under system eMMC o
### System Settings
set_mitm intercepts the `GetSettingsItemValueSize` and `GetSettingsItemValue` commands for all requesters.
It does so in order to enable user configuration of system settings, which are parsed from `/atmosphere/system_settings.ini` on boot. See [here](../../features/configurations.md) for more information on the system settings format.
## dns_mitm
dns_mitm enables intercepting requests to dns resolution services, to enable redirecting requests for specified hostnames.
For documentation, see [here](../../features/dns_mitm.md).
+53
View File
@@ -0,0 +1,53 @@
# DNS.mitm
As of 0.18.0, atmosphère provides a mechanism for redirecting DNS resolution requests.
By default, atmosphère redirects resolution requests for official telemetry servers, redirecting them to a loopback address.
## Hosts files
DNS.mitm can be configured through the usage of a slightly-extended `hosts` file format, which is parsed only once on system startup.
In particular, hosts files parsed by DNS.mitm have the following extensions to the usual format:
+ `*` is treated as a wildcard character, matching any collection of 0 or more characters wherever it occurs in a hostname.
+ `%` is treated as a stand-in for the value of `nsd!environment_identifier`. This is always `lp1`, on production devices.
If multiple entries in a host file match a domain, the last-defined match is used.
Please note that homebrew may trigger a hosts file re-parse by sending the extension IPC command 65000 ("AtmosphereReloadHostsFile") to a connected `sfdnsres` session.
### Hosts file selection
Atmosphère will try to read hosts from the following file paths, in order, stopping once it successfully performs a file read:
+ (emummc only) `/atmosphere/hosts/emummc_%04lx.txt`, formatted with the emummc's id number (see `emummc.ini`).
+ (emummc only) `/atmosphere/hosts/emummc.txt`.
+ (sysmmc only) `/atmosphere/hosts/sysmmc.txt`.
+ `/atmosphere/hosts/default.txt`
If `/atmosphere/hosts/default.txt` does not exist, atmosphère will create it to contain the defaults.
### Atmosphère defaults
By default, atmosphère's default redirections are parsed **in addition to** the contents of the loaded hosts file.
This is equivalent to thinking of the loaded hosts file as having the atmosphère defaults prepended to it.
This setting is considered desirable, because it minimizes the telemetry risks if a user forgets to update a custom hosts file on a system update which changes the telemetry servers.
This behavior can be opted-out from by setting `atmosphere!add_defaults_to_dns_hosts = u8!0x0` in `system_settings.ini`.
The current default redirections are:
```
# Nintendo telemetry servers
127.0.0.1 receive-%.dg.srv.nintendo.net receive-%.er.srv.nintendo.net
```
## Debugging
On startup (or on hosts file re-parse), DNS.mitm will log both what hosts file it selected and the contents of all redirections it parses to `/atmosphere/logs/dns_mitm_startup.log`.
In addition, if the user sets `atmosphere!enable_dns_mitm_debug_log = u8!0x1` in `system_settings.ini`, DNS.mitm will log all requests to GetHostByName/GetAddrInfo to `/atmosphere/logs/dns_mitm_debug.log`. All redirections will be noted when they occur.
## Opting-out of DNS.mitm entirely
If you wish to disable DNS.mitm entirely, `system_settings.ini` can be edited to set `atmosphere!enable_dns_mitm = u8!0x0`.
+29 -10
View File
@@ -35,9 +35,10 @@
static void package2_decrypt(package2_header_t *package2);
static size_t package2_get_src_section(void **section, package2_header_t *package2, unsigned int id);
static size_t package2_get_thermosphere(void **thermosphere);
static size_t package2_get_thermosphere(const void **thermosphere);
static ini1_header_t *package2_rebuild_ini1(ini1_header_t *ini1, uint32_t target_firmware, void *emummc, size_t emummc_size);
static void package2_append_section(unsigned int id, package2_header_t *package2, void *data, size_t size);
static void package2_append_section(unsigned int id, package2_header_t *package2, const void *data, size_t size);
static void package2_fixup_thermosphere_and_entrypoint(package2_header_t *package2);
static void package2_fixup_header_and_section_hashes(package2_header_t *package2, size_t size);
static inline size_t align_to_4(size_t s) {
@@ -50,7 +51,7 @@ void package2_rebuild_and_copy(package2_header_t *package2, uint32_t target_firm
void *kernel;
size_t kernel_size;
bool is_sd_kernel = false;
void *thermosphere;
const void *thermosphere;
size_t thermosphere_size;
ini1_header_t *orig_ini1, *rebuilt_ini1;
@@ -67,6 +68,8 @@ void package2_rebuild_and_copy(package2_header_t *package2, uint32_t target_firm
fatal_error(u8"Error: Package2 has no unused section for Thermosphère!\n");
}
package2->metadata.section_offsets[PACKAGE2_SECTION_UNUSED] = 0; /* base of DRAM */
/* Load Kernel from SD, if possible. */
{
size_t sd_kernel_size = get_file_size("atmosphere/kernel.bin");
@@ -143,6 +146,9 @@ void package2_rebuild_and_copy(package2_header_t *package2, uint32_t target_firm
package2_append_section(PACKAGE2_SECTION_INI1, rebuilt_package2, rebuilt_ini1, rebuilt_ini1->size);
package2_append_section(PACKAGE2_SECTION_UNUSED, rebuilt_package2, thermosphere, thermosphere_size);
/* Swap entrypoint if Thermosphère is present */
package2_fixup_thermosphere_and_entrypoint(rebuilt_package2);
/* Fix all necessary data in the header to accomodate for the new patches. */
package2_fixup_header_and_section_hashes(rebuilt_package2, rebuilt_package2_size);
@@ -327,12 +333,9 @@ static size_t package2_get_src_section(void **section, package2_header_t *packag
return package2->metadata.section_sizes[id];
}
static size_t package2_get_thermosphere(void **thermosphere) {
/*extern const uint8_t thermosphere_bin[];
extern const uint32_t thermosphere_bin_size;*/
/* TODO: enable when tested. */
(*thermosphere) = NULL;
return 0;
static size_t package2_get_thermosphere(const void **thermosphere) {
(*thermosphere) = thermosphere_bin;
return thermosphere_bin_size;
}
static ini1_header_t *package2_rebuild_ini1(ini1_header_t *ini1, uint32_t target_firmware, void *emummc, size_t emummc_size) {
@@ -353,7 +356,7 @@ static ini1_header_t *package2_rebuild_ini1(ini1_header_t *ini1, uint32_t target
return merged;
}
static void package2_append_section(unsigned int id, package2_header_t *package2, void *data, size_t size) {
static void package2_append_section(unsigned int id, package2_header_t *package2, const void *data, size_t size) {
/* This function must be called in ascending order of id. */
/* We assume that the loading address doesn't need to be changed. */
uint8_t *dst = package2->data;
@@ -365,6 +368,22 @@ static void package2_append_section(unsigned int id, package2_header_t *package2
package2->metadata.section_sizes[id] = align_to_4(size);
}
static void package2_fixup_thermosphere_and_entrypoint(package2_header_t *package2) {
/* Return if Thermosphère is not present */
if (package2->metadata.section_sizes[PACKAGE2_SECTION_UNUSED] == 0) {
return;
}
uint8_t *dst = package2->data;
for (unsigned int i = 0; i < PACKAGE2_SECTION_UNUSED; i++) {
dst += package2->metadata.section_sizes[i];
}
/* Swap kernel entrypoint with Thermosphère */
*(uint64_t *)(dst + 8) = DRAM_BASE_PHYSICAL + package2->metadata.entrypoint;
package2->metadata.entrypoint = 0;
}
static void package2_fixup_header_and_section_hashes(package2_header_t *package2, size_t size) {
uint8_t *data = package2->data;
+1
View File
@@ -59,6 +59,7 @@
#define PACKAGE2_MINVER_1100_CURRENT 0x10
#define NX_BOOTLOADER_PACKAGE2_LOAD_ADDRESS ((void *)(0xA9800000ull))
#define DRAM_BASE_PHYSICAL (0x80000000)
typedef struct {
union {
+2 -2
View File
@@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/Atmosphere-NX/Atmosphere-libs
branch = master
commit = 6c11c07e2a7f03952a4e70eb89b47bf528de39c6
parent = 9e104bb83f1302e9f126542fbf57c7f666aae953
commit = bc08912dd31bb172467add8e24b4f0adac431939
parent = 71add1add8521e0c2115ec612c514400ac7ba688
method = merge
cmdver = 0.4.1
@@ -45,7 +45,21 @@
namespace ams::kern {
static_assert(cpu::NumCores <= static_cast<s32>(BITSIZEOF(u64)));
static_assert(util::size(cpu::VirtualToPhysicalCoreMap) == BITSIZEOF(u64));
namespace cpu {
static constexpr inline size_t NumVirtualCores = BITSIZEOF(u64);
static constexpr inline u64 VirtualCoreMask = [] {
u64 mask = 0;
for (size_t i = 0; i < NumVirtualCores; ++i) {
mask |= (UINT64_C(1) << i);
}
return mask;
}();
}
static_assert(cpu::NumCores <= cpu::NumVirtualCores);
static_assert(util::size(cpu::VirtualToPhysicalCoreMap) == cpu::NumVirtualCores);
}
@@ -314,12 +314,12 @@ namespace ams::kern::board::nintendo::nx {
g_secure_applet_memory_used = false;
}
u64 GetVersionIdentifier() {
u64 value = kern::GetTargetFirmware();
value |= static_cast<u64>(ATMOSPHERE_RELEASE_VERSION_MICRO) << 32;
value |= static_cast<u64>(ATMOSPHERE_RELEASE_VERSION_MINOR) << 40;
value |= static_cast<u64>(ATMOSPHERE_RELEASE_VERSION_MAJOR) << 48;
value |= static_cast<u64>('M') << 56;
u32 GetVersionIdentifier() {
u32 value = 0;
value |= static_cast<u64>(ATMOSPHERE_RELEASE_VERSION_MICRO) << 0;
value |= static_cast<u64>(ATMOSPHERE_RELEASE_VERSION_MINOR) << 8;
value |= static_cast<u64>(ATMOSPHERE_RELEASE_VERSION_MAJOR) << 16;
value |= static_cast<u64>('M') << 24;
return value;
}
@@ -584,8 +584,8 @@ namespace ams::kern::board::nintendo::nx {
f_ctx->module_base = KMemoryLayout::GetKernelCodeRegionExtents().GetAddress();
/* Set afsr1. */
f_ctx->afsr0 = 0;
f_ctx->afsr1 = GetVersionIdentifier();
f_ctx->afsr0 = GetVersionIdentifier();
f_ctx->afsr1 = static_cast<u32>(kern::GetTargetFirmware());
/* Set efsr/far. */
f_ctx->far = cpu::GetFarEl1();
@@ -22,7 +22,7 @@ namespace ams::kern {
/* Most fields have already been cleared by our constructor. */
/* Initial processes may run on all cores. */
m_core_mask = (1ul << cpu::NumCores) - 1;
m_core_mask = cpu::VirtualCoreMask;
/* Initial processes may use any user priority they like. */
m_priority_mask = ~0xFul;
@@ -57,16 +57,15 @@ namespace ams::kern {
R_UNLESS(min_core <= max_core, svc::ResultInvalidCombination());
R_UNLESS(min_prio <= max_prio, svc::ResultInvalidCombination());
R_UNLESS(max_core < cpu::NumCores, svc::ResultInvalidCoreId());
R_UNLESS(max_core < cpu::NumVirtualCores, svc::ResultInvalidCoreId());
MESOSPHERE_ASSERT(max_core < BITSIZEOF(u64));
MESOSPHERE_ASSERT(max_prio < BITSIZEOF(u64));
/* Set core mask. */
for (auto core_id = min_core; core_id <= max_core; core_id++) {
m_core_mask |= (1ul << core_id);
}
MESOSPHERE_ASSERT((m_core_mask & ((1ul << cpu::NumCores) - 1)) == m_core_mask);
MESOSPHERE_ASSERT((m_core_mask & cpu::VirtualCoreMask) == m_core_mask);
/* Set priority mask. */
for (auto prio = min_prio; prio <= max_prio; prio++) {
@@ -43,7 +43,6 @@ namespace ams::kern {
if (owner_thread->IsSuspended()) {
owner_thread->ContinueIfHasKernelWaiters();
KScheduler::SetSchedulerUpdateNeeded();
}
}
@@ -53,6 +52,7 @@ namespace ams::kern {
KThread *owner_thread = cur_thread->GetLockOwner();
if (AMS_UNLIKELY(owner_thread)) {
owner_thread->RemoveWaiter(cur_thread);
KScheduler::SetSchedulerUpdateNeeded();
}
}
}
@@ -216,7 +216,7 @@ namespace ams::kern::svc {
case ams::svc::InfoType_ThreadTickCount:
{
/* Verify the requested core is valid. */
const bool core_valid = (info_subtype == static_cast<u64>(-1ul)) || (info_subtype < util::size(cpu::VirtualToPhysicalCoreMap));
const bool core_valid = (info_subtype == static_cast<u64>(-1ul)) || (info_subtype < cpu::NumVirtualCores);
R_UNLESS(core_valid, svc::ResultInvalidCombination());
/* Get the thread from its handle. */
@@ -21,8 +21,8 @@ namespace ams::kern::svc {
namespace {
constexpr bool IsValidCoreId(int32_t core_id) {
return (0 <= core_id && core_id < static_cast<int32_t>(cpu::NumCores));
constexpr bool IsValidVirtualCoreId(int32_t core_id) {
return (0 <= core_id && core_id < static_cast<int32_t>(cpu::NumVirtualCores));
}
void ExitProcess() {
@@ -275,7 +275,7 @@ namespace ams::kern::svc {
R_UNLESS(process.IsNotNull(), svc::ResultInvalidHandle());
/* Validate the core id. */
R_UNLESS(IsValidCoreId(core_id), svc::ResultInvalidCoreId());
R_UNLESS(IsValidVirtualCoreId(core_id), svc::ResultInvalidCoreId());
R_UNLESS(((1ul << core_id) & process->GetCoreMask()) != 0, svc::ResultInvalidCoreId());
/* Validate the priority. */
@@ -21,8 +21,8 @@ namespace ams::kern::svc {
namespace {
constexpr bool IsValidCoreId(int32_t core_id) {
return (0 <= core_id && core_id < static_cast<int32_t>(cpu::NumCores));
constexpr bool IsValidVirtualCoreId(int32_t core_id) {
return (0 <= core_id && core_id < static_cast<int32_t>(cpu::NumVirtualCores));
}
Result CreateThread(ams::svc::Handle *out, ams::svc::ThreadFunc f, uintptr_t arg, uintptr_t stack_bottom, int32_t priority, int32_t core_id) {
@@ -33,7 +33,7 @@ namespace ams::kern::svc {
}
/* Validate arguments. */
R_UNLESS(IsValidCoreId(core_id), svc::ResultInvalidCoreId());
R_UNLESS(IsValidVirtualCoreId(core_id), svc::ResultInvalidCoreId());
R_UNLESS(((1ul << core_id) & process.GetCoreMask()) != 0, svc::ResultInvalidCoreId());
R_UNLESS(ams::svc::HighestThreadPriority <= priority && priority <= ams::svc::LowestThreadPriority, svc::ResultInvalidPriority());
@@ -168,7 +168,7 @@ namespace ams::kern::svc {
R_UNLESS(affinity_mask != 0, svc::ResultInvalidCombination());
/* Validate the core id. */
if (IsValidCoreId(core_id)) {
if (IsValidVirtualCoreId(core_id)) {
R_UNLESS(((1ul << core_id) & affinity_mask) != 0, svc::ResultInvalidCombination());
} else {
R_UNLESS(core_id == ams::svc::IdealCoreNoUpdate || core_id == ams::svc::IdealCoreDontCare, svc::ResultInvalidCoreId());
+4
View File
@@ -18,6 +18,7 @@ include $(DEVKITPRO)/libnx/switch_rules
# options for code generation
#---------------------------------------------------------------------------------
PRECOMPILED_HEADERS := $(CURRENT_DIRECTORY)/include/stratosphere.hpp
#PRECOMPILED_HEADERS :=
DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_STRATOSPHERE -D_GNU_SOURCE
SETTINGS := $(ATMOSPHERE_SETTINGS) -O2
@@ -121,6 +122,9 @@ $(OFILES) : $(GCH_FILES)
$(OFILES_SRC) : $(HFILES_BIN)
ams_environment_weak.o: CXXFLAGS += -fno-lto
pm_info_api_weak.o: CXXFLAGS += -fno-lto
#---------------------------------------------------------------------------------
%_bin.h %.bin.o : %.bin
#---------------------------------------------------------------------------------
@@ -61,6 +61,7 @@
#include <stratosphere/ncm.hpp>
#include <stratosphere/nim.hpp>
#include <stratosphere/ns.hpp>
#include <stratosphere/nsd.hpp>
#include <stratosphere/patcher.hpp>
#include <stratosphere/pcv.hpp>
#include <stratosphere/pgl.hpp>
@@ -74,9 +75,11 @@
#include <stratosphere/settings.hpp>
#include <stratosphere/sf.hpp>
#include <stratosphere/sm.hpp>
#include <stratosphere/socket.hpp>
#include <stratosphere/spl.hpp>
#include <stratosphere/time.hpp>
#include <stratosphere/updater.hpp>
#include <stratosphere/usb.hpp>
#include <stratosphere/wec.hpp>
/* Include FS last. */
@@ -22,6 +22,9 @@ namespace ams::emummc {
/* Get whether emummc is active. */
bool IsActive();
/* Get the active emummc id. */
u32 GetActiveId();
/* Get Nintendo redirection path. */
const char *GetNintendoDirPath();
@@ -26,4 +26,7 @@ namespace ams {
void InitializeForBoot();
void SetInitialRebootPayload(const void *src, size_t src_size);
void *Malloc(size_t size);
void Free(void *ptr);
}
@@ -113,6 +113,9 @@ namespace ams::impl {
AMS_DEFINE_SYSTEM_THREAD(21, erpt, Main);
AMS_DEFINE_SYSTEM_THREAD(21, erpt, IpcServer);
/* socket. */
AMS_DEFINE_SYSTEM_THREAD(29, socket, ResolverIpcServer);
/* jpegdec. */
AMS_DEFINE_SYSTEM_THREAD(21, jpegdec, Main);
@@ -13,15 +13,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/dd/dd_types.hpp>
namespace ams::dd {
using ProcessHandle = ::Handle;
/* TODO gcc-11: using MemoryPermission = os::MemoryPermission; using enum os::MemoryPermission; */
enum MemoryPermission {
MemoryPermission_None = 0,
MemoryPermission_ReadOnly = (1u << 0),
@@ -17,16 +17,12 @@
#include <vapours.hpp>
#include <stratosphere/erpt/erpt_types.hpp>
namespace ams::erpt::sf {
#define AMS_ERPT_I_ATTACHMENT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Open, (const erpt::AttachmentId &attachment_id), (attachment_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Read, (ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer), (out_count, out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetFlags, (erpt::AttachmentFlagSet flags), (flags)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetFlags, (ams::sf::Out<erpt::AttachmentFlagSet> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, Close, (), ()) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetSize, (ams::sf::Out<s64> out), (out))
#define AMS_ERPT_I_ATTACHMENT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Open, (const AttachmentId &attachment_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Read, (ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetFlags, (AttachmentFlagSet flags)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetFlags, (ams::sf::Out<AttachmentFlagSet> out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, Close, ()) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetSize, (ams::sf::Out<s64> out))
AMS_SF_DEFINE_INTERFACE(IAttachment, AMS_ERPT_I_ATTACHMENT_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::erpt::sf, IAttachment, AMS_ERPT_I_ATTACHMENT_INTERFACE_INFO)
@@ -20,24 +20,20 @@
#include <stratosphere/erpt/erpt_multiple_category_context.hpp>
#include <stratosphere/time/time_steady_clock_time_point.hpp>
namespace ams::erpt::sf {
#define AMS_ERPT_I_CONTEXT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SubmitContext, (const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreateReportV0, (ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &meta_buffer)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetInitialLaunchSettingsCompletionTime, (const time::SteadyClockTimePoint &time_point), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, ClearInitialLaunchSettingsCompletionTime, (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, UpdatePowerOnTime, (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, UpdateAwakeTime, (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SubmitMultipleCategoryContext, (const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, UpdateApplicationLaunchTime, (), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, ClearApplicationLaunchTime, (), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, SubmitAttachment, (ams::sf::Out<AttachmentId> out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data), hos::Version_8_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, CreateReportWithAttachmentsDeprecated, (ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &attachment_ids_buffer), hos::Version_8_0_0, hos::Version_10_2_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, CreateReportWithAttachments, (ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &attachment_ids_buffer, Result result), hos::Version_11_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, CreateReport, (ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &meta_buffer, Result result), hos::Version_11_0_0)
#define AMS_ERPT_I_CONTEXT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SubmitContext, (const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer), (ctx_buffer, str_buffer)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreateReportV0, (erpt::ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &meta_buffer), (report_type, ctx_buffer, str_buffer, meta_buffer)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetInitialLaunchSettingsCompletionTime, (const time::SteadyClockTimePoint &time_point), (time_point), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, ClearInitialLaunchSettingsCompletionTime, (), (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, UpdatePowerOnTime, (), (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, UpdateAwakeTime, (), (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SubmitMultipleCategoryContext, (const erpt::MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer), (ctx_entry, str_buffer), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, UpdateApplicationLaunchTime, (), (), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, ClearApplicationLaunchTime, (), (), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, SubmitAttachment, (ams::sf::Out<erpt::AttachmentId> out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data), (out, attachment_name, attachment_data), hos::Version_8_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, CreateReportWithAttachmentsDeprecated, (erpt::ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &attachment_ids_buffer), (report_type, ctx_buffer, str_buffer, attachment_ids_buffer), hos::Version_8_0_0, hos::Version_10_2_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, CreateReportWithAttachments, (erpt::ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &attachment_ids_buffer, Result result), (report_type, ctx_buffer, str_buffer, attachment_ids_buffer, result), hos::Version_11_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, CreateReport, (erpt::ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &meta_buffer, Result result), (report_type, ctx_buffer, str_buffer, meta_buffer, result), hos::Version_11_0_0)
AMS_SF_DEFINE_INTERFACE(IContext, AMS_ERPT_I_CONTEXT_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::erpt::sf, IContext, AMS_ERPT_I_CONTEXT_INTERFACE_INFO)
@@ -17,17 +17,13 @@
#include <vapours.hpp>
#include <stratosphere/erpt/erpt_types.hpp>
namespace ams::erpt::sf {
#define AMS_ERPT_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetReportList, (const ams::sf::OutBuffer &out_list, ReportType type_filter)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetEvent, (ams::sf::OutCopyHandle out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, CleanupReports, (), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, DeleteReport, (const ReportId &report_id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetStorageUsageStatistics, (ams::sf::Out<StorageUsageStatistics> out), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetAttachmentList, (const ams::sf::OutBuffer &out_buf, const ReportId &report_id), hos::Version_8_0_0)
#define AMS_ERPT_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetReportList, (const ams::sf::OutBuffer &out_list, erpt::ReportType type_filter), (out_list, type_filter)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetEvent, (ams::sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, CleanupReports, (), (), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, DeleteReport, (const erpt::ReportId &report_id), (report_id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetStorageUsageStatistics, (ams::sf::Out<erpt::StorageUsageStatistics> out), (out), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetAttachmentList, (const ams::sf::OutBuffer &out_buf, const erpt::ReportId &report_id), (out_buf, report_id), hos::Version_8_0_0)
AMS_SF_DEFINE_INTERFACE(IManager, AMS_ERPT_I_MANAGER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::erpt::sf, IManager, AMS_ERPT_I_MANAGER_INTERFACE_INFO)
@@ -17,17 +17,12 @@
#include <vapours.hpp>
#include <stratosphere/erpt/erpt_types.hpp>
namespace ams::erpt::sf {
#define AMS_ERPT_I_REPORT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Open, (const erpt::ReportId &report_id), (report_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Read, (ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer), (out_count, out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetFlags, (erpt::ReportFlagSet flags), (flags)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetFlags, (ams::sf::Out<erpt::ReportFlagSet> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, Close, (), ()) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetSize, (ams::sf::Out<s64> out), (out))
#define AMS_ERPT_I_REPORT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Open, (const ReportId &report_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Read, (ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetFlags, (ReportFlagSet flags)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetFlags, (ams::sf::Out<ReportFlagSet> out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, Close, ()) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetSize, (ams::sf::Out<s64> out))
AMS_SF_DEFINE_INTERFACE(IReport, AMS_ERPT_I_REPORT_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::erpt::sf, IReport, AMS_ERPT_I_REPORT_INTERFACE_INFO)
@@ -20,13 +20,9 @@
#include <stratosphere/erpt/sf/erpt_sf_i_manager.hpp>
#include <stratosphere/erpt/sf/erpt_sf_i_attachment.hpp>
namespace ams::erpt::sf {
#define AMS_ERPT_I_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenReport, (ams::sf::Out<ams::sf::SharedPointer<erpt::sf::IReport>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenManager, (ams::sf::Out<ams::sf::SharedPointer<erpt::sf::IManager>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenAttachment, (ams::sf::Out<ams::sf::SharedPointer<erpt::sf::IAttachment>> out), (out), hos::Version_8_0_0)
#define AMS_ERPT_I_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenReport, (ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenManager, (ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenAttachment, (ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out), hos::Version_8_0_0)
AMS_SF_DEFINE_INTERFACE(ISession, AMS_ERPT_I_SESSION_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::erpt::sf, ISession, AMS_ERPT_I_SESSION_INTERFACE_INFO)
@@ -19,11 +19,7 @@
#include <stratosphere/fatal/fatal_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::fatal::impl {
#define AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetFatalEvent, (sf::OutCopyHandle out_h), (out_h))
#define AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetFatalEvent, (sf::OutCopyHandle out_h))
AMS_SF_DEFINE_INTERFACE(IPrivateService, AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::fatal::impl, IPrivateService, AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO)
@@ -19,13 +19,9 @@
#include <stratosphere/fatal/fatal_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::fatal::impl {
#define AMS_FATAL_I_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ThrowFatal, (Result error, const sf::ClientProcessId &client_pid), (error, client_pid)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, ThrowFatalWithPolicy, (Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy), (error, client_pid, policy)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ThrowFatalWithCpuContext, (Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy, const fatal::CpuContext &cpu_ctx), (error, client_pid, policy, cpu_ctx))
#define AMS_FATAL_I_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ThrowFatal, (Result error, const sf::ClientProcessId &client_pid)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, ThrowFatalWithPolicy, (Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ThrowFatalWithCpuContext, (Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx))
AMS_SF_DEFINE_INTERFACE(IService, AMS_FATAL_I_SERVICE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::fatal::impl, IService, AMS_FATAL_I_SERVICE_INTERFACE_INFO)
@@ -37,14 +37,14 @@ namespace ams::fssrv::impl {
class FileSystemInterfaceAdapter;
class FileInterfaceAdapter final {
class FileInterfaceAdapter {
NON_COPYABLE(FileInterfaceAdapter);
private:
std::shared_ptr<FileSystemInterfaceAdapter> parent_filesystem;
ams::sf::SharedPointer<FileSystemInterfaceAdapter> parent_filesystem;
std::unique_ptr<fs::fsa::IFile> base_file;
std::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
public:
FileInterfaceAdapter(std::unique_ptr<fs::fsa::IFile> &&file, std::shared_ptr<FileSystemInterfaceAdapter> &&parent, std::unique_lock<fssystem::SemaphoreAdapter> &&sema);
FileInterfaceAdapter(std::unique_ptr<fs::fsa::IFile> &&file, FileSystemInterfaceAdapter *parent, util::unique_lock<fssystem::SemaphoreAdapter> &&sema);
~FileInterfaceAdapter();
private:
void InvalidateCache();
@@ -59,14 +59,14 @@ namespace ams::fssrv::impl {
};
static_assert(fssrv::sf::IsIFile<FileInterfaceAdapter>);
class DirectoryInterfaceAdapter final {
class DirectoryInterfaceAdapter {
NON_COPYABLE(DirectoryInterfaceAdapter);
private:
std::shared_ptr<FileSystemInterfaceAdapter> parent_filesystem;
ams::sf::SharedPointer<FileSystemInterfaceAdapter> parent_filesystem;
std::unique_ptr<fs::fsa::IDirectory> base_dir;
std::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
public:
DirectoryInterfaceAdapter(std::unique_ptr<fs::fsa::IDirectory> &&dir, std::shared_ptr<FileSystemInterfaceAdapter> &&parent, std::unique_lock<fssystem::SemaphoreAdapter> &&sema);
DirectoryInterfaceAdapter(std::unique_ptr<fs::fsa::IDirectory> &&dir, FileSystemInterfaceAdapter *parent, util::unique_lock<fssystem::SemaphoreAdapter> &&sema);
~DirectoryInterfaceAdapter();
public:
/* Command API */
@@ -75,11 +75,11 @@ namespace ams::fssrv::impl {
};
static_assert(fssrv::sf::IsIDirectory<DirectoryInterfaceAdapter>);
class FileSystemInterfaceAdapter final : public std::enable_shared_from_this<FileSystemInterfaceAdapter> {
class FileSystemInterfaceAdapter : public ams::sf::ISharedObject {
NON_COPYABLE(FileSystemInterfaceAdapter);
private:
std::shared_ptr<fs::fsa::IFileSystem> base_fs;
std::unique_lock<fssystem::SemaphoreAdapter> mount_count_semaphore;
util::unique_lock<fssystem::SemaphoreAdapter> mount_count_semaphore;
os::ReadWriteLock invalidation_lock;
bool open_count_limited;
bool deep_retry_enabled = false;
@@ -103,8 +103,8 @@ namespace ams::fssrv::impl {
Result RenameFile(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path);
Result RenameDirectory(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path);
Result GetEntryType(ams::sf::Out<u32> out, const fssrv::sf::Path &path);
Result OpenFile(ams::sf::Out<std::shared_ptr<fssrv::sf::IFile>> out, const fssrv::sf::Path &path, u32 mode);
Result OpenDirectory(ams::sf::Out<std::shared_ptr<fssrv::sf::IDirectory>> out, const fssrv::sf::Path &path, u32 mode);
Result OpenFile(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFile>> out, const fssrv::sf::Path &path, u32 mode);
Result OpenDirectory(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IDirectory>> out, const fssrv::sf::Path &path, u32 mode);
Result Commit();
Result GetFreeSpaceSize(ams::sf::Out<s64> out, const fssrv::sf::Path &path);
Result GetTotalSpaceSize(ams::sf::Out<s64> out, const fssrv::sf::Path &path);
@@ -27,19 +27,19 @@ namespace ams::fs {
namespace ams::fssrv::impl {
class StorageInterfaceAdapter final {
class StorageInterfaceAdapter {
NON_COPYABLE(StorageInterfaceAdapter);
private:
/* TODO: Nintendo uses fssystem::AsynchronousAccessStorage here. */
std::shared_ptr<fs::IStorage> base_storage;
std::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
os::ReadWriteLock invalidation_lock;
/* TODO: DataStorageContext. */
bool deep_retry_enabled = false;
public:
StorageInterfaceAdapter(fs::IStorage *storage);
StorageInterfaceAdapter(std::unique_ptr<fs::IStorage> storage);
explicit StorageInterfaceAdapter(std::shared_ptr<fs::IStorage> &&storage);
explicit StorageInterfaceAdapter(std::shared_ptr<fs::IStorage> storage);
/* TODO: Other constructors. */
~StorageInterfaceAdapter();
@@ -18,12 +18,8 @@
#include <stratosphere/sf.hpp>
#include <stratosphere/fs/fs_directory.hpp>
namespace ams::fssrv::sf {
#define AMS_FSSRV_I_DIRECTORY_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (ams::sf::Out<s64> out, const ams::sf::OutBuffer &out_entries), (out, out_entries)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetEntryCount, (ams::sf::Out<s64> out), (out))
#define AMS_FSSRV_I_DIRECTORY_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (ams::sf::Out<s64> out, const ams::sf::OutBuffer &out_entries)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetEntryCount, (ams::sf::Out<s64> out))
AMS_SF_DEFINE_INTERFACE(IDirectory, AMS_FSSRV_I_DIRECTORY_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::fssrv::sf, IDirectory, AMS_FSSRV_I_DIRECTORY_INTERFACE_INFO)
@@ -19,16 +19,12 @@
#include <stratosphere/fs/fs_file.hpp>
#include <stratosphere/fs/fs_query_range.hpp>
namespace ams::fssrv::sf {
#define AMS_FSSRV_I_FILE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (ams::sf::Out<s64> out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, ams::fs::ReadOption option), (out, offset, buffer, size, option)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Write, (s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size, ams::fs::WriteOption option), (offset, buffer, size, option)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Flush, (), ()) \
AMS_SF_METHOD_INFO(C, H, 3, Result, SetSize, (s64 size), (size)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetSize, (ams::sf::Out<s64> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, OperateRange, (ams::sf::Out<ams::fs::FileQueryRangeInfo> out, s32 op_id, s64 offset, s64 size), (out, op_id, offset, size), hos::Version_4_0_0)
#define AMS_FSSRV_I_FILE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (ams::sf::Out<s64> out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, ams::fs::ReadOption option)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Write, (s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size, ams::fs::WriteOption option)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Flush, ()) \
AMS_SF_METHOD_INFO(C, H, 3, Result, SetSize, (s64 size)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetSize, (ams::sf::Out<s64> out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, OperateRange, (ams::sf::Out<ams::fs::FileQueryRangeInfo> out, s32 op_id, s64 offset, s64 size), hos::Version_4_0_0) \
AMS_SF_DEFINE_INTERFACE(IFile, AMS_FSSRV_I_FILE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::fssrv::sf, IFile, AMS_FSSRV_I_FILE_INTERFACE_INFO)
@@ -22,26 +22,22 @@
#include <stratosphere/fssrv/sf/fssrv_sf_ifile.hpp>
#include <stratosphere/fssrv/sf/fssrv_sf_idirectory.hpp>
namespace ams::fssrv::sf {
#define AMS_FSSRV_I_FILESYSTEM_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, CreateFile, (const ams::fssrv::sf::Path &path, s64 size, s32 option), (path, size, option)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, DeleteFile, (const ams::fssrv::sf::Path &path), (path)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, CreateDirectory, (const ams::fssrv::sf::Path &path), (path)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, DeleteDirectory, (const ams::fssrv::sf::Path &path), (path)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, DeleteDirectoryRecursively, (const ams::fssrv::sf::Path &path), (path)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RenameFile, (const ams::fssrv::sf::Path &old_path, const ams::fssrv::sf::Path &new_path), (old_path, new_path)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, RenameDirectory, (const ams::fssrv::sf::Path &old_path, const ams::fssrv::sf::Path &new_path), (old_path, new_path)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetEntryType, (ams::sf::Out<u32> out, const ams::fssrv::sf::Path &path), (out, path)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, OpenFile, (ams::sf::Out<ams::sf::SharedPointer<ams::fssrv::sf::IFile>> out, const ams::fssrv::sf::Path &path, u32 mode), (out, path, mode)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, OpenDirectory, (ams::sf::Out<ams::sf::SharedPointer<ams::fssrv::sf::IDirectory>> out, const ams::fssrv::sf::Path &path, u32 mode), (out, path, mode)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, Commit, (), ()) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetFreeSpaceSize, (ams::sf::Out<s64> out, const ams::fssrv::sf::Path &path), (out, path)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetTotalSpaceSize, (ams::sf::Out<s64> out, const ams::fssrv::sf::Path &path), (out, path)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, CleanDirectoryRecursively, (const ams::fssrv::sf::Path &path), (path), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetFileTimeStampRaw, (ams::sf::Out<ams::fs::FileTimeStampRaw> out, const ams::fssrv::sf::Path &path), (out, path), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 15, Result, QueryEntry, (const ams::sf::OutBuffer &out_buf, const ams::sf::InBuffer &in_buf, s32 query_id, const ams::fssrv::sf::Path &path), (out_buf, in_buf, query_id, path), hos::Version_4_0_0)
#define AMS_FSSRV_I_FILESYSTEM_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, CreateFile, (const ams::fssrv::sf::Path &path, s64 size, s32 option)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, DeleteFile, (const ams::fssrv::sf::Path &path)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, CreateDirectory, (const ams::fssrv::sf::Path &path)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, DeleteDirectory, (const ams::fssrv::sf::Path &path)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, DeleteDirectoryRecursively, (const ams::fssrv::sf::Path &path)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RenameFile, (const ams::fssrv::sf::Path &old_path, const ams::fssrv::sf::Path &new_path)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, RenameDirectory, (const ams::fssrv::sf::Path &old_path, const ams::fssrv::sf::Path &new_path)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetEntryType, (ams::sf::Out<u32> out, const ams::fssrv::sf::Path &path)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, OpenFile, (ams::sf::Out<std::shared_ptr<ams::fssrv::sf::IFile>> out, const ams::fssrv::sf::Path &path, u32 mode)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, OpenDirectory, (ams::sf::Out<std::shared_ptr<ams::fssrv::sf::IDirectory>> out, const ams::fssrv::sf::Path &path, u32 mode)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, Commit, ()) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetFreeSpaceSize, (ams::sf::Out<s64> out, const ams::fssrv::sf::Path &path)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetTotalSpaceSize, (ams::sf::Out<s64> out, const ams::fssrv::sf::Path &path)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, CleanDirectoryRecursively, (const ams::fssrv::sf::Path &path), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetFileTimeStampRaw, (ams::sf::Out<ams::fs::FileTimeStampRaw> out, const ams::fssrv::sf::Path &path), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 15, Result, QueryEntry, (const ams::sf::OutBuffer &out_buf, const ams::sf::InBuffer &in_buf, s32 query_id, const ams::fssrv::sf::Path &path), hos::Version_4_0_0)
AMS_SF_DEFINE_INTERFACE(IFileSystem, AMS_FSSRV_I_FILESYSTEM_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::fssrv::sf, IFileSystem, AMS_FSSRV_I_FILESYSTEM_INTERFACE_INFO)
@@ -19,16 +19,12 @@
#include <stratosphere/fs/fs_file.hpp>
#include <stratosphere/fs/fs_query_range.hpp>
namespace ams::fssrv::sf {
#define AMS_FSSRV_I_STORAGE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size), (offset, buffer, size)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Write, (s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size), (offset, buffer, size)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Flush, (), ()) \
AMS_SF_METHOD_INFO(C, H, 3, Result, SetSize, (s64 size), (size)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetSize, (ams::sf::Out<s64> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, OperateRange, (ams::sf::Out<ams::fs::StorageQueryRangeInfo> out, s32 op_id, s64 offset, s64 size), (out, op_id, offset, size), hos::Version_4_0_0)
#define AMS_FSSRV_I_STORAGE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Write, (s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Flush, ()) \
AMS_SF_METHOD_INFO(C, H, 3, Result, SetSize, (s64 size)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetSize, (ams::sf::Out<s64> out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, OperateRange, (ams::sf::Out<ams::fs::StorageQueryRangeInfo> out, s32 op_id, s64 offset, s64 size), hos::Version_4_0_0)
AMS_SF_DEFINE_INTERFACE(IStorage, AMS_FSSRV_I_STORAGE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::fssrv::sf, IStorage, AMS_FSSRV_I_STORAGE_INTERFACE_INFO)
@@ -23,6 +23,6 @@ namespace ams::gpio {
void Initialize();
void Finalize();
void InitializeWith(std::shared_ptr<gpio::sf::IManager> &&sp);
void InitializeWith(ams::sf::SharedPointer<gpio::sf::IManager> sp);
}
@@ -20,6 +20,6 @@
namespace ams::gpio::server {
std::shared_ptr<gpio::sf::IManager> GetServiceObject();
ams::sf::SharedPointer<gpio::sf::IManager> GetServiceObject();
}
@@ -21,21 +21,17 @@
#include <stratosphere/gpio/gpio_select_pad_name.hpp>
#include <stratosphere/gpio/sf/gpio_sf_i_pad_session.hpp>
namespace ams::gpio::sf {
#define AMS_GPIO_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, s32 pad_descriptor), (out, pad_descriptor) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name), (out, pad_name) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenSessionForTest, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name), (out, pad_name) ) \
AMS_SF_METHOD_INFO(C, H, 3, Result, IsWakeEventActive, (ams::sf::Out<bool> out, gpio::GpioPadName pad_name), (out, pad_name), hos::Version_Min, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetWakeEventActiveFlagSet, (ams::sf::Out<gpio::WakeBitFlag> out), (out), hos::Version_Min, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, SetWakeEventActiveFlagSetForDebug, (gpio::GpioPadName pad_name, bool is_enabled), (pad_name, is_enabled), hos::Version_Min, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SetWakePinDebugMode, (s32 mode), (mode) ) \
AMS_SF_METHOD_INFO(C, H, 7, Result, OpenSession2, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, DeviceCode device_code, ddsf::AccessMode access_mode), (out, device_code, access_mode), hos::Version_5_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 8, Result, IsWakeEventActive2, (ams::sf::Out<bool> out, DeviceCode device_code), (out, device_code), hos::Version_5_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 9, Result, SetWakeEventActiveFlagSetForDebug2, (DeviceCode device_code, bool is_enabled), (device_code, is_enabled), hos::Version_5_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 10, Result, SetRetryValues, (u32 arg0, u32 arg1), (arg0, arg1), hos::Version_6_0_0 )
#define AMS_GPIO_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<std::shared_ptr<gpio::sf::IPadSession>> out, s32 pad_descriptor) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<std::shared_ptr<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenSessionForTest, (ams::sf::Out<std::shared_ptr<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name) ) \
AMS_SF_METHOD_INFO(C, H, 3, Result, IsWakeEventActive, (ams::sf::Out<bool> out, gpio::GpioPadName pad_name), hos::Version_Min, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetWakeEventActiveFlagSet, (ams::sf::Out<gpio::WakeBitFlag> out), hos::Version_Min, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, SetWakeEventActiveFlagSetForDebug, (gpio::GpioPadName pad_name, bool is_enabled), hos::Version_Min, hos::Version_6_2_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SetWakePinDebugMode, (s32 mode) ) \
AMS_SF_METHOD_INFO(C, H, 7, Result, OpenSession2, (ams::sf::Out<std::shared_ptr<gpio::sf::IPadSession>> out, DeviceCode device_code, ddsf::AccessMode access_mode), hos::Version_5_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 8, Result, IsWakeEventActive2, (ams::sf::Out<bool> out, DeviceCode device_code), hos::Version_5_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 9, Result, SetWakeEventActiveFlagSetForDebug2, (DeviceCode device_code, bool is_enabled), hos::Version_5_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 10, Result, SetRetryValues, (u32 arg0, u32 arg1), hos::Version_6_0_0 )
AMS_SF_DEFINE_INTERFACE(IManager, AMS_GPIO_I_MANAGER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::gpio::sf, IManager, AMS_GPIO_I_MANAGER_INTERFACE_INFO)
@@ -18,28 +18,24 @@
#include <vapours.hpp>
#include <stratosphere/gpio/gpio_types.hpp>
namespace ams::gpio::sf {
#define AMS_GPIO_I_PAD_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetDirection, (gpio::Direction direction), (direction) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetDirection, (ams::sf::Out<gpio::Direction> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetInterruptMode, (gpio::InterruptMode mode), (mode) ) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetInterruptMode, (ams::sf::Out<gpio::InterruptMode> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetInterruptEnable, (bool enable), (enable) ) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetInterruptEnable, (ams::sf::Out<bool> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetInterruptStatus, (ams::sf::Out<gpio::InterruptStatus> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 7, Result, ClearInterruptStatus, (), () ) \
AMS_SF_METHOD_INFO(C, H, 8, Result, SetValue, (gpio::GpioValue value), (value) ) \
AMS_SF_METHOD_INFO(C, H, 9, Result, GetValue, (ams::sf::Out<gpio::GpioValue> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 10, Result, BindInterrupt, (ams::sf::OutCopyHandle out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 11, Result, UnbindInterrupt, (), () ) \
AMS_SF_METHOD_INFO(C, H, 12, Result, SetDebounceEnabled, (bool enable), (enable) ) \
AMS_SF_METHOD_INFO(C, H, 13, Result, GetDebounceEnabled, (ams::sf::Out<bool> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 14, Result, SetDebounceTime, (s32 ms), (ms) ) \
AMS_SF_METHOD_INFO(C, H, 15, Result, GetDebounceTime, (ams::sf::Out<s32> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 16, Result, SetValueForSleepState, (gpio::GpioValue value), (value), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 16, Result, GetValueForSleepState, (ams::sf::Out<gpio::GpioValue> out), (out), hos::Version_6_0_0)
#define AMS_GPIO_I_PAD_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetDirection, (gpio::Direction direction) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetDirection, (ams::sf::Out<gpio::Direction> out) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetInterruptMode, (gpio::InterruptMode mode) ) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetInterruptMode, (ams::sf::Out<gpio::InterruptMode> out) ) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetInterruptEnable, (bool enable) ) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetInterruptEnable, (ams::sf::Out<bool> out) ) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetInterruptStatus, (ams::sf::Out<gpio::InterruptStatus> out) ) \
AMS_SF_METHOD_INFO(C, H, 7, Result, ClearInterruptStatus, () ) \
AMS_SF_METHOD_INFO(C, H, 8, Result, SetValue, (gpio::GpioValue value) ) \
AMS_SF_METHOD_INFO(C, H, 9, Result, GetValue, (ams::sf::Out<gpio::GpioValue> out) ) \
AMS_SF_METHOD_INFO(C, H, 10, Result, BindInterrupt, (ams::sf::OutCopyHandle out) ) \
AMS_SF_METHOD_INFO(C, H, 11, Result, UnbindInterrupt, () ) \
AMS_SF_METHOD_INFO(C, H, 12, Result, SetDebounceEnabled, (bool enable) ) \
AMS_SF_METHOD_INFO(C, H, 13, Result, GetDebounceEnabled, (ams::sf::Out<bool> out) ) \
AMS_SF_METHOD_INFO(C, H, 14, Result, SetDebounceTime, (s32 ms) ) \
AMS_SF_METHOD_INFO(C, H, 15, Result, GetDebounceTime, (ams::sf::Out<s32> out) ) \
AMS_SF_METHOD_INFO(C, H, 16, Result, SetValueForSleepState, (gpio::GpioValue value), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 16, Result, GetValueForSleepState, (ams::sf::Out<gpio::GpioValue> out), hos::Version_6_0_0)
AMS_SF_DEFINE_INTERFACE(IPadSession, AMS_GPIO_I_PAD_SESSION_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::gpio::sf, IPadSession, AMS_GPIO_I_PAD_SESSION_INTERFACE_INFO)
@@ -20,7 +20,7 @@
namespace ams::i2c {
void InitializeWith(std::shared_ptr<i2c::sf::IManager> &&sp, std::shared_ptr<i2c::sf::IManager> &&sp_pcv);
void InitializeWith(ams::sf::SharedPointer<i2c::sf::IManager> sp, ams::sf::SharedPointer<i2c::sf::IManager> sp_pcv);
void InitializeEmpty();
void Finalize();
@@ -20,7 +20,7 @@
namespace ams::i2c::server {
std::shared_ptr<i2c::sf::IManager> GetServiceObject();
std::shared_ptr<i2c::sf::IManager> GetServiceObjectPowerBus();
ams::sf::SharedPointer<i2c::sf::IManager> GetServiceObject();
ams::sf::SharedPointer<i2c::sf::IManager> GetServiceObjectPowerBus();
}
@@ -20,15 +20,11 @@
#include <stratosphere/i2c/i2c_select_device_name.hpp>
#include <stratosphere/i2c/sf/i2c_sf_i_session.hpp>
namespace ams::i2c::sf {
#define AMS_I2C_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, s32 bus_idx, u16 slave_address, i2c::AddressingMode addressing_mode, i2c::SpeedMode speed_mode), (out, bus_idx, slave_address, addressing_mode, speed_mode) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, i2c::I2cDevice device), (out, device) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, HasDevice, (ams::sf::Out<bool> out, i2c::I2cDevice device), (out, device), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HasDeviceForDev, (ams::sf::Out<bool> out, i2c::I2cDevice device), (out, device), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, OpenSession2, (ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, DeviceCode device_code), (out, device_code), hos::Version_6_0_0 )
#define AMS_I2C_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<std::shared_ptr<i2c::sf::ISession>> out, s32 bus_idx, u16 slave_address, i2c::AddressingMode addressing_mode, i2c::SpeedMode speed_mode) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<std::shared_ptr<i2c::sf::ISession>> out, i2c::I2cDevice device) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, HasDevice, (ams::sf::Out<bool> out, i2c::I2cDevice device), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HasDeviceForDev, (ams::sf::Out<bool> out, i2c::I2cDevice device), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, OpenSession2, (ams::sf::Out<std::shared_ptr<i2c::sf::ISession>> out, DeviceCode device_code), hos::Version_6_0_0 )
AMS_SF_DEFINE_INTERFACE(IManager, AMS_I2C_I_MANAGER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::i2c::sf, IManager, AMS_I2C_I_MANAGER_INTERFACE_INFO)
@@ -18,17 +18,13 @@
#include <vapours.hpp>
#include <stratosphere/i2c/i2c_types.hpp>
namespace ams::i2c::sf {
#define AMS_I2C_I_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SendOld, (const ams::sf::InBuffer &in_data, i2c::TransactionOption option), (in_data, option), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 1, Result, ReceiveOld, (const ams::sf::OutBuffer &out_data, i2c::TransactionOption option), (out_data, option), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ExecuteCommandListOld, (const ams::sf::OutBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list), (rcv_buf, command_list), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, Send, (const ams::sf::InAutoSelectBuffer &in_data, i2c::TransactionOption option), (in_data, option) ) \
AMS_SF_METHOD_INFO(C, H, 11, Result, Receive, (const ams::sf::OutAutoSelectBuffer &out_data, i2c::TransactionOption option), (out_data, option) ) \
AMS_SF_METHOD_INFO(C, H, 12, Result, ExecuteCommandList, (const ams::sf::OutAutoSelectBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list), (rcv_buf, command_list) ) \
AMS_SF_METHOD_INFO(C, H, 13, Result, SetRetryPolicy, (s32 max_retry_count, s32 retry_interval_us), (max_retry_count, retry_interval_us), hos::Version_6_0_0 )
#define AMS_I2C_I_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SendOld, (const ams::sf::InBuffer &in_data, i2c::TransactionOption option), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 1, Result, ReceiveOld, (const ams::sf::OutBuffer &out_data, i2c::TransactionOption option), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ExecuteCommandListOld, (const ams::sf::OutBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list), hos::Version_Min, hos::Version_5_1_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, Send, (const ams::sf::InAutoSelectBuffer &in_data, i2c::TransactionOption option) ) \
AMS_SF_METHOD_INFO(C, H, 11, Result, Receive, (const ams::sf::OutAutoSelectBuffer &out_data, i2c::TransactionOption option) ) \
AMS_SF_METHOD_INFO(C, H, 12, Result, ExecuteCommandList, (const ams::sf::OutAutoSelectBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list) ) \
AMS_SF_METHOD_INFO(C, H, 13, Result, SetRetryPolicy, (s32 max_retry_count, s32 retry_interval_us), hos::Version_6_0_0 )
AMS_SF_DEFINE_INTERFACE(ISession, AMS_I2C_I_SESSION_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::i2c::sf, ISession, AMS_I2C_I_SESSION_INTERFACE_INFO)
@@ -19,15 +19,11 @@
#include <stratosphere/ldr/ldr_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::ldr::impl {
#define AMS_LDR_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgumentsDeprecated, (ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size), (program_id, args, args_size), hos::Version_Min, hos::Version_10_2_0) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArguments, (ncm::ProgramId program_id, const sf::InPointerBuffer &args), (program_id, args), hos::Version_11_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, FlushArguments, (), ()) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetProcessModuleInfo, (sf::Out<u32> count, const sf::OutPointerArray<ldr::ModuleInfo> &out, os::ProcessId process_id), (count, out, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedBootProgram, (sf::Out<bool> out, ncm::ProgramId program_id), (out, program_id))
#define AMS_LDR_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgumentsDeprecated, (ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size), hos::Version_Min, hos::Version_10_2_0) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArguments, (ncm::ProgramId program_id, const sf::InPointerBuffer &args), hos::Version_11_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, FlushArguments, ()) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetProcessModuleInfo, (sf::Out<u32> count, const sf::OutPointerArray<ModuleInfo> &out, os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedProgram, (sf::Out<bool> out, ncm::ProgramId program_id))
AMS_SF_DEFINE_INTERFACE(IDebugMonitorInterface, AMS_LDR_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ldr::impl, IDebugMonitorInterface, AMS_LDR_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
@@ -19,18 +19,14 @@
#include <stratosphere/ldr/ldr_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::ldr::impl {
#define AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, CreateProcess, (sf::OutMoveHandle proc_h, ldr::PinId id, u32 flags, sf::CopyHandle reslimit_h), (proc_h, id, flags, reslimit_h)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetProgramInfo, (sf::Out<ldr::ProgramInfo> out_program_info, const ncm::ProgramLocation &loc), (out_program_info, loc)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, PinProgram, (sf::Out<ldr::PinId> out_id, const ncm::ProgramLocation &loc), (out_id, loc)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, UnpinProgram, (ldr::PinId id), (id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabledProgramVerification, (bool enabled), (enabled), hos::Version_10_0_0) \
AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedBootProgram, (sf::Out<bool> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetProgramInfo, (sf::Out<ldr::ProgramInfo> out_program_info, sf::Out<cfg::OverrideStatus> out_status, const ncm::ProgramLocation &loc), (out_program_info, out_status, loc)) \
AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmospherePinProgram, (sf::Out<ldr::PinId> out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status), (out_id, loc, override_status))
#define AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, CreateProcess, (sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle reslimit_h)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetProgramInfo, (sf::Out<ProgramInfo> out_program_info, const ncm::ProgramLocation &loc)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, PinProgram, (sf::Out<PinId> out_id, const ncm::ProgramLocation &loc)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, UnpinProgram, (PinId id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabledProgramVerification, (bool enabled), hos::Version_10_0_0) \
AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedProgram, (sf::Out<bool> out, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetProgramInfo, (sf::Out<ProgramInfo> out_program_info, sf::Out<cfg::OverrideStatus> out_status, const ncm::ProgramLocation &loc)) \
AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmospherePinProgram, (sf::Out<PinId> out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status))
AMS_SF_DEFINE_INTERFACE(IProcessManagerInterface, AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ldr::impl, IProcessManagerInterface, AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO)
@@ -19,15 +19,11 @@
#include <stratosphere/ldr/ldr_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::ldr::impl {
#define AMS_LDR_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgumentsDeprecated, (ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size), (program_id, args, args_size), hos::Version_Min, hos::Version_10_2_0) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArguments, (ncm::ProgramId program_id, const sf::InPointerBuffer &args), (program_id, args), hos::Version_11_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, FlushArguments, (), ()) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereRegisterExternalCode, (sf::OutMoveHandle out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, void, AtmosphereUnregisterExternalCode, (ncm::ProgramId program_id), (program_id))
#define AMS_LDR_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgumentsDeprecated, (ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size), hos::Version_Min, hos::Version_10_2_0) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArguments, (ncm::ProgramId program_id, const sf::InPointerBuffer &args), hos::Version_11_0_0 ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, FlushArguments, ()) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereRegisterExternalCode, (sf::OutMoveHandle out, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, void, AtmosphereUnregisterExternalCode, (ncm::ProgramId program_id))
AMS_SF_DEFINE_INTERFACE(IShellInterface, AMS_LDR_I_SHELL_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ldr::impl, IShellInterface, AMS_LDR_I_SHELL_INTERFACE_INTERFACE_INFO)
@@ -25,7 +25,7 @@ namespace ams::ldr::pm {
Result PinProgram(PinId *out, const ncm::ProgramLocation &loc);
Result UnpinProgram(PinId pin_id);
Result SetEnabledProgramVerification(bool enabled);
Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id);
Result HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id);
/* Atmosphere extension API. */
Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc);
@@ -23,10 +23,10 @@ namespace ams::lr {
class AddOnContentLocationResolver {
NON_COPYABLE(AddOnContentLocationResolver);
private:
std::shared_ptr<IAddOnContentLocationResolver> interface;
sf::SharedPointer<IAddOnContentLocationResolver> interface;
public:
AddOnContentLocationResolver() { /* ... */ }
explicit AddOnContentLocationResolver(std::shared_ptr<IAddOnContentLocationResolver> intf) : interface(std::move(intf)) { /* ... */ }
explicit AddOnContentLocationResolver(sf::SharedPointer<IAddOnContentLocationResolver> intf) : interface(intf) { /* ... */ }
AddOnContentLocationResolver(AddOnContentLocationResolver &&rhs) {
this->interface = std::move(rhs.interface);
@@ -17,16 +17,12 @@
#pragma once
#include <stratosphere/lr/lr_types.hpp>
namespace ams::lr {
#define AMS_LR_I_ADD_ON_CONTENT_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveAddOnContentPath, (sf::Out<lr::Path> out, ncm::DataId id), (out, id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterAddOnContentStorageDeprecated, (ncm::DataId id, ncm::StorageId storage_id), (id, storage_id), hos::Version_2_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterAddOnContentStorage, (ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id), (id, application_id, storage_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, UnregisterAllAddOnContentPath, (), (), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, RefreshApplicationAddOnContent, (const sf::InArray<ncm::ApplicationId> &ids), (ids), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, UnregisterApplicationAddOnContent, (ncm::ApplicationId id), (id), hos::Version_9_0_0)
#define AMS_LR_I_ADD_ON_CONTENT_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveAddOnContentPath, (sf::Out<Path> out, ncm::DataId id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterAddOnContentStorageDeprecated, (ncm::DataId id, ncm::StorageId storage_id), hos::Version_2_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterAddOnContentStorage, (ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, UnregisterAllAddOnContentPath, (), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 3, Result, RefreshApplicationAddOnContent, (const sf::InArray<ncm::ApplicationId> &ids), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, UnregisterApplicationAddOnContent, (ncm::ApplicationId id), hos::Version_9_0_0)
AMS_SF_DEFINE_INTERFACE(IAddOnContentLocationResolver, AMS_LR_I_ADD_ON_CONTENT_LOCATION_RESOLVER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::lr, IAddOnContentLocationResolver, AMS_LR_I_ADD_ON_CONTENT_LOCATION_RESOLVER_INTERFACE_INFO)
@@ -17,37 +17,33 @@
#pragma once
#include <stratosphere/lr/lr_types.hpp>
namespace ams::lr {
#define AMS_LR_I_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveProgramPath, (sf::Out<Path> out, ncm::ProgramId id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RedirectProgramPath, (const Path &path, ncm::ProgramId id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ResolveApplicationControlPath, (sf::Out<Path> out, ncm::ProgramId id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, ResolveApplicationHtmlDocumentPath, (sf::Out<Path> out, ncm::ProgramId id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, ResolveDataPath, (sf::Out<Path> out, ncm::DataId id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RedirectApplicationControlPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RedirectApplicationControlPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, RedirectApplicationHtmlDocumentPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 6, Result, RedirectApplicationHtmlDocumentPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, ResolveApplicationLegalInformationPath, (sf::Out<Path> out, ncm::ProgramId id)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, RedirectApplicationLegalInformationPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 8, Result, RedirectApplicationLegalInformationPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, Refresh, ()) \
AMS_SF_METHOD_INFO(C, H, 10, Result, RedirectApplicationProgramPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_5_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 10, Result, RedirectApplicationProgramPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ClearApplicationRedirectionDeprecated, (), hos::Version_5_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ClearApplicationRedirection, (const sf::InArray<ncm::ProgramId> &excluding_ids), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 12, Result, EraseProgramRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 13, Result, EraseApplicationControlRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 14, Result, EraseApplicationHtmlDocumentRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 15, Result, EraseApplicationLegalInformationRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 16, Result, ResolveProgramPathForDebug, (sf::Out<Path> out, ncm::ProgramId id), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 17, Result, RedirectProgramPathForDebug, (const Path &path, ncm::ProgramId id), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 18, Result, RedirectApplicationProgramPathForDebugDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_7_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 18, Result, RedirectApplicationProgramPathForDebug, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, EraseProgramRedirectionForDebug, (ncm::ProgramId id), hos::Version_7_0_0)
#define AMS_LR_I_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveProgramPath, (sf::Out<lr::Path> out, ncm::ProgramId id), (out, id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RedirectProgramPath, (const lr::Path &path, ncm::ProgramId id), (path, id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ResolveApplicationControlPath, (sf::Out<lr::Path> out, ncm::ProgramId id), (out, id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, ResolveApplicationHtmlDocumentPath, (sf::Out<lr::Path> out, ncm::ProgramId id), (out, id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, ResolveDataPath, (sf::Out<lr::Path> out, ncm::DataId id), (out, id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RedirectApplicationControlPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RedirectApplicationControlPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, RedirectApplicationHtmlDocumentPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 6, Result, RedirectApplicationHtmlDocumentPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, ResolveApplicationLegalInformationPath, (sf::Out<lr::Path> out, ncm::ProgramId id), (out, id)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, RedirectApplicationLegalInformationPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 8, Result, RedirectApplicationLegalInformationPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, Refresh, (), ()) \
AMS_SF_METHOD_INFO(C, H, 10, Result, RedirectApplicationProgramPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_5_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 10, Result, RedirectApplicationProgramPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ClearApplicationRedirectionDeprecated, (), (), hos::Version_5_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ClearApplicationRedirection, (const sf::InArray<ncm::ProgramId> &excluding_ids), (excluding_ids), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 12, Result, EraseProgramRedirection, (ncm::ProgramId id), (id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 13, Result, EraseApplicationControlRedirection, (ncm::ProgramId id), (id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 14, Result, EraseApplicationHtmlDocumentRedirection, (ncm::ProgramId id), (id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 15, Result, EraseApplicationLegalInformationRedirection, (ncm::ProgramId id), (id), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 16, Result, ResolveProgramPathForDebug, (sf::Out<lr::Path> out, ncm::ProgramId id), (out, id), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 17, Result, RedirectProgramPathForDebug, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 18, Result, RedirectApplicationProgramPathForDebugDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_7_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 18, Result, RedirectApplicationProgramPathForDebug, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, EraseProgramRedirectionForDebug, (ncm::ProgramId id), (id), hos::Version_7_0_0)
AMS_SF_DEFINE_INTERFACE(ILocationResolver, AMS_LR_I_LOCATION_RESOLVER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::lr, ILocationResolver, AMS_LR_I_LOCATION_RESOLVER_INTERFACE_INFO)
@@ -20,14 +20,10 @@
#include <stratosphere/lr/lr_i_add_on_content_location_resolver.hpp>
#include <stratosphere/lr/lr_i_registered_location_resolver.hpp>
namespace ams::lr {
#define AMS_LR_I_LOCATION_RESOLVER_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenLocationResolver, (sf::Out<ams::sf::SharedPointer<lr::ILocationResolver>> out, ncm::StorageId storage_id), (out, storage_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenRegisteredLocationResolver, (sf::Out<ams::sf::SharedPointer<lr::IRegisteredLocationResolver>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, RefreshLocationResolver, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, OpenAddOnContentLocationResolver, (sf::Out<ams::sf::SharedPointer<lr::IAddOnContentLocationResolver>> out), (out), hos::Version_2_0_0)
#define AMS_LR_I_LOCATION_RESOLVER_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenLocationResolver, (sf::Out<std::shared_ptr<ILocationResolver>> out, ncm::StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenRegisteredLocationResolver, (sf::Out<std::shared_ptr<IRegisteredLocationResolver>> out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, RefreshLocationResolver, (ncm::StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, OpenAddOnContentLocationResolver, (sf::Out<std::shared_ptr<IAddOnContentLocationResolver>> out), hos::Version_2_0_0)
AMS_SF_DEFINE_INTERFACE(ILocationResolverManager, AMS_LR_I_LOCATION_RESOLVER_MANAGER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::lr, ILocationResolverManager, AMS_LR_I_LOCATION_RESOLVER_MANAGER_INTERFACE_INFO)
@@ -17,24 +17,20 @@
#pragma once
#include <stratosphere/lr/lr_types.hpp>
namespace ams::lr {
#define AMS_LR_I_REGISTERED_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveProgramPath, (sf::Out<lr::Path> out, ncm::ProgramId id), (out, id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterProgramPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterProgramPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, UnregisterProgramPath, (ncm::ProgramId id), (id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, RedirectProgramPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 3, Result, RedirectProgramPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, ResolveHtmlDocumentPath, (sf::Out<lr::Path> out, ncm::ProgramId id), (out, id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RegisterHtmlDocumentPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_2_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RegisterHtmlDocumentPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, UnregisterHtmlDocumentPath, (ncm::ProgramId id), (id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, RedirectHtmlDocumentPathDeprecated, (const lr::Path &path, ncm::ProgramId id), (path, id), hos::Version_2_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 7, Result, RedirectHtmlDocumentPath, (const lr::Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), (path, id, owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, Refresh, (), (), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, RefreshExcluding, (const sf::InArray<ncm::ProgramId> &ids), (ids), hos::Version_9_0_0)
#define AMS_LR_I_REGISTERED_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveProgramPath, (sf::Out<Path> out, ncm::ProgramId id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterProgramPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterProgramPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, UnregisterProgramPath, (ncm::ProgramId id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, RedirectProgramPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 3, Result, RedirectProgramPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 4, Result, ResolveHtmlDocumentPath, (sf::Out<Path> out, ncm::ProgramId id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RegisterHtmlDocumentPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_2_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 5, Result, RegisterHtmlDocumentPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, UnregisterHtmlDocumentPath, (ncm::ProgramId id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, RedirectHtmlDocumentPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_2_0_0, hos::Version_8_1_1) \
AMS_SF_METHOD_INFO(C, H, 7, Result, RedirectHtmlDocumentPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, Refresh, (), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, RefreshExcluding, (const sf::InArray<ncm::ProgramId> &ids), hos::Version_9_0_0)
AMS_SF_DEFINE_INTERFACE(IRegisteredLocationResolver, AMS_LR_I_REGISTERED_LOCATION_RESOLVER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::lr, IRegisteredLocationResolver, AMS_LR_I_REGISTERED_LOCATION_RESOLVER_INTERFACE_INFO)
@@ -23,21 +23,21 @@ namespace ams::lr {
class LocationResolver {
NON_COPYABLE(LocationResolver);
private:
std::shared_ptr<ILocationResolver> interface;
sf::SharedPointer<ILocationResolver> interface;
public:
LocationResolver() { /* ... */ }
explicit LocationResolver(std::shared_ptr<ILocationResolver> intf) : interface(std::move(intf)) { /* ... */ }
explicit LocationResolver(sf::SharedPointer<ILocationResolver> intf) : interface(intf) { /* ... */ }
LocationResolver(LocationResolver &&rhs) {
this->interface = std::move(rhs.interface);
}
LocationResolver &operator=(LocationResolver &&rhs) {
LocationResolver(std::move(rhs)).Swap(*this);
LocationResolver(std::move(rhs)).swap(*this);
return *this;
}
void Swap(LocationResolver &rhs) {
void swap(LocationResolver &rhs) {
std::swap(this->interface, rhs.interface);
}
public:
@@ -21,20 +21,20 @@
namespace ams::lr {
class LocationResolverManagerImpl final {
class LocationResolverManagerImpl {
private:
/* Resolver storage. */
ncm::BoundedMap<ncm::StorageId, std::shared_ptr<ILocationResolver>, 5> location_resolvers;
std::shared_ptr<IRegisteredLocationResolver> registered_location_resolver = nullptr;
std::shared_ptr<IAddOnContentLocationResolver> add_on_content_location_resolver = nullptr;
ncm::BoundedMap<ncm::StorageId, sf::SharedPointer<ILocationResolver>, 5> location_resolvers;
sf::SharedPointer<IRegisteredLocationResolver> registered_location_resolver = nullptr;
sf::SharedPointer<IAddOnContentLocationResolver> add_on_content_location_resolver = nullptr;
os::Mutex mutex{false};
public:
/* Actual commands. */
Result OpenLocationResolver(sf::Out<std::shared_ptr<ILocationResolver>> out, ncm::StorageId storage_id);
Result OpenRegisteredLocationResolver(sf::Out<std::shared_ptr<IRegisteredLocationResolver>> out);
Result OpenLocationResolver(sf::Out<sf::SharedPointer<ILocationResolver>> out, ncm::StorageId storage_id);
Result OpenRegisteredLocationResolver(sf::Out<sf::SharedPointer<IRegisteredLocationResolver>> out);
Result RefreshLocationResolver(ncm::StorageId storage_id);
Result OpenAddOnContentLocationResolver(sf::Out<std::shared_ptr<IAddOnContentLocationResolver>> out);
Result OpenAddOnContentLocationResolver(sf::Out<sf::SharedPointer<IAddOnContentLocationResolver>> out);
};
static_assert(IsILocationResolverManager<LocationResolverManagerImpl>);
@@ -23,10 +23,10 @@ namespace ams::lr {
class RegisteredLocationResolver {
NON_COPYABLE(RegisteredLocationResolver);
private:
std::shared_ptr<IRegisteredLocationResolver> interface;
sf::SharedPointer<IRegisteredLocationResolver> interface;
public:
RegisteredLocationResolver() { /* ... */ }
explicit RegisteredLocationResolver(std::shared_ptr<IRegisteredLocationResolver> intf) : interface(std::move(intf)) { /* ... */ }
explicit RegisteredLocationResolver(sf::SharedPointer<IRegisteredLocationResolver> intf) : interface(intf) { /* ... */ }
RegisteredLocationResolver(RegisteredLocationResolver &&rhs) {
this->interface = std::move(rhs.interface);
@@ -24,7 +24,7 @@ namespace ams::ncm {
void Initialize();
void Finalize();
void InitializeWithObject(std::shared_ptr<IContentManager> manager_object);
void InitializeWithObject(sf::SharedPointer<IContentManager> manager_object);
/* Service API. */
Result CreateContentStorage(StorageId storage_id);
@@ -67,7 +67,7 @@ namespace ams::ncm {
};
static_assert(util::is_pod<SystemSaveDataInfo>::value);
class ContentManagerImpl final {
class ContentManagerImpl {
private:
constexpr static size_t MaxContentStorageRoots = 8;
constexpr static size_t MaxContentMetaDatabaseRoots = 8;
@@ -80,7 +80,7 @@ namespace ams::ncm {
char path[128];
StorageId storage_id;
fs::ContentStorageId content_storage_id;
std::shared_ptr<IContentStorage> content_storage;
sf::SharedPointer<IContentStorage> content_storage;
ContentStorageRoot() { /* ... */ }
};
@@ -93,7 +93,7 @@ namespace ams::ncm {
char path[128];
StorageId storage_id;
SystemSaveDataInfo info;
std::shared_ptr<IContentMetaDatabase> content_meta_database;
sf::SharedPointer<IContentMetaDatabase> content_meta_database;
std::optional<kvdb::MemoryKeyValueStore<ContentMetaKey>> kvs;
ContentMetaMemoryResource *memory_resource;
u32 max_content_metas;
@@ -135,8 +135,8 @@ namespace ams::ncm {
Result CreateContentMetaDatabase(StorageId storage_id);
Result VerifyContentStorage(StorageId storage_id);
Result VerifyContentMetaDatabase(StorageId storage_id);
Result OpenContentStorage(sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id);
Result OpenContentMetaDatabase(sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id);
Result OpenContentStorage(sf::Out<sf::SharedPointer<IContentStorage>> out, StorageId storage_id);
Result OpenContentMetaDatabase(sf::Out<sf::SharedPointer<IContentMetaDatabase>> out, StorageId storage_id);
Result CloseContentStorageForcibly(StorageId storage_id);
Result CloseContentMetaDatabaseForcibly(StorageId storage_id);
Result CleanupContentMetaDatabase(StorageId storage_id);
@@ -26,21 +26,21 @@ namespace ams::ncm {
s32 total;
};
private:
std::shared_ptr<IContentMetaDatabase> interface;
sf::SharedPointer<IContentMetaDatabase> interface;
public:
ContentMetaDatabase() { /* ... */ }
explicit ContentMetaDatabase(std::shared_ptr<IContentMetaDatabase> intf) : interface(std::move(intf)) { /* ... */ }
explicit ContentMetaDatabase(sf::SharedPointer<IContentMetaDatabase> intf) : interface(intf) { /* ... */ }
ContentMetaDatabase(ContentMetaDatabase &&rhs) {
this->interface = std::move(rhs.interface);
}
ContentMetaDatabase &operator=(ContentMetaDatabase &&rhs) {
ContentMetaDatabase(std::move(rhs)).Swap(*this);
ContentMetaDatabase(std::move(rhs)).swap(*this);
return *this;
}
void Swap(ContentMetaDatabase &rhs) {
void swap(ContentMetaDatabase &rhs) {
std::swap(this->interface, rhs.interface);
}
public:
@@ -21,21 +21,21 @@ namespace ams::ncm {
class ContentStorage {
NON_COPYABLE(ContentStorage);
private:
std::shared_ptr<IContentStorage> interface;
sf::SharedPointer<IContentStorage> interface;
public:
ContentStorage() { /* ... */ }
explicit ContentStorage(std::shared_ptr<IContentStorage> intf) : interface(std::move(intf)) { /* ... */ }
explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : interface(intf) { /* ... */ }
ContentStorage(ContentStorage &&rhs) {
this->interface = std::move(rhs.interface);
}
ContentStorage &operator=(ContentStorage &&rhs) {
ContentStorage(std::move(rhs)).Swap(*this);
ContentStorage(std::move(rhs)).swap(*this);
return *this;
}
void Swap(ContentStorage &rhs) {
void swap(ContentStorage &rhs) {
std::swap(this->interface, rhs.interface);
}
public:
@@ -18,25 +18,21 @@
#include <stratosphere/ncm/ncm_i_content_meta_database.hpp>
#include <stratosphere/ncm/ncm_memory_report.hpp>
namespace ams::ncm {
#define AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, CreateContentStorage, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, VerifyContentStorage, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, VerifyContentMetaDatabase, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, OpenContentStorage, (sf::Out<sf::SharedPointer<ncm::IContentStorage>> out, ncm::StorageId storage_id), (out, storage_id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, OpenContentMetaDatabase, (sf::Out<sf::SharedPointer<ncm::IContentMetaDatabase>> out, ncm::StorageId storage_id), (out, storage_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, CloseContentStorageForcibly, (ncm::StorageId storage_id), (storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, CloseContentMetaDatabaseForcibly, (ncm::StorageId storage_id), (storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, CleanupContentMetaDatabase, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, ActivateContentStorage, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, InactivateContentStorage, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ActivateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 12, Result, InactivateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 13, Result, InvalidateRightsIdCache, (), (), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetMemoryReport, (sf::Out<ncm::MemoryReport> out), (out), hos::Version_10_0_0)
#define AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, CreateContentStorage, (StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreateContentMetaDatabase, (StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, VerifyContentStorage, (StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, VerifyContentMetaDatabase, (StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, OpenContentStorage, (sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, OpenContentMetaDatabase, (sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, CloseContentStorageForcibly, (StorageId storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, CloseContentMetaDatabaseForcibly, (StorageId storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, CleanupContentMetaDatabase, (StorageId storage_id)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, ActivateContentStorage, (StorageId storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, InactivateContentStorage, (StorageId storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ActivateContentMetaDatabase, (StorageId storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 12, Result, InactivateContentMetaDatabase, (StorageId storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 13, Result, InvalidateRightsIdCache, (), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetMemoryReport, (sf::Out<MemoryReport> out), hos::Version_10_0_0)
AMS_SF_DEFINE_INTERFACE(IContentManager, AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO);
}
AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentManager, AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO);
@@ -17,33 +17,29 @@
#include <stratosphere/sf.hpp>
#include <stratosphere/ncm/ncm_content_meta.hpp>
namespace ams::ncm {
#define AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Set, (const ncm::ContentMetaKey &key, const sf::InBuffer &value), (key, value)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Get, (sf::Out<u64> out_size, const ncm::ContentMetaKey &key, const sf::OutBuffer &out_value), (out_size, key, out_value)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Remove, (const ncm::ContentMetaKey &key), (key)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetContentIdByType, (sf::Out<ncm::ContentId> out_content_id, const ncm::ContentMetaKey &key, ncm::ContentType type), (out_content_id, key, type)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, ListContentInfo, (sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ContentInfo> &out_info, const ncm::ContentMetaKey &key, s32 offset), (out_entries_written, out_info, key, offset)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, List, (sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ContentMetaKey> &out_info, ncm::ContentMetaType meta_type, ncm::ApplicationId application_id, u64 min, u64 max, ncm::ContentInstallType install_type), (out_entries_total, out_entries_written, out_info, meta_type, application_id, min, max, install_type)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetLatestContentMetaKey, (sf::Out<ncm::ContentMetaKey> out_key, u64 id), (out_key, id)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, ListApplication, (sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ApplicationContentMetaKey> &out_keys, ncm::ContentMetaType meta_type), (out_entries_total, out_entries_written, out_keys, meta_type)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, Has, (sf::Out<bool> out, const ncm::ContentMetaKey &key), (out, key)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, HasAll, (sf::Out<bool> out, const sf::InArray<ncm::ContentMetaKey> &keys), (out, keys)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, GetSize, (sf::Out<u64> out_size, const ncm::ContentMetaKey &key), (out_size, key)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetRequiredSystemVersion, (sf::Out<u32> out_version, const ncm::ContentMetaKey &key), (out_version, key)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetPatchId, (sf::Out<ncm::PatchId> out_patch_id, const ncm::ContentMetaKey &key), (out_patch_id, key)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, DisableForcibly, (), ()) \
AMS_SF_METHOD_INFO(C, H, 14, Result, LookupOrphanContent, (const sf::OutArray<bool> &out_orphaned, const sf::InArray<ncm::ContentId> &content_ids), (out_orphaned, content_ids)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, Commit, (), ()) \
AMS_SF_METHOD_INFO(C, H, 16, Result, HasContent, (sf::Out<bool> out, const ncm::ContentMetaKey &key, const ncm::ContentId &content_id), (out, key, content_id)) \
AMS_SF_METHOD_INFO(C, H, 17, Result, ListContentMetaInfo, (sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ContentMetaInfo> &out_meta_info, const ncm::ContentMetaKey &key, s32 offset), (out_entries_written, out_meta_info, key, offset)) \
AMS_SF_METHOD_INFO(C, H, 18, Result, GetAttributes, (sf::Out<u8> out_attributes, const ncm::ContentMetaKey &key), (out_attributes, key)) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRequiredApplicationVersion, (sf::Out<u32> out_version, const ncm::ContentMetaKey &key), (out_version, key), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetContentIdByTypeAndIdOffset, (sf::Out<ncm::ContentId> out_content_id, const ncm::ContentMetaKey &key, ncm::ContentType type, u8 id_offset), (out_content_id, key, type, id_offset), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 21, Result, GetCount, (sf::Out<u32> out_count), (out_count), hos::Version_10_0_0) \
AMS_SF_METHOD_INFO(C, H, 22, Result, GetOwnerApplicationId, (sf::Out<ncm::ApplicationId> out_id, const ncm::ContentMetaKey &key), (out_id, key), hos::Version_10_0_0)
#define AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Set, (const ContentMetaKey &key, sf::InBuffer value)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Get, (sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Remove, (const ContentMetaKey &key)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetContentIdByType, (sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, ListContentInfo, (sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, List, (sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetLatestContentMetaKey, (sf::Out<ContentMetaKey> out_key, u64 id)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, ListApplication, (sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, Has, (sf::Out<bool> out, const ContentMetaKey &key)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, HasAll, (sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, GetSize, (sf::Out<u64> out_size, const ContentMetaKey &key)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetRequiredSystemVersion, (sf::Out<u32> out_version, const ContentMetaKey &key)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetPatchId, (sf::Out<PatchId> out_patch_id, const ContentMetaKey &key)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, DisableForcibly, ()) \
AMS_SF_METHOD_INFO(C, H, 14, Result, LookupOrphanContent, (const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, Commit, ()) \
AMS_SF_METHOD_INFO(C, H, 16, Result, HasContent, (sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id)) \
AMS_SF_METHOD_INFO(C, H, 17, Result, ListContentMetaInfo, (sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset)) \
AMS_SF_METHOD_INFO(C, H, 18, Result, GetAttributes, (sf::Out<u8> out_attributes, const ContentMetaKey &key)) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRequiredApplicationVersion, (sf::Out<u32> out_version, const ContentMetaKey &key), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetContentIdByTypeAndIdOffset, (sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 21, Result, GetCount, (sf::Out<u32> out_count), hos::Version_10_0_0) \
AMS_SF_METHOD_INFO(C, H, 22, Result, GetOwnerApplicationId, (sf::Out<ApplicationId> out_id, const ContentMetaKey &key), hos::Version_10_0_0)
AMS_SF_DEFINE_INTERFACE(IContentMetaDatabase, AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentMetaDatabase, AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO)
@@ -20,40 +20,36 @@
#include <stratosphere/ncm/ncm_path.hpp>
#include <stratosphere/ncm/ncm_rights_id.hpp>
namespace ams::ncm {
#define AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GeneratePlaceHolderId, (sf::Out<ncm::PlaceHolderId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreatePlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id, s64 size), (placeholder_id, content_id, size)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, DeletePlaceHolder, (ncm::PlaceHolderId placeholder_id), (placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HasPlaceHolder, (sf::Out<bool> out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, WritePlaceHolder, (ncm::PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data), (placeholder_id, offset, data)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, Register, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id), (placeholder_id, content_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, Delete, (ncm::ContentId content_id), (content_id)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, Has, (sf::Out<bool> out, ncm::ContentId content_id), (out, content_id)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, GetPath, (sf::Out<ncm::Path> out, ncm::ContentId content_id), (out, content_id)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, GetPlaceHolderPath, (sf::Out<ncm::Path> out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, CleanupAllPlaceHolder, (), ()) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ListPlaceHolder, (sf::Out<s32> out_count, const sf::OutArray<ncm::PlaceHolderId> &out_buf), (out_count, out_buf)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetContentCount, (sf::Out<s32> out_count), (out_count)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, ListContentId, (sf::Out<s32> out_count, const sf::OutArray<ncm::ContentId> &out_buf, s32 start_offset), (out_count, out_buf, start_offset)) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetSizeFromContentId, (sf::Out<s64> out_size, ncm::ContentId content_id), (out_size, content_id)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, DisableForcibly, (), ()) \
AMS_SF_METHOD_INFO(C, H, 16, Result, RevertToPlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId old_content_id, ncm::ContentId new_content_id), (placeholder_id, old_content_id, new_content_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 17, Result, SetPlaceHolderSize, (ncm::PlaceHolderId placeholder_id, s64 size), (placeholder_id, size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 18, Result, ReadContentIdFile, (const sf::OutBuffer &buf, ncm::ContentId content_id, s64 offset), (buf, content_id, offset), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated, (sf::Out<ams::fs::RightsId> out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_2_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderId, (sf::Out<ncm::RightsId> out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated, (sf::Out<ams::fs::RightsId> out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_2_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentId, (sf::Out<ncm::RightsId> out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 21, Result, WriteContentForDebug, (ncm::ContentId content_id, s64 offset, const sf::InBuffer &data), (content_id, offset, data), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 22, Result, GetFreeSpaceSize, (sf::Out<s64> out_size), (out_size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 23, Result, GetTotalSpaceSize, (sf::Out<s64> out_size), (out_size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 24, Result, FlushPlaceHolder, (), (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 25, Result, GetSizeFromPlaceHolderId, (sf::Out<s64> out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 26, Result, RepairInvalidFileAttribute, (), (), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCache, (sf::Out<ncm::RightsId> out_rights_id, ncm::PlaceHolderId placeholder_id, ncm::ContentId cache_content_id), (out_rights_id, placeholder_id, cache_content_id), hos::Version_8_0_0)
#define AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GeneratePlaceHolderId, (sf::Out<PlaceHolderId> out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreatePlaceHolder, (PlaceHolderId placeholder_id, ContentId content_id, s64 size)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, DeletePlaceHolder, (PlaceHolderId placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HasPlaceHolder, (sf::Out<bool> out, PlaceHolderId placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, WritePlaceHolder, (PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, Register, (PlaceHolderId placeholder_id, ContentId content_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, Delete, (ContentId content_id)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, Has, (sf::Out<bool> out, ContentId content_id)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, GetPath, (sf::Out<Path> out, ContentId content_id)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, GetPlaceHolderPath, (sf::Out<Path> out, PlaceHolderId placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, CleanupAllPlaceHolder, ()) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ListPlaceHolder, (sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetContentCount, (sf::Out<s32> out_count)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, ListContentId, (sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 start_offset)) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetSizeFromContentId, (sf::Out<s64> out_size, ContentId content_id)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, DisableForcibly, ()) \
AMS_SF_METHOD_INFO(C, H, 16, Result, RevertToPlaceHolder, (PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 17, Result, SetPlaceHolderSize, (PlaceHolderId placeholder_id, s64 size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 18, Result, ReadContentIdFile, (sf::OutBuffer buf, ContentId content_id, s64 offset), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated, (sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id), hos::Version_2_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderId, (sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated, (sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id), hos::Version_2_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentId, (sf::Out<ncm::RightsId> out_rights_id, ContentId content_id), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 21, Result, WriteContentForDebug, (ContentId content_id, s64 offset, sf::InBuffer data), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 22, Result, GetFreeSpaceSize, (sf::Out<s64> out_size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 23, Result, GetTotalSpaceSize, (sf::Out<s64> out_size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 24, Result, FlushPlaceHolder, (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 25, Result, GetSizeFromPlaceHolderId, (sf::Out<s64> out, PlaceHolderId placeholder_id), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 26, Result, RepairInvalidFileAttribute, (), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCache, (sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id), hos::Version_8_0_0)
AMS_SF_DEFINE_INTERFACE(IContentStorage, AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentStorage, AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO)
@@ -19,13 +19,9 @@
#include <stratosphere/err/err_error_context.hpp>
#include <stratosphere/sf.hpp>
namespace ams::ns::impl {
#define AMS_NS_I_ASYNC_RESULT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Get, (), ()) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Cancel, (), ()) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetErrorContext, (::ams::sf::Out<::ams::err::ErrorContext> out), (out))
#define AMS_NS_I_ASYNC_RESULT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Get, ()) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Cancel, ()) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetErrorContext, (::ams::sf::Out<::ams::err::ErrorContext> out))
AMS_SF_DEFINE_INTERFACE(IAsyncResult, AMS_NS_I_ASYNC_RESULT_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ns::impl, IAsyncResult, AMS_NS_I_ASYNC_RESULT_INTERFACE_INFO)
@@ -14,10 +14,5 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::mitm {
void ThrowResultForDebug(Result res);
}
#include <stratosphere/nsd/nsd_types.hpp>
#include <stratosphere/nsd/impl/device/nsd_device.hpp>
@@ -13,24 +13,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/nsd/nsd_types.hpp>
#include "printk.h"
#include "vsprintf.h"
namespace ams::nsd::impl::device {
/**
* Temporary stand-in main printk.
*
* TODO: This should print via UART, console framebuffer, and to a ring for
* consumption by Horizon
*/
void printk(char *fmt, ...)
{
va_list list;
char buf[512];
va_start(list, fmt);
vsnprintf(buf, sizeof(buf), fmt, list);
const EnvironmentIdentifier &GetEnvironmentIdentifierFromSettings();
/* FIXME: print via UART */
va_end(list);
}
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::nsd {
struct EnvironmentIdentifier {
static constexpr size_t Size = 8;
char value[Size];
constexpr friend bool operator==(const EnvironmentIdentifier &lhs, const EnvironmentIdentifier &rhs) {
return util::Strncmp(lhs.value, rhs.value, Size) == 0;
}
constexpr friend bool operator!=(const EnvironmentIdentifier &lhs, const EnvironmentIdentifier &rhs) {
return !(lhs == rhs);
}
};
constexpr inline const EnvironmentIdentifier EnvironmentIdentifierOfProductDevice = {"lp1"};
constexpr inline const EnvironmentIdentifier EnvironmentIdentifierOfNotProductDevice = {"dd1"};
}
@@ -25,10 +25,10 @@ namespace ams::pgl {
class EventObserver {
NON_COPYABLE(EventObserver);
private:
std::shared_ptr<pgl::sf::IEventObserver> interface;
ams::sf::SharedPointer<pgl::sf::IEventObserver> interface;
public:
EventObserver() { /* ... */ }
explicit EventObserver(std::shared_ptr<pgl::sf::IEventObserver> intf) : interface(std::move(intf)) { /* ... */ }
explicit EventObserver(ams::sf::SharedPointer<pgl::sf::IEventObserver> intf) : interface(intf) { /* ... */ }
EventObserver(EventObserver &&rhs) {
this->interface = std::move(rhs.interface);
@@ -20,12 +20,8 @@
#include <stratosphere/pm.hpp>
#include <stratosphere/pgl/pgl_types.hpp>
namespace ams::pgl::sf {
#define AMS_PGL_I_EVENT_OBSERVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessEventHandle, (ams::sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetProcessEventInfo, (ams::sf::Out<pm::ProcessEventInfo> out), (out))
#define AMS_PGL_I_EVENT_OBSERVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessEventHandle, (ams::sf::OutCopyHandle out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetProcessEventInfo, (ams::sf::Out<pm::ProcessEventInfo> out))
AMS_SF_DEFINE_INTERFACE(IEventObserver, AMS_PGL_I_EVENT_OBSERVER_INTERFACE_INFO);
}
AMS_SF_DEFINE_INTERFACE(ams::pgl::sf, IEventObserver, AMS_PGL_I_EVENT_OBSERVER_INTERFACE_INFO);
@@ -21,25 +21,19 @@
#include <stratosphere/pgl/pgl_types.hpp>
#include <stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp>
namespace ams::pgl::sf {
#define AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (ams::sf::Out<os::ProcessId> out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags), (out, loc, pm_flags, pgl_flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, LaunchProgramFromHost, (ams::sf::Out<os::ProcessId> out, const ams::sf::InBuffer &content_path, u32 pm_flags), (out, content_path, pm_flags)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetHostContentMetaInfo, (ams::sf::Out<pgl::ContentMetaInfo> out, const ams::sf::InBuffer &content_path), (out, content_path)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (ams::sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, BoostSystemMemoryResourceLimit, (u64 size), (size)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, IsProcessTracked, (ams::sf::Out<bool> out, os::ProcessId process_id), (out, process_id)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, EnableApplicationCrashReport, (bool enabled), (enabled)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, IsApplicationCrashReportEnabled, (ams::sf::Out<bool> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, EnableApplicationAllThreadDumpOnCrash, (bool enabled), (enabled)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, TriggerApplicationSnapShotDumper, (pgl::SnapShotDumpType dump_type, const ams::sf::InBuffer &arg), (dump_type, arg)) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetShellEventObserver, (ams::sf::Out<ams::sf::SharedPointer<pgl::sf::IEventObserver>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 21, Result, Command21NotImplemented, (ams::sf::Out<u64> out, u32 in, const ams::sf::InBuffer &buf1, const ams::sf::InBuffer &buf2), (out, in, buf1, buf2), hos::Version_11_0_0)
#define AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (ams::sf::Out<os::ProcessId> out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, LaunchProgramFromHost, (ams::sf::Out<os::ProcessId> out, const ams::sf::InBuffer &content_path, u32 pm_flags)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetHostContentMetaInfo, (ams::sf::Out<pgl::ContentMetaInfo> out, const ams::sf::InBuffer &content_path)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (ams::sf::Out<os::ProcessId> out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, BoostSystemMemoryResourceLimit, (u64 size)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, IsProcessTracked, (ams::sf::Out<bool> out, os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, EnableApplicationCrashReport, (bool enabled)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, IsApplicationCrashReportEnabled, (ams::sf::Out<bool> out)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, EnableApplicationAllThreadDumpOnCrash, (bool enabled)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, TriggerApplicationSnapShotDumper, (SnapShotDumpType dump_type, const ams::sf::InBuffer &arg)) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetShellEventObserver, (ams::sf::Out<std::shared_ptr<pgl::sf::IEventObserver>> out)) \
AMS_SF_METHOD_INFO(C, H, 21, Result, Command21NotImplemented, (ams::sf::Out<u64> out, u32 in, const ams::sf::InBuffer &buf1, const ams::sf::InBuffer &buf2), hos::Version_11_0_0)
AMS_SF_DEFINE_INTERFACE(IShellInterface, AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO);
}
AMS_SF_DEFINE_INTERFACE(ams::pgl::sf, IShellInterface, AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO);
@@ -20,6 +20,6 @@
namespace ams::pgl::srv {
void Initialize(ShellInterface *interface, MemoryResource *mr);
void Initialize();
}
@@ -20,18 +20,16 @@
namespace ams::pgl::srv {
class ShellInterface final {
class ShellInterface {
NON_COPYABLE(ShellInterface);
NON_MOVEABLE(ShellInterface);
private:
MemoryResource *memory_resource;
using Allocator = ams::sf::ExpHeapAllocator;
using ObjectFactory = ams::sf::ObjectFactory<ams::sf::ExpHeapAllocator::Policy>;
private:
Allocator *m_allocator;
public:
constexpr ShellInterface() : memory_resource(nullptr) { /* ... */ }
void Initialize(MemoryResource *mr) {
AMS_ASSERT(this->memory_resource == nullptr);
this->memory_resource = mr;
}
constexpr ShellInterface(Allocator *a) : m_allocator(a) { /* ... */ }
public:
/* Interface commands. */
Result LaunchProgram(ams::sf::Out<os::ProcessId> out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags);
@@ -46,7 +44,7 @@ namespace ams::pgl::srv {
Result EnableApplicationAllThreadDumpOnCrash(bool enabled);
Result TriggerApplicationSnapShotDumper(SnapShotDumpType dump_type, const ams::sf::InBuffer &arg);
Result GetShellEventObserver(ams::sf::Out<std::shared_ptr<pgl::sf::IEventObserver>> out);
Result GetShellEventObserver(ams::sf::Out<ams::sf::SharedPointer<pgl::sf::IEventObserver>> out);
Result Command21NotImplemented(ams::sf::Out<u64> out, u32 in, const ams::sf::InBuffer &buf1, const ams::sf::InBuffer &buf2);
};
static_assert(pgl::sf::IsIShellInterface<ShellInterface>);
@@ -19,12 +19,8 @@
#include <stratosphere/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::pm::impl {
#define AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, void, GetBootMode, (sf::Out<u32> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, void, SetMaintenanceBoot, (), ())
#define AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, void, GetBootMode, (sf::Out<u32> out)) \
AMS_SF_METHOD_INFO(C, H, 1, void, SetMaintenanceBoot, ())
AMS_SF_DEFINE_INTERFACE(IBootModeInterface, AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IBootModeInterface, AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO)
@@ -19,32 +19,28 @@
#include <stratosphere/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::pm::impl {
#define AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetExceptionProcessIdList, (sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids), (out_count, out_process_ids)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, StartProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id), (out_hook, program_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetApplicationProcessId, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook), (out_hook)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, ClearHook, (u32 which), (which), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id), (out_process_handle, out_loc, out_status, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out<s64> out_cur_val, sf::Out<s64> out_lim_val, u32 group, u32 resource), (out_cur_val, out_lim_val, group, resource))
#define AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetExceptionProcessIdList, (sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, StartProcess, (os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetApplicationProcessId, (sf::Out<os::ProcessId> out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, ClearHook, (u32 which), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out<s64> out_cur_val, sf::Out<s64> out_lim_val, u32 group, u32 resource))
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IDebugMonitorInterface, AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
AMS_SF_DEFINE_INTERFACE(IDebugMonitorInterface, AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
#define AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetModuleIdList, (sf::Out<u32> out_count, const sf::OutBuffer &out_buf, u64 unused), (out_count, out_buf, unused)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetExceptionProcessIdList, (sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids), (out_count, out_process_ids)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, StartProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id), (out_hook, program_id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook), (out_hook)) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id), (out_process_handle, out_loc, out_status, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out<s64> out_cur_val, sf::Out<s64> out_lim_val, u32 group, u32 resource), (out_cur_val, out_lim_val, group, resource))
#define AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetModuleIdList, (sf::Out<u32> out_count, const sf::OutBuffer &out_buf, u64 unused)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetExceptionProcessIdList, (sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, StartProcess, (os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (sf::Out<os::ProcessId> out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook)) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out<s64> out_cur_val, sf::Out<s64> out_lim_val, u32 group, u32 resource))
AMS_SF_DEFINE_INTERFACE(IDeprecatedDebugMonitorInterface, AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IDeprecatedDebugMonitorInterface, AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
@@ -19,14 +19,10 @@
#include <stratosphere/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::pm::impl {
#define AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetProgramId, (sf::Out<ncm::ProgramId> out, os::ProcessId process_id), (out, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereHasLaunchedBootProgram, (sf::Out<bool> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmosphereGetProcessInfo, (sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id), (out_loc, out_status, process_id))
#define AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetProgramId, (sf::Out<ncm::ProgramId> out, os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereHasLaunchedProgram, (sf::Out<bool> out, ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmosphereGetProcessInfo, (sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id))
AMS_SF_DEFINE_INTERFACE(IInformationInterface, AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IInformationInterface, AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO)
@@ -19,34 +19,30 @@
#include <stratosphere/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::pm::impl {
#define AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out<os::ProcessId> out_process_id, const ncm::ProgramLocation &loc, u32 flags), (out_process_id, loc, flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id), (program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out<pm::ProcessEventInfo> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, void, NotifyBootFinished, (), ()) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetApplicationProcessIdForShell, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), (boost_size)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, BoostApplicationThreadResourceLimit, (), (), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, void, GetBootFinishedEventHandle, (sf::OutCopyHandle out), (out), hos::Version_8_0_0)
#define AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out<os::ProcessId> out_process_id, const ncm::ProgramLocation &loc, u32 flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out)) \
AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out<ProcessEventInfo> out)) \
AMS_SF_METHOD_INFO(C, H, 5, void, NotifyBootFinished, ()) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetApplicationProcessIdForShell, (sf::Out<os::ProcessId> out)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, BoostSystemMemoryResourceLimit, (u64 boost_size)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, BoostApplicationThreadResourceLimit, (), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, void, GetBootFinishedEventHandle, (sf::OutCopyHandle out), hos::Version_8_0_0)
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IShellInterface, AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO)
AMS_SF_DEFINE_INTERFACE(IShellInterface, AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO)
#define AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out<os::ProcessId> out_process_id, const ncm::ProgramLocation &loc, u32 flags), (out_process_id, loc, flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id), (program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out<pm::ProcessEventInfo> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, CleanupProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, ClearExceptionOccurred, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 7, void, NotifyBootFinished, (), ()) \
AMS_SF_METHOD_INFO(C, H, 8, Result, GetApplicationProcessIdForShell, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), (boost_size), hos::Version_4_0_0)
#define AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out<os::ProcessId> out_process_id, const ncm::ProgramLocation &loc, u32 flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out)) \
AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out<ProcessEventInfo> out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, CleanupProcess, (os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, ClearExceptionOccurred, (os::ProcessId process_id)) \
AMS_SF_METHOD_INFO(C, H, 7, void, NotifyBootFinished, ()) \
AMS_SF_METHOD_INFO(C, H, 8, Result, GetApplicationProcessIdForShell, (sf::Out<os::ProcessId> out)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), hos::Version_4_0_0)
AMS_SF_DEFINE_INTERFACE(IDeprecatedShellInterface, AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IDeprecatedShellInterface, AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO)
@@ -27,12 +27,12 @@ namespace ams::pm::info {
/* Information API. */
Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id);
Result GetProcessId(os::ProcessId *out_process_id, ncm::ProgramId program_id);
Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id);
Result HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id);
Result GetProcessInfo(ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id);
/* Information convenience API. */
bool HasLaunchedProgram(ncm::ProgramId program_id);
bool HasLaunchedBootProgram(ncm::ProgramId program_id);
Result IsHblProcessId(bool *out, os::ProcessId process_id);
Result IsHblProgramId(bool *out, ncm::ProgramId program_id);
@@ -26,7 +26,7 @@ namespace ams::psc {
NON_COPYABLE(PmModule);
NON_MOVEABLE(PmModule);
private:
std::shared_ptr<psc::sf::IPmModule> intf;
ams::sf::SharedPointer<psc::sf::IPmModule> intf;
os::SystemEvent system_event;
bool initialized;
PmModuleId module_id;
@@ -19,7 +19,7 @@
namespace ams::psc {
enum PmModuleId : u16 {
enum PmModuleId : u32 {
PmModuleId_Usb = 4,
PmModuleId_Ethernet = 5,
PmModuleId_Fgm = 6,
@@ -19,15 +19,11 @@
#include <stratosphere/psc/psc_types.hpp>
#include <stratosphere/psc/psc_pm_module_id.hpp>
namespace ams::psc::sf {
#define AMS_PSC_I_PM_MODULE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list), (out, module_id, child_list)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetRequest, (ams::sf::Out<psc::PmState> out_state, ams::sf::Out<psc::PmFlagSet> out_flags), (out_state, out_flags)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Acknowledge, (), ()) \
AMS_SF_METHOD_INFO(C, H, 3, Result, Finalize, (), ()) \
AMS_SF_METHOD_INFO(C, H, 4, Result, AcknowledgeEx, (psc::PmState state), (state), hos::Version_5_1_0)
#define AMS_PSC_I_PM_MODULE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetRequest, (ams::sf::Out<PmState> out_state, ams::sf::Out<PmFlagSet> out_flags)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Acknowledge, ()) \
AMS_SF_METHOD_INFO(C, H, 3, Result, Finalize, ()) \
AMS_SF_METHOD_INFO(C, H, 4, Result, AcknowledgeEx, (PmState state), hos::Version_5_1_0)
AMS_SF_DEFINE_INTERFACE(IPmModule, AMS_PSC_I_PM_MODULE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::psc::sf, IPmModule, AMS_PSC_I_PM_MODULE_INTERFACE_INFO)
@@ -18,11 +18,7 @@
#include <vapours.hpp>
#include <stratosphere/psc/sf/psc_sf_i_pm_module.hpp>
namespace ams::psc::sf {
#define AMS_PSC_I_PM_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::Out<ams::sf::SharedPointer<psc::sf::IPmModule>> out), (out))
#define AMS_PSC_I_PM_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::Out<std::shared_ptr<psc::sf::IPmModule>> out))
AMS_SF_DEFINE_INTERFACE(IPmService, AMS_PSC_I_PM_SERVICE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::psc::sf, IPmService, AMS_PSC_I_PM_SERVICE_INTERFACE_INFO)
@@ -20,7 +20,7 @@
namespace ams::pwm {
void InitializeWith(std::shared_ptr<pwm::sf::IManager> &&sp);
void InitializeWith(ams::sf::SharedPointer<pwm::sf::IManager> sp);
void Finalize();
}
@@ -20,6 +20,6 @@
namespace ams::pwm::server {
std::shared_ptr<pwm::sf::IManager> GetServiceObject();
ams::sf::SharedPointer<pwm::sf::IManager> GetServiceObject();
}
@@ -18,18 +18,14 @@
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
namespace ams::pwm::sf {
#define AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetPeriod, (TimeSpanType period), (period) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetPeriod, (ams::sf::Out<TimeSpanType> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetDuty, (int duty), (duty) ) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetDuty, (ams::sf::Out<int> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabled, (bool enabled), (enabled) ) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetEnabled, (ams::sf::Out<bool> out), (out) ) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SetScale, (double scale), (scale), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetScale, (ams::sf::Out<double> out), (out), hos::Version_6_0_0)
#define AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetPeriod, (TimeSpanType period) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetPeriod, (ams::sf::Out<TimeSpanType> out) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetDuty, (int duty) ) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetDuty, (ams::sf::Out<int> out) ) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabled, (bool enabled) ) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetEnabled, (ams::sf::Out<bool> out) ) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SetScale, (double scale), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetScale, (ams::sf::Out<double> out), hos::Version_6_0_0)
AMS_SF_DEFINE_INTERFACE(IChannelSession, AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::pwm::sf, IChannelSession, AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO)
@@ -20,13 +20,9 @@
#include <stratosphere/pwm/pwm_select_channel_name.hpp>
#include <stratosphere/pwm/sf/pwm_sf_i_channel_session.hpp>
namespace ams::pwm::sf {
#define AMS_PWM_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, int channel), (out, channel) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name), (out, channel_name) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenSession2, (ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, DeviceCode device_code), (out, device_code), hos::Version_6_0_0)
#define AMS_PWM_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, int channel) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenSession2, (ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, DeviceCode device_code), hos::Version_6_0_0)
AMS_SF_DEFINE_INTERFACE(IManager, AMS_PWM_I_MANAGER_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::pwm::sf, IManager, AMS_PWM_I_MANAGER_INTERFACE_INFO)
@@ -19,11 +19,7 @@
#include <stratosphere/ro/ro_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::ro::impl {
#define AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessModuleInfo, (sf::Out<u32> out_count, const sf::OutArray<LoaderModuleInfo> &out_infos, os::ProcessId process_id), (out_count, out_infos, process_id))
#define AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessModuleInfo, (sf::Out<u32> out_count, const sf::OutArray<LoaderModuleInfo> &out_infos, os::ProcessId process_id))
AMS_SF_DEFINE_INTERFACE(IDebugMonitorInterface, AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ro::impl, IDebugMonitorInterface, AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO)
@@ -19,16 +19,12 @@
#include <stratosphere/ro/ro_types.hpp>
#include <stratosphere/sf.hpp>
namespace ams::ro::impl {
#define AMS_RO_I_RO_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, MapManualLoadModuleMemory, (sf::Out<u64> out_load_address, const sf::ClientProcessId &client_pid, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size), (out_load_address, client_pid, nro_address, nro_size, bss_address, bss_size)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, UnmapManualLoadModuleMemory, (const sf::ClientProcessId &client_pid, u64 nro_address), (client_pid, nro_address)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, RegisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size), (client_pid, nrr_address, nrr_size)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, UnregisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address), (client_pid, nrr_address)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, RegisterProcessHandle, (const sf::ClientProcessId &client_pid, sf::CopyHandle process_h), (client_pid, process_h)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, RegisterProcessModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h), (client_pid, nrr_address, nrr_size, process_h), hos::Version_7_0_0)
#define AMS_RO_I_RO_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, MapManualLoadModuleMemory, (sf::Out<u64> out_load_address, const sf::ClientProcessId &client_pid, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, UnmapManualLoadModuleMemory, (const sf::ClientProcessId &client_pid, u64 nro_address)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, RegisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, UnregisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, RegisterProcessHandle, (const sf::ClientProcessId &client_pid, sf::CopyHandle process_h)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, RegisterProcessModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h), hos::Version_7_0_0)
AMS_SF_DEFINE_INTERFACE(IRoInterface, AMS_RO_I_RO_INTERFACE_INTERFACE_INFO)
}
AMS_SF_DEFINE_INTERFACE(ams::ro::impl, IRoInterface, AMS_RO_I_RO_INTERFACE_INTERFACE_INFO)
@@ -17,8 +17,13 @@
#pragma once
#include <stratosphere/sf/sf_common.hpp>
#include <stratosphere/sf/sf_allocation_policies.hpp>
#include <stratosphere/sf/sf_lmem_utility.hpp>
#include <stratosphere/sf/sf_mem_utility.hpp>
#include <stratosphere/sf/sf_exp_heap_allocator.hpp>
#include <stratosphere/sf/sf_standard_allocation_policy.hpp>
#include <stratosphere/sf/sf_std_allocation_policy.hpp>
#include <stratosphere/sf/sf_shared_object.hpp>
#include <stratosphere/sf/sf_service_object.hpp>
#include <stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp>
@@ -28,7 +33,10 @@
#include <stratosphere/sf/sf_out.hpp>
#include <stratosphere/sf/sf_buffers.hpp>
#include <stratosphere/sf/impl/sf_impl_command_serialization.hpp>
#include <stratosphere/sf/impl/sf_impl_service_object_macros.hpp>
#include <stratosphere/sf/impl/sf_impl_autogen_interface_macros.hpp>
#include <stratosphere/sf/impl/sf_impl_autogen_impl_macros.hpp>
#include <stratosphere/sf/impl/sf_impl_template_base.hpp>
#include <stratosphere/sf/sf_object_factory.hpp>
#include <stratosphere/sf/hipc/sf_hipc_server_manager.hpp>
@@ -15,9 +15,10 @@
*/
#pragma once
#include "../sf_common.hpp"
#include "sf_cmif_domain_api.hpp"
#include "sf_cmif_domain_service_object.hpp"
#include <stratosphere/sf/sf_common.hpp>
#include <stratosphere/sf/cmif/sf_cmif_domain_api.hpp>
#include <stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp>
#include <stratosphere/sf/impl/sf_service_object_impl.hpp>
namespace ams::sf::cmif {
@@ -39,7 +40,7 @@ namespace ams::sf::cmif {
explicit Entry() : owner(nullptr) { /* ... */ }
};
class Domain final : public DomainServiceObject {
class Domain final : public DomainServiceObject, private sf::impl::ServiceObjectImplBase2 {
NON_COPYABLE(Domain);
NON_MOVEABLE(Domain);
private:
@@ -51,7 +52,17 @@ namespace ams::sf::cmif {
explicit Domain(ServerDomainManager *m) : manager(m) { /* ... */ }
~Domain();
void DestroySelf();
void DisposeImpl();
virtual void AddReference() {
ServiceObjectImplBase2::AddReferenceImpl();
}
virtual void Release() {
if (ServiceObjectImplBase2::ReleaseImpl()) {
this->DisposeImpl();
}
}
virtual ServerDomainBase *GetServerDomain() override final {
return static_cast<ServerDomainBase *>(this);
@@ -120,7 +131,7 @@ namespace ams::sf::cmif {
}
public:
static void DestroyDomainServiceObject(DomainServiceObject *obj) {
static_cast<Domain *>(obj)->DestroySelf();
static_cast<Domain *>(obj)->DisposeImpl();
}
};
@@ -84,18 +84,14 @@ namespace ams::sf::cmif {
}
};
template<size_t N, class = std::make_index_sequence<N>>
class ServiceDispatchTableImpl;
template<size_t N, size_t... Is>
class ServiceDispatchTableImpl<N, std::index_sequence<Is...>> : public ServiceDispatchTableBase {
private:
template<size_t>
using EntryType = ServiceCommandMeta;
template<size_t N>
class ServiceDispatchTableImpl : public ServiceDispatchTableBase {
public:
static constexpr size_t NumEntries = N;
private:
const std::array<ServiceCommandMeta, N> entries;
public:
explicit constexpr ServiceDispatchTableImpl(EntryType<Is>... args) : entries { args... } { /* ... */ }
explicit constexpr ServiceDispatchTableImpl(const std::array<ServiceCommandMeta, N> &e) : entries{e} { /* ... */ }
Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageImpl(ctx, in_raw_data, this->entries.data(), this->entries.size());
@@ -104,20 +100,20 @@ namespace ams::sf::cmif {
Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageForMitmImpl(ctx, in_raw_data, this->entries.data(), this->entries.size());
}
constexpr const std::array<ServiceCommandMeta, N> &GetEntries() const {
return this->entries;
}
};
}
template<typename ...Entries>
class ServiceDispatchTable : public impl::ServiceDispatchTableImpl<sizeof...(Entries)> {
template<size_t N>
class ServiceDispatchTable : public impl::ServiceDispatchTableImpl<N> {
public:
explicit constexpr ServiceDispatchTable(Entries... entries) : impl::ServiceDispatchTableImpl<sizeof...(Entries)>(entries...) { /* ... */ }
explicit constexpr ServiceDispatchTable(const std::array<ServiceCommandMeta, N> &e) : impl::ServiceDispatchTableImpl<N>(e) { /* ... */ }
};
#define AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE \
template<typename ServiceImpl> \
static constexpr inline ::ams::sf::cmif::ServiceDispatchTable s_CmifServiceDispatchTable
struct ServiceDispatchMeta {
const impl::ServiceDispatchTableBase *DispatchTable;
Result (impl::ServiceDispatchTableBase::*ProcessHandler)(ServiceDispatchContext &, const cmif::PointerAndSize &) const;
@@ -140,6 +136,16 @@ namespace ams::sf::cmif {
static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl};
};
template<>
struct ServiceDispatchTraits<sf::IServiceObject> {
static constexpr inline auto DispatchTable = ServiceDispatchTable<0>(std::array<ServiceCommandMeta, 0>{});
};
template<>
struct ServiceDispatchTraits<sf::IMitmServiceObject> {
static constexpr inline auto DispatchTable = ServiceDispatchTable<0>(std::array<ServiceCommandMeta, 0>{});
};
template<typename T>
constexpr ALWAYS_INLINE const ServiceDispatchMeta *GetServiceDispatchMeta() {
return &ServiceDispatchTraits<T>::Meta;
@@ -22,7 +22,7 @@ namespace ams::sf::cmif {
class ServiceObjectHolder {
private:
std::shared_ptr<sf::IServiceObject> srv;
SharedPointer<IServiceObject> srv;
const ServiceDispatchMeta *dispatch_meta;
private:
/* Copy constructor. */
@@ -30,7 +30,7 @@ namespace ams::sf::cmif {
ServiceObjectHolder &operator=(const ServiceObjectHolder &o) = delete;
public:
/* Default constructor, null all members. */
ServiceObjectHolder() : srv(nullptr), dispatch_meta(nullptr) { /* ... */ }
ServiceObjectHolder() : srv(nullptr, false), dispatch_meta(nullptr) { /* ... */ }
~ServiceObjectHolder() {
this->dispatch_meta = nullptr;
@@ -38,9 +38,8 @@ namespace ams::sf::cmif {
/* Ensure correct type id at runtime through template constructor. */
template<typename ServiceImpl>
constexpr explicit ServiceObjectHolder(std::shared_ptr<ServiceImpl> &&s) {
this->srv = std::move(s);
this->dispatch_meta = GetServiceDispatchMeta<ServiceImpl>();
constexpr explicit ServiceObjectHolder(SharedPointer<ServiceImpl> &&s) : srv(std::move(s)), dispatch_meta(GetServiceDispatchMeta<ServiceImpl>()) {
/* ... */
}
/* Move constructor, assignment operator. */
@@ -50,13 +49,13 @@ namespace ams::sf::cmif {
ServiceObjectHolder &operator=(ServiceObjectHolder &&o) {
ServiceObjectHolder tmp(std::move(o));
tmp.Swap(*this);
tmp.swap(*this);
return *this;
}
/* State management. */
void Swap(ServiceObjectHolder &o) {
std::swap(this->srv, o.srv);
void swap(ServiceObjectHolder &o) {
this->srv.swap(o.srv);
std::swap(this->dispatch_meta, o.dispatch_meta);
}
@@ -86,21 +85,21 @@ namespace ams::sf::cmif {
return 0;
}
template<typename ServiceImpl>
template<typename Interface>
constexpr inline bool IsServiceObjectValid() const {
return this->GetServiceId() == GetServiceDispatchMeta<ServiceImpl>()->GetServiceId();
return this->GetServiceId() == GetServiceDispatchMeta<Interface>()->GetServiceId();
}
template<typename ServiceImpl>
inline std::shared_ptr<ServiceImpl> GetServiceObject() const {
if (this->GetServiceId() == GetServiceDispatchMeta<ServiceImpl>()->GetServiceId()) {
return std::static_pointer_cast<ServiceImpl>(this->srv);
template<typename Interface>
inline Interface *GetServiceObject() const {
if (this->GetServiceId() == GetServiceDispatchMeta<Interface>()->GetServiceId()) {
return static_cast<Interface *>(this->srv.Get());
}
return nullptr;
}
inline sf::IServiceObject *GetServiceObjectUnsafe() const {
return this->srv.get();
return static_cast<sf::IServiceObject *>(this->srv.Get());
}
/* Processing. */
@@ -46,74 +46,30 @@ namespace ams::sf::hipc {
protected:
using ServerDomainSessionManager::DomainEntryStorage;
using ServerDomainSessionManager::DomainStorage;
private:
class ServerBase : public os::WaitableHolderType {
protected:
class Server : public os::WaitableHolderType {
friend class ServerManagerBase;
template<size_t, typename, size_t>
friend class ServerManager;
NON_COPYABLE(ServerBase);
NON_MOVEABLE(ServerBase);
protected:
cmif::ServiceObjectHolder static_object;
::Handle port_handle;
sm::ServiceName service_name;
bool service_managed;
public:
ServerBase(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) :
static_object(std::move(sh)), port_handle(ph), service_name(sn), service_managed(m)
{
hipc::AttachWaitableHolderForAccept(this, ph);
}
virtual ~ServerBase() = 0;
virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const = 0;
};
template<typename Interface, auto MakeShared>
class Server : public ServerBase {
NON_COPYABLE(Server);
NON_MOVEABLE(Server);
private:
static constexpr bool IsMitmServer = sf::IsMitmServiceObject<Interface>;
cmif::ServiceObjectHolder static_object;
::Handle port_handle;
sm::ServiceName service_name;
int index;
bool service_managed;
bool is_mitm_server;
public:
Server(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) : ServerBase(ph, sn, m, std::forward<cmif::ServiceObjectHolder>(sh)) {
/* ... */
}
void AcknowledgeMitmSession(std::shared_ptr<::Service> *out_fsrv, sm::MitmProcessInfo *out_client_info) {
/* Check mitm server. */
AMS_ABORT_UNLESS(this->is_mitm_server);
virtual ~Server() override {
if (this->service_managed) {
if constexpr (IsMitmServer) {
R_ABORT_UNLESS(sm::mitm::UninstallMitm(this->service_name));
} else {
R_ABORT_UNLESS(sm::UnregisterService(this->service_name));
}
R_ABORT_UNLESS(svc::CloseHandle(this->port_handle));
}
}
/* Create forward service. */
*out_fsrv = ServerSession::CreateForwardService();
virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const override final {
/* If we're serving a static object, use it. */
if (this->static_object) {
*out_obj = std::move(this->static_object.Clone());
*out_fsrv = nullptr;
return;
}
/* Otherwise, we're either a mitm session or a non-mitm session. */
if constexpr (IsMitmServer) {
/* Custom deleter ensures that nothing goes awry. */
std::shared_ptr<::Service> forward_service = std::move(ServerSession::CreateForwardService());
/* Get mitm forward session. */
sm::MitmProcessInfo client_info;
R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(forward_service.get(), &client_info, this->service_name));
*out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared(std::shared_ptr<::Service>(forward_service), client_info))));
*out_fsrv = std::move(forward_service);
} else {
*out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared())));
*out_fsrv = nullptr;
}
/* Get client info. */
R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(out_fsrv->get(), out_client_info, this->service_name));
}
};
private:
@@ -139,33 +95,99 @@ namespace ams::sf::hipc {
Result ProcessForMitmServer(os::WaitableHolderType *holder);
Result ProcessForSession(os::WaitableHolderType *holder);
template<typename Interface, auto MakeShared>
void RegisterServerImpl(Handle port_handle, sm::ServiceName service_name, bool managed, cmif::ServiceObjectHolder &&static_holder) {
/* Allocate server memory. */
auto *server = this->AllocateServer();
AMS_ABORT_UNLESS(server != nullptr);
new (server) Server<Interface, MakeShared>(port_handle, service_name, managed, std::forward<cmif::ServiceObjectHolder>(static_holder));
void RegisterServerImpl(Server *server, Handle port_handle, bool is_mitm_server) {
server->port_handle = port_handle;
hipc::AttachWaitableHolderForAccept(server, port_handle);
if constexpr (!sf::IsMitmServiceObject<Interface>) {
/* Non-mitm server. */
os::SetWaitableHolderUserData(server, static_cast<uintptr_t>(UserDataTag::Server));
} else {
server->is_mitm_server = is_mitm_server;
if (is_mitm_server) {
/* Mitm server. */
os::SetWaitableHolderUserData(server, static_cast<uintptr_t>(UserDataTag::MitmServer));
} else {
/* Non-mitm server. */
os::SetWaitableHolderUserData(server, static_cast<uintptr_t>(UserDataTag::Server));
}
os::LinkWaitableHolder(std::addressof(this->waitable_manager), server);
}
template<typename Interface, typename ServiceImpl>
static constexpr inline std::shared_ptr<Interface> MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) {
return sf::MakeShared<Interface, ServiceImpl>(std::forward<std::shared_ptr<::Service>>(s), client_info);
void RegisterServerImpl(int index, cmif::ServiceObjectHolder &&static_holder, Handle port_handle, bool is_mitm_server) {
/* Allocate server memory. */
auto *server = this->AllocateServer();
AMS_ABORT_UNLESS(server != nullptr);
server->service_managed = false;
if (static_holder) {
server->static_object = std::move(static_holder);
} else {
server->index = index;
}
this->RegisterServerImpl(server, port_handle, is_mitm_server);
}
Result RegisterServerImpl(int index, cmif::ServiceObjectHolder &&static_holder, sm::ServiceName service_name, size_t max_sessions) {
/* Register service. */
Handle port_handle;
R_TRY(sm::RegisterService(&port_handle, service_name, max_sessions, false));
/* Allocate server memory. */
auto *server = this->AllocateServer();
AMS_ABORT_UNLESS(server != nullptr);
server->service_managed = true;
server->service_name = service_name;
if (static_holder) {
server->static_object = std::move(static_holder);
} else {
server->index = index;
}
this->RegisterServerImpl(server, port_handle, false);
return ResultSuccess();
}
template<typename Interface>
Result RegisterMitmServerImpl(int index, cmif::ServiceObjectHolder &&static_holder, sm::ServiceName service_name) {
/* Install mitm service. */
Handle port_handle;
R_TRY(this->InstallMitmServerImpl(&port_handle, service_name, &Interface::ShouldMitm));
/* Allocate server memory. */
auto *server = this->AllocateServer();
AMS_ABORT_UNLESS(server != nullptr);
server->service_managed = true;
server->service_name = service_name;
if (static_holder) {
server->static_object = std::move(static_holder);
} else {
server->index = index;
}
this->RegisterServerImpl(server, port_handle, true);
return ResultSuccess();
}
Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func);
protected:
virtual ServerBase *AllocateServer() = 0;
virtual void DestroyServer(ServerBase *server) = 0;
virtual Server *AllocateServer() = 0;
virtual void DestroyServer(Server *server) = 0;
virtual Result OnNeedsToAccept(int port_index, Server *server) {
AMS_ABORT("OnNeedsToAccept must be overridden when using indexed ports");
}
template<typename Interface>
Result AcceptImpl(Server *server, SharedPointer<Interface> p) {
return ServerSessionManager::AcceptSession(server->port_handle, std::move(p));
}
template<typename Interface>
Result AcceptMitmImpl(Server *server, SharedPointer<Interface> p, std::shared_ptr<::Service> forward_service) {
return ServerSessionManager::AcceptMitmSession(server->port_handle, std::move(p), std::move(forward_service));
}
public:
ServerManagerBase(DomainEntryStorage *entry_storage, size_t entry_count) :
ServerDomainSessionManager(entry_storage, entry_count),
@@ -181,40 +203,27 @@ namespace ams::sf::hipc {
os::InitializeWaitableManager(std::addressof(this->waitlist));
}
template<typename Interface, typename ServiceImpl, auto MakeShared = sf::MakeShared<Interface, ServiceImpl>> requires (sf::IsServiceObject<Interface> && !sf::IsMitmServiceObject<Interface>)
void RegisterServer(Handle port_handle, std::shared_ptr<Interface> static_object = nullptr) {
/* Register server. */
cmif::ServiceObjectHolder static_holder;
if (static_object != nullptr) {
static_holder = cmif::ServiceObjectHolder(std::move(static_object));
}
this->RegisterServerImpl<Interface, MakeShared>(port_handle, sm::InvalidServiceName, false, std::move(static_holder));
template<typename Interface>
void RegisterObjectForServer(SharedPointer<Interface> static_object, Handle port_handle) {
this->RegisterServerImpl(0, cmif::ServiceObjectHolder(std::move(static_object)), port_handle, false);
}
template<typename Interface, typename ServiceImpl, auto MakeShared = sf::MakeShared<Interface, ServiceImpl>> requires (sf::IsServiceObject<Interface> && !sf::IsMitmServiceObject<Interface>)
Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr<Interface> static_object = nullptr) {
/* Register service. */
Handle port_handle;
R_TRY(sm::RegisterService(&port_handle, service_name, max_sessions, false));
/* Register server. */
cmif::ServiceObjectHolder static_holder;
if (static_object != nullptr) {
static_holder = cmif::ServiceObjectHolder(std::move(static_object));
}
this->RegisterServerImpl<Interface, MakeShared>(port_handle, service_name, true, std::move(static_holder));
return ResultSuccess();
template<typename Interface>
Result RegisterObjectForServer(SharedPointer<Interface> static_object, sm::ServiceName service_name, size_t max_sessions) {
return this->RegisterServerImpl(0, cmif::ServiceObjectHolder(std::move(static_object)), service_name, max_sessions);
}
template<typename Interface, typename ServiceImpl, auto MakeShared = MakeSharedMitm<Interface, ServiceImpl>>
requires (sf::IsMitmServiceObject<Interface> && sf::IsMitmServiceImpl<ServiceImpl>)
Result RegisterMitmServer(sm::ServiceName service_name) {
/* Install mitm service. */
Handle port_handle;
R_TRY(this->InstallMitmServerImpl(&port_handle, service_name, &ServiceImpl::ShouldMitm));
void RegisterServer(int port_index, Handle port_handle) {
this->RegisterServerImpl(port_index, cmif::ServiceObjectHolder(), port_handle, false);
}
this->RegisterServerImpl<Interface, MakeShared>(port_handle, service_name, true, cmif::ServiceObjectHolder());
return ResultSuccess();
Result RegisterServer(int port_index, sm::ServiceName service_name, size_t max_sessions) {
return this->RegisterServerImpl(port_index, cmif::ServiceObjectHolder(), service_name, max_sessions);
}
template<typename Interface>
Result RegisterMitmServer(int port_index, sm::ServiceName service_name) {
return this->template RegisterMitmServerImpl<Interface>(port_index, cmif::ServiceObjectHolder(), service_name);
}
/* Processing. */
@@ -251,7 +260,7 @@ namespace ams::sf::hipc {
private:
/* Resource storage. */
os::Mutex resource_mutex;
TYPED_STORAGE(ServerBase) server_storages[MaxServers];
TYPED_STORAGE(Server) server_storages[MaxServers];
bool server_allocated[MaxServers];
TYPED_STORAGE(ServerSession) session_storages[MaxSessions];
bool session_allocated[MaxSessions];
@@ -265,7 +274,7 @@ namespace ams::sf::hipc {
bool domain_allocated[ManagerOptions::MaxDomains];
DomainEntryStorage domain_entry_storages[ManagerOptions::MaxDomainObjects];
private:
constexpr inline size_t GetServerIndex(const ServerBase *server) const {
constexpr inline size_t GetServerIndex(const Server *server) const {
const size_t i = server - GetPointer(this->server_storages[0]);
AMS_ABORT_UNLESS(i < MaxServers);
return i;
@@ -299,7 +308,7 @@ namespace ams::sf::hipc {
this->session_allocated[index] = false;
}
virtual ServerBase *AllocateServer() override final {
virtual Server *AllocateServer() override final {
std::scoped_lock lk(this->resource_mutex);
for (size_t i = 0; i < MaxServers; i++) {
if (!this->server_allocated[i]) {
@@ -310,11 +319,22 @@ namespace ams::sf::hipc {
return nullptr;
}
virtual void DestroyServer(ServerBase *server) override final {
virtual void DestroyServer(Server *server) override final {
std::scoped_lock lk(this->resource_mutex);
const size_t index = this->GetServerIndex(server);
AMS_ABORT_UNLESS(this->server_allocated[index]);
server->~ServerBase();
{
os::UnlinkWaitableHolder(server);
os::FinalizeWaitableHolder(server);
if (server->service_managed) {
if (server->is_mitm_server) {
R_ABORT_UNLESS(sm::mitm::UninstallMitm(server->service_name));
} else {
R_ABORT_UNLESS(sm::UnregisterService(server->service_name));
}
R_ABORT_UNLESS(svc::CloseHandle(server->port_handle));
}
}
this->server_allocated[index] = false;
}
@@ -34,14 +34,14 @@ namespace ams::sf::hipc {
namespace impl {
class HipcManager;
class HipcManagerImpl;
}
class ServerSession : public os::WaitableHolderType {
friend class ServerSessionManager;
friend class ServerManagerBase;
friend class impl::HipcManager;
friend class impl::HipcManagerImpl;
NON_COPYABLE(ServerSession);
NON_MOVEABLE(ServerSession);
private:
@@ -92,16 +92,13 @@ namespace ams::sf::hipc {
/* Allocate session. */
ServerSession *session_memory = this->AllocateSession();
R_UNLESS(session_memory != nullptr, sf::hipc::ResultOutOfSessionMemory());
/* Register session. */
bool succeeded = false;
ON_SCOPE_EXIT {
if (!succeeded) {
this->DestroySession(session_memory);
}
};
auto register_guard = SCOPE_GUARD { this->DestroySession(session_memory); };
R_TRY(ctor(session_memory));
/* Save new session to output. */
succeeded = true;
register_guard.Cancel();
*out = session_memory;
return ResultSuccess();
}
@@ -162,13 +159,13 @@ namespace ams::sf::hipc {
Result RegisterMitmSession(Handle session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv);
Result AcceptMitmSession(Handle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv);
template<typename ServiceImpl>
Result AcceptSession(Handle port_handle, std::shared_ptr<ServiceImpl> obj) {
template<typename Interface>
Result AcceptSession(Handle port_handle, SharedPointer<Interface> obj) {
return this->AcceptSession(port_handle, cmif::ServiceObjectHolder(std::move(obj)));
}
template<typename ServiceImpl>
Result AcceptMitmSession(Handle mitm_port_handle, std::shared_ptr<ServiceImpl> obj, std::shared_ptr<::Service> &&fsrv) {
template<typename Interface>
Result AcceptMitmSession(Handle mitm_port_handle, SharedPointer<Interface> obj, std::shared_ptr<::Service> &&fsrv) {
return this->AcceptMitmSession(mitm_port_handle, cmif::ServiceObjectHolder(std::move(obj)), std::forward<std::shared_ptr<::Service>>(fsrv));
}
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/sf/impl/sf_impl_autogen_interface_macros.hpp>
#include <stratosphere/sf/impl/sf_impl_template_base.hpp>
namespace ams::sf::impl {
#define AMS_SF_IMPL_DEFINE_IMPL_SYNC_METHOD(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
virtual RETURN AMS_SF_IMPL_SYNC_FUNCTION_NAME(NAME) ARGS override { \
return ImplGetter::GetImplPointer(static_cast<ImplHolder *>(this))->NAME ARGNAMES; \
}
#define AMS_SF_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, BASE, CMD_MACRO) \
namespace NAMESPACE { \
\
AMS_SF_DEFINE_INTERFACE_IMPL(BASE, INTERFACE, CMD_MACRO) \
\
} \
\
namespace ams::sf::impl { \
\
template<typename Base, typename ImplHolder, typename ImplGetter, typename Root> \
class ImplTemplateBaseT<::NAMESPACE::INTERFACE, Base, ImplHolder, ImplGetter, Root> : public Base, public ImplHolder { \
public: \
template<typename... Args> \
constexpr explicit ImplTemplateBaseT(Args &&...args) : ImplHolder(std::forward<Args>(args)...) { /* ... */ } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_IMPL_SYNC_METHOD) \
}; \
\
}
#define AMS_SF_DEFINE_INTERFACE(NAMESPACE, INTERFACE, CMD_MACRO) \
AMS_SF_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, ::ams::sf::IServiceObject, CMD_MACRO)
#define AMS_SF_DEFINE_MITM_INTERFACE(NAMESPACE, INTERFACE, CMD_MACRO) \
AMS_SF_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, ::ams::sf::IMitmServiceObject, CMD_MACRO)
#define AMS_SF_DEFINE_INTERFACE_WITH_BASE(NAMESPACE, INTERFACE, BASE, CMD_MACRO) \
namespace NAMESPACE { \
\
AMS_SF_DEFINE_INTERFACE_IMPL(BASE, INTERFACE, CMD_MACRO) \
\
} \
\
namespace ams::sf::impl { \
\
template<typename Base, typename ImplHolder, typename ImplGetter, typename Root> \
class ImplTemplateBaseT<::NAMESPACE::INTERFACE, Base, ImplHolder, ImplGetter, Root> : public ImplTemplateBaseT<BASE, Base, ImplHolder, ImplGetter, Root> { \
private: \
using BaseImplTemplateBase = ImplTemplateBaseT<BASE, Base, ImplHolder, ImplGetter, Root>; \
public: \
template<typename... Args> \
constexpr explicit ImplTemplateBaseT(Args &&...args) : BaseImplTemplateBase(std::forward<Args>(args)...) { /* ... */ } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_IMPL_SYNC_METHOD) \
}; \
\
}
}
@@ -0,0 +1,144 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::sf::impl {
struct SyncFunctionTraits {
public:
template<typename R, typename C, typename... A>
static std::tuple<A...> GetArgsImpl(R(C::*)(A...));
};
template<auto F>
using SyncFunctionArgsType = decltype(SyncFunctionTraits::GetArgsImpl(F));
template<typename T>
struct TypeTag{};
template<size_t First, size_t... Ix>
static constexpr inline size_t ParameterCount = sizeof...(Ix);
#define AMS_SF_IMPL_SYNC_FUNCTION_NAME(FUNCNAME) \
_ams_sf_sync_##FUNCNAME
#define AMS_SF_IMPL_DEFINE_INTERFACE_SYNC_METHOD(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
virtual RETURN AMS_SF_IMPL_SYNC_FUNCTION_NAME(NAME) ARGS = 0;
#define AMS_SF_IMPL_EXTRACT_INTERFACE_SYNC_METHOD_ARGUMENTS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
using NAME##ArgumentsType = ::ams::sf::impl::SyncFunctionArgsType<&CLASSNAME::AMS_SF_IMPL_SYNC_FUNCTION_NAME(NAME)>;
#define AMS_SF_IMPL_DEFINE_INTERFACE_METHOD(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
ALWAYS_INLINE RETURN NAME ARGS { \
return this->AMS_SF_IMPL_SYNC_FUNCTION_NAME(NAME) ARGNAMES; \
}
#define AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
template<typename Interface, typename A> struct NAME##ServiceCommandMetaHolder; \
\
template<typename Interface, typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, NAME##ArgumentsType> \
struct NAME##ServiceCommandMetaHolder<Interface, std::tuple<Arguments...>> { \
static constexpr auto Value = ::ams::sf::impl::MakeServiceCommandMeta<VERSION_MIN, VERSION_MAX, CMD_ID, &Interface::AMS_SF_IMPL_SYNC_FUNCTION_NAME(NAME), RETURN, Interface, Arguments...>(); \
};
#define AMS_SF_IMPL_GET_NULL_FOR_PARAMETER_COUNT(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
, 0
#define AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
NAME##ServiceCommandMetaHolder<Interface, NAME##ArgumentsType>::Value,
template<typename...>
struct Print;
#define AMS_SF_IMPL_DEFINE_INTERFACE(BASECLASS, CLASSNAME, CMD_MACRO) \
class CLASSNAME : public BASECLASS { \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_SYNC_METHOD) \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_EXTRACT_INTERFACE_SYNC_METHOD_ARGUMENTS) \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_METHOD) \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER) \
public: \
template<typename Interface> \
static constexpr inline ::ams::sf::cmif::ServiceDispatchTable s_CmifServiceDispatchTable { \
[] { \
constexpr size_t CurSize = ::ams::sf::impl::ParameterCount<0 CMD_MACRO(CLASSNAME, AMS_SF_IMPL_GET_NULL_FOR_PARAMETER_COUNT) >; \
std::array<::ams::sf::cmif::ServiceCommandMeta, CurSize> cur_entries { CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY) }; \
\
constexpr const auto &BaseEntries = ::ams::sf::cmif::ServiceDispatchTraits<BASECLASS>::DispatchTable.GetEntries(); \
constexpr size_t BaseSize = BaseEntries.size(); \
\
std::array<::ams::sf::cmif::ServiceCommandMeta, BaseSize + CurSize> combined_entries{}; \
for (size_t i = 0; i < BaseSize; ++i) { \
combined_entries[i] = BaseEntries[i]; \
} \
for (size_t i = 0; i < CurSize; ++i) { \
combined_entries[BaseSize + i] = cur_entries[i]; \
} \
\
return ::ams::sf::cmif::ServiceDispatchTable { combined_entries }; \
} () \
}; \
};
#define AMS_SF_IMPL_DEFINE_CONCEPT_HELPERS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
template<typename T, typename... Args> \
concept Is##CLASSNAME##__##NAME##Impl = requires (T &t, Args &&... args) { \
{ t.NAME(std::forward<Args>(args)...) } -> std::same_as<RETURN>; \
}; \
\
template<typename T, typename A> \
struct Is##CLASSNAME##__##NAME##Holder : std::false_type{}; \
\
template<typename T, typename... Args> requires std::same_as<std::tuple<Args...>, CLASSNAME::NAME##ArgumentsType> \
struct Is##CLASSNAME##__##NAME##Holder<T, std::tuple<Args...>> : std::bool_constant<Is##CLASSNAME##__##NAME##Impl<T, Args...>>{}; \
\
template<typename T> \
static constexpr inline bool Is##CLASSNAME##__##NAME = Is##CLASSNAME##__##NAME##Holder<T, CLASSNAME::NAME##ArgumentsType>::value;
#define AMS_SF_IMPL_CHECK_CONCEPT_HELPER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
Is##CLASSNAME##__##NAME<T> &&
#define AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CONCEPT_HELPERS) \
\
template<typename T> \
concept Is##CLASSNAME = CMD_MACRO(CLASSNAME, AMS_SF_IMPL_CHECK_CONCEPT_HELPER) true;
#define AMS_SF_DEFINE_INTERFACE_IMPL(BASECLASS, CLASSNAME, CMD_MACRO) \
AMS_SF_IMPL_DEFINE_INTERFACE(BASECLASS, CLASSNAME, CMD_MACRO) \
AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \
static_assert(Is##CLASSNAME<CLASSNAME>);
#define AMS_SF_METHOD_INFO_7(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, ARGNAMES) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, hos::Version_Min, hos::Version_Max)
#define AMS_SF_METHOD_INFO_8(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, hos::Version_Max)
#define AMS_SF_METHOD_INFO_9(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX)
#define AMS_SF_METHOD_INFO_X(_, _0, _1, _2, _3, _4, _5, _6, _7, _8, FUNC, ...) FUNC
#define AMS_SF_METHOD_INFO(...) \
AMS_SF_METHOD_INFO_X(, ## __VA_ARGS__, AMS_SF_METHOD_INFO_9(__VA_ARGS__), AMS_SF_METHOD_INFO_8(__VA_ARGS__), AMS_SF_METHOD_INFO_7(__VA_ARGS__))
}
@@ -68,34 +68,78 @@ namespace ams::sf {
struct OutObjectTag{};
template<size_t, size_t>
class InOutObjectHolder;
}
template<typename T>
class IsOutForceEnabled<std::shared_ptr<T>> : public std::true_type{};
template<typename ServiceImpl>
class Out<std::shared_ptr<ServiceImpl>> : public impl::OutObjectTag {
static_assert(std::is_base_of<sf::IServiceObject, ServiceImpl>::value, "Out<std::shared_ptr<ServiceImpl>> requires ServiceObject base.");
template<typename ServiceImpl> requires std::derived_from<ServiceImpl, IServiceObject>
class Out<SharedPointer<ServiceImpl>> : public impl::OutObjectTag {
template<typename>
friend class Out;
public:
using ServiceImplType = ServiceImpl;
using Interface = ServiceImpl;
private:
cmif::ServiceObjectHolder *srv;
cmif::DomainObjectId *object_id;
impl::SharedPointerBase *m_out;
cmif::DomainObjectId *m_object_id;
private:
Out(impl::SharedPointerBase *p, cmif::DomainObjectId *o = nullptr) : m_out(p), m_object_id(o) { /* ... */ }
public:
Out(cmif::ServiceObjectHolder *s) : srv(s), object_id(nullptr) { /* ... */ }
Out(cmif::ServiceObjectHolder *s, cmif::DomainObjectId *o) : srv(s), object_id(o) { /* ... */ }
Out(const Out &rhs) : m_out(rhs.m_out), m_object_id(rhs.m_object_id) { /* ... */ }
void SetValue(std::shared_ptr<ServiceImpl> &&s, cmif::DomainObjectId new_object_id = cmif::InvalidDomainObjectId) {
*this->srv = cmif::ServiceObjectHolder(std::move(s));
Out(SharedPointer<ServiceImpl> *out, cmif::DomainObjectId *o = nullptr) : m_out(std::addressof(out->m_base)), m_object_id(o) { /* .... */ }
template<typename U> requires std::derived_from<U, ServiceImpl>
Out(Out<SharedPointer<U>> out) : m_out(out.m_out), m_object_id(out.m_object_id) { /* ... */ }
template<typename U> requires std::derived_from<U, ServiceImpl>
Out(SharedPointer<U> *out, cmif::DomainObjectId *o = nullptr) : m_out(std::addressof(out->m_base)), m_object_id(o) { /* .... */ }
void SetValue(SharedPointer<ServiceImpl> s, cmif::DomainObjectId new_object_id = cmif::InvalidDomainObjectId) {
*m_out = std::move(s.m_base);
if (new_object_id != cmif::InvalidDomainObjectId) {
AMS_ABORT_UNLESS(object_id != nullptr);
*this->object_id = new_object_id;
AMS_ABORT_UNLESS(m_object_id != nullptr);
*m_object_id = new_object_id;
}
}
template<typename U> requires std::derived_from<U, ServiceImpl>
void SetValue(SharedPointer<U> s, cmif::DomainObjectId new_object_id = cmif::InvalidDomainObjectId) {
*m_out = std::move(s.m_base);
if (new_object_id != cmif::InvalidDomainObjectId) {
AMS_ABORT_UNLESS(m_object_id != nullptr);
*m_object_id = new_object_id;
}
}
class DerefProxy {
template<typename>
friend class Out;
private:
Out &m_target;
private:
explicit DerefProxy(Out &t) : m_target(t) { /* ... */ }
public:
DerefProxy &operator=(SharedPointer<ServiceImpl> p) {
m_target.SetValue(std::move(p));
return *this;
}
template<typename U> requires std::derived_from<U, ServiceImpl>
DerefProxy &operator=(SharedPointer<U> p) {
m_target.SetValue(std::move(p));
return *this;
}
};
DerefProxy operator *() {
return DerefProxy(*this);
}
template<typename U>
Out<SharedPointer<U>> DownCast() {
return Out<SharedPointer<U>>(m_out, m_object_id);
}
};
}
@@ -149,8 +193,8 @@ namespace ams::sf::impl {
struct IsInObject : public std::false_type{};
template<typename T>
struct IsInObject<std::shared_ptr<T>> : public std::true_type {
static_assert(std::is_base_of<sf::IServiceObject, T>::value, "Invalid IsInObject<std::shared_ptr<T>>");
struct IsInObject<sf::SharedPointer<T>> : public std::true_type {
static_assert(std::is_base_of<sf::IServiceObject, T>::value, "Invalid IsInObject<sf::SharedPointer<T>>");
};
template<typename T>
@@ -628,6 +672,7 @@ namespace ams::sf::impl {
private:
std::array<cmif::ServiceObjectHolder, NumInObjects> in_object_holders;
std::array<cmif::ServiceObjectHolder, NumOutObjects> out_object_holders;
std::array<TYPED_STORAGE(SharedPointer<sf::IServiceObject>), NumOutObjects> out_shared_pointers;
std::array<cmif::DomainObjectId, NumOutObjects> out_object_ids;
public:
constexpr InOutObjectHolder() : in_object_holders(), out_object_holders() {
@@ -655,8 +700,8 @@ namespace ams::sf::impl {
static_assert(std::tuple_size<ServiceImplTuple>::value == NumInObjects);
#define _SF_IN_OUT_HOLDER_VALIDATE_IN_OBJECT(n) do { \
if constexpr (NumInObjects > n) { \
using SharedPtrToServiceImplType = typename std::tuple_element<n, ServiceImplTuple>::type; \
using ServiceImplType = typename SharedPtrToServiceImplType::element_type; \
using SharedPointerType = typename std::tuple_element<n, ServiceImplTuple>::type; \
using ServiceImplType = typename SharedPointerType::Interface; \
R_UNLESS((this->in_object_holders[n].template IsServiceObjectValid<ServiceImplType>()), sf::cmif::ResultInvalidInObject()); \
} \
} while (0)
@@ -672,15 +717,21 @@ namespace ams::sf::impl {
return ResultSuccess();
}
template<size_t Index, typename ServiceImpl>
std::shared_ptr<ServiceImpl> GetInObject() const {
/* We know from ValidateInObjects() that this will succeed always. */
return this->in_object_holders[Index].template GetServiceObject<ServiceImpl>();
template<size_t Index, typename Interface>
SharedPointer<Interface> *GetOutObjectSharedPointer() {
static_assert(sizeof(SharedPointer<Interface>) == sizeof(SharedPointer<sf::IServiceObject>));
return static_cast<SharedPointer<Interface> *>(static_cast<void *>(&out_shared_pointers[Index]));
}
template<size_t Index, typename ServiceImpl>
Out<std::shared_ptr<ServiceImpl>> GetOutObject() {
return Out<std::shared_ptr<ServiceImpl>>(&this->out_object_holders[Index], &this->out_object_ids[Index]);
template<size_t Index, typename Interface>
Out<SharedPointer<Interface>> GetOutObject() {
auto sp = new (GetOutObjectSharedPointer<Index, Interface>()) SharedPointer<Interface>;
return Out<SharedPointer<Interface>>(sp, &this->out_object_ids[Index]);
}
template<size_t Index, typename Interface>
void SetOutObject() {
this->out_object_holders[Index] = cmif::ServiceObjectHolder(std::move(*GetOutObjectSharedPointer<Index, Interface>()));
}
constexpr void SetOutObjects(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response) {
@@ -985,10 +1036,10 @@ namespace ams::sf::impl {
}
} else if constexpr (Info.arg_type == ArgumentType::InObject) {
/* New InObject. */
return in_out_objects_holder.template GetInObject<Info.in_object_index, typename T::element_type>();
return in_out_objects_holder.template GetInObject<Info.in_object_index, typename T::Interface>();
} else if constexpr (Info.arg_type == ArgumentType::OutObject) {
/* New OutObject. */
return in_out_objects_holder.template GetOutObject<Info.out_object_index, typename T::ServiceImplType>();
return in_out_objects_holder.template GetOutObject<Info.out_object_index, typename T::Interface>();
} else if constexpr (Info.arg_type == ArgumentType::Buffer) {
/* Buffers were already processed earlier. */
if constexpr (sf::IsLargeData<T>) {
@@ -1124,6 +1175,21 @@ namespace ams::sf::impl {
out_handles_holder.CopyTo(response, runtime_metadata.GetOutObjectCount());
/* Set output objects. */
#define _SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(n) do { \
if constexpr (n < CommandMeta::NumOutObjects) { \
in_out_objects_holder.template SetOutObject<n, typename std::tuple_element_t<n, typename CommandMeta::OutObjects>::Interface>(); \
} \
} while (0)
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(0);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(1);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(2);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(3);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(4);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(5);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(6);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(7);
_SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT(8);
#undef _SF_IMPL_PROCESSOR_MARSHAL_OUT_OBJECT
in_out_objects_holder.SetOutObjects(ctx, response);
return ResultSuccess();
@@ -1,327 +0,0 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::sf::impl {
template<typename T>
concept ServiceCommandResult = std::same_as<::ams::Result, T> || std::same_as<void, T>;
template<auto F, typename ...Arguments>
concept Invokable = requires (Arguments &&... args) {
{ F(std::forward<Arguments>(args)...) };
};
struct FunctionTraits {
public:
template<typename R, typename... A>
static std::tuple<A...> GetArgsImpl(R(A...));
};
template<auto F>
using FunctionArgsType = decltype(FunctionTraits::GetArgsImpl(F));
template<typename Class, typename Return, typename ArgsTuple>
struct ClassFunctionPointerHelper;
template<typename Class, typename Return, typename... Arguments>
struct ClassFunctionPointerHelper<Class, Return, std::tuple<Arguments...>> {
using Type = Return (*)(Class *, Arguments &&...);
};
template<typename Class, typename Return, typename ArgsTuple>
using ClassFunctionPointer = typename ClassFunctionPointerHelper<Class, Return, ArgsTuple>::Type;
template<typename T>
struct TypeTag{};
#define AMS_SF_IMPL_HELPER_FUNCTION_NAME_IMPL(CLASSNAME, FUNCNAME, SUFFIX) \
__ams_sf_impl_helper_##CLASSNAME##_##FUNCNAME##_##SUFFIX
#define AMS_SF_IMPL_HELPER_FUNCTION_NAME(CLASSNAME, FUNCNAME) \
AMS_SF_IMPL_HELPER_FUNCTION_NAME_IMPL(CLASSNAME, FUNCNAME, intf)
#define AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, FUNCNAME) \
::ams::sf::impl::FunctionArgsType<AMS_SF_IMPL_HELPER_FUNCTION_NAME(CLASSNAME, FUNCNAME)>
#define AMS_SF_IMPL_CONCEPT_HELPER_FUNCTION_NAME(CLASSNAME, FUNCNAME) \
AMS_SF_IMPL_HELPER_FUNCTION_NAME_IMPL(CLASSNAME, FUNCNAME, intf_for_concept)
#define AMS_SF_IMPL_DECLARE_HELPER_FUNCTIONS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
static void AMS_SF_IMPL_HELPER_FUNCTION_NAME(CLASSNAME, NAME) ARGS { __builtin_unreachable(); } \
template<typename T, typename... Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
static auto AMS_SF_IMPL_CONCEPT_HELPER_FUNCTION_NAME(CLASSNAME, NAME) (T &t, std::tuple<Arguments...> a) { \
return [&]<size_t... Ix>(std::index_sequence<Ix...>) { \
return t.NAME(std::forward<typename std::tuple_element<Ix, decltype(a)>::type>(std::get<Ix>(a))...); \
}(std::make_index_sequence<sizeof...(Arguments)>()); \
}
#define AMS_SF_IMPL_DECLARE_HELPERS(CLASSNAME, CMD_MACRO) \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_HELPER_FUNCTIONS)
#define AMS_SF_IMPL_DECLARE_CONCEPT_REQUIREMENT(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
{ AMS_SF_IMPL_CONCEPT_HELPER_FUNCTION_NAME(CLASSNAME, NAME) (impl, std::declval<AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>()) } -> ::ams::sf::impl::ServiceCommandResult;
#define AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \
template<typename Impl> \
concept Is##CLASSNAME = requires (Impl &impl) { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_CONCEPT_REQUIREMENT) \
};
#define AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
::ams::sf::impl::ClassFunctionPointer<CLASSNAME, RETURN, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>
#define AMS_SF_IMPL_DECLARE_FUNCTION_POINTER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) NAME;
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
RETURN Invoke##NAME##ByCommandTable (Arguments &&... args) { \
return this->cmd_table->NAME(this, std::forward<Arguments>(args)...); \
} \
template<typename ...Arguments> \
requires (::ams::sf::impl::Invokable<AMS_SF_IMPL_HELPER_FUNCTION_NAME(CLASSNAME, NAME), Arguments...> && \
std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>) \
ALWAYS_INLINE RETURN NAME (Arguments &&... args) { \
return this->Invoke##NAME##ByCommandTable(std::forward<Arguments>(args)...); \
} \
template<typename ...Arguments> \
requires (::ams::sf::impl::Invokable<AMS_SF_IMPL_HELPER_FUNCTION_NAME(CLASSNAME, NAME), Arguments...> && \
!std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>) \
ALWAYS_INLINE RETURN NAME (Arguments &&... args) { \
return [this] <typename... CorrectArguments, typename... PassedArguments> ALWAYS_INLINE_LAMBDA (::ams::sf::impl::TypeTag<std::tuple<CorrectArguments...>>, PassedArguments &&...args_) -> RETURN { \
return this->template NAME<CorrectArguments...>(std::forward<CorrectArguments>(args_)...); \
}(::ams::sf::impl::TypeTag<AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>{}, std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
static RETURN NAME##Invoker (CLASSNAME *_this, Arguments &&... args) { \
return static_cast<ImplHolder *>(_this)->NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER_POINTER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
static RETURN NAME##Invoker (CLASSNAME *_this, Arguments &&... args) { \
return static_cast<ImplPointer *>(_this)->NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER_SHARED_POINTER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
static RETURN NAME##Invoker (CLASSNAME *_this, Arguments &&... args) { \
return static_cast<ImplSharedPointer *>(_this)->NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires (std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> && \
std::same_as<RETURN, decltype(impl.NAME(std::declval<Arguments>()...))>) \
RETURN NAME (Arguments &&... args) { \
return this->impl.NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires (std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> && \
std::same_as<RETURN, decltype(impl->NAME(std::declval<Arguments>()...))>) \
RETURN NAME (Arguments &&... args) { \
return this->impl->NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename A> struct NAME##FunctionPointerHolder; \
\
template<typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
struct NAME##FunctionPointerHolder<std::tuple<Arguments...>> { \
static constexpr auto Value = static_cast<AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX)>(&NAME##Invoker<Arguments...>); \
};
#define AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ServiceImpl, typename A> struct NAME##ServiceCommandMetaHolder; \
\
template<typename ServiceImpl, typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
struct NAME##ServiceCommandMetaHolder<ServiceImpl, std::tuple<Arguments...>> { \
static constexpr auto Value = ::ams::sf::impl::MakeServiceCommandMeta<VERSION_MIN, VERSION_MAX, CMD_ID, &ServiceImpl::template Invoke##NAME##ByCommandTable<Arguments...>, RETURN, CLASSNAME, Arguments...>(); \
};
#define AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
.NAME = NAME##FunctionPointerHolder<AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>::Value,
#define AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
NAME##ServiceCommandMetaHolder<ServiceImpl, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>::Value,
template<typename T>
struct Print;
#define AMS_SF_IMPL_DEFINE_CLASS(BASECLASS, CLASSNAME, CMD_MACRO) \
class CLASSNAME : public BASECLASS { \
NON_COPYABLE(CLASSNAME); \
NON_MOVEABLE(CLASSNAME); \
private: \
struct CommandPointerTable { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_FUNCTION_POINTER) \
}; \
private: \
const CommandPointerTable * const cmd_table; \
private: \
CLASSNAME() = delete; \
protected: \
constexpr CLASSNAME(const CommandPointerTable *ct) \
: cmd_table(ct) { /* ... */ } \
virtual ~CLASSNAME() { /* ... */ } \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION) \
private: \
template<typename S, typename T> \
requires ((std::same_as<CLASSNAME, S> && !std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) && \
(::ams::sf::IsMitmServiceObject<S> == ::ams::sf::IsMitmServiceImpl<T>)) \
struct ImplGenerator { \
public: \
class ImplHolder : public S { \
private: \
T impl; \
public: \
template<typename... Args> requires std::constructible_from<T, Args...> \
constexpr ImplHolder(Args &&... args) \
: S(std::addressof(CommandPointerTableImpl)), impl(std::forward<Args>(args)...) \
{ \
/* ... */ \
} \
ALWAYS_INLINE T &GetImpl() { return this->impl; } \
ALWAYS_INLINE const T &GetImpl() const { return this->impl; } \
\
template<typename U = S> requires ::ams::sf::IsMitmServiceObject<S> && std::same_as<U, S> \
static ALWAYS_INLINE bool ShouldMitm(os::ProcessId p, ncm::ProgramId r) { return T::ShouldMitm(p, r); } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER_HOLDER) \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL) \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER) \
public: \
static constexpr CommandPointerTable CommandPointerTableImpl = { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER) \
}; \
}; \
static_assert(Is##CLASSNAME<ImplHolder>); \
\
class ImplPointer : public S { \
private: \
T *impl; \
public: \
constexpr ImplPointer(T *t) \
: S(std::addressof(CommandPointerTableImpl)), impl(t) \
{ \
/* ... */ \
} \
ALWAYS_INLINE T &GetImpl() { return *this->impl; } \
ALWAYS_INLINE const T &GetImpl() const { return *this->impl; } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER_POINTER) \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR) \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER) \
public: \
static constexpr CommandPointerTable CommandPointerTableImpl = { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER) \
}; \
}; \
\
class ImplSharedPointer : public S { \
private: \
std::shared_ptr<T> impl; \
public: \
constexpr ImplSharedPointer(std::shared_ptr<T> &&t) \
: S(std::addressof(CommandPointerTableImpl)), impl(std::move(t)) \
{ \
/* ... */ \
} \
ALWAYS_INLINE T &GetImpl() { return *this->impl; } \
ALWAYS_INLINE const T &GetImpl() const { return *this->impl; } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER_SHARED_POINTER) \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR) \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER) \
public: \
static constexpr CommandPointerTable CommandPointerTableImpl = { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER) \
}; \
}; \
static_assert(Is##CLASSNAME<ImplHolder>); \
}; \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER) \
public: \
template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) \
using ImplHolder = typename ImplGenerator<CLASSNAME, T>::ImplHolder; \
\
template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) \
using ImplPointer = typename ImplGenerator<CLASSNAME, T>::ImplPointer; \
\
template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T> && \
std::derived_from<T, std::enable_shared_from_this<T>>) \
using ImplSharedPointer = typename ImplGenerator<CLASSNAME, T>::ImplSharedPointer; \
\
AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY) \
}; \
};
#define AMS_SF_METHOD_INFO_6(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, hos::Version_Min, hos::Version_Max)
#define AMS_SF_METHOD_INFO_7(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, hos::Version_Max)
#define AMS_SF_METHOD_INFO_8(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX)
#define AMS_SF_METHOD_INFO_X(_, _0, _1, _2, _3, _4, _5, _6, _7, FUNC, ...) FUNC
#define AMS_SF_METHOD_INFO(...) \
AMS_SF_METHOD_INFO_X(, ## __VA_ARGS__, AMS_SF_METHOD_INFO_8(__VA_ARGS__), AMS_SF_METHOD_INFO_7(__VA_ARGS__), AMS_SF_METHOD_INFO_6(__VA_ARGS__))
#define AMS_SF_DEFINE_INTERFACE(CLASSNAME, CMD_MACRO) \
AMS_SF_IMPL_DECLARE_HELPERS(CLASSNAME,CMD_MACRO) \
AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \
AMS_SF_IMPL_DEFINE_CLASS( ::ams::sf::IServiceObject, CLASSNAME, CMD_MACRO) \
static_assert(Is##CLASSNAME<CLASSNAME>);
#define AMS_SF_DEFINE_MITM_INTERFACE(CLASSNAME, CMD_MACRO) \
AMS_SF_IMPL_DECLARE_HELPERS(CLASSNAME,CMD_MACRO) \
AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \
AMS_SF_IMPL_DEFINE_CLASS(::ams::sf::IMitmServiceObject, CLASSNAME, CMD_MACRO) \
static_assert(Is##CLASSNAME<CLASSNAME>);
#define AMS_SF_IMPL_DECLARE_INTERFACE_METHODS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
RETURN NAME ARGS;
#define AMS_SF_DECLARE_INTERFACE_METHODS(CMD_MACRO) \
CMD_MACRO(_, AMS_SF_IMPL_DECLARE_INTERFACE_METHODS)
}
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::sf::impl {
template<typename Interface, typename Base, typename ImplHolder, typename ImplGetter, typename Root>
class ImplTemplateBaseT;
template<typename Interface, typename Base, typename ImplHolder, typename ImplGetter>
class ImplTemplateBase : public ImplTemplateBaseT<Interface, Base, ImplHolder, ImplGetter, Interface> {
private:
using BaseImpl = ImplTemplateBaseT<Interface, Base, ImplHolder, ImplGetter, Interface>;
public:
using BaseImpl::BaseImpl;
};
}
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::sf::impl {
class ServiceObjectImplBase2 {
private:
std::atomic<u32> m_ref_count;
protected:
constexpr ServiceObjectImplBase2() : m_ref_count(1) { /* ... */ }
void AddReferenceImpl() {
const auto prev = m_ref_count.fetch_add(1);
AMS_ABORT_UNLESS(prev < std::numeric_limits<u32>::max());
}
bool ReleaseImpl() {
const auto prev = m_ref_count.fetch_sub(1);
AMS_ABORT_UNLESS(prev != 0);
return prev == 1;
}
};
}
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::sf {
namespace impl {
struct StatelessDummyAllocator;
}
template<typename A>
class StatelessAllocationPolicy {
public:
static constexpr bool HasStatefulAllocator = false;
using Allocator = impl::StatelessDummyAllocator;
template<typename>
using StatelessAllocator = A;
template<typename>
static void *AllocateAligned(size_t size, size_t align) {
return A().Allocate(size);
}
template<typename>
static void DeallocateAligned(void *ptr, size_t size, size_t align) {
A().Deallocate(ptr, size);
}
};
template<template<typename> typename A>
class StatelessTypedAllocationPolicy {
public:
static constexpr bool HasStatefulAllocator = false;
using Allocator = impl::StatelessDummyAllocator;
template<typename T>
using StatelessAllocator = A<T>;
template<typename T>
static void *AllocateAligned(size_t size, size_t align) {
return StatelessAllocator<T>().Allocate(size);
}
template<typename T>
static void DeallocateAligned(void *ptr, size_t size, size_t align) {
StatelessAllocator<T>().Deallocate(ptr, size);
}
};
template<typename A>
class StatefulAllocationPolicy {
public:
static constexpr bool HasStatefulAllocator = true;
using Allocator = A;
static void *AllocateAligned(Allocator *allocator, size_t size, size_t align) {
return allocator->Allocate(size);
}
static void DeallocateAligned(Allocator *allocator, void *ptr, size_t size, size_t align) {
allocator->Deallocate(ptr, size);
}
};
template<typename T>
concept IsStatefulPolicy = T::HasStatefulAllocator;
}
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/sf/sf_common.hpp>
#include <stratosphere/sf/sf_allocation_policies.hpp>
namespace ams::sf {
namespace impl {
void *DefaultAllocateImpl(size_t size, size_t align, size_t offset);
void DefaultDeallocateImpl(void *ptr, size_t size, size_t align, size_t offset);
template<typename T>
class DefaultAllocationPolicyAllocator {
private:
struct Holder {
MemoryResource *allocator;
typename std::aligned_storage<sizeof(T), alignof(T)>::type storage;
};
public:
void *Allocate(size_t size) {
AMS_ASSERT(size == sizeof(T));
return DefaultAllocateImpl(sizeof(Holder), alignof(Holder), offsetof(Holder, storage));
}
void Deallocate(void *ptr, size_t size) {
AMS_ASSERT(size == sizeof(T));
return DefaultDeallocateImpl(ptr, sizeof(Holder), alignof(Holder), offsetof(Holder, storage));
}
};
}
using DefaultAllocationPolicy = StatelessTypedAllocationPolicy<impl::DefaultAllocationPolicyAllocator>;
MemoryResource *GetGlobalDefaultMemoryResource();
MemoryResource *GetCurrentEffectiveMemoryResource();
MemoryResource *GetCurrentMemoryResource();
MemoryResource *GetNewDeleteMemoryResource();
MemoryResource *SetGlobalDefaultMemoryResource(MemoryResource *mr);
MemoryResource *SetCurrentMemoryResource(MemoryResource *mr);
class ScopedCurrentMemoryResourceSetter {
NON_COPYABLE(ScopedCurrentMemoryResourceSetter);
NON_MOVEABLE(ScopedCurrentMemoryResourceSetter);
private:
MemoryResource *m_prev;
public:
explicit ScopedCurrentMemoryResourceSetter(MemoryResource *mr);
~ScopedCurrentMemoryResourceSetter();
};
}
Loaded 100 of 474 files, more files were not shown because too many files have changed in this diff. Show more