From: Vladimir 'phcoder' Serbinenko Date: Sun, 15 May 2011 00:23:36 +0000 (+0200) Subject: merge mainline into sgi X-Git-Tag: 2.00~1254^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bee1aeb9a1b540ea8334679c787cd3fdd1b81230;p=thirdparty%2Fgrub.git merge mainline into sgi --- bee1aeb9a1b540ea8334679c787cd3fdd1b81230 diff --cc conf/Makefile.common index 13963d5f3,77b84c112..751188b26 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@@ -25,9 -25,10 +25,9 @@@ endi if COND_i386_ieee1275 CFLAGS_PLATFORM += -mrtd -mregparm=3 endif - if COND_mips_yeeloong + if COND_mips_loongson CFLAGS_PLATFORM += -mexplicit-relocs CPPFLAGS_PLATFORM = -DUSE_ASCII_FAILBACK - CCASFLAGS_PLATFORM = -march=mips3 endif if COND_mips CFLAGS_PLATFORM += -mflush-func=grub_cpu_flush_cache diff --cc configure.ac index 28c13b511,50049b5e8..9c086f4df --- a/configure.ac +++ b/configure.ac @@@ -123,8 -123,9 +123,10 @@@ case "$target_cpu"-"$platform" i powerpc-ieee1275) ;; sparc64-ieee1275) ;; mips-qemu-mips) ;; - mips-yeeloong) ;; + mips-yeeloong) platform=loongson ;; + mips-fuloong) platform=loongson ;; + mips-loongson) ;; + mips-arc) ;; *-emu) ;; *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;; esac @@@ -157,9 -158,8 +159,9 @@@ case "$platform" i qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;; pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;; emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;; - yeeloong) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; + loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; qemu-mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; + mips-arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_ARC=1 -DGRUB_MACHINE_ARC=1" ;; esac case "$target_cpu" in mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;; @@@ -952,9 -952,8 +954,9 @@@ AM_CONDITIONAL([COND_i386_ieee1275], [t AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot]) AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot]) AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi]) - AM_CONDITIONAL([COND_mips_yeeloong], [test x$target_cpu = xmips -a x$platform = xyeeloong]) + AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmips -a x$platform = xloongson]) AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips]) +AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc]) AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips]) diff --cc gentpl.py index c8d81cfba,17c6abfd8..375bb0747 --- a/gentpl.py +++ b/gentpl.py @@@ -6,8 -6,8 +6,8 @@@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275", "x86_64_efi", - "mips_yeeloong", "sparc64_ieee1275", + "mips_loongson", "sparc64_ieee1275", - "powerpc_ieee1275" ] + "powerpc_ieee1275", "mips_arc" ] GROUPS = {} @@@ -17,7 -17,7 +17,7 @@@ GROUPS["common"] = GRUB_PLATFORMS[: GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ] GROUPS["x86_64"] = [ "x86_64_efi" ] GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"] - GROUPS["mips"] = [ "mips_yeeloong", "mips_arc" ] -GROUPS["mips"] = [ "mips_loongson" ] ++GROUPS["mips"] = [ "mips_loongson", "mips_arc" ] GROUPS["sparc64"] = [ "sparc64_ieee1275" ] GROUPS["powerpc"] = [ "powerpc_ieee1275" ] @@@ -29,8 -29,8 +29,8 @@@ GROUPS["ieee1275"] = [ "i386_ieee1275 GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu") # Groups based on hardware features - GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_yeeloong"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi") - GROUPS["pci"] = GROUPS["x86"] + ["mips_yeeloong"] + GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi") -GROUPS["pci"] = GROUPS["x86"] + GROUPS["mips"] ++GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"] GROUPS["usb"] = GROUPS["pci"] # If gfxterm is main output console integrate it into kernel @@@ -39,7 -39,7 +39,7 @@@ GROUPS["videomodules"] = GRUB_PLATFOR for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i) # Similar for terminfo - GROUPS["terminfoinkernel"] = ["mips_yeeloong", "mips_arc"] + GROUPS["ieee1275"]; -GROUPS["terminfoinkernel"] = ["mips_loongson"] + GROUPS["ieee1275"]; ++GROUPS["terminfoinkernel"] = ["mips_loongson", "mips_arc"] + GROUPS["ieee1275"]; GROUPS["terminfomodule"] = GRUB_PLATFORMS[:]; for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i) diff --cc grub-core/Makefile.am index 234bd3ee8,3b1611db2..9a804507b --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@@ -125,17 -125,9 +125,17 @@@ KERNEL_HEADER_FILES += $(top_srcdir)/in KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h endif +if COND_mips +KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/kernel.h +endif + +if COND_mips_arc +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h +endif + - if COND_mips_yeeloong + if COND_mips_loongson KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h -KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h diff --cc grub-core/Makefile.core.def index e27d375c4,a75c0f738..0d56ff19b --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@@ -32,12 -32,11 +32,12 @@@ kernel = i386_coreboot_ldflags = '-Wl,-Ttext=0x8200'; i386_multiboot_ldflags = '-Wl,-Ttext=0x8200'; i386_ieee1275_ldflags = '-Wl,-Ttext=0x10000'; - mips_yeeloong_ldflags = '-Wl,-Ttext,0x80200000'; + mips_loongson_ldflags = '-Wl,-Ttext,0x80200000'; powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000'; sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400'; + mips_arc_ldflags = '-Wl,-Ttext,0x8a000000'; - mips_yeeloong_cppflags = '-DUSE_ASCII_FAILBACK'; + mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK'; i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; emu_cflags = '$(CFLAGS_GNULIB)'; emu_cppflags = '$(CPPFLAGS_GNULIB)'; @@@ -137,24 -136,20 +137,25 @@@ i386_ieee1275 = kern/ieee1275/init.c; + mips = kern/mips/cache.S; + mips = kern/mips/dl.c; + mips = kern/mips/init.c; + + mips_arc = kern/mips/arc/init.c; + mips_arc = term/arc/console.c; + mips_arc = disk/arc/arcdisk.c; + - mips_yeeloong = term/ns8250.c; - mips_yeeloong = bus/bonito.c; - mips_yeeloong = bus/cs5536.c; - mips_yeeloong = bus/pci.c; - mips_yeeloong = kern/mips/yeeloong/init.c; - mips_yeeloong = term/at_keyboard.c; - mips_yeeloong = term/serial.c; - mips_yeeloong = video/sm712.c; + mips_loongson = term/ns8250.c; + mips_loongson = bus/bonito.c; + mips_loongson = bus/cs5536.c; + mips_loongson = bus/pci.c; - mips_loongson = kern/mips/cache.S; - mips_loongson = kern/mips/dl.c; - mips_loongson = kern/mips/init.c; + mips_loongson = kern/mips/loongson/init.c; + mips_loongson = term/at_keyboard.c; + mips_loongson = term/serial.c; + mips_loongson = video/sm712.c; + mips_loongson = video/sis315pro.c; extra_dist = video/sm712_init.c; - mips_yeeloong = commands/keylayouts.c; + mips_loongson = commands/keylayouts.c; powerpc_ieee1275 = kern/ieee1275/init.c; powerpc_ieee1275 = kern/powerpc/cache.S; diff --cc grub-core/kern/mips/loongson/init.c index 426e7eabb,acc3a17c7..f0f5c5874 --- a/grub-core/kern/mips/loongson/init.c +++ b/grub-core/kern/mips/loongson/init.c @@@ -31,9 -31,9 +31,10 @@@ #include #include #include +#include extern void grub_video_sm712_init (void); + extern void grub_video_sis315pro_init (void); extern void grub_video_init (void); extern void grub_bitmap_init (void); extern void grub_font_init (void); diff --cc grub-core/kern/mips/startup.S index 48bf253de,624ceb6d0..ac7ed3175 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@@ -50,11 -51,11 +51,11 @@@ VARIABLE(grub_prefix */ . = _start + GRUB_KERNEL_MACHINE_PREFIX_END +VARIABLE (grub_arch_cpuclock) + .long 0 - #ifdef GRUB_MACHINE_MIPS_YEELOONG + #ifdef GRUB_MACHINE_MIPS_LOONGSON VARIABLE (grub_arch_busclock) .long 0 -VARIABLE (grub_arch_cpuclock) - .long 0 VARIABLE (grub_arch_memsize) .long 0 VARIABLE (grub_arch_highmemsize) diff --cc grub-core/loader/mips/linux.c index 0b95bd3c2,193ea9681..b0b69eae6 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@@ -31,17 -31,17 +31,16 @@@ GRUB_MOD_LICENSE ("GPLv3+"); /* For frequencies. */ -#include #include - #ifdef GRUB_MACHINE_MIPS_YEELOONG - + #ifdef GRUB_MACHINE_MIPS_LOONGSON -#include +#include - /* 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; @@@ -54,10 -54,7 +53,10 @@@ static struct grub_relocator *relocator static grub_uint8_t *playground; static grub_addr_t target_addr, entry_addr; static int linux_argc; -static grub_off_t argv_off, envp_off; +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; static int initrd_loaded = 0; @@@ -70,12 -67,7 +69,12 @@@ 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; +#endif + state.gpr[7] = 0; state.jumpreg = 1; grub_relocator32_boot (relocator, state); @@@ -210,13 -202,9 +209,13 @@@ grub_cmd_linux (grub_command_t cmd __at int i; int size; void *extra = NULL; - grub_uint32_t *linux_argv, *linux_envp; - char *linux_args, *linux_envs; + 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 if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified"); @@@ -327,7 -321,6 +332,7 @@@ 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); diff --cc include/grub/mips/loongson/kernel.h index 000000000,857b37a15..612221ed2 mode 000000,100644..100644 --- a/include/grub/mips/loongson/kernel.h +++ b/include/grub/mips/loongson/kernel.h @@@ -1,0 -1,36 +1,34 @@@ + /* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + + #ifndef GRUB_KERNEL_MACHINE_HEADER + #define GRUB_KERNEL_MACHINE_HEADER 1 + + #include ++#include + + #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 */ diff --cc include/grub/offsets.h index d71e7deae,0be305c27..d17f4a89c --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@@ -100,28 -100,17 +100,28 @@@ #define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4 #define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000 - #define GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR 0x80200000 + #define GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR 0x80200000 - #define GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN 32 + #define GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN 32 - #define GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE 0x8 - #define GRUB_KERNEL_MIPS_YEELOONG_UNCOMPRESSED_SIZE 0xc + #define GRUB_KERNEL_MIPS_LOONGSON_COMPRESSED_SIZE 0x8 + #define GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_SIZE 0xc - #define GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE 0x08 - #define GRUB_KERNEL_MIPS_YEELOONG_PREFIX 0x0c - #define GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END 0x54 + #define GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE 0x08 + #define GRUB_KERNEL_MIPS_LOONGSON_PREFIX 0x0c + #define GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END 0x54 +#define GRUB_KERNEL_MIPS_ARC_LINK_ADDR 0x8a000000 + +#define GRUB_KERNEL_MIPS_ARC_LINK_ALIGN 32 + +#define GRUB_KERNEL_MIPS_ARC_COMPRESSED_SIZE 0x8 +#define GRUB_KERNEL_MIPS_ARC_UNCOMPRESSED_SIZE 0xc + +#define GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE 0x08 +#define GRUB_KERNEL_MIPS_ARC_PREFIX 0x0c +#define GRUB_KERNEL_MIPS_ARC_PREFIX_END 0x54 + /* The offset of GRUB_PREFIX. */ #define GRUB_KERNEL_I386_EFI_PREFIX 0x8 @@@ -155,8 -144,7 +155,8 @@@ #define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000 - #define GRUB_KERNEL_MIPS_YEELOONG_MOD_ALIGN 0x1 + #define GRUB_KERNEL_MIPS_LOONGSON_MOD_ALIGN 0x1 +#define GRUB_KERNEL_MIPS_ARC_MOD_ALIGN 0x1 /* Minimal gap between _end and the start of the modules. It's a hack for PowerMac to prevent "CLAIM failed" error. The real fix is to diff --cc util/grub-mkimage.c index 259d78beb,b65a3e3d5..fe112c26a --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@@ -64,8 -65,8 +65,8 @@@ struct image_target_des enum { IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT, IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275, - IMAGE_YEELOONG_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, - IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC + IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, - IMAGE_FULOONG_FLASH, IMAGE_I386_PC_PXE ++ IMAGE_FULOONG_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC } id; enum { @@@ -355,27 -392,6 +392,28 @@@ struct image_target_desc image_targets[ .install_bsd_part = TARGET_NO_FIELD, .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR }, + { - .name = "mips-arc", ++ .dirname = "mips-arc", ++ .names = {"mips-arc", NULL}, + .voidp_sizeof = 4, + .bigendian = 1, + .id = IMAGE_MIPS_ARC, + .flags = PLATFORM_FLAGS_DECOMPRESSORS, + .prefix = GRUB_KERNEL_MIPS_ARC_PREFIX, + .prefix_end = GRUB_KERNEL_MIPS_ARC_PREFIX_END, + .raw_size = 0, + .total_module_size = GRUB_KERNEL_MIPS_ARC_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_ARC_LINK_ADDR, + .elf_target = EM_MIPS, + .link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN, + .default_compression = COMPRESSION_NONE + }, }; #define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x))) @@@ -1238,77 -1273,7 +1295,77 @@@ generate_image (const char *dir, char * core_size = rom_size; } break; + case IMAGE_MIPS_ARC: + { + char *ecoff_img; + struct ecoff_header { + grub_uint16_t magic; + grub_uint16_t nsec; + grub_uint32_t time; + grub_uint32_t syms; + grub_uint32_t nsyms; + grub_uint16_t opt; + grub_uint16_t flags; + grub_uint16_t magic2; + grub_uint16_t version; + grub_uint32_t textsize; + grub_uint32_t datasize; + grub_uint32_t bsssize; + grub_uint32_t entry; + grub_uint32_t text_start; + grub_uint32_t data_start; + grub_uint32_t bss_start; + grub_uint32_t gprmask; + grub_uint32_t cprmask[4]; + grub_uint32_t gp_value; + }; + struct ecoff_section + { + char name[8]; + grub_uint32_t paddr; + grub_uint32_t vaddr; + grub_uint32_t size; + grub_uint32_t file_offset; + grub_uint32_t reloc; + grub_uint32_t gp; + grub_uint16_t nreloc; + grub_uint16_t ngp; + grub_uint32_t flags; + }; + struct ecoff_header *head; + struct ecoff_section *section; + grub_uint32_t target_addr; + size_t program_size; + + program_size = ALIGN_ADDR (core_size); + target_addr = image_target->link_addr - ALIGN_UP(program_size, 1048576) + - (1 << 20); + + ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section)); + grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section)); + head = (void *) ecoff_img; + section = (void *) (head + 1); + head->magic = grub_host_to_target16 (0x160); + head->nsec = grub_host_to_target16 (1); + head->time = grub_host_to_target32 (0); + head->opt = grub_host_to_target16 (0x38); + head->flags = grub_host_to_target16 (0x207); + head->magic2 = grub_host_to_target16 (0x107); + head->textsize = grub_host_to_target32 (program_size); + head->entry = grub_host_to_target32 (target_addr); + head->text_start = grub_host_to_target32 (target_addr); + head->data_start = grub_host_to_target32 (target_addr + program_size); + grub_memcpy (section->name, ".text", sizeof (".text") - 1); + section->vaddr = grub_host_to_target32 (target_addr); + section->size = grub_host_to_target32 (program_size); + section->file_offset = grub_host_to_target32 (sizeof (*head) + sizeof (*section)); + memcpy (section + 1, core_img, core_size); + free (core_img); + core_img = ecoff_img; + core_size = program_size + sizeof (*head) + sizeof (*section); + } + break; - case IMAGE_YEELOONG_ELF: + case IMAGE_LOONGSON_ELF: case IMAGE_PPC: case IMAGE_COREBOOT: case IMAGE_I386_IEEE1275: