kern: obj stubs to get past slab init

This commit is contained in:
Michael Scire 2020-02-07 11:51:58 -08:00
parent 8cfffc69d5
commit e9e949ec36
22 changed files with 642 additions and 9 deletions

View file

@ -165,7 +165,7 @@ namespace ams::kern::init {
/* N shuffles the slab type array with the following simple algorithm. */
for (size_t i = 0; i < util::size(slab_types); i++) {
const size_t rnd = KSystemControl::GenerateRandomRange(0, util::size(slab_types));
const size_t rnd = KSystemControl::GenerateRandomRange(0, util::size(slab_types) - 1);
std::swap(slab_types[i], slab_types[rnd]);
}
@ -195,12 +195,9 @@ namespace ams::kern::init {
/* Initialize the slabheap. */
switch (slab_types[i]) {
/* NOTE: This can't be used right now because we don't have all these types implemented. */
/* Once we do, uncomment the following. */
/* TODO: FOREACH_SLAB_TYPE(INITIALIZE_SLAB_HEAP) */
case KSlabType_KThread:
address = InitializeSlabHeap<KThread>(address, SLAB_COUNT(KThread));
break;
/* For each of the slab types, we want to initialize that heap. */
FOREACH_SLAB_TYPE(INITIALIZE_SLAB_HEAP)
/* If we somehow get an invalid type, abort. */
MESOSPHERE_UNREACHABLE_DEFAULT_CASE();
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mesosphere.hpp>
namespace ams::kern {
bool KReadableEvent::IsSignaled() const {
MESOSPHERE_ASSERT_THIS();
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());
return this->is_signaled;
}
void KReadableEvent::Destroy() {
MESOSPHERE_ASSERT_THIS();
if (this->parent_event) {
this->parent_event->Close();
}
}
Result KReadableEvent::Signal() {
MESOSPHERE_ASSERT_THIS();
KScopedSchedulerLock lk;
if (!this->is_signaled) {
this->is_signaled = true;
this->NotifyAvailable();
}
return ResultSuccess();
}
Result KReadableEvent::Clear() {
MESOSPHERE_ASSERT_THIS();
this->Reset();
return ResultSuccess();
}
Result KReadableEvent::Reset() {
MESOSPHERE_ASSERT_THIS();
KScopedSchedulerLock lk;
R_UNLESS(this->is_signaled, svc::ResultInvalidState());
this->is_signaled = false;
return ResultSuccess();
}
}