merge mainline into sgi

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-05-15 02:23:36 +02:00
commit bee1aeb9a1
49 changed files with 1148 additions and 348 deletions

View file

@ -33,15 +33,14 @@ GRUB_MOD_LICENSE ("GPLv3+");
/* For frequencies. */
#include <grub/machine/time.h>
#ifdef GRUB_MACHINE_MIPS_YEELOONG
#ifdef GRUB_MACHINE_MIPS_LOONGSON
#include <grub/pci.h>
/* 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"
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;
@ -55,7 +54,7 @@ static grub_uint8_t *playground;
static grub_addr_t target_addr, entry_addr;
static int linux_argc;
static grub_off_t argv_off;
#ifdef GRUB_MACHINE_MIPS_YEELOONG
#ifdef GRUB_MACHINE_MIPS_LOONGSON
static grub_off_t envp_off;
#endif
static grub_off_t rd_addr_arg_off, rd_size_arg_off;
@ -70,7 +69,7 @@ grub_linux_boot (void)
state.gpr[1] = entry_addr;
state.gpr[4] = linux_argc;
state.gpr[5] = target_addr + argv_off;
#ifdef GRUB_MACHINE_MIPS_YEELOONG
#ifdef GRUB_MACHINE_MIPS_LOONGSON
state.gpr[6] = target_addr + envp_off;
#else
state.gpr[6] = 0;
@ -213,7 +212,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_uint32_t *linux_argv;
char *linux_args;
grub_err_t err;
#ifdef GRUB_MACHINE_MIPS_YEELOONG
#ifdef GRUB_MACHINE_MIPS_LOONGSON
char *linux_envs;
grub_uint32_t *linux_envp;
#endif
@ -238,7 +237,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
/* For arguments. */
linux_argc = argc;
#ifdef LOONGSON_MACHTYPE
#ifdef GRUB_MACHINE_MIPS_LOONGSON
linux_argc++;
#endif
/* Main arguments. */
@ -253,8 +252,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_LOONGSON
size += ALIGN_UP (sizeof (loongson_machtypes[0]), 4);
#endif
/* rd arguments. */
@ -293,14 +292,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_LOONGSON
{
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++)
@ -327,7 +332,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
extra = linux_args;
#ifdef GRUB_MACHINE_MIPS_YEELOONG
#ifdef GRUB_MACHINE_MIPS_LOONGSON
linux_envp = extra;
envp_off = (grub_uint8_t *) linux_envp - (grub_uint8_t *) playground;
linux_envs = (char *) (linux_envp + 5);