Chameleon

Chameleon Commit Details

Date:2010-08-10 09:57:44 (8 years 11 months ago)
Author:Azimutz
Commit:344
Parents: 343
Message:Porting the inspiration back to search_and_get_acpi_fd, to match behaviour. About the removed code, check rev 157.
Changes:
M/branches/azimutz/CleanCut/i386/boot2/drivers.c
M/branches/azimutz/CleanCut/i386/libsaio/acpi_patcher.c
M/branches/azimutz/CleanCut/i386/boot2/boot.h

File differences

branches/azimutz/CleanCut/i386/libsaio/acpi_patcher.c
8686
8787
8888
89
89
90
9091
9192
92
93
94
95
96
93
94
95
96
9797
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
98
99
100
101
102
103
104
127105
128
129
130
131
132
133106
134
135
136
107
108
109
110
137111
138
139
140
112
113
114
115
141116
142
143
144
117
118
119
120
145121
122
123
124
125
126
146127
128
129
147130
131
148132
149
150133
151134
152135
153
154
136
155137
156138
157139
}
return NULL;
}
/** The folowing ACPI Table search algo. should be reused anywhere needed:*/
/** The following ACPI Table search algo, should be reused anywhere needed: */
int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)
{
int fd=0;
const char * overriden_pathname=NULL;
static char dirspec[512]="";
static bool first_time =true;
int len=0;
chardirSpecDSDT[512] = "";
const char *override_pathname = NULL; // full path to a file.
intlen = 0, fd = 0;
extern char gMacOSVersion;
/// 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);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
}
// Check that dirspec is not already assigned with a path
if (!first_time && *dirspec)
{ // it is so start searching this cached patch first
//extract path
for (len=strlen(dirspec)-1; len; len--)
if (dirspec[len]=='/' || len==0)
{
dirspec[len]='\0';
break;
}
// now concat with the filename
strncat(dirspec, "/", sizeof(dirspec));
strncat(dirspec, filename, sizeof(dirspec));
// and test to see if we don't have our big boy here:
fd=open (dirspec,0);
if (fd>=0)
{
// printf("ACPI file search cache hit: file found at %s\n", dirspec);
goto success_fd;
}
// Take in account user overriding
if (getValueForKey(kDSDTKey, &override_pathname, &len, &bootInfo->bootConfig))
{
// Specify a path to a file, e.g. /Extra/test.aml
sprintf(dirSpecDSDT, override_pathname);
fd = open(dirSpecDSDT, 0);
if (fd >= 0) goto success_fd;
}
// Start searching any potential location for ACPI Table
// search the Extra folders first
sprintf(dirspec,"/Extra/%s",filename);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
sprintf(dirspec,"bt(0,0)/Extra/%s",filename);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
// Check rd's root.
sprintf(dirSpecDSDT, "rd(0,0)/%s", filename);
fd = open(dirSpecDSDT, 0);
if (fd >= 0) goto success_fd;
sprintf(dirspec, "%s", filename); // search current dir
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
// Check booter volume/rdbt for OS specific folders.
sprintf(dirSpecDSDT, "bt(0,0)/Extra/%s/%s", &gMacOSVersion, filename);
fd = open(dirSpecDSDT, 0);
if (fd >= 0) goto success_fd;
sprintf(dirspec, "/%s", filename); // search root
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
// Check booter volume/rdbt Extra.
sprintf(dirSpecDSDT, "bt(0,0)/Extra/%s", filename);
fd = open(dirSpecDSDT, 0);
if (fd >= 0) goto success_fd;
//Azi: All loaded files stay in Extra.. please!? :)
//sprintf(dirspec, "/%s", filename); // search root
//fd=open (dirspec,0);
//if (fd>=0) goto success_fd;
// NOT FOUND:
//Azi: a reminder - handling this only on pci_root.c, getPciRootUID() (it's enough to check if .aml file exists),
// to reduce number of printed messages and the confusion caused by them on users.
//verbose("ACPI Table not found: %s\n", filename);
if (outDirspec) *outDirspec = "";
first_time = false;
return -1;
// FOUND
success_fd:
first_time = false;
if (outDirspec) *outDirspec = dirspec;
if (outDirspec) *outDirspec = dirSpecDSDT;
return fd;
}
branches/azimutz/CleanCut/i386/boot2/boot.h
6969
7070
7171
72
72
7373
7474
7575
#define kWakeImage"WakeImage"// boot.c
#define kProductVersion"ProductVersion"// boot.c
#define karch"arch"// boot.c
#define kDSDT"DSDT"// acpi_patcher.c
#define kDSDTKey"DSDT"// acpi_patcher.c
#define kDropSSDT"DropSSDT"// acpi_patcher.c
#define kRestartFix"RestartFix" // acpi_patcher.c
#define kGeneratePStates"GeneratePStates"// acpi_patcher.c
branches/azimutz/CleanCut/i386/boot2/drivers.c
163163
164164
165165
166
166
167167
168168
169169
long LoadDrivers( char * dirSpec )
{
char dirSpecExtra[1024];
const char *override_pathfolder = NULL; // path to folder
const char *override_pathfolder = NULL; // full path to a folder.
intfd = 0, len = 0;
if ( InitDriverSupport() != 0 )

Archive Download the corresponding diff file

Revision: 344