diff options
| author | 2014-12-21 10:04:08 -0200 | |
|---|---|---|
| committer | 2014-12-28 11:52:55 -0200 | |
| commit | 7e2903cb74050d846f2da951dff7e84aee13761b (patch) | |
| tree | 621c9245d2dd393a9569b1b4192f50a27d831972 /src/core/hle/service | |
| parent | Kernel: Replace GetStaticHandleType by HANDLE_TYPE constants (diff) | |
| download | yuzu-7e2903cb74050d846f2da951dff7e84aee13761b.tar.gz yuzu-7e2903cb74050d846f2da951dff7e84aee13761b.tar.xz yuzu-7e2903cb74050d846f2da951dff7e84aee13761b.zip | |
Kernel: New handle manager
This handle manager more closely mirrors the behaviour of the CTR-OS
one. In addition object ref-counts and support for DuplicateHandle have
been added.
Note that support for DuplicateHandle is still experimental, since parts
of the kernel still use Handles internally, which will likely cause
troubles if two different handles to the same object are used to e.g.
wait on a synchronization primitive.
Diffstat (limited to 'src/core/hle/service')
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 5 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 5746b58e5..487bf3aa7 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -133,7 +133,7 @@ public: | |||
| 133 | case FileCommand::Close: | 133 | case FileCommand::Close: |
| 134 | { | 134 | { |
| 135 | LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); | 135 | LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); |
| 136 | Kernel::g_handle_table.Destroy<File>(GetHandle()); | 136 | backend->Close(); |
| 137 | break; | 137 | break; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| @@ -189,7 +189,7 @@ public: | |||
| 189 | case DirectoryCommand::Close: | 189 | case DirectoryCommand::Close: |
| 190 | { | 190 | { |
| 191 | LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); | 191 | LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); |
| 192 | Kernel::g_handle_table.Destroy<Directory>(GetHandle()); | 192 | backend->Close(); |
| 193 | break; | 193 | break; |
| 194 | } | 194 | } |
| 195 | 195 | ||
| @@ -283,7 +283,8 @@ ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSy | |||
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | auto file = Common::make_unique<File>(std::move(backend), path); | 285 | auto file = Common::make_unique<File>(std::move(backend), path); |
| 286 | Handle handle = Kernel::g_handle_table.Create(file.release()); | 286 | // TOOD(yuriks): Fix error reporting |
| 287 | Handle handle = Kernel::g_handle_table.Create(file.release()).ValueOr(INVALID_HANDLE); | ||
| 287 | return MakeResult<Handle>(handle); | 288 | return MakeResult<Handle>(handle); |
| 288 | } | 289 | } |
| 289 | 290 | ||
| @@ -388,7 +389,8 @@ ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const F | |||
| 388 | } | 389 | } |
| 389 | 390 | ||
| 390 | auto directory = Common::make_unique<Directory>(std::move(backend), path); | 391 | auto directory = Common::make_unique<Directory>(std::move(backend), path); |
| 391 | Handle handle = Kernel::g_handle_table.Create(directory.release()); | 392 | // TOOD(yuriks): Fix error reporting |
| 393 | Handle handle = Kernel::g_handle_table.Create(directory.release()).ValueOr(INVALID_HANDLE); | ||
| 392 | return MakeResult<Handle>(handle); | 394 | return MakeResult<Handle>(handle); |
| 393 | } | 395 | } |
| 394 | 396 | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index e9a7973b3..0f3cc2aa8 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -56,7 +56,8 @@ Manager::~Manager() { | |||
| 56 | 56 | ||
| 57 | /// Add a service to the manager (does not create it though) | 57 | /// Add a service to the manager (does not create it though) |
| 58 | void Manager::AddService(Interface* service) { | 58 | void Manager::AddService(Interface* service) { |
| 59 | m_port_map[service->GetPortName()] = Kernel::g_handle_table.Create(service); | 59 | // TOOD(yuriks): Fix error reporting |
| 60 | m_port_map[service->GetPortName()] = Kernel::g_handle_table.Create(service).ValueOr(INVALID_HANDLE); | ||
| 60 | m_services.push_back(service); | 61 | m_services.push_back(service); |
| 61 | } | 62 | } |
| 62 | 63 | ||
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 9d5828fd0..28b4ccd17 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -54,7 +54,8 @@ public: | |||
| 54 | 54 | ||
| 55 | /// Allocates a new handle for the service | 55 | /// Allocates a new handle for the service |
| 56 | Handle CreateHandle(Kernel::Object *obj) { | 56 | Handle CreateHandle(Kernel::Object *obj) { |
| 57 | Handle handle = Kernel::g_handle_table.Create(obj); | 57 | // TODO(yuriks): Fix error reporting |
| 58 | Handle handle = Kernel::g_handle_table.Create(obj).ValueOr(INVALID_HANDLE); | ||
| 58 | m_handles.push_back(handle); | 59 | m_handles.push_back(handle); |
| 59 | return handle; | 60 | return handle; |
| 60 | } | 61 | } |
| @@ -62,7 +63,7 @@ public: | |||
| 62 | /// Frees a handle from the service | 63 | /// Frees a handle from the service |
| 63 | template <class T> | 64 | template <class T> |
| 64 | void DeleteHandle(const Handle handle) { | 65 | void DeleteHandle(const Handle handle) { |
| 65 | Kernel::g_handle_table.Destroy<T>(handle); | 66 | Kernel::g_handle_table.Close(handle); |
| 66 | m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end()); | 67 | m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end()); |
| 67 | } | 68 | } |
| 68 | 69 | ||