kernel.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2014 Citra Emulator Project / PPSSPP Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "core/hle/kernel/object.h"
  6. template <typename T>
  7. class ResultVal;
  8. namespace CoreTiming {
  9. struct EventType;
  10. }
  11. namespace Kernel {
  12. class HandleTable;
  13. class Process;
  14. class ResourceLimit;
  15. class Thread;
  16. class Timer;
  17. enum class ResourceLimitCategory : u8;
  18. /// Represents a single instance of the kernel.
  19. class KernelCore {
  20. public:
  21. KernelCore();
  22. ~KernelCore();
  23. KernelCore(const KernelCore&) = delete;
  24. KernelCore& operator=(const KernelCore&) = delete;
  25. KernelCore(KernelCore&&) = delete;
  26. KernelCore& operator=(KernelCore&&) = delete;
  27. /// Resets the kernel to a clean slate for use.
  28. void Initialize();
  29. /// Clears all resources in use by the kernel instance.
  30. void Shutdown();
  31. /// Provides a reference to the handle table.
  32. Kernel::HandleTable& HandleTable();
  33. /// Provides a const reference to the handle table.
  34. const Kernel::HandleTable& HandleTable() const;
  35. /// Retrieves a shared pointer to a ResourceLimit identified by the given category.
  36. SharedPtr<ResourceLimit> ResourceLimitForCategory(ResourceLimitCategory category) const;
  37. /// Retrieves a shared pointer to a Thread instance within the thread wakeup handle table.
  38. SharedPtr<Thread> RetrieveThreadFromWakeupCallbackHandleTable(Handle handle) const;
  39. /// Retrieves a shared pointer to a Timer instance within the timer callback handle table.
  40. SharedPtr<Timer> RetrieveTimerFromCallbackHandleTable(Handle handle) const;
  41. /// Adds the given shared pointer to an internal list of active processes.
  42. void AppendNewProcess(SharedPtr<Process> process);
  43. private:
  44. friend class Object;
  45. friend class Process;
  46. friend class Thread;
  47. friend class Timer;
  48. /// Creates a new object ID, incrementing the internal object ID counter.
  49. u32 CreateNewObjectID();
  50. /// Creates a new process ID, incrementing the internal process ID counter;
  51. u32 CreateNewProcessID();
  52. /// Creates a new thread ID, incrementing the internal thread ID counter.
  53. u32 CreateNewThreadID();
  54. /// Creates a timer callback handle for the given timer.
  55. ResultVal<Handle> CreateTimerCallbackHandle(const SharedPtr<Timer>& timer);
  56. /// Retrieves the event type used for thread wakeup callbacks.
  57. CoreTiming::EventType* ThreadWakeupCallbackEventType() const;
  58. /// Retrieves the event type used for timer callbacks.
  59. CoreTiming::EventType* TimerCallbackEventType() const;
  60. /// Provides a reference to the thread wakeup callback handle table.
  61. Kernel::HandleTable& ThreadWakeupCallbackHandleTable();
  62. /// Provides a const reference to the thread wakeup callback handle table.
  63. const Kernel::HandleTable& ThreadWakeupCallbackHandleTable() const;
  64. struct Impl;
  65. std::unique_ptr<Impl> impl;
  66. };
  67. } // namespace Kernel