Chameleon

Chameleon Commit Details

Date:2010-02-04 01:23:30 (14 years 2 months ago)
Author:Rekursor
Commit:61
Parents: 60
Message:Merged latest pre8 in my branch for any's work integration
Changes:
M/branches/rekursor
M/branches/rekursor/i386/libsaio/dsdt_patcher.c
M/branches/rekursor/version
M/branches/rekursor/i386/libsaio/nvidia.c
M/branches/rekursor/i386/libsaio/pci.c
M/branches/rekursor/CHANGES
M/branches/rekursor/i386/libsaio/pci_root.c
M/branches/rekursor/i386/libsaio/biosfn.c

File differences

branches/rekursor/version
1
1
2.0-RC5pre6
2.0-RC5pre7
branches/rekursor/CHANGES
1
2
13
24
35
- Nvidia injection fix
- pciroot would not always return correct uuid in autodection mode
- Fixed the hibernation problem in boot2/resume.c
- Fixed all new booter versions with SystemType would override the facp value even if correct,
now keeps the facp value if correct and no override has been done, implemented a best effort algo.
branches/rekursor/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);
branches/rekursor/i386/libsaio/dsdt_patcher.c
1212
1313
1414
15
15
1616
1717
1818
......
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
#include "platform.h"
#ifndef DEBUG_DSDT
#define DEBUG_DSDT 1
#define DEBUG_DSDT 0
#endif
#if DEBUG_DSDT==2
}
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();
branches/rekursor/i386/libsaio/nvidia.c
594594
595595
596596
597
598597
599598
600599
......
616615
617616
618617
619
618
620619
621620
622621
......
662661
663662
664663
665
664
666665
667666
668667
static int devprop_add_nvidia_template(struct DevPropDevice *device)
{
chartmp[16];
intlen;
if(!device)
return 0;
// Rek : Dont use sprintf return, it does not WORK !! our custom sprintf() always return 0!
// len = sprintf(tmp, "Slot-%x", devices_number);
sprintf(tmp, "Slot-%x",devices_number);
devprop_add_value(device, "AAPL,slot-name", tmp, strlen(tmp));
devprop_add_value(device, "AAPL,slot-name", (uint8_t *) tmp, strlen(tmp));
devices_number++;
return 1;
verbose("Using nVidia Video BIOS File %s (%d Bytes)\n", nvFilename, nvBiosOveride);
DBG("%s Signature 0x%02x%02x %d bytes\n", nvFilename, rom[0], rom[1], nvBiosOveride);
} else {
printf("ERROR: unable to open Vidia Video BIOS File %s\n", nvFilename);
printf("ERROR: unable to open nVidia Video BIOS File %s\n", nvFilename);
return false;
}
} else {
branches/rekursor/i386/libsaio/pci.c
77
88
99
10
1011
1112
12
13
1314
1415
1516
......
149150
150151
151152
152
153
154
155
156
153157
154
158
159
155160
156
157
158
159
161
162
163
164
165
166
167
168
160169
161170
162171
#include "libsaio.h"
#include "bootstruct.h"
#include "pci.h"
#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;
branches/rekursor/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: 61