Chameleon

Chameleon Commit Details

Date:2010-02-04 00:11:10 (14 years 2 months ago)
Author:Rekursor
Commit:60
Parents: 59
Message:Rewrote badly duplicated dsdt code and made it work the same by factorizing the code to a new function in dsdt_patcher, fixed pciroot problem in pre7 see CHANGES for more info. Also did not integrate prasys options.c yet, I have a strange sid effect when using it (lspci dump though no keys have been pressed.
Changes:
M/trunk/i386/libsaio/dsdt_patcher.c
M/trunk/i386/libsaio/pci.c
M/trunk/i386/libsaio/pci_root.c
M/trunk/i386/libsaio/biosfn.c

File differences

trunk/i386/libsaio/pci_root.c
77
88
99
10
10
1111
1212
1313
......
4646
4747
4848
49
5049
51
52
5350
51
52
5453
55
56
57
54
5855
5956
6057
61
62
63
58
6459
6560
66
6761
68
69
70
71
62
63
7264
7365
74
7566
76
67
7768
7869
7970
80
71
8172
8273
8374
84
85
86
87
8875
89
90
91
76
77
78
79
80
81
82
83
9284
85
9386
9487
9588
......
10497
10598
10699
107
100
108101
109102
110
111
103
104
105
112106
113107
114
115
108
116109
117110
118111
#include "bootstruct.h"
#ifndef DEBUG_PCIROOT
#define DEBUG_PCIROOT 0
#define DEBUG_PCIROOT 1
#endif
#if DEBUG_PCIROOT
int getPciRootUID(void)
{
void *new_dsdt;
const char *dsdt_filename;
const char *val;
int fd;
int dsdt_uid;
int len,fsize;
const char * dsdt_filename=NULL;
extern int search_and_get_acpi_fd(const char *, const char **);
if (rootuid < 10) {
return rootuid;
}
if (rootuid < 10) return rootuid;
rootuid = 0;/* default uid = 0 */
if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->bootConfig)) {
if (isdigit(val[0])) {
rootuid = val[0] - '0';
}
if (isdigit(val[0])) rootuid = val[0] - '0';
goto out;
}
#if 1
/* Chameleon compatibility */
if (getValueForKey("PciRoot", &val, &len, &bootInfo->bootConfig)) {
if (isdigit(val[0])) {
rootuid = val[0] - '0';
}
else if (getValueForKey("PciRoot", &val, &len, &bootInfo->bootConfig)) {
if (isdigit(val[0])) rootuid = val[0] - '0';
goto out;
}
/* PCEFI compatibility */
if (getValueForKey("-pci0", &val, &len, &bootInfo->bootConfig)) {
else if (getValueForKey("-pci0", &val, &len, &bootInfo->bootConfig)) {
rootuid = 0;
goto out;
}
if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig)) {
else if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig)) {
rootuid = 1;
goto out;
}
#endif
if (!getValueForKey(kDSDT, &dsdt_filename, &len, &bootInfo->bootConfig)) {
dsdt_filename="/Extra/DSDT.aml";
}
if ((fd = open_bvdev("bt(0,0)", dsdt_filename, 0)) < 0) {
verbose("[WARNING] %s not found\n", dsdt_filename);
goto out;
int fd = search_and_get_acpi_fd("DSDT.aml", &dsdt_filename);
// Check booting partition
if (fd<0)
{
verbose("No DSDT found, using 0 as uid value.\n");
rootuid = 0;
return rootuid;
}
fsize = file_size(fd);
if ((new_dsdt = malloc(fsize)) == NULL) {
}
close (fd);
dsdt_uid = findpciroot(new_dsdt, fsize);
rootuid = findpciroot(new_dsdt, fsize);
free(new_dsdt);
if(dsdt_uid == 11) dsdt_uid=0; //usually when _UID isnt present, it means uid is zero
else if (dsdt_uid < 0 || dsdt_uid > 9)
// make sure it really works:
if (rootuid == 11) rootuid=0; //usually when _UID isnt present, it means uid is zero
else if (rootuid < 0 || rootuid > 9)
{
printf("PciRoot uid value wasnt found, using 0, if you want it to be 1, use -PciRootUID flag");
dsdt_uid = 0;
//if(dsdt_uid == 10) //algo failed, PCI0 wasnt found
rootuid = 0;
}
out:
verbose("Using PCI-Root-UID value: %d\n", rootuid);
trunk/i386/libsaio/dsdt_patcher.c
7272
7373
7474
75
76
75
76
7777
78
79
80
81
82
83
78
79
80
81
8482
85
86
87
88
83
84
85
8986
90
91
92
93
94
95
96
87
88
89
90
91
9792
98
93
94
95
96
9997
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
98
99
100
116101
117
118
119
120
121
122
123
124
125
126
102
103
104
127105
128
129
130
131
106
107
108
132109
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
133146
134
135147
136148
137149
......
253265
254266
255267
256
268
257269
258270
259271
}
return NULL;
}
void *loadACPITable ()
/** The folowing ACPI Table search algo. should be reused anywhere needed:*/
int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)
{
void *tableAddr;
int fd = -1;
char dirspec[512];
const char * const filename = "DSDT.aml";
const char * overriden_pathname=NULL;
int len=0;
int fd=0;
const char * overriden_pathname=NULL;
static char dirspec[512]="";
int len=0;
// Check booting partition
// Rek: if user specified a full path name then take it in consideration
if (getValueForKey(kDSDT, &overriden_pathname, &len,
/// Take in accound user overriding if it's DSDT only
if (strstr(filename, "DSDT") &&
getValueForKey(kDSDT, &overriden_pathname, &len,
&bootInfo->bootConfig))
{
sprintf(dirspec, "%s", overriden_pathname); // start searching root
//printf("Using custom DSDT path %s\n", dirspec);
//getc();
}
else
sprintf(dirspec, "/%s", filename); // start searching root
{
sprintf(dirspec, "%s", overriden_pathname); // start searching root
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
}
fd=open (dirspec,0);
// Start searching any potential location for ACPI Table
sprintf(dirspec, "/%s", filename); // start searching root
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
if (fd<0)
{// Check Extra on booting partition
//verbose("Searching for DSDT.aml file ...\n");
sprintf(dirspec,"/Extra/%s",filename);
fd=open (dirspec,0);
if (fd<0)
{// Fall back to booter partition
sprintf(dirspec,"bt(0,0)/Extra/%s",filename);
fd=open (dirspec,0);
if (fd<0)
{
verbose("ACPI Table not found: %s\n", filename);
return NULL;
}
}
}
sprintf(dirspec, "%s", filename); // start current dir
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
tableAddr=(void*)AllocateKernelMemory(file_size (fd));
if (tableAddr)
{
if (read (fd, tableAddr, file_size (fd))!=file_size (fd))
{
printf("Couldn't read table %s\n",dirspec);
free (tableAddr);
close (fd);
return NULL;
}
sprintf(dirspec,"/Extra/%s",filename);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
DBG("Table %s read and stored at: %x\n", dirspec, tableAddr);
close (fd);
return tableAddr;
}
sprintf(dirspec,"bt(0,0)/Extra/%s",filename);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
// NOT FOUND:
verbose("ACPI Table not found: %s\n", filename);
if (outDirspec) *outDirspec = "";
return -1;
// FOUND
success_fd:
if (outDirspec) *outDirspec = dirspec;
return fd;
}
void *loadACPITable (const char * filename)
{
void *tableAddr;
const char * dirspec=NULL;
int fd = search_and_get_acpi_fd(filename, &dirspec);
if (fd>=0)
{
tableAddr=(void*)AllocateKernelMemory(file_size (fd));
if (tableAddr)
{
if (read (fd, tableAddr, file_size (fd))!=file_size (fd))
{
printf("Couldn't read table %s\n",dirspec);
free (tableAddr);
close (fd);
return NULL;
}
DBG("Table %s read and stored at: %x\n", dirspec, tableAddr);
close (fd);
return tableAddr;
}
close (fd);
}
printf("Couldn't allocate memory for table %s\n", dirspec);
close (fd);
return NULL;
}
bool drop_ssdt;
// Load replacement DSDT
new_dsdt=loadACPITable();
new_dsdt=loadACPITable("DSDT.aml");
if (!new_dsdt)
{
return setupAcpiNoMod();
trunk/i386/libsaio/pci.c
1010
1111
1212
13
13
1414
1515
1616
......
150150
151151
152152
153
153
154
155
156
154157
155
158
159
156160
157
158
159
160
161
162
163
164
165
166
167
168
161169
162170
163171
#include "pci_root.h"
#ifndef DEBUG_PCI
#define DEBUG_PCI 0
#define DEBUG_PCI 1
#endif
#if DEBUG_PCI
dev_path[0] = 0;
end = root_pci_dev;
while (end != pci_dt) {
int uid = getPciRootUID();
while (end != pci_dt)
{
current = pci_dt;
while (current->parent != end) current = current->parent;
while (current->parent != end)
current = current->parent;
end = current;
if (current->parent == root_pci_dev)
sprintf(tmp, "PciRoot(0x%x)/Pci(0x%x,0x%x)", getPciRootUID(), current->dev.bits.dev, current->dev.bits.func);
else
sprintf(tmp, "/Pci(0x%x,0x%x)", current->dev.bits.dev, current->dev.bits.func);
if (current->parent == root_pci_dev)
{
sprintf(tmp, "PciRoot(0x%x)/Pci(0x%x,0x%x)", uid,
current->dev.bits.dev, current->dev.bits.func);
} else {
sprintf(tmp, "/Pci(0x%x,0x%x)",
current->dev.bits.dev, current->dev.bits.func);
}
strcat(dev_path, tmp);
}
return dev_path;
trunk/i386/libsaio/biosfn.c
168168
169169
170170
171
171
172172
173173
174174
MemoryRange *range = (MemoryRange *)BIOS_ADDR;
unsigned longcount = 0;
unsigned longrerangedCount;
// unsigned longrerangedCount;
unsigned long longconMemSize = 0;
unsigned long longextMemSize = 0;

Archive Download the corresponding diff file

Revision: 60