Merge mainline int sparc-mkimage-unify
This commit is contained in:
commit
0b4ab8e54a
13 changed files with 174 additions and 105 deletions
76
ChangeLog
76
ChangeLog
|
@ -1,3 +1,79 @@
|
|||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Merge grub_ieee1275_map_physical into grub_map and rename to
|
||||
grub_ieee1275_map
|
||||
|
||||
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_map): New proto.
|
||||
* include/grub/sparc64/ieee1275/ieee1275.h (grub_ieee1275_map_physical):
|
||||
Remove.
|
||||
* kern/ieee1275/openfw.c (grub_map): Rename to ...
|
||||
(grub_ieee1275_map): ... this. All users updated. Add phys_lo when
|
||||
necessary.
|
||||
* kern/sparc64/ieee1275/ieee1275.c (grub_ieee1275_map_physical): Remove.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* disk/ieee1275/ofdisk.c (grub_ofdisk_open): Check device type before
|
||||
opening and not after.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* term/ieee1275/ofconsole.c (grub_ofconsole_readkey): Macroify
|
||||
constants.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* loader/sparc64/ieee1275/linux.c (align_addr): Remove.
|
||||
(alloc_phys): Use ALIGN_UP instead of align_addr.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* loader/sparc64/ieee1275/linux.c (alloc_phys): Correct bounds checking.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* kern/sparc64/ieee1275/crt0.S (codestart): Move modules backwards.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* disk/ieee1275/ofdisk.c (grub_ofdisk_read): Remove excessively
|
||||
verbose dprintf.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fix over-4GiB seek on sparc64.
|
||||
|
||||
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_seek):
|
||||
Replace pos_i and pos_lo with pos. All users updated.
|
||||
* include/grub/powerpc/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
|
||||
New constant.
|
||||
* include/grub/sparc64/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
|
||||
Likewise.
|
||||
* kern/ieee1275/ieee1275.c (grub_ieee1275_seek): Split pos into pos_hi
|
||||
and pos_lo.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkrawimage.c (main): Call set_program_name.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Properly align 64-bit targets.
|
||||
|
||||
* util/grub-mkrawimage.c (ALIGN_ADDR): New macro.
|
||||
(generate_image): Use ALIGN_ADDR.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Properly create cross-endian images.
|
||||
|
||||
* include/grub/types.h (grub_host_to_target_addr): New macro
|
||||
* util/grub-mkrawimage.c (generate_image): Add missing host_to_target.
|
||||
|
||||
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkrawimage.c (generate_image): Add forgotten ALIGN_UP.
|
||||
|
||||
2010-02-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Pass SIMPLE framebuffer size in bytes and not 64K blocks.
|
||||
|
|
|
@ -172,16 +172,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
|
||||
grub_dprintf ("disk", "Opening `%s'.\n", op->devpath);
|
||||
|
||||
grub_ieee1275_open (op->devpath, &dev_ihandle);
|
||||
if (! dev_ihandle)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath,
|
||||
(void *) (unsigned long) dev_ihandle);
|
||||
|
||||
if (grub_ieee1275_finddevice (op->devpath, &dev))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read device properties");
|
||||
|
@ -201,6 +191,16 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
grub_ieee1275_open (op->devpath, &dev_ihandle);
|
||||
if (! dev_ihandle)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath,
|
||||
(void *) (unsigned long) dev_ihandle);
|
||||
|
||||
/* XXX: There is no property to read the number of blocks. There
|
||||
should be a property `#blocks', but it is not there. Perhaps it
|
||||
is possible to use seek for this. */
|
||||
|
@ -234,14 +234,10 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
grub_ssize_t status, actual;
|
||||
unsigned long long pos;
|
||||
|
||||
grub_dprintf ("disk",
|
||||
"Reading handle %p: sector 0x%llx, size 0x%lx, buf %p.\n",
|
||||
(void *) disk->data, (long long) sector, (long) size, buf);
|
||||
|
||||
pos = sector * 512UL;
|
||||
|
||||
grub_ieee1275_seek ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
|
||||
(int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status);
|
||||
pos, &status);
|
||||
if (status < 0)
|
||||
return grub_error (GRUB_ERR_READ_ERROR,
|
||||
"seek error, can't seek block %llu",
|
||||
|
|
|
@ -138,7 +138,7 @@ int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle,
|
|||
void *buffer, grub_size_t len,
|
||||
grub_ssize_t *actualp);
|
||||
int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle,
|
||||
int pos_hi, int pos_lo,
|
||||
grub_disk_addr_t pos,
|
||||
grub_ssize_t *result);
|
||||
int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node,
|
||||
grub_ieee1275_phandle_t *result);
|
||||
|
@ -173,6 +173,10 @@ grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
|
|||
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
|
||||
int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
|
||||
|
||||
int
|
||||
EXPORT_FUNC(grub_ieee1275_map) (grub_addr_t phys, grub_addr_t virt,
|
||||
grub_size_t size, grub_uint32_t mode);
|
||||
|
||||
char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);
|
||||
char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_IEEE1275_CELL_SIZEOF 4
|
||||
typedef grub_uint32_t grub_ieee1275_cell_t;
|
||||
|
||||
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_IEEE1275_CELL_SIZEOF 8
|
||||
typedef grub_uint64_t grub_ieee1275_cell_t;
|
||||
|
||||
/* Encoding of 'mode' argument to grub_ieee1275_map_physical() */
|
||||
|
@ -36,10 +37,6 @@ typedef grub_uint64_t grub_ieee1275_cell_t;
|
|||
#define IEEE1275_MAP_DEFAULT (IEEE1275_MAP_WRITE | IEEE1275_MAP_READ | \
|
||||
IEEE1275_MAP_EXEC | IEEE1275_MAP_CACHED)
|
||||
|
||||
extern int EXPORT_FUNC(grub_ieee1275_map_physical) (grub_addr_t paddr,
|
||||
grub_addr_t vaddr,
|
||||
grub_size_t size,
|
||||
grub_uint32_t mode);
|
||||
extern int EXPORT_FUNC(grub_ieee1275_claim_vaddr) (grub_addr_t vaddr,
|
||||
grub_size_t size);
|
||||
extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr,
|
||||
|
|
|
@ -223,4 +223,10 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
|
|||
# endif
|
||||
#endif /* ! WORDS_BIGENDIAN */
|
||||
|
||||
#if GRUB_TARGET_SIZEOF_VOID_P == 8
|
||||
# define grub_host_to_target_addr(x) grub_host_to_target64(x)
|
||||
#else
|
||||
# define grub_host_to_target_addr(x) grub_host_to_target32(x)
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_TYPES_HEADER */
|
||||
|
|
|
@ -284,8 +284,8 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
|
|||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
|
||||
int pos_lo, grub_ssize_t *result)
|
||||
grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos,
|
||||
grub_ssize_t *result)
|
||||
{
|
||||
struct write_args
|
||||
{
|
||||
|
@ -299,8 +299,15 @@ grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
|
|||
|
||||
INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
|
||||
args.ihandle = ihandle;
|
||||
args.pos_hi = (grub_ieee1275_cell_t) pos_hi;
|
||||
args.pos_lo = (grub_ieee1275_cell_t) pos_lo;
|
||||
/* To prevent stupid gcc warning. */
|
||||
#if GRUB_IEEE1275_CELL_SIZEOF >= 8
|
||||
args.pos_hi = 0;
|
||||
args.pos_lo = pos;
|
||||
#else
|
||||
args.pos_hi = (grub_ieee1275_cell_t) (pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF));
|
||||
args.pos_lo = (grub_ieee1275_cell_t)
|
||||
(pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1));
|
||||
#endif
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
|
|
@ -199,9 +199,9 @@ nextprop:
|
|||
}
|
||||
|
||||
/* Call the "map" method of /chosen/mmu. */
|
||||
static int
|
||||
grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size,
|
||||
grub_uint8_t mode)
|
||||
int
|
||||
grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
|
||||
grub_uint32_t mode)
|
||||
{
|
||||
struct map_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
|
@ -210,17 +210,30 @@ grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size,
|
|||
grub_ieee1275_cell_t mode;
|
||||
grub_ieee1275_cell_t size;
|
||||
grub_ieee1275_cell_t virt;
|
||||
grub_ieee1275_cell_t phys;
|
||||
#ifdef GRUB_MACHINE_SPARC64
|
||||
grub_ieee1275_cell_t phys_high;
|
||||
#endif
|
||||
grub_ieee1275_cell_t phys_low;
|
||||
grub_ieee1275_cell_t catch_result;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method",
|
||||
#ifdef GRUB_MACHINE_SPARC64
|
||||
7,
|
||||
#else
|
||||
6,
|
||||
#endif
|
||||
1);
|
||||
args.method = (grub_ieee1275_cell_t) "map";
|
||||
args.ihandle = grub_ieee1275_mmu;
|
||||
args.phys = phys;
|
||||
#ifdef GRUB_MACHINE_SPARC64
|
||||
args.phys_high = 0;
|
||||
#endif
|
||||
args.phys_low = phys;
|
||||
args.virt = virt;
|
||||
args.size = size;
|
||||
args.mode = mode; /* Format is WIMG0PP. */
|
||||
args.catch_result = (grub_ieee1275_cell_t) -1;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
@ -235,7 +248,7 @@ grub_claimmap (grub_addr_t addr, grub_size_t size)
|
|||
return -1;
|
||||
|
||||
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE)
|
||||
&& grub_map (addr, addr, size, 0x00))
|
||||
&& grub_ieee1275_map (addr, addr, size, 0x00))
|
||||
{
|
||||
grub_printf ("map failed: address 0x%llx, size 0x%llx\n",
|
||||
(long long) addr, (long long) size);
|
||||
|
|
|
@ -53,12 +53,16 @@ codestart:
|
|||
or %o3, %lo(_end), %o3
|
||||
sethi %hi(grub_total_module_size), %o4
|
||||
lduw [%o4 + %lo(grub_total_module_size)], %o4
|
||||
add %o2, %o4, %o2
|
||||
add %o3, %o4, %o3
|
||||
sub %o2, 4, %o2
|
||||
sub %o3, 4, %o3
|
||||
1: lduw [%o2], %o5
|
||||
stw %o5, [%o3]
|
||||
subcc %o4, 4, %o4
|
||||
add %o2, 4, %o2
|
||||
sub %o2, 4, %o2
|
||||
bne,pt %icc, 1b
|
||||
add %o3, 4, %o3
|
||||
sub %o3, 4, %o3
|
||||
|
||||
/* Now it's safe to clear out the BSS. */
|
||||
sethi %hi(__bss_start), %o2
|
||||
|
|
|
@ -21,39 +21,6 @@
|
|||
|
||||
/* Sun specific ieee1275 interfaces used by GRUB. */
|
||||
|
||||
int
|
||||
grub_ieee1275_map_physical (grub_addr_t paddr, grub_addr_t vaddr,
|
||||
grub_size_t size, grub_uint32_t mode)
|
||||
{
|
||||
struct map_physical_args
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_cell_t method;
|
||||
grub_ieee1275_cell_t ihandle;
|
||||
grub_ieee1275_cell_t mode;
|
||||
grub_ieee1275_cell_t size;
|
||||
grub_ieee1275_cell_t virt;
|
||||
grub_ieee1275_cell_t phys_high;
|
||||
grub_ieee1275_cell_t phys_low;
|
||||
grub_ieee1275_cell_t catch_result;
|
||||
}
|
||||
args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 7, 1);
|
||||
args.method = (grub_ieee1275_cell_t) "map";
|
||||
args.ihandle = grub_ieee1275_mmu;
|
||||
args.mode = mode;
|
||||
args.size = size;
|
||||
args.virt = vaddr;
|
||||
args.phys_high = 0;
|
||||
args.phys_low = paddr;
|
||||
args.catch_result = (grub_ieee1275_cell_t) -1;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
return args.catch_result;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_claim_vaddr (grub_addr_t vaddr, grub_size_t size)
|
||||
{
|
||||
|
|
|
@ -173,12 +173,6 @@ grub_linux_unload (void)
|
|||
|
||||
#define FOUR_MB (4 * 1024 * 1024)
|
||||
|
||||
static grub_addr_t
|
||||
align_addr(grub_addr_t val, grub_addr_t align)
|
||||
{
|
||||
return (val + (align - 1)) & ~(align - 1);
|
||||
}
|
||||
|
||||
static grub_addr_t
|
||||
alloc_phys (grub_addr_t size)
|
||||
{
|
||||
|
@ -192,39 +186,39 @@ alloc_phys (grub_addr_t size)
|
|||
if (type != 1)
|
||||
return 0;
|
||||
|
||||
addr = align_addr (addr, FOUR_MB);
|
||||
if (addr >= end)
|
||||
addr = ALIGN_UP (addr, FOUR_MB);
|
||||
if (addr + size >= end)
|
||||
return 0;
|
||||
|
||||
if (addr >= grub_phys_start && addr < grub_phys_end)
|
||||
{
|
||||
addr = align_addr (grub_phys_end, FOUR_MB);
|
||||
if (addr >= end)
|
||||
addr = ALIGN_UP (grub_phys_end, FOUR_MB);
|
||||
if (addr + size >= end)
|
||||
return 0;
|
||||
}
|
||||
if ((addr + size) >= grub_phys_start
|
||||
&& (addr + size) < grub_phys_end)
|
||||
{
|
||||
addr = align_addr (grub_phys_end, FOUR_MB);
|
||||
if (addr >= end)
|
||||
addr = ALIGN_UP (grub_phys_end, FOUR_MB);
|
||||
if (addr + size >= end)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (loaded)
|
||||
{
|
||||
grub_addr_t linux_end = align_addr (linux_paddr + linux_size, FOUR_MB);
|
||||
grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB);
|
||||
|
||||
if (addr >= linux_paddr && addr < linux_end)
|
||||
{
|
||||
addr = linux_end;
|
||||
if (addr >= end)
|
||||
if (addr + size >= end)
|
||||
return 0;
|
||||
}
|
||||
if ((addr + size) >= linux_paddr
|
||||
&& (addr + size) < linux_end)
|
||||
{
|
||||
addr = linux_end;
|
||||
if (addr >= end)
|
||||
if (addr + size >= end)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -258,8 +252,8 @@ grub_linux_load64 (grub_elf_t elf)
|
|||
if (paddr == (grub_addr_t) -1)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't allocate physical memory");
|
||||
ret = grub_ieee1275_map_physical (paddr, linux_addr - off,
|
||||
linux_size + off, IEEE1275_MAP_DEFAULT);
|
||||
ret = grub_ieee1275_map (paddr, linux_addr - off,
|
||||
linux_size + off, IEEE1275_MAP_DEFAULT);
|
||||
if (ret)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't map physical memory");
|
||||
|
@ -409,7 +403,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
"couldn't allocate physical memory");
|
||||
goto fail;
|
||||
}
|
||||
ret = grub_ieee1275_map_physical (paddr, addr, size, IEEE1275_MAP_DEFAULT);
|
||||
ret = grub_ieee1275_map (paddr, addr, size, IEEE1275_MAP_DEFAULT);
|
||||
if (ret)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
|
|
|
@ -165,7 +165,7 @@ grub_ofconsole_readkey (int *key)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (c != 91)
|
||||
if (c != '[')
|
||||
return 0;
|
||||
|
||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
|
@ -174,21 +174,21 @@ grub_ofconsole_readkey (int *key)
|
|||
|
||||
switch (c)
|
||||
{
|
||||
case 65:
|
||||
case 'A':
|
||||
/* Up: Ctrl-p. */
|
||||
c = 16;
|
||||
c = GRUB_TERM_UP;
|
||||
break;
|
||||
case 66:
|
||||
case 'B':
|
||||
/* Down: Ctrl-n. */
|
||||
c = 14;
|
||||
c = GRUB_TERM_DOWN;
|
||||
break;
|
||||
case 67:
|
||||
case 'C':
|
||||
/* Right: Ctrl-f. */
|
||||
c = 6;
|
||||
c = GRUB_TERM_RIGHT;
|
||||
break;
|
||||
case 68:
|
||||
case 'D':
|
||||
/* Left: Ctrl-b. */
|
||||
c = 2;
|
||||
c = GRUB_TERM_LEFT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include "progname.h"
|
||||
|
||||
#define ALIGN_ADDR(x) (ALIGN_UP((x), GRUB_TARGET_SIZEOF_VOID_P))
|
||||
|
||||
#ifdef ENABLE_LZMA
|
||||
#include <grub/lib/LzmaEnc.h>
|
||||
|
||||
|
@ -130,20 +132,20 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
if (font_path)
|
||||
{
|
||||
font_size = ALIGN_UP(grub_util_get_image_size (font_path), 4);
|
||||
font_size = ALIGN_ADDR (grub_util_get_image_size (font_path));
|
||||
total_module_size += font_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
if (config_path)
|
||||
{
|
||||
config_size_pure = grub_util_get_image_size (config_path) + 1;
|
||||
config_size = ALIGN_UP(config_size_pure, 4);
|
||||
config_size = ALIGN_ADDR (config_size_pure);
|
||||
grub_util_info ("the size of config file is 0x%x", config_size);
|
||||
total_module_size += config_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
for (p = path_list; p; p = p->next)
|
||||
total_module_size += (ALIGN_UP (grub_util_get_image_size (p->name), 4)
|
||||
total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
|
||||
+ sizeof (struct grub_module_header));
|
||||
|
||||
grub_util_info ("the total module size is 0x%x", total_module_size);
|
||||
|
@ -158,9 +160,9 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
/* Fill in the grub_module_info structure. */
|
||||
modinfo = (struct grub_module_info *) (kernel_img + kernel_size);
|
||||
memset (modinfo, 0, sizeof (struct grub_module_info));
|
||||
modinfo->magic = GRUB_MODULE_MAGIC;
|
||||
modinfo->offset = sizeof (struct grub_module_info);
|
||||
modinfo->size = total_module_size;
|
||||
modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
|
||||
modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info));
|
||||
modinfo->size = grub_host_to_target_addr (total_module_size);
|
||||
|
||||
offset = kernel_size + sizeof (struct grub_module_info);
|
||||
for (p = path_list; p; p = p->next)
|
||||
|
@ -169,11 +171,11 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
size_t mod_size, orig_size;
|
||||
|
||||
orig_size = grub_util_get_image_size (p->name);
|
||||
mod_size = ALIGN_UP(orig_size, 4);
|
||||
mod_size = ALIGN_ADDR (orig_size);
|
||||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_ELF;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_ELF);
|
||||
header->size = grub_host_to_target32 (mod_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
memset (kernel_img + offset + orig_size, 0, mod_size - orig_size);
|
||||
|
@ -188,7 +190,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_MEMDISK;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_MEMDISK);
|
||||
header->size = grub_host_to_target32 (memdisk_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
|
@ -202,7 +204,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_FONT;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_FONT);
|
||||
header->size = grub_host_to_target32 (font_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
|
@ -216,7 +218,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = OBJ_TYPE_CONFIG;
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_CONFIG);
|
||||
header->size = grub_host_to_target32 (config_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
|
@ -382,7 +384,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
Elf32_Phdr *phdr;
|
||||
grub_uint32_t target_addr;
|
||||
|
||||
program_size = ALIGN_UP (core_size, 4);
|
||||
program_size = ALIGN_ADDR (core_size);
|
||||
|
||||
elf_img = xmalloc (program_size + sizeof (*ehdr) + sizeof (*phdr));
|
||||
memset (elf_img, 0, program_size + sizeof (*ehdr) + sizeof (*phdr));
|
||||
|
@ -517,6 +519,8 @@ main (int argc, char *argv[])
|
|||
grub_platform_image_format_t format = GRUB_PLATFORM_IMAGE_DEFAULT;
|
||||
#endif
|
||||
|
||||
set_program_name (argv[0]);
|
||||
|
||||
grub_util_init_nls ();
|
||||
|
||||
while (1)
|
||||
|
|
Loading…
Reference in a new issue