Chameleon

Chameleon Commit Details

Date:2014-10-31 20:49:24 (9 years 5 months ago)
Author:ErmaC
Commit:2458
Parents: 2457
Message:Merge bitshoveler improvements and bugfix
Changes:
M/branches/ErmaC/Enoch/i386/libsaio/saio_internal.h
M/branches/ErmaC/Enoch/i386/libsa/zalloc.c
M/branches/ErmaC/Enoch/i386/libsaio/hpet.c
M/branches/ErmaC/Enoch/i386/libsaio/ufs.h
M/branches/ErmaC/Enoch/i386/boot2/picopng.c
M/branches/ErmaC/Enoch/i386/libsaio/cache.c
M/branches/ErmaC/Enoch/i386/boot2/graphics.c
M/branches/ErmaC/Enoch/i386/boot2/boot.c
M/branches/ErmaC/Enoch/i386/modules/AcpiCodec/acpi_codec.c
M/branches/ErmaC/Enoch/package/buildpkg.sh
M/branches/ErmaC/Enoch/i386/boot2/modules.c
M/branches/ErmaC/Enoch/CHANGES
M/branches/ErmaC/Enoch/i386/libsaio/vbe.c
M/branches/ErmaC/Enoch/i386/libsaio/ati.c
M/branches/ErmaC/Enoch/i386/libsa/string.c
M/branches/ErmaC/Enoch/i386/libsaio/sys.c
M/branches/ErmaC/Enoch/i386/libsaio/aml_generator.c
M/branches/ErmaC/Enoch/i386/libsaio/hfs.c
M/branches/ErmaC/Enoch/i386/boot2/drivers.c
M/branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c
M/branches/ErmaC/Enoch/i386/libsaio/saio_types.h
M/branches/ErmaC/Enoch/i386/libsaio/aml_generator.h
M/branches/ErmaC/Enoch/i386/libsaio/msdos.c
M/branches/ErmaC/Enoch/i386/libsaio/hfs.h
M/branches/ErmaC/Enoch/i386/libsaio/bootargs.h
M/branches/ErmaC/Enoch/i386/boot2/bmdecompress.c
M/branches/ErmaC/Enoch/i386/boot2/gui.c
M/branches/ErmaC/Enoch/i386/libsaio/platform.h
M/branches/ErmaC/Enoch/i386/libsaio/fake_efi.c
M/branches/ErmaC/Enoch/i386/libsaio/msdos.h
M/branches/ErmaC/Enoch/i386/libsaio/disk.c

File differences

branches/ErmaC/Enoch/i386/libsaio/vbe.c
3333
3434
3535
36
37
3836
3937
4038
......
7169
7270
7371
74
75
7672
7773
7874
......
163159
164160
165161
166
162
167163
168
164
169165
170166
171167
......
195191
196192
197193
198
199
200
194
195
196
201197
198
199
200
202201
203202
204203
......
206205
207206
208207
209
210
211
212208
213209
214210
......
230226
231227
232228
233
229
234230
235231
236232
static biosBuf_t bb;
#if UNUSED
//==============================================================================
#if UNUSED
static inline void
#endif /* UNUSED */
//==============================================================================
#endif /* UNUSED */
int getVBEInfo( void * infoBlock )
{
bb.intno = 0x10;
int paramType,
VBECRTCInfoBlock * timing )
{
double h_period_est, h_freq, h_period, h_total_pixels, h_sync_pixels;
double h_period, h_total_pixels, h_sync_pixels;
double h_active_pixels, h_ideal_duty_cycle, h_blank_pixels, pixel_freq = 0;
double v_sync_plus_bp = 0, v_total_lines = 0, v_field_rate_est, v_frame_rate = 0;
double v_sync_plus_bp = 0, v_total_lines = 0, v_frame_rate = 0;
const double h_pixels = (double) width;
const double v_lines = (double) height;
double v_field_rate_in = (double) paramValue;
// Estimate the horizontal period
h_period_est = ((1 / v_field_rate_in) - kMinVSyncPlusBP / 1000000) /
(v_lines + (2 * top_margin_lines) + kMinFrontPorch + interlace) *
1000000;
double h_period_est = ((1 / v_field_rate_in) - kMinVSyncPlusBP / 1000000) /
(v_lines + (2 * top_margin_lines) + kMinFrontPorch + interlace) *
1000000;
// Estimate the vertical field frequency
double v_field_rate_est = 1 / h_period_est / v_total_lines * 1000000;
// Number of lines in Vsync + back porch
v_sync_plus_bp = Round(kMinVSyncPlusBP / h_period_est);
v_total_lines = v_lines + top_margin_lines + bot_margin_lines +
v_sync_plus_bp + interlace + kMinFrontPorch;
// Estimate the vertical field frequency
v_field_rate_est = 1 / h_period_est / v_total_lines * 1000000;
// Find the actual horizontal period
h_period = h_period_est / (v_field_rate_in / v_field_rate_est);
if (paramType == kCRTCParamPixelClock)
{
// Horizontal frequency
h_freq = pixel_freq / h_total_pixels * 1000;
double h_freq = pixel_freq / h_total_pixels * 1000;
// Number of lines in V sync + back porch
v_sync_plus_bp = Round(kMinVSyncPlusBP * h_freq / 1000);
branches/ErmaC/Enoch/i386/libsaio/hfs.c
22
33
44
5
5
66
77
88
......
1616
1717
1818
19
19
2020
21
22
21
22
2323
2424
2525
......
4545
4646
4747
48
49
48
49
5050
5151
5252
......
5959
6060
6161
62
63
64
65
66
67
68
69
70
71
72
73
74
75
62
63
64
65
66
67
68
69
70
71
72
73
74
75
7676
7777
7878
79
80
79
80
8181
8282
83
83
8484
8585
86
86
8787
88
88
8989
90
90
9191
9292
93
93
9494
9595
96
97
96
97
9898
99
100
99
100
101101
102102
103103
......
108108
109109
110110
111
112111
113112
114113
......
119118
120119
121120
122
123121
124122
125123
126124
127
125
126
128127
129128
130129
131130
132131
133
134132
135133
136134
......
150148
151149
152150
153
154151
155152
156153
157154
158
155
159156
157
158
160159
161160
162161
......
284283
285284
286285
287
288286
289287
290288
......
292290
293291
294292
295
293
296294
297295
298296
299
297
298
300299
301300
302301
......
358357
359358
360359
361
360
362361
363362
363
364
364365
365
366
367366
368367
369368
......
435434
436435
437436
438
439
440
441
437
442438
443
439
440
441
442
444443
445
444
445
446446
447447
448448
449449
450
451450
452451
453452
......
462461
463462
464463
465
466464
467465
468
466
469467
470468
471
469
470
472471
473472
474473
......
479478
480479
481480
482
483
484
481
485482
486483
487484
......
519516
520517
521518
522
523
519
520
524521
525522
526
527
528
523
529524
530525
531526
......
550545
551546
552547
553
548
554549
555
556
550
551
552
553
554
557555
558
559
560
561
562
563556
564557
565558
......
600593
601594
602595
603
596
604597
605
598
606599
607600
608601
609602
610
603
611604
612605
613606
......
654647
655648
656649
657
658
659650
660651
661652
......
672663
673664
674665
675
676666
677667
678
668
679669
680670
681
671
672
682673
683674
684675
......
742733
743734
744735
745
746736
747737
748
738
749739
750
740
751741
752742
753743
744
745
754746
755747
756748
......
767759
768760
769761
770
771
762
763
772764
773765
774766
767
775768
776769
777770
......
806799
807800
808801
809
810802
811803
812
804
813805
814
806
815807
816808
817809
818810
819811
820
812
821813
822
823
824
825
814
826815
827
816
828817
829818
819
820
830821
831822
832823
833824
834
835
836
837
825
838826
839
827
840828
841829
830
831
842832
843833
844834
......
846836
847837
848838
849
850839
851840
852
841
853842
854843
855844
......
872861
873862
874863
875
876864
877865
878866
879867
880
868
881869
882
870
883871
884872
885
886
887
873
874
875
876
888877
889878
890879
......
981970
982971
983972
984
973
985974
986975
987976
......
10641053
10651054
10661055
1067
1056
10681057
1069
1070
1058
10711059
1072
1060
10731061
10741062
10751063
10761064
1077
1065
10781066
10791067
10801068
......
10861074
10871075
10881076
1089
1077
10901078
1091
1092
1093
1094
1095
1096
1097
1079
1080
1081
1082
1083
1084
1085
10981086
10991087
11001088
......
11911179
11921180
11931181
1194
1182
11951183
1196
1184
11971185
11981186
11991187
......
12101198
12111199
12121200
1213
12141201
12151202
1216
1203
12171204
1218
1205
12191206
12201207
12211208
......
12321219
12331220
12341221
1235
12361222
12371223
12381224
......
12641250
12651251
12661252
1267
12681253
12691254
12701255
......
13131298
13141299
13151300
1316
13171301
13181302
13191303
......
13731357
13741358
13751359
1376
1360
13771361
1378
1362
13791363
13801364
13811365
13821366
1367
1368
1369
13831370
13841371
13851372
* Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 2.0 (the
* "License"). You may not use this file except in compliance with the
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
*
*
* hfs.c - File System Module for HFS and HFS+.
*
* Copyright (c) 1999-2002 Apple Computer, Inc.
static long long gAllocationOffset;
static long gIsHFSPlus;
static long gCaseSensitive;
static long gBlockSize;
static long gCacheBlockSize;
static u_int32_t gBlockSize;
static u_int32_t gCacheBlockSize;
static char *gBTreeHeaderBuffer;
static BTHeaderRec *gBTHeaders[2];
static char *gHFSMdbVib;
#else /* !__i386__ */
static CICell gCurrentIH;
static long long gAllocationOffset;
static long gIsHFSPlus;
static long gBlockSize;
static long gCaseSensitive;
static long gCacheBlockSize;
static char gBTreeHeaderBuffer[512];
static BTHeaderRec *gBTHeaders[2];
static char gHFSMdbVib[kBlockSize];
static HFSMasterDirectoryBlock *gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib;
static char gHFSPlusHeader[kBlockSize];
static HFSPlusVolumeHeader *gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader;
static char gLinkTemp[64];
static long long gVolID;
static CICellgCurrentIH;
static long longgAllocationOffset;
static longgIsHFSPlus;
static longgCaseSensitive;
static u_int32_tgBlockSize;
static u_int32_tgCacheBlockSize;
static chargBTreeHeaderBuffer[512];
static BTHeaderRec*gBTHeaders[2];
static chargHFSMdbVib[kBlockSize];
static HFSMasterDirectoryBlock*gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib;
static chargHFSPlusHeader[kBlockSize];
static HFSPlusVolumeHeader*gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader;
static chargLinkTemp[64];
static long longgVolID;
#endif /* !__i386__ */
static long ReadFile(void *file, uint64_t *length, void *base, uint64_t offset);
static long GetCatalogEntryInfo(void *entry, long *flags, long *time,
static long ReadFile(void *file, u_int64_t *length, void *base, u_int64_t offset);
static long GetCatalogEntryInfo(void *entry, long *flags, u_int32_t *time,
FinderInfo *finderInfo, long *infoValid);
static long ResolvePathToCatalogEntry(char *filePath, long *flags,
void *entry, long dirID, long long *dirIndex);
void *entry, u_int32_t dirID, long long *dirIndex);
static long GetCatalogEntry(long long *dirIndex, char **name,
long *flags, long *time,
long *flags, u_int32_t *time,
FinderInfo *finderInfo, long *infoValid);
static long ReadCatalogEntry(char *fileName, long dirID, void *entry,
static long ReadCatalogEntry(char *fileName, u_int32_t dirID, void *entry,
long long *dirIndex);
static long ReadExtentsEntry(long fileID, long startBlock, void *entry);
static long ReadExtentsEntry(u_int32_t fileID, long startBlock, void *entry);
static long ReadBTreeEntry(long btree, void *key, char *entry, long long *dirIndex);
static void GetBTreeRecord(long index, char *nodeBuffer, long nodeSize,
static void GetBTreeRecord(u_int16_t index, char *nodeBuffer, u_int16_t nodeSize,
char **key, char **data);
static long ReadExtent(char *extent, uint64_t extentSize, long extentFile,
uint64_t offset, uint64_t size, void *buffer, long cache);
static long ReadExtent(char *extent, u_int64_t extentSize, u_int32_t extentFile,
u_int64_t offset, u_int64_t size, void *buffer, long cache);
static long GetExtentStart(void *extents, long index);
static long GetExtentSize(void *extents, long index);
static u_int32_t GetExtentStart(void *extents, u_int32_t index);
static u_int32_t GetExtentSize(void *extents, u_int32_t index);
static long CompareHFSCatalogKeys(void *key, void *testKey);
static long CompareHFSPlusCatalogKeys(void *key, void *testKey);
extern long BinaryUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1,
u_int16_t *uniStr2, u_int32_t len2);
//==============================================================================
static void SwapFinderInfo(FndrFileInfo *dst, FndrFileInfo *src)
// Don't bother with location
}
//==============================================================================
void HFSFree(CICell ih)
{
if(gCurrentIH == ih) {
if(gCurrentIH == ih)
{
gCurrentIH = 0;
}
free(ih);
}
//==============================================================================
bool HFSProbe (const void *buf)
return true;
}
//==============================================================================
long HFSInitPartition(CICell ih)
{
long extentSize, extentFile, nodeSize;
u_int64_t extentSize;
void *extent;
u_int32_t extentFile;
u_int16_t nodeSize;
if (ih == gCurrentIH)
{
return 0;
}
//==============================================================================
long HFSLoadFile(CICell ih, char * filePath)
return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0);
}
long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length)
long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length)
{
char entry[512];
char devStr[12];
long dirID, result, flags = 0;
u_int32_t dirID;
long result, flags;
if (HFSInitPartition(ih) == -1)
{
return length;
}
long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, char ** name, long * flags, long * time, FinderInfo * finderInfo, long * infoValid)
long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid)
{
char entry[512];
u_int32_t dirID;
long dirFlags;
long dirID, dirFlags = 0;
if (HFSInitPartition(ih) == -1)
{
return -1;
void HFSGetDescription(CICell ih, char *str, long strMaxLen)
{
UInt16 nodeSize;
UInt32 firstLeafNode;
long long dirIndex;
long long dirIndex = 0;
char *name;
long flags =0, time;
long flags;
u_int32_t firstLeafNode;
u_int32_t time;
u_int16_t nodeSize;
if (HFSInitPartition(ih) == -1) {
if (HFSInitPartition(ih) == -1)
{
return;
}
/* Fill some crucial data structures by side effect. */
dirIndex = 0;
HFSGetDirEntry(ih, "/", &dirIndex, &name, &flags, &time, 0, 0);
/* Now we can loook up the volume name node. */
str[strMaxLen] = '\0';
}
//==============================================================================
long HFSGetFileBlock(CICell ih, char *filePath, unsigned long long *firstBlock)
long HFSGetFileBlock(CICell ih, char *filePath, u_int64_t *firstBlock)
{
char entry[512];
long dirID, result, flags =0;
long result, flags;
u_int32_t dirID;
void *extents;
HFSCatalogFile *hfsFile = (void *)entry;
HFSPlusCatalogFile *hfsPlusFile = (void *)entry;
}
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
// Skip a lead '/'. Start in the system folder if there are two.
if (filePath[0] == '/')
{
if (filePath[1] == '/')
}
#if DEBUG
printf("extent start 0x%x\n", (unsigned long)GetExtentStart(extents, 0));
printf("block size 0x%x\n", (unsigned long)gBlockSize);
printf("extent start 0x%x\n", GetExtentStart(extents, 0));
printf("block size 0x%x\n", gBlockSize);
printf("Allocation offset 0x%x\n", (unsigned long)gAllocationOffset);
#endif
*firstBlock = ((unsigned long long)GetExtentStart(extents, 0) * (unsigned long long) gBlockSize + gAllocationOffset) / 512ULL;
*firstBlock = ((u_int64_t) GetExtentStart(extents, 0) * (u_int64_t) gBlockSize + gAllocationOffset) / 512ULL;
return 0;
}
//==============================================================================
// Private Functions
static long ReadFile(void * file, uint64_t * length, void * base, uint64_t offset)
static long ReadFile(void * file, u_int64_t * length, void * base, u_int64_t offset)
{
void*extents;
longfileID;
u_int64_t fileLength;
void *extents;
HFSCatalogFile *hfsFile = file;
HFSPlusCatalogFile *hfsPlusFile = file;
u_int32_t fileID;
uint64_tfileLength;
HFSCatalogFile*hfsFile = file;
HFSPlusCatalogFile*hfsPlusFile = file;
if (gIsHFSPlus)
{
fileID = SWAP_BE32(hfsPlusFile->fileID);
//==============================================================================
static long GetCatalogEntryInfo(void * entry, long * flags, long * time, FinderInfo * finderInfo, long * infoValid)
static long GetCatalogEntryInfo(void * entry, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid)
{
long tmpTime = 0;
u_int32_t tmpTime = 0;
long valid = 0;
// Get information about the file.
switch (SWAP_BE16(*(short *)entry))
switch ( SWAP_BE16(*(short *)entry) )
{
case kHFSFolderRecord :
*flags = kFileTypeDirectory;
*flags = kFileTypeUnknown;
tmpTime = 0;
break;
default:
break;
}
if (time != 0)
return 0;
}
//==============================================================================
static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entry, long dirID, long long * dirIndex)
static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entry, u_int32_t dirID, long long * dirIndex)
{
char*restPath;
longresult, cnt, subFolderID = 0;
longresult, cnt;
u_int32_tsubFolderID = 0;
long longtmpDirIndex;
HFSPlusCatalogFile*hfsPlusFile;
return result;
}
//==============================================================================
static long GetCatalogEntry(long long * dirIndex, char ** name, long * flags, long * time, FinderInfo * finderInfo, long * infoValid)
static long GetCatalogEntry(long long * dirIndex, char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid)
{
long extentSize, nodeSize, curNode, index;
u_int64_t extentSize;
void *extent;
char *nodeBuf, *testKey, *entry;
BTNodeDescriptor *node;
u_int32_t curNode;
u_int16_t nodeSize, index;
if (gIsHFSPlus)
{
nodeBuf = (char *)malloc(nodeSize);
node = (BTNodeDescriptor *)nodeBuf;
index = (long) (*dirIndex % nodeSize);
curNode = (long) (*dirIndex / nodeSize);
index = (u_int16_t) (*dirIndex % nodeSize);
curNode = (u_int32_t) (*dirIndex / nodeSize);
// Read the BTree node and get the record for index.
ReadExtent(extent, extentSize, kHFSCatalogFileID, (long long) curNode * nodeSize, nodeSize, nodeBuf, 1);
GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &entry);
GetCatalogEntryInfo(entry, flags, time, finderInfo, infoValid);
return 0;
}
//==============================================================================
static long ReadCatalogEntry(char * fileName, long dirID, void * entry, long long * dirIndex)
static long ReadCatalogEntry(char * fileName, u_int32_t dirID, void * entry, long long * dirIndex)
{
long length = 0;
long length = strlen(fileName);
char key[sizeof(HFSPlusCatalogKey)];
HFSCatalogKey *hfsKey = (HFSCatalogKey *)key;
HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key;
// Make the catalog key.
if (gIsHFSPlus)
if ( gIsHFSPlus )
{
hfsPlusKey->parentID = SWAP_BE32(dirID);
length = strlen(fileName);
if (length > 255)
if (length > kHFSPlusMaxFileNameChars)
{
length = 255;
length = kHFSPlusMaxFileNameChars;
}
hfsPlusKey->parentID = SWAP_BE32(dirID);
utf_decodestr((u_int8_t *)fileName, hfsPlusKey->nodeName.unicode, &(hfsPlusKey->nodeName.length), 512, OSBigEndian);
}
else
{
hfsKey->parentID = SWAP_BE32(dirID);
length = strlen(fileName);
if (length > 31)
if (length > kHFSMaxFileNameChars)
{
length = 31;
length = kHFSMaxFileNameChars;
}
hfsKey->parentID = SWAP_BE32(dirID);
hfsKey->nodeName[0] = length;
strncpy((char *)(hfsKey->nodeName + 1), fileName, length);
}
return ReadBTreeEntry(kBTreeCatalog, &key, entry, dirIndex);
}
//==============================================================================
static long ReadExtentsEntry(long fileID, long startBlock, void * entry)
static long ReadExtentsEntry(u_int32_t fileID, long startBlock, void * entry)
{
char key[sizeof(HFSPlusExtentKey)];
HFSExtentKey *hfsKey = (HFSExtentKey *)key;
return ReadBTreeEntry(kBTreeExtents, &key, entry, 0);
}
//==============================================================================
static long ReadBTreeEntry(long btree, void * key, char * entry, long long * dirIndex)
{
long extentSize;
u_int64_t extentSize;
void *extent;
short extentFile;
u_int16_t extentFile;
char *nodeBuf;
BTNodeDescriptor *node;
long nodeSize, result = 0, entrySize = 0;
long curNode, index = 0, lowerBound, upperBound;
char *testKey, *recordData =0;
long result = 0, entrySize = 0;
u_int32_t curNode;
char *testKey, *recordData;
u_int16_t nodeSize, index = 0, lowerBound, upperBound;
// Figure out which tree is being looked at.
if (btree == kBTreeCatalog)
}
else
{
break;// search = trial
break;// search = trial
}
}
//==============================================================================
static void GetBTreeRecord(long index, char * nodeBuffer, long nodeSize, char ** key, char ** data)
static void GetBTreeRecord(u_int16_t index, char * nodeBuffer, u_int16_t nodeSize, char ** key, char ** data)
{
long keySize;
long recordOffset;
u_int16_t recordOffset, keySize;
recordOffset = SWAP_BE16(*((short *)(nodeBuffer + (nodeSize - 2 * index - 2))));
recordOffset = SWAP_BE16(*((u_int16_t *)(nodeBuffer + (nodeSize - 2 * index - 2))));
*key = nodeBuffer + recordOffset;
if (gIsHFSPlus)
{
keySize = SWAP_BE16(*(short *)*key);
keySize = SWAP_BE16(*(u_int16_t *)*key);
*data = *key + 2 + keySize;
}
else
//==============================================================================
static long ReadExtent(char * extent, uint64_t extentSize, long extentFile, uint64_t offset, uint64_t size, void * buffer, long cache)
static long ReadExtent(char * extent, u_int64_t extentSize, u_int32_t extentFile, u_int64_t offset, u_int64_t size, void * buffer, long cache)
{
uint64_t lastOffset;
long long blockNumber, countedBlocks = 0;
long long nextExtent = 0, sizeRead = 0, readSize;
long long nextExtentBlock, currentExtentBlock = 0;
long long readOffset;
long long extentDensity, sizeofExtent, currentExtentSize;
char *currentExtent, *extentBuffer = 0, *bufferPos = buffer;
u_int64_t lastOffset;
u_int64_t blockNumber, countedBlocks = 0;
u_int64_t nextExtent = 0, sizeRead = 0, readSize;
u_int64_t nextExtentBlock, currentExtentBlock = 0;
u_int64_t readOffset;
u_int64_t extentDensity, sizeofExtent, currentExtentSize;
char *currentExtent, *extentBuffer = 0, *bufferPos = buffer;
if (offset >= extentSize)
{
//==============================================================================
static long GetExtentStart(void * extents, long index)
static u_int32_t GetExtentStart(void * extents, u_int32_t index)
{
long start;
u_int32_t start;
HFSExtentDescriptor*hfsExtents= extents;
HFSPlusExtentDescriptor*hfsPlusExtents= extents;
return start;
}
//==============================================================================
static long GetExtentSize(void * extents, long index)
static u_int32_t GetExtentSize(void * extents, u_int32_t index)
{
long size = 0;
u_int32_t size = 0;
HFSExtentDescriptor *hfsExtents = extents;
HFSPlusExtentDescriptor *hfsPlusExtents = extents;
return size;
}
//==============================================================================
static long CompareHFSCatalogKeys(void * key, void * testKey)
return result;
}
//==============================================================================
static long CompareHFSPlusCatalogKeys(void * key, void * testKey)
return result;
}
//==============================================================================
static long CompareHFSExtentsKeys(void * key, void * testKey)
static long CompareHFSPlusExtentsKeys(void * key, void * testKey)
{
HFSPlusExtentKey *searchKey, *trialKey;
HFSPlusExtentKey*searchKey, *trialKey;
long result = -1; // assume searchKey < trialKey
longresult;
searchKey = key;
trialKey = testKey;
// assume searchKey < trialKey
result = -1;
if (searchKey->fileID == trialKey->fileID)
{
// FileNum's are equal; compare fork types
branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c
126126
127127
128128
129
130129
131130
132131
133132
134133
135134
136
135
137136
138137
139138
......
212211
213212
214213
215
214
216215
217216
218217
......
415414
416415
417416
418
417
419418
420419
421420
......
519518
520519
521520
522
521
523522
524523
525524
......
531530
532531
533532
534
533
535534
536535
537536
......
977976
978977
979978
980
979
981980
982981
983982
void *loadACPITable (const char * filename)
{
void *tableAddr;
const char * dirspec=NULL;
int fd = search_and_get_acpi_fd(filename, &dirspec);
if (fd>=0)
{
tableAddr=(void*)AllocateKernelMemory(file_size (fd));
void *tableAddr = (void*)AllocateKernelMemory(file_size (fd));
if (tableAddr)
{
if (read (fd, tableAddr, file_size (fd))!=file_size (fd))
struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt)
{
char ssdt_header[] = // cst_ssdt_header
static char ssdt_header[] = // cst_ssdt_header
{
0x53, 0x53, 0x44, 0x54, 0xE7, 0x00, 0x00, 0x00, /* SSDT.... */
0x01, 0x17, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x41, /* ..PmRefA */
struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt)
{
char ssdt_header[] = // pss_ssdt_header
static char ssdt_header[] = // pss_ssdt_header
{
0x53, 0x53, 0x44, 0x54, 0x7E, 0x00, 0x00, 0x00, /* SSDT.... */
0x01, 0x6A, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x00, /* ..PmRef. */
p_states_count = 0;
} else {
uint8_t vidstep;
uint8_t i = 0, u, invalid = 0;
uint8_t u, invalid = 0;
// Finalize P-States
// Find how many P-States machine supports
p_states_count = (uint8_t)(maximum.CID - minimum.CID + 1);
vidstep = ((maximum.VID << 2) - (minimum.VID << 2)) / (p_states_count - 1);
for (u = 0; u < p_states_count; u++) {
i = u - invalid;
uint8_t i = u - invalid;
p_states[i].CID = maximum.CID - u;
p_states[i].FID = (uint8_t)(p_states[i].CID >> 1);
rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress);
DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length);
DBG("RSDT @%x, Length %d\n",rsdt, rsdt ? rsdt->Length : 0);
if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000) {
uint32_t *rsdt_entries;
branches/ErmaC/Enoch/i386/libsaio/hfs.h
2020
2121
2222
23
24
2325
2426
25
27
2628
27
29
2830
2931
30
32
3133
3234
3335
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/types.h>
extern long HFSInitPartition(CICell ih);
extern long HFSLoadFile(CICell ih, char * filePath);
extern long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length);
extern long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length);
extern long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex,
char ** name, long * flags, long * time,
char ** name, long * flags, u_int32_t * time,
FinderInfo * finderInfo, long * infoValid);
extern void HFSGetDescription(CICell ih, char *str, long strMaxLen);
extern long HFSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock);
extern long HFSGetFileBlock(CICell ih, char *str, u_int64_t *firstBlock);
extern long HFSGetUUID(CICell ih, char *uuidStr);
extern void HFSFree(CICell ih);
extern bool HFSProbe (const void *buf);
branches/ErmaC/Enoch/i386/libsaio/bootargs.h
131131
132132
133133
134
134135
135136
136137
......
166167
167168
168169
169
170
171
172
173170
174171
175172
#define kBootArgsFlagRebootOnPanic(1 << 0)
#define kBootArgsFlagHiDPI(1 << 1)
#define kBootArgsFlagBlack(1 << 2)
typedef struct boot_args_pre_lion
{
uint16_t Revision;/* Revision of boot_args structure */
} boot_args_pre_lion;
/* Bitfields for boot_args->flags */
#define kBootArgsFlagRebootOnPanic (1 << 0)
#define kBootArgsFlagHiDPI (1 << 1)
typedef struct boot_args
{
uint16_t Revision;/* Revision of boot_args structure */
branches/ErmaC/Enoch/i386/libsaio/ufs.h
2424
2525
2626
27
27
2828
2929
3030
extern long UFSLoadFile(CICell ih, char * filePath);
extern long UFSReadFile( CICell ih, char * filePath, void * base, uint64_t offset, uint64_t length );
extern long UFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex,
char ** name, long * flags, long * time,
char ** name, long * flags, u_int32_t * time,
FinderInfo * finderInfo, long * infoValid);
extern void UFSGetDescription(CICell ih, char *str, long strMaxLen);
extern long UFSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock);
branches/ErmaC/Enoch/i386/libsaio/aml_generator.c
8585
8686
8787
88
88
8989
9090
9191
free(node);
}
AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, char* buffer, uint32_t size)
AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, const char* buffer, uint32_t size)
{
AML_CHUNK* node = aml_create_node(parent);
branches/ErmaC/Enoch/i386/libsaio/aml_generator.h
186186
187187
188188
189
189
190190
191191
192192
bool aml_add_to_parent(AML_CHUNK* parent, AML_CHUNK* node);
AML_CHUNK* aml_create_node(AML_CHUNK* parent);
void aml_destroy_node(AML_CHUNK* node);
AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, char* buffer, uint32_t size);
AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, const char* buffer, uint32_t size);
AML_CHUNK* aml_add_byte(AML_CHUNK* parent, uint8_t value);
AML_CHUNK* aml_add_word(AML_CHUNK* parent, uint16_t value);
AML_CHUNK* aml_add_dword(AML_CHUNK* parent, uint32_t value);
branches/ErmaC/Enoch/i386/libsaio/ati.c
941941
942942
943943
944
944
945
945946
946947
947948
......
953954
954955
955956
956
957
958
957959
958960
959961
......
963965
964966
965967
966
967968
968969
969970
970971
971
972
973
972974
973975
974976
idx++;
memsize = ((uint64_t)card->vram_size << 32);
if (idx == 0) {
if (idx == 0)
{
memsize = memsize | (uint64_t)card->vram_size;
}
val->type = kCst;
bool get_binimage_val(value_t *val)
{
if (!card->rom) {
if (!card->rom)
{
return false;
}
val->type = kPtr;
return true;
}
bool get_romrevision_val(value_t *val)
{
char *cRev="109-B77101-00";
uint8_t *rev;
if (!card->rom) {
if (!card->rom)
{
val->type = kPtr;
val->size = 13;
val->data = malloc(val->size);
branches/ErmaC/Enoch/i386/libsaio/sys.c
344344
345345
346346
347
347
348348
349349
350350
......
370370
371371
372372
373
373
374374
375375
376376
......
796796
797797
798798
799
799
800800
801801
802802
......
807807
808808
809809
810
810
811811
812812
813813
// Fetch the next directory entry for the given directory.
long GetDirEntry(const char * dirSpec, long long * dirIndex, const char ** name,
long * flags, long * time)
long * flags, u_int32_t * time)
{
const char * dirPath;
BVRef bvr;
static char* gMakeDirSpec;
long GetFileInfo(const char * dirSpec, const char * name,
long * flags, long * time)
long * flags, u_int32_t * time)
{
long long index = 0;
const char * entryName;
//==========================================================================
int readdir(struct dirstuff * dirp, const char ** name, long * flags,
long * time)
u_int32_t * time)
{
return dirp->dir_bvr->fs_getdirentry(dirp->dir_bvr,
/* dirPath */ dirp->dir_path,
//==========================================================================
int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags,
long * time, FinderInfo *finderInfo, long *infoValid)
u_int32_t * time, FinderInfo *finderInfo, long *infoValid)
{
return dirp->dir_bvr->fs_getdirentry( dirp->dir_bvr,
/* dirPath */ dirp->dir_path,
branches/ErmaC/Enoch/i386/libsaio/platform.h
1313
1414
1515
16
17
18
1619
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
1735
1836
1937
......
5775
5876
5977
60
61
62
63
6478
6579
6680
......
239253
240254
241255
242
243
244
245
246
247
248
249
250
251
252
253
254
255256
256257
257258
extern void scan_platform(void);
extern void dumpPhysAddr(const char * title, void * a, int len);
/* CPUID Vendor */
#define CPUID_VENDOR_INTEL 0x756E6547
#define CPUID_VENDOR_AMD 0x68747541
/* CPUID index into cpuid_raw */
#define CPUID_00
#define CPUID_11
#define CPUID_22
#define CPUID_33
#define CPUID_44
#define CPUID_55
#define CPUID_66
#define CPUID_807
#define CPUID_818
#define CPUID_889
#define CPUID_MAX10
#define CPU_MODEL_ANY0x00
#define CPU_MODEL_UNKNOWN0x01
#define CPU_MODEL_PRESCOTT0x03// Celeron D, Pentium 4 (90nm)
#define CPU_MODEL_NOCONA0x04// Xeon Nocona/Paxville, Irwindale (90nm)
#define CPU_MODEL_PRESLER0x06// Pentium 4, Pentium D (65nm)
// 5A silvermont / atom
// 5D silvermont / atom
/* CPUID Vendor */
#define CPUID_VENDOR_INTEL 0x756E6547
#define CPUID_VENDOR_AMD 0x68747541
/* Unknown CPU */
#define CPU_STRING_UNKNOWN"Unknown CPU Type"
#define bit(n)(1ULL << (n))
// DFE: This constant comes from older xnu:
#define CLKNUM1193182/* formerly 1193167 */
/* CPUID index into cpuid_raw */
#define CPUID_00
#define CPUID_11
#define CPUID_22
#define CPUID_33
#define CPUID_44
#define CPUID_55
#define CPUID_66
#define CPUID_807
#define CPUID_818
#define CPUID_889
#define CPUID_MAX10
/* CPU Features */
#define CPU_FEATURE_MMX0x00000001// MMX Instruction Set
#define CPU_FEATURE_SSE0x00000002// SSE Instruction Set
branches/ErmaC/Enoch/i386/libsaio/disk.c
760760
761761
762762
763
763
764764
765765
766766
......
10401040
10411041
10421042
1043
1043
10441044
10451045
10461046
......
10661066
10671067
10681068
1069
1069
1070
10701071
10711072
10721073
......
16471648
16481649
16491650
1650
1651
1652
16511653
16521654
16531655
(*bvr->bv_free)(bvr);
bvr = NULL;
}
if ( readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 )
else if ( readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 )
{
bvr->flags |= kBVFlagBootable;
}
* an Apple partition map elsewhere.
*/
#if UNUSED
if (map->bvrcnt == 0)
if (map && map->bvrcnt == 0)
{
static struct fdisk_part cdpart;
cdpart.systid = 0xCD;
}
#endif
// Actually this should always be true given the above code
if(map == gDiskBVMap)
// (unless malloc failed above)
if(map && map == gDiskBVMap)
{
// Don't leave a null map in the chain
if(map->bvrcnt == 0 && map->bvr == NULL)
char dirSpec[512], fileSpec[512];
char label[BVSTRLEN];
int ret;
long flags, time;
long flags;
u_int32_t time;
int fh, fileSize, error;
for (bvr = chain; bvr; bvr = bvr->next) {
branches/ErmaC/Enoch/i386/libsaio/hpet.c
242242
243243
244244
245
245246
247
246248
247249
248250
lpc_controllers_intel[i].name, lpc_dev->vendor_id, lpc_dev->device_id, rcba);
if (rcba == 0)
{
printf(" RCBA disabled; cannot force enable HPET\n");
}
else
{
val = REG32(rcba, 0x3404);
branches/ErmaC/Enoch/i386/libsaio/cache.c
4343
4444
4545
46
46
4747
4848
4949
......
6666
6767
6868
69
69
7070
7171
7272
......
113113
114114
115115
116
116
117117
118118
119119
#define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize)
static CICell gCacheIH;
static long gCacheBlockSize;
static u_int32_t gCacheBlockSize;
static long gCacheNumEntries;
static long gCacheTime;
gCacheIH = NULL;
}
void CacheInit( CICell ih, long blockSize )
void CacheInit( CICell ih, u_int32_t blockSize )
{
#ifdef __i386__
if ((ih == gCacheIH) && (blockSize == gCacheBlockSize))
bzero(gCacheEntries, kCacheMaxEntries * sizeof(CacheEntry));
}
long CacheRead(CICell ih, char * buffer, long long offset, long length, long cache)
u_int32_t CacheRead(CICell ih, char * buffer, long long offset, u_int32_t length, long cache)
{
long cnt, oldestEntry = 0, oldestTime, loadCache = 0;
CacheEntry *entry;
branches/ErmaC/Enoch/i386/libsaio/saio_types.h
153153
154154
155155
156
156
157157
158158
159159
typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length);
typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock);
typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
char ** name, long * flags, long * time,
char ** name, long * flags, u_int32_t * time,
FinderInfo * finderInfo, long * infoValid);
typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
branches/ErmaC/Enoch/i386/libsaio/msdos.c
648648
649649
650650
651
651
652652
653653
654654
}
long MSDOSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex,
char ** name, long * flags, long * time,
char ** name, long * flags, u_int32_t * time,
FinderInfo * finderInfo, long * infoValid)
{
struct msdosdirstate *st;
branches/ErmaC/Enoch/i386/libsaio/fake_efi.c
771771
772772
773773
774
774775
775776
776777
}
cpuTick = getCPUTick();// callq0x121a7
//printf("value: 0x%llx\n", getCPUTick());
rcx = (cpuTick >> 8);// mov%rax,%rcx
// shr$0x8,%rcx
rdx = (cpuTick >> 10);// mov%rax,%rdx
branches/ErmaC/Enoch/i386/libsaio/msdos.h
2525
2626
2727
28
28
2929
3030
3131
extern long MSDOSLoadFile(CICell ih, char * filePath);
extern long MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length);
extern long MSDOSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex,
char ** name, long * flags, long * time,
char ** name, long * flags, u_int32_t * time,
FinderInfo * finderInfo, long * infoValid);
extern long MSDOSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock);
extern long MSDOSGetUUID(CICell ih, char *uuidStr);
branches/ErmaC/Enoch/i386/libsaio/saio_internal.h
22
33
44
5
5
66
77
88
......
1010
1111
1212
13
13
1414
1515
1616
......
1818
1919
2020
21
21
2222
2323
2424
......
8080
8181
8282
83
84
85
83
84
85
8686
87
8887
8988
9089
......
9695
9796
9897
99
98
10099
101100
102101
......
176175
177176
178177
179
178
180179
181
180
182181
183182
184183
......
197196
198197
199198
200
199
201200
202
201
203202
204203
205204
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
*
* @APPLE_LICENSE_HEADER_END@
*/
extern void finalizeBootStruct(void);
/* cache.c */
extern voidCacheReset();
extern voidCacheInit(CICell ih, long blockSize);
extern longCacheRead(CICell ih, char *buffer, long long offset, long length, long cache);
extern void CacheReset();
extern void CacheInit(CICell ih, u_int32_t blockSize);
extern u_int32_t CacheRead(CICell ih, char *buffer, long long offset, u_int32_t length, long cache);
/* console.c */
extern bool gVerboseMode;
extern bool gErrors;
extern int printf(const char *format, ...);
extern int error(const char *format, ...);
extern int verbose(const char *format, ...);
extern void stop(const char *format, ...);
extern void stop(const char *format, ...) __attribute__ ((noreturn));
//Azi: replace getc/getchar with ? console.c
extern void pause();
extern long ReadFileAtOffset(const char * fileSpec, void *buffer, uint64_t offset, uint64_t length);
extern long LoadThinFatFile(const char *fileSpec, void **binary);
extern long GetDirEntry(const char *dirSpec, long long *dirIndex, const char **name,
long *flags, long *time);
long *flags, u_int32_t *time);
extern long GetFileInfo(const char *dirSpec, const char *name,
long *flags, long *time);
long *flags, u_int32_t *time);
extern long GetFileBlock(const char *fileSpec, unsigned long long *firstBlock);
extern long GetFSUUID(char *spec, char *uuidStr);
extern long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr);
extern struct dirstuff * opendir(const char *path);
extern struct dirstuff * vol_opendir(BVRef bvr, const char *path);
extern int closedir(struct dirstuff *dirp);
extern int readdir(struct dirstuff *dirp, const char **name, long *flags, long *time);
extern int readdir(struct dirstuff *dirp, const char **name, long *flags, u_int32_t *time);
extern int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags,
long * time, FinderInfo *finderInfo, long *infoValid);
u_int32_t * time, FinderInfo *finderInfo, long *infoValid);
extern void flushdev(void);
extern void scanBootVolumes(int biosdev, int *count);
extern void scanDisks(int biosdev, int *count);
branches/ErmaC/Enoch/i386/boot2/picopng.c
241241
242242
243243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260244
261245
262246
263
247
264248
265249
266250
267
268
251
252
253
254
269255
270
271
272
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
273271
274272
275273
......
928926
929927
930928
931
932
933
934
935
936
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
937944
938945
939946
......
949956
950957
951958
952
959
960
953961
954962
955963
956964
957965
958966
959
967
968
960969
961970
962971
......
965974
966975
967976
968
977
978
969979
970980
971981
972982
973983
974
984
985
975986
976987
977988
......
980991
981992
982993
983
994
995
984996
985997
986998
......
9891001
9901002
9911003
992
1004
1005
9931006
9941007
9951008
......
9971010
9981011
9991012
1000
1013
1014
10011015
10021016
10031017
......
10261040
10271041
10281042
1029
1043
1044
10301045
10311046
10321047
......
10381053
10391054
10401055
1041
1056
10421057
10431058
10441059
1045
1046
1047
1060
1061
1062
1063
1064
10481065
10491066
10501067
10511068
10521069
1053
1070
1071
10541072
10551073
10561074
1057
1075
1076
10581077
10591078
10601079
......
10861105
10871106
10881107
1108
10891109
10901110
10911111
......
11301150
11311151
11321152
1133
11341153
11351154
11361155
1156
1157
1158
1159
1160
1161
1162
11371163
11381164
11391165
return 1;
}
uint32_t vector8_resizev(vector8_t *p, size_t size, uint8_t value)
{// resize and give all new elements the value
size_t oldsize = p->size, i;
if (!vector8_resize(p, size))
return 0;
for (i = oldsize; i < size; i++)
p->data[i] = value;
return 1;
}
void vector8_init(vector8_t *p)
{
p->data = NULL;
p->size = p->allocsize = 0;
}
vector8_t *vector8_new(size_t size, uint8_t value)
{
vector8_t *p = png_alloc_malloc(sizeof (vector8_t));
if(!p)
if (!p)
{
return NULL;
}
vector8_init(p);
if (size && !vector8_resizev(p, size, value))
p->data = NULL;
p->size = p->allocsize = 0;
if (size)
{
vector8_cleanup(p);
png_alloc_free(p);
return NULL;
size_t i;
size_t newsize = size * sizeof (uint32_t) * 2;
void *data = png_alloc_malloc(newsize);
if (!data)
{
png_alloc_free(p);
return NULL;
}
p->data = (uint8_t *) data;
p->allocsize = newsize;
p->size = size;
for (i = 0; i < size; ++i)
{
p->data[i] = value;
}
}
return p;
}
int PNG_convert(const PNG_info_t *info, vector8_t *out, const uint8_t *in)
{// converts from any color type to 32-bit. return value = LodePNG error code
size_t i, c;
uint32_t bitDepth, colorType;
bitDepth = info->bitDepth;
colorType = info->colorType;
size_t numpixels = info->width * info->height, bp = 0;
vector8_resize(out, numpixels * 4);
uint8_t *out_data = out->size ? out->data : 0;
size_t numpixels = info->width * info->height;
if (!numpixels)
{
return 0; // nothing to do
}
if (!vector8_resize(out, numpixels * 4))
{
return 83; // out of memory
}
size_t bp = 0;
uint32_t bitDepth = info->bitDepth;
uint32_t colorType = info->colorType;
uint8_t *out_data = out->data;
if (bitDepth == 8 && colorType == 0) // greyscale
for (i = 0; i < numpixels; i++)
{
(in[3 * i + 1] == info->key_g) && (in[3 * i + 2] == info->key_b)) ? 0 : 255;
}
else if (bitDepth == 8 && colorType == 3) // indexed color (palette)
for (i = 0; i < numpixels; i++) {
for (i = 0; i < numpixels; i++)
{
if (4U * in[i] >= info->palette->size)
return 46;
for (c = 0; c < 4; c++) // get rgb colors from the palette
out_data[4 * i + c] = info->palette->data[4 * in[i] + c];
}
else if (bitDepth == 8 && colorType == 4) // greyscale with alpha
for (i = 0; i < numpixels; i++) {
for (i = 0; i < numpixels; i++)
{
out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = in[2 * i + 0];
out_data[4 * i + 3] = in[2 * i + 1];
}
for (c = 0; c < 4; c++)
out_data[4 * i + c] = in[4 * i + c]; // RGB with alpha
else if (bitDepth == 16 && colorType == 0) // greyscale
for (i = 0; i < numpixels; i++) {
for (i = 0; i < numpixels; i++)
{
out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = in[2 * i];
out_data[4 * i + 3] = (info->key_defined && (256U * in[i] + in[i + 1] == info->key_r))
? 0 : 255;
}
else if (bitDepth == 16 && colorType == 2) // RGB color
for (i = 0; i < numpixels; i++) {
for (i = 0; i < numpixels; i++)
{
for (c = 0; c < 3; c++)
out_data[4 * i + c] = in[6 * i + 2 * c];
out_data[4 * i + 3] = (info->key_defined &&
(256U * in[6 * i + 4] + in[6 * i + 5] == info->key_b)) ? 0 : 255;
}
else if (bitDepth == 16 && colorType == 4) // greyscale with alpha
for (i = 0; i < numpixels; i++) {
for (i = 0; i < numpixels; i++)
{
out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = in[4 * i]; // msb
out_data[4 * i + 3] = in[4 * i + 2];
}
for (c = 0; c < 4; c++)
out_data[4 * i + c] = in[8 * i + 2 * c]; // RGB with alpha
else if (bitDepth < 8 && colorType == 0) // greyscale
for (i = 0; i < numpixels; i++) {
for (i = 0; i < numpixels; i++)
{
uint32_t value = (PNG_readBitsFromReversedStream(&bp, in, bitDepth) * 255) /
((1 << bitDepth) - 1); // scale value from 0 to 255
out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = (uint8_t) value;
(((1U << bitDepth) - 1U) == info->key_r) && ((1U << bitDepth) - 1U)) ? 0 : 255;
}
else if (bitDepth < 8 && colorType == 3) // palette
for (i = 0; i < numpixels; i++) {
for (i = 0; i < numpixels; i++)
{
uint32_t value = PNG_readBitsFromReversedStream(&bp, in, bitDepth);
if (4 * value >= info->palette->size)
return 47;
{
PNG_info_t *info;
PNG_error = 0;
if (size == 0 || in == 0) {
if (size == 0 || in == 0)
{
PNG_error = 48; // the given data is empty
return NULL;
}
}
size_t pos = 33; // first byte of the first chunk after the header
vector8_t *idat = NULL; // the data from idat chunks
bool IEND = false, known_type = true;
bool IEND = false;
info->key_defined = false;
// loop through the chunks, ignoring unknown chunks and stopping at IEND chunk. IDAT data is
// put at the start of the in buffer
while (!IEND) {
size_t i, j;
if (pos + 8 >= size) {
while (!IEND)
{
size_t i;
if (pos + 8 >= size)
{
PNG_error = 30; // error: size of the in buffer too small to contain next chunk
return NULL;
}
size_t chunkLength = PNG_read32bitInt(&in[pos]);
pos += 4;
if (chunkLength > 0x7fffffff) {
if (chunkLength > 0x7fffffff)
{
PNG_error = 63;
return NULL;
}
if (pos + chunkLength >= size) {
if (pos + chunkLength >= size)
{
PNG_error = 35; // error: size of the in buffer too small to contain next chunk
return NULL;
}
return NULL;
}
for (i = 0; i < info->palette->size; i += 4) {
size_t j;
for (j = 0; j < 3; j++)
info->palette->data[i + j] = in[pos++]; // RGB
info->palette->data[i + 3] = 255; // alpha
return NULL;
}
pos += (chunkLength + 4); // skip 4 letters and uninterpreted data of unimplemented chunk
known_type = false;
}
pos += 4; // step over CRC (which is ignored)
}
if (!idat)
{
PNG_error = 1; // no data seen
return NULL;
}
uint32_t bpp = PNG_getBpp(info);
vector8_t *scanlines; // now the out buffer will be filled
scanlines = vector8_new(((info->width * (info->height * bpp + 7)) / 8) + info->height, 0);
branches/ErmaC/Enoch/i386/boot2/graphics.c
12651265
12661266
12671267
1268
12681269
12691270
12701271
//==========================================================================
// Display and clear the activity indicator.
// BASIC Indicator
static char indicator[] = {'-', '\\', '|', '/', '-', '\\', '|', '/', '\0'};
// Bouncing ball .oOo.
branches/ErmaC/Enoch/i386/boot2/drivers.c
279279
280280
281281
282
283
282
283
284
284285
285286
286287
......
310311
311312
312313
313
314
315
316
314
315
316
317
318
317319
318320
319321
static long FileLoadMKext( const char * dirSpec, const char * extDirSpec )
{
longret, flags, time, time2;
charaltDirSpec[512];
longret, flags;
u_int32_ttime, time2;
charaltDirSpec[512];
snprintf(altDirSpec, sizeof(altDirSpec), "%s%s", dirSpec, extDirSpec);
ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time);
long FileLoadDrivers( char * dirSpec, long plugin )
{
long ret, length, flags, time, bundleType;
long long index;
long result = -1;
const char * name;
long longindex;
longret, length, flags, bundleType;
longresult = -1;
u_int32_ttime;
const char* name;
if ( !plugin )
{
branches/ErmaC/Enoch/i386/boot2/boot.c
242242
243243
244244
245
245
246246
247
247248
248249
249250
......
273274
274275
275276
276
277
277
278
278279
279280
280281
......
524525
525526
526527
527
528
529
528530
529531
530
532
531533
532534
533535
......
710712
711713
712714
713
715
714716
715717
716718
......
828830
829831
830832
831
833
834
832835
833836
834837
{
charkernelCacheFile[512];
charkernelCachePath[512];
longflags, time, cachetime, kerneltime, exttime, ret=-1;
longflags, ret=-1;
unsigned long adler32;
u_int32_t time, cachetime, kerneltime, exttime;
if((gBootMode & kBootModeSafe) != 0)
{
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char*name;
longprev_time = 0;
char *name;
u_int32_t prev_time = 0;
structdirstuff* cacheDir = opendir(kDefaultCachePathSnow);
booluseKernelCache = true; // by default try to use the prelinked kernel
const char*val;
intlen, ret = -1;
longflags, sleeptime, time;
longflags;
u_int32_tsleeptime, time;
void*binary = (void *)kLoadAddr;
char bootFile[sizeof(bootInfo->bootFile)];
charbootFile[sizeof(bootInfo->bootFile)];
charbootFilePath[512];
charkernelCacheFile[512];
// bootFile must start with a / if it not start with a device name
if (!bootFileWithDevice && (bootInfo->bootFile)[0] != '/')
{
if (!YOSEMITE)
if ( !YOSEMITE )
{
//printf(HEADER " (%s).\n", bootInfo->bootFile);
snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading /
bool checkOSVersion(const char * version)
{
if ( (sizeof(version) > 4) && (version[3] == '1') ) {
if ( (sizeof(version) > 4) && ('.' != version[4]) && ('\0' != version[4]) )
{
return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1])
&& (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3])
&& (gMacOSVersion[4] == version[4]));
branches/ErmaC/Enoch/i386/boot2/modules.c
103103
104104
105105
106
106
107107
108108
109109
{
char* name;
long flags;
long time;
u_int32_t time;
struct dirstuff* moduleDir = opendir("/Extra/modules/");
if(!moduleDir)
{
branches/ErmaC/Enoch/i386/boot2/bmdecompress.c
4242
4343
4444
45
45
46
4647
4748
4849
......
5455
5556
5657
57
58
59
5860
5961
6062
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
if (!sc0 || !sc1 || !sc2 || !sc3) {
if (!sc0 || !sc1 || !sc2 || !sc3)
{
return;
}
bzero(sc3, (width+2) * sizeof(uint16_t));
uint32_t tmp1, tmp2, out;
for (j = 0; j < (height + 2); j++) {
for (j = 0; j < (height + 2); j++)
{
input = compressBuffer;
if (j < height)
branches/ErmaC/Enoch/i386/boot2/gui.c
10091009
10101010
10111011
1012
10131012
1014
10151013
10161014
10171015
{
case kPartitionTypeHFS:
{
// ErmaC : TODO test needed for recovery icon
// Use HFSRECOVERY icon.
//if (device->flags & kBVFlagBooter)
//{
branches/ErmaC/Enoch/i386/modules/AcpiCodec/acpi_codec.c
47434743
47444744
47454745
4746
4747
4748
4746
4747
4748
4749
47494750
4750
4751
4752
4751
4752
4753
47534754
47544755
47554756
......
50775078
50785079
50795080
5080
5081
5082
5083
50815084
50825085
50835086
......
51585161
51595162
51605163
5161
5164
5165
5166
51625167
51635168
51645169
}
{
long ret, length, flags, time;
long long index = 0;
const char * name;
long longindex = 0;
longret, length, flags;
u_int32_ttime;
const char* name;
U8 i = 0;
char dirspec[512];
bool acpidir_found = false;
U8 i = 0;
char dirspec[512];
bool acpidir_found = false;
ret = GetFileInfo("rd(0,0)/Extra/", "Acpi", &flags, &time);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory))
MadtPointer = (ACPI_TABLE_MADT *)madt_file;
}
} else {
}
else
{
MadtPointer = (acpi_tables.MadtPointer64 != (void*)0ul) ? (ACPI_TABLE_MADT *)acpi_tables.MadtPointer64 : (ACPI_TABLE_MADT *)acpi_tables.MadtPointer;
}
/* XXX aserebln why uint32 cast if pointer is uint64 ? */
rsd_p = (U32)rsdp_mod;
addConfigurationTable(&gEfiAcpi20TableGuid, &rsd_p, "ACPI_20");
} else {
}
else
{
/* XXX aserebln why uint32 cast if pointer is uint64 ? */
rsd_p = (U32)rsdp_mod;
addConfigurationTable(&gEfiAcpiTableGuid, &rsd_p, "ACPI");
branches/ErmaC/Enoch/i386/libsa/zalloc.c
157157
158158
159159
160
160
161
161162
162163
163164
#endif
done:
if ((ret == 0) || (ret + size >= zalloc_end)) {
if ((ret == 0) || (ret + size >= zalloc_end))
{
if (zerror)
{
(*zerror)(ret, size, file, line);
branches/ErmaC/Enoch/i386/libsa/string.c
166166
167167
168168
169
169170
171
172
170173
174
171175
176
172177
173178
174179
return 0;
do {
if (*s1 != *s2++)
{
return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1));
}
if (!*s1++)
{
break;
}
} while (--n);
return 0;
}
branches/ErmaC/Enoch/package/buildpkg.sh
173173
174174
175175
176
176177
177
178
179
178
179
180
181
182
183
180184
181185
182186
$chameleonSubsts
$ownSubst"
# HACK: Don't try to substitute in TIFF files!
for file in "$@";do
cp -pf "$file" "${file}.in"
sed "$allSubst" "${file}.in" > "${file}"
rm -f "${file}.in"
if [ -z `echo "$file" | grep tiff` ]
then
cp -pf "$file" "${file}.in"
sed "$allSubst" "${file}.in" > "${file}"
rm -f "${file}.in"
fi
done
}
branches/ErmaC/Enoch/CHANGES
1
2
3
4
5
6
7
8
19
210
311
- bitshoveler : Make 'buffer' arg to aml_add_buffer 'const char *', was just 'char *' (aml_generator)
- bitshoveler : Fix "sed: RE error: illegal byte sequence", which turns out to be from feeding sed a TIFF file (buildpkg.sh)
- bitshoveler : Remove "-x" option from "ld" command which breaks build under newer Xcode versions (MakeInc.dir)
- bitshoveler : CacheInit(), CacheRead() prototypes: use u_int32_t instead of long where appropriate (saio_internal.h)
- bitshoveler : Improved defensiveness against malloc failure (disk.c)
- bitshoveler : Use u_int32_t instead of long where appropriate (cache.c)
- bitshoveler : Make some constant arrays static; other minor fixes (acpi_patcher.c)
- bitshoveler : Various fixes to problems exposed by Clang static analyzer (picopng.c)
- bitshoveler : Remove "-x" option from "ld" command which breaks build under newer Xcode versions (/i386/modules/MakeInc.dir)
- bitshoveler : Comment out some unused functions by expanding "#if UNUSED" conditional (stringTable.c)
- bitshoveler : Comment out unused static functions, which cause build to fail in "release" mode (vbe.c)

Archive Download the corresponding diff file

Revision: 2458