Chameleon

Chameleon Commit Details

Date:2011-07-22 18:34:01 (12 years 10 months ago)
Author:Evan Lojewski
Commit:1209
Parents: 1208
Message:Use printf from klibc instead of from console.c
Changes:
A/branches/xZen/i386/modules/klibc/printf.c
A/branches/xZen/i386/modules/klibc/fprintf.c
A/branches/xZen/i386/modules/klibc/vfprintf.c
A/branches/xZen/i386/modules/klibc/fwrite.c
M/branches/xZen/i386/modules/klibc/Cconfig
M/branches/xZen/i386/libsaio/console.c
M/branches/xZen/i386/modules/Disk/GUIDPartition.cpp
M/branches/xZen/i386/modules/klibc/Makefile
M/branches/xZen/i386/modules/Disk/BiosDisk.cpp
M/branches/xZen/i386/modules/Disk/include/GUIDPartition.hpp

File differences

branches/xZen/i386/libsaio/console.c
162162
163163
164164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191165
192166
193167
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;
branches/xZen/i386/modules/klibc/printf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
* printf.c
*/
#include <stdio.h>
#include <stdarg.h>
#define BUFFER_SIZE16384
int printf(const char *format, ...)
{
va_list ap;
int rv;
va_start(ap, format);
rv = vfprintf(NULL, format, ap);
va_end(ap);
return rv;
}
branches/xZen/i386/modules/klibc/Makefile
2222
2323
2424
25
2526
2627
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
branches/xZen/i386/modules/klibc/vfprintf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
* vfprintf.c
*/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#define BUFFER_SIZE32768
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);
}
branches/xZen/i386/modules/klibc/Cconfig
66
77
88
9
9
1010
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.
branches/xZen/i386/modules/klibc/fwrite.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
* fwrite.c
*/
#include <unistd.h>
#include <stdio.h>
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;
}
branches/xZen/i386/modules/klibc/fprintf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
* fprintf.c
*/
#include <stdio.h>
#include <stdarg.h>
#define BUFFER_SIZE16384
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;
}
branches/xZen/i386/modules/Disk/GUIDPartition.cpp
1313
1414
1515
16
17
1618
1719
1820
......
2325
2426
2527
26
28
29
30
2731
2832
2933
......
3640
3741
3842
39
40
43
44
4145
46
4247
4348
4449
45
46
50
51
52
53
54
55
56
57
58
4759
60
61
62
63
64
65
66
67
4868
69
70
71
4972
5073
74
5175
76
5277
5378
5479
GUIDPartition::GUIDPartition(Disk* disk, UInt8 partitionNumber) : Partition(disk, partitionNumber)
{
UInt32 entrySize = 0;
mDisk = disk;
mNumSectors = 0;
mBeginSector = 0;
{
// 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
{
}
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()
branches/xZen/i386/modules/Disk/include/GUIDPartition.hpp
99
1010
1111
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
1247
1348
1449
......
1954
2055
2156
22
23
24
57
58
59
2560
2661
2762
#include <Partition.hpp>
#include <IOKit/storage/IOGUIDPartitionScheme.h>
#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:
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 */
branches/xZen/i386/modules/Disk/BiosDisk.cpp
9898
9999
100100
101
101
102102
103103
104104
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;

Archive Download the corresponding diff file

Revision: 1209