sandbox: Extract init code into sandbox_init()
Split the init code from sandbox_main() into a separate sandbox_init() function that handles all setup up to the call to board_init_f(). This allows the init to be called independently of the main execution flow. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <linux/compiler_attributes.h>
|
||||
|
||||
struct global_data;
|
||||
|
||||
/* board/.../... */
|
||||
int board_init(void);
|
||||
|
||||
@@ -41,6 +43,22 @@ void sandbox_reset(void);
|
||||
/* Exit sandbox (quit U-Boot) */
|
||||
void __noreturn sandbox_exit(void);
|
||||
|
||||
/**
|
||||
* sandbox_init() - init sandbox
|
||||
*
|
||||
* This function initialises sandbox state, parses arguments, and sets up the
|
||||
* global data structure, but does not call board_init_f().
|
||||
*
|
||||
* The caller must zero @data before calling this function. This function sets
|
||||
* gd to point to @data so it must remain valid for the life of sandbox.
|
||||
*
|
||||
* @argc: the number of arguments passed to the program
|
||||
* @argv: array of argc pointers, plus a NULL terminator
|
||||
* @data: pointer to global data structure to init
|
||||
* Return: 0 if OK, -ve on error
|
||||
*/
|
||||
int sandbox_init(int argc, char *argv[], struct global_data *data);
|
||||
|
||||
/**
|
||||
* sandbox_main() - main entrypoint for sandbox
|
||||
*
|
||||
@@ -50,6 +68,9 @@ void __noreturn sandbox_exit(void);
|
||||
* This calls sandbox_init(), then board_init_f/r(). It does not return unless
|
||||
* something goes wrong.
|
||||
*
|
||||
* @argc: the number of arguments passed to the program
|
||||
* @argv: array of argc pointers, plus a NULL terminator
|
||||
*
|
||||
* Return: 1 on error
|
||||
*/
|
||||
int sandbox_main(int argc, char *argv[]);
|
||||
|
||||
Reference in New Issue
Block a user