Chameleon

Chameleon Commit Details

Date:2010-01-17 14:27:34 (14 years 2 months ago)
Author:JrCs
Commit:16
Parents: 15
Message:New function loadACPITable to load any ACPI table like dsdt, facp, etc.
Changes:
M/branches/JrCs/i386/libsaio/dsdt_patcher.c

File differences

branches/JrCs/i386/libsaio/dsdt_patcher.c
7272
7373
7474
75
76
77
78
79
7580
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
76121
77122
78123
......
88133
89134
90135
91
136
92137
93138
94
139
95140
96141
97142
......
100145
101146
102147
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122148
123
149
124150
125151
126
127152
128153
129
130
131
132
133
134
135
136154
137155
138156
return NULL;
}
void *loadACPITable (const char *filename)
{
void *tableAddr;
int fd;
char dirspec[512];
// Check booting partition
sprintf(dirspec,"%s",filename);
fd=open (dirspec,0);
if (fd<0)
{// Check Extra on booting partition
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;
}
}
}
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;
}
printf("Couldn't allocate memory for table %s\n", dirspec);
close (fd);
return NULL;
}
/* Setup ACPI without replacing DSDT. */
int setupAcpiNoMod()
{
/* Setup ACPI. Replace DSDT if DSDT.aml is found */
int setupAcpi()
{
int fd, version;
int version;
void *new_dsdt;
const char *dsdt_filename;
char dirspec[512];
/* const char *facp_filename; */
int len;
boolean_t drop_ssdt=NO;
if (!getValueForKey("DSDT", &dsdt_filename, &len, &bootInfo->bootConfig))
dsdt_filename="DSDT.aml";
// Check booting partition
sprintf(dirspec,"%s",dsdt_filename);
fd=open (dirspec,0);
if (fd<0)
{// Check Extra on booting partition
sprintf(dirspec,"/Extra/%s",dsdt_filename);
fd=open (dirspec,0);
if (fd<0)
{// Fall back to booter partition
sprintf(dirspec,"bt(0,0)/Extra/%s",dsdt_filename);
fd=open (dirspec,0);
if (fd<0)
{
verbose("No DSDT replacement found. Leaving ACPI data as is\n");
return setupAcpiNoMod();
}
}
}
// Load replacement DSDT
new_dsdt=(void*)AllocateKernelMemory(file_size (fd));
new_dsdt=loadACPITable(dsdt_filename);
if (!new_dsdt)
{
printf("Couldn't allocate memory for DSDT\n");
return setupAcpiNoMod();
}
if (read (fd, new_dsdt, file_size (fd))!=file_size (fd))
{
printf("Couldn't read file\n");
return setupAcpiNoMod();
}
close (fd);
DBG("New DSDT Loaded in memory\n");
{

Archive Download the corresponding diff file

Revision: 16