Chameleon

Chameleon Commit Details

Date:2012-04-30 17:01:21 (8 years 7 months ago)
Author:armel cadet-petit
Commit:1929
Parents: 1928
Message:minor bug fixes
Changes:
M/branches/cparm/i386/libsaio/modules.h
M/branches/cparm/i386/modules/HibernateEnabler/graphic_utils.c
M/branches/cparm/i386/libsaio/device_tree.c
M/branches/cparm/i386/libsaio/hfs.c
M/branches/cparm/i386/modules/ACPICodec/acpidecode.c
M/branches/cparm/i386/boot2/drivers.c
M/branches/cparm/i386/MakeInc.dir
M/branches/cparm/xcode3_sym.zip
M/branches/cparm/i386/boot2/mboot.c
M/branches/cparm/i386/util/amlsgn.m
M/branches/cparm/i386/libsaio/fake_efi.c
M/branches/cparm/i386/libsaio/disk.c
M/branches/cparm/i386/libsaio/acpi_tools.c
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/i386/boot2/Makefile
M/branches/cparm/i386/libsa/strtol.c
M/branches/cparm/i386/libsaio/xml.c
M/branches/cparm/i386/modules/GUI/GUI_module.c
M/branches/cparm/i386/boot2/graphics.c
M/branches/cparm/i386/libsaio/xml.h
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/modules/GUI/graphic_utils.c
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.c
M/branches/cparm/TODO
M/branches/cparm/i386/modules/GUI/picopng.c

File differences

branches/cparm/TODO
66
77
88
9
10
911
1012
1113
- Implement the bundles
- Backport cconfig from the trunk
- move winfs, bsdfs, ext2fs, befs and lspci into modules
- Implement a pool allocator, so each module will run and allocate memory in there own pool, de-alloc all allocated memory by the module,
will be done simply by destroying the pool
branches/cparm/i386/libsaio/xml.c
148148
149149
150150
151
151
152152
153153
154154
......
443443
444444
445445
446
447
446448
447449
448450
......
652654
653655
654656
655
657
656658
657659
658660
661
662
659663
660664
661665
......
674678
675679
676680
677
678
679
680
681
681682
682683
683684
&& (dict->type != kTagTypeArray)// If we are an array, any element is valid
) continue;
if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->string);
//if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->string);
count++;
}
int integer = (int)GetRefString(id);
TagPtr tmpTag = NewTag();
if (tmpTag == 0) return -1;
tmpTag->type = kTagTypeInteger;
tmpTag->string = (char*) integer;
tmpTag->tag = 0;
{
long length, integer;
bool negative = false;
TagPtr tmpTag = 0;
TagPtr tmpTag;
char* val = buffer;
int size;
tmpTag = NewTag();
if (tmpTag == 0) return -1;
if(buffer[0] == '<')
{
size = length = FixDataMatchingTag(buffer, kXMLTagInteger);
if (length == -1) return -1;
tmpTag = NewTag();
if (tmpTag == 0) return -1;
integer = 0;
if(size > 1 && (val[1] == 'x' || val[1] == 'X'))// Hex value
branches/cparm/i386/libsaio/xml.h
6464
6565
6666
67
68
69
70
71
72
67
68
69
70
71
72
73
74
75
7376
77
78
79
80
81
82
83
84
85
7486
7587
7688
#define kXMLStringIDRef "IDREF="
#define kPropCFBundleIdentifier ("CFBundleIdentifier")
#define kPropCFBundleExecutable ("CFBundleExecutable")
#define kPropOSBundleRequired ("OSBundleRequired")
#define kPropOSBundleLibraries ("OSBundleLibraries")
#define kPropIOKitPersonalities ("IOKitPersonalities")
#define kPropIONameMatch ("IONameMatch")
#define kPropCFBundleIdentifier ("CFBundleIdentifier")
#define kPropCFBundleExecutable ("CFBundleExecutable")
#define kPropOSBundleRequired ("OSBundleRequired")
#define kPropOSBundleLibraries ("OSBundleLibraries")
#define kPropOSBundlePriority ("OSBundlePriority")
#define kPropOSBundleEnabled ("OSBundleEnabled")
#define kPropIOKitPersonalities ("IOKitPersonalities")
#define kPropIONameMatch ("IONameMatch")
#define kPropCFBundleGetInfoString ("CFBundleGetInfoString")
#define kPropNSHumanReadableCopyright ("NSHumanReadableCopyright")
#define kPropCFBundleShortVersionString ("CFBundleShortVersionString")
#define kPropCFBundleIconFile ("CFBundleIconFile")
#define kPropCFBundleVersion ("CFBundleVersion")
#define kPropCFBundlePackageType ("CFBundlePackageType")
#define kPropCFBundleName ("CFBundleName")
#define kPropNSPrincipalClass ("NSPrincipalClass")
#define kPropIOClass ("IOClass")
#define kPropIOProviderClass ("IOProviderClass")
#define DEFAULT_BOOT_CONFIG_DICT (TagPtr)0
#define DEFAULT_SYSTEM_CONFIG_DICT (TagPtr)1
branches/cparm/i386/libsaio/device_tree.c
320320
321321
322322
323
323
324324
325325
326326
......
352352
353353
354354
355
355
356356
357
357
358358
359
359
360
361
362
360363
361364
362365
Node *
DT__FindNode(const char *path, bool createIfMissing)
{
Node *node, *child;
Node *node, *child = 0;
DTPropertyNameBuf nameBuf;
char *bp;
int i;
}
if (child == 0 && createIfMissing) {
DPRINTF("Creating node\n");
char *str = malloc(strlen(nameBuf) + 1);
//char *str = malloc(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
//strcpy(str, nameBuf);
child = DT__AddChild(node, str);
const char *str = newString(nameBuf);
if (str) {
child = DT__AddChild(node, str);
}
}
node = child;
}
branches/cparm/i386/libsaio/hfs.c
8383
8484
8585
86
86
8787
8888
8989
9090
9191
92
92
9393
9494
9595
9696
97
97
9898
9999
100
100
101101
102102
103103
......
146146
147147
148148
149
149
150150
151151
152152
153153
154154
155155
156
156
157157
158158
159159
......
169169
170170
171171
172
172
173173
174174
175175
176176
177177
178
178
179179
180180
181181
182
182
183183
184184
185
185
186186
187187
188188
189189
190190
191191
192
192
193193
194194
195
195
196196
197197
198198
199199
200200
201201
202
202
203203
204
205
204
205
206206
207207
208208
209209
210210
211
211
212212
213213
214
214
215215
216216
217
217
218218
219
219
220220
221221
222222
223
223
224224
225225
226226
227
227
228228
229
229
230230
231
231
232232
233233
234234
235235
236
236
237237
238238
239239
240240
241
241
242242
243243
244244
245245
246
246
247247
248248
249
249
250250
251
252
251
252
253253
254254
255255
256256
257257
258
258
259259
260260
261261
......
268268
269269
270270
271
272
271
272
273273
274274
275275
......
279279
280280
281281
282
283
282
283
284284
285285
286286
287287
288
288
289289
290290
291
291
292292
293
293
294294
295295
296296
297297
298298
299
299
300300
301301
302
302
303303
304
304
305305
306306
307307
......
319319
320320
321321
322
323
322
323
324324
325
325
326326
327
327
328328
329329
330330
......
336336
337337
338338
339
339
340340
341341
342342
343343
344344
345
345
346346
347347
348348
349
349
350350
351351
352352
353353
354354
355355
356
356
357357
358358
359359
360360
361
362
361
362
363363
364
364
365365
366366
367367
368
368
369369
370370
371371
372
372
373373
374
374
375375
376
376
377377
378378
379379
......
383383
384384
385385
386
386
387387
388388
389389
390
390
391391
392
392
393393
394394
395395
......
397397
398398
399399
400
401
400
401
402402
403403
404404
405405
406
406
407407
408408
409409
410
410
411411
412
412
413413
414414
415415
416416
417417
418
418
419419
420420
421421
......
429429
430430
431431
432
432
433433
434434
435435
......
442442
443443
444444
445
445
446446
447447
448448
......
452452
453453
454454
455
455
456456
457457
458458
459459
460
460
461461
462462
463463
464
465
466
467
468
469
464
465
466
467
468
469
470470
471471
472
472
473473
474474
475475
......
478478
479479
480480
481
481
482482
483483
484484
......
487487
488488
489489
490
490
491491
492492
493
493
494494
495495
496496
497497
498
498
499499
500500
501501
......
504504
505505
506506
507
507
508508
509509
510
510
511511
512512
513513
......
516516
517517
518518
519
519
520520
521521
522522
......
527527
528528
529529
530
530
531531
532532
533533
534534
535535
536
536
537537
538538
539539
......
544544
545545
546546
547
547
548548
549549
550550
551551
552
552
553553
554554
555555
556
556
557557
558558
559
559
560560
561561
562
562
563563
564
564
565565
566
566
567567
568568
569569
570570
571571
572572
573
573
574574
575575
576576
577
577
578578
579579
580580
581581
582
583
584
585
582
583
584
585
586586
587587
588
588
589589
590590
591591
......
597597
598598
599599
600
600
601601
602602
603603
......
605605
606606
607607
608
608
609609
610610
611611
612
612
613613
614614
615
615
616616
617617
618618
619619
620
620
621621
622
622
623623
624624
625625
......
628628
629629
630630
631
631
632632
633633
634634
635
635
636636
637637
638638
......
640640
641641
642642
643
643
644644
645
645
646646
647647
648648
......
653653
654654
655655
656
656
657657
658658
659659
......
669669
670670
671671
672
672
673673
674674
675675
......
678678
679679
680680
681
681
682682
683683
684684
......
689689
690690
691691
692
692
693693
694694
695695
......
703703
704704
705705
706
706
707707
708708
709709
......
724724
725725
726726
727
727
728728
729729
730730
......
733733
734734
735735
736
736
737737
738738
739
739
740740
741741
742742
743743
744
744
745745
746746
747747
748748
749
749
750750
751751
752752
753753
754754
755
755
756756
757
757
758758
759759
760760
......
768768
769769
770770
771
771
772772
773773
774774
775775
776
776
777777
778778
779779
780780
781781
782782
783
783
784784
785785
786786
787787
788788
789
789
790790
791791
792
792
793793
794794
795795
......
806806
807807
808808
809
809
810810
811
811
812812
813813
814814
......
818818
819819
820820
821
821
822822
823
823
824824
825825
826826
......
829829
830830
831831
832
832
833833
834834
835835
......
852852
853853
854854
855
855
856856
857
857
858858
859859
860860
......
862862
863863
864864
865
865
866866
867867
868868
869
869
870870
871871
872872
......
874874
875875
876876
877
877
878878
879879
880880
881
881
882882
883883
884884
885885
886
886
887887
888888
889889
890890
891891
892
892
893893
894
894
895895
896896
897897
898898
899
899
900900
901901
902
902
903903
904
905
904
905
906906
907907
908908
909
909
910910
911
911
912912
913913
914
914
915915
916916
917917
918918
919
919
920920
921
921
922922
923923
924924
......
927927
928928
929929
930
930
931931
932932
933
933
934934
935935
936936
......
939939
940940
941941
942
942
943943
944944
945
945
946946
947947
948948
......
950950
951951
952952
953
953
954954
955955
956
956
957957
958958
959
959
960960
961961
962962
......
964964
965965
966966
967
967
968968
969969
970970
......
972972
973973
974974
975
975
976976
977977
978
978
979979
980980
981
981
982982
983983
984984
......
987987
988988
989989
990
991
992
993
994
995
996
997
998
999
1000
990
991
992
993
994
995
996
997
998
999
1000
10011001
1002
1002
10031003
10041004
10051005
......
10071007
10081008
10091009
1010
1010
10111011
10121012
1013
1013
10141014
10151015
1016
1016
10171017
10181018
10191019
......
10351035
10361036
10371037
1038
1038
10391039
10401040
10411041
......
10431043
10441044
10451045
1046
1046
10471047
10481048
1049
1049
10501050
10511051
1052
1052
10531053
10541054
10551055
......
10711071
10721072
10731073
1074
1074
10751075
10761076
10771077
static long GetCatalogEntryInfo(void *entry, long *flags, long *time,
FinderInfo *finderInfo, long *infoValid);
static long ResolvePathToCatalogEntry(char *filePath, long *flags,
void *entry, long dirID, long long *dirIndex);
void *entry, long dirID, long long *dirIndex);
static long GetCatalogEntry(long long *dirIndex, char **name,
long *flags, long *time,
FinderInfo *finderInfo, long *infoValid);
static long ReadCatalogEntry(char *fileName, long dirID, void *entry,
long long *dirIndex);
long long *dirIndex);
static long ReadExtentsEntry(long 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,
char **key, char **data);
char **key, char **data);
static long ReadExtent(char *extent, uint64_t extentSize, long extentFile,
uint64_t offset, uint64_t size, void *buffer, long cache);
uint64_t offset, uint64_t size, void *buffer, long cache);
static long GetExtentStart(void *extents, long index);
static long GetExtentSize(void *extents, long index);
{
long extentSize, extentFile, nodeSize;
void *extent;
if (ih == gCurrentIH) {
#ifdef __i386__
CacheInit(ih, gCacheBlockSize);
#endif
return 0;
}
#ifdef __i386__
if (!gTempStr) gTempStr = (char *)malloc(4096);
if (!gLinkTemp) gLinkTemp = (char *)malloc(64);
if (!gTempStr || !gLinkTemp || !gBTreeHeaderBuffer ||
!gHFSMdbVib || !gHFSPlusHeader) return -1;
#endif /* __i386__ */
gAllocationOffset = 0;
gIsHFSPlus = 0;
gCaseSensitive = 0;
gBTHeaders[0] = 0;
gBTHeaders[1] = 0;
// Look for the HFS MDB
Seek(ih, kMDBBaseOffset);
Read(ih, (long)gHFSMdbVib, kBlockSize);
if ( SWAP_BE16(gHFSMDB->drSigWord) == kHFSSigWord ) {
gAllocationOffset = SWAP_BE16(gHFSMDB->drAlBlSt) * kBlockSize;
// See if it is HFSPlus
if (SWAP_BE16(gHFSMDB->drEmbedSigWord) != kHFSPlusSigWord) {
// Normal HFS;
gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSMDB->drAlBlkSiz);
CacheInit(ih, gCacheBlockSize);
gCurrentIH = ih;
// grab the 64 bit volume ID
bcopy(&gHFSMDB->drFndrInfo[6], &gVolID, 8);
// Get the Catalog BTree node size.
extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec;
extentSize = SWAP_BE32(gHFSMDB->drCTFlSize);
extentFile = kHFSCatalogFileID;
ReadExtent(extent, extentSize, extentFile, 0, 256,
gBTreeHeaderBuffer + kBTreeCatalog * 256, 0);
nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 +
sizeof(BTNodeDescriptor)))->nodeSize);
sizeof(BTNodeDescriptor)))->nodeSize);
// If the BTree node size is larger than the block size, reset the cache.
if (nodeSize > gBlockSize) {
gCacheBlockSize = nodeSize;
CacheInit(ih, gCacheBlockSize);
}
return 0;
}
// Calculate the offset to the embeded HFSPlus volume.
gAllocationOffset += (long long)SWAP_BE16(gHFSMDB->drEmbedExtent.startBlock) *
SWAP_BE32(gHFSMDB->drAlBlkSiz);
SWAP_BE32(gHFSMDB->drAlBlkSiz);
}
// Look for the HFSPlus Header
Seek(ih, gAllocationOffset + kMDBBaseOffset);
Read(ih, (long)gHFSPlusHeader, kBlockSize);
// Not a HFS+ or HFSX volume.
if (SWAP_BE16(gHFSPlus->signature) != kHFSPlusSigWord &&
SWAP_BE16(gHFSPlus->signature) != kHFSXSigWord) {
verbose("HFS signature was not present.\n");
verbose("HFS signature was not present.\n");
gCurrentIH = 0;
return -1;
return -1;
}
gIsHFSPlus = 1;
gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSPlus->blockSize);
CacheInit(ih, gCacheBlockSize);
gCurrentIH = ih;
ih->modTime = SWAP_BE32(gHFSPlus->modifyDate) - 2082844800;
// grab the 64 bit volume ID
bcopy(&gHFSPlus->finderInfo[24], &gVolID, 8);
// Get the Catalog BTree node size.
extent = &gHFSPlus->catalogFile.extents;
extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize);
extentFile = kHFSCatalogFileID;
ReadExtent(extent, extentSize, extentFile, 0, 256,
gBTreeHeaderBuffer + kBTreeCatalog * 256, 0);
nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 +
sizeof(BTNodeDescriptor)))->nodeSize);
sizeof(BTNodeDescriptor)))->nodeSize);
// If the BTree node size is larger than the block size, reset the cache.
if (nodeSize > gBlockSize) {
gCacheBlockSize = nodeSize;
CacheInit(ih, gCacheBlockSize);
}
return 0;
}
{
char entry[512];
char devStr[12];
long dirID, result, flags;
long dirID, result, flags = 0;
if (HFSInitPartition(ih) == -1) return -1;
dirID = kHFSRootFolderID;
if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
else dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]);
if (dirID == 0) {
return -1;
}
return -1;
}
filePath++;
}
filePath++;
}
result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0);
if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
return -1;
return -1;
}
#if UNUSED
// Not yet for Intel. System.config/Default.table will fail this check.
// Check file owner and permissions.
if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite)) return -1;
#endif
result = ReadFile(entry, &length, base, offset);
if (result == -1) {
return -1;
return -1;
}
getDeviceDescription(ih, devStr);
if (HFSLoadVerbose) {
FinderInfo * finderInfo, long * infoValid)
{
char entry[512];
long dirID, dirFlags;
long dirID, dirFlags = 0;
if (HFSInitPartition(ih) == -1) return -1;
if (*dirIndex == -1) return -1;
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
if (dirPath[0] == '/') {
}
dirPath++;
}
if (*dirIndex == 0) {
ResolvePathToCatalogEntry(dirPath, &dirFlags, entry, dirID, dirIndex);
if (*dirIndex == 0) *dirIndex = -1;
if ((dirFlags & kFileTypeMask) != kFileTypeUnknown) return -1;
}
GetCatalogEntry(dirIndex, name, flags, time, finderInfo, infoValid);
if (*dirIndex == 0) *dirIndex = -1;
if ((*flags & kFileTypeMask) == kFileTypeUnknown) return -1;
return 0;
}
void
HFSGetDescription(CICell ih, char *str, long strMaxLen)
{
UInt16 nodeSize;
UInt32 firstLeafNode;
long long dirIndex;
char *name;
long flags, time;
long flags = 0, time;
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. */
nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize);
firstLeafNode = SWAP_BE32(gBTHeaders[kBTreeCatalog]->firstLeafNode);
dirIndex = (long long) firstLeafNode * nodeSize;
GetCatalogEntry(&dirIndex, &name, &flags, &time, 0, 0);
strncpy(str, name, strMaxLen);
str[strMaxLen] = '\0';
}
HFSGetFileBlock(CICell ih, char *filePath, unsigned long long *firstBlock)
{
char entry[512];
long dirID, result, flags;
long dirID, result, flags = 0;
void *extents;
HFSCatalogFile *hfsFile = (void *)entry;
HFSPlusCatalogFile *hfsPlusFile = (void *)entry;
if (HFSInitPartition(ih) == -1) return -1;
dirID = kHFSRootFolderID;
// Skip a lead '\'. Start in the system folder if there are two.
if (filePath[0] == '/') {
if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
else dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]);
if (dirID == 0) {
return -1;
}
return -1;
}
filePath++;
}
filePath++;
}
result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0);
if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
printf("HFS: Resolve path %s failed\n", filePath);
return -1;
return -1;
}
if (gIsHFSPlus) {
extents = &hfsPlusFile->dataFork.extents;
} else {
extents = &hfsFile->dataExtents;
}
#if DEBUG
printf("extent start 0x%x\n", (unsigned long)GetExtentStart(extents, 0));
printf("block size 0x%x\n", (unsigned long)gBlockSize);
{
if (HFSInitPartition(ih) == -1) return -1;
if (gVolID == 0LL) return -1;
return CreateUUIDString((uint8_t*)(&gVolID), sizeof(gVolID), uuidStr);
}
uint64_t fileLength;
HFSCatalogFile *hfsFile = file;
HFSPlusCatalogFile *hfsPlusFile = file;
if (gIsHFSPlus) {
fileID = SWAP_BE32(hfsPlusFile->fileID);
fileLength = (uint64_t)SWAP_BE64(hfsPlusFile->dataFork.logicalSize);
fileLength = SWAP_BE32(hfsFile->dataLogicalSize);
extents = &hfsFile->dataExtents;
}
if (offset > fileLength) {
printf("Offset is too large.\n");
return -1;
}
if ((*length == 0) || ((offset + *length) > fileLength)) {
*length = fileLength - offset;
}
/* if (*length > kLoadSize) {
printf("File is too large.\n");
return -1;
}*/
/* if (*length > kLoadSize) {
printf("File is too large.\n");
return -1;
}*/
*length = ReadExtent((char *)extents, fileLength, fileID,
offset, *length, (char *)base, 0);
return 0;
}
{
long tmpTime = 0;
long valid = 0;
// Get information about the file.
switch ( SWAP_BE16(*(short *)entry) )
*flags = kFileTypeDirectory;
tmpTime = SWAP_BE32(((HFSCatalogFolder *)entry)->modifyDate);
break;
case kHFSPlusFolderRecord :
*flags = kFileTypeDirectory |
(SWAP_BE16(((HFSPlusCatalogFolder *)entry)->bsdInfo.fileMode) & kPermMask);
(SWAP_BE16(((HFSPlusCatalogFolder *)entry)->bsdInfo.fileMode) & kPermMask);
if (SWAP_BE32(((HFSPlusCatalogFolder *)entry)->bsdInfo.ownerID) != 0)
*flags |= kOwnerNotRoot;
tmpTime = SWAP_BE32(((HFSPlusCatalogFolder *)entry)->contentModDate);
break;
case kHFSFileRecord :
*flags = kFileTypeFlat;
tmpTime = SWAP_BE32(((HFSCatalogFile *)entry)->modifyDate);
valid = 1;
}
break;
case kHFSPlusFileRecord :
*flags = kFileTypeFlat |
(SWAP_BE16(((HFSPlusCatalogFile *)entry)->bsdInfo.fileMode) & kPermMask);
(SWAP_BE16(((HFSPlusCatalogFile *)entry)->bsdInfo.fileMode) & kPermMask);
if (SWAP_BE32(((HFSPlusCatalogFile *)entry)->bsdInfo.ownerID) != 0)
*flags |= kOwnerNotRoot;
tmpTime = SWAP_BE32(((HFSPlusCatalogFile *)entry)->contentModDate);
valid = 1;
}
break;
case kHFSFileThreadRecord :
case kHFSPlusFileThreadRecord :
case kHFSFolderThreadRecord :
default:
break;
}
if (time != 0) {
// Convert base time from 1904 to 1970.
*time = tmpTime - 2082844800;
}
if (infoValid) *infoValid = valid;
return 0;
}
long result, cnt, subFolderID = 0;
long long tmpDirIndex;
HFSPlusCatalogFile *hfsPlusFile;
// Copy the file name to gTempStr
cnt = 0;
while ((filePath[cnt] != '/') && (filePath[cnt] != '\0')) cnt++;
strlcpy(gTempStr, filePath, cnt+1);
// Move restPath to the right place.
if (filePath[cnt] != '\0') cnt++;
restPath = filePath + cnt;
// gTempStr is a name in the current Dir.
// restPath is the rest of the path if any.
result = ReadCatalogEntry(gTempStr, dirID, entry, dirIndex);
if (result == -1) {
return -1;
return -1;
}
GetCatalogEntryInfo(entry, flags, 0, 0, 0);
if ((*flags & kFileTypeMask) == kFileTypeDirectory) {
if (gIsHFSPlus)
subFolderID = SWAP_BE32(((HFSPlusCatalogFolder *)entry)->folderID);
else
subFolderID = SWAP_BE32(((HFSCatalogFolder *)entry)->folderID);
}
if ((*flags & kFileTypeMask) == kFileTypeDirectory)
result = ResolvePathToCatalogEntry(restPath, flags, entry,
subFolderID, dirIndex);
if (gIsHFSPlus && ((*flags & kFileTypeMask) == kFileTypeFlat)) {
hfsPlusFile = (HFSPlusCatalogFile *)entry;
if ((SWAP_BE32(hfsPlusFile->userInfo.fdType) == kHardLinkFileType) &&
(SWAP_BE32(hfsPlusFile->userInfo.fdCreator) == kHFSPlusCreator)) {
sprintf(gLinkTemp, "%s/%s%ld", HFSPLUSMETADATAFOLDER,
HFS_INODE_PREFIX, SWAP_BE32(hfsPlusFile->bsdInfo.special.iNodeNum));
result = ResolvePathToCatalogEntry(gLinkTemp, flags, entry,
kHFSRootFolderID, &tmpDirIndex);
sprintf(gLinkTemp, "%s/%s%ld", HFSPLUSMETADATAFOLDER,
HFS_INODE_PREFIX, SWAP_BE32(hfsPlusFile->bsdInfo.special.iNodeNum));
result = ResolvePathToCatalogEntry(gLinkTemp, flags, entry,
kHFSRootFolderID, &tmpDirIndex);
}
}
return result;
}
void *extent;
char *nodeBuf, *testKey, *entry;
BTNodeDescriptor *node;
if (gIsHFSPlus) {
extent = &gHFSPlus->catalogFile.extents;
extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize);
extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec;
extentSize = SWAP_BE32(gHFSMDB->drCTFlSize);
}
nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize);
nodeBuf = (char *)malloc(nodeSize);
node = (BTNodeDescriptor *)nodeBuf;
index = (long) (*dirIndex % nodeSize);
curNode = (long) (*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);
// Get the file name.
if (gIsHFSPlus) {
utf_encodestr(((HFSPlusCatalogKey *)testKey)->nodeName.unicode,
} else {
strncpy(gTempStr,
(const char *)&((HFSCatalogKey *)testKey)->nodeName[1],
((HFSCatalogKey *)testKey)->nodeName[0]);
((HFSCatalogKey *)testKey)->nodeName[0]);
gTempStr[((HFSCatalogKey *)testKey)->nodeName[0]] = '\0';
}
*name = gTempStr;
// Update dirIndex.
index++;
if (index == SWAP_BE16(node->numRecords)) {
curNode = SWAP_BE32(node->fLink);
}
*dirIndex = (long long) curNode * nodeSize + index;
free(nodeBuf);
return 0;
}
char key[sizeof(HFSPlusCatalogKey)];
HFSCatalogKey *hfsKey = (HFSCatalogKey *)key;
HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key;
// Make the catalog key.
if ( gIsHFSPlus )
{
hfsKey->nodeName[0] = length;
strncpy((char *)(hfsKey->nodeName + 1), fileName, length);
}
return ReadBTreeEntry(kBTreeCatalog, &key, entry, dirIndex);
}
char key[sizeof(HFSPlusExtentKey)];
HFSExtentKey *hfsKey = (HFSExtentKey *)key;
HFSPlusExtentKey *hfsPlusKey = (HFSPlusExtentKey *)key;
// Make the extents key.
if (gIsHFSPlus) {
hfsPlusKey->forkType = 0;
hfsKey->fileID = SWAP_BE32(fileID);
hfsKey->startBlock = SWAP_BE16(startBlock);
}
return ReadBTreeEntry(kBTreeExtents, &key, entry, 0);
}
long nodeSize, result = 0, entrySize = 0;
long curNode, index = 0, lowerBound, upperBound;
char *testKey, *recordData = 0;
// Figure out which tree is being looked at.
if (btree == kBTreeCatalog) {
if (gIsHFSPlus) {
}
extentFile = kHFSExtentsFileID;
}
// Read the BTree Header if needed.
if (gBTHeaders[btree] == 0) {
ReadExtent(extent, extentSize, extentFile, 0, 256,
sizeof(BTNodeDescriptor));
if ((gIsHFSPlus && btree == kBTreeCatalog) &&
(gBTHeaders[btree]->keyCompareType == kHFSBinaryCompare)) {
gCaseSensitive = 1;
gCaseSensitive = 1;
}
}
curNode = SWAP_BE32(gBTHeaders[btree]->rootNode);
nodeSize = SWAP_BE16(gBTHeaders[btree]->nodeSize);
nodeBuf = (char *)malloc(nodeSize);
node = (BTNodeDescriptor *)nodeBuf;
while (1) {
// Read the current node.
ReadExtent(extent, extentSize, extentFile,
(long long) curNode * nodeSize, nodeSize, nodeBuf, 1);
// Find the matching key.
lowerBound = 0;
upperBound = SWAP_BE16(node->numRecords) - 1;
while (lowerBound <= upperBound) {
index = (lowerBound + upperBound) / 2;
GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &recordData);
if (gIsHFSPlus) {
if (btree == kBTreeCatalog) {
result = CompareHFSPlusCatalogKeys(key, testKey);
result = CompareHFSExtentsKeys(key, testKey);
}
}
if (result < 0) upperBound = index - 1; // search < trial
else if (result > 0) lowerBound = index + 1; // search > trial
else break; // search = trial
}
if (result < 0) {
index = upperBound;
GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &recordData);
}
if (!recordData) { free(nodeBuf); return -1; }
// Found the closest key... Recurse on it if this is an index node.
if (node->kind == kBTIndexNode) {
curNode = SWAP_BE32( *((long *)recordData) );
} else break;
}
// Return error if the file was not found.
if (result != 0 || !recordData) { free(nodeBuf); return -1; }
if (btree == kBTreeCatalog) {
switch (SWAP_BE16(*(short *)recordData)) {
case kHFSFolderRecord : entrySize = 70; break;
if (gIsHFSPlus) entrySize = sizeof(HFSPlusExtentRecord);
else entrySize = sizeof(HFSExtentRecord);
}
bcopy(recordData, entry, entrySize);
// Update dirIndex.
if (dirIndex != 0) {
index++;
}
*dirIndex = (long long) curNode * nodeSize + index;
}
free(nodeBuf);
return 0;
}
{
long keySize;
long recordOffset;
recordOffset = SWAP_BE16(*((short *)(nodeBuffer + (nodeSize - 2 * index - 2))));
*key = nodeBuffer + recordOffset;
if (gIsHFSPlus) {
long long readOffset;
long long extentDensity, sizeofExtent, currentExtentSize;
char *currentExtent, *extentBuffer = 0, *bufferPos = buffer;
if (offset >= extentSize) return 0;
if (gIsHFSPlus) {
extentDensity = kHFSPlusExtentDensity;
sizeofExtent = sizeof(HFSPlusExtentDescriptor);
extentDensity = kHFSExtentDensity;
sizeofExtent = sizeof(HFSExtentDescriptor);
}
lastOffset = offset + size;
while (offset < lastOffset) {
blockNumber = offset / gBlockSize;
// Find the extent for the offset.
for (; ; nextExtent++) {
if (nextExtent < extentDensity) {
countedBlocks += GetExtentSize(extent, nextExtent);
continue;
}
currentExtent = extent + nextExtent * sizeofExtent;
break;
}
if (extentBuffer == 0) {
extentBuffer = malloc(sizeofExtent * extentDensity);
if (extentBuffer == 0) return -1;
}
nextExtentBlock = nextExtent / extentDensity;
if (currentExtentBlock != nextExtentBlock) {
ReadExtentsEntry(extentFile, countedBlocks, extentBuffer);
currentExtentBlock = nextExtentBlock;
}
currentExtentSize = GetExtentSize(extentBuffer, nextExtent % extentDensity);
if ((countedBlocks + currentExtentSize - 1) >= blockNumber) {
currentExtent = extentBuffer + sizeofExtent * (nextExtent % extentDensity);
break;
}
countedBlocks += currentExtentSize;
}
readOffset = ((blockNumber - countedBlocks) * gBlockSize) +
(offset % gBlockSize);
(offset % gBlockSize);
// MacWen: fix overflow in multiplication by forcing 64bit multiplication
readSize = (long long)GetExtentSize(currentExtent, 0) * gBlockSize - readOffset;
if (readSize > (long long)(size - sizeRead)) readSize = size - sizeRead;
readOffset += (long long)GetExtentStart(currentExtent, 0) * gBlockSize;
CacheRead(gCurrentIH, bufferPos, gAllocationOffset + readOffset,
readSize, cache);
sizeRead += readSize;
offset += readSize;
bufferPos += readSize;
}
if (extentBuffer) free(extentBuffer);
return sizeRead;
}
long start;
HFSExtentDescriptor *hfsExtents = extents;
HFSPlusExtentDescriptor *hfsPlusExtents = extents;
if (gIsHFSPlus) start = SWAP_BE32(hfsPlusExtents[index].startBlock);
else start = SWAP_BE16(hfsExtents[index].startBlock);
return start;
}
long size;
HFSExtentDescriptor *hfsExtents = extents;
HFSPlusExtentDescriptor *hfsPlusExtents = extents;
if (gIsHFSPlus) size = SWAP_BE32(hfsPlusExtents[index].blockCount);
else size = SWAP_BE16(hfsExtents[index].blockCount);
return size;
}
{
HFSCatalogKey *searchKey, *trialKey;
long result, searchParentID, trialParentID;
searchKey = key;
trialKey = testKey;
searchParentID = SWAP_BE32(searchKey->parentID);
trialParentID = SWAP_BE32(trialKey->parentID);
// parent dirID is unsigned
if (searchParentID > trialParentID) result = 1;
else if (searchParentID < trialParentID) result = -1;
// parent dirID's are equal, compare names
result = FastRelString(searchKey->nodeName, trialKey->nodeName);
}
return result;
}
{
HFSPlusCatalogKey *searchKey, *trialKey;
long result, searchParentID, trialParentID;
searchKey = key;
trialKey = testKey;
searchParentID = SWAP_BE32(searchKey->parentID);
trialParentID = SWAP_BE32(trialKey->parentID);
// parent dirID is unsigned
if (searchParentID > trialParentID) result = 1;
else if (searchParentID < trialParentID) result = -1;
if ((searchKey->nodeName.length == 0) || (trialKey->nodeName.length == 0))
result = searchKey->nodeName.length - trialKey->nodeName.length;
else
if (gCaseSensitive) {
result = BinaryUnicodeCompare(&searchKey->nodeName.unicode[0],
SWAP_BE16(searchKey->nodeName.length),
&trialKey->nodeName.unicode[0],
SWAP_BE16(trialKey->nodeName.length));
} else {
result = FastUnicodeCompare(&searchKey->nodeName.unicode[0],
SWAP_BE16(searchKey->nodeName.length),
&trialKey->nodeName.unicode[0],
SWAP_BE16(trialKey->nodeName.length), OSBigEndian);
}
if (gCaseSensitive) {
result = BinaryUnicodeCompare(&searchKey->nodeName.unicode[0],
SWAP_BE16(searchKey->nodeName.length),
&trialKey->nodeName.unicode[0],
SWAP_BE16(trialKey->nodeName.length));
} else {
result = FastUnicodeCompare(&searchKey->nodeName.unicode[0],
SWAP_BE16(searchKey->nodeName.length),
&trialKey->nodeName.unicode[0],
SWAP_BE16(trialKey->nodeName.length), OSBigEndian);
}
}
return result;
}
{
HFSExtentKey *searchKey, *trialKey;
long result;
searchKey = key;
trialKey = testKey;
// assume searchKey < trialKey
result = -1;
if (searchKey->fileID == trialKey->fileID) {
// FileNum's are equal; compare fork types
if (searchKey->forkType == trialKey->forkType) {
if (SWAP_BE32(searchKey->fileID) > SWAP_BE32(trialKey->fileID))
result = 1;
}
return result;
}
{
HFSPlusExtentKey *searchKey, *trialKey;
long result;
searchKey = key;
trialKey = testKey;
// assume searchKey < trialKey
result = -1;
if (searchKey->fileID == trialKey->fileID) {
// FileNum's are equal; compare fork types
if (searchKey->forkType == trialKey->forkType) {
if (SWAP_BE32(searchKey->fileID) > SWAP_BE32(trialKey->fileID))
result = 1;
}
return result;
}
branches/cparm/i386/libsaio/modules.h
7878
7979
8080
81
82
8381
8482
8583
......
10199
102100
103101
102
103
104
105
106
107
108
109
110
111
112
104113
EFI_STATUS bind_macho(char* module, void* base, char* bind_stream, UInt32 size);
EFI_STATUS load_module(char* module);
EFI_STATUS load_bundle(const char* bundle);
VOID load_all_bundles(void);
EFI_STATUS is_module_loaded(const char* name);
VOID module_loaded(const char* name);
extern unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*));
long InitBundleSupport(void);
long FileLoadBundles(char *dirSpec, long plugin);
long LoadBundlePList(char *dirSpec, char *name, long bundleType);
long LoadMatchedBundles(void);
long MatchBundlesLibraries(void);
long LoadBundles( char * dirSpec );
void * GetBundleDict( char * bundle_id );
void * GetBundlePersonalities( char * bundle_id );
char * GetBundlePath( char * bundle_id );
#endif /* __BOOT_MODULES_H */
branches/cparm/i386/libsaio/disk.c
612612
613613
614614
615
615
616616
617617
618618
......
771771
772772
773773
774
774
775775
776776
777777
(*bvr->bv_free)(bvr);
bvr = NULL;
}
if ( readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 )
if ( bvr && readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 )
{
bvr->flags |= kBVFlagBootable;
}
(*bvr->bv_free)(bvr);
bvr = NULL;
}
if ( readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 )
if ( bvr && readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 )
{
bvr->flags |= kBVFlagBootable;
}
branches/cparm/i386/libsaio/acpi_tools.c
9090
9191
9292
93
93
9494
9595
96
96
9797
9898
9999
100100
101101
102
102
103103
104
105
106
107
108104
109105
110
106
111107
108
109
110
111
112
112113
113114
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
115132
116133
134
135
136
137
117138
118139
119140
120
121
122
123
124
125
126
127
128
141
142
129143
144
145
146
147
130148
131149
132
150
151
152
153
154
155
133156
134
135
136
137
138157
139
140
141
142158
143159
144160
if (!success)
success = GetRsdtPointer((void *)0x0F0000, 0x10000, acpi_tables);
if (!success)
if (!success || (acpi_tables->RsdtPointer == 0ul))
return (0ul);
GetXsdtPointer(acpi_tables);
success = GetXsdtPointer(acpi_tables);
// Find FACP table pointer which is one of table pointers in the RDST
acpi_tables->FacpPointer = (ACPI_TABLE_FADT *)
GetTablePtr(acpi_tables->RsdtPointer, NAMESEG("FACP"));
if (acpi_tables->FacpPointer == 0ul)
return (0ul);
return (0ul);
// Find FACP(64) table pointer which is one of table pointers in the XDST
acpi_tables->FacpPointer64 = (ACPI_TABLE_FADT *)
GetTablePtr64(acpi_tables->XsdtPointer, NAMESEG("FACP"));
// Find the DSDT which is included in the FACP table
acpi_tables->DsdtPointer = (ACPI_TABLE_DSDT *) acpi_tables->FacpPointer->Dsdt;
if ((*(U32 *) (acpi_tables->DsdtPointer->Header.Signature) != NAMESEG("DSDT")) ||
if ((acpi_tables->DsdtPointer == 0ul) || (*(U32 *) (acpi_tables->DsdtPointer->Header.Signature) != NAMESEG("DSDT")) ||
(GetChecksum(acpi_tables->DsdtPointer, acpi_tables->DsdtPointer->Header.Length) != 0))
return (0ul);
// Find the FACS which is included in the FACP table
acpi_tables->FacsPointer = (ACPI_TABLE_FACS *) acpi_tables->FacpPointer->Facs;
if ((acpi_tables->FacsPointer == 0ul) || (*(U32 *) (acpi_tables->FacsPointer->Signature) != NAMESEG("FACS")))
return (0ul);
{
// Find the MADT table which is one of the table pointers in the RSDT
acpi_tables->MadtPointer = (ACPI_TABLE_MADT *) GetTablePtr(acpi_tables->RsdtPointer, NAMESEG("APIC"));
if (acpi_tables->MadtPointer == 0ul)
return (0ul);
do {
if (!success || (acpi_tables->XsdtPointer == 0ul))
break;
// Find FACP(64) table pointer which is one of table pointers in the XDST
acpi_tables->FacpPointer64 = (ACPI_TABLE_FADT *)
GetTablePtr64(acpi_tables->XsdtPointer, NAMESEG("FACP"));
if (acpi_tables->FacpPointer64 == 0ul)
break;
// Find the XDSDT which is included in the FACP(64) table
ACPI_TABLE_DSDT *DsdtPointer64 = (ACPI_TABLE_DSDT *)((U32)acpi_tables->FacpPointer64->XDsdt);
if (DsdtPointer64 == 0ul)
break;
if ((*(U32*) (DsdtPointer64->Header.Signature) == NAMESEG("DSDT")) &&
(GetChecksum(DsdtPointer64, DsdtPointer64->Header.Length) == 0))
acpi_tables->DsdtPointer64 = (ACPI_TABLE_DSDT *) DsdtPointer64;
}
// Find the FACS which is included in the FACP table
acpi_tables->FacsPointer = (ACPI_TABLE_FACS *) acpi_tables->FacpPointer->Facs;
if (*(U32 *) (acpi_tables->FacsPointer->Signature) != NAMESEG("FACS"))
return (0ul);
{
// Find the XFACS which is included in the FACP(64) table
// Find the XFACS which is included in the FACP(64) table
ACPI_TABLE_FACS *FacsPointer64 = (ACPI_TABLE_FACS *)((U32)acpi_tables->FacpPointer64->XFacs);
if (FacsPointer64 == 0ul)
break;
if (*(U32*) (FacsPointer64->Signature) == NAMESEG("FACS"))
acpi_tables->FacsPointer64 = (ACPI_TABLE_FACS *) FacsPointer64;
}
// Find the MADT(64) table which is one of the table pointers in the XSDT
acpi_tables->MadtPointer64 = (ACPI_TABLE_MADT *) GetTablePtr64(acpi_tables->XsdtPointer, NAMESEG("APIC"));
} while (0);
// Find the MADT table which is one of the table pointers in the RSDT
acpi_tables->MadtPointer = (ACPI_TABLE_MADT *) GetTablePtr(acpi_tables->RsdtPointer, NAMESEG("APIC"));
if (acpi_tables->MadtPointer == 0ul)
return (0ul);
// Find the MADT(64) table which is one of the table pointers in the XSDT
acpi_tables->MadtPointer64 = (ACPI_TABLE_MADT *) GetTablePtr64(acpi_tables->XsdtPointer, NAMESEG("APIC"));
return (1ul);
}
branches/cparm/i386/libsaio/fake_efi.c
44
55
66
7
7
88
99
1010
*/
/*
* Copyright 2010,2011 Cadet-petit Armel <armelcadetpetit@gmail.com>. All rights reserved.
* Copyright 2010,2011,2012 Cadet-petit Armel <armelcadetpetit@gmail.com>. All rights reserved.
*/
#include "libsaio.h"
branches/cparm/i386/MakeInc.dir
3939
4040
4141
42
4243
44
45
46
47
48
49
50
51
52
4353
4454
4555
......
5363
5464
5565
66
5667
5768
5869
.SUFFIXES: .s .i .c .o
ifeq "makedep" "NO"
.c.o .m.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o
$(OBJROOT)/%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o
$(OBJROOT)/%.o: %.m
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o
else
.c.o .m.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
endif
#.s.o:
#cc $(INC) -E $< > $(OBJROOT)/$*.o2
branches/cparm/i386/boot2/graphics.c
507507
508508
509509
510
511
512
510513
511514
512515
unsigned char bitsPerPixel )
{
VBEModeInfoBlock minfo;
minfo.XResolution = 0;
minfo.YResolution = 0;
unsigned short mode = modeEndOfList;
if ( (cols != 80) || (rows != 25) ) // not 80x25 mode
branches/cparm/i386/boot2/boot.c
181181
182182
183183
184
184
185185
186186
187187
......
960960
961961
962962
963
963
964964
965965
966966
outb(0x21, 0x01);
outb(0xA1, 0x01);
outb(0x70, inb(0x70)|0x80); /* Disable NMI */
//outb(0x70, inb(0x70)|0x80); /* Disable NMI */ is this really necessary ?
outb(0x21, 0xff); /* Maskout all interrupts Pic1 */
outb(0xa1, 0xff); /* Maskout all interrupts Pic2 */
free(platformInfo);
}
DBG("Adler32: %08lX\n",bootInfo->adler32);
DBG("Adler32: %08lX\n",Adler32);
if (gBootVolume->OSVersion[3] < '6')
{
branches/cparm/i386/boot2/drivers.c
434434
435435
436436
437
437
438438
439439
440440
......
480480
481481
482482
483
484
483485
484486
485487
......
490492
491493
492494
495
493496
494497
495498
496499
497500
498
499
501
502
500503
501504
502505
......
530533
531534
532535
533
534
535
536
537
538
539
540
541
536542
537543
538544
LoadDriverPList( char * dirSpec, char * name, long bundleType )
{
long length, executablePathLength, bundlePathLength;
ModulePtr module;
ModulePtr module = 0;
TagPtr personalities;
char * buffer = 0;
char * tmpExecutablePath = 0;
ret = ParseXML(buffer, &module, &personalities);
if (ret != 0) { break; }
if (!module) {ret = -1;break;} // Should never happen but it will make the compiler happy
// Allocate memory for the driver path and the plist.
module->executablePath = tmpExecutablePath;
if ((module->executablePath == 0) || (module->bundlePath == 0) || (module->plistAddr == 0))
{
if ( module->plistAddr ) free(module->plistAddr);
ret = -1;
break;
}
// Save the driver path in the module.
//strcpy(module->driverPath, tmpDriverPath);
tmpExecutablePath = 0;
tmpBundlePath = 0;
//tmpExecutablePath = 0;
//tmpBundlePath = 0;
// Add the plist to the module.
while (0);
if ( buffer ) free( buffer );
if ( tmpExecutablePath ) free( tmpExecutablePath );
if ( tmpBundlePath ) free( tmpBundlePath );
if (ret != 0)
{
if ( tmpExecutablePath ) free( tmpExecutablePath );
if ( tmpBundlePath ) free( tmpBundlePath );
if ( module ) free( module );
}
return ret;
}
branches/cparm/i386/boot2/mboot.c
296296
297297
298298
299
300
299301
300302
301303
// because we're stuck in extended memory at this point.
struct multiboot_info *mi_p = copyMultibootInfo(multiboot_magic, mi_orig);
if (mi_p == NULL)
return BAD_BOOT_DEVICE;
#if 0
/*
* cparm: I'm not an asm guru but i don't see what's the use of this part of code, moreover some
branches/cparm/i386/boot2/Makefile
7676
7777
7878
79
79
8080
8181
8282
......
134134
135135
136136
137
137
138138
139139
140140
......
150150
151151
152152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
153167
154168
155169
@echo "\t[LD] boot.sys"
@$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \
-nostdlib -arch i386 -Wl,-segalign,20 \
-o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS)
-o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) #-e boot2
@echo "\t[MACHOCONV] boot"
@$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot &> /dev/null
@##size $(SYMROOT)/${SYMBOLS_MODULE}
Symbols.o:
Symbols.o: Symbols.plist
@rm -rf $(SYMROOT)/Symbols.h
@echo "typedef struct {" >> $(SYMROOT)/Symbols.h
@echo "char*symbol;" >> $(SYMROOT)/Symbols.h
@echo "\t[CC] $@"
@$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(UTILDIR)/Symbols.c $(INC) -o $(OBJROOT)/Symbols.o
Symbols.plist:
@rm -rf $(SYMROOT)/Symbols.plist
@echo "<?xml version="1.0" encoding="UTF-8"?>" >> $(SYMROOT)/Symbols.plist
@echo "<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> " >> $(SYMROOT)/Symbols.plist
@echo "<plist version="1.0">" >> $(SYMROOT)/Symbols.plist
@echo "<dict>" >> $(SYMROOT)/Symbols.plist
@echo "<key>IOKitPersonalities</key>" >> $(SYMROOT)/Symbols.plist
@echo "<dict>" >> $(SYMROOT)/Symbols.plist
@nm -g $(SYMROOT)/boot.sys | tr . _ | awk '{print "<key>"$$3"</key><string>"$$1"</string>"}' >> $(SYMROOT)/Symbols.plist
@echo "</dict>" >> $(SYMROOT)/Symbols.plist
@echo "</dict>" >> $(SYMROOT)/Symbols.plist
@echo "</plist>" >> $(SYMROOT)/Symbols.plist
@plutil -convert xml1 $(SYMROOT)/Symbols.plist
install_i386:: all $(INSTALLDIR)
cp $(SYMROOT)/boot $(OTHER_FILES) $(INSTALLDIR)
branches/cparm/i386/modules/GUI/picopng.c
2323
2424
2525
26
27
28
29
30
26
27
28
29
30
3131
3232
3333
......
132132
133133
134134
135
136
135137
136
137
138
138
139
140
139141
140142
141143
......
284286
285287
286288
287
289
288290
289
291
290292
291
293
292294
293
295
294296
295297
296298
......
339341
340342
341343
342
344
343345
344346
345347
......
368370
369371
370372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
371387
372388
373389
374
390
375391
376392
377393
378394
379
395
380396
381397
382398
......
432448
433449
434450
435
451
436452
437453
438454
......
443459
444460
445461
446
462
447463
448464
449465
......
452468
453469
454470
455
471
456472
457473
458474
......
560576
561577
562578
563
579
564580
565581
566582
......
627643
628644
629645
630
646
631647
632648
633649
......
838854
839855
840856
841
857
842858
843859
844860
......
846862
847863
848864
849
850
851
852
853
854
855
856
857
858
859
860
865
861866
862
863
864
865867
866
867
868
868
869
869870
870
871
872
873
874
875871
876872
877
878
879
880
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
881897
882898
883899
......
890906
891907
892908
893
894
895
896
909
910
911
912
897913
898914
899915
900916
901
902
917
918
903919
904920
905921
......
911927
912928
913929
914
930
915931
916932
917933
918934
919935
920936
921
937
922938
923939
924940
......
945961
946962
947963
948
964
949965
950966
951967
......
956972
957973
958974
959
975
960976
961977
962978
......
978994
979995
980996
981
997
982998
983999
9841000
9851001
9861002
9871003
988
989
990
1004
1005
1006
9911007
9921008
9931009
......
10011017
10021018
10031019
1004
1020
10051021
10061022
1007
1023
10081024
10091025
10101026
......
10781094
10791095
10801096
1097
1098
1099
1100
1101
1102
10811103
10821104
10831105
......
11421164
11431165
11441166
1167
1168
1169
1170
1171
11451172
11461173
11471174
......
11601187
11611188
11621189
1163
1190
11641191
11651192
11661193
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
11821210
1183
11841211
11851212
11861213
......
11951222
11961223
11971224
1198
1225
11991226
12001227
12011228
......
12031230
12041231
12051232
1206
1207
1233
1234
12081235
12091236
12101237
......
12371264
12381265
12391266
1240
1267
12411268
12421269
12431270
......
12561283
12571284
12581285
1259
1286
12601287
1261
1288
12621289
12631290
12641291
12651292
12661293
1267
1294
12681295
12691296
12701297
12711298
1272
1299
12731300
12741301
12751302
......
12851312
12861313
12871314
1288
1315
12891316
12901317
12911318
12921319
12931320
12941321
1295
1322
12961323
12971324
12981325
/* sys.c */
/*
extern int open_bvdev(const char *bvd, const char *path);
extern int close(int fdesc);
extern int file_size(int fdesc);
extern int read(int fdesc, char *buf, int count);
*/
extern int open_bvdev(const char *bvd, const char *path);
extern int close(int fdesc);
extern int file_size(int fdesc);
extern int read(int fdesc, char *buf, int count);
*/
/*************************************************************************************************/
void png_alloc_free(void *addr)
{
if (!addr) return;
png_alloc_node_t *node = png_alloc_find_node(addr);
if (!node)
return;
png_alloc_remove_node(node);
if (node)
png_alloc_remove_node(node);
free(addr);
}
/*************************************************************************************************/
const uint32_t LENBASE[29] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51,
59, 67, 83, 99, 115, 131, 163, 195, 227, 258 };
59, 67, 83, 99, 115, 131, 163, 195, 227, 258 };
const uint32_t LENEXTRA[29] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,
4, 5, 5, 5, 5, 0 };
4, 5, 5, 5, 5, 0 };
const uint32_t DISTBASE[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385,
513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 };
513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 };
const uint32_t DISTEXTRA[30] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13 };
10, 10, 11, 11, 12, 12, 13, 13 };
// code length code lengths
const uint32_t CLCL[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
blcount = vector32_new(maxbitlen + 1, 0);
nextcode = vector32_new(maxbitlen + 1, 0);
if (!tree1d || !blcount || !nextcode || !nextcode->data) {
return 1; // FIXME
goto error;
}
for (bits = 0; bits < numcodes; bits++)
blcount->data[bitlen->data[bits]]++; // count number of instances of each code length
treepos = tree2d->data[2 * treepos + bit] - numcodes;
}
return 0;
error:
if (tree1d) {
vector32_cleanup(tree1d);
png_alloc_free(tree1d);
}
if (blcount) {
vector32_cleanup(blcount);
png_alloc_free(blcount);
}
if (nextcode) {
vector32_cleanup(nextcode);
png_alloc_free(nextcode);
}
return 1;
}
int HuffmanTree_decode(const HuffmanTree *tree, bool *decoded, uint32_t *result, size_t *treepos,
uint32_t bit)
uint32_t bit)
{// Decodes a symbol from the tree
const vector32_t *tree2d = tree->tree2d;
if (!tree2d) {
return 1; // FIXME
}
uint32_t numcodes = (uint32_t) tree2d->size / 2;
if (*treepos >= numcodes)
}
uint32_t Inflator_huffmanDecodeSymbol(const uint8_t *in, size_t *bp, const HuffmanTree *codetree,
size_t inlength)
size_t inlength)
{// decode a single symbol from given list of bits with given code tree. returns the symbol
bool decoded = false;
uint32_t ct = 0;
return 0;
}
Inflator_error = HuffmanTree_decode(codetree, &decoded, &ct, &treepos,
Zlib_readBitFromStream(bp, in));
Zlib_readBitFromStream(bp, in));
if (Inflator_error)
return 0; // stop, an error happened
if (decoded)
}
void Inflator_getTreeInflateDynamic(HuffmanTree *tree, HuffmanTree *treeD, const uint8_t *in,
size_t *bp, size_t inlength)
size_t *bp, size_t inlength)
{// get the tree of a deflated block with dynamic tree, the tree itself is also Huffman
// compressed with a known tree
size_t i, n;
}
void Inflator_inflateHuffmanBlock(vector8_t *out, const uint8_t *in, size_t *bp, size_t *pos,
size_t inlength, uint32_t btype)
size_t inlength, uint32_t btype)
{
HuffmanTree *codetree, *codetreeD; // the code tree for Huffman codes, dist codes
codetree = HuffmanTree_new();
}
void Inflator_inflateNoCompression(vector8_t *out, const uint8_t *in, size_t *bp, size_t *pos,
size_t inlength)
size_t inlength)
{
while ((*bp & 0x7) != 0)
(*bp)++; // go to first boundary of byte
}
void PNG_unFilterScanline(uint8_t *recon, const uint8_t *scanline, const uint8_t *precon,
size_t bytewidth, uint32_t filterType, size_t length)
size_t bytewidth, uint32_t filterType, size_t length)
{
size_t i;
if (!recon) {
return;
}
switch (filterType) {
case 0:
for (i = 0; i < length; i++)
recon[i] = scanline[i];
break;
case 1:
for (i = 0; i < bytewidth; i++)
recon[i] = scanline[i];
for (i = bytewidth; i < length; i++)
recon[i] = scanline[i] + recon[i - bytewidth];
break;
case 2:
if (precon)
case 0:
for (i = 0; i < length; i++)
recon[i] = scanline[i] + precon[i];
else
for (i = 0; i < length; i++)
recon[i] = scanline[i];
break;
case 3:
if (precon) {
break;
case 1:
for (i = 0; i < bytewidth; i++)
recon[i] = scanline[i] + precon[i] / 2;
for (i = bytewidth; i < length; i++)
recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) / 2);
} else {
for (i = 0; i < bytewidth; i++)
recon[i] = scanline[i];
for (i = bytewidth; i < length; i++)
recon[i] = scanline[i] + recon[i - bytewidth] / 2;
}
break;
case 4:
recon[i] = scanline[i] + recon[i - bytewidth];
break;
case 2:
if (precon)
for (i = 0; i < length; i++)
recon[i] = scanline[i] + precon[i];
else
for (i = 0; i < length; i++)
recon[i] = scanline[i];
break;
case 3:
if (precon) {
for (i = 0; i < bytewidth; i++)
recon[i] = scanline[i] + precon[i] / 2;
for (i = bytewidth; i < length; i++)
recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) / 2);
} else {
for (i = 0; i < bytewidth; i++)
recon[i] = scanline[i];
for (i = bytewidth; i < length; i++)
recon[i] = scanline[i] + recon[i - bytewidth] / 2;
}
break;
case 4:
if (precon) {
for (i = 0; i < bytewidth; i++)
recon[i] = (uint8_t) (scanline[i] + PNG_paethPredictor(0, precon[i], 0));
for (i = bytewidth; i < length; i++)
recon[i] = (uint8_t) (scanline[i] + PNG_paethPredictor(recon[i - bytewidth], 0, 0));
}
break;
default:
PNG_error = 36; // error: nonexistent filter type given
return;
break;
default:
PNG_error = 36; // error: nonexistent filter type given
return;
}
}
void PNG_adam7Pass(uint8_t *out, uint8_t *linen, uint8_t *lineo, const uint8_t *in, uint32_t w,
size_t passleft, size_t passtop, size_t spacex, size_t spacey, size_t passw, size_t passh,
uint32_t bpp)
size_t passleft, size_t passtop, size_t spacex, size_t spacey, size_t passw, size_t passh,
uint32_t bpp)
{// filter and reposition the pixels into the output when the image is Adam7 interlaced. This
// function can only do it after the full image is already decoded. The out buffer must have
// the correct allocated memory size already.
size_t i, b;
uint8_t filterType = in[y * linelength], *prevline = (y == 0) ? 0 : lineo;
PNG_unFilterScanline(linen, &in[y * linelength + 1], prevline, bytewidth, filterType,
(w * bpp + 7) / 8);
(w * bpp + 7) / 8);
if (PNG_error)
return;
if (bpp >= 8)
for (i = 0; i < passw; i++)
for (b = 0; b < bytewidth; b++) // b = current byte of this pixel
out[bytewidth * w * (passtop + spacey * y) + bytewidth *
(passleft + spacex * i) + b] = linen[bytewidth * i + b];
(passleft + spacex * i) + b] = linen[bytewidth * i + b];
else
for (i = 0; i < passw; i++) {
size_t obp, bp;
return 1; // FIXME : find the appropiate error return
}
uint8_t *out_data = out->data ;
if (bitDepth == 8 && colorType == 0) // greyscale
for (i = 0; i < numpixels; i++) {
out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = in[i];
for (c = 0; c < 3; c++)
out_data[4 * i + c] = in[3 * i + c];
out_data[4 * i + 3] = (info->key_defined && (in[3 * i + 0] == info->key_r) &&
(in[3 * i + 1] == info->key_g) && (in[3 * i + 2] == info->key_b)) ? 0 : 255;
(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++) {
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;
? 0 : 255;
}
else if (bitDepth == 16 && colorType == 2) // RGB color
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 + 0] + in[6 * i + 1] == info->key_r) &&
(256U * in[6 * i + 2] + in[6 * i + 3] == info->key_g) &&
(256U * in[6 * i + 4] + in[6 * i + 5] == info->key_b)) ? 0 : 255;
(256U * in[6 * i + 0] + in[6 * i + 1] == info->key_r) &&
(256U * in[6 * i + 2] + in[6 * i + 3] == info->key_g) &&
(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++) {
else if (bitDepth < 8 && colorType == 0) // greyscale
for (i = 0; i < numpixels; i++) {
uint32_t value = (PNG_readBitsFromReversedStream(&bp, in, bitDepth) * 255) /
((1 << bitDepth) - 1); // scale value from 0 to 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;
out_data[4 * i + 3] = (info->key_defined && value &&
(((1U << bitDepth) - 1U) == info->key_r) && ((1U << bitDepth) - 1U)) ? 0 : 255;
(((1U << bitDepth) - 1U) == info->key_r) && ((1U << bitDepth) - 1U)) ? 0 : 255;
}
else if (bitDepth < 8 && colorType == 3) // palette
for (i = 0; i < numpixels; i++) {
vector8_resize(idat, offset + chunkLength);
} else
idat = vector8_new(chunkLength, 0);
if (!idat)
{
PNG_error = 1;
return NULL;
}
for (i = 0; i < chunkLength; i++)
idat->data[offset + i] = in[pos + 4 + i];
pos += (4 + chunkLength);
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);
if (!scanlines)
{
PNG_error = 1;
return NULL;
}
PNG_error = Zlib_decompress(scanlines, idat);
if (PNG_error)
return NULL; // stop if the zlib decompressor returned an error
const uint8_t *prevline;
prevline = (y == 0) ? 0 : &out_data[(y - 1) * info->width * bytewidth];
PNG_unFilterScanline(&out_data[linestart - y], &scanlines->data[linestart + 1],
prevline, bytewidth, filterType, linelength);
prevline, bytewidth, filterType, linelength);
if (PNG_error)
return NULL;
linestart += (1 + linelength); // go to start of next scanline
} else { // less than 8 bits per pixel, so fill it up bit per bit
vector8_t *templine; // only used if bpp < 8
templine = vector8_new((info->width * bpp + 7) >> 3, 0);
for (y = 0, obp = 0; y < info->height; y++) {
uint32_t filterType = scanlines->data[linestart];
const uint8_t *prevline;
prevline = (y == 0) ? 0 : &out_data[(y - 1) * info->width * bytewidth];
PNG_unFilterScanline(templine->data, &scanlines->data[linestart + 1], prevline,
bytewidth, filterType, linelength);
if (PNG_error)
return NULL;
for (bp = 0; bp < info->width * bpp;)
PNG_setBitOfReversedStream(&obp, out_data, PNG_readBitFromReversedStream(&bp,
templine->data));
linestart += (1 + linelength); // go to start of next scanline
} else { // less than 8 bits per pixel, so fill it up bit per bit
vector8_t *templine; // only used if bpp < 8
templine = vector8_new((info->width * bpp + 7) >> 3, 0);
for (y = 0, obp = 0; y < info->height; y++) {
uint32_t filterType = scanlines->data[linestart];
const uint8_t *prevline;
prevline = (y == 0) ? 0 : &out_data[(y - 1) * info->width * bytewidth];
PNG_unFilterScanline(templine->data, &scanlines->data[linestart + 1], prevline,
bytewidth, filterType, linelength);
if (PNG_error)
return NULL;
for (bp = 0; bp < info->width * bpp;)
PNG_setBitOfReversedStream(&obp, out_data, PNG_readBitFromReversedStream(&bp,
templine->data));
linestart += (1 + linelength); // go to start of next scanline
}
}
}
} else { // interlaceMethod is 1 (Adam7)
int i;
size_t passw[7] = {
};
size_t passstart[7] = { 0 };
size_t pattern[28] = { 0, 4, 0, 2, 0, 1, 0, 0, 0, 4, 0, 2, 0, 1, 8, 8, 4, 4, 2, 2, 1, 8, 8,
8, 4, 4, 2, 2 }; // values for the adam7 passes
8, 4, 4, 2, 2 }; // values for the adam7 passes
for (i = 0; i < 6; i++)
passstart[i + 1] = passstart[i] + passh[i] * ((passw[i] ? 1 : 0) + (passw[i] * bpp + 7) / 8);
vector8_t *scanlineo, *scanlinen; // "old" and "new" scanline
scanlinen = vector8_new((info->width * bpp + 7) / 8, 0);
for (i = 0; i < 7; i++)
PNG_adam7Pass(out_data, scanlinen->data, scanlineo->data, &scanlines->data[passstart[i]],
info->width, pattern[i], pattern[i + 7], pattern[i + 14], pattern[i + 21],
passw[i], passh[i], bpp);
info->width, pattern[i], pattern[i + 7], pattern[i + 14], pattern[i + 21],
passw[i], passh[i], bpp);
}
if (info->colorType != 6 || info->bitDepth != 8) { // conversion needed
#if 1
FILE *infp, *outfp;
uint8_t *inbuf;
uint32_t n;
if (stat(fname, &statbuf) != 0) {
perror("stat");
return 1;
return 1;
}
fclose(infp);
printf("input file: %s (size: %d)\n", fname, insize);
info = PNG_decode(inbuf, insize);
free(inbuf);
printf("PNG_error: %d\n", PNG_error);
if (PNG_error != 0)
return 1;
printf("width: %d, height: %d\nfirst 16 bytes: ", info->width, info->height);
for (n = 0; n < 16; n++)
printf("%02x ", info->image->data[n]);
printf("\n");
outsize = info->width * info->height * 4;
printf("image size: %d\n", outsize);
if (outsize != info->image->size) {
return 1;
}
fclose(outfp);
#ifdef ALLOC_DEBUG
png_alloc_node_t *node;
for (node = png_alloc_head, n = 1; node; node = node->next, n++)
printf("node %d (%p) addr = %p, size = %ld\n", n, node, node->addr, node->size);
#endif
png_alloc_free_all(); // also frees info and image data from PNG_decode
return 0;
}
branches/cparm/i386/modules/GUI/gui.c
26522652
26532653
26542654
2655
2655
26562656
2657
2658
2659
2657
2658
2659
26602660
26612661
26622662
......
27312731
27322732
27332733
2734
2735
}
int GUI_countdown( const char * msg, int row, int timeout , int *optionKey)
int GUI_countdown( const char * msg, register int row, register int timeout , int *optionKey)
{
unsigned long time;
register int ch = 0;
int col = strlen(msg) + 1;
register unsigned long time;
int ch = 0;
register int col = strlen(msg) + 1;
flushKeyboardBuffer();
return ch;
}
branches/cparm/i386/modules/GUI/GUI_module.c
278278
279279
280280
281
281
282
282283
283284
284285
......
453454
454455
455456
457
456458
457459
458460
......
484486
485487
486488
487
489
488490
489491
490492
......
515517
516518
517519
518
520
521
519522
520523
521524
** replace various menu functions. Finaly, initialize the gui and hook
** into important events.
**/
void GUI_start(moduleList_t* module)
void GUI_start(void);
void GUI_start(void)
{
register_hook_callback("GUI_Display", &GUI_diplay_hook);
{
CursorState cursorState;
cursorState.x = cursorState.y = cursorState.type=0;
// Set cursor at current position, and clear inverse video.
{
moveCursor( 0, MenuRow + MenuSelection - MenuTop );
printMenuItem( &gMenuItems[MenuSelection], 1 );
moved = restoreCursor( &cursorState );
/*moved =*/ restoreCursor( &cursorState );
}
else
{
int i;
CursorState cursorState;
cursorState.x = cursorState.y = cursorState.type=0;
if ( items == NULL || count == 0 )
return;
branches/cparm/i386/modules/GUI/graphic_utils.c
626626
627627
628628
629
630
629631
630632
631633
unsigned char bitsPerPixel )
{
VBEModeInfoBlock minfo;
minfo.XResolution = 0;
minfo.YResolution = 0;
unsigned short mode = modeEndOfList;
if ( (cols != 80) || (rows != 25) ) // not 80x25 mode
branches/cparm/i386/modules/HibernateEnabler/graphic_utils.c
434434
435435
436436
437
438
437439
438440
439441
unsigned char bitsPerPixel )
{
VBEModeInfoBlock minfo;
minfo.XResolution = 0;
minfo.YResolution = 0;
unsigned short mode = modeEndOfList;
if ( (cols != 80) || (rows != 25) ) // not 80x25 mode
branches/cparm/i386/modules/ACPICodec/acpidecode.c
201201
202202
203203
204
204
205205
206206
207207
......
432432
433433
434434
435
436
435
436
437437
438438
439439
......
485485
486486
487487
488
489
488
489
490490
491491
492492
......
506506
507507
508508
509
509
510510
511511
512512
......
554554
555555
556556
557
558
557
558
559559
560560
561561
......
563563
564564
565565
566
567
566
567
568568
569569
570570
......
587587
588588
589589
590
591
590
591
592592
593593
594594
......
627627
628628
629629
630
631
630
631
632632
633633
634634
......
644644
645645
646646
647
648
647
648
649649
650650
651651
......
732732
733733
734734
735
736
735
736
737737
738738
739739
......
791791
792792
793793
794
795
794
795
796796
797797
798798
static U8 *parse_acpi_buffer(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U32 pkglen, lengthEncoding;
U32 pkglen = 0, lengthEncoding = 0;
(void)ns;
(void)end;
if (*current != AML_BUFFER_OP)
{
U8 *new_end = current;
U8 *temp;
U32 pkglen;
U32 lengthEncoding;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
(void)end;
{
U8 *new_end = current;
U8 *temp;
U32 pkglen;
U32 lengthEncoding;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
U8 id;
U32 pmbase;
pmbase = *(U32 *) current;
current += 4;
(void)current; // Silent a warning reported by the clang static analizer .
#if DEBUG_ACPI_DECODE
DBG( "Found CPU object: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
} else if (*(current + 1) == AML_FIELD_OP) {
U32 pkglen;
U32 lengthEncoding;
U32 pkglen = 0;
U32 lengthEncoding = 0;
current += 2;
DBG( "FieldOp at memory location %p\n", current);
current += pkglen;
} else if (*(current + 1) == AML_DEVICE_OP) {
U8 *new_end;
U32 pkglen;
U32 lengthEncoding;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
current += 2;
current = parse_acpi_processor(ns, current, end);
} else if (*(current + 1) == AML_INDEXFIELD_OP) {
U8 *new_end;
U32 pkglen;
U32 lengthEncoding;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
current += 2;
case AML_IF_OP:
{
U8 *new_end;
U32 pkgLen;
U32 lengthEncoding;
U32 pkgLen = 0;
U32 lengthEncoding = 0;
DBG( "Found IfOp\n");
current++;
case AML_ELSE_OP:
{
U8 *new_end;
U32 pkgLen;
U32 lengthEncoding;
U32 pkgLen = 0;
U32 lengthEncoding = 0;
DBG( "Found ElseOp\n");
current++;
(void)ns;
(void)end;
if (*current == AML_PACKAGE_OP) {
U32 pkglen;
U32 lengthEncoding;
U32 pkglen = 0;
U32 lengthEncoding = 0;
DBG( "Found PackageOp\n");
current++;
{
U8 *new_end;
struct acpi_namespace new_ns;
U32 scopeLen;
U32 lengthEncoding;
U32 scopeLen = 0;
U32 lengthEncoding = 0;
current++;
parsePackageLength(current, &scopeLen, &lengthEncoding);
branches/cparm/i386/modules/ACPICodec/acpi_codec.c
3131
3232
3333
34
34
3535
3636
3737
......
172172
173173
174174
175
175
176
177
176178
177179
178180
......
36123614
36133615
36143616
3617
3618
3619
36153620
36163621
36173622
......
47004705
47014706
47024707
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
47254755
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4756
4757
4758
4759
4760
4761
47394762
4740
4741
4742
4743
4763
4764
47444765
4745
4746
4747
4766
4767
4768
4769
47484770
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4771
47614772
47624773
47634774
*/
/*
* Copyright (c) 2011 cparm <armelcadetpetit@gmail.com>. All rights reserved.
* Copyright (c) 2011,2012 cparm <armelcadetpetit@gmail.com>. All rights reserved.
*
*/
#define ACPI_TABLE_LIST_FULL_NON_RESERVED MAX_ACPI_TABLE + 1
//#define ULONG_MAX_32 4294967295UL
#ifndef ULONG_MAX_32
#define ULONG_MAX_32 4294967295UL
#endif
#define __RES(s, u)\
static inline unsigned u\
U32 pstates_enabled = 0;
U32 cstates_enabled = 0;
CPU_DETAILS cpu;
cpu.max_ratio_as_mfg = 0;
cpu.package_power_limit = 0;
U8 ACPI_COORD_TYPE = ACPI_COORD_TYPE_SW_ANY; // default
ACPI_TABLE_SSDT *SsdtPointer = (void*)0ul;
if (acpidir_found == true)
{
if (checkOem == true)
{
MakeAcpiSgn();
}
struct dirstuff* moduleDir = opendir(dirspec);
while(readdir(moduleDir, (const char**)&name, &flags, &time) >= 0)
{
if((strstr(name, ".aml")) && ((strlen(dirspec)+strlen(name)) < 512))
{
// Some simple verifications to save time in case of those tables simply named as follow:
if ((strncmp(name, "RSDT", 4) == 0) || (strncmp(name, "rsdt", 4) == 0) ||
(strncmp(name, "XSDT", 4) == 0) || (strncmp(name, "xsdt", 4) == 0) ||
(strncmp(name, "RSDP", 4) == 0) || (strncmp(name, "rsdp", 4) == 0))
{
continue;
}
if ((strncmp(name, "FACS", 4) == 0) || (strncmp(name, "facs", 4) == 0)) // FACS is not supported
{
continue;
}
struct dirstuff* AcpiDir = opendir(dirspec);
if (AcpiDir != NULL)
{
if (checkOem == true)
{
MakeAcpiSgn();
}
while(readdir(AcpiDir, (const char**)&name, &flags, &time) >= 0)
{
if((strstr(name, ".aml")) && ((strlen(dirspec)+strlen(name)) < 512))
{
// Some simple verifications to save time in case of those tables simply named as follow:
if ((strncmp(name, "RSDT", 4) == 0) || (strncmp(name, "rsdt", 4) == 0) ||
(strncmp(name, "XSDT", 4) == 0) || (strncmp(name, "xsdt", 4) == 0) ||
(strncmp(name, "RSDP", 4) == 0) || (strncmp(name, "rsdp", 4) == 0))
{
continue;
}
if ((strncmp(name, "FACS", 4) == 0) || (strncmp(name, "facs", 4) == 0)) // FACS is not supported
{
continue;
}
DBG("* Attempting to load acpi table: %s\n", name);
if ( (new_table_list[i]=(U32)loadACPITable(new_table_list,dirspec,name)))
{
if (i < MAX_ACPI_TABLE)
{
i++;
}
else
{
DBG("Max nb of allowed aml files reached, exiting .");
break;
}
}
}
#if DEBUG_ACPI
else
{
printf("Ignoring %s\n", name);
}
#endif
DBG("* Attempting to load acpi table: %s\n", name);
if ( (new_table_list[i]=(U32)loadACPITable(new_table_list,dirspec,name)))
{
if (i < MAX_ACPI_TABLE)
{
i++;
}
else
{
DBG("Max nb of allowed aml files reached, exiting .");
break;
}
}
}
if (i)
{
//sanitize the new tables list
sanitize_new_table_list(new_table_list);
}
#if DEBUG_ACPI
else
{
//move to kernel memory
move_table_list_to_kmem(new_table_list);
printf("Ignoring %s\n", name);
}
#endif
DBG("New ACPI tables Loaded in memory\n");
}
closedir(AcpiDir);
}
if (i)
{
//sanitize the new tables list
sanitize_new_table_list(new_table_list);
//move to kernel memory
move_table_list_to_kmem(new_table_list);
DBG("New ACPI tables Loaded in memory\n");
}
}
}
}
branches/cparm/i386/libsa/strtol.c
7474
7575
7676
77
78
79
80
7781
7882
7983
#include "libsa.h"
#include <limits.h>
#ifndef UQUAD_MAX
#define UQUAD_MAX 0xffffffffffffffffUL
#endif
/*
* Convert a string to a long integer.
*
branches/cparm/i386/util/amlsgn.m
238238
239239
240240
241
242
241243
242244
243245
......
256258
257259
258260
259
260
261
262
263
261264
262265
263266
......
287290
288291
289292
293
294
290295
291296
292297
......
303308
304309
305310
311
312
313
306314
307
308
309315
310316
311317
NSMutableData * mem = [[NSMutableData alloc] initWithContentsOfFile : inStr ];
if (!mem) {
NSLog(@"Error while opening the file : %@ \n",inStr);
//CFRelease(data);
//data = NULL;
goto out;
}
ACPI_TABLE_HEADER * head = (ACPI_TABLE_HEADER *)[mem mutableBytes];
[mem release];
}
goto out;
//CFRelease(data);
//data = NULL;
goto out;
}
}
NSMutableData * mem = [[NSMutableData alloc] initWithContentsOfFile : inStr ];
if (!mem) {
NSLog(@"Error while opening the file : %@\n",inStr);
//CFRelease(data);
//data = NULL;
goto out;
}
ACPI_TABLE_HEADER * head = (ACPI_TABLE_HEADER *)[mem mutableBytes];
[mem release];
}
//CFRelease(data);
//data = NULL;
goto out;
goto out;
}
}
NSLog(@"No UUID entry\n");

Archive Download the corresponding diff file

Revision: 1929