Add support for some basic system calls and args handling correctly. #29

Merged
sb3923 merged 49 commits from system-calls into master 2024-11-07 19:36:30 +00:00
2 changed files with 127 additions and 20 deletions
Showing only changes of commit 2a890d5bd2 - Show all commits

View File

@@ -2,6 +2,7 @@
#include <debug.h> #include <debug.h>
#include <inttypes.h> #include <inttypes.h>
#include <round.h> #include <round.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -116,7 +117,7 @@ start_process (void *file_name_)
/* Calculate the remaining number of bytes that need to be written /* Calculate the remaining number of bytes that need to be written
to the user process stack in order to check for possible overflow. */ to the user process stack in order to check for possible overflow. */
size_t align_size = (unsigned int) if_.esp % 4; size_t align_size = ((unsigned int) if_.esp % 4) * sizeof (uint8_t);
size_t argv_data_size = (arg_count + 1) * sizeof (char *); size_t argv_data_size = (arg_count + 1) * sizeof (char *);
size_t argv_size = sizeof (char **); size_t argv_size = sizeof (char **);
size_t argc_size = sizeof (int); size_t argc_size = sizeof (int);
@@ -133,7 +134,7 @@ start_process (void *file_name_)
/* Align stack pointer to word size before pushing argv elements for /* Align stack pointer to word size before pushing argv elements for
performance. */ performance. */
if_.esp -= align_size * sizeof (uint8_t); if_.esp -= align_size;
/* Push a null pointer sentinel inside argv. */ /* Push a null pointer sentinel inside argv. */
if_.esp -= sizeof (char *); if_.esp -= sizeof (char *);