From: John Hodge Date: Fri, 2 Oct 2009 03:22:43 +0000 (+0800) Subject: Removed Page directory dump, added a mention of the fault details before the table... X-Git-Tag: rel0.06~396 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=71127582530c214c99852fda37f7e5296774a26f;p=tpg%2Facess2.git Removed Page directory dump, added a mention of the fault details before the table dump. Added qsort function to libc --- diff --git a/Kernel/arch/x86/mm_virt.c b/Kernel/arch/x86/mm_virt.c index 1fadd4b4..2b7d191b 100644 --- a/Kernel/arch/x86/mm_virt.c +++ b/Kernel/arch/x86/mm_virt.c @@ -149,6 +149,8 @@ void MM_PageFault(Uint Addr, Uint ErrorCode, tRegs *Regs) if( gaPageDir[Addr>>22] & PF_PRESENT ) Log("gaPageTable[0x%x] = 0x%x", Addr>>12, gaPageTable[Addr>>12]); + Log("Code at %p accessed %p\n", Regs->eip, Addr); + MM_DumpTables(0, -1); Panic("Page Fault at 0x%x\n", Regs->eip); @@ -168,6 +170,7 @@ void MM_DumpTables(tVAddr Start, tVAddr End) Start >>= 12; End >>= 12; + #if 0 Log("Directory Entries:"); for(page = Start >> 10; page < (End >> 10)+1; @@ -181,6 +184,7 @@ void MM_DumpTables(tVAddr Start, tVAddr End) ); } } + #endif Log("Table Entries:"); for(page = Start, curPos = Start<<12; diff --git a/Usermode/Applications/cat_src/Makefile b/Usermode/Applications/cat_src/Makefile index dcd326d8..5774e570 100644 --- a/Usermode/Applications/cat_src/Makefile +++ b/Usermode/Applications/cat_src/Makefile @@ -22,7 +22,7 @@ $(BIN): $(COBJ) @echo --- $(LD) -o $@ @$(LD) $(LDFLAGS) -o $@ $(COBJ) -Map Map.txt objdump -d $(BIN) > $(BIN).dsm - cp $(BIN) /mnt/AcessHDD/Acess2/ + cp $(BIN) /mnt/AcessHDD/Acess2/Bin/ clean: $(RM) $(COBJ) $(BIN) diff --git a/Usermode/Libraries/libc.so_src/stdlib.c b/Usermode/Libraries/libc.so_src/stdlib.c index f5acadbd..850d2695 100644 --- a/Usermode/Libraries/libc.so_src/stdlib.c +++ b/Usermode/Libraries/libc.so_src/stdlib.c @@ -13,9 +13,6 @@ #define _stdout 1 #define _stdin 0 -// === IMPORTS === -extern int fprintfv(FILE *fp, const char *format, va_list args); - // === PROTOTYPES === EXPORT int atoi(const char *str); EXPORT void exit(int status); @@ -31,6 +28,34 @@ EXPORT void exit(int status) } /** + * \fn EXPORT void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)) + * \brief Sort an array + * \note Uses a selection sort + */ +EXPORT void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)) +{ + int i, j, min; + for( i = 0; i < (nmemb-1); i++ ) + { + min = i; + for( j = i+1; j < nmemb; j++ ) + { + if(compar(base+size*j, base + size*min) < 0) { + min = j; + } + } + if (i != min) { + char swap[size]; + memcpy(swap, base+size*i, size); + memcpy(base+size*i, base+size*min, size); + memcpy(base+size*i, swap, size); + } + } +} + +/** + * \fn EXPORT int atoi(const char *str) + * \brief Convert a string to an integer */ EXPORT int atoi(const char *str) { diff --git a/Usermode/include/stdlib.h b/Usermode/include/stdlib.h index 6f745f16..9dd720e7 100644 --- a/Usermode/include/stdlib.h +++ b/Usermode/include/stdlib.h @@ -13,6 +13,9 @@ stdlib.h # define NULL ((void*)0) #endif +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + typedef unsigned int size_t; // --- Spinlock Macros --- @@ -24,6 +27,7 @@ typedef unsigned int size_t; // --- StdLib --- extern int atoi(const char *ptr); extern void exit(int status) __attribute__((noreturn)); +extern void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); // --- Environment --- extern char *getenv(const char *name);