aout image support
This commit is contained in:
parent
6bea3f8983
commit
a49217cff7
10 changed files with 122 additions and 81 deletions
|
@ -129,7 +129,7 @@ bootit:
|
||||||
mov NOTIFICATION_DONE_LEN, %o3
|
mov NOTIFICATION_DONE_LEN, %o3
|
||||||
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
|
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
|
||||||
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
|
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
|
||||||
mov CIF_REG, %o0
|
mov CIF_REG, %o4
|
||||||
1: ba,a 1b
|
1: ba,a 1b
|
||||||
|
|
||||||
lastlist:
|
lastlist:
|
||||||
|
|
|
@ -48,7 +48,7 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
|
||||||
symlist.c kern/$(target_cpu)/cache.S
|
symlist.c kern/$(target_cpu)/cache.S
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc -static-libgcc -lgcc
|
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x4400,-Bstatic,-melf64_sparc -static-libgcc -lgcc
|
||||||
kernel_img_FORMAT = binary
|
kernel_img_FORMAT = binary
|
||||||
|
|
||||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||||
|
|
|
@ -102,6 +102,7 @@ union grub_aout_header
|
||||||
#define AOUT_MID_I386 134 /* i386 BSD binary */
|
#define AOUT_MID_I386 134 /* i386 BSD binary */
|
||||||
#define AOUT_MID_SPARC 138 /* sparc */
|
#define AOUT_MID_SPARC 138 /* sparc */
|
||||||
#define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
|
#define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
|
||||||
|
#define AOUT_MID_SUN 0x103
|
||||||
#define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
|
#define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
|
||||||
#define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
|
#define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
|
||||||
#define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
|
#define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
|
||||||
|
@ -114,10 +115,14 @@ union grub_aout_header
|
||||||
#define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
|
#define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
|
||||||
#define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
|
#define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
|
||||||
|
|
||||||
|
#ifndef GRUB_UTIL
|
||||||
|
|
||||||
int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
|
int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
|
grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
|
||||||
grub_addr_t load_addr, int load_size,
|
grub_addr_t load_addr, int load_size,
|
||||||
grub_addr_t bss_end_addr);
|
grub_addr_t bss_end_addr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ! GRUB_AOUT_HEADER */
|
#endif /* ! GRUB_AOUT_HEADER */
|
||||||
|
|
|
@ -59,6 +59,8 @@ extern grub_addr_t grub_arch_modules_addr (void);
|
||||||
|
|
||||||
extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
|
extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
|
||||||
|
|
||||||
|
grub_addr_t grub_modules_get_end (void);
|
||||||
|
|
||||||
/* The start point of the C code. */
|
/* The start point of the C code. */
|
||||||
void grub_main (void);
|
void grub_main (void);
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,21 @@
|
||||||
|
|
||||||
#define GRUB_KERNEL_MACHINE_RAW_SIZE 0
|
#define GRUB_KERNEL_MACHINE_RAW_SIZE 0
|
||||||
|
|
||||||
|
#define GRUB_PLATFORM_IMAGE_FORMATS "raw, aout"
|
||||||
|
#define GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "raw"
|
||||||
|
|
||||||
|
#define GRUB_PLATFORM_IMAGE_DEFAULT GRUB_PLATFORM_IMAGE_RAW
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GRUB_PLATFORM_IMAGE_RAW,
|
||||||
|
GRUB_PLATFORM_IMAGE_AOUT
|
||||||
|
}
|
||||||
|
grub_platform_image_format_t;
|
||||||
|
#define GRUB_PLATFORM_IMAGE_RAW GRUB_PLATFORM_IMAGE_RAW
|
||||||
|
#define GRUB_PLATFORM_IMAGE_AOUT GRUB_PLATFORM_IMAGE_AOUT
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
|
19
kern/main.c
19
kern/main.c
|
@ -53,6 +53,25 @@ grub_module_iterate (int (*hook) (struct grub_module_header *header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is actualy platform-independant but used only on yeeloong and sparc. */
|
||||||
|
#if defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_SPARC64)
|
||||||
|
grub_addr_t
|
||||||
|
grub_modules_get_end (void)
|
||||||
|
{
|
||||||
|
struct grub_module_info *modinfo;
|
||||||
|
grub_addr_t modbase;
|
||||||
|
|
||||||
|
modbase = grub_arch_modules_addr ();
|
||||||
|
modinfo = (struct grub_module_info *) modbase;
|
||||||
|
|
||||||
|
/* Check if there are any modules. */
|
||||||
|
if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
|
||||||
|
return modbase;
|
||||||
|
|
||||||
|
return modbase + modinfo->size;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Load all modules in core. */
|
/* Load all modules in core. */
|
||||||
static void
|
static void
|
||||||
grub_load_modules (void)
|
grub_load_modules (void)
|
||||||
|
|
|
@ -63,35 +63,13 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
get_modules_end (void)
|
|
||||||
{
|
|
||||||
struct grub_module_info *modinfo;
|
|
||||||
struct grub_module_header *header;
|
|
||||||
grub_addr_t modbase;
|
|
||||||
|
|
||||||
modbase = grub_arch_modules_addr ();
|
|
||||||
modinfo = (struct grub_module_info *) modbase;
|
|
||||||
|
|
||||||
/* Check if there are any modules. */
|
|
||||||
if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
|
|
||||||
return modinfo;
|
|
||||||
|
|
||||||
for (header = (struct grub_module_header *) (modbase + modinfo->offset);
|
|
||||||
header < (struct grub_module_header *) (modbase + modinfo->size);
|
|
||||||
header = (struct grub_module_header *) ((char *) header + header->size));
|
|
||||||
|
|
||||||
return header;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_machine_init (void)
|
grub_machine_init (void)
|
||||||
{
|
{
|
||||||
void *modend;
|
grub_addr_t modend;
|
||||||
modend = get_modules_end ();
|
modend = grub_modules_get_end ();
|
||||||
grub_mm_init_region (modend, (grub_arch_memsize << 20)
|
grub_mm_init_region (modend, (grub_arch_memsize << 20)
|
||||||
- (((grub_addr_t) modend) - GRUB_ARCH_LOWMEMVSTART));
|
- (modend - GRUB_ARCH_LOWMEMVSTART));
|
||||||
/* FIXME: use upper memory as well. */
|
/* FIXME: use upper memory as well. */
|
||||||
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
.globl _start
|
.globl _start
|
||||||
_start:
|
_start:
|
||||||
ba codestart
|
ba codestart
|
||||||
nop
|
mov %o4, %o0
|
||||||
|
|
||||||
. = EXT_C(_start) + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
. = EXT_C(_start) + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ grub_machine_set_prefix (void)
|
||||||
static void
|
static void
|
||||||
grub_heap_init (void)
|
grub_heap_init (void)
|
||||||
{
|
{
|
||||||
grub_mm_init_region ((void *)(long)0x4000UL, 0x200000 - 0x4000);
|
grub_mm_init_region ((void *) grub_modules_get_end (), 0x200000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
#include <grub/elf.h>
|
#include <grub/elf.h>
|
||||||
|
#include <grub/aout.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <grub/kernel.h>
|
#include <grub/kernel.h>
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
|
@ -230,6 +231,36 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
|
|
||||||
grub_util_info ("the core size is 0x%x", core_size);
|
grub_util_info ("the core size is 0x%x", core_size);
|
||||||
|
|
||||||
|
#ifdef GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||||
|
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
|
||||||
|
= grub_host_to_target32 (total_module_size);
|
||||||
|
#endif
|
||||||
|
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
|
||||||
|
= grub_host_to_target32 (kernel_size);
|
||||||
|
#ifdef GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
|
||||||
|
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
|
||||||
|
= grub_host_to_target32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) && defined(GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
|
||||||
|
/* If we included a drive in our prefix, let GRUB know it doesn't have to
|
||||||
|
prepend the drive told by BIOS. */
|
||||||
|
if (prefix[0] == '(')
|
||||||
|
{
|
||||||
|
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART))
|
||||||
|
= grub_host_to_target32 (-2);
|
||||||
|
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART))
|
||||||
|
= grub_host_to_target32 (-2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_PCBIOS
|
||||||
|
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
|
||||||
|
grub_util_error (_("core image is too big (%p > %p)"),
|
||||||
|
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
|
||||||
|
GRUB_MEMORY_MACHINE_UPPER);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(GRUB_MACHINE_PCBIOS)
|
#if defined(GRUB_MACHINE_PCBIOS)
|
||||||
{
|
{
|
||||||
unsigned num;
|
unsigned num;
|
||||||
|
@ -299,6 +330,26 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
free (boot_path);
|
free (boot_path);
|
||||||
}
|
}
|
||||||
#elif defined (GRUB_MACHINE_SPARC64)
|
#elif defined (GRUB_MACHINE_SPARC64)
|
||||||
|
if (format == GRUB_PLATFORM_IMAGE_AOUT)
|
||||||
|
{
|
||||||
|
void *aout_img;
|
||||||
|
size_t aout_size;
|
||||||
|
struct grub_aout32_header *aout_head;
|
||||||
|
|
||||||
|
aout_size = core_size + sizeof (*aout_head);
|
||||||
|
aout_img = xmalloc (aout_size);
|
||||||
|
aout_head = aout_img;
|
||||||
|
aout_head->a_midmag = grub_host_to_target32 ((AOUT_MID_SUN << 16)
|
||||||
|
| AOUT32_OMAGIC);
|
||||||
|
aout_head->a_text = grub_host_to_target32 (core_size);
|
||||||
|
aout_head->a_entry = grub_host_to_target32 (0x4400);
|
||||||
|
memcpy (aout_img + sizeof (*aout_head), core_img, core_size);
|
||||||
|
|
||||||
|
free (core_img);
|
||||||
|
core_img = aout_img;
|
||||||
|
core_size = aout_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
unsigned int num;
|
unsigned int num;
|
||||||
char *boot_path, *boot_img;
|
char *boot_path, *boot_img;
|
||||||
|
@ -322,39 +373,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
free (boot_img);
|
free (boot_img);
|
||||||
free (boot_path);
|
free (boot_path);
|
||||||
}
|
}
|
||||||
#endif
|
#elif defined(GRUB_MACHINE_MIPS)
|
||||||
|
|
||||||
#ifdef GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
|
||||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
|
|
||||||
= grub_host_to_target32 (total_module_size);
|
|
||||||
#endif
|
|
||||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
|
|
||||||
= grub_host_to_target32 (kernel_size);
|
|
||||||
#ifdef GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
|
|
||||||
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
|
|
||||||
= grub_host_to_target32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) && defined(GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
|
|
||||||
/* If we included a drive in our prefix, let GRUB know it doesn't have to
|
|
||||||
prepend the drive told by BIOS. */
|
|
||||||
if (prefix[0] == '(')
|
|
||||||
{
|
|
||||||
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART))
|
|
||||||
= grub_host_to_target32 (-2);
|
|
||||||
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART))
|
|
||||||
= grub_host_to_target32 (-2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_PCBIOS
|
|
||||||
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
|
|
||||||
grub_util_error (_("core image is too big (%p > %p)"),
|
|
||||||
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
|
|
||||||
GRUB_MEMORY_MACHINE_UPPER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GRUB_MACHINE_MIPS)
|
|
||||||
if (format == GRUB_PLATFORM_IMAGE_ELF)
|
if (format == GRUB_PLATFORM_IMAGE_ELF)
|
||||||
{
|
{
|
||||||
char *elf_img;
|
char *elf_img;
|
||||||
|
@ -527,6 +546,11 @@ main (int argc, char *argv[])
|
||||||
if (strcmp (optarg, "elf") == 0)
|
if (strcmp (optarg, "elf") == 0)
|
||||||
format = GRUB_PLATFORM_IMAGE_ELF;
|
format = GRUB_PLATFORM_IMAGE_ELF;
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
|
#ifdef GRUB_PLATFORM_IMAGE_AOUT
|
||||||
|
if (strcmp (optarg, "aout") == 0)
|
||||||
|
format = GRUB_PLATFORM_IMAGE_AOUT;
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
usage (1);
|
usage (1);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue