MIPS qemu flash support.
* grub-core/boot/mips/startup_raw.S [GRUB_MACHINE_MIPS_QEMU_MIPS]: Check magic. * grub-core/kern/mips/qemu_mips/init.c (probe_mem): New function. (grub_machine_init): Probe memory if its size isn't known. * util/grub-mkimage.c (image_targets): Add flash targets. (generate_image): Handle flash targets.
This commit is contained in:
parent
d734599439
commit
748ccabea1
4 changed files with 121 additions and 3 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2011-07-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
MIPS qemu flash support.
|
||||
|
||||
* grub-core/boot/mips/startup_raw.S [GRUB_MACHINE_MIPS_QEMU_MIPS]: Check
|
||||
magic.
|
||||
* grub-core/kern/mips/qemu_mips/init.c (probe_mem): New function.
|
||||
(grub_machine_init): Probe memory if its size isn't known.
|
||||
* util/grub-mkimage.c (image_targets): Add flash targets.
|
||||
(generate_image): Handle flash targets.
|
||||
|
||||
2011-07-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
MIPS qemu at_keyboard support.
|
||||
|
|
|
@ -54,8 +54,22 @@ codestart:
|
|||
/* Parse arguments. Has to be done before relocation.
|
||||
So need to do it in asm. */
|
||||
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
|
||||
lui $t0, %hi (((16 << 20) - 264 + 4) | 0x80000000)
|
||||
lw $t1, %lo (((16 << 20) - 264 + 4) | 0x80000000) ($t0)
|
||||
|
||||
lui $t2, 0x1234
|
||||
ori $t2, 0x5678
|
||||
|
||||
bne $t1, $t2, 1f
|
||||
nop
|
||||
|
||||
lui $t0, %hi (((16 << 20) - 264) | 0x80000000)
|
||||
lw $s4, %lo (((16 << 20) - 264) | 0x80000000) ($t0)
|
||||
b 2f
|
||||
lw $s4, %lo (((16 << 20) - 264) | 0x80000000) ($t0)
|
||||
|
||||
1:
|
||||
li $s4, 0
|
||||
2:
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
|
|
|
@ -23,11 +23,36 @@ extern void grub_terminfo_init (void);
|
|||
extern void grub_keylayouts_init (void);
|
||||
extern void grub_boot_init (void);
|
||||
|
||||
static inline int
|
||||
probe_mem (grub_addr_t addr)
|
||||
{
|
||||
volatile grub_uint8_t *ptr = (grub_uint8_t *) (0xa0000000 | addr);
|
||||
grub_uint8_t c = *ptr;
|
||||
*ptr = 0xAA;
|
||||
if (*ptr != 0xAA)
|
||||
return 0;
|
||||
*ptr = 0x55;
|
||||
if (*ptr != 0x55)
|
||||
return 0;
|
||||
*ptr = c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
grub_addr_t modend;
|
||||
|
||||
if (grub_arch_memsize == 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 27; i >= 0; i--)
|
||||
if (probe_mem (grub_arch_memsize | (1 << i)))
|
||||
grub_arch_memsize |= (1 << i);
|
||||
grub_arch_memsize++;
|
||||
}
|
||||
|
||||
/* FIXME: measure this. */
|
||||
grub_arch_cpuclock = 64000000;
|
||||
|
||||
|
@ -40,7 +65,6 @@ grub_machine_init (void)
|
|||
grub_video_init ();
|
||||
grub_bitmap_init ();
|
||||
grub_font_init ();
|
||||
grub_gfxterm_init ();
|
||||
|
||||
grub_keylayouts_init ();
|
||||
grub_at_keyboard_init ();
|
||||
|
@ -49,6 +73,8 @@ grub_machine_init (void)
|
|||
grub_serial_init ();
|
||||
|
||||
grub_boot_init ();
|
||||
|
||||
grub_gfxterm_init ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -67,7 +67,8 @@ struct image_target_desc
|
|||
IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
|
||||
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
|
||||
IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
|
||||
IMAGE_FULOONG_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC
|
||||
IMAGE_FULOONG_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
|
||||
IMAGE_QEMU_MIPS_FLASH
|
||||
} id;
|
||||
enum
|
||||
{
|
||||
|
@ -466,6 +467,50 @@ struct image_target_desc image_targets[] =
|
|||
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.dirname = "mips-qemu_mips",
|
||||
.names = { "mips-qemu_mips-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_QEMU_MIPS_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.dirname = "mipsel-qemu_mips",
|
||||
.names = { "mipsel-qemu_mips-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_QEMU_MIPS_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.dirname = "mips-qemu_mips",
|
||||
.names = { "mips-qemu_mips-elf", NULL },
|
||||
|
@ -1389,6 +1434,28 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
core_size = rom_size;
|
||||
}
|
||||
break;
|
||||
case IMAGE_QEMU_MIPS_FLASH:
|
||||
{
|
||||
char *rom_img;
|
||||
size_t rom_size;
|
||||
|
||||
if (core_size > 512 * 1024)
|
||||
grub_util_error ("firmware image is too big");
|
||||
rom_size = 512 * 1024;
|
||||
|
||||
rom_img = xmalloc (rom_size);
|
||||
memset (rom_img, 0, rom_size);
|
||||
|
||||
memcpy (rom_img, core_img, core_size);
|
||||
|
||||
memset (rom_img + core_size, 0,
|
||||
rom_size - core_size);
|
||||
|
||||
free (core_img);
|
||||
core_img = rom_img;
|
||||
core_size = rom_size;
|
||||
}
|
||||
break;
|
||||
case IMAGE_MIPS_ARC:
|
||||
{
|
||||
char *ecoff_img;
|
||||
|
|
Loading…
Reference in a new issue