Chameleon

Chameleon Commit Details

Date:2011-12-20 02:15:53 (12 years 4 months ago)
Author:armel cadet-petit
Commit:1735
Parents: 1734
Message:fixes, enhancements and updates, please see the changelog
Changes:
A/branches/cparm/artwork/themes/LoginToLion/device_scroll_next.png
A/branches/cparm/artwork/themes/LoginToLion/background.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_leo_o.png
A/branches/cparm/artwork/themes/LoginToLion/menu_verbose_disabled.png
A/branches/cparm/artwork/themes/LoginToLion/device_cdrom.png
A/branches/cparm/i386/util/amlsgn.m
A/branches/cparm/artwork/themes/LoginToLion/progress_bar.png
A/branches/cparm/artwork/themes/LoginToLion/menu_verbose.png
A/branches/cparm/artwork/themes/LoginToLion/text_scroll_prev.png
A/branches/cparm/artwork/themes/LoginToLion/boot.png
A/branches/cparm/artwork/themes/LoginToLion/menu_single_user.png
A/branches/cparm/artwork/themes/LoginToLion/menu_video_info.png
A/branches/cparm/artwork/themes/LoginToLion/device_scroll_prev.png
A/branches/cparm/artwork/themes/LoginToLion/menu_help.png
A/branches/cparm/artwork/themes/LoginToLion
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_sl_o.png
A/branches/cparm/artwork/themes/LoginToLion/device_ext3_o.png
A/branches/cparm/i386/util/Intel_Acpi/ppmsetup.h
A/branches/cparm/artwork/themes/LoginToLion/progress_bar_background.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_sl.png
A/branches/cparm/i386/util/Intel_Acpi/ppm.h
A/branches/cparm/artwork/themes/LoginToLion/device_ntfs_o.png
A/branches/cparm/artwork/themes/LoginToLion/menu_selection.png
A/branches/cparm/artwork/themes/LoginToLion/device_generic_o.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_tiger_o.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsraid_o.png
A/branches/cparm/i386/util/Intel_Acpi
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_lion.png
A/branches/cparm/i386/util/Intel_Acpi/acpidecode.h
A/branches/cparm/artwork/themes/LoginToLion/menu_boot.png
A/branches/cparm/artwork/themes/LoginToLion/device_openbsd_o.png
A/branches/cparm/artwork/themes/LoginToLion/device_ntfs.png
A/branches/cparm/artwork/themes/LoginToLion/menu_single_user_disabled.png
A/branches/cparm/artwork/themes/LoginToLion/device_generic.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_tiger.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsraid.png
A/branches/cparm/artwork/themes/LoginToLion/logo.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_leo.png
A/branches/cparm/artwork/themes/LoginToLion/menu_ignore_caches_disabled.png
A/branches/cparm/artwork/themes/LoginToLion/device_fat_o.png
A/branches/cparm/artwork/themes/LoginToLion/device_freebsd_o.png
A/branches/cparm/artwork/themes/LoginToLion/theme.plist
A/branches/cparm/artwork/themes/LoginToLion/device_openbsd.png
A/branches/cparm/i386/util/Intel_Acpi/intel_acpi.h
A/branches/cparm/artwork/themes/LoginToLion/menu_ignore_caches.png
A/branches/cparm/i386/util/Intel_Acpi/datatype.h
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_o.png
A/branches/cparm/artwork/themes/LoginToLion/font_console.png
A/branches/cparm/artwork/themes/LoginToLion/device_freebsd.png
A/branches/cparm/artwork/themes/LoginToLion/device_fat.png
A/branches/cparm/artwork/themes/LoginToLion/font_small.png
A/branches/cparm/artwork/themes/LoginToLion/text_scroll_next.png
A/branches/cparm/artwork/themes/LoginToLion/device_cdrom_o.png
A/branches/cparm/artwork/themes/LoginToLion/device_ext3.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus_lion_o.png
A/branches/cparm/artwork/themes/LoginToLion/device_hfsplus.png
A/branches/cparm/artwork/themes/LoginToLion/device_selection.png
A/branches/cparm/artwork/themes/LoginToLion/menu_memory_info.png
M/branches/cparm/i386/modules/HibernateEnabler/resume.c
M/branches/cparm/i386/util/Makefile
M/branches/cparm/i386/libsaio/disk.c
M/branches/cparm/CHANGES
M/branches/cparm/i386/modules/NetbookInstaller/NBI.c
M/branches/cparm/i386/libsaio/fake_efi.c
M/branches/cparm/i386/modules/RamDiskLoader/ramdisk.h
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/modules/RamDiskLoader/RamDiskLoader.c
M/branches/cparm/i386/boot2/drivers.c
M/branches/cparm/i386/libsaio/saio_types.h
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/i386/modules/GUI/gui.h
M/branches/cparm/i386/libsaio/bootstruct.c

File differences

branches/cparm/CHANGES
1
2
3
4
5
6
7
8
9
10
111
212
313
......
3747
3848
3949
40
50
4151
4252
4353
- Chameleon can now boot the Lion Auto-Installer partition (additionally, on a GPT disk this enable the option "Localize my Mac" of iCloud)
- Added a first version of amlsgn (NOTE: This tool can can sign an aml file for your machine (with the UUID) or for your machine model, this can be useful
with multiple machines w/o an identical model, combined with acpicodec and the option "LoadSignedAmlOnly", you can make sure that Chameleon will load the good
aml files (even if you have about 50 dsdt files named differently in your Acpi directory and each one for a different machine) )
- Applied Guerrero's patch on gui.c (http://forge.voodooprojects.org/p/chameleon/issues/view/attachment/152/gui.diff)
- Added a theme compatible with the OS detection/Volume feature (credit to Enzo for LoginToLion, see http://forum.voodooprojects.org/index.php?topic=2125.0 for more.)
- Fixed a mistake with the smbios.plist loading process
- Reworked the OS detection/Volume (NOTE: now embedded into the core and executed much earlier )
- Added Haiku support (credit to scorpius)
- Added EXFAT (FAT64) support (credit to dmazar)
- Added JrCs fixes (see trunk v1716 v1719)
- Updated keymapper ...
- Applied scorpius's patch (to get an unstretched boot screen for nVidia cards on DVI) in boot0.s , disabled by default,
see - http://forum.voodooprojects.org/index.php/topic,2158.msg10345/boardseen.html#new - for more info.
- Applied Vladimir Zidar's hibernate patch on hibernateEnabler
- Applied Vladimir Zidar's hibernate patch on hibernateEnabler.
- Applied "Intel HD Graphics 3000" patch to gma.c (credit: ???) ,
found at - http://www.darwinx86.net/forum/61-section-francaise-/1880-espace-de-discussion-anval?limit=10&start=60#6247 -
- Added AMD support (most of the code is derived from the trunk, MUST BE ENABLED BY HAND IN CPU.C) see - http://forge.voodooprojects.org/p/chameleon/issues/163/ -
branches/cparm/artwork/themes/LoginToLion/theme.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Author</key>
<string>Enzo</string>
<key>Enabled</key>
<string>no</string>
<key>Version</key>
<string>1.0</string>
<key>background_pos_x</key>
<string></string>
<key>background_pos_y</key>
<string></string>
<key>boot_bgcolor</key>
<string>#AAAAAA</string>
<key>boot_height</key>
<string>768</string>
<key>boot_width</key>
<string>1024</string>
<key>bootprompt_bgcolor</key>
<string>#232427</string>
<key>bootprompt_height</key>
<string>20</string>
<key>bootprompt_pos_x</key>
<string></string>
<key>bootprompt_pos_y</key>
<string>-2</string>
<key>bootprompt_textmargin_h</key>
<string>10</string>
<key>bootprompt_textmargin_v</key>
<string>5</string>
<key>bootprompt_transparency</key>
<string>60</string>
<key>bootprompt_width</key>
<string>40%</string>
<key>countdown_pos_x</key>
<string></string>
<key>countdown_pos_y</key>
<string>-28%</string>
<key>devices_bgcolor</key>
<string>#232427</string>
<key>devices_iconspacing</key>
<string>80</string>
<key>devices_layout</key>
<string>horizontal</string>
<key>devices_max_visible</key>
<string>5</string>
<key>devices_pos_x</key>
<string></string>
<key>devices_pos_y</key>
<string>38%</string>
<key>devices_transparency</key>
<string>255</string>
<key>infobox_bgcolor</key>
<string>#232427</string>
<key>infobox_height</key>
<string>406</string>
<key>infobox_pos_x</key>
<string></string>
<key>infobox_pos_y</key>
<string></string>
<key>infobox_textmargin_h</key>
<string>10</string>
<key>infobox_textmargin_v</key>
<string>10</string>
<key>infobox_transparency</key>
<string>60</string>
<key>infobox_width</key>
<string>800</string>
<key>logo_bgcolor</key>
<string>#000000</string>
<key>logo_pos_x</key>
<string></string>
<key>logo_pos_y</key>
<string>25%</string>
<key>logo_transparency</key>
<string>255</string>
<key>menu_bgcolor</key>
<string>#3c3e42</string>
<key>menu_pos_x</key>
<string></string>
<key>menu_pos_y</key>
<string>-5%</string>
<key>menu_textmargin_h</key>
<string>10</string>
<key>menu_textmargin_v</key>
<string>5</string>
<key>menu_transparency</key>
<string>255</string>
<key>progressbar_height</key>
<string>40</string>
<key>progressbar_pos_x</key>
<string></string>
<key>progressbar_pos_y</key>
<string>-33%</string>
<key>progressbar_width</key>
<string>100</string>
<key>screen_bgcolor</key>
<string>#3c3e42</string>
<key>screen_height</key>
<string>768</string>
<key>screen_textmargin_h</key>
<string>10</string>
<key>screen_textmargin_v</key>
<string>10</string>
<key>screen_width</key>
<string>1024</string>
</dict>
</plist>
branches/cparm/i386/libsaio/bootstruct.c
153153
154154
155155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
156
182157
183158
184159
......
194169
195170
196171
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
172
221173
222174
223175
void
reserveKern107BootStruct(void)
{
//bootArgs107 = (boot_args_107 *)AllocateKernelMemory(sizeof(boot_args_107));
/* Common Darwin boot arguments */
/*
bootArgs107->Revision = bootArgs->Header.Revision ;
bootArgs107->Version = bootArgs->Header.Version ;
bcopy(bootArgs->CommandLine, bootArgs107->CommandLine, BOOT_LINE_LENGTH);
bootArgs107->MemoryMap = bootArgs->MemoryMap ;
bootArgs107->MemoryMapSize = bootArgs->MemoryMapSize ;
bootArgs107->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize ;
bootArgs107->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion ;
bootArgs107->Video = bootArgs->Video ;
bootArgs107->deviceTreeP = bootArgs->deviceTreeP ;
bootArgs107->deviceTreeLength = bootArgs->deviceTreeLength ;
bootArgs107->kaddr = bootArgs->kaddr ;
bootArgs107->ksize = bootArgs->ksize ;
bootArgs107->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart ;
bootArgs107->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount ;
bootArgs107->efiSystemTable = bootArgs->efiSystemTable ;
bootArgs107->efiMode = bootArgs->efiMode ;
bootArgs107->performanceDataStart = bootArgs->performanceDataStart ;
bootArgs107->performanceDataSize = bootArgs->performanceDataSize ;
bootArgs107->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart ;
*/
{
init_boot_args(107);
/* Darwin 10.7 specific boot arguments */
void
reserveKernLegacyBootStruct(void)
{
//bootArgsLegacy = (boot_args_legacy *)AllocateKernelMemory(sizeof(boot_args_legacy));
/*
bootArgsLegacy->Revision = bootArgs->Header.Revision ;
bootArgsLegacy->Version = bootArgs->Header.Version ;
bcopy(bootArgs->CommandLine, bootArgsLegacy->CommandLine, BOOT_LINE_LENGTH);
bootArgsLegacy->MemoryMap = bootArgs->MemoryMap ;
bootArgsLegacy->MemoryMapSize = bootArgs->MemoryMapSize ;
bootArgsLegacy->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize ;
bootArgsLegacy->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion ;
bootArgsLegacy->Video = bootArgs->Video ;
bootArgsLegacy->deviceTreeP = bootArgs->deviceTreeP ;
bootArgsLegacy->deviceTreeLength = bootArgs->deviceTreeLength ;
bootArgsLegacy->kaddr = bootArgs->kaddr ;
bootArgsLegacy->ksize = bootArgs->ksize ;
bootArgsLegacy->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart ;
bootArgsLegacy->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount ;
bootArgsLegacy->efiSystemTable = bootArgs->efiSystemTable ;
bootArgsLegacy->efiMode = bootArgs->efiMode ;
bootArgsLegacy->performanceDataStart = bootArgs->performanceDataStart ;
bootArgsLegacy->performanceDataSize = bootArgs->performanceDataSize ;
bootArgsLegacy->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart ;
*/
{
init_boot_args(Legacy);
}
branches/cparm/i386/libsaio/disk.c
9191
9292
9393
94
95
96
97
98
99
100
101
94102
95103
96104
......
188196
189197
190198
199
191200
192201
193202
......
15101519
15111520
15121521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
15131577
15141578
15151579
15161580
15171581
1518
15191582
1520
15211583
15221584
15231585
......
15641626
15651627
15661628
1567
1568
1569
1570
1571
1629
15721630
1573
1574
1631
15751632
1576
1577
1578
15791633
15801634
15811635
#define DBG(x...)
#endif
#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#endif
#ifdef APPLE_PARTITION_MAP_SUPPORT
#defineUINT_MAX0xffffffff/* max value for an unsigned int, defined in <limits.h>. */
#include <IOKit/storage/IOApplePartitionScheme.h>
#ifdef APPLE_PARTITION_MAP_SUPPORT
static BVRef diskScanAPMBootVolumes( int biosdev, int * countPtr );
#endif
static bool getOSVersion(BVRef bvr, char *str);
//==========================================================================
}
}
static bool getOSVersion(BVRef bvr, char *str)
{
bool valid = false;
config_file_t systemVersion;
char dirSpec[512];
long flags, time;
sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &systemVersion))
{
valid = true;
}
else
{
sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &systemVersion))
{
sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
valid = true;
}
else
{
sprintf(dirSpec, "hd(%d,%d)/", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (GetFileInfo(dirSpec, "Mac OS X Install Data", &flags, &time) == 0)
{
*str = '\0';
strncat(str, "10.7", 4);
return true;
}
}
}
if (valid)
{
const char *val;
int len;
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 4));
}
else
valid = false;
}
return valid;
}
//==========================================================================
static void scanFSLevelBVRSettings(BVRef chain)
{
BVRef bvr;
char dirSpec[512], fileSpec[512];
int ret;
long flags, time;
#ifdef BOOT_HELPER_SUPPORT
char label[BVSTRLEN];
int fh, fileSize, error;
//
if (bvr->flags & kBVFlagNativeBoot)
{
sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/", BIOS_DEV_UNIT(bvr), bvr->part_no);
strcpy(fileSpec, "SystemVersion.plist");
ret = GetFileInfo(dirSpec, fileSpec, &flags, &time);
if (ret == -1)
if (getOSVersion(bvr,bvr->OSVersion) == true)
{
strcpy(fileSpec, "ServerVersion.plist");
ret = GetFileInfo(dirSpec, fileSpec, &flags, &time);
bvr->flags |= kBVFlagSystemVolume;
}
if (!ret)
bvr->flags |= kBVFlagSystemVolume;
}
}
branches/cparm/i386/libsaio/saio_types.h
207207
208208
209209
210
210211
211212
212213
char altlabel[BVSTRLEN]; /* partition volume label */
bool filtered; /* newFilteredBVChain() will set to TRUE */
bool visible; /* will shown in the device list */
char OSVersion[8];
};
enum {
branches/cparm/i386/libsaio/fake_efi.c
743743
744744
745745
746
747
748746
749747
750748
751749
752750
753
751
754752
755753
756754
......
845843
846844
847845
848
846
849847
850
851
848
852849
853
854850
855851
856852
......
878874
879875
880876
881
877
882878
883879
884880
Node *efiNode = DT__AddChild(node, "efi");
{
extern char gMacOSVersion[];
// Set up the /efi/runtime-services table node similar to the way a child node of configuration-table
// is set up. That is, name and table properties
Node *runtimeServicesNode = DT__AddChild(efiNode, "runtime-services");
Node *kernelCompatibilityNode = 0; // ??? not sure that it should be used like that (because it's maybe the kernel capability and not the cpu capability)
if (gMacOSVersion[3] > '6')
if (gBootVolume->OSVersion[3] > '6')
{
kernelCompatibilityNode = DT__AddChild(efiNode, "kernel-compatibility");
DT__AddProperty(kernelCompatibilityNode, "i386", sizeof(uint32_t), (EFI_UINT32*)&DEVICE_SUPPORTED);
void setupSmbiosConfigFile(const char *filename)
{
//static bool readSmbConfigFile = true;
static bool readSmbConfigFile = true;
if (&bootInfo->bootConfig == 0)
//if (readSmbConfigFile == true)
if (readSmbConfigFile == true)
{
verbose("loading smbios plist\n");
chardirSpecSMBIOS[128] = "";
const char *override_pathname = NULL;
intlen = 0, err = 0;
{
verbose("No SMBIOS config file found.\n");
}
//readSmbConfigFile = false;
readSmbConfigFile = false;
}
}
branches/cparm/i386/boot2/boot.c
8787
8888
8989
90
9190
9291
9392
......
111110
112111
113112
114
115113
116114
117115
......
199197
200198
201199
202
200
203201
204202
205
203
206204
207205
208206
......
211209
212210
213211
214
212
215213
216214
217215
......
337335
338336
339337
340
338
341339
342
340
343341
344342
345343
......
351349
352350
353351
354
352
355353
356354
357355
......
592590
593591
594592
595
596
597
598
593
599594
600595
601596
......
647642
648643
649644
650
645
651646
652647
653648
......
701696
702697
703698
704
699
705700
706701
707702
......
853848
854849
855850
856
851
857852
858853
859854
860
855
861856
862857
863858
......
908903
909904
910905
911
906
912907
913908
914909
......
10171012
10181013
10191014
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
10531015
10541016
10551017
bool gOverrideKernel;
char gBootKernelCacheFile[512];
char gMKextName[512];
char gMacOSVersion[8];
char *gRootDevice = NULL;
#ifndef OPTION_ROM
static inline void malloc_error(char *addr, size_t size);
#endif
static int ExecKernel(void *binary);
static bool getOSVersion(char *str);
static void getRootDevice();
#ifdef NBP_SUPPORT
static bool gUnloadPXEOnExit = false;
bootArgs->kaddr = bootArgs->ksize = 0;
if(gMacOSVersion[3] <= '6')
if(gBootVolume->OSVersion[3] <= '6')
{
bootArgs->Header.Version = kBootArgsVersion1;
bootArgs->Header.Revision = gMacOSVersion[3];
bootArgs->Header.Revision = gBootVolume->OSVersion[3];
}
else
{
bootArgs->Header.Version = kBootArgsVersion;
bootArgs->Header.Revision = kBootArgsRevision;
#else
if(gMacOSVersion[3] == '7')
if(gBootVolume->OSVersion[3] == '7')
{
bootArgs->Header.Version = 2;
bootArgs->Header.Revision = 0;
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL, NULL, NULL);// Notify modules that the kernel is about to be started
if (gMacOSVersion[3] <= '6')
if (gBootVolume->OSVersion[3] <= '6')
reserveKernLegacyBootStruct();
else if (gMacOSVersion[3] == '7')
else if (gBootVolume->OSVersion[3] == '7')
reserveKern107BootStruct();
#if UNUSED
IMPS_LAPIC_WRITE(LAPIC_LVT1, LAPIC_ICR_DM_NMI);
#endif
switch (gMacOSVersion[3]) {
switch (gBootVolume->OSVersion[3]) {
case '4':
case '5':
case '6':
// Other status (e.g. 0) means that we should proceed with boot.
execute_hook("GUI_PreBoot", NULL, NULL, NULL, NULL, NULL, NULL);
// Find out which version mac os we're booting.
getOSVersion(gMacOSVersion);
if (getValueForKey(karch, &val, &len, &bootInfo->bootConfig) && val)
{
if (strncmp(val, "x86_64", 4) == 0)
trycache = false;
}
verbose("Loading Darwin %s\n", gMacOSVersion);
verbose("Loading Darwin %s\n", gBootVolume->OSVersion);
{
long cachetime, kerneltime, exttime;
if (trycache && !forcecache) do {
{
bootFile = gBootKernelCacheFile;
verbose("Loading kernel cache %s\n", bootFile);
if (gMacOSVersion[3] > '6')
if (gBootVolume->OSVersion[3] > '6')
{
ret = LoadThinFatFile(bootFile, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)
}
else
{
if(gMacOSVersion[3] > '6')
if(gBootVolume->OSVersion[3] > '6')
{
sprintf(gBootKernelCacheFile, "%s", kDefaultCachePath);
}
else if(gMacOSVersion[3] <= '6')
else if(gBootVolume->OSVersion[3] <= '6')
{
PlatformInfo *platformInfo = malloc(sizeof(PlatformInfo));
DBG("Adler32: %08lX\n",bootInfo->adler32);
if (gMacOSVersion[3] < '6')
if (gBootVolume->OSVersion[3] < '6')
{
long flags, cachetime;
int ret = -1;
gRootDevice = (char* )val;
}
static bool getOSVersion(char *str)
{
bool valid = false;
config_file_t systemVersion;
if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion))
{
valid = true;
}
else if (!loadConfigFile("System/Library/CoreServices/ServerVersion.plist", &systemVersion))
{
valid = true;
}
if (valid)
{
const char *val;
int len;
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 4));
}
else
valid = false;
}
return valid;
}
static bool find_file_with_ext(const char* dir, const char *ext, const char * name_compare, size_t ext_size)
{
char* name;
branches/cparm/i386/boot2/drivers.c
4040
4141
4242
43
4443
4544
4645
......
126125
127126
128127
129
128
130129
131130
132131
......
138137
139138
140139
141
140
142141
143142
144143
......
762761
763762
764763
765
764
766765
767766
768767
#include "drivers.h"
#include "modules.h"
extern char gMacOSVersion[];
extern char gBootKernelCacheFile[];
static ModulePtr gModuleHead, gModuleTail;
#endif
// First try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "/Extra/%s/", &gMacOSVersion);
sprintf(dirSpecExtra, "/Extra/%s/", &gBootVolume->OSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next try to load Extra extensions from the selected root partition.
if (!(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no))
{
// First try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gBootVolume->OSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
printf("adler mismatch\n");
return -1;
}
if (((gBootMode & kBootModeSafe) == 0) && (gBootKernelCacheFile[0] != '\0') && gMacOSVersion[3] > '6')
if (((gBootMode & kBootModeSafe) == 0) && (gBootKernelCacheFile[0] != '\0') && gBootVolume->OSVersion[3] > '6')
bootInfo->adler32 = kernel_header->adler32;
}
branches/cparm/i386/modules/NetbookInstaller/NBI.c
2929
3030
3131
32
33
34
3532
3633
3734
#endif
extern long FileLoadDrivers(char *dirSpec, long plugin);
extern char gMacOSVersion;
extern long LoadDriverMKext(char *fileSpec);
extern long LoadDriverPList(char *dirSpec, char *name, long bundleType);
branches/cparm/i386/modules/RamDiskLoader/ramdisk.h
3535
3636
3737
38
3938
4039
4140
extern BVRef gRAMDiskVolume;
extern bool gRAMDiskBTAliased;
extern char gMacOSVersion;
extern long FileLoadDrivers(char *dirSpec, long plugin);
extern void setRAMDiskBTHook(bool mode);
branches/cparm/i386/modules/RamDiskLoader/RamDiskLoader.c
5454
5555
5656
57
57
5858
5959
6060
......
6464
6565
6666
67
67
6868
6969
7070
break;
case 1:
// First try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "rd(0,0)/Extra/%s/", &gMacOSVersion);
sprintf(dirSpecExtra, "rd(0,0)/Extra/%s/", &gBootVolume->OSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
break;
case 2:
// First try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gBootVolume->OSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
branches/cparm/i386/modules/GUI/gui.c
8080
8181
8282
83
84
85
86
87
8388
8489
8590
......
497502
498503
499504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
500537
501538
502539
......
959996
960997
961998
962
999
9631000
9641001
9651002
......
10491086
10501087
10511088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
10521099
10531100
10541101
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
11431102
11441103
11451104
11461105
11471106
1148
11491107
11501108
11511109
......
11571115
11581116
11591117
1160
1161
1162
1118
11631119
11641120
11651121
1166
1167
1168
1169
1122
1123
11701124
11711125
11721126
......
11861140
11871141
11881142
1189
1143
11901144
1191
1192
1193
1145
11941146
11951147
11961148
......
12641216
12651217
12661218
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
14531219
14541220
14551221
......
20231789
20241790
20251791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
20261807
20271808
20281809
#endif
static int getImageIndexByName(const char *name);
static int destroyFont(font_t *font);
static int unloadGraphics(void);
static int freeBackBuffer( window_t *window );
static bool is_image_loaded(int i);
#define LOADPNG(src, img, alt_img) if (loadThemeImage(src, #img, alt_img) != 0) { return 1; }
#ifndef MIN
return 0;
}
static int unloadGraphics(void)
{
int i;
destroyFont(&font_console);
destroyFont(&font_small);
for (i = 0; i < sizeof(images) / sizeof(images[0]); i++)
{
if (images[i].image)
{
if (images[i].image->pixels) free(images[i].image->pixels);
free (images[i].image);
images[i].image = 0;
}
}
return 0;
}
static int freeBackBuffer( window_t *window )
{
if (gui.backbuffer && gui.backbuffer->pixels)
{
free(gui.backbuffer->pixels);
free(gui.backbuffer);
gui.backbuffer = 0;
return 0;
}
return 1;
}
#if UNUSED
pixmap_t *getCroppedPixmapAtPosition( pixmap_t *from, position_t pos, uint16_t width, uint16_t height )
{
if (ret) printf("Failed to load Default Theme : %s !! \n", THEME_NAME_DEFAULT);
}
}
}
return ret;
}
}
}
}
// Loading error occurred, freeing resources
freeWindowBuffer(&gui.menu);
freeWindowBuffer(&gui.infobox);
freeWindowBuffer(&gui.bootprompt);
freeWindowBuffer(&gui.devicelist);
freeWindowBuffer(&gui.screen);
freeBackBuffer(&gui.screen);
unloadGraphics();
return 1;
}
/*************************************************
*
* Volume Versioning Management
*/
volume_t* volumeList = NULL;
bool add_volume(char* Version, BVRef bvr)
{
volume_t* new_volume= malloc(sizeof(volume_t));
if (new_volume)
{
new_volume->next = volumeList;
volumeList = new_volume;
strlcpy(new_volume->version,Version,sizeof(new_volume->version)+1);
new_volume->bvr = bvr;
return true;
}
return false;
}
bool get_volume_version(char *str,BVRef bvr)
{
volume_t* volume = volumeList;
while(volume)
{
if (volume->bvr == bvr) {
strlcpy(str,volume->version,sizeof(volume->version)+1);
return true;
}
volume = volume->next;
}
return false;
}
static bool getOSVersionForVolume(char *str, BVRef bvr)
{
bool valid = false;
if (get_volume_version(str,bvr) == false)
{
char dirSpec[128];
char dirSpec2[128];
config_file_t systemVersion;
sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
sprintf(dirSpec2, "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &systemVersion))
{
valid = true;
}
else if (!loadConfigFile(dirSpec2, &systemVersion))
{
valid = true;
}
if (valid)
{
const char *val;
int len;
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 4));
add_volume(str, bvr);
}
else
valid = false;
}
}
else
{
valid = true;
}
return valid;
}
static bool is_image_loaded(int i)
{
return (images[i].image != NULL) ? true : false;
}
/*************************************************/
static void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected)
{
int devicetype;
switch (device->part_type)
{
case kPartitionTypeHFS:
{
char VolumeMacOSVersion[8];
{
#ifdef BOOT_HELPER_SUPPORT
// Use HFS or HFSRAID icon depending on bvr flags.
if (device->flags & kBVFlagBooter) {
getOSVersionForRaidVolume(VolumeMacOSVersion,device);
switch (VolumeMacOSVersion[3]) {
switch (device->OSVersion[3]) {
case '7':
devicetype = is_image_loaded(iDeviceHFSRAID_Lion) ? iDeviceHFSRAID_Lion : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
break;
} else
#endif
{
{
getOSVersionForVolume(VolumeMacOSVersion,device);
switch (VolumeMacOSVersion[3]) {
switch (device->OSVersion[3]) {
case '7':
devicetype = is_image_loaded(iDeviceHFS_Lion) ? iDeviceHFS_Lion : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
break;
}
#if 0
static void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected)
{
int devicetype;
if( diskIsCDROM(device) )
devicetype = iDeviceCDROM;// Use CDROM icon
else
{
switch (device->part_type)
{
case kPartitionTypeHFS:
{
bool hfs_img_replacement_found = false;
char VolumeMacOSVersion[8];
#ifdef BOOT_HELPER_SUPPORT
// Use HFS or HFSRAID icon depending on bvr flags.
if (device->flags & kBVFlagBooter) {
if (getOSVersionForRaidVolume(VolumeMacOSVersion,device))
{
int i ;
if (VolumeMacOSVersion[3] == '7') {
if ((i = getImageIndexByName("device_hfsplus_raid_lion")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '6') {
if ((i = getImageIndexByName("device_hfsplus_raid_sl")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '5') {
if ((i = getImageIndexByName("device_hfsplus_raid_leo")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '4') {
if ((i = getImageIndexByName("device_hfsplus_raid_tiger")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
}
}
switch (VolumeMacOSVersion[3]) {
case '7':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_Lion : iDeviceHFSRAID;
break;
case '6':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_SL : iDeviceHFSRAID;
break;
case '5':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_Leo : iDeviceHFSRAID;
break;
case '4':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_Tiger : iDeviceHFSRAID;
break;
default:
devicetype = iDeviceHFSRAID;
break;
}
} else
#endif
{
if (getOSVersionForVolume(VolumeMacOSVersion,device))
{
int i ;
if (VolumeMacOSVersion[3] == '7') {
if ((i = getImageIndexByName("device_hfsplus_lion")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '6') {
if ((i = getImageIndexByName("device_hfsplus_sl")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '5') {
if ((i = getImageIndexByName("device_hfsplus_leo")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '4') {
if ((i = getImageIndexByName("device_hfsplus_tiger")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
}
}
switch (VolumeMacOSVersion[3]) {
case '7':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_Lion : iDeviceHFS;
break;
case '6':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_SL : iDeviceHFS;
break;
case '5':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_Leo : iDeviceHFS;
break;
case '4':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_Tiger : iDeviceHFS;
break;
default:
devicetype = iDeviceHFS;
break;
}
}
break;
}
case kPartitionTypeHPFS:
devicetype = iDeviceNTFS;// Use HPFS / NTFS icon
break;
case kPartitionTypeFAT16:
devicetype = iDeviceFAT16;// Use FAT16 icon
break;
case kPartitionTypeFAT32:
devicetype = iDeviceFAT32;// Use FAT32 icon
break;
case kPartitionTypeEXT3:
devicetype = iDeviceEXT3;// Use EXT2/3 icon
break;
case kPartitionTypeFreeBSD:
devicetype = iDeviceFreeBSD;// Use FreeBSD icon
break;
case kPartitionTypeOpenBSD:
devicetype = iDeviceOpenBSD;// Use OpenBSD icon
break;
case kPartitionTypeBEFS: /* Haiku detection and Icon credits to scorpius */
devicetype = iDeviceBEFS;// Use BEFS / Haiku icon
break;
default:
devicetype = iDeviceGeneric;// Use Generic icon
break;
}
}
// Draw the selection image and use the next (device_*_o) image for the selected item.
if (isSelected)
{
blend(images[iSelection].image, buffer, centeredAt(images[iSelection].image, p));
devicetype++; // selec override image
}
// draw icon
blend( images[devicetype].image, buffer, centeredAt( images[devicetype].image, p ));
p.y += (images[iSelection].image->height / 2) + font_console.chars[0]->height;
// draw volume label
drawStrCenteredAt( device->label, &font_small, buffer, p);
}
#endif
void drawDeviceList (int start, int end, int selection)
{
int i;
drawStr(text, font, blendInto, p);
}
static int destroyFont(font_t *font)
{
int i;
for (i = 0; i < CHARACTERS_COUNT; i++)
{
if (font->chars[i])
{
if (font->chars[i]->pixels) free (font->chars[i]->pixels);
free (font->chars[i]);
font->chars[i] = 0;
}
}
return 0;
}
static int initFont(font_t *font, image_t *data)
{
unsigned int x = 0, y = 0, x2 = 0, x3 = 0;
branches/cparm/i386/modules/GUI/gui.h
7070
7171
7272
73
74
75
76
77
78
79
80
81
8273
8374
8475
} image_t;
/*
* Volume structure.
*/
typedef struct volume_t {
charversion[8];
BVRefbvr;
struct volume_t* next;
} volume_t;
/*
* Font structure.
*/
typedef struct {
branches/cparm/i386/modules/HibernateEnabler/resume.c
1717
1818
1919
20
21
2220
2321
2422
......
283281
284282
285283
286
284
287285
288286
289287
#include "resume.h"
#include "graphic_utils.h"
extern char gMacOSVersion[];
extern int previewTotalSectors;
extern int previewLoadedSectors;
extern uint8_t *previewSaveunder;
IOHibernateImageHeader * header = &_header;
long buffer;
if(gMacOSVersion[3] == '7')
if(gBootVolume->OSVersion[3] == '7')
{
HibernateBoot107(image_filename);
return;
branches/cparm/i386/util/Intel_Acpi/datatype.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
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.
*/
#ifndef DATATYPE_H
#define DATATYPE_H
#include <stdint.h>
#include <string.h>
#include <stdio.h>
typedef uint8_t U8;
typedef uint16_t U16;
typedef uint32_t U32;
typedef uint64_t U64;
/*
//typedef uint32_t bool;
#ifndef false
#define true 1
#endif
#ifndef false
#define false 0
#endif
*/
#ifndef NULL
#define NULL ((void *) 0)
#endif
#endif /* DATATYPE_H */
branches/cparm/i386/util/Intel_Acpi/ppm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
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.
*/
#ifndef ppm_h
#define ppm_h
#include "datatype.h"
#define PROFILE_ALL
//#define PROFILE_NEHALEM_EP_DP
//#define PROFILE_WESTMERE_EP_UP_DP
//#define PROFILE_NEHALEM_EX_MP
//#define PROFILE_WESTMERE_EX_MP
//#define PROFILE_SANDYBRIDGE_UP
#if defined(PROFILE_ALL) || defined(PROFILE_WESTMERE_EX_MP)
#define MAX_CPU_SOCKETS 8 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 256 // max count of cpu found in MADT
#define MAX_CORES 32 // Based on full range of Core APID ID values (max of 5 bits for core APIC ID mask)
#elif defined(PROFILE_NEHALEM_EX_MP)
#define MAX_CPU_SOCKETS 8 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 128 // max count of cpu found in MADT
#define MAX_CORES 16 // Based on full range of Core APID ID values (max of 4 bits for core APIC ID mask)
#elif defined(PROFILE_WESTMERE_EP_UP_DP)
#define MAX_CPU_SOCKETS 2 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 64 // max count of cpu found in MADT
#define MAX_CORES 16 // Based on full range of Core APID ID values (max of 4 bits for core APIC ID mask)
#elif defined(PROFILE_NEHALEM_EP_UP_DP)
#define MAX_CPU_SOCKETS 2 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 32 // max count of cpu found in MADT
#define MAX_CORES 8 // Based on full range of Core APID ID values (max of 3 bits for core APIC ID mask)
#elif defined(PROFILE_SANDY_BRIDGE_UP)
#define MAX_CPU_SOCKETS 1 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 8 // max count of cpu found in MADT
#define MAX_CORES 4
#endif
#define MAX_PSTATES 16
#define MAX_CSTATES 4
#define MAX_TSTATES 15
//Define ACPI_CSD to force building ACPI _CSD
//#define BUILD_ACPI_CSD
#ifndef DWORD_REGS_TYPEDEF
#define DWORD_REGS_TYPEDEF
typedef struct dword_regs {
U32 _eax;
U32 _ebx;
U32 _ecx;
U32 _edx;
} DWORD_REGS;
#endif
typedef struct acpi_tables {
// Define the Storage Locations for all the ACPI Table Pointers.
ACPI_TABLE_DSDT *DsdtPointer; // Differentiated System Description Table (RSDP->RSDT->FACP->DSDT)
ACPI_TABLE_DSDT *DsdtPointer64; // Differentiated System Description Table (RSDP->XSDT->FACP->XDSDT)
ACPI_TABLE_FADT *FacpPointer; // Fixed ACPI Description Table (RSDP->RSDT->FACP)
ACPI_TABLE_FACS *FacsPointer; // Firmware ACPI Control Structure (RSDP->RSDT->FACP->FACS)
ACPI_TABLE_FACS *FacsPointer64; // Firmware ACPI Control Structure (RSDP->XSDT->FACP->XFACS)
ACPI_TABLE_RSDP *RsdPointer; // Root System Description Pointer Structure (RSDP)
ACPI_TABLE_RSDT *RsdtPointer; // Root System Description Table (RSDP->RSDT)
ACPI_TABLE_MADT *MadtPointer; // Multiple APIC Description Table (RSDP->RSDT->APIC)
ACPI_TABLE_MADT *MadtPointer64; // Multiple APIC Description Table (RSDP->XSDT->APIC)
ACPI_TABLE_XSDT *XsdtPointer; // Extended Root System Description Table (RSDP->XSDT)
ACPI_TABLE_FADT *FacpPointer64; // Fixed ACPI Description Table (RSDP->XSDT->FACP)
} ACPI_TABLES;
typedef struct pstate {
U32 frequency;
U32 power;
U32 ratio;
U32 translatency;
U32 bmlatency;
U32 control;
U32 status;
} PSTATE;
typedef struct pkg_pstates {
U32 num_pstates;
PSTATE pstate[MAX_PSTATES];
} PKG_PSTATES;
typedef struct tstate {
U32 freqpercent;
U32 power;
U32 latency;
U32 control;
U32 status;
} TSTATE;
typedef struct pkg_tstates {
U32 num_tstates;
TSTATE tstate[MAX_TSTATES];
} PKG_TSTATES;
typedef enum cstate_encoding {
IO_REDIRECTION = 0,
NATIVE_MWAIT = 1,
} CSTATE_ENCODING;
typedef enum cpu_cstate {
CPU_C1 = 1,
//CPU_C2 = 2,
CPU_C3_ACPI_C2 = 3,
CPU_C3_ACPI_C3 = 4,
CPU_C4 = 5,
CPU_C6 = 6,
CPU_C7 = 7,
} CPU_CSTATE;
typedef struct cstate {
U8 type;
U16 latency;
U32 power;
} CSTATE;
typedef struct pkg_cstates {
U32 num_cstates;
CSTATE cstate[MAX_CSTATES];
ACPI_GENERIC_ADDRESS gas[MAX_CSTATES];
} PKG_CSTATES;
typedef struct cpu_details {
U32 present;
U32 x2apic_id;
U32 socket_id;
U32 intra_package_mask_width;
U32 intra_package_mask;
U32 smt_mask_width;
U32 smt_select_mask;
U32 core_select_mask;
DWORD_REGS cpuid1;
DWORD_REGS cpuid5;
DWORD_REGS cpuid6;
DWORD_REGS cpuidB_0;
DWORD_REGS cpuidB_1;
U32 eist_cpuid_feature_flag;
U32 turbo_cpuid_feature_flag;
U32 turbo_misc_enables_feature_flag;
U32 invariant_apic_timer_flag;
U32 tdc_limit;
U32 tdp_limit;
U32 turbo_available;
U32 max_ratio_as_mfg;
U32 max_ratio_as_cfg;
U32 min_ratio;
U32 tdc_tdp_limits_for_turbo_flag;
U32 ratio_limits_for_turbo_flag;
U32 xe_available;
U32 logical_processor_count_from_madt;
U32 core_logical_processor_count_from_madt[MAX_CORES];
PKG_PSTATES pkg_pstates;
PKG_CSTATES pkg_mwait_cstates;
PKG_CSTATES pkg_io_cstates;
PKG_TSTATES pkg_tstates;
U32 package_cstate_limit;
U32 core_c1_supported;
U32 core_c2_supported;
U32 core_c3_supported;
U32 core_c4_supported;
U32 core_c6_supported;
U32 core_c7_supported;
U32 mwait_supported;
U32 acpi_support_cpuid_feature_flag;
U32 energy_perf_bias_supported;
U64 package_power_limit;
U64 package_power_sku_unit;
} CPU_DETAILS;
typedef struct socket_info {
U32 signature;
U32 socket_count;
CPU_DETAILS cpu[MAX_CPU_SOCKETS];
} SOCKET_INFO;
typedef struct lapic_info {
U32 processorId;
U32 apicId;
U32 pkg_index;
U32 core_apic_id;
U32 core_index;
PROCESSOR_NUMBER_TO_NAMESEG *namepath;
U32 madt_type;
U32 uid;
} LAPIC_INFO;
typedef struct proc_info {
U32 processorId;
U32 apicId;
} PROC_INFO;
typedef struct madt_info {
U32 lapic_count;
LAPIC_INFO lapic[MAX_LOGICAL_CPU];
} MADT_INFO;
typedef struct rsdt_info {
U32 proc_count;
PROC_INFO processor[MAX_LOGICAL_CPU];
} RSDT_INFO;
typedef struct smp_exit_state {
U32 signature;
// Number of Failure or Informative codes included in the buffer
U32 error_code_count;
// Buffer of Failure or Informative codes
U32 error_codes[10];
} SMP_EXIT_STATE;
typedef enum smp_exit_code {
// Generic successful
SMP_EXIT_CODE_OK = 1,
// Generic failure
EXIT_CODE_FAILED = 2,
// First logical processor for this socket unable to find available structure
EXIT_CODE_FAILED_SOCKET_PROXY_SAVE = 3,
} SMP_EXIT_CODE;
typedef struct ppm_host {
U32 signature;
U32 pstates_enabled;
U32 pstate_coordination;
U32 turbo_enabled;
U32 cstates_enabled;
U32 tstates_enabled;
U32 performance_per_watt;
ACPI_TABLES acpi_tables;
RSDT_INFO rsdt_info;
MADT_INFO madt_info;
SOCKET_INFO skt_info;
PPM_SETUP_OPTIONS *options;
SMP_EXIT_STATE smp_exit_state;
U32 detected_cpu_family;
} PPM_HOST;
#endif // ppm_h
branches/cparm/i386/util/Intel_Acpi/ppmsetup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
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
312
313
314
315
316
317
318
319
320
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/*
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.
*/
#ifndef ppmsetup_h
#define ppmsetup_h
#include "datatype.h"
#define CURRENT_PPM_RCM_INTERFACE_SPECIFICATION 11
#ifndef nameseg_defined
#define nameseg_defined
#define NAMESEG(s) (((U32)(s[0]) << 0) \
|((U32)(s[1]) << 8) \
|((U32)(s[2]) << 16) \
|((U32)(s[3]) << 24))
#endif
typedef enum ssdt_loc_flag {
// Flag indicating the SSDT ACPI structure should be built in a stack-based
// buffer. If the SSDT is successfully created, then the following occurs:
// (1) the RSDT ACPI structure is moved lower in memory and updated to
// include a pointer to the new SSDT.
// (2) the SSDT APCI structure is copied into memory just above the moved
// RSDT structure
// (3) the RSD ACPI structure is updated to included the new location of
// the just moved RSDT ACPI structure
// Note: The XSDT is not updated!
//
// NOTE: THIS OPTION WILL DEPRECATED AND REMOVED
// IN A FUTURE VERSION OF THIS SPECIFICATION.
SSDT_LOC_FLAG_ACPI_RECLAIM = 0,
// Flag indicating the SSDT should be built directly in the memory region
// provided by the ssdt_mem_addr option parameter.
// If the SSDT is successfully created, then the following occurs:
// (1) the RSDT ACPI structure is moved lower in memory and updated to
// include a pointer to the new SSDT.
// (2) the RSD ACPI structure is updated to include the new location of the
// RSDT ACPI structure.
// Note: The XSDT is not updated!
//
// NOTE: THIS OPTION WILL DEPRECATED AND REMOVED
// IN A FUTURE VERSION OF THIS SPECIFICATION.
SSDT_LOC_FLAG_ADDR_PROVIDED = 1,
// Flag indicating the SSDT should be built directly in the memory region
// provided by the ssdt_mem_addr option parameter.
// After SSDT is successfully created, no further processing occurs.
SSDT_LOC_FLAG_ADDR_PROVIDED_NO_INSERT = 2,
// Flag indicating the SSDT should be built directly in the memory region
// provided by the ssdt_mem_addr option parameter.
// After SSDT is successfully created, then the following occurs:
// (1) the RSDT ACPI structure is not moved but is updated to
// include a 32-bit pointer to the new SSDT.
// (2) If the XSDT exists, it is not moved but is updated to
// include a 64-bit pointer to the new SSDT.
SSDT_LOC_FLAG_ADDR_PROVIDED_INSERT = 3,
} SSDT_LOC_FLAG;
typedef enum exit_code {
// PPM RCM completed all initialization successfully
EXIT_CODE_PPM_COMPLETED = 1,
// Failed building P-state table
EXIT_CODE_FAILED_BUILD_PSTATES = 2,
EXIT_CODE_PPM_EIST_DISABLED = 3,
// Failed to find ACPI tables
EXIT_CODE_FAILED_FIND_ACPI_TABLES = 4,
// Failed to process the ACPI MADT structure
EXIT_CODE_FAILED_PROCESS_MADT = 5,
// Failed to resolve ACPI MADT structure against available logical
// processors
EXIT_CODE_FAILED_PROCESS_MADT_INFO = 6,
// Failed to build ACPI SSDT structure
EXIT_CODE_FAILED_PROCESS_SSDT = 7,
// Failed to build and intialize HOST structure
EXIT_CODE_FAILED_HOST_INIT = 8,
// Failed during wake of all NBSP to gather processor information
EXIT_CODE_FAILED_COLLECT_SOCKET_INFO = 9,
// Failed to resolve target configuration between desired options and
// processor features
EXIT_CODE_FAILED_DETERMINE_CONFIGURATION = 0x0a,
// No SSDT ACPI struture was created
EXIT_CODE_NO_SSDT_CREATED = 0x0b,
// Failed to build Cstates correctly
EXIT_CODE_FAILED_BUILD_CSTATES = 0x0c,
// Failed to build Tstates correctly
EXIT_CODE_FAILED_BUILD_TSTATES = 0x0d,
// Failed to find package index of logical processor listed in MADT ACPI table
EXIT_CODE_FAILED_FIND_PKG_INDEX_FROM_LAPIC = 0x0e,
// Failed with invalid input provided for SSDT location flag
EXIT_CODE_FAILED_INVALID_SSDT_LOCATION_FLAG = 0x0f,
// Failed with no logical processors found in MADT
EXIT_CODE_FAILED_NO_LAPIC_FOUND_IN_MADT = 0x10,
// Failed with SSDT size exceeded during SSDT creation
EXIT_CODE_FAILED_SSDT_SIZE_EXCEEDED = 0x11,
// Failed to build ACPI SSDT structure
EXIT_CODE_FAILED_BUILD_SSDT = 0x12,
// Failed with core index of logical processor listed in MADT ACPI table exceeding max
EXIT_CODE_MAX_CORES_EXCEEDED = 0x13,
// Failed to find CPU Scope from array of ACPI processor number to ACPI CPU NameSeg structures
EXIT_CODE_FAILED_FIND_CPU_SCOPE_NAME_SEG = 0x14,
// Failed to update FADT
EXIT_CODE_FAILED_UPDATE_FADT = 0x15,
// GPF detected
EXIT_CODE_GPF_DETECTED = 0x16,
// Failed with invalid SSDT buffer address
EXIT_CODE_INVALID_SSDT_ADDR = 0x17,
// Failed with invalid SSDT buffer length
EXIT_CODE_INVALID_SSDT_LEN = 0x18,
} EXIT_CODE;
typedef struct exit_state {
// 1 = success, 0 = failure
U32 return_status;
// Number of Failure or Informative codes included in the buffer
U32 error_code_count;
// Buffer of Failure or Informative codes
U32 error_codes[10];
// This 32-bit physical memory address specifies the final location for the
// SSDT ACPI structure built by the PPM RC.
U32 ssdt_mem_addr;
// This value specifies the final size of the SSDT ACPI structure for the
// SSDT ACPI structure built by the PPM RC.
U32 ssdt_mem_size;
// The final state for the P-state initialization
// 1=enabled; 0=disabled
U32 pstates_enabled;
// The final state for the Turbo feature initialization
// 1=enabled; 0=disabled
U32 turbo_enabled;
// The final state for the C-state initialization
// 1=enabled; 0=disabled
U32 cstates_enabled;
// The final state for the T-state initialization
// 1=enabled; 0=disabled
U32 tstates_enabled;
} EXIT_STATE;
typedef enum cpu_namespace_flag {
// Flag indicating the SSDT ACPI structure should be built
// using ACPI 1.0 compliant processor namespace "_PR"
CPU_NAMESPACE_PR = 0,
// Flag indicating the SSDT ACPI structure should be built
// using ACPI 2.0+ compliant processor namespace "_SB"
CPU_NAMESPACE_SB = 1,
} CPU_NAMESPACE_FLAG;
// Define the total number of required NameSegs to reach the DSDT processor
// device or object declarations
#define MAX_SUPPORTED_CPU_NAMESEGS 3
typedef struct processor_number_to_nameseg {
// Contains one of the ACPI processor ID values used in a
// ACPI Declare Processor statement in the DSDT or XSDT
U32 acpi_processor_number;
// Number of NameSpace segments in NamePath to processor devices/objects
U32 seg_count;
// Contains the corresponding ACPI Name Scope in the form
// of a series of NameSegs constituting the NamePath to a
// processor device or object declaration
U32 nameseg[MAX_SUPPORTED_CPU_NAMESEGS];
} PROCESSOR_NUMBER_TO_NAMESEG;
typedef struct ppm_setup_options {
// This 32-bit physical memory address specifies a read-write memory region
// below 1MB. Minimum size is 8KB. This memory is used by the callback as
// the SIPI target and stack for each AP. This region is not required to be
// cacheable.
U32 mem_region_below_1M;
// Number of CPU sockets which exist on the platform
U32 num_sockets;
// Desired state for the P-state initialization
// 1=enabled; 0=disabled
U32 pstates_enabled;
// Desired state for the P-state hardware coordination
// ACPI_PSD_COORD_TYPE_SW_ALL = 0xFC
// ACPI_PSD_COORD_TYPE_SW_ANY = 0xFD
// ACPI_PSD_COORD_TYPE_HW_ALL = 0xFE
U32 pstate_coordination;
// Desired state for the Turbo state initialization
// 1=enabled; 0=disabled
U32 turbo_enabled;
// Desired state for the C-state initialization
// 1=enabled; 0=disabled
U32 cstates_enabled;
// Desired state for the C1E initialization
// 1=enabled; 0=disabled
U32 c1e_enabled;
// Desired state for the processor core C3 state included in the _CST
// 0= processor core C3 cannot be used as an ACPI C state
// 2= processor core C3 can be used as an ACPI C2 state
// 3= processor core C3 can be used as an ACPI C3 state
// 4= processor core C3 can be used as an ACPI C2 state
// if Invariant APIC Timer detected, else not used as ACPI C state
// 5= processor core C3 can be used as an ACPI C2 state
// if Invariant APIC Timer detected, else APIC C3 state
U32 c3_enabled;
// Desired state for the processor core C6 state included in the _CST as an
// ACPI C3 state.
// 1= processor core C6 can be used as an ACPI C3 state
// 0= processor core C6 cannot be used as an ACPI C3 state
U32 c6_enabled;
// Desired state for the processor core C7 state included in the _CST as an
// ACPI C3 state.
// 1= processor core C7 can be used as an ACPI C7 state
// 0= processor core C7 cannot be used as an ACPI C7 state
U32 c7_enabled;
// Desired state for providing alternate ACPI _CST structure using MWAIT
// extensions
// 1= Alternate _CST using MWAIT extension is enabled for OSPM use
// 0= Alternate _CST using MWAIT extension is disabled for OSPM use
U32 mwait_enabled;
// Power management base address used for processors
U32 pmbase;
// Desired state for the C-state package limit.
// Note: The C-state package limit may be further limited by the
// capabilities of the processor
// 000b = C0 (No package C-state support)
// 001b = C1 (Behavior is the same as 000b)
// 010b = C3
// 011b = C6
// 100b = C7
// 111b = No package C-state limit
U32 package_cstate_limit;
// Desired state for the T-state initialization
// 1=enabled; 0=disabled
U32 tstates_enabled;
// This 32-bit physical memory address specifies a read-write memory region
// for the SSDT ACPI structure built by the PPM RC. Minimum size is 16KB.
U32 ssdt_mem_addr;
// This value specifies the size of the SSDT memory region. Minimum size is
// 16KB.
U32 ssdt_mem_size;
// This value specifies the PPM RCM behavior related to creation and
// incorporation of the new SSDT ACPI structure. See definition of the
// SSDT_LOC_FLAG for acceptable values.
U32 ssdt_loc_flag;
// This value specifies the PPM RCM behavior related to creation and
// incorporation of the new SSDT ACPI structure. If all power management
// features are disabled by input options, the SSDT can still be created
// for debug review.
// 1 = Create SSDT even if all power management features are disabled
// 0 = Do not create SSDT if all power management features are disabled
U32 ssdt_force_creation;
// Exit structure intended to convey state to the caller and/or subsequent
// init code
EXIT_STATE exit_state;
// Flag indicating the processor namespace that should be used in the
// SSDT ACPI structure for each CPU.
// See definition of the CPU_NAMESPACE_FLAG for acceptable values.
U32 cpu_namespace_flag;
// This version number identifies the PPM RCM specification.
// Specifically denotes the version of this structure definition is compliant
// with with file nehalem-ppm-rcm-vX.txt where X is the version number.
// PPMSETUP.C should always use the version definition from the top of
// this file called CURRENT_PPM_RCM_INTERFACE_SPECIFICATION.
U32 ppm_rcm_interface_specification;
// This flag indicates whether or not after all AP Wakes are completed,
// that the AP should be forced to jump to the real mode address specified
// in the realmode_callback_address field below.
// realmode_callback = 0 means leave AP in INIT or Wait For SIPI (WFS) state
// realmode_callback = 1 means AP should jump to real mode address specified below
U32 realmode_callback_flag;
// This file contains the real mode callback address which AP must jump to after
// INIT_SIPI_SIPI sequences used to force AP initalization for PPM.
// Upper 16-bits specify target real mode segment for a far 16-bit jump instruction
// Lower 16-bits specify target real mode offset for a far 16-bit jump instruction
U32 realmode_callback_address;
// Number of ACPI processor number to ACPI CPU NameSeg structures
U32 cpu_map_count;
// Array of ACPI processor number to ACPI CPU NameSeg structures
PROCESSOR_NUMBER_TO_NAMESEG *cpu_map;
// This flag indicates whether or not PPM RC should update an existing ACPI FADT.
// modify_fadt_flag = 0 means do not modify existing ACPI FADT structure
// modify_fadt_flag = 1 means do check and if needed, modify existing ACPI FADT structure
U32 modify_fadt_flag;
// Desired state for the performance_per_watt optimizations
// performance_per_watt = 2 means "Low Power"
// performance_per_watt = 1 means "Power Optimized or Power Balanced"
// performance_per_watt = 0 means "Traditional or Max Performance"
U32 performance_per_watt;
} PPM_SETUP_OPTIONS;
#endif // ppmsetup_h
branches/cparm/i386/util/Intel_Acpi/acpidecode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
/*
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.
*/
#ifndef ACPI_DECODE_H
#define ACPI_DECODE_H
#include "datatype.h"
#include "intel_acpi.h"
#include "ppm.h"
/* acpidecode.h contains functions needed only for decoding ACPI to produce the
* inputs to the PPM code, but not needed for encoding ACPI as done inside the
* PPM code. */
#define ACPI_NAMESPACE_MAX_DEPTH 10
struct acpi_namespace {
U32 nameseg[ACPI_NAMESPACE_MAX_DEPTH];
U32 depth;
};
/* Globals used for retrieving ACPI processor structures from the DSDT */
#define CPU_MAP_LIMIT 256 /* Any bigger than 256 and we'd have to support the x2APIC structures, which we don't yet anyway. */
struct acpi_processor {
struct acpi_namespace ns;
U8 id;
U32 pmbase;
};
#define ACPI_NAMESPATH_STR_MAX_LEN 2 /* \_ */ + (4 * ACPI_NAMESPACE_MAX_DEPTH ) + (ACPI_NAMESPACE_MAX_DEPTH - 1 /*max number of . */ ) + 1 /* eof */
#endif /* ACPI_DECODE_H */
branches/cparm/i386/util/Intel_Acpi/intel_acpi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
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
312
313
314
315
316
317
318
319
320
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
/* Per ACPI 3.0a spec */
/*
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.
*/
#ifndef __LIBSAIO_INTEL_ACPI_H
#define __LIBSAIO_INTEL_ACPI_H
#include "datatype.h"
#include "ppmsetup.h"
//
// All tables and structures must be byte-packed to match the ACPI specification
#pragma pack(1)
#define ACPI_SIG_DSDT "DSDT" // Differentiated System Description Table
#define ACPI_SIG_FADT "FACP" // Fixed ACPI Description Table
#define ACPI_SIG_FACS "FACS" // Firmware ACPI Control Structure
#define ACPI_SIG_PSDT "PSDT" // Persistent System Description Table
#define ACPI_SIG_RSDP "RSD PTR " // Root System Description Pointer
#define ACPI_SIG_RSDT "RSDT" // Root System Description Table
#define ACPI_SIG_XSDT "XSDT" // Extended System Description Table
#define ACPI_SIG_SSDT "SSDT" // Secondary System Description Table
#define ACPI_RSDP_NAME "RSDP" // Short name for RSDP, not signature
#define ACPI_SIG_MADT "APIC" // Multiple APIC Description Table
#define ACPI_SIG_SBST "SBST" // Smart Battery Specification Table
#define ACPI_SIG_ECDT "ECDT" // Embedded Controller Boot Resources Table
#define ACPI_SIG_ASF "ASF!" // Alert Standard Format table
#define ACPI_SIG_DMAR "DMAR" // DMA Remapping table
#define ACPI_SIG_HPET "HPET" // High Precision Event Timer table
#define ACPI_SIG_MCFG "MCFG" // PCI Memory Mapped Configuration table
#define ACPI_SIG_UEFI "UEFI" // Uefi Boot Optimization Table
#ifndef nameseg_defined
#define nameseg_defined
#define NAMESEG(s) (((U32)(s[0]) << 0) \
|((U32)(s[1]) << 8) \
|((U32)(s[2]) << 16) \
|((U32)(s[3]) << 24))
#endif
#define NAMESEG64(s) (((U64)(s[0]) << 0) \
|((U64)(s[1]) << 8) \
|((U64)(s[2]) << 16) \
|((U64)(s[3]) << 24) \
|((U64)(s[4]) << 32) \
|((U64)(s[5]) << 40) \
|((U64)(s[6]) << 48) \
|((U64)(s[7]) << 56)) \
// Data Objects Encoding values.
#define AML_EXT_OP_PREFIX 0x5B
// Name Space Modifier Objects Encoding values.
#define AML_NAME_OP 0x08 // Name operator.
#define AML_SCOPE_OP 0x10 // Scope operator.
// Named Objects Encoding values.
#define AML_MUTEX_OP 0x01
#define AML_METHOD_OP 0x14 // Method operator.
#define AML_OPREGION_OP 0x80 // Operation Region operator.
#define AML_FIELD_OP 0x81
#define AML_DEVICE_OP 0x82
#define AML_PROCESSOR_OP 0x83 // Processor operator.
// Type2 Opcodes Encoding values.
#define AML_NULL_NAME 0x00
#define AML_ZERO_OP 0x00
#define AML_ALIAS_OP 0x06
#define AML_ONE_OP 0x01
#define AML_BYTE_OP 0x0a
#define AML_WORD_OP 0x0b
#define AML_DWORD_OP 0x0c
#define AML_STRING_OP 0x0d
#define AML_QWORD_OP 0x0e
#define AML_BUFFER_OP 0x11
#define AML_PACKAGE_OP 0x12
#define AML_COND_REF_OF_OP 0x12 // Requires AML_EXT_OP_PREFIX
#define AML_CREATE_FIELD_OP 0x13 // Requires AML_EXT_OP_PREFIX
#define AML_DUAL_NAME_PREFIX 0x2e
#define AML_MULTI_NAME_PREFIX 0x2f
#define AML_REVISION_OP 0x30 // Requires AML_EXT_OP_PREFIX
#define AML_DEBUG_OP 0x31
#define AML_ROOT_PREFIX 0x5c
#define AML_PARENT_PREFIX 0x5e
#define AML_LOCAL0_OP 0x60
#define AML_LOCAL1_OP 0x61
#define AML_LOCAL2_OP 0x62
#define AML_LOCAL3_OP 0x63
#define AML_LOCAL4_OP 0x64
#define AML_LOCAL5_OP 0x65
#define AML_LOCAL6_OP 0x66
#define AML_LOCAL7_OP 0x67
#define AML_ARG0_OP 0x68
#define AML_ARG1_OP 0x69
#define AML_ARG2_OP 0x6A
#define AML_ARG3_OP 0x6B
#define AML_ARG4_OP 0x6C
#define AML_ARG5_OP 0x6D
#define AML_ARG6_OP 0x6E
#define AML_STORE_OP 0x70
#define AML_CONCAT_OP 0x73
#define AML_SUBTRACT_OP 0x74
#define AML_MULTIPLY_OP 0x77
#define AML_AND_OP 0x7B
#define AML_END_TAG_OP 0x79
#define AML_GEN_REG_FIELD 0x82
#define AML_PROCESSOR_OP 0x83
#define AML_INDEXFIELD_OP 0x86 // Requires AML_EXT_OP_PREFIX
#define AML_SIZEOF_OP 0x87
#define AML_INDEX_OP 0x88
#define AML_CREATE_DWORD_FIELD_OP 0x8A
#define AML_LAND_OP 0x90
#define AML_LOR_OP 0x91
#define AML_LNOT_OP 0x92
#define AML_LEQUAL_OP 0x93
#define AML_LGREATER_OP 0x94
#define AML_LLESS_OP 0x95
#define AML_IF_OP 0xA0
#define AML_ELSE_OP 0xA1
#define AML_RETURN_OP 0xA4
#define AML_ONES_OP 0xFF
#define GAS_TYPE_FFH 0x7f
#define GAS_TYPE_SYSTEM_IO 0x01
#define GAS_VENDOR_INTEL 0x01
#define GAS_CLASS_CODE_NATIVE 0x02
// Define the Generic System Description Table Structure.
// This common header is used by all tables except the RSDP and FACS.
// The define is used for direct inclusion of header into other ACPI tables
typedef struct acpi_table_header {
U8 Signature[4]; // ASCII table signature
U32 Length; // Length of table in bytes, including this header
U8 Revision; // ACPI Specification minor version #
U8 Checksum; // To make checksum of entire table == 0
U8 OemId[6]; // ASCII OEM identification
U8 OemTableId[8]; // ASCII OEM table identification
U32 OemRevision; // OEM revision number
U8 AslCompilerId[4]; // ASCII ASL compiler vendor ID
U32 AslCompilerRevision; // ASL compiler version
} ACPI_TABLE_HEADER;
// GAS - Generic Address Structure (ACPI 2.0+)
typedef struct acpi_generic_address {
U8 SpaceId; // Address space where struct or register exists
U8 BitWidth; // Size in bits of given register
U8 BitOffset; // Bit offset within the register
U8 AccessWidth; // Minimum Access size (ACPI 3.0)
U64 Address; // 64-bit address of struct or register
} ACPI_GENERIC_ADDRESS;
// RSDP - Root System Description Pointer (Signature is "RSD PTR ")
typedef struct acpi_table_rsdp {
U8 Signature[8]; // ACPI signature, contains "RSD PTR "
U8 Checksum; // ACPI 1.0 checksum
U8 OemId[6]; // OEM identification
U8 Revision; // Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+
U32 RsdtPhysicalAddress; // 32-bit physical address of the RSDT
U32 Length; // Table length in bytes, including header (ACPI 2.0+)
U64 XsdtPhysicalAddress; // 64-bit physical address of the XSDT (ACPI 2.0+)
U8 ExtendedChecksum; // Checksum of entire table (ACPI 2.0+)
U8 Reserved[3]; // Reserved, must be zero
} ACPI_TABLE_RSDP;
#define ACPI_RSDP_REV0_SIZE 20 // Size of original ACPI 1.0 RSDP
// RSDT - Root System Description Table
typedef struct acpi_table_rsdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 TableOffsetEntry[1]; // Array of pointers to ACPI tables
} ACPI_TABLE_RSDT;
// XSDT - Root System Description Table
typedef struct acpi_table_xsdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U64 TableOffsetEntry[1]; // Array of pointers to ACPI tables
} ACPI_TABLE_XSDT;
// DSDT - Differentiated System Description Table
typedef struct acpi_table_dsdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 EntryStart;
} ACPI_TABLE_DSDT;
// FACS - Firmware ACPI Control Structure (FACS)
typedef struct acpi_table_facs {
U8 Signature[4]; // ASCII table signature
U32 Length; // Length of structure, in bytes
U32 HardwareSignature; // Hardware configuration signature
U32 FirmwareWakingVector; // 32-bit physical address of the Firmware Waking Vector
U32 GlobalLock; // Global Lock for shared hardware resources
U32 Flags;
U64 XFirmwareWakingVector; // 64-bit version of the Firmware Waking Vector (ACPI 2.0+)
U8 Version; // Version of this table (ACPI 2.0+)
U8 Reserved[31]; // Reserved, must be zero
} ACPI_TABLE_FACS;
// SBST - Smart Battery Specification Table - Version 1
typedef struct acpi_table_sbst
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U32 WarningLevel;
U32 LowLevel;
U32 CriticalLevel;
} ACPI_TABLE_SBST;
// ASF - Alert Standard Format table (Signature "ASF!")
typedef struct acpi_table_asf
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
} ACPI_TABLE_ASF;
// DMAR - DMA Remapping table - Version 1
typedef struct acpi_table_dmar
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U8Width; /* Host Address Width */
U8Flags;
U8Reserved[10];
} ACPI_TABLE_DMAR;
// HPET - High Precision Event Timer table - Version 1
typedef struct acpi_table_hpet
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U32Id; /* Hardware ID of event timer block */
ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */
U8Sequence; /* HPET sequence number */
U16MinimumTick; /* Main counter min tick, periodic mode */
U8Flags;
} ACPI_TABLE_HPET;
//MCFG - PCI Memory Mapped Configuration table and sub-table - Version 1
typedef struct acpi_table_mcfg
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U8Reserved[8];
} ACPI_TABLE_MCFG;
//UEFI - UEFI Boot optimization Table - Version 1
typedef struct acpi_table_uefi
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U8Identifier[16]; /* UUID identifier */
U16DataOffset; /* Offset of remaining data in table */
} ACPI_TABLE_UEFI;
// ECDT - Embedded Controller Boot Resources Table - Version 1
typedef struct acpi_table_ecdt
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
ACPI_GENERIC_ADDRESS Control; /* Address of EC command/status register */
ACPI_GENERIC_ADDRESS Data; /* Address of EC data register */
U32Uid; /* Unique ID - must be same as the EC _UID method */
U8Gpe; /* The GPE for the EC */
U8Id[1]; /* Full namepath of the EC in the ACPI namespace */
} ACPI_TABLE_ECDT;
// FADT - Fixed ACPI Description Table (Signature "FACP")
typedef struct acpi_table_fadt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 Facs; // 32-bit physical address of FACS
U32 Dsdt; // 32-bit physical address of DSDT
U8 Model; // System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+
U8 PreferredProfile; // Conveys preferred power management profile to OSPM.
U16 SciInterrupt; // System vector of SCI interrupt
U32 SmiCommand; // 32-bit Port address of SMI command port
U8 AcpiEnable; // Value to write to smi_cmd to enable ACPI
U8 AcpiDisable; // Value to write to smi_cmd to disable ACPI
U8 S4BiosRequest; // Value to write to SMI CMD to enter S4BIOS state
U8 PstateControl; // Processor performance state control
U32 Pm1aEventBlock; // 32-bit Port address of Power Mgt 1a Event Reg Blk
U32 Pm1bEventBlock; // 32-bit Port address of Power Mgt 1b Event Reg Blk
U32 Pm1aControlBlock; // 32-bit Port address of Power Mgt 1a Control Reg Blk
U32 Pm1bControlBlock; // 32-bit Port address of Power Mgt 1b Control Reg Blk
U32 Pm2ControlBlock; // 32-bit Port address of Power Mgt 2 Control Reg Blk
U32 PmTimerBlock; // 32-bit Port address of Power Mgt Timer Ctrl Reg Blk
U32 Gpe0Block; // 32-bit Port address of General Purpose Event 0 Reg Blk
U32 Gpe1Block; // 32-bit Port address of General Purpose Event 1 Reg Blk
U8 Pm1EventLength; // Byte Length of ports at Pm1xEventBlock
U8 Pm1ControlLength; // Byte Length of ports at Pm1xControlBlock
U8 Pm2ControlLength; // Byte Length of ports at Pm2ControlBlock
U8 PmTimerLength; // Byte Length of ports at PmTimerBlock
U8 Gpe0BlockLength; // Byte Length of ports at Gpe0Block
U8 Gpe1BlockLength; // Byte Length of ports at Gpe1Block
U8 Gpe1Base; // Offset in GPE number space where GPE1 events start
U8 CstControl; // Support for the _CST object and C States change notification
U16 C2Latency; // Worst case HW latency to enter/exit C2 state
U16 C3Latency; // Worst case HW latency to enter/exit C3 state
U16 FlushSize; // Processor's memory cache line width, in bytes
U16 FlushStride; // Number of flush strides that need to be read
U8 DutyOffset; // Processor duty cycle index in processor's P_CNT reg
U8 DutyWidth; // Processor duty cycle value bit width in P_CNT register.
U8 DayAlarm; // Index to day-of-month alarm in RTC CMOS RAM
U8 MonthAlarm; // Index to month-of-year alarm in RTC CMOS RAM
U8 Century; // Index to century in RTC CMOS RAM
U16 BootFlags; // IA-PC Boot Architecture Flags. See Table 5-10 for description
U8 Reserved; // Reserved, must be zero
U32 Flags; // Miscellaneous flag bits (see below for individual flags)
ACPI_GENERIC_ADDRESS ResetRegister; // 64-bit address of the Reset register
U8 ResetValue; // Value to write to the ResetRegister port to reset the system
U8 Reserved4[3]; // Reserved, must be zero
U64 XFacs; // 64-bit physical address of FACS
U64 XDsdt; // 64-bit physical address of DSDT
ACPI_GENERIC_ADDRESS XPm1aEventBlock; // 64-bit Extended Power Mgt 1a Event Reg Blk address
ACPI_GENERIC_ADDRESS XPm1bEventBlock; // 64-bit Extended Power Mgt 1b Event Reg Blk address
ACPI_GENERIC_ADDRESS XPm1aControlBlock; // 64-bit Extended Power Mgt 1a Control Reg Blk address
ACPI_GENERIC_ADDRESS XPm1bControlBlock; // 64-bit Extended Power Mgt 1b Control Reg Blk address
ACPI_GENERIC_ADDRESS XPm2ControlBlock; // 64-bit Extended Power Mgt 2 Control Reg Blk address
ACPI_GENERIC_ADDRESS XPmTimerBlock; // 64-bit Extended Power Mgt Timer Ctrl Reg Blk address
ACPI_GENERIC_ADDRESS XGpe0Block; // 64-bit Extended General Purpose Event 0 Reg Blk address
ACPI_GENERIC_ADDRESS XGpe1Block; // 64-bit Extended General Purpose Event 1 Reg Blk address
} ACPI_TABLE_FADT;
// SSDT - Secondary System Description Table
typedef struct acpi_table_ssdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
} ACPI_TABLE_SSDT;
//MADT - Multiple APIC Description Table
typedef struct acpi_table_madt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 Address; // Physical address of local APIC
U32 Flags;
} ACPI_TABLE_MADT;
// Values for subtable type in ACPI_SUBTABLE_HEADER
enum AcpiMadtType {
ACPI_MADT_TYPE_LOCAL_APIC = 0,
ACPI_MADT_TYPE_IO_APIC = 1,
ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2,
ACPI_MADT_TYPE_NMI_SOURCE = 3,
ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4,
ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5,
ACPI_MADT_TYPE_IO_SAPIC = 6,
ACPI_MADT_TYPE_LOCAL_SAPIC = 7,
ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8,
ACPI_MADT_TYPE_X2APIC = 9,
ACPI_MADT_TYPE_RESERVED = 10 // 10 and greater are reserved
};
// Common Sub-table header (used in MADT, SRAT, etc.)
typedef struct acpi_subtable_header {
U8 Type;
U8 Length;
} ACPI_SUBTABLE_HEADER;
// MADT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER
// 0: Processor Local APIC
typedef struct acpi_madt_local_apic {
ACPI_SUBTABLE_HEADER Header;
U8 ProcessorId; // ACPI processor id
U8 Id; // Processor's local APIC id
U32 LapicFlags;
} ACPI_MADT_LOCAL_APIC;
// 1: IO APIC
typedef struct acpi_madt_io_apic {
ACPI_SUBTABLE_HEADER Header;
U8 Id; // I/O APIC ID
U8 Reserved; // Reserved - must be zero
U32 Address; // APIC physical address
U32 GlobalIrqBase; // Global system interrupt where INTI lines start
} ACPI_MADT_IO_APIC;
// 2: Interrupt Override
typedef struct acpi_madt_interrupt_override {
ACPI_SUBTABLE_HEADER Header;
U8 Bus; // 0 - ISA
U8 SourceIrq; // Interrupt source (IRQ)
U32 GlobalIrq; // Global system interrupt
U16 IntiFlags;
} ACPI_MADT_INTERRUPT_OVERRIDE;
// 3: NMI Source
typedef struct acpi_madt_nmi_source {
ACPI_SUBTABLE_HEADER Header;
U16 IntiFlags;
U32 GlobalIrq; // Global system interrupt
} ACPI_MADT_NMI_SOURCE;
// 4: Local APIC NMI
typedef struct acpi_madt_local_apic_nmi {
ACPI_SUBTABLE_HEADER Header;
U8 ProcessorId; // ACPI processor id
U16 IntiFlags;
U8 Lint; // LINTn to which NMI is connected
} ACPI_MADT_LOCAL_APIC_NMI;
// 5: Address Override
typedef struct acpi_madt_local_apic_override {
ACPI_SUBTABLE_HEADER Header;
U16 Reserved; // Reserved, must be zero
U64 Address; // APIC physical address
} ACPI_MADT_LOCAL_APIC_OVERRIDE;
// 6: I/O Sapic
typedef struct acpi_madt_io_sapic {
ACPI_SUBTABLE_HEADER Header;
U8 Id; // I/O SAPIC ID
U8 Reserved; // Reserved, must be zero
U32 GlobalIrqBase; // Global interrupt for SAPIC start
U64 Address; // SAPIC physical address
} ACPI_MADT_IO_SAPIC;
// 7: Local Sapic
typedef struct acpi_madt_local_sapic {
ACPI_SUBTABLE_HEADER Header;
U8 ProcessorId; // ACPI processor id
U8 Id; // SAPIC ID
U8 Eid; // SAPIC EID
U8 Reserved[3]; // Reserved, must be zero
U32 LapicFlags;
U32 Uid; // Numeric UID - ACPI 3.0
char UidString[1]; // String UID - ACPI 3.0
} ACPI_MADT_LOCAL_SAPIC;
// 8: Platform Interrupt Source
typedef struct acpi_madt_interrupt_source {
ACPI_SUBTABLE_HEADER Header;
U16 IntiFlags;
U8 Type; // 1=PMI, 2=INIT, 3=corrected
U8 Id; // Processor ID
U8 Eid; // Processor EID
U8 IoSapicVector; // Vector value for PMI interrupts
U32 GlobalIrq; // Global system interrupt
U32 Flags; // Interrupt Source Flags
} ACPI_MADT_INTERRUPT_SOURCE;
// 9: Processor X2APIC
typedef struct acpi_madt_x2apic {
ACPI_SUBTABLE_HEADER Header;
U16 Reserved; // Must be zero
U32 x2apicId; // Processor's X2APIC ID
U32 x2apicFlags;
U32 UID;
} ACPI_MADT_X2APIC;
// Common flags fields for MADT subtables
// MADT Local APIC flags (LapicFlags)
#define ACPI_MADT_ENABLED (1) // 00: Processor is usable if set
// MADT MPS INTI flags (IntiFlags)
#define ACPI_MADT_POLARITY_MASK (3) // 00-01: Polarity of APIC I/O input signals
#define ACPI_MADT_TRIGGER_MASK (3<<2) // 02-03: Trigger mode of APIC input signals
// Values for MPS INTI flags
#define ACPI_MADT_POLARITY_CONFORMS 0
#define ACPI_MADT_POLARITY_ACTIVE_HIGH 1
#define ACPI_MADT_POLARITY_RESERVED 2
#define ACPI_MADT_POLARITY_ACTIVE_LOW 3
#define ACPI_MADT_TRIGGER_CONFORMS (0)
#define ACPI_MADT_TRIGGER_EDGE (1<<2)
#define ACPI_MADT_TRIGGER_RESERVED (2<<2)
#define ACPI_MADT_TRIGGER_LEVEL (3<<2)
#define ACPI_COORD_TYPE_SW_ALL 0xFC
#define ACPI_COORD_TYPE_SW_ANY 0xFD
#define ACPI_COORD_TYPE_HW_ALL 0xFE
typedef struct packageLength {
U8 packageLength0;
U8 packageLength1;
} ACPI_PACKAGE_LENGTH;
typedef struct acpi_scope {
U8 scopeOpcode;
ACPI_PACKAGE_LENGTH pkgLength;
U8 rootChar;
} ACPI_SCOPE;
typedef struct dual_name_path {
U8 prefix;
U32 nameseg[2];
} DUAL_NAME_PATH;
typedef struct multi_name_path {
U8 prefix;
U8 segCount;
U32 nameseg[MAX_SUPPORTED_CPU_NAMESEGS];
} MULTI_NAME_PATH;
typedef struct generic_register {
U8 genericRegisterField;
ACPI_PACKAGE_LENGTH pkgLength;
ACPI_GENERIC_ADDRESS gas;
} ACPI_GENERIC_REGISTER;
typedef struct package {
U8 packageOpcode;
ACPI_PACKAGE_LENGTH pkgLength;
U8 numElements;
} ACPI_PACKAGE;
typedef struct small_package {
U8 packageOpcode;
U8 packageLength;
U8 numElements;
} ACPI_SMALL_PACKAGE;
typedef struct small_buffer {
U8 bufferOpcode;
U8 packageLength;
} ACPI_SMALL_BUFFER;
typedef struct end_tag {
U8 endTagField;
U8 checksum;
} ACPI_END_TAG;
typedef struct return_name_seg {
U8 returnOpcode;
U32 name;
} ACPI_RETURN_NAME_SEG;
typedef struct return_package {
U8 returnOpcode;
ACPI_PACKAGE package;
} ACPI_RETURN_PACKAGE;
typedef struct return_zero {
U8 returnOpcode;
U8 zeroOpcode;
} ACPI_RETURN_ZERO;
typedef struct return_opcode {
U8 returnOpcode;
U8 opcodeToReturn;
} ACPI_RETURN_OPCODE;
typedef struct byteConst {
U8 byteOpcode;
U8 byteData;
} ACPI_BYTE_CONST;
typedef struct wordConst {
U8 wordOpcode;
U16 wordData;
} ACPI_WORD_CONST;
typedef struct dwordConst {
U8 dwordOpcode;
U32 dwordData;
} ACPI_DWORD_CONST;
typedef struct small_method {
U8 methodOpcode;
U8 packageLength;
U32 name;
U8 methodFlags;
} ACPI_SMALL_METHOD;
typedef struct method {
U8 methodOpcode;
ACPI_PACKAGE_LENGTH pkgLength;
U32 name;
U8 methodFlags;
} ACPI_METHOD;
typedef struct namePath {
U8 nameOpcode;
U32 name;
} ACPI_NAME_PATH;
typedef struct named_dword {
ACPI_NAME_PATH namePath;
ACPI_DWORD_CONST dword;
} ACPI_NAMED_DWORD;
typedef struct rootNamePath {
U8 nameOpcode;
U8 rootPrefix;
U32 name;
} ACPI_ROOT_NAME_PATH;
typedef struct root_named_dword {
ACPI_ROOT_NAME_PATH rootNamePath;
ACPI_DWORD_CONST dword;
} ACPI_ROOT_NAMED_DWORD;
typedef struct named_object {
ACPI_NAME_PATH namePath;
ACPI_PACKAGE package;
} ACPI_NAMED_OBJECT;
typedef struct small_named_object {
ACPI_NAME_PATH namePath;
ACPI_SMALL_PACKAGE package;
} ACPI_SMALL_NAMED_OBJECT;
typedef struct create_dword_field {
ACPI_NAME_PATH namePath;
ACPI_SMALL_PACKAGE package;
} ACPI_CREATE_DWORD_FIELD;
typedef struct tstate_package {
ACPI_SMALL_PACKAGE package;
ACPI_DWORD_CONST FreqPercent;
ACPI_DWORD_CONST Power;
ACPI_DWORD_CONST TransLatency;
ACPI_DWORD_CONST Control;
ACPI_DWORD_CONST Status;
} ACPI_TSTATE_PACKAGE;
typedef struct pstate_package {
ACPI_SMALL_PACKAGE package;
ACPI_DWORD_CONST CoreFreq;
ACPI_DWORD_CONST Power;
ACPI_DWORD_CONST TransLatency;
ACPI_DWORD_CONST BMLatency;
ACPI_DWORD_CONST Control;
ACPI_DWORD_CONST Status;
} ACPI_PSTATE_PACKAGE;
typedef struct psd_package {
ACPI_SMALL_PACKAGE package;
ACPI_BYTE_CONST NumberOfEntries;
ACPI_BYTE_CONST Revision;
ACPI_DWORD_CONST Domain;
ACPI_DWORD_CONST CoordType;
ACPI_DWORD_CONST NumProcessors;
} ACPI_PSD_PACKAGE;
typedef struct csd_package {
ACPI_SMALL_PACKAGE package;
ACPI_BYTE_CONST NumberOfEntries;
ACPI_BYTE_CONST Revision;
ACPI_DWORD_CONST Domain;
ACPI_DWORD_CONST CoordType;
ACPI_DWORD_CONST NumProcessors;
ACPI_DWORD_CONST Index;
} ACPI_CSD_PACKAGE;
typedef struct tsd_package {
ACPI_SMALL_PACKAGE package;
ACPI_BYTE_CONST NumberOfEntries;
ACPI_BYTE_CONST Revision;
ACPI_DWORD_CONST Domain;
ACPI_DWORD_CONST CoordType;
ACPI_DWORD_CONST NumProcessors;
} ACPI_TSD_PACKAGE;
typedef struct processor {
U8 processorOpCode;
U8 packageLength;
U8 numElements;
ACPI_BYTE_CONST ProcID;
ACPI_DWORD_CONST PblkAddr;
ACPI_BYTE_CONST PblkLen;
} ACPI_PROCESSOR;
#pragma pack()
#endif /* !__LIBSAIO_INTEL_ACPI_H */
branches/cparm/i386/util/amlsgn.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
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
312
313
314
315
316
317
318
319
320
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
355
356
357
358
359
360
361
362
363
/*
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.
*/
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 2.0 (the 'License'). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import <IOKit/IOReturn.h>
#include "Intel_Acpi/acpidecode.h"
#include "Intel_Acpi/ppmsetup.h"
unsigned long uuid32;
#define UUID_LEN16
#define UUID_STR_LEN UUID_LEN*2 + 8
typedef int8_t EFI_CHAR8;
unsigned long
adler32( unsigned char * buffer, long length );
U8 GetChecksum(void *mem_addr, U32 mem_size);
void SetChecksum(struct acpi_table_header *header);
const char * getStringFromUUID(const EFI_CHAR8* eUUID);
unsigned long
adler32( unsigned char * buffer, long length )
{
long cnt;
unsigned long result, lowHalf, highHalf;
lowHalf = 1;
highHalf = 0;
for ( cnt = 0; cnt < length; cnt++ )
{
if ((cnt % 5000) == 0)
{
lowHalf %= 65521L;
highHalf %= 65521L;
}
lowHalf += buffer[cnt];
highHalf += lowHalf;
}
lowHalf %= 65521L;
highHalf %= 65521L;
result = (highHalf << 16) | lowHalf;
return result;
}
//-------------------------------------------------------------------------------
//
// Procedure: GetChecksum - Performs byte checksum
//
//-------------------------------------------------------------------------------
U8 GetChecksum(void *mem_addr, U32 mem_size)
{
U8 *current = mem_addr;
U8 *end = current + mem_size;
U8 checksum = 0;
for (; current < end; current++)
checksum = checksum + *current;
return (checksum);
}
void SetChecksum(struct acpi_table_header *header)
{
header->Checksum = 0;
header->Checksum = 0 - GetChecksum(header, header->Length);
}
/** Transform a 16 bytes hexadecimal value UUID to a string */
/* getStringFromUUID : credit to Rekursor (see convert.c) */
const char * getStringFromUUID(const EFI_CHAR8* eUUID)
{
static char msg[UUID_STR_LEN] = "";
if (!eUUID) return "";
const unsigned char * uuid = (unsigned char*) eUUID;
sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5], uuid[6], uuid[7],
uuid[8], uuid[9], uuid[10],uuid[11],
uuid[12],uuid[13],uuid[14],uuid[15]);
return msg ;
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
mach_port_t masterPort;
io_registry_entry_t entry,entry2;
kern_return_t err;
CFDataRef data;
CFAllocatorRef allocator=kCFAllocatorDefault;
const UInt8* rawdata = NULL;
UInt32 uuid32 = 0;
UInt32 Model32 = 0;
const char *cfilename ;
NSString *filename, *fullfilename ;
NSArray *namechunks;
NSMutableArray *chunks;
char * input, *output, dirspec[512];
NSString *outStr, *inStr;
if (argc > 3 || argc < 2) {
printf("Usage: amlsgn input(as a file) output(as a directory)\n");
return 1;
} else if (argc == 2) {
/* Creating output string */
inStr = [NSString stringWithUTF8String:argv[1]];
chunks = [[NSMutableArray alloc] init];
[chunks addObjectsFromArray:[inStr componentsSeparatedByString: @"/"]];
fullfilename = [chunks lastObject];
namechunks = [fullfilename componentsSeparatedByString: @"."];
filename = [namechunks objectAtIndex:0];
cfilename = [filename UTF8String];
[chunks removeLastObject];
outStr = [chunks componentsJoinedByString: @"/"];
} else {
inStr = [NSString stringWithUTF8String:argv[1]];
BOOL isDirectory= FALSE;
if ([[NSFileManager defaultManager] fileExistsAtPath:outStr isDirectory:&isDirectory]) {
if (isDirectory == FALSE) {
chunks = [[NSMutableArray alloc] init];
[chunks addObjectsFromArray:[inStr componentsSeparatedByString: @"/"]];
[chunks removeLastObject];
outStr = [chunks componentsJoinedByString: @"/"];
} else {
outStr = [NSString stringWithUTF8String:argv[2]];
}
}
}
do {
BOOL isDirectory= FALSE;
if ([[NSFileManager defaultManager] fileExistsAtPath:outStr isDirectory:&isDirectory] && isDirectory) {
if ([[NSFileManager defaultManager] isWritableFileAtPath:outStr])
break;
}
outStr = [NSHomeDirectory() stringByAppendingPathComponent: @"Desktop"];
} while (0);
err = IOMasterPort(MACH_PORT_NULL, &masterPort);
if (err == KERN_SUCCESS){
entry2=IORegistryEntryFromPath(masterPort, [@"IODeviceTree:/efi" UTF8String]);
if (entry2!=MACH_PORT_NULL) {
data = IORegistryEntrySearchCFProperty( entry2, kIOServicePlane, CFSTR("motherboard-name"), allocator, kIORegistryIterateRecursively);
if (data != NULL) {
rawdata=CFDataGetBytePtr(data);
int len = 0;
char *ModelStr = ( char* )rawdata;
if (len = strlen(ModelStr))
{
Model32 = OSSwapHostToBigInt32(adler32( (unsigned char *) ModelStr, len ));
printf("uuid32 0x%lu uuidStr %s\n",(unsigned long)Model32,ModelStr);
UInt8 mem[1024*1024];
bzero(mem, sizeof(mem));
int fdIn = open([inStr UTF8String], O_RDONLY, 0666);
if (-1 == fdIn) {
printf("Error while opening the file \n");
return 1;
}
size_t nbRead = read(fdIn, (void*)mem, sizeof(mem));
if (nbRead <= 0) {
printf("Error: Unable to read the file\n");
close(fdIn);
return 1;
}
ACPI_TABLE_HEADER * head = (ACPI_TABLE_HEADER *)mem;
close(fdIn);
head->OemRevision = Model32;
SetChecksum(head);
{
char dir[1024];
sprintf(dir,"%s/%s.%s.aml",[outStr UTF8String],cfilename,ModelStr);
int fdOut = open(dir, O_WRONLY | O_CREAT, 0666);
if (-1 == fdOut) {
printf("Error: Can't save the file\n");
return 1;
}
write(fdOut, mem, head->Length);
close(fdOut);
}
}
IOObjectRelease(entry2);
goto out;
}
}
printf("No Model entry \n");
entry=IORegistryEntryFromPath(masterPort, [@"IODeviceTree:/efi/platform" UTF8String]);
if (entry!=MACH_PORT_NULL){
data = IORegistryEntrySearchCFProperty( entry, kIOServicePlane, CFSTR("system-id"), allocator, kIORegistryIterateRecursively);
if (data != NULL) {
rawdata=CFDataGetBytePtr(data);
const char *uuidStr = getStringFromUUID(( EFI_CHAR8* )rawdata);
if (strlen(uuidStr))
{
uuid32 = OSSwapHostToBigInt32(adler32( (unsigned char *) uuidStr, UUID_STR_LEN ));
printf("uuid32 : 0x%lu\n",(unsigned long)uuid32);
printf("uuidStr : %s\n",uuidStr);
UInt8 mem[1024*1024];
bzero(mem, sizeof(mem));
int fdIn = open([inStr UTF8String], O_RDONLY, 0666);
if (-1 == fdIn) {
printf("Error while opening the file \n");
return 1;
}
size_t nbRead = read(fdIn, (void*)mem, sizeof(mem));
if (nbRead <= 0) {
printf("Error: Unable to read the file\n");
close(fdIn);
return 1;
}
ACPI_TABLE_HEADER * head = (ACPI_TABLE_HEADER *)mem;
close(fdIn);
head->OemRevision = uuid32;
SetChecksum(head);
{
char dir[1024];
sprintf(dir,"%s/%s.%lu.aml",[outStr UTF8String],cfilename,(unsigned long)uuid32);
int fdOut = open(dir, O_WRONLY | O_CREAT, 0666);
if (-1 == fdOut) {
printf("Error: Can't save the file\n");
return 1;
}
write(fdOut, mem, head->Length);
close(fdOut);
}
}
IOObjectRelease(entry);
goto out;
}
}
printf("No UUID entry\n");
}
out:
[pool drain];
return 0;
}
branches/cparm/i386/util/Makefile
3232
3333
3434
35
36
37
38
39
3540
3641
3742
bdmesg: bdmesg.o
$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 -o $(SYMROOT)/$(@F) bdmesg.o
amlsgn:
$(CC) -arch i386 -framework IOKit -framework Foundation -mmacosx-version-min=10.5 amlsgn.m -o $(SYMROOT)/amlsgn
include ../MakeInc.dir
#dependencies

Archive Download the corresponding diff file

Revision: 1735