Chameleon

Chameleon Commit Details

Date:2012-07-20 03:48:09 (7 years 1 month ago)
Author:ErmaC
Commit:2022
Parents: 2021
Message:Merge from main trunk: nvidia plist helper (credits to cparm).
Changes:
A/branches/ErmaC/Trunk/i386/libsaio/nvidia_helper.c
A/branches/ErmaC/Trunk/i386/libsaio/nvidia_helper.h
A/branches/ErmaC/Trunk/doc/org.chameleon.Boot.nvidia.plist
M/branches/ErmaC/Trunk/i386/boot2/boot.c
M/branches/ErmaC/Trunk/CHANGES
M/branches/ErmaC/Trunk/i386/util/bdmesg.c

File differences

branches/ErmaC/Trunk/i386/libsaio/nvidia_helper.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
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
/*
* Copyright (c) 2012 cparm <armelcadetpetit@gmail.com>. All rights reserved.
*
*/
#include "libsaio.h"
#include "bootstruct.h"
#include "xml.h"
#include "nvidia_helper.h"
#include "pci.h"
#include "nvidia.h"
/*
NVIDIA card injection usage e.g (to be placed in the boot.plist):
<key>NVIDIA</key>
<array>
<dict>
<key>Chipset Name</key>
<string>Quadro FX 380</string>
<key>IOPCIPrimaryMatch</key>
<string>0x10DE0658</string>
<key>VRam Size</key>
<string>256</string>
</dict>
<dict>
<key>Chipset Name</key>
<string>YOUR_CARD_NAME</string>
<key>IOPCIPrimaryMatch</key>
<string>YOUR_CARD_ID</string>
<key>IOPCISubDevId</key>
<string>YOUR_CARD_SUB_ID(if necessary)</string>
<key>VRam Size</key>
<string>YOUR_CARD_VRAM_SIZE</string>
</dict>
<dict>
<key>Chipset Name</key>
<string>YOUR_SECOND_CARD_NAME</string>
<key>IOPCIPrimaryMatch</key>
<string>YOUR_SECOND_CARD_ID</string>
<key>IOPCISubDevId</key>
<string>YOUR_SECOND_CARD_SUB_ID(if necessary)</string>
<key>VRam Size</key>
<string>YOUR_SECOND_CARD_VRAM_SIZE</string>
</dict>
.
.
.
.
</array>
*/
cardList_t* cardList = NULL;
void add_card(char* model, uint32_t id, uint32_t subid, uint64_t videoRam)
{
cardList_t* new_card = malloc(sizeof(cardList_t));
if (new_card)
{
new_card->next = cardList;
cardList = new_card;
new_card->id = id;
new_card->subid = subid;
new_card->videoRam = videoRam;
new_card->model = model;
}
}
cardList_t* FindCardWithIds(uint32_t id, uint32_t subid)
{
cardList_t* entry = cardList;
while(entry)
{
if((entry->id == id) && (entry->subid == subid))
{
return entry;
}
else
{
entry = entry->next;
}
}
// LET A SECOND CHANCE by seaching only for the device-id
entry = cardList;
while(entry)
{
if((entry->id == id))
{
return entry;
}
else
{
entry = entry->next;
}
}
return NULL;
}
void fill_card_list(void)
{
unsigned inti, count;
TagPtr NVDIATag;
char *model_name = NULL, *match_id = NULL, *sub_id = NULL, *vram_size = NULL;
uint32_t dev_id = 0, subdev_id = NV_SUB_IDS;
uint64_t VramSize = 0;
if ((NVDIATag = XMLCastArray(XMLGetProperty(bootInfo->chameleonConfig.dictionary, (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")); //device-id
sub_id = XMLCastString(XMLGetProperty(element, (const char*)"IOPCISubDevId")); //sub device-id
model_name = XMLCastString(XMLGetProperty(element, (const char*)"Chipset Name"));
vram_size = XMLCastString(XMLGetProperty(element, (const char*)"VRam Size"));
if (match_id) {
dev_id = strtoul(match_id, NULL, 16);
}
if (sub_id) {
subdev_id = strtoul(sub_id, NULL, 16);
}
if (vram_size) {
VramSize = strtoul(vram_size, NULL, 10);
}
add_card(model_name, dev_id, subdev_id, VramSize);
}
}
}
}
branches/ErmaC/Trunk/i386/libsaio/nvidia_helper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
* Copyright (c) 2012 cparm <armelcadetpetit@gmail.com>. All rights reserved.
*
*/
#ifndef __LIBSAIO_NVIDIA_HELPER_H
#define __LIBSAIO_NVIDIA_HELPER_H
typedef struct cardList_t
{
char* model;
uint32_t id;
uint32_t subid;
uint64_t videoRam;
struct cardList_t* next;
} cardList_t;
void add_card(char* model, uint32_t id, uint32_t subid, uint64_t videoRam);
void fill_card_list(void);
cardList_t* FindCardWithIds(uint32_t id, uint32_t subid);
#endif //__LIBSAIO_NVIDIA_HELPER_H
branches/ErmaC/Trunk/i386/boot2/boot.c
239239
240240
241241
242
242
243243
244244
245
245
246246
247247
248248
if (cacheFile[0] != 0)
strlcpy(kernelCacheFile, cacheFile, sizeof(kernelCacheFile));
else {
// Mountain Lion and Lion prelink kernel cache file
// Lion and Mountain Lion prelink kernel cache file
if ((checkOSVersion("10.7")) || (checkOSVersion("10.8"))) {
sprintf(kernelCacheFile, "%skernelcache", kDefaultCachePathSnow);
}
}
// Snow Leopard prelink kernel cache file
else if (checkOSVersion("10.6")) {
sprintf(kernelCacheFile, "kernelcache_%s", (archCpuType == CPU_TYPE_I386)
branches/ErmaC/Trunk/i386/util/bdmesg.c
3232
3333
3434
35
35
3636
3737
3838
const UInt8 *msglog = CFDataGetBytePtr((CFDataRef)bootLog);
if (msglog)
printf("%s\n", msglog);
CFRelease(bootLog);
return 0;
}
branches/ErmaC/Trunk/doc/org.chameleon.Boot.nvidia.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
<?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>Default Partition</key>
<string></string>
<key>GraphicsEnabler</key>
<string>Yes</string>
<key>Kernel</key>
<string>mach_kernel</string>
<key>Kernel Flags</key>
<string></string>
<key>NVIDIA</key>
<array>
<dict>
<key>Chipset Name</key>
<string>Quadro FX 380</string>
<key>IOPCIPrimaryMatch</key>
<string>0x10DE0658</string>
<key>IOPCISubDevId</key>
<string>0x00000000</string>
<key>VRam Size</key>
<string>256</string>
</dict>
</array>
<key>Quiet Boot</key>
<string>No</string>
<key>Timeout</key>
<string>5</string>
</dict>
</plist>
branches/ErmaC/Trunk/CHANGES
1
12
23
34
- cparm : Ported the nvidia plist helper (less time to spend on the device id more time to code :-) )
- Added Recovery Icon for Default Theme (TODO) (credits to blackosx).
- Merge Intel Graphics 4000 device IDs from Chimera (Commit 1999).
- Merge more cparm's (security, stability, bugs fixes) improvements from his branch.

Archive Download the corresponding diff file

Revision: 2022