]> git.proxmox.com Git - grub2.git/commitdiff
machtype autodetection
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 18 Jan 2011 18:04:27 +0000 (19:04 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 18 Jan 2011 18:04:27 +0000 (19:04 +0100)
grub-core/boot/mips/startup_raw.S
grub-core/boot/mips/yeeloong/fwstart.S
grub-core/kern/mips/startup.S

index c41ce8257925e2cdbaa6f198c562dd928e095fe4..d8789982fa0253b1657ed7d0f073c81e067e0655 100644 (file)
@@ -20,6 +20,7 @@
 #include <grub/symbol.h>
 #include <grub/offsets.h>
 #include <grub/machine/memory.h>
+#include <grub/machine/kernel.h>
 #include <grub/offsets.h>
 
 #define BASE_ADDR 8
@@ -54,10 +55,12 @@ codestart:
        move $s3, $zero
        move $s4, $zero
        move $s5, $zero
+       move $s7, $zero
 
        /* $a2 has the environment.  */
-       addiu $t0, $a2, 1
-       beq $t0, $zero, argdone
+       addiu $t0, $zero, -0x10
+       and $t1, $a2, $t0
+       beq $t0, $t1, argfw
         nop
        move $t0, $a2   
 argcont:       
@@ -72,11 +75,19 @@ argcont:
         nop              ;\
        b 2f;\
         move reg, $v0;  \
-1:     
+1:
+#define DO_CHECKT1(str, val)                            \
+       move $t6, $t1                                   ;\
+       addiu $t7, $s0, (str - base);\
+       bal do_check                                   ;\
+        li $t2, val
+
        DO_PARSE (busclockstr, $s2)
        DO_PARSE (cpuclockstr, $s3)
        DO_PARSE (memsizestr, $s4)
        DO_PARSE (highmemsizestr, $s5)
+       DO_CHECKT1 (pmon_yeeloong_verstr, GRUB_ARCH_MACHINE_YEELOONG)
+       DO_CHECKT1 (pmon_fuloong_verstr, GRUB_ARCH_MACHINE_FULOONG)
 2:     
        b argcont
         addiu $t0, $t0, 4       
@@ -120,8 +131,47 @@ busclockstr:       .asciiz "busclock="
 cpuclockstr:   .asciiz "cpuclock="
 memsizestr:    .asciiz "memsize="
 highmemsizestr:        .asciiz "highmemsize="
+machtype_yeeloong_str1:        .asciiz "machtype=8.9"
+machtype_yeeloong_str2:        .asciiz "machtype=lemote-yeeloong-"
+machtype_fuloong_str:  .asciiz "machtype=lemote-fuloong-"
+pmon_yeeloong_str:     .asciiz "PMON_VER=LM8"
+pmon_fuloong_str:      .asciiz "PMON_VER=LM6"
+pmon_yeeloong_verstr:  .asciiz "Version=LM8"
+pmon_fuloong_verstr:   .asciiz "Version=LM6"
        .p2align 2
+
 argdone:
+       beq $a0, $zero, cmdlinedone
+        nop
+#define DO_CHECKA1(str, val)                            \
+       lw $t6, 0($a1)                                  ;\
+       addiu $t7, $s0, (str - base);\
+       bal do_check                                   ;\
+        li $t2, val
+       DO_CHECKA1 (machtype_yeeloong_str1, GRUB_ARCH_MACHINE_YEELOONG)
+       DO_CHECKA1 (machtype_yeeloong_str2, GRUB_ARCH_MACHINE_YEELOONG)
+       DO_CHECKA1 (pmon_yeeloong_str, GRUB_ARCH_MACHINE_YEELOONG)
+       DO_CHECKA1 (machtype_fuloong_str, GRUB_ARCH_MACHINE_FULOONG)
+       DO_CHECKA1 (pmon_fuloong_str, GRUB_ARCH_MACHINE_FULOONG)
+       addiu $a0, $a0, -1
+       b argdone
+        addiu $a1, $a1, 4
+do_check:
+       lb $t4, 0($t7)
+       beq $t4, $zero, 1f
+        lb $t3, 0($t6)
+       bne $t3, $t4, 2f
+        addiu $t6, $t6, 1
+       b do_check
+        addiu $t7, $t7, 1
+1:
+       move $s7, $t2
+2:
+       jr $ra
+        nop
+argfw:
+       not $s7, $a2
+cmdlinedone:   
 #endif
        /* Copy the decompressor. */
        lui $t1, %hi(base)
index 4c2fe554341ad6d7d2f83a11e628f06c1c99d02b..bc59c1174ccf0210b0334a44835c6cb735dabe2e 100644 (file)
@@ -21,6 +21,7 @@
 #include <grub/mips/loongson.h>
 #include <grub/pci.h>
 #include <grub/machine/serial.h>
+#include <grub/machine/kernel.h>
 #include <grub/ns8250.h>
 #include <grub/cs5536.h>
 #include <grub/smbus.h>
@@ -629,6 +630,6 @@ continue:
        lui $t0, %hi(cached_continue - 0x20000000)
        addiu $t0, $t0, %lo(cached_continue - 0x20000000)
        jr $t0
-        addiu $a2, $zero, -1
+        addiu $a2, $zero, -(1 + GRUB_ARCH_MACHINE_YEELOONG)
 
 cached_continue:
\ No newline at end of file
index 4bf4c17628a830340d53dd52a83d1a2886c3186f..999beee7980bed053277d6f8550f497fd7ce2619 100644 (file)
@@ -74,6 +74,7 @@ cont:
        sw $s3, 4($t1)
        sw $s4, 8($t1)
        sw $s5, 12($t1)
+       sw $s7, 16($t1)
 #endif
 
        /* Move the modules out of BSS.  */