Index: branches/xZen/i386/libsaio/console.c =================================================================== --- branches/xZen/i386/libsaio/console.c (revision 1208) +++ branches/xZen/i386/libsaio/console.c (revision 1209) @@ -162,32 +162,6 @@ return (c); } -int printf(const char * fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - - prf(fmt, ap, putchar, 0); - - { - // Kabyl: BooterLog - struct putc_info pi; - - if (!msgbuf) - return 0; - - if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) - return 0; - pi.str = cursor; - pi.last_str = 0; - prf(fmt, ap, sputc, &pi); - cursor += strlen((char *)cursor); - } - - va_end(ap); - return 0; -} - int verbose(const char * fmt, ...) { va_list ap; Index: branches/xZen/i386/modules/klibc/printf.c =================================================================== --- branches/xZen/i386/modules/klibc/printf.c (revision 0) +++ branches/xZen/i386/modules/klibc/printf.c (revision 1209) @@ -0,0 +1,19 @@ +/* + * printf.c + */ + +#include +#include + +#define BUFFER_SIZE 16384 + +int printf(const char *format, ...) +{ + va_list ap; + int rv; + + va_start(ap, format); + rv = vfprintf(NULL, format, ap); + va_end(ap); + return rv; +} Index: branches/xZen/i386/modules/klibc/Makefile =================================================================== --- branches/xZen/i386/modules/klibc/Makefile (revision 1208) +++ branches/xZen/i386/modules/klibc/Makefile (revision 1209) @@ -22,5 +22,6 @@ memccpy.o memchr.o memmem.o memmove.o memrchr.o memswap.o \ qsort.o sha1hash.o onexit.o atexit.o exit.o \ snprintf.o vsnprintf.o sscanf.o vsscanf.o\ + fwrite.o fprintf.o vfprintf.o printf.o include ../MakeInc.dir \ No newline at end of file Index: branches/xZen/i386/modules/klibc/vfprintf.c =================================================================== --- branches/xZen/i386/modules/klibc/vfprintf.c (revision 0) +++ branches/xZen/i386/modules/klibc/vfprintf.c (revision 1209) @@ -0,0 +1,28 @@ +/* + * vfprintf.c + */ + +#include +#include +#include +#include + +#define BUFFER_SIZE 32768 + +extern size_t _fwrite(const void *buf, size_t count, FILE *f); + +int vfprintf(FILE * file, const char *format, va_list ap) +{ + int rv; + char buffer[BUFFER_SIZE]; + + rv = vsnprintf(buffer, BUFFER_SIZE, format, ap); + + if (rv < 0) + return rv; + + if (rv > BUFFER_SIZE - 1) + rv = BUFFER_SIZE - 1; + + return _fwrite(buffer, rv, file); +} Index: branches/xZen/i386/modules/klibc/Cconfig =================================================================== --- branches/xZen/i386/modules/klibc/Cconfig (revision 1208) +++ branches/xZen/i386/modules/klibc/Cconfig (revision 1209) @@ -6,5 +6,5 @@ tristate "klibc Module" default m ---help--- - Say Y here if you want to enable to use of this module. + Say Y here if you want to enable the use of this module. Index: branches/xZen/i386/modules/klibc/fwrite.c =================================================================== --- branches/xZen/i386/modules/klibc/fwrite.c (revision 0) +++ branches/xZen/i386/modules/klibc/fwrite.c (revision 1209) @@ -0,0 +1,24 @@ +/* + * fwrite.c + */ + +#include +#include + +size_t _fwrite(const void *buf, size_t count, FILE *f) +{ + size_t bytes = 0; + ssize_t rv; + const char *p = buf; + + while (count) { + rv = 1; + putchar(*p); + + p += rv; + bytes += rv; + count -= rv; + } + + return bytes; +} Index: branches/xZen/i386/modules/klibc/fprintf.c =================================================================== --- branches/xZen/i386/modules/klibc/fprintf.c (revision 0) +++ branches/xZen/i386/modules/klibc/fprintf.c (revision 1209) @@ -0,0 +1,19 @@ +/* + * fprintf.c + */ + +#include +#include + +#define BUFFER_SIZE 16384 + +int fprintf(FILE * file, const char *format, ...) +{ + va_list ap; + int rv; + + va_start(ap, format); + rv = vfprintf(file, format, ap); + va_end(ap); + return rv; +} Index: branches/xZen/i386/modules/Disk/GUIDPartition.cpp =================================================================== --- branches/xZen/i386/modules/Disk/GUIDPartition.cpp (revision 1208) +++ branches/xZen/i386/modules/Disk/GUIDPartition.cpp (revision 1209) @@ -13,6 +13,8 @@ GUIDPartition::GUIDPartition(Disk* disk, UInt8 partitionNumber) : Partition(disk, partitionNumber) { + UInt32 entrySize = 0; + mDisk = disk; mNumSectors = 0; mBeginSector = 0; @@ -23,7 +25,9 @@ { // read in lba1, this contains the partition map if it's GPT mDisk->Read(1, 1, mLBABUffer); - mGPTHeader = (gpt_hdr*)mLBABUffer; + mGPTHeader = (GPTHeader*)mLBABUffer; + entrySize = mGPTHeader->hdr_entsz; + } else { @@ -36,19 +40,40 @@ } mGPTHeader = NULL; - - if(mPartitionNumber >= 0 && mPartitionNumber < mNumPartitions) + + if(entrySize && mPartitionNumber >= 0 && mPartitionNumber < mNumPartitions) { + printf("Partitions %d at LBA %d\n", mPartitionNumber, 2 + (mPartitionNumber / 4)); // TODO: Verify partition is valid + offset. mDisk->Read(2 + (mPartitionNumber / 4), 1, mLBABUffer); - UInt32 offset = (mPartitionNumber % 4) * mGPTHeader->hdr_entsz; - mGPTEntry = (gpt_ent*) mLBABUffer + offset; + for(int i = 0; i < 10; i++) + { + for(int j = 0; j < 15; j++) + { + printf("%x ", mLBABUffer[i*15+j]); + } + printf("\n"); + + } + UInt32 offset = (mPartitionNumber % 4) * entrySize; + printf("\toffset %d at LBA %d\n", offset); + + mGPTEntry = (GPTEntry*) /*mLBABUffer*/ BIOS_ADDR + offset; + + printf("UUID0 %X%X%X%X\n", mGPTEntry->ent_type[3], mGPTEntry->ent_type[2], mGPTEntry->ent_type[1], mGPTEntry->ent_type[0]); + printf("mGPTEntry = %d\n", mGPTEntry); + mNumSectors = mGPTEntry->ent_lba_end - mGPTEntry->ent_lba_start; + printf("mNumSectors = %d\n", mNumSectors); + + printf("LBS Start: %lld\tEnd: %lld\n", mGPTEntry->ent_lba_start, mGPTEntry->ent_lba_end); mBeginSector = mGPTEntry->ent_lba_start; //mUUID = mGPTEntry->ent_uuid; + pause(); } + } GUIDPartition::~GUIDPartition() Index: branches/xZen/i386/modules/Disk/include/GUIDPartition.hpp =================================================================== --- branches/xZen/i386/modules/Disk/include/GUIDPartition.hpp (revision 1208) +++ branches/xZen/i386/modules/Disk/include/GUIDPartition.hpp (revision 1209) @@ -9,6 +9,41 @@ #include #include +#pragma pack(push, 1) /* (enable 8-bit struct packing) */ + +typedef struct +{ + UInt8 hdr_sig[8]; + UInt32 hdr_revision; + UInt32 hdr_size; + UInt32 hdr_crc_self; + UInt32 __reserved; + UInt64 hdr_lba_self; + UInt64 hdr_lba_alt; + UInt64 hdr_lba_start; + UInt64 hdr_lba_end; + UInt8 hdr_uuid[16]; + UInt64 hdr_lba_table; + UInt32 hdr_entries; + UInt32 hdr_entsz; + UInt32 hdr_crc_table; + UInt32 padding; +} GPTHeader; + +/* Partition map entry. */ + +typedef struct +{ + UInt8 ent_type[16]; + UInt8 ent_uuid[16]; + UInt64 ent_lba_start; + UInt64 ent_lba_end; + UInt64 ent_attr; + UInt16 ent_name[36]; +} GPTEntry; + +#pragma pack(pop) + class GUIDPartition : public Partition { public: @@ -19,9 +54,9 @@ bool isGPTDisk(); private: - UInt8 mLBABUffer[512]; // TODO: don't assume 512 - gpt_hdr* mGPTHeader; - gpt_ent* mGPTEntry; + UInt8 mLBABUffer[512*4]; // TODO: don't assume 512 + GPTHeader* mGPTHeader; + GPTEntry* mGPTEntry; }; #endif /* GUID_PARTITION_H */ Index: branches/xZen/i386/modules/Disk/BiosDisk.cpp =================================================================== --- branches/xZen/i386/modules/Disk/BiosDisk.cpp (revision 1208) +++ branches/xZen/i386/modules/Disk/BiosDisk.cpp (revision 1209) @@ -98,7 +98,7 @@ if(!isValid()) return kIOReturnNoDevice; // Assume EBIOS capable for now... - if(EBIOSRead(sector, size) == 0) + if(EBIOSRead(sector, size) == kIOReturnSuccess) { bcopy((void*)BIOS_ADDR, buffer, size * mBytesPerSector); return kIOReturnSuccess;