Changeset 683 for trunk/kernel/kern/process.h
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/process.h
r669 r683 98 98 * This structure defines the information required by the process_make_exec() function 99 99 * to create a new reference process descriptor, and the associated main thread. 100 * All fields in this structure are filled by the sys_exec() function, using the 101 * process_exec_get_strings() function. 100 * All fields in this structure are filled by the sys_exec() function. 102 101 * 103 102 * It contains three parts: … … 106 105 * - the "envs_pointers" & "envs_nr" fields define the env variables (one env == one string). 107 106 * 108 * For both the arguments, and the environment variables, the array of pointers and the 109 * strings themselve are stored in kernel space in the same kernel buffer containing 110 * an integer number of pages, defined by CONFIG_VMM_ARGS_SIZE and CONFIG_VMM_ENVS_SIZE. 111 * This aligned kernel buffer (one or several contiguous physical pages) contains : 107 * For both the arguments and the environment variables, the array of pointers and the 108 * strings themselve are stored in the same kernel buffer. These kernel buffers contain 109 * an integer number of contiguous pages, defined by the CONFIG_VMM_ARGS_SIZE and 110 * CONFIG_VMM_ENVS_SIZE parameters respectively. 111 * Each kernel (args / envs) buffer contains : 112 112 * - in the first bytes, a fixed size kernel array of pointers on the strings. 113 113 * - in the following bytes, the strings themselves. 114 * The size of these arrays of pointers is defined by CONFIG_PROCESS_ARGS_MAX_NR 115 * and CONFIG¨PROCESS_ENVS_MAX_NR. 116 * 117 * WARNING: The "args_pointers" & "envs_pointers" kernel buffer are directly mapped to 118 * the "args" and "envs" user vsegs to be accessed by the user process. 119 * Therefore, the arrays of pointers build by the sys_exec() function contain 120 * kernel pointers, but the process_make_exec() function replace these pointers 121 * by user pointers in the new process user space. 114 * The size of these arrays of pointers is defined by the CONFIG_PROCESS_ARGS_MAX_NR and 115 * CONFIG_PROCESS_ENVS_MAX_NR parameters respectively. 116 * 117 * WARNING (1) The "args_pointers[i]" & "envs_pointers[i] stored in the dynamically 118 * allocated kernel buffers are local pointers. They must be extended by the 119 * local cluster identifier to compute a valid PPN. 120 * WARNING (2) The "args" & "envs" kernel buffers will be mapped to the "args" and "envs" 121 * user vsegs, to be accessed by the new user process. 122 * The process_make_exec() function must therefore replace the kernel pointers 123 * set by sys_exec(), by user pointers in the new process user space. 122 124 ********************************************************************************************/ 123 125 … … 232 234 * The process GPT is initialised as required by the target architecture. 233 235 * The "kcode" and "kdata" segments are registered in the process VSL. 236 * This function does not return an error code: in case of failure, it print a PANIC message 237 * on kernel terminal TXT0, and the core goes to sleep mode. 234 238 ********************************************************************************************* 235 239 * @ process : [in] pointer on process descriptor to initialize. … … 241 245 /********************************************************************************************* 242 246 * This function allocates memory and initializes the "process_init" descriptor and the 243 * associated "thread_init" descriptor. It is called once at the end of the kernel 244 * initialisation procedure. Its local process identifier is 1, and parent process 245 * is the kernel process in cluster 0. 247 * associated "thread_init" descriptor. It is called once at the end of the kernel_init() 248 * procedure. Its local process identifier is 1, and parent process is the kernel process. 246 249 * The "process_init" is the first user process, and all other user processes will be forked 247 250 * from this process. The code executed by "process_init" is stored in a .elf file, whose 248 251 * pathname is defined by the CONFIG_PROCESS_INIT_PATH configuration variable. 249 * Th e process_init does not use the [STDIN/STDOUT/STDERR] streams, but it is linked250 * to kernel TXT0, because these streams must be defined for all user processes.252 * This function does not return an error code: in case of failure, it print a PANIC message 253 * on kernel terminal TXT0, and the core goes to sleep mode. 251 254 ********************************************************************************************/ 252 255 void process_init_create( void ); … … 415 418 416 419 /********************************************************************************************* 417 * This function is called twice by the sys_exec() function :418 * - to register the main() arguments (args) in the process <exec_info> structure.419 * - to register the environment variables (envs) in the <exec_info> structure.420 * In both cases the input is an array of NULL terminated string pointers in user space,421 * identified by the <u_pointers> argument. The strings can be dispatched anywhere in422 * the calling user process space. The max number of envs, and the max number of args are423 * defined by the CONFIG_PROCESS_ARGS_NR and CONFIG_PROCESS_ENVS_MAX_NR parameters.424 *********************************************************************************************425 * Implementation Note:426 * Both the array of pointers and the strings themselve are stored in kernel space in one427 * single, dynamically allocated, kernel buffer containing an integer number of pages,428 * defined by the CONFIG_VMM_ENVS_SIZE and CONFIG_VMM_STACK_SIZE parameters.429 * This aligned kernel buffer (one or several contiguous physical pages) contains :430 * - in the first bytes a fixed size kernel array of kernel pointers on the strings.431 * - in the following bytes the strings themselves.432 * All the pointers, and the actual number of strings are stored in the process exec_info433 * structure defined in the <process.h> file.434 *********************************************************************************************435 * @ is_args : [in] true if called for (args) / false if called for (envs).436 * @ u_pointers : [in] array of pointers on the strings (in user space).437 * @ exec_info : [inout] pointer on the exec_info structure.438 * @ return 0 if success / non-zero if too many strings or no memory.439 ********************************************************************************************/440 error_t process_exec_get_strings( bool_t is_args,441 char ** u_pointers,442 exec_info_t * exec_info );443 444 /*********************************************************************************************445 420 * This function implements the "execve" system call, and is called by sys_exec() function. 446 421 * It must be called by the main thread of the calling "old" process. … … 595 570 * @ dst_xp : extended pointer on the source process descriptor (in owner cluster). 596 571 * @ src_xp : extended pointer on the destination process descriptor (in owner cluster). 597 ********************************************************************************************/ 598 void process_fd_replicate( xptr_t dst_xp, 599 xptr_t src_xp ); 572 * @ return 0 if success / return -1 if failure 573 ********************************************************************************************/ 574 error_t process_fd_replicate( xptr_t dst_xp, 575 xptr_t src_xp ); 600 576 601 577 /********************************************************************************************* … … 617 593 ********************************************************************************************/ 618 594 void process_fd_display( xptr_t process_xp ); 595 596 /********************************************************************************************* 597 * This utility function builds in the buffer defined by the <buffer> and <size> arguments 598 * a printable string describing the current state of a process descriptor identified 599 * by the <process_xp> argument, or a WARNING message if the buffer size is too small. 600 ********************************************************************************************* 601 * @ process_xp : extended pointer on target process descriptor. 602 * @ buffer : kernel buffer for string. 603 * @ size : buffer size in bytes. 604 * @ return always the string length (not including NUL), that can be a warning message. 605 ********************************************************************************************/ 606 uint32_t process_build_string( xptr_t process_xp, 607 char * buffer, 608 uint32_t size ); 619 609 620 610 /******************** Thread Related Operations *****************************************/
Note: See TracChangeset
for help on using the changeset viewer.