Chameleon

Chameleon Commit Details

Date:2012-07-12 15:05:17 (11 years 9 months ago)
Author:armel cadet-petit
Commit:2010
Parents: 2009
Message:implemented nvidia cards injection from a plist, updated smbios code
Changes:
M/branches/cparm/i386/libsa/string.c
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
M/branches/cparm/Chameleon.xcodeproj/project.pbxproj
M/branches/cparm/doc/ModuleHelp.txt
M/branches/cparm/i386/libsa/libsa.h
M/branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
M/branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c
M/branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
M/branches/cparm/CHANGES
M/branches/cparm/i386/libsaio/smbios.c

File differences

branches/cparm/doc/ModuleHelp.txt
1717
1818
1919
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2036
2137
2238
VBIOS=Yes|No Inject VBIOS to device-properties.
NVIDIA card injection usage e.g: // TODO : add memory info for each card to this structure
<key>NVIDIA</key>
<array>
<dict>
<key>Chipset Name</key>
<string>Quadro FX 380</string>
<key>IOPCIPrimaryMatch</key>
<string>0x10DE0658</string>
</dict>
.
.
.
.
</array>
Networking module:
-----------------
EnableNetworkModule=Yes|NoFully enable/disable the Networking module (Enabled by default, if the module is installed)
branches/cparm/Chameleon.xcodeproj/project.pbxproj
99
1010
1111
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1229
1330
1431
......
625642
626643
627644
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
628677
629678
630679
......
10741123
10751124
10761125
1126
10771127
10781128
10791129
/* Begin PBXFileReference section */
AB0E930C14C6223500F798D7 /* cpu_intel_amd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpu_intel_amd.c; sourceTree = "<group>"; };
AB22095D15334C9E00AA9851 /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = "<group>"; };
AB30EB4615AD7D3E000ACA09 /* acpi_codec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpi_codec.c; sourceTree = "<group>"; };
AB30EB4715AD7D3E000ACA09 /* acpi_codec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpi_codec.h; sourceTree = "<group>"; };
AB30EB4815AD7D3E000ACA09 /* acpicode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpicode.c; sourceTree = "<group>"; };
AB30EB4915AD7D3E000ACA09 /* acpicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpicode.h; sourceTree = "<group>"; };
AB30EB4A15AD7D3E000ACA09 /* ACPICodec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ACPICodec.c; sourceTree = "<group>"; };
AB30EB4B15AD7D3E000ACA09 /* acpidecode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acpidecode.c; sourceTree = "<group>"; };
AB30EB4C15AD7D3E000ACA09 /* acpidecode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acpidecode.h; sourceTree = "<group>"; };
AB30EB4D15AD7D3E000ACA09 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
AB30EB4E15AD7DC6000ACA09 /* AcpiAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AcpiAdditions.h; sourceTree = "<group>"; };
AB30EB4F15AD7E77000ACA09 /* portable_efi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = portable_efi.h; sourceTree = "<group>"; };
AB30EB5815AD8399000ACA09 /* Acpi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi.h; sourceTree = "<group>"; };
AB30EB5915AD8399000ACA09 /* Acpi10.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi10.h; sourceTree = "<group>"; };
AB30EB5A15AD8399000ACA09 /* Acpi20.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi20.h; sourceTree = "<group>"; };
AB30EB5B15AD8399000ACA09 /* Acpi30.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi30.h; sourceTree = "<group>"; };
AB30EB5C15AD8399000ACA09 /* Acpi40.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi40.h; sourceTree = "<group>"; };
AB30EB5D15AD8399000ACA09 /* Acpi50.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acpi50.h; sourceTree = "<group>"; };
AB30EB5E15AD8399000ACA09 /* AcpiAml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AcpiAml.h; sourceTree = "<group>"; };
AB42D02115187F2C0078E84A /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; };
AB42D02215187F2C0078E84A /* boot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = boot.png; sourceTree = "<group>"; };
AB42D02315187F2C0078E84A /* device_cdrom.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = device_cdrom.png; sourceTree = "<group>"; };
name = Chameleon;
sourceTree = "<group>";
};
AB30EB4515AD7D3E000ACA09 /* ACPICodecV2 */ = {
isa = PBXGroup;
children = (
AB30EB5715AD8398000ACA09 /* IndustryStandard */,
AB30EB4E15AD7DC6000ACA09 /* AcpiAdditions.h */,
AB30EB4615AD7D3E000ACA09 /* acpi_codec.c */,
AB30EB4715AD7D3E000ACA09 /* acpi_codec.h */,
AB30EB4815AD7D3E000ACA09 /* acpicode.c */,
AB30EB4915AD7D3E000ACA09 /* acpicode.h */,
AB30EB4A15AD7D3E000ACA09 /* ACPICodec.c */,
AB30EB4B15AD7D3E000ACA09 /* acpidecode.c */,
AB30EB4C15AD7D3E000ACA09 /* acpidecode.h */,
AB30EB4D15AD7D3E000ACA09 /* Makefile */,
AB30EB4F15AD7E77000ACA09 /* portable_efi.h */,
);
path = ACPICodecV2;
sourceTree = "<group>";
};
AB30EB5715AD8398000ACA09 /* IndustryStandard */ = {
isa = PBXGroup;
children = (
AB30EB5815AD8399000ACA09 /* Acpi.h */,
AB30EB5915AD8399000ACA09 /* Acpi10.h */,
AB30EB5A15AD8399000ACA09 /* Acpi20.h */,
AB30EB5B15AD8399000ACA09 /* Acpi30.h */,
AB30EB5C15AD8399000ACA09 /* Acpi40.h */,
AB30EB5D15AD8399000ACA09 /* Acpi50.h */,
AB30EB5E15AD8399000ACA09 /* AcpiAml.h */,
);
path = IndustryStandard;
sourceTree = "<group>";
};
AB42D02015187F2C0078E84A /* embed */ = {
isa = PBXGroup;
children = (
isa = PBXGroup;
children = (
AB43B34914C37E520018D529 /* ACPICodec */,
AB30EB4515AD7D3E000ACA09 /* ACPICodecV2 */,
AB43B35214C37E520018D529 /* ACPIPatcher */,
AB43B35914C37E520018D529 /* CPUfreq */,
ABA02704156CE81A00F8E5F3 /* Ext2fs */,
branches/cparm/CHANGES
1
2
3
14
25
36
- Implemented a method to inject new graphics cards from a plist, no need to hardcode device ids anymore !! (for now, only nvidia cards are supported, see doc/ModuleHelp.txt for usage)
- Moved the smbios detection code to the freebsd one
- Fixed a bug in the bundle dependency dispatcher
- security fixes in printf.c
branches/cparm/i386/libsaio/smbios.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
126
27
28
29
30
31
32
33
234
35
36
37
38
39
40
41
42
43
44
345
446
547
648
7
8
9
49
50
51
52
53
1054
11
55
56
57
58
59
60
61
62
63
64
65
1266
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
67
68
69
70
71
72
3373
3474
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
3590
3691
37
92
3893
39
94
4095
41
96
97
4298
43
99
44100
45101
46102
47103
48104
49
105
50106
51107
52108
/*-
* Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
/*
* Detect SMBIOS and export information about the SMBIOS into the
* environment.
*
* System Management BIOS Reference Specification, v2.6 Final
* http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf
*/
/*
* 2.1.1 SMBIOS Structure Table Entry Point
*
* "On non-EFI systems, the SMBIOS Entry Point structure, described below, can
* be located by application software by searching for the anchor-string on
* paragraph (16-byte) boundaries within the physical memory address range
* 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate anchor
* string that is used by some existing DMI browsers."
*/
#include "libsaio.h"
#include "SMBIOS.h"
#include "Platform.h"
static const char * const SMTAG = "_SM_";
static const char* const DMITAG= "_DMI_";
static struct SMBEntryPoint *getAddressOfSmbiosTable(void);
#define SMBIOS_START 0xf0000
#define SMBIOS_LENGTH 0x10000
#define SMBIOS_STEP 0x10
#define SMBIOS_SIG "_SM_"
#define SMBIOS_DMI_SIG "_DMI_"
static struct SMBEntryPoint *getAddressOfSmbiosTable(void)
#define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off)))
#define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off)))
#define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off)))
#define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01)
#define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base))
typedef char* caddr_t;
static uint8_t
smbios_checksum(const caddr_t addr, const uint8_t len)
{
struct SMBEntryPoint*smbios;
/*
* The logic is to start at 0xf0000 and end at 0xfffff iterating 16 bytes at a time looking
* for the SMBIOS entry-point structure anchor (literal ASCII "_SM_").
*/
smbios = (struct SMBEntryPoint*) SMBIOS_RANGE_START;
while (smbios <= (struct SMBEntryPoint *)SMBIOS_RANGE_END)
{
if (COMPARE_DWORD(smbios->anchor, SMTAG) &&
COMPARE_DWORD(smbios->dmi.anchor, DMITAG) &&
smbios->dmi.anchor[4]==DMITAG[4] &&
checksum8(smbios, sizeof(struct SMBEntryPoint)) == 0)
{
return ((void*)smbios);
}
smbios = (struct SMBEntryPoint*) ( ((char*) smbios) + 16 );
}
printf("Error: Could not find original SMBIOS !!\n");
pause();
return NULL;
uint8_t sum;
int i;
for (sum = 0, i = 0; i < len; i++)
sum += SMBIOS_GET8(addr, i);
return (sum);
}
static caddr_t
smbios_sigsearch(const caddr_t addr, const uint32_t len)
{
caddr_t cp;
/* Search on 16-byte boundaries. */
for (cp = addr; cp < addr + len; cp += SMBIOS_STEP)
if (strncmp(cp, SMBIOS_SIG, 4) == 0 &&
smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 &&
strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 &&
smbios_checksum(cp + 0x10, 0x0f) == 0)
return (cp);
return (NULL);
}
struct SMBEntryPoint *getSmbiosOriginal()
{
static struct SMBEntryPoint *orig = NULL; // cached
static caddr_t smbios = NULL; // cached
if (orig == NULL)
if (smbios == NULL)
{
orig = getAddressOfSmbiosTable();
/* Search signatures and validate checksums. */
smbios = smbios_sigsearch((caddr_t)ptov(SMBIOS_START), SMBIOS_LENGTH);
if (orig)
if (smbios)
{
verbose("Found System Management BIOS (SMBIOS) table\n");
}
}
return orig;
return (struct SMBEntryPoint *)smbios;
}
/* get product Name from original SMBIOS */
branches/cparm/i386/modules/ACPIPatcher/acpi_patcher.c
5757
5858
5959
60
61
62
63
64
65
66
67
68
69
70
71
72
6073
6174
6275
#define RSDP_CHECKSUM_LENGTH 20
/* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */
static uint8_t checksum8( void * start, unsigned int length )
{
uint8_t csum = 0;
uint8_t * cp = (uint8_t *) start;
unsigned int i;
for ( i = 0; i < length; i++)
csum += *cp++;
return csum;
}
/*-
*FOR biosacpi_search_rsdp AND biosacpi_find_rsdp
*
branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
5454
5555
5656
57
5758
5859
5960
......
9091
9192
9293
93
9494
9595
9696
......
11411141
11421142
11431143
1144
1145
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
11461172
11471173
11481174
11491175
11501176
1177
11511178
11521179
11531180
#include "platform.h"
#include "device_inject.h"
#include "nvidia.h"
#include "xml.h"
#ifndef DEBUG_NVIDIA
#define DEBUG_NVIDIA 0
#define NVCAP_LEN ( sizeof(default_NVCAP) / sizeof(uint8_t) )
//TODO: once the bundles will be implemented, add a plist reader so there will be no need anymore to hardcode the device ids of each cards, each one will be able to add his own device ids in the plist, it willl work great if the card is supported by the apple's drivers
struct nv_chipsets_t NVKnownChipsets[] = {
{ 0x00000000, "Unknown" },
//========================================
}
static char *get_nvidia_model(uint32_t id) {
unsigned inti;
unsigned inti, count;
TagPtr NVDIATag;
char *model_name = NULL, *match_id = NULL;
// First check in the plist, (for e.g this can override any hardcoded devices)
if ((NVDIATag = XMLCastArray(XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"NVIDIA"))))
{
count = XMLTagCount(NVDIATag);
for (i=0; i<count; i++)
{
TagPtr element = XMLGetElement( NVDIATag, i );
if (element)
{
match_id = XMLCastString(XMLGetProperty(element, (const char*)"IOPCIPrimaryMatch"));
if (strtoul(match_id, NULL, 16) == id)
{
model_name = XMLCastString(XMLGetProperty(element, (const char*)"Chipset Name"));
if (model_name)
{
return model_name;
}
}
}
}
}
for (i=1; i< (sizeof(NVKnownChipsets) / sizeof(NVKnownChipsets[0])); i++) {
if (NVKnownChipsets[i].device == id) {
return NVKnownChipsets[i].name;
}
}
return NVKnownChipsets[0].name;
}
branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
498498
499499
500500
501
502
503
504
505
506
507
508
509
510
511
512
513
501514
502515
503516
const char* sm_get_random_year(void);
const char* sm_get_random_country(void);
/* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */
static uint8_t checksum8( void * start, unsigned int length )
{
uint8_t csum = 0;
uint8_t * cp = (uint8_t *) start;
unsigned int i;
for ( i = 0; i < length; i++)
csum += *cp++;
return csum;
}
const char *getDefaultSMBproductName(void)
{
setDefaultSMBData();
branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
280280
281281
282282
283
284
285
286
287
288
289
290
291
292
293
294
295
283296
284297
285298
const char* sm_get_random_year(void);
const char* sm_get_random_country(void);
/* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */
static uint8_t checksum8( void * start, unsigned int length )
{
uint8_t csum = 0;
uint8_t * cp = (uint8_t *) start;
unsigned int i;
for ( i = 0; i < length; i++)
csum += *cp++;
return csum;
}
const char* sm_search_str(const SMStrEntryPair*sm_defaults, const char * key)
{
int i;
branches/cparm/i386/libsa/libsa.h
9898
9999
100100
101
102101
103102
104103
extern char *itoa(int,char*);
extern const char *strstr(const char *, const char *);
extern uint8_t checksum8( void * start, unsigned int length );
extern unsigned long
adler32( unsigned char * buffer, long length );
extern void * bsearch(register const void *key,const void *base0,size_t nmemb,register size_t size,register int (*compar)(const void *, const void *));
branches/cparm/i386/libsa/string.c
523523
524524
525525
526
527
528
529
530
531
532
533
534
535
536
537
538
539526
540527
541528
return start;
}
/* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */
uint8_t checksum8( void * start, unsigned int length )
{
uint8_t csum = 0;
uint8_t * cp = (uint8_t *) start;
unsigned int i;
for ( i = 0; i < length; i++)
csum += *cp++;
return csum;
}
unsigned long
adler32( unsigned char * buffer, long length )
{

Archive Download the corresponding diff file

Revision: 2010