void *memcpy (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memmove")));
+void *grub_decompressor_scratch;
+
+void
+find_scratch (void *src, void *dst, unsigned long srcsize,
+ unsigned long dstsize)
+{
+#ifdef _mips
+ /* Decoding from ROM. */
+ if (((grub_addr_t) src & 0x10000000))
+ {
+ grub_decompressor_scratch = (char *) dst + dstsize;
+ return;
+ }
+#endif
+ if ((char *) src + srcsize > (char *) dst + dstsize)
+ grub_decompressor_scratch = (char *) src + srcsize;
+ else
+ grub_decompressor_scratch = (char *) dst + dstsize;
+ return;
+}
+
void
grub_decompress_core (void *src, void *dst, unsigned long srcsize,
unsigned long dstsize)
struct xz_dec *dec;
struct xz_buf buf;
+ find_scratch (src, dst, srcsize, dstsize);
+
dec = xz_dec_init (GRUB_DECOMPRESSOR_DICT_SIZE);
buf.in = src;
/* Parse arguments. Has to be done before relocation.
So need to do it in asm. */
-#if 0 // def GRUB_MACHINE_MIPS_YEELOONG
+#ifdef GRUB_MACHINE_MIPS_YEELOONG
move $s2, $zero
move $s3, $zero
move $s4, $zero
bne $t3, $0, bsscont
addiu $t1, $t1, 1
- li $sp, GRUB_MACHINE_MEMORY_STACK_HIGH
lui $t1, %hi(grub_main)
addiu $t1, %lo(grub_main)
+ lui $sp, %hi(GRUB_MACHINE_MEMORY_STACK_HIGH)
jr $t1
- nop
+ addiu $sp, $sp, %lo(GRUB_MACHINE_MEMORY_STACK_HIGH)
#ifdef GRUB_EMBED_DECOMPRESSOR
#include <grub/decompressor.h>
static struct xz_dec_lzma2 lzma2;
-static char dict[GRUB_DECOMPRESSOR_DICT_SIZE];
#endif
struct xz_dec_lzma2 * xz_dec_lzma2_create(uint32_t dict_max)
}
#else
- if (dict_max > GRUB_DECOMPRESSOR_DICT_SIZE)
- return NULL;
-
s = &lzma2;
-
- if (dict_max > 0) {
- s->dict.buf = (void *) &dict;
- }
+ s->dict.buf = grub_decompressor_scratch;
#endif
s->dict.allocated = dict_max;
s->dict.buf = newdict;
s->dict.allocated = s->dict.size;
}
-#else
- if (s->dict.allocated > 0 && s->dict.allocated < s->dict.size)
- return XZ_MEMLIMIT_ERROR;
#endif
s->dict.end = s->dict.size;
grub_decompress_core (void *src, void *dst, unsigned long srcsize,
unsigned long dstsize);
+void
+find_scratch (void *src, void *dst, unsigned long srcsize,
+ unsigned long dstsize);
+
#define GRUB_DECOMPRESSOR_DICT_SIZE (1 << 16)
+extern void *grub_decompressor_scratch;
+
#endif