hos: change initialization API

This was needed to make stratosphere buildable with debugging on.

os:: assertions rely on GetCurrentThread() working, and this requires
the global os resource manager to be constructed. However, __appInit executes
before global constructors. We now require that hos::InitializeForStratosphere()
be called before anything else is done. This initializes the os resource manager,
sets the hos version for libnx, and may do more things in the future.

TODO: Consider replacing __appInit/__appExit with ams:: namespace functions in general,
and wrap them so that we guarantee hos::InitializeForStratosphere is called first, and
generally ensure a consistent stratosphere environment.
This commit is contained in:
Michael Scire 2020-04-16 22:57:01 -07:00
parent 332dbdd497
commit 94ec9ae41b
23 changed files with 136 additions and 23 deletions

View file

@ -13,8 +13,8 @@
* 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 <stratosphere.hpp>
#include "hos_version_api_private.hpp"
namespace ams::hos {
@ -86,7 +86,7 @@ namespace ams::hos {
return g_hos_version;
}
void SetVersionForLibnx() {
void SetVersionForLibnxInternal() {
u32 major = 0, minor = 0, micro = 0;
switch (hos::GetVersion()) {
case hos::Version_1_0_0: