Commit 431f94fb authored by Russell King's avatar Russell King

[ARM] Clean up lookup of processor and machine types.

Rather than having an assembly and C version performing the same
lookup, re-use the assembly version with a C wrapper around it.
This removes the duplication.
Signed-off-by: default avatarRussell King <rmk@arm.linux.org.uk>
parent f5049cdf
......@@ -406,7 +406,7 @@ err_str:
* calculate the offset.
*
* Returns:
* r3, r6 corrupted
* r3, r4, r6 corrupted
* r5 = proc_info pointer in physical address space
* r9 = cpuid
*/
......@@ -418,9 +418,9 @@ __lookup_processor_type:
add r5, r5, r3 @ convert virt addresses to
add r6, r6, r3 @ physical address space
mrc p15, 0, r9, c0, c0 @ get processor id
1: ldmia r5, {r3, r10} @ value, mask
and r10, r10, r9 @ mask wanted bits
teq r3, r10
1: ldmia r5, {r3, r4} @ value, mask
and r4, r4, r9 @ mask wanted bits
teq r3, r4
beq 2f
add r5, r5, #PROC_INFO_SZ @ sizeof(proc_info_list)
cmp r5, r6
......@@ -428,6 +428,15 @@ __lookup_processor_type:
mov r5, #0 @ unknown processor
2: mov pc, lr
/*
* This provides a C-API version of the above function.
*/
ENTRY(lookup_processor_type)
stmfd sp!, {r4 - r6, r9, lr}
bl __lookup_processor_type
mov r0, r5
ldmfd sp!, {r4 - r6, r9, pc}
/*
* Look in include/asm-arm/procinfo.h and arch/arm/kernel/arch.[ch] for
* more information about the __proc_info and __arch_info structures.
......@@ -464,3 +473,13 @@ __lookup_machine_type:
blt 1b
mov r5, #0 @ unknown machine
2: mov pc, lr
/*
* This provides a C-API version of the above function.
*/
ENTRY(lookup_machine_type)
stmfd sp!, {r4 - r6, lr}
mov r1, r0
bl __lookup_machine_type
mov r0, r5
ldmfd sp!, {r4 - r6, pc}
......@@ -267,9 +267,15 @@ int cpu_architecture(void)
return cpu_arch;
}
/*
* These functions re-use the assembly code in head.S, which
* already provide the required functionality.
*/
extern struct proc_info_list *lookup_processor_type(void);
extern struct machine_desc *lookup_machine_type(unsigned int);
static void __init setup_processor(void)
{
extern struct proc_info_list __proc_info_begin, __proc_info_end;
struct proc_info_list *list;
/*
......@@ -277,15 +283,8 @@ static void __init setup_processor(void)
* types. The linker builds this table for us from the
* entries in arch/arm/mm/proc-*.S
*/
for (list = &__proc_info_begin; list < &__proc_info_end ; list++)
if ((processor_id & list->cpu_mask) == list->cpu_val)
break;
/*
* If processor type is unrecognised, then we
* can do nothing...
*/
if (list >= &__proc_info_end) {
list = lookup_processor_type();
if (!list) {
printk("CPU configuration botched (ID %08x), unable "
"to continue.\n", processor_id);
while (1);
......@@ -321,22 +320,14 @@ static void __init setup_processor(void)
static struct machine_desc * __init setup_machine(unsigned int nr)
{
extern struct machine_desc __arch_info_begin, __arch_info_end;
struct machine_desc *list;
/*
* locate architecture in the list of supported architectures.
*/
for (list = &__arch_info_begin; list < &__arch_info_end; list++)
if (list->nr == nr)
break;
/*
* If the architecture type is not recognised, then we
* can co nothing...
* locate machine in the list of supported machines.
*/
if (list >= &__arch_info_end) {
printk("Architecture configuration botched (nr %d), unable "
list = lookup_machine_type(nr);
if (!list) {
printk("Machine configuration botched (nr %d), unable "
"to continue.\n", nr);
while (1);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment