2009-06-18 02:45:48 +08:00
|
|
|
/****************************************************************************
|
2015-11-14 21:29:47 +08:00
|
|
|
* binfmt/binfmt.h
|
2009-06-18 02:45:48 +08:00
|
|
|
*
|
2021-02-03 21:47:23 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2009-06-18 02:45:48 +08:00
|
|
|
*
|
2021-02-03 21:47:23 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-06-18 02:45:48 +08:00
|
|
|
*
|
2021-02-03 21:47:23 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2009-06-18 02:45:48 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-11-14 21:29:47 +08:00
|
|
|
#ifndef __BINFMT_BINFMT_H
|
|
|
|
#define __BINFMT_BINFMT_H
|
2009-06-18 02:45:48 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2012-10-25 04:19:44 +08:00
|
|
|
#include <nuttx/binfmt/binfmt.h>
|
2009-06-18 02:45:48 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
2014-09-15 04:10:23 +08:00
|
|
|
extern "C"
|
|
|
|
{
|
2009-06-18 02:45:48 +08:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2020-04-22 16:24:15 +08:00
|
|
|
/* This is a list of registered handlers for different binary formats.
|
|
|
|
* This list should only be accessed by normal user programs. It should be
|
|
|
|
* sufficient protection to simply disable pre-emption when accessing this
|
|
|
|
* list.
|
2009-06-18 02:45:48 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
EXTERN FAR struct binfmt_s *g_binfmts;
|
|
|
|
|
2015-10-03 07:48:24 +08:00
|
|
|
/****************************************************************************
|
2009-06-18 02:45:48 +08:00
|
|
|
* Public Function Prototypes
|
2015-10-03 07:48:24 +08:00
|
|
|
****************************************************************************/
|
2009-06-18 02:45:48 +08:00
|
|
|
|
2014-09-15 04:10:23 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: dump_module
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump the contents of struct binary_s.
|
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Input Parameters:
|
2014-09-15 04:10:23 +08:00
|
|
|
* bin - Load structure
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2018-09-14 20:55:45 +08:00
|
|
|
* Zero (OK) on success; a negated errno value on failure
|
2014-09-15 04:10:23 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2009-06-18 02:45:48 +08:00
|
|
|
|
2016-06-12 04:14:08 +08:00
|
|
|
#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_DEBUG_BINFMT)
|
2014-09-15 04:10:23 +08:00
|
|
|
int dump_module(FAR const struct binary_s *bin);
|
2009-06-18 02:45:48 +08:00
|
|
|
#else
|
|
|
|
# define dump_module(bin)
|
|
|
|
#endif
|
|
|
|
|
2015-11-14 21:29:47 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: binfmt_copyargv
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* In the kernel build, the argv list will likely lie in the caller's
|
2021-03-11 04:13:31 +08:00
|
|
|
* address environment and, hence, be inaccessible when we switch to the
|
2015-11-14 21:29:47 +08:00
|
|
|
* address environment of the new process address environment. So we
|
|
|
|
* do not have any real option other than to copy the callers argv[] list.
|
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Input Parameters:
|
2015-11-14 21:29:47 +08:00
|
|
|
* bin - Load structure
|
|
|
|
* argv - Argument list
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2018-09-14 20:55:45 +08:00
|
|
|
* Zero (OK) on success; a negated errno value on failure.
|
2015-11-14 21:29:47 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int binfmt_copyargv(FAR struct binary_s *bin, FAR char * const *argv);
|
|
|
|
|
2014-09-15 04:10:23 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: binfmt_freeargv
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Release the copied argv[] list.
|
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Input Parameters:
|
2014-09-15 04:10:23 +08:00
|
|
|
* bin - Load structure
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
|
|
|
void binfmt_freeargv(FAR struct binary_s *bin);
|
|
|
|
#else
|
|
|
|
# define binfmt_freeargv(bin)
|
|
|
|
#endif
|
|
|
|
|
2019-08-23 23:07:40 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: builtin_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* In order to use the builtin binary format, this function must be called
|
|
|
|
* during system initialize to register the builtin binary format.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* This is a NuttX internal function so it follows the convention that
|
|
|
|
* 0 (OK) is returned on success and a negated errno is returned on
|
|
|
|
* failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-04-30 14:35:04 +08:00
|
|
|
#ifdef CONFIG_FS_BINFS
|
2019-08-23 23:07:40 +08:00
|
|
|
int builtin_initialize(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: builtin_uninitialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Unregister the builtin binary loader
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-04-30 14:35:04 +08:00
|
|
|
#ifdef CONFIG_FS_BINFS
|
2019-08-23 23:07:40 +08:00
|
|
|
void builtin_uninitialize(void);
|
|
|
|
#endif
|
|
|
|
|
2009-06-18 02:45:48 +08:00
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-11-14 21:29:47 +08:00
|
|
|
#endif /* __BINFMT_BINFMT_H */
|