ChangeSet 1.2181.28.2, 2005/03/27 18:17:05+01:00, [EMAIL PROTECTED](none)

        [ARM PATCH] 2579/1: make early boot failure more verbose
        
        Patch from Nicolas Pitre
        
        It is pointless for cases where one tries to boot a kernel
        on the wrong ARM subarchitecture, but for those cases where the
        architecture is similar enough so the low level routines do work
        then something a bit more informative than "Error: a" might be
        handy, especially when the bootloader is the culprit.
        All extra strings are compiled in only if CONFIG_DEBUG_LL
        is selected of course.
        
        Signed-off-by: Nicolas Pitre
        Signed-off-by: Russell King



 arch/arm/kernel/head.S      |   75 +++++++++++++++++++++++++++++++-------------
 include/asm-arm/mach/arch.h |    2 -
 2 files changed, 54 insertions(+), 23 deletions(-)


diff -Nru a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
--- a/arch/arm/kernel/head.S    2005-03-28 23:12:15 -08:00
+++ b/arch/arm/kernel/head.S    2005-03-28 23:12:15 -08:00
@@ -24,9 +24,11 @@
 #define PROCINFO_MMUFLAGS      8
 #define PROCINFO_INITFUNC      12
 
+#define MACHINFO_TYPE          0
 #define MACHINFO_PHYSRAM       4
 #define MACHINFO_PHYSIO                8
 #define MACHINFO_PGOFFIO       12
+#define MACHINFO_NAME          16
 
 #ifndef CONFIG_XIP_KERNEL
 /*
@@ -101,12 +103,10 @@
                                                @ and irqs disabled
        bl      __lookup_processor_type         @ r5=procinfo r9=cpuid
        movs    r10, r5                         @ invalid processor (r5=0)?
-       moveq   r0, #'p'                        @ yes, error 'p'
-       beq     __error
+       beq     __error_p                               @ yes, error 'p'
        bl      __lookup_machine_type           @ r5=machinfo
        movs    r8, r5                          @ invalid machine (r5=0)?
-       moveq   r0, #'a'                        @ yes, error 'a'
-       beq     __error
+       beq     __error_a                       @ yes, error 'a'
        bl      __create_page_tables
 
        /*
@@ -359,22 +359,59 @@
  * ought to tell the user, but since we don't have any guarantee that
  * we're even running on the right architecture, we do virtually nothing.
  *
- * r0 = ascii error character:
- *     a = invalid architecture
- *     p = invalid processor
- *     i = invalid calling convention
- *
- * Generally, only serious errors cause this.
+ * If CONFIG_DEBUG_LL is set we try to print out something about the error
+ * and hope for the best (useful if bootloader fails to pass a proper
+ * machine ID for example).
  */
-       .type   __error, %function
-__error:
+
+       .type   __error_p, %function
+__error_p:
+#ifdef CONFIG_DEBUG_LL
+       adr     r0, str_p1
+       bl      printascii
+       b       __error
+str_p1:        .asciz  "\nError: unrecognized/unsupported processor variant.\n"
+       .align
+#endif
+
+       .type   __error_a, %function
+__error_a:
 #ifdef CONFIG_DEBUG_LL
-       mov     r8, r0                          @ preserve r0
-       adr     r0, err_str
+       mov     r4, r1                          @ preserve machine ID
+       adr     r0, str_a1
+       bl      printascii
+       mov     r0, r4
+       bl      printhex8
+       adr     r0, str_a2
+       bl      printascii
+       adr     r3, 3f
+       ldmia   r3, {r4, r5, r6}                @ get machine desc list
+       sub     r4, r3, r4                      @ get offset between virt&phys
+       add     r5, r5, r4                      @ convert virt addresses to
+       add     r6, r6, r4                      @ physical address space
+1:     ldr     r0, [r5, #MACHINFO_TYPE]        @ get machine type
+       bl      printhex8
+       mov     r0, #'\t'
+       bl      printch
+       ldr     r0, [r5, #MACHINFO_NAME]        @ get machine name
+       add     r0, r0, r4
        bl      printascii
-       mov     r0, r8
+       mov     r0, #'\n'
        bl      printch
+       add     r5, r5, #SIZEOF_MACHINE_DESC    @ next machine_desc
+       cmp     r5, r6
+       blo     1b
+       adr     r0, str_a3
+       bl      printascii
+       b       __error
+str_a1:        .asciz  "\nError: unrecognized/unsupported machine ID (r1 = 0x"
+str_a2:        .asciz  ").\n\nAvailable machine support:\n\nID (hex)\tNAME\n"
+str_a3:        .asciz  "\nPlease check your kernel config and/or bootloader.\n"
+       .align
 #endif
+
+       .type   __error, %function
+__error:
 #ifdef CONFIG_ARCH_RPC
 /*
  * Turn the screen red on a error - RiscPC only.
@@ -391,12 +428,6 @@
 1:     mov     r0, r0
        b       1b
 
-#ifdef CONFIG_DEBUG_LL
-       .type   err_str, %object
-err_str:
-       .asciz  "\nError: "
-       .align
-#endif
 
 /*
  * Read processor ID register (CP#15, CR0), and look up in the linker-built
@@ -465,7 +496,7 @@
        sub     r3, r3, r4                      @ get offset between virt&phys
        add     r5, r5, r3                      @ convert virt addresses to
        add     r6, r6, r3                      @ physical address space
-1:     ldr     r3, [r5]                        @ get machine type
+1:     ldr     r3, [r5, #MACHINFO_TYPE]        @ get machine type
        teq     r3, r1                          @ matches loader number?
        beq     2f                              @ found
        add     r5, r5, #SIZEOF_MACHINE_DESC    @ next machine_desc
diff -Nru a/include/asm-arm/mach/arch.h b/include/asm-arm/mach/arch.h
--- a/include/asm-arm/mach/arch.h       2005-03-28 23:12:15 -08:00
+++ b/include/asm-arm/mach/arch.h       2005-03-28 23:12:15 -08:00
@@ -16,7 +16,7 @@
 
 struct machine_desc {
        /*
-        * Note! The first four elements are used
+        * Note! The first five elements are used
         * by assembler code in head-armv.S
         */
        unsigned int            nr;             /* architecture number  */
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to