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 "sjme/boot.h"
13 #include "sjme/debug.h"
17 * Combines all of the input ROMs and provides a virtual ROM that contains
18 * all of the libraries, this is so everything is within a single library
21 * @param config The input configuration.
22 * @param outLibraries The output libraries.
23 * @return If this was successful.
26 static sjme_attrCheckReturn sjme_errorCode
sjme_nvm_bootCombineRom(
27 sjme_attrInNotNull
const sjme_nvm_bootParam
* config
,
28 sjme_attrOutNotNull sjme_static_libraries
** outLibraries
)
30 if (config
== NULL
|| outLibraries
== NULL
)
31 return SJME_ERROR_NULL_ARGUMENTS
;
33 /* Determine the total library count. */
35 sjme_todo("sjme_nvm_bootVirtualRom()");
37 /* Allocate output result. */
39 sjme_todo("sjme_nvm_bootVirtualRom()");
41 /* Bring in all the libraries into the output. */
43 sjme_todo("sjme_nvm_bootVirtualRom()");
45 /* Return the result. */
46 sjme_todo("sjme_nvm_bootVirtualRom()");
47 return SJME_ERROR_NOT_IMPLEMENTED
;
50 sjme_errorCode
sjme_nvm_boot(sjme_alloc_pool
* mainPool
,
51 const sjme_nvm_bootParam
* param
,
52 sjme_nvm_state
** outState
, int argc
, char** argv
)
54 sjme_nvm_state
* result
;
56 sjme_alloc_pool
* reservedPool
;
57 sjme_jint reservedSize
;
60 if (param
== NULL
|| outState
== NULL
)
61 return SJME_ERROR_NULL_ARGUMENTS
;
63 /* Set up a reserved pool where all the data structures for the VM go... */
65 reservedSize
= 64 * 1024;
66 if (SJME_IS_ERROR(error
= sjme_alloc(mainPool
,
67 reservedSize
, (void**)&reservedBase
) ||
68 reservedBase
== NULL
))
71 /* Initialize a reserved pool where all of our own data structures go. */
73 if (SJME_IS_ERROR(error
= sjme_alloc_poolStatic(
74 &reservedPool
, reservedBase
, reservedSize
)) ||
78 /* Allocate resultant state. */
80 if (SJME_IS_ERROR(error
= sjme_alloc(reservedPool
,
81 sizeof(*result
), (void**)&result
)) || result
== NULL
)
84 /* Set parameters accordingly. */
85 result
->allocPool
= mainPool
;
86 result
->reservedPool
= reservedPool
;
88 /* Copy the boot config over. */
89 memmove(&result
->bootConfig
, param
, sizeof(*param
));
91 /* Combine the input ROMs to a set of libraries. */
92 if (!sjme_nvm_bootCombineRom(param
, &result
->libraries
))
94 sjme_nvm_destroy(result
, NULL
);
95 return SJME_JNI_FALSE
;
98 /* Parse the command line arguments for options on running the VM. */
100 sjme_todo("sjme_nvm_boot()");
102 /* Spawn initial task which uses the main arguments. */
104 sjme_todo("sjme_nvm_boot()");
106 /* Return newly created VM. */
107 sjme_todo("sjme_nvm_boot()");
108 return SJME_ERROR_NOT_IMPLEMENTED
;
111 sjme_errorCode
sjme_nvm_destroy(sjme_nvm_state
* state
, sjme_jint
* exitCode
)
114 return SJME_ERROR_NULL_ARGUMENTS
;
116 /* Free sub-structures. */
118 sjme_todo("sjme_nvm_destroy()");
120 /* Free main structure. */
122 sjme_todo("sjme_nvm_destroy()");
124 /* Set exit code, if requested. */
126 sjme_todo("sjme_nvm_destroy()");
129 sjme_todo("sjme_nvm_destroy()");
130 return SJME_ERROR_NOT_IMPLEMENTED
;