From: John Hodge Date: Wed, 23 Mar 2011 05:33:04 +0000 (+0800) Subject: Cleaning up mostly X-Git-Tag: rel0.10~151 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9096ba960349e39b44a7053a753d20bce726710c;p=tpg%2Facess2.git Cleaning up mostly - Fixed makefiles to not assume that environment is correctly set (I.e. $(ARCH)) - Changed GCC to CC and NASM to AS in makefile trace output - Cleaned up top-of-file externs - Improved Heap_Dump output --- diff --git a/Kernel/Makefile b/Kernel/Makefile index af931a63..e4b0436b 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -70,14 +70,14 @@ $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile @$(STRIP) $(BIN) %.ao.$(ARCH): %.asm Makefile - @echo --- NASM -o $@ + @echo --- AS -o $@ @$(AS) $(ASFLAGS) $< -o $@ %.o.$(ARCH): %.c Makefile # if exists %*/Makefile # @make -C %*/ all # else - @echo --- GCC -o $@ + @echo --- CC -o $@ @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $*.d.$(ARCH) $< # endif diff --git a/Kernel/Makefile.BuildNum.x86_64 b/Kernel/Makefile.BuildNum.x86_64 index 379412ae..446c8f59 100644 --- a/Kernel/Makefile.BuildNum.x86_64 +++ b/Kernel/Makefile.BuildNum.x86_64 @@ -1 +1 @@ -BUILD_NUM = 233 +BUILD_NUM = 234 diff --git a/Kernel/arch/x86/Makefile b/Kernel/arch/x86/Makefile index 0c442882..41a10bc3 100644 --- a/Kernel/arch/x86/Makefile +++ b/Kernel/arch/x86/Makefile @@ -13,21 +13,21 @@ CPPFLAGS = CFLAGS = ASFLAGS = -f elf +USE_MP=0 +USE_PAE=0 + ifeq ($(ARCH),i386) - ASFLAGS += -D USE_MP=0 -D USE_PAE=0 - CPPFLAGS += -DUSE_MP=0 -DUSE_PAE=0 -else - ifeq ($(ARCH),i486) - ASFLAGS += -D USE_MP=1 -D USE_PAE=0 - CPPFLAGS += -DUSE_MP=1 -DUSE_PAE=0 - else - ifeq ($(ARCH),i586) - ASFLAGS += -D USE_MP=1 -D USE_PAE=1 - CPPFLAGS += -DUSE_MP=1 -DUSE_PAE=1 - endif - endif + USE_MP=0 + USE_PAE=0 +else ifeq ($(ARCH),i486) + USE_MP=1 +else ifeq ($(ARCH),i586) + USE_MP=1 + USE_PAE=1 endif - + +ASFLAGS += -D USE_MP=$(USE_MP) -D USE_PAE=$(USE_PAE) +CPPFLAGS += -DUSE_MP=$(USE_MP) -DUSE_PAE=$(USE_PAE) A_OBJ = start.ao main.o lib.o desctab.ao errors.o irq.o A_OBJ += mm_phys.o mm_virt.o diff --git a/Kernel/arch/x86/main.c b/Kernel/arch/x86/main.c index a55979f2..b0fe6e09 100644 --- a/Kernel/arch/x86/main.c +++ b/Kernel/arch/x86/main.c @@ -28,7 +28,6 @@ extern void System_Init(char *Commandline); // === PROTOTYPES === int kmain(Uint MbMagic, void *MbInfoPtr); -void Arch_LoadBootModules(void); // === GLOBALS === char *gsBootCmdLine = NULL; diff --git a/Kernel/heap.c b/Kernel/heap.c index a569578c..c440b183 100644 --- a/Kernel/heap.c +++ b/Kernel/heap.c @@ -62,6 +62,11 @@ void *Heap_Extend(int Bytes) if( (tVAddr)gHeapEnd == MM_KHEAP_MAX ) return NULL; + if( Bytes == 0 ) { + Log_Warning("Heap", "Heap_Extend called with Bytes=%i", Bytes); + return NULL; + } + // Bounds Check if( (tVAddr)gHeapEnd + ((Bytes+0xFFF)&~0xFFF) > MM_KHEAP_MAX ) { Bytes = MM_KHEAP_MAX - (tVAddr)gHeapEnd; @@ -314,7 +319,7 @@ void Heap_Deallocate(void *Ptr) } if(head->Magic != MAGIC_USED) { Log_Warning("Heap", "free - Magic value is invalid (%p, 0x%x)", head, head->Magic); - Log_Notice("Heap", "Allocated %s:%i", head->File, head->Line); + Log_Notice("Heap", "Allocated by %s:%i", head->File, head->Line); return; } @@ -322,12 +327,12 @@ void Heap_Deallocate(void *Ptr) foot = (void*)( (Uint)head + head->Size - sizeof(tHeapFoot) ); if(foot->Head != head) { Log_Warning("Heap", "free - Footer backlink is incorrect (%p, 0x%x)", head, foot->Head); - Log_Notice("Heap", "Allocated %s:%i", head->File, head->Line); + Log_Notice("Heap", "Allocated by %s:%i", head->File, head->Line); return; } if(foot->Magic != MAGIC_FOOT) { Log_Warning("Heap", "free - Footer magic is invalid (%p, %p = 0x%x)", head, &foot->Magic, foot->Magic); - Log_Notice("Heap", "Allocated %s:%i", head->File, head->Line); + Log_Notice("Heap", "Allocated by %s:%i", head->File, head->Line); return; } @@ -561,7 +566,7 @@ void Heap_Dump(void) return ; #if !VERBOSE_DUMP - Log_Log("Heap", "%p (0x%llx): 0x%08lx (%i) %4C", + Log_Log("Heap", "%p (0x%llx): 0x%08lx %i %4C", head, MM_GetPhysAddr((Uint)head), head->Size, head->ValidSize, &head->Magic); Log_Log("Heap", "%p %4C", foot->Head, &foot->Magic); if(head->File) { diff --git a/Kernel/include/init.h b/Kernel/include/init.h index a16acfdc..9f2fc108 100644 --- a/Kernel/include/init.h +++ b/Kernel/include/init.h @@ -5,13 +5,7 @@ #ifndef _INIT_H #define _INIT_H -#define INIT_SRV_MAGIC (0xE6|('S'<<8)|('R'<<16)|('V'<<24)) - -typedef struct sInitServ { - Uint32 Magic; - Uint32 LoadBase; - Uint32 MemSize; - int (*Entrypoint)(char **Args); -} tInitServ; +extern void Arch_LoadBootModules(void); +extern void StartupPrint(const char *String); #endif diff --git a/Kernel/include/threads.h b/Kernel/include/threads.h index f53bbad2..68fb9552 100644 --- a/Kernel/include/threads.h +++ b/Kernel/include/threads.h @@ -111,6 +111,7 @@ extern BOOL gaThreads_NoTaskSwitch[MAX_CPUS]; // === FUNCTIONS === extern tThread *Proc_GetCurThread(void); + extern tThread *Threads_GetThread(Uint TID); extern void Threads_SetPriority(tThread *Thread, int Pri); extern int Threads_Wake(tThread *Thread); diff --git a/Kernel/include/tpl_drv_joystick.h b/Kernel/include/tpl_drv_joystick.h index 16c04cee..dd220011 100644 --- a/Kernel/include/tpl_drv_joystick.h +++ b/Kernel/include/tpl_drv_joystick.h @@ -28,7 +28,7 @@ */ enum eTplJoystick_IOCtl { /** - * ioctl(..., struct{int Ident;tKeybardCallback *Callback}) + * ioctl(..., struct{int Ident;tJoystickCallback *Callback}) * \brief Sets the callback * \note Can be called from kernel mode only * diff --git a/Kernel/syscalls.c b/Kernel/syscalls.c index 6c62a927..b0329836 100644 --- a/Kernel/syscalls.c +++ b/Kernel/syscalls.c @@ -8,6 +8,7 @@ #include #include #include +#include #define CHECK_NUM_NULLOK(v,size) \ if((v)&&!Syscall_Valid((size),(Uint)(v))){ret=-1;err=-EINVAL;break;}