grub as flash for qemu-gdium
This commit is contained in:
parent
ad17a401d6
commit
a9a6948ac3
10 changed files with 46 additions and 16 deletions
|
@ -87,7 +87,7 @@ sbin_UTILITIES += grub-emu
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# For grub-mkimage.
|
# For grub-mkimage.
|
||||||
grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \
|
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
||||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||||
util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile
|
util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
|
@ -103,6 +103,13 @@ kernel_img_FORMAT = binary
|
||||||
sbin_SCRIPTS =
|
sbin_SCRIPTS =
|
||||||
bin_SCRIPTS =
|
bin_SCRIPTS =
|
||||||
|
|
||||||
|
# For grub-mkimage.
|
||||||
|
bin_UTILITIES += grub-mkimage
|
||||||
|
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
||||||
|
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||||
|
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||||
|
util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = memdisk.mod \
|
pkglib_MODULES = memdisk.mod \
|
||||||
lsmmap.mod
|
lsmmap.mod
|
||||||
|
|
|
@ -28,7 +28,23 @@
|
||||||
#define GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE 0xc
|
#define GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE 0xc
|
||||||
#define GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE 0x10
|
#define GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE 0x10
|
||||||
|
|
||||||
#define GRUB_KERNEL_CPU_PREFIX 0x0
|
#define GRUB_KERNEL_CPU_PREFIX GRUB_KERNEL_CPU_RAW_SIZE
|
||||||
#define GRUB_KERNEL_CPU_DATA_END 0x48
|
#define GRUB_KERNEL_CPU_DATA_END GRUB_KERNEL_CPU_RAW_SIZE + 0x48
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_KERNEL_CPU_RAW_SIZE
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MACHINE_PREFIX GRUB_KERNEL_CPU_PREFIX
|
||||||
|
#define GRUB_KERNEL_MACHINE_DATA_END GRUB_KERNEL_CPU_DATA_END
|
||||||
|
#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE
|
||||||
|
#define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE
|
||||||
|
#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE GRUB_KERNEL_CPU_COMPRESSED_SIZE
|
||||||
|
|
||||||
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
/* The prefix which points to the directory where GRUB modules and its
|
||||||
|
configuration file are located. */
|
||||||
|
extern char grub_prefix[];
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define GRUB_KERNEL_MACHINE_HEADER 1
|
#define GRUB_KERNEL_MACHINE_HEADER 1
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/cpu/kernel.h>
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
|
|
@ -20,16 +20,13 @@
|
||||||
#define GRUB_KERNEL_MACHINE_HEADER 1
|
#define GRUB_KERNEL_MACHINE_HEADER 1
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/cpu/kernel.h>
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
void EXPORT_FUNC (grub_reboot) (void);
|
void EXPORT_FUNC (grub_reboot) (void);
|
||||||
void EXPORT_FUNC (grub_halt) (void);
|
void EXPORT_FUNC (grub_halt) (void);
|
||||||
|
|
||||||
/* The prefix which points to the directory where GRUB modules and its
|
|
||||||
configuration file are located. */
|
|
||||||
extern char grub_prefix[];
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
|
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x801ffff0
|
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x801ffff0
|
||||||
|
#define GRUB_MACHINE_MEMORY_USABLE 0x81000000
|
||||||
|
|
||||||
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ grub_module_iterate (int (*hook) (struct grub_module_header *header))
|
||||||
header < (struct grub_module_header *) (modbase + modinfo->size);
|
header < (struct grub_module_header *) (modbase + modinfo->size);
|
||||||
header = (struct grub_module_header *) ((char *) header + header->size))
|
header = (struct grub_module_header *) ((char *) header + header->size))
|
||||||
{
|
{
|
||||||
|
grub_printf ("%p:", header);
|
||||||
if (hook (header))
|
if (hook (header))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ reloccont:
|
||||||
bne $t3, $0, reloccont
|
bne $t3, $0, reloccont
|
||||||
|
|
||||||
/* Move the modules out of BSS. */
|
/* Move the modules out of BSS. */
|
||||||
lui $t1, %hi(compressed)
|
lui $t1, %hi(_start)
|
||||||
addiu $t1, %lo(compressed)
|
addiu $t1, %lo(_start)
|
||||||
lw $t2, (GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE - BASE_ADDR)($ra)
|
lw $t2, (GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE - BASE_ADDR)($ra)
|
||||||
addu $t2, $t1, $t2
|
addu $t2, $t1, $t2
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ reloccont:
|
||||||
nor $t3, $t3, $0
|
nor $t3, $t3, $0
|
||||||
and $t1, $t1, $t3
|
and $t1, $t1, $t3
|
||||||
/* Pass modules address as first argument. */
|
/* Pass modules address as first argument. */
|
||||||
move $a0, $t1
|
// move $a0, $t1
|
||||||
|
|
||||||
lw $t3, (GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE - BASE_ADDR)($ra)
|
lw $t3, (GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE - BASE_ADDR)($ra)
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ bsscont:
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_CPU_RAW_SIZE
|
. = _start + GRUB_KERNEL_CPU_RAW_SIZE
|
||||||
compressed:
|
compressed:
|
||||||
. = _start + GRUB_KERNEL_CPU_RAW_SIZE + GRUB_KERNEL_CPU_PREFIX
|
. = _start + GRUB_KERNEL_CPU_PREFIX
|
||||||
|
|
||||||
VARIABLE(grub_prefix)
|
VARIABLE(grub_prefix)
|
||||||
/* to be filled by grub-mkelfimage */
|
/* to be filled by grub-mkelfimage */
|
||||||
|
@ -116,4 +116,4 @@ VARIABLE(grub_prefix)
|
||||||
* Leave some breathing room for the prefix.
|
* Leave some breathing room for the prefix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_CPU_RAW_SIZE + GRUB_KERNEL_CPU_DATA_END
|
. = _start + GRUB_KERNEL_CPU_DATA_END
|
||||||
|
|
|
@ -51,7 +51,10 @@ grub_putcode (grub_uint32_t code)
|
||||||
int height = grub_getwh () & 255;
|
int height = grub_getwh () & 255;
|
||||||
|
|
||||||
if (!grub_cur_term_output)
|
if (!grub_cur_term_output)
|
||||||
return;
|
{
|
||||||
|
*(grub_uint8_t *)0xbff003f8 = code;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (code == '\t' && grub_cur_term_output->getxy)
|
if (code == '\t' && grub_cur_term_output->getxy)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,10 +93,10 @@ static void
|
||||||
generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
char *memdisk_path, char *config_path)
|
char *memdisk_path, char *config_path)
|
||||||
{
|
{
|
||||||
char *kernel_img, *boot_img, *core_img;
|
char *kernel_img, *core_img;
|
||||||
size_t kernel_size, boot_size, total_module_size, core_size;
|
size_t kernel_size, total_module_size, core_size;
|
||||||
size_t memdisk_size = 0, config_size = 0;
|
size_t memdisk_size = 0, config_size = 0;
|
||||||
char *kernel_path, *boot_path;
|
char *kernel_path;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
struct grub_util_path_list *path_list, *p, *next;
|
struct grub_util_path_list *path_list, *p, *next;
|
||||||
struct grub_module_info *modinfo;
|
struct grub_module_info *modinfo;
|
||||||
|
@ -198,6 +198,8 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
#if defined(GRUB_MACHINE_PCBIOS)
|
#if defined(GRUB_MACHINE_PCBIOS)
|
||||||
{
|
{
|
||||||
unsigned num;
|
unsigned num;
|
||||||
|
char *boot_path, *boot_img;
|
||||||
|
size_t boot_size;
|
||||||
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
|
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
|
||||||
if (num > 0xffff)
|
if (num > 0xffff)
|
||||||
grub_util_error ("the core image is too big");
|
grub_util_error ("the core image is too big");
|
||||||
|
@ -222,6 +224,8 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
{
|
{
|
||||||
char *rom_img;
|
char *rom_img;
|
||||||
size_t rom_size;
|
size_t rom_size;
|
||||||
|
char *boot_path, *boot_img;
|
||||||
|
size_t boot_size;
|
||||||
|
|
||||||
boot_path = grub_util_get_path (dir, "boot.img");
|
boot_path = grub_util_get_path (dir, "boot.img");
|
||||||
boot_size = grub_util_get_image_size (boot_path);
|
boot_size = grub_util_get_image_size (boot_path);
|
Loading…
Reference in a new issue