| 41 | * Performs a single continuous transfer attempt. |
| 42 | * |
| 43 | * - MemMode::SkipInaccessiblePages: |
| 44 | * Attempts a continuous transfer first. If it fails, switches to page mode |
| 45 | * and skips inaccessible pages. After 64 KiB of contiguous successful |
| 46 | * transfers, it retries continuous mode. |
| 47 | * |
| 48 | * @tparam T Callable type implementing the actual read/write operation. |
| 49 | * |
| 50 | * @param address Starting memory address. |
| 51 | * @param buffer Buffer used for the transfer. |
| 52 | * @param len Number of bytes to transfer. |
| 53 | * @param mode Transfer behavior. |
| 54 | * @param operation Backend memory operation callback. |
| 55 | * |
| 56 | * @return Number of bytes successfully transferred. |
| 57 | */ |
| 58 | template <typename T> |
| 59 | static size_t KittyMemoryTransfer(uintptr_t address, void *buffer, size_t len, MemMode mode, T &&operation) |
| 60 | { |
| 61 | if (!address || !buffer || !len) |
| 62 | return 0; |
| 63 | |
| 64 | size_t total = 0; |
| 65 | |
| 66 | KTTransferState state = KTTransferState::Normal; |