mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Add syscall support for insmod and rmmod
This commit is contained in:
+15
-3
@@ -152,12 +152,24 @@
|
|||||||
# ifdef CONFIG_SCHED_HAVE_PARENT
|
# ifdef CONFIG_SCHED_HAVE_PARENT
|
||||||
# define SYS_wait (__SYS_waitpid+1)
|
# define SYS_wait (__SYS_waitpid+1)
|
||||||
# define SYS_waitid (__SYS_waitpid+2)
|
# define SYS_waitid (__SYS_waitpid+2)
|
||||||
# define __SYS_posix_spawn (__SYS_waitpid+3)
|
# define __SYS_insmod (__SYS_waitpid+3)
|
||||||
# else
|
# else
|
||||||
# define __SYS_posix_spawn (__SYS_waitpid+1)
|
# define __SYS_insmod (__SYS_waitpid+1)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
# define __SYS_posix_spawn __SYS_waitpid
|
# define __SYS_insmod __SYS_waitpid
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following can only be defined if we are configured to load
|
||||||
|
* OS modules from a file system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_MODULE
|
||||||
|
# define SYS_insmod __SYS_insmod
|
||||||
|
# define SYS_rmmod (__SYS_insmod+1)
|
||||||
|
# define __SYS_posix_spawn (__SYS_insmod+2)
|
||||||
|
#else
|
||||||
|
# define __SYS_posix_spawn __SYS_insmod
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The following can only be defined if we are configured to execute
|
/* The following can only be defined if we are configured to execute
|
||||||
|
|||||||
@@ -83,15 +83,24 @@ int rmmod(FAR struct module_s *modp)
|
|||||||
sdbg("ERROR: Failed to uninitialize the module: %d\n", ret);
|
sdbg("ERROR: Failed to uninitialize the module: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Nullify so that the uninitializer cannot be called again */
|
||||||
|
|
||||||
|
modp->uninitializer = NULL;
|
||||||
|
modp->arg = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the module memory */
|
/* Release resources held by the module */
|
||||||
|
|
||||||
/* Release memory holding the relocated ELF image */
|
|
||||||
|
|
||||||
if (modp->alloc != 0)
|
if (modp->alloc != 0)
|
||||||
{
|
{
|
||||||
|
/* Free the module memory */
|
||||||
|
|
||||||
kmm_free((FAR void *)modp->alloc);
|
kmm_free((FAR void *)modp->alloc);
|
||||||
|
|
||||||
|
/* Nullify so that the memory cannot be freed again */
|
||||||
|
|
||||||
|
modp->alloc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*"
|
"getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*"
|
||||||
"getpid","unistd.h","","pid_t"
|
"getpid","unistd.h","","pid_t"
|
||||||
"getsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR void*","FAR socklen_t*"
|
"getsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR void*","FAR socklen_t*"
|
||||||
|
"insmod","nuttx/module.h",defined(CONFIG_MODULE),"int","FAR struct module_s *"
|
||||||
"ioctl","sys/ioctl.h","!defined(CONFIG_LIBC_IOCTL_VARIADIC) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","int","int","unsigned long"
|
"ioctl","sys/ioctl.h","!defined(CONFIG_LIBC_IOCTL_VARIADIC) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","int","int","unsigned long"
|
||||||
"kill","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","pid_t","int"
|
"kill","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","pid_t","int"
|
||||||
"listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int"
|
"listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int"
|
||||||
@@ -97,6 +98,7 @@
|
|||||||
"rename","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","FAR const char*"
|
"rename","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","FAR const char*"
|
||||||
"rewinddir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","void","FAR DIR*"
|
"rewinddir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","void","FAR DIR*"
|
||||||
"rmdir","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*"
|
"rmdir","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*"
|
||||||
|
"rmmod","nuttx/module.h",defined(CONFIG_MODULE),"int","FAR struct module_s *"
|
||||||
"sched_getparam","sched.h","","int","pid_t","struct sched_param*"
|
"sched_getparam","sched.h","","int","pid_t","struct sched_param*"
|
||||||
"sched_getscheduler","sched.h","","int","pid_t"
|
"sched_getscheduler","sched.h","","int","pid_t"
|
||||||
"sched_getstreams","nuttx/sched.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR struct streamlist*"
|
"sched_getstreams","nuttx/sched.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR struct streamlist*"
|
||||||
|
|||||||
|
@@ -106,6 +106,15 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The following can only be defined if we are configured to load
|
||||||
|
* OS modules from a file system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_MODULE
|
||||||
|
SYSCALL_LOOKUP(insmod, 1, STUB_insmod)
|
||||||
|
SYSCALL_LOOKUP(rmmod, 1, STUB_rmmod)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following can only be defined if we are configured to execute
|
/* The following can only be defined if we are configured to execute
|
||||||
* programs from a file system.
|
* programs from a file system.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -107,6 +107,15 @@ uintptr_t STUB_wait(int nbr, uintptr_t parm1);
|
|||||||
uintptr_t STUB_waitid(int nbr, uintptr_t parm1, uintptr_t parm2,
|
uintptr_t STUB_waitid(int nbr, uintptr_t parm1, uintptr_t parm2,
|
||||||
uintptr_t parm3, uintptr_t parm4);
|
uintptr_t parm3, uintptr_t parm4);
|
||||||
|
|
||||||
|
/* The following can only be defined if we are configured to load
|
||||||
|
* OS modules from a file system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_MODULE
|
||||||
|
uintptr_t STUB_insmod(int nbr, uintptr_t parm1);
|
||||||
|
uintptr_t STUB_rmmod(int nbr, uintptr_t parm1);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following can only be defined if we are configured to execute
|
/* The following can only be defined if we are configured to execute
|
||||||
* programs from a file system.
|
* programs from a file system.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user