From 62b5168206bba1f8b3e470d7c1c0cfc25a56a29e Mon Sep 17 00:00:00 2001 From: Alex Stratford <alexander3.stratford@live.uwe.ac.uk> Date: Mon, 2 Dec 2019 00:54:50 +0000 Subject: [PATCH] Resolving issue with variable naming consistency as brought up by Josh in merge request --- userprog/populate_stack.c | 34 +++++++++++++++++----------------- userprog/process.c | 18 +++++++++--------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/userprog/populate_stack.c b/userprog/populate_stack.c index cfb189b..36acb8c 100644 --- a/userprog/populate_stack.c +++ b/userprog/populate_stack.c @@ -9,45 +9,45 @@ #include "userprog/argument_parsing.h" -void populate_stack(void* stackPointer, int argc, char** argv) { - *stackPointer = PHYS_BASE; +void populate_stack(void* stack_pointer, int argc, char** argv) { + *stack_pointer = PHYS_BASE; int i = argc; uint32_t * arr[argc]; // Creates an array to hold arguments in the stack while (--i >= 0) { - *stackPointer = *stackPointer - (strlen(argv[i]) + 1) * sizeof(char); + *stack_pointer = *stack_pointer - (strlen(argv[i]) + 1) * sizeof(char); - arr[i] = (uint32_t *)*stackPointer; // Assigns the current reference of the stackpointer to the array + arr[i] = (uint32_t *)*stack_pointer; // Assigns the current reference of the stack pointer to the array - memcpy(*stackPointer, argv[i], strlen(argv[i]) + 1); + memcpy(*stack_pointer, argv[i], strlen(argv[i]) + 1); } - *stackPointer = move_stack_pointer(*stackPointer, -4); //Moves the stack pointer back 4 + *stack_pointer = move_stack_pointer(*stack_pointer, -4); //Moves the stack pointer back 4 - (*(int *)(*stackPointer)) = 0;//sentinel + (*(int *)(*stack_pointer)) = 0;//sentinel i = argc; while (--i >= 0) { - *stackPointer = move_stack_pointer(*stackPointer, -4); //32bit Moves the stack pointer back 4 + *stack_pointer = move_stack_pointer(*stack_pointer, -4); //32bit Moves the stack pointer back 4 - (*(uint32_t **)(*stackPointer)) = arr[i]; + (*(uint32_t **)(*stack_pointer)) = arr[i]; } - *stackPointer = move_stack_pointer(*stackPointer, -4); + *stack_pointer = move_stack_pointer(*stack_pointer, -4); - (*(uintptr_t **)(*stackPointer)) = *stackPointer = move_stack_pointer(*stackPointer, 4); //Moves the stack pointer forwards 4 - *stackPointer = move_stack_pointer(*stackPointer, -4); //Moves the stack pointer back 4 + (*(uintptr_t **)(*stack_pointer)) = *stack_pointer = move_stack_pointer(*stack_pointer, 4); //Moves the stack pointer forwards 4 + *stack_pointer = move_stack_pointer(*stack_pointer, -4); //Moves the stack pointer back 4 - *(int *)(*stackPointer) = argc; - *stackPointer = move_stack_pointer(*stackPointer, -4); //Moves the stack pointer back 4 + *(int *)(*stack_pointer) = argc; + *stack_pointer = move_stack_pointer(*stack_pointer, -4); //Moves the stack pointer back 4 - (*(int *)(*stackPointer)) = 0; + (*(int *)(*stack_pointer)) = 0; } // Adds the move value to the stack pointer -static void move_stack_pointer(void** stackPointer, int moveValue) { - *stackPointer = *stackPointer + moveValue; +static void move_stack_pointer(void** stack_pointer, int moveValue) { + *stack_pointer = *stack_pointer + moveValue; } \ No newline at end of file diff --git a/userprog/process.c b/userprog/process.c index a2ba369..69009c2 100644 --- a/userprog/process.c +++ b/userprog/process.c @@ -19,7 +19,7 @@ #include "threads/vaddr.h" static thread_func start_process NO_RETURN; -static bool load (const char *cmdline, void (**eip) (void), void **initialStackPointer); +static bool load (const char *cmdline, void (**eip) (void), void **initial_stack_pointer); /* Starts a new thread running a user program loaded by parsing COMMAND. The new thread may be scheduled (and may even exit) @@ -79,9 +79,9 @@ start_process (void *file_name_) interrupt, implemented by intr_exit (in threads/intr-stubs.S). Because intr_exit takes all of its arguments on the stack in the form of a `struct intr_frame', - we just point the stack pointer (%initialStackPointer) to our stack frame + we just point the stack pointer (%initial_stack_pointer) to our stack frame and jump to it. */ - asm volatile ("movl %0, %%initialStackPointer; jmp intr_exit" : : "g" (&if_) : "memory"); + asm volatile ("movl %0, %%initial_stack_pointer; jmp intr_exit" : : "g" (&if_) : "memory"); NOT_REACHED (); } @@ -212,7 +212,7 @@ struct Elf32_Phdr #define PF_W 2 /* Writable. */ #define PF_R 4 /* Readable. */ -static bool setup_stack(void **initialStackPointer, char **argv, int argc) +static bool setup_stack(void **initial_stack_pointer, char **argv, int argc) static bool validate_segment (const struct Elf32_Phdr *, struct file *); static bool load_segment (struct file *file, off_t ofs, uint8_t *upage, uint32_t read_bytes, uint32_t zero_bytes, @@ -220,10 +220,10 @@ static bool load_segment (struct file *file, off_t ofs, uint8_t *upage, /* Loads an ELF executable from FILE_NAME into the current thread. Stores the executable's entry point into *EIP - and its initial stack pointer into *initialStackPointer. + and its initial stack pointer into *initial_stack_pointer. Returns true if successful, false otherwise. */ bool -load (const char *file_name, void (**eip) (void), void **initialStackPointer) +load (const char *file_name, void (**eip) (void), void **initial_stack_pointer) { struct thread *t = thread_current (); struct Elf32_Ehdr ehdr; @@ -320,7 +320,7 @@ load (const char *file_name, void (**eip) (void), void **initialStackPointer) } /* Set up stack. */ - if (!setup_stack (initialStackPointer)) + if (!setup_stack (initial_stack_pointer)) goto done; /* Start address. */ @@ -445,7 +445,7 @@ load_segment (struct file *file, off_t ofs, uint8_t *upage, /* Create a minimal stack by mapping a zeroed page at the top of user virtual memory. */ static bool -setup_stack (void **initialStackPointer, char **argv, int argc) +setup_stack (void **initial_stack_pointer, char **argv, int argc) { uint8_t *kpage; bool success = false; @@ -455,7 +455,7 @@ setup_stack (void **initialStackPointer, char **argv, int argc) { success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage, true); if (success) { - *initialStackPointer = PHYS_BASE - 12; + *initial_stack_pointer = PHYS_BASE - 12; } else palloc_free_page (kpage); } -- GitLab