mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 03:09:47 +12:00
revert formatting
This commit is contained in:
parent
124622cf18
commit
863edac152
7 changed files with 338 additions and 331 deletions
|
@ -136,7 +136,7 @@ namespace Audio {
|
|||
const auto counter0 = dspRam.region0.frameCounter;
|
||||
const auto counter1 = dspRam.region1.frameCounter;
|
||||
|
||||
// HandleType wraparound cases first
|
||||
// Handle wraparound cases first
|
||||
if (counter0 == 0xffff && counter1 != 0xfffe) {
|
||||
return 1;
|
||||
} else if (counter1 == 0xffff && counter0 != 0xfffe) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace Common {
|
||||
class CapstoneDisassembler {
|
||||
csh handle; // HandleType to our disassembler object
|
||||
csh handle; // Handle to our disassembler object
|
||||
cs_insn* instructions = nullptr; // Pointer to instruction object
|
||||
bool initialized = false;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "helpers.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result.hpp"
|
||||
|
@ -56,7 +55,7 @@ namespace ArchiveID {
|
|||
default: return "Unknown archive";
|
||||
}
|
||||
}
|
||||
} // namespace ArchiveID
|
||||
}
|
||||
|
||||
struct FSPath {
|
||||
u32 type = PathType::Invalid;
|
||||
|
@ -155,7 +154,7 @@ struct DirectorySession {
|
|||
using FileDescriptor = std::optional<FILE*>;
|
||||
|
||||
class ArchiveBase {
|
||||
public:
|
||||
public:
|
||||
struct FormatInfo {
|
||||
u32 size; // Archive size
|
||||
u32 numOfDirectories; // Number of directories
|
||||
|
@ -163,7 +162,7 @@ class ArchiveBase {
|
|||
bool duplicateData; // Whether to duplicate data or not
|
||||
};
|
||||
|
||||
protected:
|
||||
protected:
|
||||
using HandleType = u32;
|
||||
|
||||
static constexpr FileDescriptor NoFile = nullptr;
|
||||
|
@ -215,7 +214,7 @@ class ArchiveBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual std::string name() = 0;
|
||||
virtual u64 getFreeBytes() = 0;
|
||||
virtual HorizonResult createFile(const FSPath& path, u64 size) = 0;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace KernelHandles {
|
|||
MinServiceHandle = AC,
|
||||
MaxServiceHandle = Y2R,
|
||||
|
||||
GSPSharedMemHandle = MaxServiceHandle + 1, // HandleType for the GSP shared memory
|
||||
GSPSharedMemHandle = MaxServiceHandle + 1, // Handle for the GSP shared memory
|
||||
FontSharedMemHandle,
|
||||
CSNDSharedMemHandle,
|
||||
APTCaptureSharedMemHandle, // Shared memory for display capture info,
|
||||
|
@ -61,10 +61,14 @@ namespace KernelHandles {
|
|||
};
|
||||
|
||||
// Returns whether "handle" belongs to one of the OS services
|
||||
static constexpr bool isServiceHandle(HandleType handle) { return handle >= MinServiceHandle && handle <= MaxServiceHandle; }
|
||||
static constexpr bool isServiceHandle(HandleType handle) {
|
||||
return handle >= MinServiceHandle && handle <= MaxServiceHandle;
|
||||
}
|
||||
|
||||
// Returns whether "handle" belongs to one of the OS services' shared memory areas
|
||||
static constexpr bool isSharedMemHandle(HandleType handle) { return handle >= MinSharedMemHandle && handle <= MaxSharedMemHandle; }
|
||||
static constexpr bool isSharedMemHandle(HandleType handle) {
|
||||
return handle >= MinSharedMemHandle && handle <= MaxSharedMemHandle;
|
||||
}
|
||||
|
||||
// Returns the name of a handle as a string based on the given handle
|
||||
static const char* getServiceName(HandleType handle) {
|
||||
|
@ -106,4 +110,4 @@ namespace KernelHandles {
|
|||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
} // namespace KernelHandles
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ class Kernel {
|
|||
HandleType currentProcess;
|
||||
HandleType mainThread;
|
||||
int currentThreadIndex;
|
||||
HandleType srvHandle; // HandleType for the special service manager port "srv:"
|
||||
HandleType errorPortHandle; // HandleType for the err:f port used for displaying errors
|
||||
HandleType srvHandle; // Handle for the special service manager port "srv:"
|
||||
HandleType errorPortHandle; // Handle for the err:f port used for displaying errors
|
||||
|
||||
u32 arbiterCount;
|
||||
u32 threadCount; // How many threads in our thread pool have been used as of now (Up to 32)
|
||||
|
@ -66,7 +66,7 @@ class Kernel {
|
|||
HandleType makeThread(u32 entrypoint, u32 initialSP, u32 priority, ProcessorID id, u32 arg, ThreadStatus status = ThreadStatus::Dormant);
|
||||
HandleType makeMemoryBlock(u32 addr, u32 size, u32 myPermission, u32 otherPermission);
|
||||
|
||||
public:
|
||||
public:
|
||||
// Needs to be public to be accessible to the APT/HID services
|
||||
HandleType makeEvent(ResetType resetType, Event::CallbackType callback = Event::CallbackType::None);
|
||||
// Needs to be public to be accessible to the APT/DSP services
|
||||
|
@ -88,7 +88,7 @@ class Kernel {
|
|||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void signalArbiter(u32 waitingAddress, s32 threadCount);
|
||||
void sleepThread(s64 ns);
|
||||
void sleepThreadOnArbiter(u32 waitingAddress);
|
||||
|
@ -194,7 +194,7 @@ class Kernel {
|
|||
void closeDirectory(u32 messagePointer, HandleType directory);
|
||||
void readDirectory(u32 messagePointer, HandleType directory);
|
||||
|
||||
public:
|
||||
public:
|
||||
Kernel(CPU& cpu, Memory& mem, GPU& gpu, const EmulatorConfig& config);
|
||||
void initializeFS() { return serviceManager.initializeFS(); }
|
||||
void setVersion(u8 major, u8 minor);
|
||||
|
|
|
@ -1,32 +1,23 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
|
||||
#include "fs/archive_base.hpp"
|
||||
#include "handles.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
enum class KernelObjectType : u8 {
|
||||
AddressArbiter,
|
||||
Archive,
|
||||
Directory,
|
||||
File,
|
||||
MemoryBlock,
|
||||
Process,
|
||||
ResourceLimit,
|
||||
Session,
|
||||
Dummy,
|
||||
AddressArbiter, Archive, Directory, File, MemoryBlock, Process, ResourceLimit, Session, Dummy,
|
||||
// Bundle waitable objects together in the enum to let the compiler optimize certain checks better
|
||||
Event,
|
||||
Mutex,
|
||||
Port,
|
||||
Semaphore,
|
||||
Timer,
|
||||
Thread
|
||||
Event, Mutex, Port, Semaphore, Timer, Thread
|
||||
};
|
||||
|
||||
enum class ResourceLimitCategory : int { Application = 0, SystemApplet = 1, LibraryApplet = 2, Misc = 3 };
|
||||
enum class ResourceLimitCategory : int {
|
||||
Application = 0,
|
||||
SystemApplet = 1,
|
||||
LibraryApplet = 2,
|
||||
Misc = 3
|
||||
};
|
||||
|
||||
// Reset types (for use with events and timers)
|
||||
enum class ResetType {
|
||||
|
@ -35,7 +26,13 @@ enum class ResetType {
|
|||
Pulse = 2, // Only meaningful for timers: same as ONESHOT but it will periodically signal the timer instead of just once.
|
||||
};
|
||||
|
||||
enum class ArbitrationType { Signal = 0, WaitIfLess = 1, DecrementAndWaitIfLess = 2, WaitIfLessTimeout = 3, DecrementAndWaitIfLessTimeout = 4 };
|
||||
enum class ArbitrationType {
|
||||
Signal = 0,
|
||||
WaitIfLess = 1,
|
||||
DecrementAndWaitIfLess = 2,
|
||||
WaitIfLessTimeout = 3,
|
||||
DecrementAndWaitIfLessTimeout = 4
|
||||
};
|
||||
|
||||
enum class ProcessorID : s32 {
|
||||
AllCPUs = -1,
|
||||
|
@ -201,8 +198,7 @@ struct MemoryBlock {
|
|||
u32 otherPermission = 0;
|
||||
bool mapped = false;
|
||||
|
||||
MemoryBlock(u32 addr, u32 size, u32 myPerm, u32 otherPerm)
|
||||
: addr(addr), size(size), myPermission(myPerm), otherPermission(otherPerm), mapped(false) {}
|
||||
MemoryBlock(u32 addr, u32 size, u32 myPerm, u32 otherPerm) : addr(addr), size(size), myPermission(myPerm), otherPermission(otherPerm), mapped(false) {}
|
||||
};
|
||||
|
||||
// Generic kernel object class
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "crypto/aes_engine.hpp"
|
||||
#include "handles.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "loader/3dsx.hpp"
|
||||
#include "loader/ncsd.hpp"
|
||||
#include "loader/3dsx.hpp"
|
||||
#include "services/region_codes.hpp"
|
||||
|
||||
namespace PhysicalAddrs {
|
||||
|
@ -124,7 +124,7 @@ class Memory {
|
|||
SharedMemoryBlock(0, 0xE7000, KernelHandles::APTCaptureSharedMemHandle), // APT Capture Buffer memory
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
static constexpr u32 pageShift = 12;
|
||||
static constexpr u32 pageSize = 1 << pageShift;
|
||||
static constexpr u32 pageMask = pageSize - 1;
|
||||
|
@ -139,7 +139,7 @@ class Memory {
|
|||
static constexpr u32 DSP_CODE_MEMORY_OFFSET = u32(0_KB);
|
||||
static constexpr u32 DSP_DATA_MEMORY_OFFSET = u32(256_KB);
|
||||
|
||||
private:
|
||||
private:
|
||||
std::bitset<FCRAM_PAGE_COUNT> usedFCRAMPages;
|
||||
std::optional<u32> findPaddr(u32 size);
|
||||
u64 timeSince3DSEpoch();
|
||||
|
@ -198,16 +198,22 @@ class Memory {
|
|||
u8* getFCRAM() { return fcram; }
|
||||
|
||||
// Total amount of OS-only FCRAM available (Can vary depending on how much FCRAM the app requests via the cart exheader)
|
||||
u32 totalSysFCRAM() { return FCRAM_SIZE - FCRAM_APPLICATION_SIZE; }
|
||||
u32 totalSysFCRAM() {
|
||||
return FCRAM_SIZE - FCRAM_APPLICATION_SIZE;
|
||||
}
|
||||
|
||||
// Amount of OS-only FCRAM currently available
|
||||
u32 remainingSysFCRAM() { return totalSysFCRAM() - usedSystemMemory; }
|
||||
u32 remainingSysFCRAM() {
|
||||
return totalSysFCRAM() - usedSystemMemory;
|
||||
}
|
||||
|
||||
// Physical FCRAM index to the start of OS FCRAM
|
||||
// We allocate the first part of physical FCRAM for the application, and the rest to the OS. So the index for the OS = application ram size
|
||||
u32 sysFCRAMIndex() { return FCRAM_APPLICATION_SIZE; }
|
||||
|
||||
enum class BatteryLevel { Empty = 0, AlmostEmpty, OneBar, TwoBars, ThreeBars, FourBars };
|
||||
enum class BatteryLevel {
|
||||
Empty = 0, AlmostEmpty, OneBar, TwoBars, ThreeBars, FourBars
|
||||
};
|
||||
u8 getBatteryState(bool adapterConnected, bool charging, BatteryLevel batteryLevel) {
|
||||
u8 value = static_cast<u8>(batteryLevel) << 2; // Bits 2:4 are the battery level from 0 to 5
|
||||
if (adapterConnected) value |= 1 << 0; // Bit 0 shows if the charger is connected
|
||||
|
@ -233,7 +239,9 @@ class Memory {
|
|||
}
|
||||
|
||||
// Returns whether "addr" is aligned to a page (4096 byte) boundary
|
||||
static constexpr bool isAligned(u32 addr) { return (addr & pageMask) == 0; }
|
||||
static constexpr bool isAligned(u32 addr) {
|
||||
return (addr & pageMask) == 0;
|
||||
}
|
||||
|
||||
// Allocate "size" bytes of RAM starting from FCRAM index "paddr" (We pick it ourself if paddr == 0)
|
||||
// And map them to virtual address "vaddr" (We also pick it ourself if vaddr == 0).
|
||||
|
|
Loading…
Add table
Reference in a new issue