Various code fix

This commit is contained in:
Mathieu Maret 2023-11-08 20:53:13 +01:00
parent 44fa5967dd
commit bff24b2213
4 changed files with 11 additions and 3 deletions

View File

@ -41,7 +41,7 @@ void printStackTrace(unsigned int maxFrames)
#else
printf("Must be compiled with -fno-omit-frame-pointer for full stack\n");
unsigned int *ebp = &maxFrames - 2;
unsigned int eip = ebp[1];
unsigned int *eip = ebp + sizeof(unsigned int);
printf("[0] 0x%x\n", eip);
#endif
}

View File

@ -41,6 +41,8 @@ void threadExit()
int threadSetup(vaddr_t mainStack, size_t mainStackSize)
{
struct thread *current = (struct thread *)malloc(sizeof(struct thread));
if (current == NULL)
return -ENOMEM;
strzcpy(current->name, "[KINIT]", THREAD_NAME_MAX_LENGTH);
current->stackAddr = mainStack;
current->stackSize = mainStackSize;
@ -345,7 +347,11 @@ static void threadPrepareContext(struct thread *th)
int threadChangeCurrentContext(struct mmu_context *ctx)
{
uint32_t flags;
struct mmu_context *prev = currentThread->squattedContext;
struct mmu_context *prev;
assert(currentThread != NULL);
prev = currentThread->squattedContext;
if (ctx != NULL) {
assert(prev == NULL);

View File

@ -1,6 +1,8 @@
#include "assert.h"
#include "errno.h"
#include "mmuContext.h"
#include "paging.h"
#include "process.h"
#include "thread.h"
#include "uaccess.h"

View File

@ -68,7 +68,7 @@ void testPhymem(void)
assert(freePageStatAlloc == 0);
assert((usedPageStatAlloc - usedPageStatBegin) == (uint)allocCount);
while ((page = list_pop_head(allocated_page_list)) != NULL) {
while ((allocated_page_list != NULL) && (page = list_pop_head(allocated_page_list)) != NULL) {
assertmsg(page->phy_addr == (ulong)freeCount, "page %d modified", page);
assertmsg(unrefPhyPage((ulong)page) >= 0, "Failed to free page %d\n", (ulong)page);
freeCount++;