hle: kernel: Migrate KPort, KClientPort, and KServerPort to KAutoObject.

This commit is contained in:
bunnei
2021-04-23 17:00:15 -07:00
parent 7a06864100
commit 626f746971
22 changed files with 447 additions and 169 deletions

View File

@ -1,8 +1,9 @@
// Copyright 2019 yuzu emulator team
// Copyright 2021 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/assert.h"
#include "core/hle/kernel/k_client_port.h"
#include "core/hle/kernel/k_client_session.h"
#include "core/hle/kernel/k_scoped_resource_reservation.h"
#include "core/hle/kernel/k_server_session.h"
@ -14,7 +15,7 @@ KSession::KSession(KernelCore& kernel)
: KAutoObjectWithSlabHeapAndContainer{kernel}, server{kernel}, client{kernel} {}
KSession::~KSession() = default;
void KSession::Initialize(std::string&& name_) {
void KSession::Initialize(KClientPort* port_, std::string&& name_) {
// Increment reference count.
// Because reference count is one on creation, this will result
// in a reference count of two. Thus, when both server and client are closed
@ -37,11 +38,22 @@ void KSession::Initialize(std::string&& name_) {
process = kernel.CurrentProcess();
process->Open();
// Set our port.
port = port_;
if (port != nullptr) {
port->Open();
}
// Mark initialized.
initialized = true;
}
void KSession::Finalize() {}
void KSession::Finalize() {
if (port != nullptr) {
port->OnSessionFinalized();
port->Close();
}
}
void KSession::OnServerClosed() {
if (GetState() == State::Normal) {