Chameleon

Chameleon Commit Details

Date:2012-03-31 21:28:52 (2 years 6 months ago)
Author:armel cadet-petit
Commit:1913
Parents: 1912
Message:Improved Xcode4.3+ support
Changes:
M/branches/cparm/i386/libsaio/modules.h
M/branches/cparm/i386/libsaio/stringTable.c
M/branches/cparm/i386/libsa/qdivrem.c
M/branches/cparm/i386/modules/HibernateEnabler/resume.c
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
M/branches/cparm/i386/libsaio/platform.c
M/branches/cparm/i386/libsaio/allocate.c
M/branches/cparm/Chameleon.xcodeproj/project.pbxproj
M/branches/cparm/i386/util/amlsgn.m
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.h
M/branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
M/branches/cparm/i386/libsaio/disk.c
M/branches/cparm/i386/libsaio/device_inject.c
M/branches/cparm/i386/libsaio/acpi_tools.c
M/branches/cparm/i386/boot1/Makefile
M/branches/cparm/i386/boot2/options.c
M/branches/cparm/i386/libsaio/xml.c
M/branches/cparm/i386/libsaio/CoreHash.h
M/branches/cparm/i386/libsaio/uthash.h
M/branches/cparm/i386/modules/HibernateEnabler/bmdecompress.c
M/branches/cparm/i386/boot2/graphics.c
M/branches/cparm/i386/modules/GUI/GUI_module.c
M/branches/cparm/i386/boot2/graphics.h
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.c
M/branches/cparm/i386/libsa/bzero.s
M/branches/cparm/CHANGES
M/branches/cparm/i386/libsaio/sys.c
M/branches/cparm/i386/modules/USBFix/usb.c
M/branches/cparm/i386/modules/SMBiosGetters/smbios_decode.c
M/branches/cparm/i386/modules/ACPICodec/acpidecode.c
M/branches/cparm/i386/libsaio/hfs.c
M/branches/cparm/i386/boot2/drivers.c
M/branches/cparm/i386/MakeInc.dir
M/branches/cparm/i386/modules/GraphicsEnabler/gma.c
M/branches/cparm/i386/boot2/mboot.c
M/branches/cparm/i386/cdboot/Makefile
M/branches/cparm/i386/libsaio/saio_types.h
M/branches/cparm/i386/modules/Memory/spd.c
M/branches/cparm/i386/modules/HPET/HPET.c
M/branches/cparm/i386/libsaio/cpu.c
M/branches/cparm/i386/libsaio/lzss.c
M/branches/cparm/i386/libsa/zalloc.c
M/branches/cparm/i386/util/bdmesg.c
M/branches/cparm/i386/boot0/Makefile
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/i386/modules/CPUfreq/CPUfreq.c
M/branches/cparm/i386/modules/RamDiskLoader/ramdisk.c
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/modules/GUI/Makefile
M/branches/cparm/i386/modules/RamDiskLoader/ramdisk.h
M/branches/cparm/i386/modules/GUI/graphic_utils.c
M/branches/cparm/i386/modules/Memory/dram_controllers.c
M/branches/cparm/i386/libsaio/modules.c
M/branches/cparm/i386/libsaio/bootstruct.c
M/branches/cparm/TODO
M/branches/cparm/i386/modules/GUI/picopng.c
M/branches/cparm/i386/modules/Keymapper/Keylayout.c
M/branches/cparm/i386/boot2/boot.h
M/branches/cparm/i386/modules/Memory/mem.c
M/branches/cparm/i386/modules/SMBiosGetters/Makefile

File differences

branches/cparm/TODO
11
22
33
4
5
6
7
48
59
610
TODO List for Chameleon Boot Loader
====================================
- update cpu_intel_amd
- update project with corehash
- Implement the bundles
- Implement a pool allocator, so each module will run and allocate memory in there own pool, de-alloc all allocated memory by the module,
branches/cparm/Chameleon.xcodeproj/project.pbxproj
454454
455455
456456
457
457458
458459
459460
......
964965
965966
966967
968
967969
968970
969971
......
17281730
17291731
17301732
1731
1733
17321734
17331735
17341736
AB43B42A14C3A8080018D529 /* arc4random.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = arc4random.c; sourceTree = "<group>"; };
AB79217514F38CF200F5EB39 /* bootXnu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootXnu.h; sourceTree = "<group>"; };
AB79219214F3919E00F5EB39 /* ModuleHelp.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ModuleHelp.txt; sourceTree = "<group>"; };
ABB4CE7D151E39740053B64E /* lzss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lzss.c; sourceTree = "<group>"; };
ABD521F114F9197900B62550 /* utarray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utarray.h; sourceTree = "<group>"; };
ABD521F214F9197900B62550 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = "<group>"; };
ABD521F314F9197900B62550 /* uterror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uterror.c; sourceTree = "<group>"; };
AB43B2ED14C37E520018D529 /* libsaio */ = {
isa = PBXGroup;
children = (
ABB4CE7D151E39740053B64E /* lzss.c */,
AB43B2EE14C37E520018D529 /* acpi.h */,
AB43B2EF14C37E520018D529 /* acpi_tools.c */,
AB43B2F014C37E520018D529 /* acpi_tools.h */,
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0420;
LastUpgradeCheck = 0430;
};
buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "Chameleon" */;
compatibilityVersion = "Xcode 3.2";
branches/cparm/CHANGES
1
2
13
24
35
- Improved Xcode4.3+ support
- Sync'd LoginToLion with the last Enzo's update (want more about LoginToLion ? please follow or participate to this thread : http://forum.voodooprojects.org/index.php/topic,2125.0.html)
- fixed some bugs
- Added an option to change the acpi detection method (only for acpi 64 users)
branches/cparm/i386/libsaio/xml.c
987987
988988
989989
990
991
992
990
991
992
993
993994
994995
995996
#else
symbol = (SymbolPtr)AllocateBootXMemory(sizeof(Symbol) + 1 + strlen(string));
#endif
if (symbol == 0) //return 0;
stop("NULL symbol!");
if (symbol == 0) {
stop("NULL symbol!");
return 0;
}
// Set the symbol's data.
symbol->refCount = 0;
strcpy(symbol->string, string);
branches/cparm/i386/libsaio/bootstruct.c
131131
132132
133133
134
135
134136
135137
136138
{
bootArgs->Video.v_display = mode;
}
//==========================================================================
// Return the current video mode.
uint32_t getVideoMode(void)
{
return bootArgs->Video.v_display;
branches/cparm/i386/libsaio/hfs.c
649649
650650
651651
652
652
653653
654654
655655
......
658658
659659
660660
661
662
661
662
663663
664664
665665
666666
667
667
668668
669669
670670
......
702702
703703
704704
705
705
706706
707707
708708
......
778778
779779
780780
781
781
782
783
782784
783785
784786
......
786788
787789
788790
789
791
790792
791793
792794
static long ReadCatalogEntry(char * fileName, long dirID,
void * entry, long long * dirIndex)
{
long length;
//long length;
char key[sizeof(HFSPlusCatalogKey)];
HFSCatalogKey *hfsKey = (HFSCatalogKey *)key;
HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key;
if ( gIsHFSPlus )
{
hfsPlusKey->parentID = SWAP_BE32(dirID);
length = strlen(fileName);
if (length > 255) length = 255;
//length = strlen(fileName);
//if (length > 255) length = 255;
utf_decodestr((u_int8_t *)fileName, hfsPlusKey->nodeName.unicode,
&(hfsPlusKey->nodeName.length), 512, OSBigEndian);
} else {
hfsKey->parentID = SWAP_BE32(dirID);
length = strlen(fileName);
long length = strlen(fileName);
if (length > 31) length = 31;
hfsKey->nodeName[0] = length;
strncpy((char *)(hfsKey->nodeName + 1), fileName, length);
BTNodeDescriptor *node;
long nodeSize, result = 0, entrySize = 0;
long curNode, index = 0, lowerBound, upperBound;
char *testKey, *recordData;
char *testKey, *recordData = 0;
// Figure out which tree is being looked at.
if (btree == kBTreeCatalog) {
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) );
}
// Return error if the file was not found.
if (result != 0) { free(nodeBuf); return -1; }
if (result != 0 || !recordData) { free(nodeBuf); return -1; }
if (btree == kBTreeCatalog) {
switch (SWAP_BE16(*(short *)recordData)) {
branches/cparm/i386/libsaio/allocate.c
4848
4949
5050
51
51
5252
5353
5454
strcpy(nameBuf, rangeName);
buffer = malloc(2 * sizeof(uint32_t));
if (buffer == 0) return -1;
if (buffer == 0) {free(nameBuf);return -1;}
buffer[0] = start;
buffer[1] = length;
branches/cparm/i386/libsaio/modules.c
364364
365365
366366
367
368367
369368
370369
......
517516
518517
519518
520
519
521520
522
523
524
525
521
526522
527523
528524
......
550546
551547
552548
553
554
549
550
551
555552
556553
557554
555
558556
559557
560558
......
632630
633631
634632
635
633
636634
637635
638636
......
645643
646644
647645
648
646
649647
650648
651649
......
712710
713711
714712
715
716713
717714
718715
719716
720717
721
718
722719
723
724720
725721
726722
......
731727
732728
733729
734
735730
736731
737732
......
775770
776771
777772
778
779773
780774
781775
......
801795
802796
803797
804
805798
806799
807800
808801
809802
810803
811
812804
813805
814
815806
816807
817808
......
820811
821812
822813
823
824814
825815
826
816
827817
828818
829819
......
832822
833823
834824
835
836825
837826
838827
839
840
828
829
830
831
832
841833
842
834
843835
844
845
836
837
838
839
846840
847841
848842
......
850844
851845
852846
853
854
847
848
849
850
851
852
853
854
855855
856
856
857857
858
859
860
861
858
859
860
861
862
863
862864
863
865
864866
865
867
866868
867869
868
869
870
871
872
873
870874
871875
872876
873
877
874878
879
875880
876
877
878
881
882
883
884
879885
880
886
881887
882888
883889
......
889895
890896
891897
892
893
898
899
900
901
894902
895903
896904
897
898
899
905
900906
901907
902908
......
924930
925931
926932
927
928
933
934
935
929936
930937
931938
......
940947
941948
942949
943
950
951
952
953
944954
945955
946956
947
948
957
958
959
960
961
949962
950963
951964
952965
953966
954
967
955968
956969
970
957971
958972
959973
......
962976
963977
964978
965
979
980
981
966982
967
968983
969984
970985
......
975990
976991
977992
978
979
980
993
994
981995
982996
983997
984998
985999
986
1000
9871001
9881002
989
1003
1004
9901005
991
9921006
1007
9931008
9941009
9951010
9961011
9971012
9981013
999
1000
1001
1014
1015
1016
1017
1018
10021019
10031020
10041021
10051022
10061023
1007
1024
10081025
10091026
1010
1027
1028
1029
10111030
1012
1031
10131032
1014
10151033
10161034
10171035
......
10351053
10361054
10371055
1038
1039
1040
1041
1042
1056
1057
1058
1059
1060
10431061
10441062
10451063
......
10511069
10521070
10531071
1054
1072
10551073
10561074
1057
1075
1076
10581077
1059
1078
10601079
1061
10621080
10631081
10641082
......
10681086
10691087
10701088
1071
10721089
10731090
10741091
......
12501267
12511268
12521269
1270
1271
1272
12531273
12541274
12551275
{
struct segment_command *segCommand = NULL;
struct segment_command_64 *segCommand64 = NULL;
struct dylib_command* dylibCommand = NULL;
struct load_command *loadCommand = NULL;
UInt32 binaryIndex = 0;
UInt16 cmd = 0;
case LC_LOAD_DYLIB:
case LC_LOAD_WEAK_DYLIB ^ LC_REQ_DYLD:
{
dylibCommand = binary + binaryIndex;
struct dylib_command* dylibCommand = binary + binaryIndex;
char* weak_module = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name));
// TODO: verify version
// =dylibCommand->dylib.current_version;
// =dylibCommand->dylib.compatibility_version;
char *name=NULL;
name = newStringWithFormat( "%s.dylib", weak_module);
if (!name) {
break;
}
case LC_ID_DYLIB:
dylibCommand = binary + binaryIndex;
/*moduleName =binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name));
{
/*struct dylib_command* dylibCommand = binary + binaryIndex;
moduleName =binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name));
moduleVersion =dylibCommand->dylib.current_version;
moduleCompat =dylibCommand->dylib.compatibility_version;
*/
}
break;
case LC_DYLD_INFO:
UInt8 bits = 0;
UInt32 index = 0;
int done = 0;
//int done = 0;
unsigned int i = 0;
while(/*!done &&*/ i < size)
{
case REBASE_OPCODE_DONE:
// Rebase complete.
done = 1;
//done = 1;
break;
case REBASE_OPCODE_DO_REBASE_IMM_TIMES:
index = 0;
for (index = 0; index < immediate; ++index)
{
rebase_location(base + segmentAddress, (char*)base, type);
segmentAddress += sizeof(void*);
}
break;
break;
case REBASE_OPCODE_DO_REBASE_ULEB_TIMES:
tmp = 0;
bits = 0;
}
while(rebase_stream[i] & 0x80);
index = 0;
for (index = 0; index < tmp; ++index)
{
//DBG("\tRebasing 0x%X\n", segmentAddress);
}
while(rebase_stream[i] & 0x80);
index = 0;
for (index = 0; index < tmp; ++index)
{
UInt8 immediate = 0;
UInt8 opcode = 0;
UInt8 type = 0;
UInt32 segmentAddress = 0;
UInt32 address = 0;
SInt32 addend = 0;// TODO: handle this
SInt32 libraryOrdinal = 0;
const char* symbolName = NULL;
UInt8 symboFlags = 0;
UInt32 symbolAddr = 0xFFFFFFFF;
// Temperary variables
UInt32 tmp2 = 0;
UInt32 index = 0;
int done = 0;
unsigned int i = 0;
while(/*!done &&*/ i < size)
while(i < size)
{
immediate = bind_stream[i] & BIND_IMMEDIATE_MASK;
opcode = bind_stream[i] & BIND_OPCODE_MASK;
switch(opcode)
{
case BIND_OPCODE_DONE:
done = 1;
break;
case BIND_OPCODE_SET_DYLIB_ORDINAL_IMM:
libraryOrdinal = immediate;
//DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: %d\n", libraryOrdinal);
{
#if DEBUG_MODULES==2
SInt32 libraryOrdinal = immediate;
DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: %d\n", libraryOrdinal);
#endif
break;
}
case BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB:
libraryOrdinal = 0;
bits = 0;
{
#if DEBUG_MODULES==2
SInt32 libraryOrdinal = 0;
UInt8 bits = 0;
do
{
libraryOrdinal |= (bind_stream[++i] & 0x7f) << bits;
}
while(bind_stream[i] & 0x80);
//DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: %d\n", libraryOrdinal);
DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: %d\n", libraryOrdinal);
#else
do
{
i++;
}
while(bind_stream[i] & 0x80);
#endif
break;
}
case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM:
// NOTE: this is wrong, fortunately we don't use it
libraryOrdinal = -immediate;
//DBG("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal);
{
#if DEBUG_MODULES==2
// NOTE: this is wrong, fortunately we don't use it
SInt32 libraryOrdinal = -immediate;
DBG("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal);
#endif
break;
}
case BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM:
symboFlags = immediate;
{
symbolName = (char*)&bind_stream[++i];
i += strlen((char*)&bind_stream[i]);
//DBG("BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: %s, 0x%X\n", symbolName, symboFlags);
#if DEBUG_MODULES==2
UInt8 symbolFlags = immediate;
DBG("BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: %s, 0x%X\n", symbolName, symbolFlags);
#endif
symbolAddr = lookup_all_symbols(NULL ,symbolName);
break;
}
case BIND_OPCODE_SET_TYPE_IMM:
{
// Set bind type (pointer, absolute32, pcrel32)
type = immediate;
//DBG("BIND_OPCODE_SET_TYPE_IMM: %d\n", type);
#if DEBUG_MODULES==2
UInt8 type = immediate;
DBG("BIND_OPCODE_SET_TYPE_IMM: %d\n", type);
#endif
break;
}
case BIND_OPCODE_SET_ADDEND_SLEB:
addend = 0;
bits = 0;
while(bind_stream[i] & 0x80);
if(!(bind_stream[i-1] & 0x40)) addend *= -1;
//DBG("BIND_OPCODE_SET_ADDEND_SLEB: %d\n", addend);
#if DEBUG_MODULES==2
DBG("BIND_OPCODE_SET_ADDEND_SLEB: %d\n", addend);
#endif
break;
case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB:
{
segmentAddress = 0;
{
// Locate address
struct segment_command* segCommand = NULL;// NOTE: 32bit only
}while(bind_stream[i] & 0x80);
segmentAddress += tmp;
//DBG("BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: 0x%X\n", segmentAddress);
#if DEBUG_MODULES==2
DBG("BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: 0x%X\n", segmentAddress);
#endif
break;
}
case BIND_OPCODE_ADD_ADDR_ULEB:
while(bind_stream[i] & 0x80);
segmentAddress += tmp;
//DBG("BIND_OPCODE_ADD_ADDR_ULEB: 0x%X\n", segmentAddress);
#if DEBUG_MODULES==2
DBG("BIND_OPCODE_ADD_ADDR_ULEB: 0x%X\n", segmentAddress);
#endif
break;
case BIND_OPCODE_DO_BIND:
//DBG("BIND_OPCODE_DO_BIND\n");
if(symbolAddr != 0xFFFFFFFF)
#if DEBUG_MODULES==2
DBG("BIND_OPCODE_DO_BIND\n");
#endif
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
else if(symbolName && (strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0))
{
printf("Unable to bind symbol %s needed by %s\n", symbolName, module);
getc();
goto error;
}
break;
case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB:
//DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB\n");
#if DEBUG_MODULES==2
DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB\n");
#endif
// Read in offset
tmp = 0;
bits = 0;
}
while(bind_stream[i] & 0x80);
if(symbolAddr != 0xFFFFFFFF)
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
else if(symbolName && (strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0))
{
printf("Unable to bind symbol %s needed by %s\n", symbolName, module);
goto error;
getc();
goto error;
}
segmentAddress += tmp + sizeof(void*);
break;
case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED:
//DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED\n");
if(symbolAddr != 0xFFFFFFFF)
#if DEBUG_MODULES==2
DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED\n");
#endif
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
else if(symbolName && (strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0))
{
printf("Unable to bind symbol %s needed by %s\n", symbolName, module);
goto error;
getc();
goto error;
}
segmentAddress += (immediate * sizeof(void*)) + sizeof(void*);
segmentAddress += (immediate * sizeof(void*)) + sizeof(void*);
break;
case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB:
}
while(bind_stream[i] & 0x80);
//DBG("BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0x%X 0x%X\n", tmp, tmp2);
if(symbolAddr != 0xFFFFFFFF)
#if DEBUG_MODULES==2
DBG("BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0x%X 0x%X\n", tmp, tmp2);
#endif
if(symbolAddr != 0xFFFFFFFF)
{
for(index = 0; index < tmp; index++)
{
segmentAddress += tmp2 + sizeof(void*);
}
}
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
else if(symbolName && (strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0))
{
printf("Unable to bind symbol %s needed by %s\n", symbolName, module);
goto error;
getc();
goto error;
}
}
break;
default:
break;
}
return EFI_SUCCESS;
error:
getc();
return EFI_NOT_FOUND;
}
unsigned int module_start = 0xFFFFFFFF;
UInt32 symbolIndex = 0;
if (!symtabCommand) {
return 0xFFFFFFFF;
}
char* symbolString = base + (char*)symtabCommand->stroff;
//char* symbolTable = base + symtabCommand->symoff;
if(!is64)
branches/cparm/i386/libsaio/modules.h
8282
8383
8484
85
85
8686
8787
8888
VOID load_all_bundles(void);
EFI_STATUS is_module_loaded(const char* name);
VOID module_loaded(const char* name/*, UInt32 version, UInt32 compat*/);
VOID module_loaded(const char* name);
long long add_symbol(char* module,char* symbol, long long addr, char is64);
branches/cparm/i386/libsaio/device_inject.c
9292
9393
9494
95
95
96
97
9698
99
97100
98101
99102
......
153156
154157
155158
159
156160
157161
158162
......
187191
188192
189193
190
194
195
191196
192197
193198
return NULL;
}
device = malloc(sizeof(struct DevPropDevice));
if (!device) {
return NULL;
}
if (strncmp(path, pciroot_string, strlen(pciroot_string))) {
free(device);
printf("ERROR parsing device path\n");
return NULL;
}
if(!numpaths)
{
free(device);
return NULL;
}
{
if((string->entries = (struct DevPropDevice**)malloc(sizeof(device)))== NULL)
{
return 0;
free(device);
return NULL;
}
}
branches/cparm/i386/libsaio/sys.c
259259
260260
261261
262
262
263263
264264
265265
......
846846
847847
848848
849
850
849
851850
852851
853852
......
859858
860859
861860
861
862862
863863
864864
......
874874
875875
876876
877
877
878878
879879
880880
......
883883
884884
885885
886
887886
888887
889
888
890889
891890
892
893
891
892
893
894
894895
895896
896
897
897898
898
899
899
900
901
902
900903
904
905
906
907
908
901909
902
903910
904911
905912
906
907
908913
909914
910
911
915
916
912917
913
914918
915
916
917
918
919
920
919921
920922
921923
......
962964
963965
964966
965
967
966968
967969
968970
......
10331035
10341036
10351037
1036
1038
10371039
10381040
10391041
// generate the text: e.g. 5EB1869F-C4FA-3502-BDEB-3B8ED5D87292
i = 0; fmtbase = 0;
fmtbase = 0;
for(fmtidx = 0; fmtidx < sizeof(uuidfmt); fmtidx++) {
for(i=0; i < uuidfmt[fmtidx]; i++) {
uint8_t byte = mdresult[fmtbase+i];
BVRef selectBootVolume( BVRef chain )
{
bool filteredChain = false;
bool foundPrimary = false;
BVRef bvr, bvr1 = 0, bvr2 = 0;
BVRef bvr = 0;
if (chain->filtered) filteredChain = true;
if ( bvr->part_no == multiboot_partition && bvr->biosdev == gBIOSDev )
return bvr;
#endif
/*
* Checking "Default Partition" key in system configuration - use format: hd(x,y), the volume UUID or label -
* to override the default selection.
}
free(val);
}
/*
* Scannig the volume chain backwards and trying to find
* a HFS+ volume with valid boot record signature.
*/
for ( bvr = chain; bvr; bvr = bvr->next )
{
if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) foundPrimary = true;
// zhell -- Undo a regression that was introduced from r491 to 492.
// if gBIOSBootVolume is set already, no change is required
if ( bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume)
if ( (bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume))
&& gBIOSBootVolume
&& (!filteredChain || (filteredChain && bvr->visible))
&& bvr->biosdev == gBIOSDev )
bvr2 = bvr;
&& (bvr->biosdev == gBIOSDev) )
{
goto out; /* (1) */
}
// zhell -- if gBIOSBootVolume is NOT set, we use the "if" statement
// from r491,
if ( bvr->flags & kBVFlagBootable
if ( (bvr->flags & kBVFlagBootable)
&& ! gBIOSBootVolume
&& bvr->biosdev == gBIOSDev )
bvr2 = bvr;
&& (bvr->biosdev == gBIOSDev) )
{
goto out; /* (2) */
}
}
/*
* cparm:
* For cases (1) and (2), there is no need to continue the loop since only one biosdev can be the gBIOSDev
*
*/
/*
* Use the standrad method for selecting the boot volume.
*/
if (foundPrimary)
{
for ( bvr = chain; bvr; bvr = bvr->next )
{
if ( bvr->flags & kBVFlagNativeBoot && bvr->biosdev == gBIOSDev ) bvr1 = bvr;
if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) bvr2 = bvr;
if ( (bvr->flags & kBVFlagNativeBoot) && (bvr->biosdev == gBIOSDev) ) {break;}
if ( (bvr->flags & kBVFlagPrimary) && (bvr->biosdev == gBIOSDev) ) {break;}
}
}
bvr = bvr2 ? bvr2 :
bvr1 ? bvr1 : chain;
return bvr;
out:
return bvr ? bvr : chain;
}
//==========================================================================
{
const char * cp;
BVRef bvr = gRootVolume;
int biosdev = (int)get_env(envgBIOSDev);
//int biosdev = (int)get_env(envgBIOSDev);
// Search for left parenthesis in the path specification.
for ( ; *cp && *cp != RP; cp++) /* LOOP */;
if (*cp == RP) cp++;
biosdev = dp->biosdev + unit;
int biosdev = dp->biosdev + unit;
bvr = newBootVolumeRef(biosdev, part);
if(bvr == NULL)
branches/cparm/i386/libsaio/platform.c
540540
541541
542542
543
543
544544
545545
rtc_time(&rtctime);
return newStringWithFormat("%02d/%02d/%04d %02d:%02d:%02d",rtctime.Month,rtctime.Day,rtctime.Year,
rtctime.Hour,rtctime.Minute,rtctime.Second));
rtctime.Hour,rtctime.Minute,rtctime.Second);
}
#endif
branches/cparm/i386/libsaio/cpu.c
779779
780780
781781
782
783
782
784783
785784
786785
786
787
787788
788789
789790
790
791
791792
792793
793794
......
808809
809810
810811
811
812812
813
814
813815
814816
815817
......
832834
833835
834836
835
837
836838
837839
838840
......
932934
933935
934936
935
937
936938
937939
938940
Model == CPUID_MODEL_SANDYBRIDGE ||
Model == CPUID_MODEL_JAKETOWN))
{
uint8_tbus_ratio_max = 0, bus_ratio_min = 0;
uint32_tmax_ratio = 0;
uint8_tbus_ratio_max = 0;
uint64_tflex_ratio = 0;
msr = rdmsr64(MSR_PLATFORM_INFO);
#if DEBUG_CPU
uint32_tmax_ratio = 0, bus_ratio_min = 0;
DBG("msr(%d): platform_info %08x\n", __LINE__, msr & 0xffffffff);
#endif
bus_ratio_max = (msr >> 8) & 0xff;
bus_ratio_min = (msr >> 40) & 0xff;
//bus_ratio_min = (msr >> 40) & 0xff;
msr = rdmsr64(MSR_FLEX_RATIO);
#if DEBUG_CPU
DBG("msr(%d): flex_ratio %08x\n", __LINE__, msr & 0xffffffff);
/* Clear bit 16 (evidently the
presence bit) */
wrmsr64(MSR_FLEX_RATIO, (msr & 0xFFFFFFFFFFFEFFFFULL));
msr = rdmsr64(MSR_FLEX_RATIO);
#if DEBUG_CPU
msr = rdmsr64(MSR_FLEX_RATIO);
DBG("Unusable flex ratio detected. MSR Patched to %08x\n", msr & 0xffffffff);
#endif
}
{
//msr = rdmsr64(MSR_TURBO_RATIO_LIMIT);
CPUFreq = bus_ratio_max * FSBFreq;
max_ratio = bus_ratio_max * 10;
//max_ratio = bus_ratio_max * 10;
}
else
{
}
/* Mobile CPU ? */
//Slice
isMobile = 0;
//isMobile = 0;
switch (Model)
{
case 0x0D:
branches/cparm/i386/libsaio/disk.c
201201
202202
203203
204
204205
205206
206207
......
821822
822823
823824
824
825
826
827
828
829
830
825831
826832
827
828
829
830
833
834
835
836
831837
832838
833839
......
10391045
10401046
10411047
1042
1048
10431049
10441050
10451051
......
13391345
13401346
13411347
1342
1348
13431349
13441350
13451351
13461352
13471353
13481354
1349
1355
13501356
13511357
13521358
......
15501556
15511557
15521558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
15531588
15541589
15551590
......
15731608
15741609
15751610
1576
1577
1611
15781612
1579
1613
15801614
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1615
1616
1617
1618
1619
1620
1621
1622
1623
16021624
16031625
16041626
......
16681690
16691691
16701692
1671
16721693
1694
16731695
16741696
16751697
16761698
16771699
1678
16791700
16801701
16811702
static TagPtr XMLGetElementWithID( TagPtr dict, const char* id );
static bool getOSVersion(BVRef bvr, char *str);
static bool CheckDarwin(BVRef bvr);
static bool getOSInstallVersion(const char *dirSpec, char *str, config_file_t *systemVersion);
//==========================================================================
spc = 1;
}
#endif
map = (struct DiskBVMap *) malloc( sizeof(*map) );
if ( !map )
{
return NULL;
}
do {
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
if ( map )
{
//map = (struct DiskBVMap *) malloc( sizeof(*map) );
//if ( map )
//{
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
else free( booterUFS );
}
#endif
}
//}
} while (0);
/*
// Determine whether the partition entry size is valid.
UInt64 gptBlock = 0;
UInt32 gptCheck = 0;
//UInt32 gptCheck = 0;
UInt32 gptCount = 0;
UInt32 gptID = 0;
gpt_ent * gptMap = 0;
UInt32 gptSize = 0;
gptBlock = OSSwapLittleToHostInt64(headerMap->hdr_lba_table);
gptCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_table);
//gptCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_table);
gptCount = OSSwapLittleToHostInt32(headerMap->hdr_entries);
gptSize = OSSwapLittleToHostInt32(headerMap->hdr_entsz);
return tmp;
}
static bool getOSInstallVersion(const char *dirSpec, char *str, config_file_t *systemVersion)
{
if (!loadConfigFile(dirSpec, systemVersion))
{
TagPtr pkg_p = XMLCastArray(XMLGetProperty(systemVersion->dictionary, (const char*)"Packages"));
if (pkg_p)
{
char *version = NULL;
version = XMLCastString(XMLGetProperty(
XMLGetElementWithID(pkg_p,
"com.apple.mpkg.OSInstall"),
(const char*)"Version"));
if (version && strlen(version) >= 4)
{
*str = '\0';
strncat(str, version, 4);
return true;
}
}
}
return false;
}
static bool getOSVersion(BVRef bvr, char *str)
{
bool valid = false;
}
else
{
/* Much clean */
sprintf(dirSpec, "hd(%d,%d)/Mac OS X Install Data/index.sproduct", BIOS_DEV_UNIT(bvr), bvr->part_no);
sprintf(dirSpec, "hd(%d,%d)/OS X Install Data/index.sproduct", BIOS_DEV_UNIT(bvr), bvr->part_no); // 10.8
if (!loadConfigFile(dirSpec, &systemVersion))
if (!getOSInstallVersion(dirSpec, str, &systemVersion))
{
TagPtr pkg_p = XMLCastArray(XMLGetProperty(systemVersion.dictionary, (const char*)"Packages"));
if (pkg_p)
{
char *version = NULL;
version = XMLCastString(XMLGetProperty(
XMLGetElementWithID(pkg_p,
"com.apple.mpkg.OSInstall"),
(const char*)"Version"));
if (version && strlen(version) >= 4)
{
*str = '\0';
strncat(str, version, 4);
return true;
}
}
}
sprintf(dirSpec, "hd(%d,%d)/Mac OS X Install Data/index.sproduct", BIOS_DEV_UNIT(bvr), bvr->part_no); // 10.7
if (!getOSInstallVersion(dirSpec, str, &systemVersion))
return false;
else
return true;
}
else return true;
}
}
static void scanFSLevelBVRSettings(BVRef chain)
{
BVRef bvr;
int ret;
#ifdef BOOT_HELPER_SUPPORT
int ret;
char label[BVSTRLEN];
int fh, fileSize, error;
#endif
for (bvr = chain; bvr; bvr = bvr->next)
{
ret = -1;
#ifdef BOOT_HELPER_SUPPORT
error = 0;
branches/cparm/i386/libsaio/acpi_tools.c
204204
205205
206206
207
207
208208
209209
210210
......
216216
217217
218218
219
219
220220
221221
222222
getIntForKey(kAcpiMethod, &method, DEFAULT_BOOT_CONFIG);
switch (method) {
case 0x2000:
case 0x2:
{
for (index = 0; index < num_tables; index++) {
U64 ptr = xsdt->TableOffsetEntry[index];
}
break;
}
case 0x1000:
case 0x1:
default:
{
ACPI_TABLE_HEADER *table = (ACPI_TABLE_HEADER *) xsdt->TableOffsetEntry;
branches/cparm/i386/libsaio/CoreHash.h
1313
1414
1515
16
16
1717
1818
1919
......
3939
4040
4141
42
42
4343
44
45
46
47
48
49
4450
4551
4652
4753
4854
49
55
5056
5157
5258
......
8086
8187
8288
89
8390
8491
8592
......
155162
156163
157164
165
158166
159167
160168
......
191199
192200
193201
202
194203
195204
196205
//CoreHash Header and reserved fields
#define CoreHashHeader \
char name[10]; \
char *name; \
int id; \
UT_hash_handle hh; /* makes this structure hashable */
if (!var) \
return NULL; \
\
strlcpy(var->name, name, sizeof(var->name));\
bzero(var,sizeof(struct HObj)); \
\
var->name = newString(name); \
if (!var->name) { \
free(var); \
return NULL; \
} \
\
if (setjmp(h_buf_error) == -1) { \
\
free(var); \
return NULL; \
} else { \
HASH_ADD_STR( *container, name, var ); \
HASH_ADD_KEYPTR( hh, *container, name, strlen(name), var ); \
\
} \
return var;\
} else { \
HASH_DEL( container, var); \
} \
if (var->name) free(var->name); \
free(var); \
}
} else {\
HASH_DEL( container, var);\
}\
if (var->name) free(var->name); \
free(var);\
}
} else { \
HASH_ITER(hh, container, current_var, tmp) { \
HASH_DEL(container,current_var); \
if (current_var->name) free(current_var->name); \
free(current_var); \
} \
} \
branches/cparm/i386/libsaio/uthash.h
646646
647647
648648
649
649650
650651
651652
_he_hh_nxt = _he_thh->hh_next; \
HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \
_he_newbkt = &(_he_new_buckets[ _he_bkt ]); \
if (!_he_newbkt) { uthash_fatal( "out of memory"); } \
if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \
tbl->nonideal_items++; \
_he_newbkt->expand_mult = _he_newbkt->count / \
branches/cparm/i386/libsaio/stringTable.c
3434
3535
3636
37
38
39
40
3741
3842
3943
......
576580
577581
578582
583
584
585
586
579587
580588
581589
......
606614
607615
608616
609
617
610618
611619
612620
......
614622
615623
616624
625
626
617627
618
628
619629
620
630
631
621632
622633
623634
......
635646
636647
637648
638
639
649
640650
641651
642652
643653
644654
645
655
646656
647657
648658
649659
650660
651661
652
662
663
653664
654
665
666
655667
656668
657669
......
688700
689701
690702
691
703
692704
693705
694706
695707
696708
697709
698
710
711
699712
713
700714
701715
702716
......
734748
735749
736750
737
751
738752
739753
740754
741755
742756
743757
744
758
759
745760
761
746762
747763
748764
......
764780
765781
766782
767
783
768784
769785
770786
......
785801
786802
787803
788
804
805
789806
790
791
807
808
809
792810
793811
794812
......
798816
799817
800818
801
819
820
802821
803
822
823
804824
805825
806826
......
817837
818838
819839
820
840
841
821842
822843
823
844
845
824846
825847
826848
......
830852
831853
832854
833
855
856
834857
835
858
859
836860
837861
838862
......
847871
848872
849873
850
874
875
851876
852
877
878
853879
854880
855881
static char * AllocInitStringWithLength(const char * oldString, int len);
static char * AllocInitZeroEndedStringWithLength(const char * oldString, int len);
#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
#define ASSERT_CONFIG \
if (config == DEFAULT_BOOT_CONFIG) \
config = &bootInfo->bootConfig ; \
char *configBuffer;
configBuffer = malloc(strlen(buffer)+1);
if (!configBuffer) {
return -1;
}
strcpy(configBuffer, buffer);
while (1)
*/
int loadConfigFile (const char *configFile, config_file_t *config)
{
int fd, count;
int fd, count, fixedsize;
ASSERT_CONFIG
return -1;
}
fixedsize = MIN(file_size(fd),IO_CONFIG_DATA_SIZE);
// read file
count = read(fd, config->plist, IO_CONFIG_DATA_SIZE);
count = read(fd, config->plist, fixedsize);
close(fd);
if (count != fixedsize) return -1;
// build xml dictionary
return ParseXMLFile(config->plist, &config->dictionary);
}
"bt(0,0)/Extra/com.apple.Boot.plist",
"rd(0,0)/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk
"/Extra/org.chameleon.Boot.plist", // Add compatibility with the trunk
"bt(0,0)/Extra/org.chameleon.Boot.plist" // Add compatibility with the trunk
"bt(0,0)/Extra/org.chameleon.Boot.plist" // Add compatibility with the trunk
};
config_file_t *config = &bootInfo->bootConfig;
int i,fd, count, ret=-1;
int i, fd, count, ret=-1, fixedsize;
for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++)
{
if ((fd = open(dirspec[i])) >= 0)
{
// read file
count = read(fd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(fd),IO_CONFIG_DATA_SIZE);
count = read(fd, config->plist, fixedsize);
close(fd);
if (count != fixedsize) continue;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
safe_set_env(envSysConfigValid,true);
config_file_t *config = &bootInfo->overrideConfig;
int i,fd, count, ret=-1;
int i, fd, count, ret=-1, fixedsize;
for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++)
{
if ((fd = open(dirspec[i])) >= 0)
{
// read file
count = read(fd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(fd),IO_CONFIG_DATA_SIZE);
count = read(fd, config->plist, fixedsize);
close(fd);
if (count != fixedsize) continue;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
config_file_t *config = &bootInfo->SystemConfig;
int i,fd, count, ret=-1;
int i, fd, count, ret=-1, fixedsize;
for(i = 0; (unsigned)i< sizeof(dirspec)/sizeof(dirspec[0]); i++)
{
if ((fd = open(dirspec[i])) >= 0)
{
// read file
count = read(fd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(fd),IO_CONFIG_DATA_SIZE);
count = read(fd, config->plist, fixedsize);
close(fd);
if (count != fixedsize) continue;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
*/
int loadHelperConfig(void)
{
int rfd, pfd, sfd, count, ret=-1;
int rfd, pfd, sfd, count, ret=-1, fixedsize;
char *dirspec[] = {
"/com.apple.boot.P/Library/Preferences/SystemConfiguration/com.apple.Boot.plist",
if(sfd >= 0)
{
// Use sfd
count = read(sfd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(sfd),IO_CONFIG_DATA_SIZE);
count = read(sfd, config->plist, fixedsize);
close(sfd);
close(pfd);
close(pfd);
if (count != fixedsize) return -1;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
safe_set_env(envSysConfigValid,true);
else
{
// used pfd
count = read(pfd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(pfd),IO_CONFIG_DATA_SIZE);
count = read(pfd, config->plist, fixedsize);
close(pfd);
if (count != fixedsize) return -1;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
safe_set_env(envSysConfigValid,true);
if(pfd >= 0)
{
// use sfd
count = read(pfd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(pfd),IO_CONFIG_DATA_SIZE);
count = read(pfd, config->plist, fixedsize);
close(pfd);
close(rfd);
if (count != fixedsize) return -1;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
safe_set_env(envSysConfigValid,true);
else
{
// use rfd
count = read(rfd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(rfd),IO_CONFIG_DATA_SIZE);
count = read(rfd, config->plist, fixedsize);
close(rfd);
if (count != fixedsize) return -1;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
safe_set_env(envSysConfigValid,true);
if(sfd >= 0)
{
// use sfd
count = read(sfd, config->plist, IO_CONFIG_DATA_SIZE);
fixedsize = MIN(file_size(sfd),IO_CONFIG_DATA_SIZE);
count = read(sfd, config->plist, fixedsize);
close(sfd);
if (count != fixedsize) return -1;
// build xml dictionary
ParseXMLFile(config->plist, &config->dictionary);
safe_set_env(envSysConfigValid,true);
branches/cparm/i386/libsaio/saio_types.h
7979
8080
8181
82
82
8383
8484
8585
#define kSystemType"SystemType"/* fake_efi.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kDefaultPartition"Default Partition"/* sys.c */
#define kAcpiMethod"nacpi"// 0x2000 (= method 2) for some machines that may hang on acpi 2 (aka acpi 64 bit) detection (replace the old kUnsafeACPI "UnsafeACPI")
#define kAcpiMethod"Acpi2Method"// 2 (= method 2) for some machines that may hang on acpi 2 (aka acpi 64 bit) detection (replace the old kUnsafeACPI "UnsafeACPI")
#define PLATFORM_NAME_LEN 64
#define ROOT_PATH_LEN 256
branches/cparm/i386/libsaio/lzss.c
5959
6060
6161
62
6362
6463
6564
unsigned int flags;
dst = dststart;
srcend = src + srclen;
for (i = 0; i < N - F; i++)
text_buf[i] = ' ';
r = N - F;
branches/cparm/i386/boot0/Makefile
22
33
44
5
5
66
77
88
DIR = boot0
include ../MakePaths.dir
NASM = /Developer/usr/bin/nasm
NASM = /usr/bin/nasm
INSTALLDIR = $(DSTROOT)/usr/standalone/i386
DIRS_NEEDED = $(SYMROOT)
branches/cparm/i386/MakeInc.dir
5959
6060
6161
62
62
6363
6464
65
65
6666
6767
68
68
6969
7070
7171
#$(AS) -o $(OBJROOT)/$@ $(OBJROOT)/$*.o2
.s.o:
cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
gcc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
boot2.o:
cc $(CPPFLAGS) -Wa,-n -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) boot2.s
gcc $(CPPFLAGS) -Wa,-n -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) boot2.s
$(OBJROOT)/%.o: %.s
cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
gcc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
$(DIRS_NEEDED) $(INSTALLDIR) $(SRCROOT):
$(MKDIRS) $@
branches/cparm/i386/boot1/Makefile
55
66
77
8
8
99
1010
1111
INSTALLDIR = $(DSTROOT)/usr/standalone/i386
DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
NASM = /Developer/usr/bin/nasm
NASM = /usr/bin/nasm
VERSIONED_FILES = boot1h
branches/cparm/i386/boot2/graphics.c
3333
3434
3535
36
37
38
39
40
4136
4237
4338
......
4843
4944
5045
51
46
5247
5348
5449
5550
56
51
52
5753
5854
5955
......
113109
114110
115111
116
117112
118113
119114
......
378373
379374
380375
381
376
377
378
379
380
381
382
383
384
385
386
387
382388
383
384
385
386
387
388
389
390389
391390
392391
......
519518
520519
521520
522
521
523522
524
525
526
527
528
529
530
523
524
525
526
527
528
529
530
531
532
533
531534
532535
533536
......
566569
567570
568571
569
572
570573
571574
572575
......
634637
635638
636639
637
638
639
640
641
642
643
644
645
640
#include "bootstruct.h"
#include "modules.h"
int previewTotalSectors = 0;
int previewLoadedSectors = 0;
uint8_t *previewSaveunder = 0;
#define VIDEO(x) (bootArgs->Video.v_ ## x)
#define MIN(x, y) ((x) < (y) ? (x) : (y))
unsigned short rows,
unsigned char bitsPerPixel );
static int initGraphicsMode ();
static int initGraphicsMode (void);
static unsigned long lookUpCLUTIndex( unsigned char index,
unsigned char depth );
#ifndef OPTION_ROM
static void * stosl(void * dst, long val, long len);
int
__convertImage( unsigned short width,
unsigned short height,
data += width * pixelBytes;
}
}
#endif
//==========================================================================
// getVESAModeWithProperties
minfo.BitsPerPixel ) >> 3;
// Update KernBootStruct using info provided by the selected
// VESA mode.
// VESA mode.
Boot_VideoVideo;/* Video Information */
Video.v_display = GRAPHICS_MODE;
Video.v_width = minfo.XResolution;
Video.v_height = minfo.YResolution;
Video.v_depth = minfo.BitsPerPixel;
Video.v_rowBytes = minfo.BytesPerScanline;
Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr);
setBootArgsVideoStruct(&Video);
bootArgs->Video.v_display = GRAPHICS_MODE;
bootArgs->Video.v_width = minfo.XResolution;
bootArgs->Video.v_height = minfo.YResolution;
bootArgs->Video.v_depth = minfo.BitsPerPixel;
bootArgs->Video.v_rowBytes = minfo.BytesPerScanline;
bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr);
}
while ( 0 );
}
// Update KernBootStruct using info provided by the selected
// VESA mode.
// VESA mode.
bootArgs->Video.v_display = VGA_TEXT_MODE;
bootArgs->Video.v_baseAddr = 0xb8000;
bootArgs->Video.v_width = minfo.XResolution;
bootArgs->Video.v_height = minfo.YResolution;
bootArgs->Video.v_depth = 8;
bootArgs->Video.v_rowBytes = 0x8000;
Boot_VideoVideo;/* Video Information */
Video.v_display = VGA_TEXT_MODE;
Video.v_width = 0xb8000;
Video.v_height = minfo.XResolution;
Video.v_depth = minfo.YResolution;
Video.v_rowBytes = 8;
Video.v_baseAddr = 0x8000;
setBootArgsVideoStruct(&Video);
return errSuccess; // always return success
}
return count;
}
static int initGraphicsMode ()
static int initGraphicsMode (void)
{
unsigned long params[4];
int count;
setVESATextMode( params[0], params[1], 4 );
bootArgs->Video.v_display = VGA_TEXT_MODE;
}
}
//==========================================================================
// Return the current video mode, VGA_TEXT_MODE or GRAPHICS_MODE.
inline int __getVideoMode(void)
{
return bootArgs->Video.v_display;
}
}
branches/cparm/i386/boot2/boot.c
194194
195195
196196
197
197
198198
199199
200200
......
218218
219219
220220
221
221
222222
223223
224224
225225
226
226
227227
228228
229229
......
233233
234234
235235
236
236
237237
238238
239239
......
244244
245245
246246
247
247
248248
249
249
250250
251251
252252
......
284284
285285
286286
287
287
288288
289289
290290
......
324324
325325
326326
327
327
328328
329329
330330
......
357357
358358
359359
360
360
361361
362362
363363
......
380380
381381
382382
383
383
384384
385385
386386
......
426426
427427
428428
429
429
430430
431431
432432
......
442442
443443
444444
445
445
446446
447447
448448
449449
450450
451
452451
453452
454453
......
456455
457456
458457
459
458
460459
461460
461
462462
463463
464
464465
466
465467
466
468
467469
468
470
469471
470472
471473
......
473475
474476
475477
476
478
477479
478480
479481
480482
481
482483
483484
484485
......
493494
494495
495496
496
497
497498
498499
499500
......
517518
518519
519520
520
521
521522
522523
523524
524525
525526
526
527527
528
528529
529530
530531
......
540541
541542
542543
543
544
544545
545
546546
547
547548
548549
549550
......
556557
557558
558559
559
560
560561
561562
562563
......
576577
577578
578579
579
580
580581
581582
582583
583584
584
585
585586
586587
587588
......
595596
596597
597598
598
599
599600
600601
601602
......
624625
625626
626627
627
628
628629
629630
630631
......
632633
633634
634635
635
636
636637
637638
638639
......
648649
649650
650651
651
652
652653
653654
654
655
655
656
656657
657
658
658659
659660
660661
......
683684
684685
685686
686
687
687688
688689
689
690
690691
691692
692693
......
705706
706707
707708
708
709
709710
710711
711712
......
713714
714715
715716
716
717
717718
718719
719720
......
723724
724725
725726
726
727
727728
728729
729730
......
735736
736737
737738
738
739
739740
740741
741742
742743
743
744
744745
745746
746747
......
810811
811812
812813
813
814
814815
815816
816817
......
837838
838839
839840
840
841
841842
842843
843844
......
883884
884885
885886
886
887
887888
888889
889890
......
891892
892893
893894
894
895
895896
896897
897898
......
10571058
10581059
10591060
1060
1061
10611062
10621063
10631064
1064
1065
10651066
10661067
1067
1068
10681069
10691070
10701071
......
12131214
12141215
12151216
1216
1217
12171218
12181219
12191220
{
entry_t kernelEntry;
int ret;
bootArgs->kaddr = bootArgs->ksize = 0;
if(gBootVolume->OSVersion[3] <= '6')
}
execute_hook("ExecKernel", (void*)binary, NULL, NULL, NULL, NULL, NULL);
ret = DecodeKernel(binary,
&kernelEntry,
(char **) &bootArgs->kaddr,
(int *)&bootArgs->ksize );
if ( ret != 0 )
return ret;
{
LoadDrivers("/");
}
if (gErrors)
{
printf("Errors encountered while starting up the computer.\n");
}
execute_hook("md0Ramdisk", NULL, NULL, NULL, NULL, NULL, NULL);
setupFakeEfi();
verbose("Starting Darwin %s\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64");
#ifdef NBP_SUPPORT
// Cleanup the PXE base code.
}
//debug_platform_env();
if ((execute_hook("GUI_ExecKernel", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS)) // (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
#if UNUSED
}
#endif
}
finalizeEFIConfigTable();
setupBooterLog();
#include "apic.h"
IMPS_LAPIC_WRITE(LAPIC_LVT1, LAPIC_ICR_DM_NMI);
#endif
switch (gBootVolume->OSVersion[3]) {
case '4':
case '5':
getc();
break;
}
// Should not be reached
return 0;
// the base code will result in a hang or kernel panic.
gUnloadPXEOnExit = true;
#endif
// Setup VGA text mode.
// It's unsafe to call setVideoMode() before the
// bootargs is initialized, we call video_mode() instead.
init_ut_fnc();
arc4_init();
initBooterLog();
// Initialize boot info structure.
initKernBootStruct();
// Scan and record the system's hardware information.
scan_platform();
set_env(envShouldboot, false);
set_env(envkCache, (uint32_t)gBootKernelCacheFile);
set_env(envMKextName, (uint32_t)gMKextName);
InitBootPrompt();
// First get info for boot volume.
scanBootVolumes(BIOSDev, 0);
bvChain = getBVChainForBIOSDev(BIOSDev);
setBootGlobals(bvChain);
// Load Booter boot.plist config file
status = loadBooterConfig();
/*status =*/ loadBooterConfig();
{
bool isServer = false;
set_env(envIsServer , isServer);
}
{
bool quiet = false;
if (getBoolForKey(kQuietBootKey, &quiet, DEFAULT_BOOT_CONFIG) && quiet)
{
long gBootMode = kBootModeNormal;
gBootMode |= kBootModeQuiet;
}
}
firstRun = false;
}
}
{
#ifndef OPTION_ROM
bool ScanSingleDrive = false;
scanDisks();
#endif
}
}
// Create a separated bvr chain using the specified filters.
bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &devcnt);
safe_set_env(envgDeviceCount,devcnt);
gBootVolume = selectBootVolume(bvChain);
{
// Loading preboot ramdisk if exists.
execute_hook("loadPrebootRAMDisk", NULL, NULL, NULL, NULL, NULL, NULL);
#ifndef OPTION_ROM
{
// Disable rescan option by default
}
safe_set_env(envgEnableCDROMRescan, CDROMRescan);
}
printf(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
getc();
#endif
setBootGlobals(bvChain);
// Display the GUI
execute_hook("GUI_Display", NULL, NULL, NULL, NULL, NULL, NULL);
// Parse args, load and start kernel.
while (1) {
const char *val;
#endif
int ret = -1;
void *binary = (void *)kLoadAddr;
// additional variable for testing alternate kernel image locations on boot helper partitions.
char bootFileSpec[512];
bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &devcnt);
safe_set_env(envgDeviceCount,devcnt);
setBootGlobals(bvChain);
}
continue;
// Other status (e.g. 0) means that we should proceed with boot.
execute_hook("GUI_PreBoot", NULL, NULL, NULL, NULL, NULL, NULL);
if (getValueForKey(karch, &val, &len, DEFAULT_BOOT_CONFIG) && val)
{
if (strncmp(val, "x86_64", 4) == 0)
DBG("Incorrect parameter for option 'arch =' , please use x86_64 or i386\n");
determineCpuArch();
}
}
else determineCpuArch();
getRootDevice();
// Notify to all modules that we are attempting to boot
execute_hook("PreBoot", NULL, NULL, NULL, NULL, NULL, NULL);
{
trycache = false;
}
verbose("Loading Darwin %s\n", gBootVolume->OSVersion);
{
long cachetime, kerneltime, exttime;
long cachetime, kerneltime = 0, exttime;
if (trycache && !forcecache) do {
if (strcmp(bootInfo->bootFile, kDefaultKernel) != 0) {
bootFile = kDefaultKernel;
goto out;
}
ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)
|| (cachetime < kerneltime))
trycache = 0;
safe_set_env(envAdler32, 0);
DBG("Warning: No kernelcache found or kernelcache too old (timestamp of the kernel > timestamp of the cache), kernelcache disabled !!!\n");
break;
}
ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime);
trycache = 0;
safe_set_env(envAdler32, 0);
DBG("Warning: kernelcache too old, timestamp of S/L/E > timestamp of the cache, kernelcache disabled !!! \n");
break;
}
if (kerneltime > exttime)
trycache = 0;
safe_set_env(envAdler32, 0);
DBG("Warning: invalid timestamp, kernelcache disabled !!!\n");
break;
}
} while (0);
}
do {
if (trycache)
{
if (ret <= 0)
{
out:
out:
printf("Can't find %s\n", bootFile);
sleep(1);
// chainboot
if (status==1)
{
if (__getVideoMode() == GRAPHICS_MODE)
if (getVideoMode() == GRAPHICS_MODE)
{// if we are already in graphics-mode,
#if UNUSED
__setVideoMode(VGA_TEXT_MODE, 0);// switch back to text mode
if (getValueForKey(kKernelCacheKey, &val, &len, DEFAULT_BOOT_CONFIG))
{
char * buffer = newString(val);
if (val[0] == '\\')
{
// Flip the back slash's to slash's .
while (buffer[len] != '\0') {
if (buffer[len] == '\\')
{
buffer[len] = '/';
buffer[len] = '/';
}
len++;
}
if (gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, bootInfo->uuidStr) == 0)
{
verbose("Setting boot-uuid to: %s\n", bootInfo->uuidStr);
uuidSet = true;
//uuidSet = true;
SetgRootDevice(bootInfo->uuidStr);
return;
}
}
}
out:
verbose("Setting %s to: %s\n", uuidSet ? kBootUUIDKey : "root device", (char* )val);
SetgRootDevice(val);
{
bootFileWithDevice = true;
}
// bootFile must start with a / if it not start with a device name
if (!bootFileWithDevice && (str)[0] != '/')
sprintf(bootFile, "/%s", str); // append a leading /
branches/cparm/i386/boot2/graphics.h
1414
1515
1616
17
18
19
2017
2118
2219
#include "bootstruct.h"
#include "vbe.h"
int __getVideoMode(void);
char * __decodeRLE( const void * rleData, int rleBlocks, int outBytes );
void __drawColorRectangle( unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char colorIndex );
branches/cparm/i386/boot2/boot.h
9494
9595
9696
97
97
9898
9999
100100
Hookable function pointer called during the driver loading phase that
allows other code to cause additional drivers to be loaded.
*/
extern struct multiboot_info *gMI;
//extern struct multiboot_info *gMI;
struct compressed_kernel_header {
branches/cparm/i386/boot2/drivers.c
125125
126126
127127
128
128
129129
130130
131131
......
135135
136136
137137
138
138
139139
140140
141141
......
488488
489489
490490
491
492
491493
494
492495
493496
494497
......
566569
567570
568571
572
569573
570574
571575
572576
573
577
574578
575579
576580
......
827831
828832
829833
830
834
831835
832836
833837
gFileSpec = malloc( 4096 );
gTempSpec = malloc( 4096 );
gFileName = malloc( 4096 );
if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName )
stop("InitDriverSupport error");
set_env(envDriverFileSpec,(uint32_t)gFileSpec);
set_env(envDriverTempSpec,(uint32_t)gTempSpec);
set_env(envDriverFileName,(uint32_t)gFileName);
return 0;
}
module->plistAddr = malloc(length);
if ((module->executablePath == 0) || (module->bundlePath == 0) || (module->plistAddr == 0))
{
if ( module->plistAddr ) free(module->plistAddr);
break;
}
// Save the driver path in the module.
//strcpy(module->driverPath, tmpDriverPath);
executableAddr = (void *)kLoadAddr;
}
//printf("%s length = %d addr = 0x%x\n", gFileSpec, length, driverModuleAddr); getc();
}
else
length = 0;
if (length != -1)
if ((length != -1) && executableAddr)
{
//driverModuleAddr = (void *)kLoadAddr;
//if (length != 0)
if (ret == 0 && len == 0 && archCpuType==CPU_TYPE_X86_64)
{
archCpuType=CPU_TYPE_I386;
ret = ThinFatFile(&binary, &len);
/*ret =*/ ThinFatFile(&binary, &len);
}
ret = DecodeMachO(binary, rentry, raddr, rsize);
branches/cparm/i386/boot2/mboot.c
1010
1111
1212
13
13
1414
1515
1616
......
283283
284284
285285
286
286287
287288
288289
......
294295
295296
296297
297
298
299
300
301
302
303
304
305
298306
299
307
300308
301309
302310
311
303312
304313
305314
......
314323
315324
316325
326
317327
318328
319329
320330
321
331
322332
323333
324334
......
333343
334344
335345
336
337346
338347
339348
340349
341350
351
342352
343353
344354
#define OFFSET_1MEG 0x100000
#define BAD_BOOT_DEVICE 0xffffffff
struct multiboot_info *gMI;
//struct multiboot_info *gMI;
#if UNUSED
int multiboot_timeout=0;
return mi_copy;
}
// When we enter, we're actually 1 MB high.
// Fortunately, memcpy is position independent, and it's all we need
uint32_t hi_multiboot(int multiboot_magic, struct multiboot_info *mi_orig)
// makes a BIOS call from real mode which of course won't work
// because we're stuck in extended memory at this point.
struct multiboot_info *mi_p = copyMultibootInfo(multiboot_magic, mi_orig);
#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
* compilers seems to don't like this at all and crash during compilation, if it's really
* necesary maybe we should consider to do it in some other way
*/
// Get us in to low memory so we can run everything
// We cannot possibly be more than 383.5k and copying extra won't really hurt anything
// We use the address of the assembly entrypoint to get our starting location.
memcpy(&boot2_sym, (char*)&boot2_sym + OFFSET_1MEG, 0x5fe00 /* 383.5k */);
#endif
// This is a little assembler routine that returns to us in the correct selector
// instead of the kernel selector we're running in now and at the correct
// However, our caller must fix his return address if he wishes to return to
// his caller and so on and so forth.
/* Zero the BSS and initialize malloc */
initialize_runtime();
gMI = mi_p;
//gMI = mi_p;
/* Set up a temporary bootArgs so we can call console output routines
like printf that check the v_display. Note that we purposefully
bootArgs = &temporaryBootArgsData;
bootArgs->Video.v_display = VGA_TEXT_MODE;
// Since we call multiboot ourselves, its return address will be correct.
// That is unless it's inlined in which case it does not matter.
uint32_t bootdevice = multiboot(multiboot_magic, mi_p);
// We're about to exit and temporaryBootArgs will no longer be valid
bootArgs = NULL;
return bootdevice;
}
branches/cparm/i386/boot2/options.c
798798
799799
800800
801
801
802802
803803
804804
......
11581158
11591159
11601160
1161
1161
1162
11621163
11631164
11641165
changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);
nextRow = kMenuTopRow;
showPrompt = true;
/*showPrompt = true;*/
if (devcnt) {
printf("Use \30\31 keys to select the startup volume.");
intc;
bp = buf;
if(!(bp = buf)) return;
while (size-- > 0) {
if (*bp == '\n') {
*bp = '\0';
branches/cparm/i386/modules/RamDiskLoader/ramdisk.h
2323
2424
2525
26
27
28
2926
3027
3128
unsigned int size;
} RAMDiskParam;
/* mboot.c */
extern struct multiboot_info *gMI;
//
extern int (*p_get_ramdisk_info)(int biosdev, struct driveInfo *dip);
extern long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);
branches/cparm/i386/modules/RamDiskLoader/ramdisk.c
141141
142142
143143
144
145144
146145
147146
......
187186
188187
189188
190
189
191190
192
193191
194192
195193
......
214212
215213
216214
215
216
217217
218218
219219
......
235235
236236
237237
238
238
239
240
241
242
243
244
245
246
247
239248
240249
241250
......
353362
354363
355364
356
357
365
366
358367
359368
360369
......
368377
369378
370379
371
372
380
381
373382
374383
375384
......
386395
387396
388397
389
398
390399
391400
392401
// Reset multiboot structures.
gRAMDiskMI = NULL;
gMI = gRAMDiskMI;
*gRAMDiskFile = '\0';
// Save filename in gRAMDiskFile to display information.
strcpy(gRAMDiskFile, param);
// Set gMI as well for the multiboot ramdisk driver hook.
// Set gRAMDiskMI as well for the multiboot ramdisk driver hook.
gRAMDiskMI = malloc(sizeof(multiboot_info));
gMI = gRAMDiskMI;
struct multiboot_module * ramdisk_module = malloc(sizeof(multiboot_module));
umountRAMDisk();
printf("\nRamdisk contains no partitions.\n");
pause();
// error = -1; // ??
}
else
printf("\nmounting: done");
}
}
}
else error = -1;
if (error == -1) {
if (ramdisk_module)
free(ramdisk_module);
else if (gRAMDiskMI)
free(gRAMDiskMI);
}
}
return error;
}
unsigned int byteoff,
unsigned int byteCount, void * buffer )
{
int module_count = gMI->mi_mods_count;
struct multiboot_module *modules = (void*)gMI->mi_mods_addr;
int module_count = gRAMDiskMI->mi_mods_count;
struct multiboot_module *modules = (void*)gRAMDiskMI->mi_mods_addr;
if(biosdev < 0x100)
return -1;
if(biosdev >= (0x100 + module_count))
int multiboot_get_ramdisk_info(int biosdev, struct driveInfo *dip)
{
int module_count = gMI->mi_mods_count;
struct multiboot_module *modules = (void*)gMI->mi_mods_addr;
int module_count = gRAMDiskMI->mi_mods_count;
struct multiboot_module *modules = (void*)gRAMDiskMI->mi_mods_addr;
if(biosdev < 0x100)
return -1;
if(biosdev >= (0x100 + module_count))
{
char extensionsSpec[1024];
int ramdiskUnit;
for(ramdiskUnit = 0; ramdiskUnit < gMI->mi_mods_count; ++ramdiskUnit)
for(ramdiskUnit = 0; ramdiskUnit < gRAMDiskMI->mi_mods_count; ++ramdiskUnit)
{
int partCount; // unused
BVRef ramdiskChain = diskScanBootVolumes(0x100 + ramdiskUnit, &partCount);
branches/cparm/i386/modules/GUI/picopng.c
4545
4646
4747
48
48
4949
5050
5151
5252
53
53
5454
5555
5656
......
9393
9494
9595
96
97
98
9699
97100
98101
......
118121
119122
120123
121
124
122125
123126
124127
......
147150
148151
149152
150
153
151154
152155
153156
......
190193
191194
192195
196
197
198
193199
194200
201
202
203
195204
205
196206
197207
198208
199209
200210
201
211
202212
203213
204214
......
244254
245255
246256
257
258
259
260
247261
248262
249
263
264
265
266
267
250268
251269
252
270
253271
254272
255273
256274
275
276
277
257278
258279
259280
260281
282
261283
262284
263285
......
301323
302324
303325
326
327
328
304329
305330
306331
......
313338
314339
315340
341
342
343
316344
317345
318346
......
346374
347375
348376
377
378
379
380
349381
350382
351383
......
380412
381413
382414
415
416
417
418
419
383420
384421
385422
386423
387
388
424
425
426
427
428
429
430
431
389432
390433
391434
......
414457
415458
416459
460
461
462
463
417464
418465
419466
......
517564
518565
519566
567
568
569
570
520571
521
572
573
574
575
576
522577
578
579
580
523581
524582
525583
......
783841
784842
785843
844
845
846
847
786848
787849
788850
......
815877
816878
817879
818
819
820
821
822
823
824
825
826
827
828
829
830
880
881
882
883
884
885
886
887
888
889
890
891
892
831893
832894
833895
......
879941
880942
881943
882
944
945
946
947
948
883949
884950
885951
......
9541020
9551021
9561022
1023
1024
1025
1026
9571027
9581028
9591029
......
9711041
9721042
9731043
1044
1045
1046
1047
9741048
9751049
9761050
9771051
9781052
979
1053
9801054
9811055
9821056
......
10621136
10631137
10641138
1065
10661139
10671140
10681141
......
11341207
11351208
11361209
1210
11371211
1212
1213
1214
1215
11381216
1217
1218
1219
11391220
11401221
11411222
void *png_alloc_malloc(size_t size);
void *png_alloc_realloc(void *addr, size_t size);
void png_alloc_free(void *addr);
__unused void vector32_cleanup(vector32_t *p);
void vector32_cleanup(vector32_t *p);
uint32_t vector32_resize(vector32_t *p, size_t size);
uint32_t vector32_resizev(vector32_t *p, size_t size, uint32_t value);
void vector32_init(vector32_t *p);
vector32_t *vector32_new(size_t size, uint32_t value);
__unused void vector8_cleanup(vector8_t *p);
void vector8_cleanup(vector8_t *p);
uint32_t vector8_resize(vector8_t *p, size_t size);
uint32_t vector8_resizev(vector8_t *p, size_t size, uint8_t value);
void vector8_init(vector8_t *p);
void png_alloc_remove_node(png_alloc_node_t *node)
{
if (!node) {
return;
}
if (node->prev)
node->prev->next = node->next;
if (node->next)
if (!addr)
return png_alloc_malloc(size);
new_addr = realloc(addr, size);
if (new_addr != addr) {
if (new_addr && (new_addr != addr)) {
png_alloc_node_t *old_node;
old_node = png_alloc_find_node(addr);
png_alloc_remove_node(old_node);
/*************************************************************************************************/
__unused void vector32_cleanup(vector32_t *p)
void vector32_cleanup(vector32_t *p)
{
p->size = p->allocsize = 0;
if (p->data)
vector32_t *vector32_new(size_t size, uint32_t value)
{
vector32_t *p = png_alloc_malloc(sizeof (vector32_t));
if (!p) {
return NULL;
}
vector32_init(p);
if (size && !vector32_resizev(p, size, value))
{
vector32_cleanup(p);
png_alloc_free(p);
return NULL;
}
return p;
}
/*************************************************************************************************/
__unused void vector8_cleanup(vector8_t *p)
void vector8_cleanup(vector8_t *p)
{
p->size = p->allocsize = 0;
if (p->data)
vector8_t *vector8_new(size_t size, uint8_t value)
{
vector8_t *p = png_alloc_malloc(sizeof (vector8_t));
if(!p)
{
return NULL;
}
vector8_init(p);
if (size && !vector8_resizev(p, size, value))
return NULL;
{
vector8_cleanup(p);
png_alloc_free(p);
return NULL;
}
return p;
}
#if 1
vector8_t *vector8_copy(vector8_t *p)
{
vector8_t *q = vector8_new(p->size, 0);
uint32_t n;
if (!q) {
return NULL;
}
for (n = 0; n < q->size; n++)
q->data[n] = p->data[n];
return q;
}
#endif
/*************************************************************************************************/
HuffmanTree *HuffmanTree_new(void)
{
HuffmanTree *tree = png_alloc_malloc(sizeof (HuffmanTree));
if (!tree) {
return NULL;
}
tree->tree2d = NULL;
return tree;
}
tree1d = vector32_new(numcodes, 0);
blcount = vector32_new(maxbitlen + 1, 0);
nextcode = vector32_new(maxbitlen + 1, 0);
if (!tree1d || !blcount || !nextcode || !nextcode->data) {
return 1; // FIXME
}
for (bits = 0; bits < numcodes; bits++)
blcount->data[bitlen->data[bits]]++; // count number of instances of each code length
for (bits = 1; bits <= maxbitlen; bits++)
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)
return 11; // error: you appeared outside the codetree
vector32_t *bitlen, *bitlenD;
bitlen = vector32_new(288, 8);
bitlenD = vector32_new(32, 5);
if (!bitlen || !bitlenD) {
Inflator_error = 1; // FIXME: find the appropriate error return
return;
}
for (i = 144; i <= 255; i++)
bitlen->data[i] = 9;
for (i = 256; i <= 279; i++)
bitlen->data[i] = 7;
HuffmanTree_makeFromLengths(tree, bitlen, 15);
HuffmanTree_makeFromLengths(treeD, bitlenD, 15);
Inflator_error = HuffmanTree_makeFromLengths(tree, bitlen, 15);
if (Inflator_error) {
return;
}
Inflator_error = HuffmanTree_makeFromLengths(treeD, bitlenD, 15);
if (Inflator_error) {
return;
}
}
uint32_t Inflator_huffmanDecodeSymbol(const uint8_t *in, size_t *bp, const HuffmanTree *codetree,
// compressed with a known tree
size_t i, n;
HuffmanTree *codelengthcodetree = HuffmanTree_new(); // the code tree for code length codes
if (!codelengthcodetree) {
Inflator_error = 1; // FIXME
return;
}
vector32_t *bitlen, *bitlenD;
bitlen = vector32_new(288, 0);
bitlenD = vector32_new(32, 0);
{
HuffmanTree *codetree, *codetreeD; // the code tree for Huffman codes, dist codes
codetree = HuffmanTree_new();
if (!codetree) {
Inflator_error = 1; // FIXME
return;
}
codetreeD = HuffmanTree_new();
if (btype == 1)
if (!codetreeD) {
Inflator_error = 1; // FIXME
return;
}
if (btype == 1) {
Inflator_generateFixedTrees(codetree, codetreeD);
if (Inflator_error)
return;
}
else if (btype == 2) {
Inflator_getTreeInflateDynamic(codetree, codetreeD, in, bp, inlength);
if (Inflator_error)
size_t bytewidth, uint32_t filterType, size_t length)
{
size_t i;
if (!recon) {
PNG_error = 1; // FIXME : find the appropiate error return
return;
}
switch (filterType) {
case 0:
for (i = 0; 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],
precon[i], precon[i - bytewidth]));
} else {
for (i = 0; i < bytewidth; i++)
recon[i] = scanline[i];
for (i = bytewidth; i < length; i++)
recon[i] = (uint8_t) (scanline[i] + PNG_paethPredictor(recon[i - bytewidth], 0, 0));
}
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],
precon[i], precon[i - bytewidth]));
} else {
for (i = 0; i < bytewidth; i++)
recon[i] = scanline[i];
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
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;
if (!out->size) {
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];
PNG_info_t *PNG_info_new(void)
{
PNG_info_t *info = png_alloc_malloc(sizeof (PNG_info_t));
if (!info)
{
return NULL;
}
uint32_t i;
for (i = 0; i < sizeof (PNG_info_t); i++)
((uint8_t *) info)[i] = 0;
return NULL;
}
info = PNG_info_new();
if (!info) {
PNG_error = 1; // FIXME
return NULL;
}
PNG_readPngHeader(info, in, size);
if (PNG_error)
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
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)
}
passw[i], passh[i], bpp);
}
if (info->colorType != 6 || info->bitDepth != 8) { // conversion needed
#if 1
vector8_t *copy = vector8_copy(info->image); // xxx: is this copy necessary?
if (!copy) {
return NULL;
}
#endif
PNG_error = PNG_convert(info, info->image, copy->data);
if (PNG_error) {
return NULL;
}
}
return info;
}
branches/cparm/i386/modules/GUI/gui.c
19741974
19751975
19761976
1977
1978
1979
1980
1981
1977
19821978
19831979
19841980
......
20682064
20692065
20702066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
20712098
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
20922099
20932100
20942101
......
23352342
23362343
23372344
2338
2345
23392346
23402347
23412348
2342
2349
23432350
23442351
23452352
23462353
2347
23482354
23492355
23502356
......
23582364
23592365
23602366
2361
23622367
23632368
23642369
......
24692474
24702475
24712476
2472
24732477
24742478
24752479
position_t current_pos = pos(p.x, p.y);
for (i=0; i < strlen(ch); i++)
{
int cha=(int)ch[i];
cha-=32;
{
// newline ?
if ( ch[i] == '\n' )
{
{
font->chars[count]->width = ( end - start) - 1;
font->chars[count]->height = font->height;
{
int pixels_size = (font->chars[count]->width * data->image->height * 4);
if (!(pixels_size > 0))
{
continue;
}
if ( !( font->chars[count]->pixels = malloc( pixels_size ) ) )
{
continue;
}
space += pixels_size;
}
// we skip the first line because there are just the red pixels for the char width
for( y = 1; y< (font->height); y++)
{
for( x2 = (unsigned)start, x3 = 0; x2 < (unsigned)end; x2++, x3++)
{
pixel( font->chars[count], x3, y ) = pixel( data->image, x2, y );
}
}
// check if font is monospaced
if( ( count > 0 ) && ( font->width != font->chars[count]->width ) )
monospaced = true;
font->width = font->chars[count]->width;
count++;
if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) )
{
space += ( font->chars[count]->width * data->image->height * 4 );
// we skip the first line because there are just the red pixels for the char width
for( y = 1; y< (font->height); y++)
{
for( x2 = (unsigned)start, x3 = 0; x2 < (unsigned)end; x2++, x3++)
{
pixel( font->chars[count], x3, y ) = pixel( data->image, x2, y );
}
}
// check if font is monospaced
if( ( count > 0 ) && ( font->width != font->chars[count]->width ) )
monospaced = true;
font->width = font->chars[count]->width;
count++;
}
}
}
}
progressbar.width = width;
progressbar.height = buff->height;
int x=0,x2=0,y=0;
int x,x2,y;
for(y=0; y<buff->height; y++)
{
for(x=0; x<todraw; x++, x2++)
for(x=0,x2=0; x<todraw; x++, x2++)
{
if(x2 == (buff->width-1)) x2=0;
pixel(&progressbar, x,y).value = pixel(buff, x2,y).value;
}
x2=0;
}
for(y=0; y<buff->height; y++)
pixel(&progressbar, width - 1, y).value = pixel(buffBG, buffBG->width - 1, y).value;
if(progress == 0)
pixel(&progressbar, 0, y).value = pixel(buffBG, buffBG->width - 1, y).value;
x2=0;
}
blend(&progressbar, blendInto, p);
break;
case kReturnKey:
key = 0;
if( infoMenuSelection == MENU_SHOW_MEMORY_INFO )
showInfoBox( "Memory Info. Press q to quit.\n", getMemoryInfoString());
branches/cparm/i386/modules/GUI/GUI_module.c
152152
153153
154154
155
155
156156
157
158
159
160
157161
158162
163
164
159165
160166
161167
......
478484
479485
480486
481
487
482488
483489
484490
......
554560
555561
556562
557
563
558564
559565
560566
......
969975
970976
971977
972
973978
974979
975980
......
11361141
11371142
11381143
1139
11401144
11411145
11421146
setCursorPosition( col, row, 0 );
}
static void restoreCursor( const CursorState * cs )
static int restoreCursor( const CursorState * cs )
{
if (!cs) {
return 0;
}
setCursorPosition( cs->x, cs->y, 0 );
setCursorType( cs->type );
return 1;
}
char GUI_bootRescanPrompt[] =
{
moveCursor( 0, MenuRow + MenuSelection - MenuTop );
printMenuItem( &gMenuItems[MenuSelection], 1 );
restoreCursor( &cursorState );
moved = restoreCursor( &cursorState );
}
else
printMenuItem( &items[i], (i == MenuSelection) );
}
restoreCursor( &cursorState );
restoreCursor( &cursorState ); // FIXME : handle the return error
}
safe_set_env(envgMenuRow,row);
}
nextRow = kMenuTopRow;
showPrompt = true;
if (devcnt)
{
changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);
nextRow = kMenuTopRow;
showPrompt = true;
if (devcnt)
{
branches/cparm/i386/modules/GUI/Makefile
4949
5050
5151
52
52
5353
5454
5555
......
8282
8383
8484
85
85
86
8687
8788
8889
8990
9091
92
93
94
9195
92
96
9397
9498
95
99
96100
97101
98102
99
103
100104
101105
102
106
103107
104108
105109
VPATH = $(OBJROOT):$(SYMROOT)
GUI_OBJS = GUI_module.o gui.o picopng.o graphic_utils.o
GUI_OBJS = GUI_module.o gui.o picopng.o graphic_utils.o stack_protector.o
SFILES =
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
-macosx_version_min 10.6 \
$(OBJROOT)/GUI_module.o \
$(OBJROOT)/stack_protector.o \
$(OBJROOT)/GUI_module.o \
$(OBJROOT)/gui.o \
$(OBJROOT)/picopng.o \
$(OBJROOT)/graphic_utils.o \
-o $(SYMROOT)/$(MODULE_NAME).dylib
stack_protector.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/stack_protector.c" $(INC) -o "$(OBJROOT)/stack_protector.o"
GUI_module.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "GUI_module.c" $(INC) -o "$(OBJROOT)/GUI_module.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "GUI_module.c" $(INC) -o "$(OBJROOT)/GUI_module.o"
gui.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "gui.c" $(INC) -o "$(OBJROOT)/gui.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "gui.c" $(INC) -o "$(OBJROOT)/gui.o"
picopng.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "picopng.c" $(INC) -o "$(OBJROOT)/picopng.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "picopng.c" $(INC) -o "$(OBJROOT)/picopng.o"
graphic_utils.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "graphic_utils.c" $(INC) -o "$(OBJROOT)/graphic_utils.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "graphic_utils.c" $(INC) -o "$(OBJROOT)/graphic_utils.o"
art.h:
@if [ "$(PNGCRUSH)" ]; then\
branches/cparm/i386/modules/GUI/graphic_utils.c
839839
840840
841841
842
842
843843
844844
845845
846
846
847847
848848
849849
......
873873
874874
875875
876
876
877877
878878
879
879
880880
881881
882882
......
888888
889889
890890
891
892
893
891894
892895
893896
VBEModeInfoBlock minfo;
unsigned short vesaVersion;
unsigned short mode = modeEndOfList;
//unsigned short mode = modeEndOfList;
getNumberArrayFromProperty( kGraphicsModeKey, params, 4);
mode = getVESAModeWithProperties( params[0], params[1], params[2],
/* mode = */getVESAModeWithProperties( params[0], params[1], params[2],
maColorModeBit |
maModeIsSupportedBit |
maGraphicsModeBit |
strcpy( (char*)&vbeInfo, "VBE2" );
err = getVBEInfo( &vbeInfo );
if (err != errSuccess)
return 0;
goto error;
if ( strncmp( (char *)vbeInfo.VESASignature, "VESA", 4 ) )
return 0;
goto error;
small = (vbeInfo.TotalMemory < 16);
VBEDecodeFP(const char *, vbeInfo.OEMStringPtr) );
return buff;
error:
free(buff);
return 0;
}
void blend( const pixmap_t *blendThis, // Source image
branches/cparm/i386/modules/GraphicsEnabler/gma.c
9191
9292
9393
94
9495
96
9597
9698
9799
......
100102
101103
102104
105
103106
104
107
105108
106109
107110
......
109112
110113
111114
112
113
115
114116
115117
116118
{
//intlen;
char *devicepath;
#if UNUSED
volatile uint8_t *regs;
#endif
uint32_t bar[7];
char *model;
uint8_t BuiltIn = 0x00;
devicepath = get_pci_dev_path(gma_dev);
bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
#if UNUSED
regs = (uint8_t *) (bar[0] & ~0x0f);
#endif
model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);
verbose("Intel %s [%04x:%04x] :: %s\n",
if (!string)
string = devprop_create_string();
struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
device = devprop_add_device(string, devicepath);
struct DevPropDevice *device = devprop_add_device(string, devicepath);
if(!device)
{
branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
921921
922922
923923
924
924
925
926
925927
926928
927929
......
12661268
12671269
12681270
1271
12691272
12701273
12711274
......
12801283
12811284
12821285
1286
12831287
12841288
12851289
......
12931297
12941298
12951299
1300
1301
1302
12961303
12971304
12981305
uint8_t type;
uint8_t index;
uint8_t *heads;
} entries[numentries];
};
struct dcbentry entries[MAX_NUM_DCB_ENTRIES];
for (i = 0; i < numentries; i++) {
uint32_t connection;
// Valid Signature ?
if (rom[0] != 0x55 && rom[1] != 0xaa) {
printf("ERROR: Unable to locate nVidia Video BIOS\n");
free(rom);
return false;
} else {
DBG("ROM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
if ((nvPatch = patch_nvidia_rom(rom)) == PATCH_ROM_FAILED) {
printf("ERROR: nVidia ROM Patching Failed!\n");
free(rom);
return false;
}
DBG("nvidia rom successfully patched\n");
model = get_nvidia_model((rom_pci_header->vendor << 16) | rom_pci_header->device);
} else {
printf("nVidia incorrect PCI ROM signature: 0x%x\n", rom_pci_header->signature);
// ??
//free(rom);
//return false;
}
}
DBG("nvidia model : %s\n",model);
branches/cparm/i386/modules/SMBiosGetters/smbios_decode.c
3030
3131
3232
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
3363
3464
3565
static void decodeOemProcessorType(SMBOemProcessorType *structHeader);
static void decodeOemProcessorBusSpeed(SMBOemProcessorBusSpeed *structHeader);
static const char *
SMBMemoryDeviceTypes[] =
{
"RAM", /* 00h Undefined */
"RAM", /* 01h Other */
"RAM", /* 02h Unknown */
"DRAM", /* 03h DRAM */
"EDRAM", /* 04h EDRAM */
"VRAM", /* 05h VRAM */
"SRAM", /* 06h SRAM */
"RAM", /* 07h RAM */
"ROM", /* 08h ROM */
"FLASH", /* 09h FLASH */
"EEPROM", /* 0Ah EEPROM */
"FEPROM", /* 0Bh FEPROM */
"EPROM", /* 0Ch EPROM */
"CDRAM", /* 0Dh CDRAM */
"3DRAM", /* 0Eh 3DRAM */
"SDRAM", /* 0Fh SDRAM */
"SGRAM", /* 10h SGRAM */
"RDRAM", /* 11h RDRAM */
"DDR SDRAM", /* 12h DDR */
"DDR2 SDRAM", /* 13h DDR2 */
"DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */
"RAM",/* 15h unused */
"RAM",/* 16h unused */
"RAM",/* 17h unused */
"DDR3",/* 18h DDR3, chosen in [5776134] */
};
//-------------------------------------------------------------------------------------------------------------------------
// BIOSInformation
//-------------------------------------------------------------------------------------------------------------------------
branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
11941194
11951195
11961196
1197
1198
11971199
1200
11981201
11991202
12001203
......
12071210
12081211
12091212
1213
1214
1215
12101216
1217
12111218
12121219
12131220
......
12311238
12321239
12331240
1241
1242
1243
12341244
1235
1245
12361246
12371247
12381248
......
12411251
12421252
12431253
1244
1254
1255
1256
12451257
12461258
12471259
buffer = (uint8_t *)malloc(SMB_ALLOC_SIZE);
if (!buffer)
{
free(structPtr);
return NULL;
}
bzero(buffer, SMB_ALLOC_SIZE);
structPtr->new = (SMBStructHeader *)buffer;
SMBEntryPoint *neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint));
if (!neweps)
{
free(buffer);
free(structPtr);
return NULL;
}
bzero(neweps, sizeof(SMBEntryPoint));
neweps->anchor[0]= '_';
neweps->dmi.bcdRevision= 0x24;
if (!neweps->dmi.tableAddress)
{
free(buffer);
free(structPtr);
return NULL;
}
memcpy((void *)neweps->dmi.tableAddress, buffer, tableLength);
neweps->dmi.checksum= 0;
neweps->checksum= 0;
neweps->checksum= 0x100 - checksum8(neweps, sizeof(SMBEntryPoint));
//free(buffer);
free(buffer);
free(structPtr);
decodeSMBIOSTable(neweps);
return neweps;
branches/cparm/i386/modules/SMBiosGetters/mysmbios.h
306306
307307
308308
309
309310
310311
311312
......
339340
340341
341342
343
342344
343345
344346
SMBWord Data[];
} __attribute__((packed)) SMBMemorySPD;
#if 0
static const char *
SMBMemoryDeviceTypes[] =
{
static const int
kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) /
sizeof(SMBMemoryDeviceTypes[0]);
#endif
//
// OEM Processor Type (Apple Specific - Type 131)
branches/cparm/i386/modules/SMBiosGetters/Makefile
8585
8686
8787
88
88
8989
9090
91
91
9292
9393
94
94
9595
9696
97
97
9898
9999
100100
SMBiosGetters.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "SMBiosGetters.c" $(INC) -o "$(OBJROOT)/SMBiosGetters.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "SMBiosGetters.c" $(INC) -o "$(OBJROOT)/SMBiosGetters.o"
mysmbios.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "mysmbios.c" $(INC) -o "$(OBJROOT)/mysmbios.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "mysmbios.c" $(INC) -o "$(OBJROOT)/mysmbios.o"
smbios_decode.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "smbios_decode.c" $(INC) -o "$(OBJROOT)/smbios_decode.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "smbios_decode.c" $(INC) -o "$(OBJROOT)/smbios_decode.o"
smbios_getters.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "smbios_getters.c" $(INC) -o "$(OBJROOT)/smbios_getters.o"
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "smbios_getters.c" $(INC) -o "$(OBJROOT)/smbios_getters.o"
include ../../MakeInc.dir
branches/cparm/i386/modules/HibernateEnabler/resume.c
2828
2929
3030
31
3132
33
3234
3335
3436
3537
3638
39
3740
3841
42
3943
4044
4145
......
5155
5256
5357
54
58
59
60
61
5562
5663
5764
......
6572
6673
6774
75
6876
69
77
7078
7179
7280
......
110118
111119
112120
113
121
122
123
124
114125
115126
116127
......
124135
125136
126137
138
127139
128
140
129141
130142
131143
static unsigned long
getmemorylimit(void)
{
#if UNUSED
int line;
#endif
int i;
MemoryRange *mp = (MemoryRange*)(uint32_t)get_env(envMemoryMap);
int MemMapCnt = (int)get_env(envMemoryMapCnt);
#if UNUSED
// Activate and clear page 1
line = 1;
#endif
for (i = 0; i < MemMapCnt; i++)
{
static void WakeKernel(IOHibernateImageHeader * header)
{
uint32_t proc;
unsigned long cnt, newSP;
unsigned long cnt;
#if UNUSED
unsigned long newSP;
#endif
unsigned long *src, *dst;
unsigned int count;
unsigned int page;
dst = (unsigned long *) (header->restore1CodePage << 12);
count = header->restore1PageCount;
proc = (header->restore1CodeOffset + ((uint32_t) dst));
#if UNUSED
newSP = header->restore1StackOffset + (header->restore1CodePage << 12);
#endif
src = (unsigned long *) (((u_int32_t) &header->fileExtentMap[0])
+ header->fileExtentMapSize);
sum = 0;
static void WakeKernel107(IOHibernateImageHeader107 * header)
{
uint32_t proc;
unsigned long cnt, newSP;
unsigned long cnt;
#if UNUSED
unsigned long newSP;
#endif
unsigned long *src, *dst;
unsigned int count;
unsigned int page;
dst = (unsigned long *) (header->restore1CodePhysPage << 12);
count = header->restore1PageCount;
proc = (header->restore1CodeOffset + ((uint32_t) dst));
#if UNUSED
newSP = header->restore1StackOffset + (header->restore1CodePhysPage << 12);
#endif
src = (unsigned long *) (((u_int32_t) &header->fileExtentMap[0])
+ header->fileExtentMapSize);
sum = 0;
branches/cparm/i386/modules/HibernateEnabler/bmdecompress.c
3636
3737
3838
39
40
39
40
4141
4242
4343
......
4747
4848
4949
50
50
5151
5252
5353
5454
55
55
5656
5757
5858
......
6262
6363
6464
65
65
6666
6767
68
68
6969
7070
7171
......
7979
8080
8181
82
82
8383
84
84
8585
8686
8787
8888
89
89
9090
9191
9292
9393
94
95
94
95
9696
97
97
9898
9999
100100
101101
102102
103103
104
104
105105
106106
107107
......
120120
121121
122122
123
123
124124
125125
126126
127127
128
128
129129
130130
131131
......
137137
138138
139139
140
141
140
141
142142
143143
144144
......
148148
149149
150150
151
151
152152
153153
154154
155155
156
156
157157
158158
159159
......
163163
164164
165165
166
166
167167
168168
169
169
170170
171171
172172
......
180180
181181
182182
183
183
184184
185
185
186186
187187
188188
189
189
190190
191191
192192
193193
194
195
194
195
196196
197
197
198198
199199
200200
201201
202202
203203
204
204
205205
206206
207207
......
220220
221221
222222
223
223
224224
225225
226226
227227
228
228
229229
230230
231231
232
232
233233
234234
235235
......
241241
242242
243243
244
244
245245
246246
247247
248248
249249
250
251
250
251
252252
253
254
255
256
257
258
259
260253
261254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
262273
static void
PreviewDecompress16(uint32_t * compressBuffer,
uint32_t width, uint32_t height, uint32_t row,
uint16_t * output)
uint32_t width, uint32_t height, uint32_t row,
uint16_t * output)
{
int i, j;
uint32_t * input;
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
bzero(sc1, (width+2) * sizeof(uint16_t));
bzero(sc2, (width+2) * sizeof(uint16_t));
bzero(sc3, (width+2) * sizeof(uint16_t));
uint32_t tmp1, tmp2, out;
for (j = 0; j < (height + 2); j++)
{
else
input += height - 1;
input = (uint32_t *)(input[3] + ((uint8_t *)compressBuffer));
uint32_t data = 0, repeat = 0, fetch = 0, count = 0;
sr0 = sr1 = sr2 = sr3 = 0;
for (i = 0; i < (width + 2); i++)
{
if (i < width)
}
else
fetch = (0 == repeat);
count--;
if (fetch)
{
data = *((uint16_t *)input);
(*((uint16_t *)input))++;
// grayscale
// srgb 13933, 46871, 4732
// ntsc 19595, 38470, 7471
data = 13933 * (0x1f & (data >> 10))
+ 46871 * (0x1f & (data >> 5))
+ 4732 * (0x1f & data);
+ 46871 * (0x1f & (data >> 5))
+ 4732 * (0x1f & data);
data >>= 13;
// 70% white, 30 % black
data *= 19661;
data += (103 << 16);
data >>= 16;
}
}
// gauss blur
tmp2 = sr0 + data;
sr0 = data;
sc2[i] = tmp1;
out = (128 + sc3[i] + tmp2) >> 11;
sc3[i] = tmp2;
out &= 0x1f;
if ((i > 1) && (j > 1))
output[i-2] = out | (out << 5) | (out << 10);
}
if (j > 1)
output += row;
}
static void
PreviewDecompress32(uint32_t * compressBuffer,
uint32_t width, uint32_t height, uint32_t row,
uint32_t * output)
uint32_t width, uint32_t height, uint32_t row,
uint32_t * output)
{
int i, j;
uint32_t * input;
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
bzero(sc1, (width+2) * sizeof(uint16_t));
bzero(sc2, (width+2) * sizeof(uint16_t));
bzero(sc3, (width+2) * sizeof(uint16_t));
uint32_t tmp1, tmp2, out;
for (j = 0; j < (height + 2); j++)
{
else
input += height - 1;
input = (uint32_t *)(input[3] + ((uint8_t *)compressBuffer));
uint32_t data = 0, repeat = 0, fetch = 0, count = 0;
sr0 = sr1 = sr2 = sr3 = 0;
for (i = 0; i < (width + 2); i++)
{
if (i < width)
}
else
fetch = (0 == repeat);
count--;
if (fetch)
{
data = *input++;
// grayscale
// srgb 13933, 46871, 4732
// ntsc 19595, 38470, 7471
data = 13933 * (0xff & (data >> 24))
+ 46871 * (0xff & (data >> 16))
+ 4732 * (0xff & data);
+ 46871 * (0xff & (data >> 16))
+ 4732 * (0xff & data);
data >>= 16;
// 70% white, 30 % black
data *= 19661;
data += (103 << 16);
data >>= 16;
}
}
// gauss blur
tmp2 = sr0 + data;
sr0 = data;
sc2[i] = tmp1;
out = (128 + sc3[i] + tmp2) >> 8;
sc3[i] = tmp2;
out &= 0xff;
if ((i > 1) && (j > 1))
output[i-2] = out | (out << 8) | (out << 16);
}
if (j > 1)
output += row;
}
free(sc3);
free(sc2);
free(sc1);
{
uint32_t * src = (uint32_t *) srcbase;
void * ret;
*bitsPerPixel = 8 * ((int) src[0]);
*dw = (int) src[1];
*dh = (int) src[2];
ret = malloc ((*dw * *dh * *bitsPerPixel)/ 8);
switch(*bitsPerPixel)
if (!ret)
{
case 32:
PreviewDecompress32((uint32_t *)srcbase, *dw, *dh, *dw, ret);
return ret;
case 16:
PreviewDecompress16((uint32_t *)srcbase, *dw, *dh, *dw, ret);
return ret;
default:
return 0;
}
switch(*bitsPerPixel)
{
case 32:
PreviewDecompress32((uint32_t *)srcbase, *dw, *dh, *dw, ret);
break;
case 16:
PreviewDecompress16((uint32_t *)srcbase, *dw, *dh, *dw, ret);
break;
default:
{
free(ret);
ret = 0;
break;
}
}
return ret;
}
branches/cparm/i386/modules/Keymapper/Keylayout.c
133133
134134
135135
136
136
137137
138138
139139
sprintf(layoutPath, "/Extra/Keymaps/%s", val);
// Add the extension if needed
if (len <= 4 || strcmp(val+len-4,".lyt") != 0)
strncat(layoutPath, ".lyt", sizeof(layoutPath));
strlcat(layoutPath, ".lyt", sizeof(layoutPath));
if (!load_keyboard_layout_file(layoutPath))
{
branches/cparm/i386/modules/USBFix/usb.c
130130
131131
132132
133
133
134
135
134136
135137
136
137138
138
139
139
140
140141
141142
142143
......
147148
148149
149150
151
152
153
150154
155
151156
152157
153158
......
157162
158163
159164
165
166
160167
161168
162169
163170
164
171
165172
166173
167174
......
171178
172179
173180
174
181
182
183
175184
176185
177186
178187
179188
180
181
189
190
182191
183192
184193
......
189198
190199
191200
201
192202
193203
194204
DBG("capaddr=%x opaddr=%x eecp=%x\n", capaddr, opaddr, eecp);
uint32_t usbcmd = *((unsigned int*)(opaddr));// Command Register
#if DEBUG_USB
uint32_t usbcmd = *((unsigned int*)(opaddr));// Command Register
uint32_t usbsts = *((unsigned int*)(opaddr + 4));// Status Register
uint32_t usbintr = *((unsigned int*)(opaddr + 8));// Interrupt Enable Register
DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr);
// read PCI Config 32bit USBLEGSUP (eecp+0)
// read PCI Config 32bit USBLEGSUP (eecp+0)
uint32_t usblegsup = pci_config_read32(pci_dev->dev.addr, eecp);
// informational only
uint32_t usblegctlsts = pci_config_read32(pci_dev->dev.addr, eecp + 4);
DBG("usblegsup=%08x isOSowned=%d isBIOSowned=%d usblegctlsts=%08x\n", usblegsup, isOSowned, isBIOSowned, usblegctlsts);
#else
uint32_t usbcmd;
#endif
// Reset registers to Legacy OFF
DBG("Clearing USBLEGCTLSTS\n");
pci_config_write32(pci_dev->dev.addr, eecp + 4, 0);//usblegctlsts
delay(100);
usbcmd = *((unsigned int*)(opaddr));
#if DEBUG_USB
usbsts = *((unsigned int*)(opaddr + 4));
usbintr = *((unsigned int*)(opaddr + 8));
DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr);
#endif
DBG("Clearing Registers\n");
// clear registers to default
*((unsigned int*)(opaddr + 4)) = 0x1000;//usbsts - clear status registers
pci_config_write32(pci_dev->dev.addr, eecp, 1);//usblegsup
// get the results
#if DEBUG_USB
// get the results
usbcmd = *((unsigned int*)(opaddr));
usbsts = *((unsigned int*)(opaddr + 4));
usbintr = *((unsigned int*)(opaddr + 8));
DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr);
// read 32bit USBLEGSUP (eecp+0)
// read 32bit USBLEGSUP (eecp+0)
usblegsup = pci_config_read32(pci_dev->dev.addr, eecp);
// informational only
usblegctlsts = pci_config_read32(pci_dev->dev.addr, eecp + 4);
DBG("usblegsup=%08x isOSowned=%d isBIOSowned=%d usblegctlsts=%08x\n", usblegsup, isOSowned, isBIOSowned, usblegctlsts);
#endif
DBG("Legacy USB Off Done\n");
return 1;
branches/cparm/i386/modules/HPET/HPET.c
118118
119119
120120
121
121
122
123
124
122125
123126
124127
......
131134
132135
133136
134
137
135138
139
140
136141
137142
143
138144
139145
140146
141147
142148
149
150
143151
144152
145153
......
150158
151159
152160
161
153162
154163
155164
......
159168
160169
161170
162
171
172
173
174
163175
164176
165177
......
182194
183195
184196
197
185198
186199
187200
188201
202
189203
190204
191
205
192206
193207
194208
209
210
195211
196212
213
197214
198215
199
216
217
218
200219
201
220
202221
203222
204223
static void force_enable_hpet_via(pci_dt_t *lpc_dev)
{
uint32_tval, hpet_address = 0xFED00000;
uint32_tval;
#if DEBUG_HPET
uint32_t hpet_address = 0xFED00000;
#endif
unsigned int i;
for(i = 1; i < sizeof(lpc_controllers_via) / sizeof(lpc_controllers_via[0]); i++)
DBG("VIA %s LPC Interface [%04x:%04x], MMIO\n",
lpc_controllers_via[i].name, lpc_dev->vendor_id, lpc_dev->device_id);
if (val & 0x80)
if (val & 0x80)
{
#if DEBUG_HPET
hpet_address = (val & ~0x3ff);
DBG("HPET at 0x%lx\n", hpet_address);
#endif
}
else
{
val = 0xfed00000 | 0x80;
pci_config_write32(lpc_dev->dev.addr, 0x68, val);
#if DEBUG_HPET
val = pci_config_read32(lpc_dev->dev.addr, 0x68);
if (val & 0x80)
{
{
DBG("Unable to enable HPET");
}
#endif
}
}
}
static void force_enable_hpet_intel(pci_dt_t *lpc_dev)
{
uint32_tval, hpet_address = 0xFED00000;
uint32_tval;
#if DEBUG_HPET
uint32_t hpet_address = 0xFED00000;
#endif
unsigned int i;
void*rcba;
val = REG32(rcba, 0x3404);
if (val & 0x80)
{
#if DEBUG_HPET
// HPET is enabled in HPTC. Just not reported by BIOS
DBG(" HPET is enabled in HPTC, just not reported by BIOS\n");
hpet_address |= (val & 3) << 12 ;
DBG(" HPET MMIO @ 0x%lx\n", hpet_address);
#endif
}
else
{
{
// HPET disabled in HPTC. Trying to enable
DBG(" HPET is disabled in HPTC, trying to enable\n");
REG32(rcba, 0x3404) = val | 0x80;
#if DEBUG_HPET
hpet_address |= (val & 3) << 12 ;
DBG(" Force enabled HPET, MMIO @ 0x%lx\n", hpet_address);
#endif
}
// verify if the job is done
#if DEBUG_HPET
// verify if the job is done
val = REG32(rcba, 0x3404);
#if DEBUG_HPET
if (!(val & 0x80))
printf(" Failed to force enable HPET\n");
#endif
branches/cparm/i386/modules/CPUfreq/CPUfreq.c
4040
4141
4242
43
44
4543
4644
4745
bus_ratio = 0;
msr = rdmsr64(MSR_FSB_FREQ);
fsbFrequency = 0;
cpuFrequency = 0;
minfsb = 183000000;
maxfsb = 185000000;
branches/cparm/i386/modules/Memory/mem.c
5454
5555
5656
57
57
5858
59
59
6060
6161
62
62
6363
6464
6565
sprintf(str, " %02x", ad[i+j]);
else
strcpy(str, " " );
strncat(buffer, str, sizeof(buffer));
strlcat(buffer, str, sizeof(buffer));
}
strncat(buffer," ", sizeof(buffer));
strlcat(buffer," ", sizeof(buffer));
for (j=0; j < (len%STEP); j++) {
sprintf(str, "%c", DC(ad[i+j]));
strncat(buffer, str, sizeof(buffer));
strlcat(buffer, str, sizeof(buffer));
}
printf("%s\n",buffer);
}
branches/cparm/i386/modules/Memory/spd.c
268268
269269
270270
271
271
272
273
274
272275
273276
274277
......
276279
277280
278281
279
280282
283
284
281285
282286
283287
288
284289
285290
286291
{
int i, speed;
uint8_t spd_size, spd_type;
uint32_t base, mmio, hostc;
uint32_t base;
#if DEBUG_SPD
uint32_t mmio, hostc;
#endif
bool dump = false;
RamSlotInfo_t* slot;
DBG("SMBus CmdReg: 0x%x\n", cmd);
pci_config_write16(smbus_dev->dev.addr, 0x04, cmd | 1);
mmio = pci_config_read32(smbus_dev->dev.addr, 0x10);// & ~0x0f;
base = pci_config_read16(smbus_dev->dev.addr, 0x20) & 0xFFFE;
#if DEBUG_SPD
mmio = pci_config_read32(smbus_dev->dev.addr, 0x10);// & ~0x0f;
hostc = pci_config_read8(smbus_dev->dev.addr, 0x40);
DBG("Scanning SMBus [%04x:%04x], mmio: 0x%x, ioport: 0x%x, hostc: 0x%x\n",
smbus_dev->vendor_id, smbus_dev->device_id, mmio, base, hostc);
#endif
getBoolForKey("DumpSPD", &dump, DEFAULT_BOOT_CONFIG);
bool fullBanks ; // needed at least for laptops
branches/cparm/i386/modules/Memory/dram_controllers.c
271271
272272
273273
274
275
274
275
276
277
276278
277279
278280
......
299301
300302
301303
302
304
303305
304306
305
307
306308
307309
308310
......
376378
377379
378380
379
381
382
383
384
380385
381386
382387
......
406411
407412
408413
409
414
410415
411416
412
413
414
415
417
416418
417419
418420
{
// Thanks for CDH optis
uint32_t dev0, c0ckectrl, c1ckectrl, offset;
uint32_t ODT_Control_Register, Precharge_Register, ACT_Register, Read_Register, Misc_Register;
uint32_t ODT_Control_Register, Precharge_Register, ACT_Register, Read_Register;
#if UNUSED
unsigned long Misc_Register;
#endif
long *ptr;
// Read MMR Base Address
ptr = (long*)(dev0 + offset + 0x258);
Read_Register = *ptr & 0xFFFFFFFF;
#if UNUSED
ptr = (long*)(dev0 + offset + 0x244);
Misc_Register = *ptr & 0xFFFFFFFF;
#endif
// 965 Series only support DDR2
safe_set_env(envRamType,SMB_MEM_TYPE_DDR2);
{
// Thanks for CDH optis
unsigned long dev0, Memory_Check, c0ckectrl, c1ckectrl, offset;
unsigned long ODT_Control_Register, Precharge_Register, ACT_Register, Read_Register, Misc_Register;
unsigned long ODT_Control_Register, Precharge_Register, ACT_Register, Read_Register;
#if UNUSED
unsigned long Misc_Register;
#endif
long *ptr;
//Device_ID = pci_config_read16(dram_dev->dev.addr, 0x02);
ptr = (long*)(dev0 + offset + 0x258);
Read_Register = *ptr & 0xFFFFFFFF;
#if UNUSED
ptr = (long*)(dev0 + offset + 0x244);
Misc_Register = *ptr & 0xFFFFFFFF;
ptr = (long*)(dev0 + offset + 0x1E8);
Memory_Check = *ptr & 0xFFFFFFFF;
#endif
// On P45, check 1A8
if(dram_dev->device_id > 0x2E00) {
ptr = (long*)(dev0 + offset + 0x1A8);
branches/cparm/i386/modules/ACPICodec/acpidecode.c
11
2
3
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
428
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2929
3030
3131
......
5454
5555
5656
57
58
59
60
57
58
59
60
6161
6262
6363
......
7979
8080
8181
82
82
8383
8484
8585
8686
87
87
8888
8989
9090
......
113113
114114
115115
116
116
117117
118
118
119119
120120
121121
122
122
123123
124124
125125
......
132132
133133
134134
135
135
136136
137
138
139
140
141
142
143
144
145
146
147
148
137
138
139
140
141
142
143
144
145
146
147
148
149149
150150
151151
......
160160
161161
162162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178178
179179
180180
......
215215
216216
217217
218
218
219219
220220
221221
222
222
223223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244244
245
246
247
248
245
246
247
248
249249
250
250
251251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272272
273
273
274274
275275
276276
......
279279
280280
281281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312312
313313
314314
......
318318
319319
320320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355355
356356
357357
......
364364
365365
366366
367
367
368368
369369
370370
371371
372372
373373
374
374
375375
376376
377377
378378
379
379
380380
381381
382382
383383
384384
385385
386
386
387387
388388
389389
390
390
391391
392392
393393
394
394
395395
396396
397397
398
398
399399
400400
401401
402402
403403
404404
405
405
406406
407407
408408
409
409
410410
411411
412412
413
413
414414
415415
416416
417417
418418
419419
420
420
421421
422422
423423
424
424
425425
426426
427
427
428428
429429
430430
......
435435
436436
437437
438
438
439439
440
440
441441
442442
443443
444
444
445445
446446
447447
......
454454
455455
456456
457
457
458458
459
459
460460
461461
462462
463463
464464
465
465
466466
467467
468468
......
490490
491491
492492
493
493
494494
495
495
496496
497497
498498
499
499
500500
501501
502502
503503
504
504
505505
506506
507507
......
512512
513513
514514
515
515
516516
517517
518518
......
520520
521521
522522
523
523
524524
525525
526526
527
527
528528
529529
530530
......
535535
536536
537537
538
538
539539
540540
541541
......
555555
556556
557557
558
558
559559
560560
561561
......
565565
566566
567567
568
568
569569
570570
571571
......
578578
579579
580580
581
582
581
582
583583
584584
585585
......
589589
590590
591591
592
592
593593
594594
595595
......
602602
603603
604604
605
605
606606
607607
608608
609609
610
610
611611
612612
613613
614614
615615
616
617
616
617
618618
619619
620620
......
623623
624624
625625
626
626
627627
628628
629629
630630
631
631
632632
633633
634634
635635
636636
637
637
638638
639639
640640
641641
642642
643
643
644644
645645
646646
647647
648
648
649649
650650
651651
652652
653653
654
654
655655
656656
657657
658658
659
659
660660
661661
662662
663663
664664
665665
666
667
666
667
668668
669669
670670
......
672672
673673
674674
675
675
676676
677
677
678678
679679
680680
681
681
682682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701701
702702
703703
......
707707
708708
709709
710
710
711711
712712
713713
......
715715
716716
717717
718
718
719719
720720
721721
......
733733
734734
735735
736
736
737737
738738
739739
......
745745
746746
747747
748
748
749749
750750
751751
752
752
753753
754754
755755
756
756
757757
758758
759759
760760
761761
762762
763
763
764764
765
765
766766
767767
768768
769
769
770770
771771
772772
773
773
774774
775775
776776
777
777
778778
779779
780780
781
781
782782
783783
784784
......
786786
787787
788788
789
789
790790
791791
792792
793793
794794
795
795
796796
797797
798798
799
799
800800
801801
802802
......
812812
813813
814814
815
816
817
818
819
820
821
822
823
824
825
826
815
816
817
818
819
820
821
822
823
824
825
826
827827
828828
829829
......
833833
834834
835835
836
836
837837
838
838
839839
840840
841841
842
842
843843
844844
845845
846
846
847847
848848
849849
......
863863
864864
865865
866
866
867867
868868
869869
......
882882
883883
884884
885
885
886886
887
887
888888
889889
890890
891
891
892892
893893
894894
895
895
896896
897897
898898
899
899
900900
901901
902902
903
903
904904
905
905
906906
907907
908908
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "acpi.h"
#include "acpidecode.h"
void dprint_nameseg(U32 i)
{
DBG("%c%c%c%c",
(int)(i & 0x000000ff),
(int)((i & 0x0000ff00) >> 8),
(int)((i & 0x00ff0000) >> 16),
(int)(i >> 24));
(int)(i & 0x000000ff),
(int)((i & 0x0000ff00) >> 8),
(int)((i & 0x00ff0000) >> 16),
(int)(i >> 24));
}
#if DEBUG_ACPI_DECODE
U8 len0 = *current;
U8 numBytes = len0 >> 6;
U32 total = 0;
for (i = numBytes; i > 0; i--) {
total <<= 8;
total |= current[i];
}
total <<= 4;
total |= len0 & 0x3f;
*length = total;
{
U8 *temp = current;
struct acpi_namespace dummy_ns;
(void)end;
if (!ns)
ns = &dummy_ns;
*ns = *ns_context;
if (*current == AML_ROOT_PREFIX) {
ns->depth = 0;
current++;
current++;
ns->depth--;
}
switch (*current) {
case AML_DUAL_NAME_PREFIX:
if (ns->depth + 2 > ACPI_NAMESPACE_MAX_DEPTH) {
DBG( "Namespace got too deep\n");
return temp;
}
current++;
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
break;
case AML_MULTI_NAME_PREFIX:
case AML_DUAL_NAME_PREFIX:
if (ns->depth + 2 > ACPI_NAMESPACE_MAX_DEPTH) {
DBG( "Namespace got too deep\n");
return temp;
}
current++;
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
break;
case AML_MULTI_NAME_PREFIX:
{
U8 nameseg_count;
current++;
}
break;
}
case AML_NULL_NAME:
current++;
break;
default:
if (*current != '_' && (*current < 'A' || *current > 'Z')) {
DBG( "Invalid nameseg lead character: 0x%02x\n", *current);
return temp;
}
if (ns->depth + 1 > ACPI_NAMESPACE_MAX_DEPTH) {
DBG( "Namespace got too deep\n");
return temp;
}
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
break;
case AML_NULL_NAME:
current++;
break;
default:
if (*current != '_' && (*current < 'A' || *current > 'Z')) {
DBG( "Invalid nameseg lead character: 0x%02x\n", *current);
return temp;
}
if (ns->depth + 1 > ACPI_NAMESPACE_MAX_DEPTH) {
DBG( "Namespace got too deep\n");
return temp;
}
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
break;
}
#if DEBUG_ACPI_DECODE
DBG( "Found NameString: ");
static U8 *parse_acpi_computationaldata(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_buffer(ns, current, end);
if (current != temp)
return current;
switch (*current) {
case AML_BYTE_OP:
DBG("Found ByteOp\n");
current += 1 + 1;
break;
case AML_WORD_OP:
DBG( "Found WordOp\n");
current += 1 + 2;
break;
case AML_DWORD_OP:
DBG("Found DwordOp\n");
current += 1 + 4;
break;
case AML_QWORD_OP:
DBG( "Found QwordOp\n");
current += 1 + 8;
break;
case AML_STRING_OP:
DBG( "Found StringOp: \"");
current++;
while (*current)
case AML_BYTE_OP:
DBG("Found ByteOp\n");
current += 1 + 1;
break;
case AML_WORD_OP:
DBG( "Found WordOp\n");
current += 1 + 2;
break;
case AML_DWORD_OP:
DBG("Found DwordOp\n");
current += 1 + 4;
break;
case AML_QWORD_OP:
DBG( "Found QwordOp\n");
current += 1 + 8;
break;
case AML_STRING_OP:
DBG( "Found StringOp: \"");
current++;
while (*current)
#if DEBUG_ACPI_DECODE
if (*current < ' ' || *current > 0x7e)
printf( "\\x%02x", *current++);
else
printf( "%c", *current++);
if (*current < ' ' || *current > 0x7e)
printf( "\\x%02x", *current++);
else
printf( "%c", *current++);
#else
current++;
current++;
#endif
current++; /* Skip the \0 */
DBG( "\"\n");
break;
case AML_ZERO_OP:
DBG( "Found ZeroOp\n");
current += 1;
break;
case AML_ONE_OP:
DBG( "Found OneOp\n");
current += 1;
break;
case AML_ONES_OP:
DBG( "Found OneOp\n");
current += 1;
break;
case AML_EXT_OP_PREFIX:
if (*(current + 1) == AML_REVISION_OP)
current += 2;
default:
break;
current++; /* Skip the \0 */
DBG( "\"\n");
break;
case AML_ZERO_OP:
DBG( "Found ZeroOp\n");
current += 1;
break;
case AML_ONE_OP:
DBG( "Found OneOp\n");
current += 1;
break;
case AML_ONES_OP:
DBG( "Found OneOp\n");
current += 1;
break;
case AML_EXT_OP_PREFIX:
if (*(current + 1) == AML_REVISION_OP)
current += 2;
default:
break;
}
return current;
}
(void)ns;
(void)end;
switch (*current) {
case AML_ARG0_OP:
DBG( "Found Arg0Op\n");
current++;
break;
case AML_ARG1_OP:
DBG( "Found Arg1Op\n");
current++;
break;
case AML_ARG2_OP:
DBG( "Found Arg2Op\n");
current++;
break;
case AML_ARG3_OP:
DBG( "Found Arg3Op\n");
current++;
break;
case AML_ARG4_OP:
DBG( "Found Arg4Op\n");
current++;
break;
case AML_ARG5_OP:
DBG( "Found Arg5Op\n");
current++;
break;
case AML_ARG6_OP:
DBG( "Found Arg6Op\n");
current++;
break;
default:
break;
case AML_ARG0_OP:
DBG( "Found Arg0Op\n");
current++;
break;
case AML_ARG1_OP:
DBG( "Found Arg1Op\n");
current++;
break;
case AML_ARG2_OP:
DBG( "Found Arg2Op\n");
current++;
break;
case AML_ARG3_OP:
DBG( "Found Arg3Op\n");
current++;
break;
case AML_ARG4_OP:
DBG( "Found Arg4Op\n");
current++;
break;
case AML_ARG5_OP:
DBG( "Found Arg5Op\n");
current++;
break;
case AML_ARG6_OP:
DBG( "Found Arg6Op\n");
current++;
break;
default:
break;
}
return current;
}
(void)ns;
(void)end;
switch (*current) {
case AML_LOCAL0_OP:
DBG( "Found Local0Op\n");
current++;
break;
case AML_LOCAL1_OP:
DBG( "Found Local1Op\n");
current++;
break;
case AML_LOCAL2_OP:
DBG( "Found Local2Op\n");
current++;
break;
case AML_LOCAL3_OP:
DBG("Found Local3Op\n");
current++;
break;
case AML_LOCAL4_OP:
DBG( "Found Local4Op\n");
current++;
break;
case AML_LOCAL5_OP:
DBG( "Found Local5Op\n");
current++;
break;
case AML_LOCAL6_OP:
DBG( "Found Local6Op\n");
current++;
break;
case AML_LOCAL7_OP:
DBG( "Found Local7Op\n");
current++;
break;
default:
break;
case AML_LOCAL0_OP:
DBG( "Found Local0Op\n");
current++;
break;
case AML_LOCAL1_OP:
DBG( "Found Local1Op\n");
current++;
break;
case AML_LOCAL2_OP:
DBG( "Found Local2Op\n");
current++;
break;
case AML_LOCAL3_OP:
DBG("Found Local3Op\n");
current++;
break;
case AML_LOCAL4_OP:
DBG( "Found Local4Op\n");
current++;
break;
case AML_LOCAL5_OP:
DBG( "Found Local5Op\n");
current++;
break;
case AML_LOCAL6_OP:
DBG( "Found Local6Op\n");
current++;
break;
case AML_LOCAL7_OP:
DBG( "Found Local7Op\n");
current++;
break;
default:
break;
}
return current;
}
current += 2;
DBG( "Found DebugOp\n");
}
return current;
}
static U8 *parse_acpi_datarefobject(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
DBG( "Beginning datarefobject: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_dataobject(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_simplename(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_namestring(ns, NULL, current, end);
if (current != temp)
return current;
current = parse_acpi_argobj(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_localobj(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_supername(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_simplename(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_debugobj(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_target(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_supername(ns, current, end);
if (current != temp)
return current;
if (*current == AML_NULL_NAME)
current++;
return current;
}
U32 pkglen;
U32 lengthEncoding;
struct acpi_namespace new_ns;
(void)end;
parsePackageLength(current, &pkglen, &lengthEncoding);
current += lengthEncoding;
new_end += pkglen;
temp = current;
current = parse_acpi_namestring(ns, &new_ns, current, new_end);
if (current == temp)
#endif
// U8 methodFlags
current++;
parse_acpi_termlist(&new_ns, current, new_end);
#if DEBUG_ACPI_DECODE
DBG( "End of Method: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
return new_end;
}
struct acpi_namespace new_ns;
U8 id;
U32 pmbase;
(void)end;
parsePackageLength(current, &pkglen, &lengthEncoding);
current += lengthEncoding;
new_end += pkglen;
temp = current;
current = parse_acpi_namestring(ns, &new_ns, current, new_end);
if (current == temp)
return new_end;
id = *current++;
pmbase = *(U32 *) current;
current += 4;
DBG( " id = 0x%x pmbase = 0x%x\n", id, pmbase);
#endif
add_processor(&new_ns, id, pmbase);
return new_end;
}
{
DBG( "Beginning namedobj: 0x%02x at memory location %p\n", *current, current);
switch (*current) {
case AML_EXT_OP_PREFIX:
case AML_EXT_OP_PREFIX:
{
if (*(current + 1) == AML_MUTEX_OP) {
struct acpi_namespace new_ns;
current += 2;
current = parse_acpi_namestring(ns, &new_ns, current, end);
#if DEBUG_ACPI_DECODE
current++; /* SyncFlags */
} else if (*(current + 1) == AML_OPREGION_OP) {
struct acpi_namespace new_ns;
current += 2;
DBG( "OpRegion at memory location %p\n", current);
current = parse_acpi_namestring(ns, &new_ns, current, end);
} else if (*(current + 1) == AML_FIELD_OP) {
U32 pkglen;
U32 lengthEncoding;
current += 2;
DBG( "FieldOp at memory location %p\n", current);
parsePackageLength(current, &pkglen, &lengthEncoding);
U32 pkglen;
U32 lengthEncoding;
struct acpi_namespace new_ns;
current += 2;
new_end = current;
DBG( "DeviceOp at memory location %p\n", current);
dprint_namespace(&new_ns);
DBG( "\n");
#endif
current = parse_acpi_objectlist(&new_ns, current, new_end);
parse_acpi_objectlist(&new_ns, current, new_end);
current = new_end;
} else if (*(current + 1) == AML_PROCESSOR_OP) {
current += 2;
U32 pkglen;
U32 lengthEncoding;
struct acpi_namespace new_ns;
current += 2;
new_end = current;
DBG( "IndexFieldOp at memory location %p\n", current);
dprint_namespace(&new_ns);
DBG( "\n");
#endif
current = parse_acpi_objectlist(&new_ns, current, new_end);
parse_acpi_objectlist(&new_ns, current, new_end);
current = new_end;
}
break;
}
case AML_METHOD_OP:
case AML_METHOD_OP:
{
current++;
current = parse_acpi_method(ns, current, end);
break;
}
default:
break;
default:
break;
}
return current;
}
{
DBG( "Beginning type1opcode: 0x%02x at memory location %p\n", *current, current);
switch (*current) {
case AML_IF_OP:
case AML_IF_OP:
{
U8 *new_end;
U32 pkgLen;
U32 lengthEncoding;
DBG( "Found IfOp\n");
current++;
parsePackageLength(current, &pkgLen, &lengthEncoding);
new_end = current + pkgLen;
current += lengthEncoding;
current = parse_acpi_termarg(ns, current, new_end);
parse_acpi_termlist(ns, current, new_end);
current = new_end;
break;
}
case AML_ELSE_OP:
case AML_ELSE_OP:
{
U8 *new_end;
U32 pkgLen;
U32 lengthEncoding;
DBG( "Found ElseOp\n");
current++;
parsePackageLength(current, &pkgLen, &lengthEncoding);
new_end = current + pkgLen;
current += lengthEncoding;
parse_acpi_termlist(ns, current, new_end);
current = new_end;
break;
}
case AML_RETURN_OP:
case AML_RETURN_OP:
{
DBG( "Found ReturnOp\n");
current++;
current = parse_acpi_termarg(ns, current, end);
break;
}
default:
break;
default:
break;
}
return current;
}
static U8 *parse_acpi_type2opcode(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
DBG( "Beginning type2opcode: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_package(ns, current, end);
if (current != temp)
return current;
switch (*current) {
case AML_LNOT_OP:
current++;
DBG( "Found logical not operator\n");
current = parse_acpi_termarg(ns, current, end);
break;
case AML_LAND_OP:
case AML_LOR_OP:
case AML_LEQUAL_OP:
case AML_LGREATER_OP:
case AML_LLESS_OP:
DBG( "Found logical binary operator: %c\n", "&|!=><"[*current - AML_LAND_OP]);
current++;
current = parse_acpi_termarg(ns, current, end);
current = parse_acpi_termarg(ns, current, end);
break;
case AML_EXT_OP_PREFIX:
case AML_LNOT_OP:
current++;
DBG( "Found logical not operator\n");
current = parse_acpi_termarg(ns, current, end);
break;
case AML_LAND_OP:
case AML_LOR_OP:
case AML_LEQUAL_OP:
case AML_LGREATER_OP:
case AML_LLESS_OP:
DBG( "Found logical binary operator: %c\n", "&|!=><"[*current - AML_LAND_OP]);
current++;
current = parse_acpi_termarg(ns, current, end);
current = parse_acpi_termarg(ns, current, end);
break;
case AML_EXT_OP_PREFIX:
{
if (*(current + 1) == AML_COND_REF_OF_OP) {
DBG( "Found CondRefOf\n");
}
break;
}
case AML_STORE_OP:
case AML_STORE_OP:
{
DBG( "Found StoreOp\n");
current++;
current = parse_acpi_supername(ns, current, end);
break;
}
default:
default:
{
current = parse_acpi_namestring(ns, NULL, current, end);
if (current == temp)
if (*current == AML_PACKAGE_OP) {
U32 pkglen;
U32 lengthEncoding;
DBG( "Found PackageOp\n");
current++;
parsePackageLength(current, &pkglen, &lengthEncoding);
static U8 *parse_acpi_dataobject(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_computationaldata(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_package(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_termarg(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
DBG( "Beginning termarg: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_type2opcode(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_dataobject(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_argobj(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_localobj(ns, current, end);
if (current != temp)
return current;
return current;
}
{
DBG( "Beginning namespacemodifierobj: 0x%02x at memory location %p\n", *current, current);
switch (*current) {
case AML_SCOPE_OP:
case AML_SCOPE_OP:
{
U8 *new_end;
struct acpi_namespace new_ns;
U32 scopeLen;
U32 lengthEncoding;
current++;
parsePackageLength(current, &scopeLen, &lengthEncoding);
new_end = current + scopeLen;
current = parse_acpi_namestring(ns, &new_ns, current + lengthEncoding, new_end);
#if DEBUG_ACPI_DECODE
DBG( "Found Scope: ");
current = new_end;
break;
}
case AML_NAME_OP:
current++;
current = parse_acpi_namestring(ns, NULL, current, end);
current = parse_acpi_datarefobject(ns, current, end);
break;
case AML_ALIAS_OP:
current++;
current = parse_acpi_namestring(ns, NULL, current, end);
current = parse_acpi_namestring(ns, NULL, current, end);
break;
default:
break;
case AML_NAME_OP:
current++;
current = parse_acpi_namestring(ns, NULL, current, end);
current = parse_acpi_datarefobject(ns, current, end);
break;
case AML_ALIAS_OP:
current++;
current = parse_acpi_namestring(ns, NULL, current, end);
current = parse_acpi_namestring(ns, NULL, current, end);
break;
default:
break;
}
return current;
}
DBG( "Beginning objectlist: 0x%02x at memory location %p end=%p\n", *current, current, end);
while (current < end) {
U8 *temp = current;
DBG( "New iteration of objectlist: 0x%02x at memory location %p end=%p\n", *current, current, end);
current = parse_acpi_namespacemodifierobj(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_namedobj(ns, current, end);
if (current != temp)
continue;
if (current == temp) {
DBG( "Unhandled object in object list: 0x%02x at memory location %p\n", *current, current);
#if DEBUG_ACPI_DECODE
DBG( "Beginning termarglist: 0x%02x at memory location %p\n", *current, current);
while (current < end) {
U8 *temp = current;
current = parse_acpi_termarg(ns, current, end);
if (current == temp) {
DBG( "Unhandled item in term arg list: 0x%02x at memory location %p\n", *current, current);
{
while (current < end) {
U8 *temp = current;
DBG( "Beginning new term in term list: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_namespacemodifierobj(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_namedobj(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_type1opcode(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_type2opcode(ns, current, end);
if (current != temp)
continue;
switch (*current) {
default:
default:
{
DBG( "Unhandled item in term list: 0x%02x at memory location %p\n", *current, current);
#if DEBUG_ACPI_DECODE
branches/cparm/i386/modules/ACPICodec/acpi_codec.c
175175
176176
177177
178
178
179179
180180
181181
......
371371
372372
373373
374
374
375375
376376
377377
......
478478
479479
480480
481
481
482482
483483
484484
......
819819
820820
821821
822
823822
824823
825824
......
834833
835834
836835
837
836
838837
839838
840839
......
903902
904903
905904
905
906906
907907
908908
......
12761276
12771277
12781278
1279
1279
1280
1281
1282
1283
1284
1285
12801286
12811287
12821288
......
43024308
43034309
43044310
4305
4311
43064312
43074313
43084314
......
44524458
44534459
44544460
4461
44554462
44564463
44574464
......
44604467
44614468
44624469
4463
4464
4465
44664470
44674471
44684472
......
44724476
44734477
44744478
4475
4479
44764480
44774481
44784482
//#define ULONG_MAX_32 4294967295UL
#define __RES(s, u)\
inline unsigned u\
static inline unsigned u\
resolve_##s(unsigned u defaultentry, char *str, int base) \
{\
unsigned u entry = defaultentry;\
getIntForKey(kAcpiMethod, &method, DEFAULT_BOOT_CONFIG);
if (method != 0x2000)
if (method != 0x2)
{
if (GetChecksum(((ACPI_TABLE_HEADER *) (unsigned long)ptr),
((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Length) != 0)
getIntForKey(kAcpiMethod, &method, DEFAULT_BOOT_CONFIG);
if (method != 0x2000)
if (method != 0x2)
{
if (GetChecksum(table_array[index], table_array[index]->Length) != 0)
{
static U32 compute_tdp(CPU_DETAILS * cpu)
{
{
if (is_jaketown() || is_sandybridge())
{
return cpu->tdp_limit / 8;
}
}
return (0);
}
#endif // BUILD_ACPI_TSS || pstate_power_support
U32 ratio_factor = (ratio * PRECISION_FACTOR)/P1_Ratio;
return ((ratio_factor * ratio_factor * ratio_factor * Core_TDP) / PRECISION_FACTOR_CUBED) + Uncore_TDP;
}
return (0);
}
#endif // pstate_power_support
{
struct p_state p_states[32];
U8 p_states_count = 0;
U8 p_states_count = 0;
if (!cpu)
{
return (0);
}
{
#if UNUSED
struct p_state initial;
getIntForKey(kAcpiMethod, &method, DEFAULT_BOOT_CONFIG);
if (method != 0x2000)
if (method != 0x2)
{
if (GetChecksum(((ACPI_TABLE_HEADER *) (unsigned long)ptr),
((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Length) != 0)
bzero(rsdt_mod, rsdt->Header.Length);
memcpy (&rsdt_mod->Header, &rsdt->Header, sizeof(ACPI_TABLE_HEADER));
// Compute number of table pointers included in RSDT
U32 num_tables = get_num_tables(rsdt);
verbose("* Processing RSDT: \n");
ACPI_TABLE_HEADER **table_array = (ACPI_TABLE_HEADER **) rsdt->TableOffsetEntry;
// Compute number of table pointers included in RSDT
num_tables = get_num_tables(rsdt);
for (index = 0; index < num_tables; index++)
{
getIntForKey(kAcpiMethod, &method, DEFAULT_BOOT_CONFIG);
if (method != 0x2000)
if (method != 0x2)
{
if (GetChecksum(table_array[index], table_array[index]->Length) != 0)
{
branches/cparm/i386/cdboot/Makefile
22
33
44
5
5
66
77
88
DIR = cdboot
include ../MakePaths.dir
NASM = /Developer/usr/bin/nasm
NASM = /usr/bin/nasm
INSTALLDIR = $(DSTROOT)/usr/standalone/i386
DIRS_NEEDED = $(SYMROOT)
branches/cparm/i386/libsa/bzero.s
8989
9090
9191
92
9293
9394
9495
......
106107
107108
108109
109
110
/*
* void bzero(char * addr, size_t length)
*/
LABEL(___bzero) /* only for a compatibility issue */
LABEL(_bzero)
pushl%edi
movl4+ 4(%esp),%edi/* addr */
rep
stosb
popl%edi
ret
ret
branches/cparm/i386/libsa/qdivrem.c
94<