1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
12 #include "frontend/emulator/jniHelper.h"
13 #include "sjme/nvm/boot.h"
15 jlong
SJME_JNI_METHOD(SJME_CLASS_NVM_STATE
, _1_1nvmBoot
)
16 (JNIEnv
* env
, jclass classy
, jlong poolPtr
, jlong reservedPtr
,
17 jobject wrapper
, jlong paramPtr
)
22 if (poolPtr
== 0 || reservedPtr
== 0 || wrapper
== NULL
|| paramPtr
== 0)
24 sjme_jni_throwVMException(env
, SJME_ERROR_NULL_ARGUMENTS
);
28 /* Initialize new state. */
30 if (sjme_error_is(error
= sjme_nvm_boot(
31 SJME_JLONG_TO_POINTER(sjme_alloc_pool
*, poolPtr
),
32 SJME_JLONG_TO_POINTER(sjme_alloc_pool
*, reservedPtr
),
33 SJME_JLONG_TO_POINTER(const sjme_nvm_bootParam
*, paramPtr
),
34 &state
)) || state
== NULL
)
36 sjme_jni_throwVMException(env
, error
);
40 /* Set self reference object, we need a global reference for it. */
41 state
->common
.frontEnd
.data
= env
;
42 state
->common
.frontEnd
.wrapper
= SJME_FRONT_END_WRAP(
43 (*env
)->NewGlobalRef(env
, wrapper
));
45 /* Use pointer to the state. */
46 return SJME_POINTER_TO_JLONG(state
);