Factor out function to find driver for a CPU

This function can be used outside of the normal CPU setup

Change-Id: I810c63b8aff868a6f69d5b992bea1cfae5a5996b
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/868
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
Stefan Reinauer 2012-04-03 16:07:56 -07:00 committed by Stefan Reinauer
parent 61f4a744c0
commit 6293d30768
2 changed files with 14 additions and 7 deletions

View File

@ -154,6 +154,9 @@ struct cpu_driver {
struct cpu_device_id *id_table;
};
struct device;
struct cpu_driver *find_cpu_driver(struct device *cpu);
struct cpu_info {
device_t cpu;
unsigned long index;

View File

@ -211,23 +211,27 @@ static void identify_cpu(struct device *cpu)
}
}
static void set_cpu_ops(struct device *cpu)
struct cpu_driver *find_cpu_driver(struct device *cpu)
{
struct cpu_driver *driver;
cpu->ops = 0;
for (driver = cpu_drivers; driver < ecpu_drivers; driver++) {
struct cpu_device_id *id;
for(id = driver->id_table; id->vendor != X86_VENDOR_INVALID; id++) {
for (id = driver->id_table;
id->vendor != X86_VENDOR_INVALID; id++) {
if ((cpu->vendor == id->vendor) &&
(cpu->device == id->device))
{
goto found;
return driver;
}
}
}
return;
found:
cpu->ops = driver->ops;
return NULL;
}
static void set_cpu_ops(struct device *cpu)
{
struct cpu_driver *driver = find_cpu_driver(cpu);
cpu->ops = driver ? driver->ops : NULL;
}
void cpu_initialize(void)