]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
fuloong support
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 18 Jan 2011 14:28:44 +0000 (15:28 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 18 Jan 2011 14:28:44 +0000 (15:28 +0100)
grub-core/boot/mips/yeeloong/fwstart.S
grub-core/kern/mips/startup.S
grub-core/kern/mips/yeeloong/init.c
grub-core/loader/mips/linux.c
grub-core/term/serial.c
include/grub/mips/yeeloong/kernel.h
include/grub/mips/yeeloong/serial.h
include/grub/term.h

index 42545840183328421f36c99dc80eecdfc3067788..4c2fe554341ad6d7d2f83a11e628f06c1c99d02b 100644 (file)
@@ -25,6 +25,9 @@
 #include <grub/cs5536.h>
 #include <grub/smbus.h>
 
+#define GRUB_MACHINE_SERIAL_PORT GRUB_MACHINE_SERIAL_PORT0
+#define GRUB_MACHINE_SERIAL_DIVISOR_115200 GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200
+
        .set noreorder
        .set noat
        .set nomacro
index ae0e0b187a3cb7f21cb3483c7a224d0314d34b26..4bf4c17628a830340d53dd52a83d1a2886c3186f 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    
@@ -59,6 +60,8 @@ VARIABLE (grub_arch_memsize)
        .long 0
 VARIABLE (grub_arch_highmemsize)
        .long 0
+VARIABLE (grub_arch_machine)
+       .long GRUB_ARCH_MACHINE_FULOONG
 #endif
 cont:
        /* Save our base.  */
index f42c9696d2d90115605102cca88181d36fb14f38..6787a205d6cd65966946575ee8c903fee0fc6fdb 100644 (file)
@@ -208,8 +208,11 @@ grub_machine_init (void)
   grub_font_init ();
   grub_gfxterm_init ();
 
-  grub_keylayouts_init ();
-  grub_at_keyboard_init ();
+  if (grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG)
+    {
+      grub_keylayouts_init ();
+      grub_at_keyboard_init ();
+    }
 
   grub_terminfo_init ();
   grub_serial_init ();
index 6ae2a9321d9c830dff66313f5a21963a7a580703..244d2b8a3f8ec6e767512d32fd7e3e16ce07f233 100644 (file)
 #include <grub/machine/time.h>
 
 #ifdef GRUB_MACHINE_MIPS_YEELOONG
-/* This can be detected on runtime from PMON, but:
-     a) it wouldn't work when GRUB is the firmware
-   and
-     b) for now we only support Yeeloong anyway.  */
-#define LOONGSON_MACHTYPE "machtype=lemote-yeeloong-2f-8.9inches"
+#include <grub/machine/kernel.h>
+
+const char loongson_machtypes[][60] =
+  {
+    [GRUB_ARCH_MACHINE_YEELOONG] = "machtype=lemote-yeeloong-2f-8.9inches",
+    [GRUB_ARCH_MACHINE_FULOONG]  = "machtype=lemote-fuloong-2f-unknown"
+  };
 #endif
 
 static grub_dl_t my_mod;
@@ -222,7 +224,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 
   /* For arguments.  */
   linux_argc = argc;
-#ifdef LOONGSON_MACHTYPE
+#ifdef GRUB_MACHINE_MIPS_YEELOONG
   linux_argc++;
 #endif
   /* Main arguments.  */
@@ -237,8 +239,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
   /* Normal arguments.  */
   for (i = 1; i < argc; i++)
     size += ALIGN_UP (grub_strlen (argv[i]) + 1, 4);
-#ifdef LOONGSON_MACHTYPE
-  size += ALIGN_UP (sizeof (LOONGSON_MACHTYPE), 4);
+#ifdef GRUB_MACHINE_MIPS_YEELOONG
+  size += ALIGN_UP (sizeof (loongson_machtypes[0]), 4);
 #endif
 
   /* rd arguments.  */
@@ -277,14 +279,20 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
   linux_argv++;
   linux_args += ALIGN_UP (sizeof ("a0"), 4);
 
-#ifdef LOONGSON_MACHTYPE
-  /* In Loongson platform, it is the responsibility of the bootloader/firmware
-     to supply the OS kernel with machine type information.  */
-  grub_memcpy (linux_args, LOONGSON_MACHTYPE, sizeof (LOONGSON_MACHTYPE));
-  *linux_argv = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground
-    + target_addr;
-  linux_argv++;
-  linux_args += ALIGN_UP (sizeof (LOONGSON_MACHTYPE), 4);
+#ifdef GRUB_MACHINE_MIPS_YEELOONG
+  {
+    unsigned mtype = grub_arch_machine;
+    if (mtype >= ARRAY_SIZE (loongson_machtypes))
+      mtype = 0;
+    /* In Loongson platform, it is the responsibility of the bootloader/firmware
+       to supply the OS kernel with machine type information.  */
+    grub_memcpy (linux_args, loongson_machtypes[mtype],
+                sizeof (loongson_machtypes[mtype]));
+    *linux_argv = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground
+      + target_addr;
+    linux_argv++;
+    linux_args += ALIGN_UP (sizeof (loongson_machtypes[mtype]), 4);
+  }
 #endif
 
   for (i = 1; i < argc; i++)
index e672a89d643c54289282873240b1818da13e36e4..aca5769fdb3cf3e9030c3ca4ef961292e23e08b5 100644 (file)
@@ -26,6 +26,9 @@
 #include <grub/extcmd.h>
 #include <grub/i18n.h>
 #include <grub/list.h>
+#ifdef GRUB_MACHINE_MIPS_YEELOONG
+#include <grub/machine/kernel.h>
+#endif
 
 #define FOR_SERIAL_PORTS(var) FOR_LIST_ELEMENTS((var), (grub_serial_ports))
 
@@ -296,17 +299,22 @@ grub_serial_register (struct grub_serial_port *port)
   port->term_out = out;
   grub_terminfo_output_register (out, "vt100");
 #ifdef GRUB_MACHINE_MIPS_YEELOONG
-  if (grub_strcmp (port->name, "com0") == 0)
+  if (grub_strcmp (port->name, 
+                  (grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG)
+                  ? "com0" : "com2") == 0)
     {
       grub_term_register_input_active ("serial_*", in);
       grub_term_register_output_active ("serial_*", out);
     }
   else
-#endif
     {
-      grub_term_register_input ("serial_*", in);
-      grub_term_register_output ("serial_*", out);
+      grub_term_register_input_inactive ("serial_*", in);
+      grub_term_register_output_inactive ("serial_*", out);
     }
+#else
+  grub_term_register_input ("serial_*", in);
+  grub_term_register_output ("serial_*", out);
+#endif
 
   return GRUB_ERR_NONE;
 }
index 15cf9f9fd3da6db8b0c757adac775457d2997087..857b37a154e9900d04381f980fe4b0f28e88f022 100644 (file)
 
 #include <grub/symbol.h>
 
+#define GRUB_ARCH_MACHINE_YEELOONG 0
+#define GRUB_ARCH_MACHINE_FULOONG 1
+
 #ifndef ASM_FILE
 
 void EXPORT_FUNC (grub_reboot) (void) __attribute__ ((noreturn));
 void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
 
+extern grub_uint32_t EXPORT_VAR (grub_arch_machine);
+
 #endif
 
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */
index ebe3638a1d4cb90163f5b591a7a219620e1049af..45e6d8457f462d1f40970b742afe2334b088ddd3 100644 (file)
 #ifndef GRUB_MACHINE_SERIAL_HEADER
 #define GRUB_MACHINE_SERIAL_HEADER     1
 
-#define GRUB_MACHINE_SERIAL_DIVISOR_115200 2
-#define GRUB_MACHINE_SERIAL_PORT  0xbff003f8
+#define GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200 2
+#define GRUB_MACHINE_SERIAL_PORT2_DIVISOR_115200 1
+#define GRUB_MACHINE_SERIAL_PORT0  0xbff003f8
+#define GRUB_MACHINE_SERIAL_PORT1  0xbfd003f8
+#define GRUB_MACHINE_SERIAL_PORT2  0xbfd002f8
 
 #ifndef ASM_FILE
-#define GRUB_MACHINE_SERIAL_PORTS { GRUB_MACHINE_SERIAL_PORT }
+#define GRUB_MACHINE_SERIAL_PORTS { GRUB_MACHINE_SERIAL_PORT0, GRUB_MACHINE_SERIAL_PORT1, GRUB_MACHINE_SERIAL_PORT2 }
 #else
 #endif
 
index dbcb2f52cc4fab43c90dedd50c7f1762e3b06c5a..e9efc3f84d8e2dad0e7963857d16e96d8f226f86 100644 (file)
@@ -251,6 +251,14 @@ grub_term_register_input (const char *name __attribute__ ((unused)),
     }
 }
 
+static inline void
+grub_term_register_input_inactive (const char *name __attribute__ ((unused)),
+                                  grub_term_input_t term)
+{
+  grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
+                 GRUB_AS_LIST (term));
+}
+
 static inline void
 grub_term_register_input_active (const char *name __attribute__ ((unused)),
                                 grub_term_input_t term)
@@ -275,6 +283,14 @@ grub_term_register_output (const char *name __attribute__ ((unused)),
     }
 }
 
+static inline void
+grub_term_register_output_inactive (const char *name __attribute__ ((unused)),
+                                   grub_term_output_t term)
+{
+  grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
+                 GRUB_AS_LIST (term));
+}
+
 static inline void
 grub_term_register_output_active (const char *name __attribute__ ((unused)),
                                  grub_term_output_t term)