ArvernOS
Loading...
Searching...
No Matches
user_stack.h File Reference
#include <stdint.h>
Include dependency graph for user_stack.h:

Macros

#define MAX_STACK_ARGS   64
 Maximum number of arguments/env vars copied to the user stack.
#define STACK_ALIGNMENT   16
 Alignment (in bytes) of the returned user stack pointer.
#define AT_NULL   0
 End of the auxiliary vector.
#define AT_PAGESZ   6
 Page size.
#define AT_ENTRY   9
 Entry point of the program.

Functions

uintptr_t create_user_stack (uintptr_t stack_top, int argc, char *const argv[], char *const envp[], uintptr_t entry)

Function Documentation

◆ create_user_stack()

uintptr_t create_user_stack ( uintptr_t stack_top,
int argc,
char *const argv[],
char *const envp[],
uintptr_t entry )

Builds the initial user stack for a program about to be executed.

The stack is written downward from stack_top.

+-----------------------—+ <- stack_top | strings | +-----------------------—+ <- returned stack pointer | argc | | argv[0..argc-1] | | NULL | | envp[0..] | | NULL | | AT_PAGESZ, page_size | | AT_ENTRY, entry | | AT_NULL, 0 | +-----------------------—+

The returned pointer is 16-byte aligned.

Parameters
stack_topthe top (high address) of the user stack
argcthe number of arguments
argvthe argument list
envpthe environment list
entrythe program entry point
Returns
the initial stack pointer, or 0 on error