#include <grub/types.h>
#include <grub/types.h>
#include <grub/err.h>
+#include <grub/cache.h>
#include <grub/mips/relocator.h>
for (i = 1; i < 32; i++)
write_reg (i, state.gpr[i], &ptr);
write_jump (state.jumpreg, &ptr);
+ grub_arch_sync_caches (ptr0, ptr - ptr0);
+ grub_dprintf ("relocator", "Backward relocator: about to jump to %p\n", ptr0);
((void (*) (void)) ptr0) ();
}
for (i = 1; i < 32; i++)
write_reg (i, state.gpr[i], &ptr);
write_jump (state.jumpreg, &ptr);
+ grub_arch_sync_caches (ptr0, ptr - ptr0);
+ grub_dprintf ("relocator", "Forward relocator: about to jump to %p\n", ptr0);
((void (*) (void)) ptr0) ();
}
*/
#include <grub/symbol.h>
-
-#ifdef BACKWARD
-#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_backward_ ## x)
-#else
-#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_forward_ ## x)
-#endif
.p2align 4 /* force 16-byte alignment */
VARIABLE (grub_relocator32_forward_start)
+ move $12, $9
+ move $13, $10
+
copycont1:
lb $11,0($8)
sb $11,0($9)
- cache 1, 0($9)
- cache 0, 0($9)
addiu $8, $8, 0x1
addiu $9, $9, 0x1
addiu $10, $10, 0xffff
subu $11,$10,$0
bne $11, $0, copycont1
+
+cachecont1:
+ cache 1,0($12)
+ cache 0,0($12)
+ addiu $12, $12, 0x1
+ addiu $13, $13, 0xffff
+ subu $11,$13,$0
+ bne $11, $0, cachecont1
VARIABLE (grub_relocator32_forward_end)
VARIABLE (grub_relocator32_backward_start)
+ move $12, $9
+ move $13, $10
+
addu $9, $9, $10
addu $8, $8, $10
/* Backward movsl is implicitly off-by-one. compensate that. */
addiu $10, 0xffff
subu $11,$10,$0
bne $11, $0, copycont2
+cachecont2:
+ cache 1,0($12)
+ cache 0,0($12)
+ addiu $12, $12, 0x1
+ addiu $13, $13, 0xffff
+ subu $11,$13,$0
+ bne $11, $0, cachecont2
VARIABLE (grub_relocator32_backward_end)
playground = (char *) relocator - RELOCATOR_SIZEOF (forward);
size = *(grub_size_t *) playground;
+ grub_dprintf ("relocator",
+ "Relocator: source: %p, destination: 0x%x, size: 0x%x\n",
+ relocator, dest, size);
+
if (UINT_TO_PTR (dest) >= relocator)
{
int overhead;
overhead =
ALIGN_UP (dest - RELOCATOR_SIZEOF (backward) - RELOCATOR_ALIGN,
RELOCATOR_ALIGN);
+ grub_dprintf ("relocator",
+ "Backward relocator: code %p, source: %p, "
+ "destination: 0x%x, size: 0x%x\n",
+ (char *) relocator - overhead,
+ (char *) relocator - overhead,
+ dest - overhead, size + overhead);
+
write_call_relocator_bw ((char *) relocator - overhead,
(char *) relocator - overhead,
dest - overhead, size + overhead, state);
overhead = ALIGN_UP (dest + size, RELOCATOR_ALIGN)
+ RELOCATOR_SIZEOF (forward) - (dest + size);
+ grub_dprintf ("relocator",
+ "Forward relocator: code %p, source: %p, "
+ "destination: 0x%x, size: 0x%x\n",
+ (char *) relocator + size + overhead
+ - RELOCATOR_SIZEOF (forward),
+ relocator, dest, size + overhead);
write_call_relocator_fw ((char *) relocator + size + overhead
- RELOCATOR_SIZEOF (forward),