Commit 7bca0e19 authored by Mike Hibler's avatar Mike Hibler
Browse files

Merge branch 'grub2-source'

parents 221cdcf4 248bc1d0
Pipeline #1165 skipped
......@@ -116,6 +116,7 @@ if test "x$with_platform" = x; then
x86_64-*) platform=pc ;;
powerpc-*) platform=ieee1275 ;;
powerpc64-*) platform=ieee1275 ;;
powerpc64le-*) platform=ieee1275 ;;
sparc64-*) platform=ieee1275 ;;
mipsel-*) platform=loongson ;;
mips-*) platform=arc ;;
......@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in
x86_64-none) ;;
x86_64-*) target_cpu=i386 ;;
powerpc64-ieee1275) target_cpu=powerpc ;;
powerpc64le-ieee1275) target_cpu=powerpc ;;
esac
# Check if the platform is supported, make final adjustments.
......@@ -560,6 +562,41 @@ AC_COMPILE_IFELSE(
]])],
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
if test x$target_cpu = xpowerpc; then
AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
grub_cv_target_cc_big_endian=no
for cand in "-target powerpc -Wl,-EB" "-target powerpc" \
"-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \
"-mbig-endian"; do
if test x"$grub_cv_target_cc_big_endian" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
#error still little endian
#endif
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_target_cc_big_endian="$cand"], [])
done
])
if test x"$grub_cv_target_cc_big_endian" = xno ; then
AC_MSG_ERROR([could not force big-endian])
fi
skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
fi
AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
test_program=
case "x$target_cpu-$platform" in
......
......@@ -344,7 +344,7 @@ printhex:
nop
srl $t1, $a0, 28
addiu $t1, $t1, -10
blt $t1, $zero, 2f
bltz $t1, 2f
sll $a0, $a0, 4
addiu $t1, $t1, 'A'-10-'0'
2: addiu $t1, $t1, '0'+10
......@@ -398,7 +398,7 @@ read_spd:
move $t2, $a0
move $t3, $ra
lui $a0, %hi(read_spd_fail)
addiu $a0, $a0, %hi(read_spd_fail)
addiu $a0, $a0, %lo(read_spd_fail)
/* Send START. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
......@@ -547,7 +547,7 @@ gpio_dump:
#endif
gpio_dump_end:
.p2align
.p2align 3
write_dumpreg:
ld $t2, 0($t6)
......
......@@ -21,7 +21,6 @@
#include <grub/offsets.h>
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/cpu/kernel.h>
#include <grub/offsets.h>
#define BASE_ADDR 8
......@@ -33,7 +32,6 @@
.globl __start, _start, start
.set noreorder
.set nomacro
mips_attributes
__start:
_start:
start:
......
......@@ -1007,7 +1007,7 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
struct grub_diskfilter_vg *
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
char *name, grub_uint64_t disk_size,
const char *name, grub_uint64_t disk_size,
grub_uint64_t stripe_size,
int layout, int level)
{
......
......@@ -172,7 +172,7 @@ grub_dmraid_nv_detect (grub_disk_t disk,
return grub_diskfilter_make_raid (sizeof (sb.array.signature),
uuid, sb.array.total_volumes,
NULL, disk_size,
"nv", disk_size,
sb.array.stripe_block_size,
GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC,
level);
......
......@@ -538,8 +538,9 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
shift = 2;
goto indirect;
}
return grub_error (GRUB_ERR_BAD_FS,
"ext2fs doesn't support quadruple indirect blocks");
grub_error (GRUB_ERR_BAD_FS,
"ext2fs doesn't support quadruple indirect blocks");
return -1;
indirect:
do {
......@@ -554,7 +555,7 @@ indirect:
& ((1 << log_perblock) - 1))
* sizeof (indir),
sizeof (indir), &indir))
return grub_errno;
return -1;
} while (shift--);
return grub_le_to_cpu32 (indir);
......
......@@ -136,7 +136,13 @@ struct grub_xfs_dir2_entry
grub_uint8_t len;
} GRUB_PACKED;
typedef grub_uint32_t grub_xfs_extent[4];
struct grub_xfs_extent
{
/* This should be a bitfield but bietfields are unportable, so just have
a raw array and functions extracting useful info from it.
*/
grub_uint32_t raw[4];
} GRUB_PACKED;
struct grub_xfs_btree_node
{
......@@ -147,20 +153,20 @@ struct grub_xfs_btree_node
grub_uint64_t right;
/* In V5 here follow crc, uuid, etc. */
/* Then follow keys and block pointers */
} GRUB_PACKED;
} GRUB_PACKED;
struct grub_xfs_btree_root
{
grub_uint16_t level;
grub_uint16_t numrecs;
grub_uint64_t keys[1];
} GRUB_PACKED;
} GRUB_PACKED;
struct grub_xfs_time
{
grub_uint32_t sec;
grub_uint32_t nanosec;
} GRUB_PACKED;
} GRUB_PACKED;
struct grub_xfs_inode
{
......@@ -313,25 +319,25 @@ GRUB_XFS_FSB_TO_BLOCK (struct grub_xfs_data *data, grub_disk_addr_t fsb)
}
static inline grub_uint64_t
GRUB_XFS_EXTENT_OFFSET (grub_xfs_extent *exts, int ex)
GRUB_XFS_EXTENT_OFFSET (struct grub_xfs_extent *exts, int ex)
{
return ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23
| grub_be_to_cpu32 (exts[ex][1]) >> 9);
return ((grub_be_to_cpu32 (exts[ex].raw[0]) & ~(1 << 31)) << 23
| grub_be_to_cpu32 (exts[ex].raw[1]) >> 9);
}
static inline grub_uint64_t
GRUB_XFS_EXTENT_BLOCK (grub_xfs_extent *exts, int ex)
GRUB_XFS_EXTENT_BLOCK (struct grub_xfs_extent *exts, int ex)
{
return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex][1])
return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex].raw[1])
& (0x1ff)) << 43
| (grub_uint64_t) grub_be_to_cpu32 (exts[ex][2]) << 11
| grub_be_to_cpu32 (exts[ex][3]) >> 21);
| (grub_uint64_t) grub_be_to_cpu32 (exts[ex].raw[2]) << 11
| grub_be_to_cpu32 (exts[ex].raw[3]) >> 21);
}
static inline grub_uint64_t
GRUB_XFS_EXTENT_SIZE (grub_xfs_extent *exts, int ex)
GRUB_XFS_EXTENT_SIZE (struct grub_xfs_extent *exts, int ex)
{
return (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 21) - 1));
return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1));
}
......@@ -377,7 +383,10 @@ grub_xfs_fshelp_size(struct grub_xfs_data *data)
+ grub_xfs_inode_size(data);
}
static void *
/* This should return void * but XFS code is error-prone with alignment, so
return char to retain cast-align.
*/
static char *
grub_xfs_inode_data(struct grub_xfs_inode *inode)
{
if (inode->version <= 2)
......@@ -388,20 +397,20 @@ grub_xfs_inode_data(struct grub_xfs_inode *inode)
static struct grub_xfs_dir_entry *
grub_xfs_inline_de(struct grub_xfs_dir_header *head)
{
/*
* With small inode numbers the header is 4 bytes smaller because of
* smaller parent pointer
*/
return (void *)(((char *)head) + sizeof(struct grub_xfs_dir_header) -
(head->largeino ? 0 : sizeof(grub_uint32_t)));
/*
With small inode numbers the header is 4 bytes smaller because of
smaller parent pointer
*/
return (struct grub_xfs_dir_entry *)
(((char *) head) + sizeof(struct grub_xfs_dir_header) -
(head->largeino ? 0 : sizeof(grub_uint32_t)));
}
static grub_uint8_t *
grub_xfs_inline_de_inopos(struct grub_xfs_data *data,
struct grub_xfs_dir_entry *de)
{
return ((grub_uint8_t *)(de + 1)) + de->len - 1 +
(data->hasftype ? 1 : 0);
return ((grub_uint8_t *)(de + 1)) + de->len - 1 + (data->hasftype ? 1 : 0);
}
static struct grub_xfs_dir_entry *
......@@ -445,14 +454,17 @@ grub_xfs_next_de(struct grub_xfs_data *data, struct grub_xfs_dir2_entry *de)
return (struct grub_xfs_dir2_entry *)(((char *)de) + ALIGN_UP(size, 8));
}
static grub_uint64_t *
/* This should return void * but XFS code is error-prone with alignment, so
return char to retain cast-align.
*/
static char *
grub_xfs_btree_keys(struct grub_xfs_data *data,
struct grub_xfs_btree_node *leaf)
{
grub_uint64_t *keys = (grub_uint64_t *)(leaf + 1);
char *keys = (char *)(leaf + 1);
if (data->hascrc)
keys += 6; /* skip crc, uuid, ... */
keys += 48; /* skip crc, uuid, ... */
return keys;
}
......@@ -476,28 +488,34 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
return 0;
}
static grub_uint64_t
get_fsb (const void *keys, int idx)
{
const char *p = (const char *) keys + sizeof(grub_uint64_t) * idx;
return grub_be_to_cpu64 (grub_get_unaligned64 (p));
}
static grub_disk_addr_t
grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{
struct grub_xfs_btree_node *leaf = 0;
int ex, nrec;
grub_xfs_extent *exts;
struct grub_xfs_extent *exts;
grub_uint64_t ret = 0;
if (node->inode.format == XFS_INODE_FORMAT_BTREE)
{
struct grub_xfs_btree_root *root;
const grub_uint64_t *keys;
const char *keys;
int recoffset;
leaf = grub_malloc (node->data->bsize);
if (leaf == 0)
return 0;
root = grub_xfs_inode_data(&node->inode);
root = (struct grub_xfs_btree_root *) grub_xfs_inode_data(&node->inode);
nrec = grub_be_to_cpu16 (root->numrecs);
keys = &root->keys[0];
keys = (char *) &root->keys[0];
if (node->inode.fork_offset)
recoffset = (node->inode.fork_offset - 1) / 2;
else
......@@ -510,7 +528,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
for (i = 0; i < nrec; i++)
{
if (fileblock < grub_be_to_cpu64 (keys[i]))
if (fileblock < get_fsb(keys, i))
break;
}
......@@ -520,8 +538,9 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
grub_free (leaf);
return 0;
}
if (grub_disk_read (node->data->disk,
GRUB_XFS_FSB_TO_BLOCK (node->data, grub_be_to_cpu64 (keys[i - 1 + recoffset])) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
0, node->data->bsize, leaf))
return 0;
......@@ -542,12 +561,12 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
/ (2 * sizeof (grub_uint64_t)));
}
while (leaf->level);
exts = (grub_xfs_extent *) keys;
exts = (struct grub_xfs_extent *) keys;
}
else if (node->inode.format == XFS_INODE_FORMAT_EXT)
{
nrec = grub_be_to_cpu32 (node->inode.nextents);
exts = grub_xfs_inode_data(&node->inode);
exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode);
}
else
{
......@@ -700,7 +719,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
{
case XFS_INODE_FORMAT_INO:
{
struct grub_xfs_dir_header *head = grub_xfs_inode_data(&diro->inode);
struct grub_xfs_dir_header *head = (struct grub_xfs_dir_header *) grub_xfs_inode_data(&diro->inode);
struct grub_xfs_dir_entry *de = grub_xfs_inline_de(head);
int smallino = !head->largeino;
int i;
......
......@@ -381,9 +381,24 @@ __aeabi_idiv (grub_int32_t a, grub_int32_t b)
__attribute__ ((alias ("__divsi3")));
void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memcpy")));
void *__aeabi_memcpy4 (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memcpy")));
void *__aeabi_memcpy8 (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memcpy")));
void *__aeabi_memset (void *s, int c, grub_size_t n)
__attribute__ ((alias ("memset")));
void
__aeabi_memclr (void *s, grub_size_t n)
{
grub_memset (s, 0, n);
}
void __aeabi_memclr4 (void *s, grub_size_t n)
__attribute__ ((alias ("__aeabi_memclr")));
void __aeabi_memclr8 (void *s, grub_size_t n)
__attribute__ ((alias ("__aeabi_memclr")));
int
__aeabi_ulcmp (grub_uint64_t a, grub_uint64_t b)
{
......
#include <grub/symbol.h>
#include <grub/cpu/kernel.h>
.set noreorder
.set nomacro
mips_attributes
FUNCTION (grub_arch_sync_caches)
#include "cache_flush.S"
......
......@@ -21,7 +21,6 @@
#include <grub/offsets.h>
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/cpu/kernel.h>
#include <grub/offsets.h>
#define BASE_ADDR 8
......@@ -29,7 +28,6 @@
.globl __start, _start, start
.set noreorder
.set nomacro
mips_attributes
__start:
_start:
start:
......
......@@ -17,13 +17,11 @@
*/
#include <grub/symbol.h>
#include <grub/cpu/kernel.h>
.p2align 4 /* force 16-byte alignment */
.set noreorder
.set nomacro
mips_attributes
VARIABLE (grub_relocator_forward_start)
move $a0, $9
......
......@@ -213,6 +213,7 @@ grub_initrd_init (int argc, char *argv[],
if (newc)
{
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4);
free_dir (root);
......@@ -290,7 +291,11 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
ptr += cursize;
}
if (newc)
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
{
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
}
free_dir (root);
root = 0;
return GRUB_ERR_NONE;
......
......@@ -88,7 +88,14 @@ EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b);
void *
EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n);
void *
EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n);
void *
EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n);
void *
EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n);
void EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n);
void EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n);
void EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n);
grub_uint64_t
EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b);
......
......@@ -172,7 +172,7 @@ grub_diskfilter_unregister (grub_diskfilter_t diskfilter)
struct grub_diskfilter_vg *
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
char *name, grub_uint64_t disk_size,
const char *name, grub_uint64_t disk_size,
grub_uint64_t stripe_size,
int layout, int level);
......
......@@ -21,8 +21,4 @@
#include <grub/symbol.h>
#ifdef ASM_FILE
#define mips_attributes .gnu_attribute 4, 3
#endif
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment