I am trying to copy a structure romfile_s from one location to another by memcpy (before the booting stage), but struggling with a weird problem. My memcpy arguments - memcpy(void *d1, const void *s1, size_t len) :
d1 (destination) = 0x000f4d34 s1 (source) = 0x07f3f610 len (size) = 0x0000008c
Expected results: all 0x8c bytes are copied Actual results: only the first 0x04 copied
Confirmed by dprintf printing the contents after memcpy:
source[0x0] = 0x07f3f6e0 || destination[0x0] = 0x07f3f6e0 source[0x4] = 0xff03a9c0 || destination[0x4] = 0x00000000 source[0x8] = 0x00000000 || destination[0x8] = 0x00000000 source[0xc] = 0x6c796170 || destination[0xc] = 0xa4908b65 source[0x10] = 0xff02f388 || destination[0x10] = 0x20525450 ... source[0x88] = 0x0ff81184 || destination[0x88] = 0xa4908b65
This code is being executed inside memcpy: (common case route)
SET_SEG(ES, GET_SEG(SS)); void *d = d1; // Common case - use 4-byte copy len /= 4; asm volatile( "rep movsl (%%esi),%%es:(%%edi)" : "+c"(len), "+S"(s1), "+D"(d) : "m" (__segment_ES) : "cc", "memory"); return d1;
Is there a hidden bug, or I should be using another memcpy_ function to copy from 0x07f3f610 to 0x000f4d34 , like memcpy_far ? ( however, if indeed the wrong function, why is it working for the first 0x04 bytes while shouldn't be working at all ? )
P.S. also I've tried copying it manually instead of memcpy() - by 4 bytes using for() cycle with (0x8c/4) = 23 iterations. It works but SeaBIOS quickly freezes after that, which probably means it is incorrect substitution for some reason
Best regards, Mike Banon