hgruniaux / Pi-kachULM_OS

A mini OS kernel for Raspberry PI 3 and 4
Other
3 stars 1 forks source link

[feat] Support command line arguments for tasks #54

Open hgruniaux opened 6 months ago

hgruniaux commented 6 months ago

Command line arguments should be passed in the stack of the created task.

| Stack                               |
| ----------------------------------- |
| Arg 0                               | <- start of the stack
| Arg 1                               |
| ...                                 |
| Arg n                               |
| The constant n                      |
| A pointer to the start of the stack |
| ...                                 | <- SP points here

Example of the _start function in glibc for aarch64:

ENTRY(_start)
    ...

    /* Load argc and a pointer to argv */
    ldr PTR_REG (1), [sp, #0]
    add x2, sp, #PTR_SIZE

    /* Setup stack limit in argument register */
    mov x6, sp

        ...