Index: branches/xZenu/src/modules/uClibcxx/new_opvnt.cpp =================================================================== --- branches/xZenu/src/modules/uClibcxx/new_opvnt.cpp (revision 1296) +++ branches/xZenu/src/modules/uClibcxx/new_opvnt.cpp (revision 1297) @@ -21,9 +21,7 @@ #include #include #include -extern "C" { -#include "libsaio.h" -}; + #ifndef NO_NOTHROW _UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) throw(){ return malloc(numBytes); Index: branches/xZenu/src/modules/uClibcxx/new_opnt.cpp =================================================================== --- branches/xZenu/src/modules/uClibcxx/new_opnt.cpp (revision 1296) +++ branches/xZenu/src/modules/uClibcxx/new_opnt.cpp (revision 1297) @@ -21,9 +21,7 @@ #include #include #include -extern "C" { -#include "libsaio.h" -}; + #ifndef NO_NOTHROW _UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) throw(){ return malloc(numBytes); Index: branches/xZenu/src/modules/uClibcxx/new_opv.cpp =================================================================== --- branches/xZenu/src/modules/uClibcxx/new_opv.cpp (revision 1296) +++ branches/xZenu/src/modules/uClibcxx/new_opv.cpp (revision 1297) @@ -21,9 +21,7 @@ #include #include #include -extern "C" { -#include "libsaio.h" -}; + _UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc){ //C++ stardard 5.3.4.8 requires that a valid pointer be returned for //a call to new(0). Thus: Index: branches/xZenu/src/modules/uClibcxx/new_op.cpp =================================================================== --- branches/xZenu/src/modules/uClibcxx/new_op.cpp (revision 1296) +++ branches/xZenu/src/modules/uClibcxx/new_op.cpp (revision 1297) @@ -20,9 +20,6 @@ #include #include -extern "C" { -#include "libsaio.h" -}; _UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc){ //C++ stardard 5.3.4.8 requires that a valid pointer be returned for Index: branches/xZenu/src/modules/uClibcxx/uClibc++.c =================================================================== --- branches/xZenu/src/modules/uClibcxx/uClibc++.c (revision 1296) +++ branches/xZenu/src/modules/uClibcxx/uClibc++.c (revision 1297) @@ -1,4 +1,4 @@ -#include "libsaio.h" +#include void uClibcxx_start() { @@ -6,7 +6,8 @@ void abort() { - stop("uClibc+: abort()\n"); + printf("uClibc+: abort()\n"); + while(1); } Index: branches/xZenu/src/modules/MakeInc.dir =================================================================== --- branches/xZenu/src/modules/MakeInc.dir (revision 1296) +++ branches/xZenu/src/modules/MakeInc.dir (revision 1297) @@ -49,7 +49,7 @@ MODULE_INCLUDES := $(foreach x,ModuleSystem $(MODULE_DEPENDENCIES),-I$(SRCROOT)/modules/$(x)/include/) -INC = -I$(SRCROOT)/include/ -I$(SRCROOT)/sym/ -I$(SRCROOT)/modules/include/ -Iinclude/ -I$(SRCROOT)/arch/i386/libsaio/ -I$(SRCROOT)/arch/i386/libsa/ -I$(SRCROOT)/arch/i386/include/ -I$(SRCROOT)/i386/boot2/ $(MODULE_INCLUDES) +INC = -I$(SRCROOT)/include/ -I$(SRCROOT)/sym/ -I$(SRCROOT)/modules/include/ -Iinclude/ $(MODULE_INCLUDES) DEFINES := -D__KLIBC__ $(DEFINES) MODULE_DEPENDENCIES := $(wildcard $(foreach x,$(MODULE_DEPENDENCIES),$(SYMROOT)/$(x).dylib)) \ Index: branches/xZenu/src/modules/klibc/klibc.c =================================================================== --- branches/xZenu/src/modules/klibc/klibc.c (revision 1296) +++ branches/xZenu/src/modules/klibc/klibc.c (revision 1297) @@ -4,7 +4,7 @@ * glue + initialization */ -#include "libsaio.h" +#include int _DefaultRuneLocale; // todo: fixme @@ -14,8 +14,8 @@ void _exit(int status) { - stop("exit() called\n"); - while(1) halt(); // this is never reached + printf("exit() called\n"); + while(1); } char __toupper(char c) @@ -25,7 +25,8 @@ void __divide_error() { - stop("Divide by 0\n"); + printf("Divide by 0\n"); + while(1); } // hack Index: branches/xZenu/src/modules/klibc/zalloc.c =================================================================== --- branches/xZenu/src/modules/klibc/zalloc.c (revision 1296) +++ branches/xZenu/src/modules/klibc/zalloc.c (revision 1297) @@ -29,16 +29,9 @@ * */ -#include "libsa.h" -//#include "saio_internal.h" - Azi: needed for ZDEBUG (printf) -#include "memory.h" +#include +#include -#define ZDEBUG 0 //Azi: booter doesn't load with this enabled; instant reboot at "boot1: ..." - -#if ZDEBUG -int zout; -#endif - typedef struct { char * start; size_t size; @@ -56,10 +49,6 @@ static void zdelete(zmem * zp, int ndx); static void zcoalesce(void); -#if ZDEBUG -size_t zalloced_size; -#endif - #define ZALLOC_NODES 16384 static void malloc_error(char *addr, size_t size, const char *file, int line) @@ -74,7 +63,7 @@ // define the block of memory that the allocator will use void malloc_init(char * start, int size, int nodes, void (*malloc_err_fn)(char *, size_t, const char *, int)) { - zalloc_base = start ? start : (char *)ZALLOC_ADDR; +/* zalloc_base = start ? start : (char *)ZALLOC_ADDR; totalNodes = nodes ? nodes : ZALLOC_NODES; zalloced = (zmem *) zalloc_base; zavailable = (zmem *) zalloc_base + sizeof(zmem) * totalNodes; @@ -85,11 +74,25 @@ availableNodes = 1; allocedNodes = 0; zerror = malloc_err_fn ? malloc_err_fn : malloc_error; + */ + + zalloc_base = start; + totalNodes = nodes; + zalloced = (zmem *) zalloc_base; + zavailable = (zmem *) zalloc_base + sizeof(zmem) * totalNodes; + zavailable[0].start = (char *)zavailable + sizeof(zmem) * totalNodes; + zavailable[0].size = size - (zavailable[0].start - zalloc_base); + zalloc_end = zalloc_base + size; + availableNodes = 1; + allocedNodes = 0; + zerror = malloc_err_fn ? malloc_err_fn : malloc_error; + } #define BEST_FIT 1 #undef malloc +void * safe_malloc(size_t size, const char *file, int line); void *malloc(size_t size) { return safe_malloc(size, __FILE__, __LINE__); @@ -106,8 +109,8 @@ if ( !zalloc_base ) { - // this used to follow the bss but some bios' corrupted it... - malloc_init((char *)ZALLOC_ADDR, ZALLOC_LEN, ZALLOC_NODES, malloc_error); + printf("malloc_init not called.\n"); + while(1); } size = ((size + 0xf) & ~0xf); @@ -168,11 +171,8 @@ } if (ret != 0) { - bzero(ret, size); + memset(ret, 0, size); } -#if ZDEBUG - zalloced_size += size; -#endif return (void *) ret; } @@ -200,15 +200,8 @@ if ( zalloced[i].start == start ) { tsize = zalloced[i].size; -#if ZDEBUG - zout -= tsize; - printf(" zz out %d\n",zout); -#endif zdelete(zalloced, i); allocedNodes--; found = 1; -#if ZDEBUG - memset(pointer, 0x5A, tsize); -#endif break; } } @@ -216,9 +209,6 @@ if (zerror) (*zerror)(pointer, rp, "free", 0); else return; } -#if ZDEBUG - zalloced_size -= tsize; -#endif for (i = 0; i < availableNodes; i++) { @@ -262,10 +252,6 @@ static void zallocate(char * start,int size) { -#if ZDEBUG - zout += size; - printf(" alloc %d, total 0x%x\n",size,zout); -#endif zalloced[allocedNodes].start = start; zalloced[allocedNodes].size = size; if (++allocedNodes > totalNodes) { @@ -325,7 +311,7 @@ void * realloc(void * start, size_t newsize) { void * newstart = safe_malloc(newsize, __FILE__, __LINE__); - bcopy(start, newstart, newsize); + memcpy(start, newstart, newsize); free(start); return newstart; } Index: branches/xZenu/src/modules/klibc/__udivmoddi4.c =================================================================== --- branches/xZenu/src/modules/klibc/__udivmoddi4.c (revision 1296) +++ branches/xZenu/src/modules/klibc/__udivmoddi4.c (revision 1297) @@ -1,4 +1,4 @@ -#include "libsaio.h" +#include extern void __divide_error(); Index: branches/xZenu/src/modules/klibc/__udivmodsi4.c =================================================================== --- branches/xZenu/src/modules/klibc/__udivmodsi4.c (revision 1296) +++ branches/xZenu/src/modules/klibc/__udivmodsi4.c (revision 1297) @@ -1,4 +1,5 @@ -#include "libsaio.h" +#include + extern void __divide_error(); uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem_p) { Index: branches/xZenu/src/modules/Disk/GUIDPartition.cpp =================================================================== --- branches/xZenu/src/modules/Disk/GUIDPartition.cpp (revision 1296) +++ branches/xZenu/src/modules/Disk/GUIDPartition.cpp (revision 1297) @@ -5,11 +5,6 @@ #include #include -extern "C" -{ -#include "libsaio.h" -#include "stdio.h" -} GUIDPartition::GUIDPartition(Disk* disk, UInt8 partitionNumber) : Partition(disk, partitionNumber) { Index: branches/xZenu/src/modules/Disk/Main.cpp =================================================================== --- branches/xZenu/src/modules/Disk/Main.cpp (revision 1296) +++ branches/xZenu/src/modules/Disk/Main.cpp (revision 1297) @@ -2,6 +2,7 @@ * Copyright (c) 2011 Evan Lojewski. All rights reserved. * */ +#include #include #include @@ -12,7 +13,6 @@ #define BIOSBUFFER 512 * 8 /* 4Kb */ extern "C" { -#include "libsaio.h" void Disk_start(); } @@ -50,7 +50,7 @@ - halt(); + while (1); } void DetermineDisks() Index: branches/xZenu/src/modules/Disk/i386/BiosDisk.cpp =================================================================== --- branches/xZenu/src/modules/Disk/i386/BiosDisk.cpp (revision 1296) +++ branches/xZenu/src/modules/Disk/i386/BiosDisk.cpp (revision 1297) @@ -45,14 +45,8 @@ * - Converted to c++ * - Converted to UInt* style variable types */ - +#include #include - -extern "C" -{ -#include "libsaio.h" -#include "stdio.h" -} BiosDisk::BiosDisk(const char* name) { Index: branches/xZenu/src/modules/Disk/Makefile =================================================================== --- branches/xZenu/src/modules/Disk/Makefile (revision 1296) +++ branches/xZenu/src/modules/Disk/Makefile (revision 1297) @@ -9,6 +9,6 @@ DIR = Disk MODULE_OBJS = Disk Partition FDiskPartition GUIDPartition Main -I386_OBJS = BiosDisk +#I386_OBJS = BiosDisk include ../MakeInc.dir \ No newline at end of file