@@ -113,28 +113,30 @@ void* k_memset (void* const s, U8 c, size_t n)
113113 * @Input n Number of bytes to copy.
114114 * @return Pointer to the start of the destination.
115115***************************************************************************************************/
116- void k_memcpyToPhyMem (Physical dest , PTR src , SIZE n )
116+ void k_memcpyToPhyMem (Physical dest , PTR src , UINT destOffset , UINT srcOffset , SIZE n )
117117{
118118 FUNC_ENTRY ("Dest: %px, Src: %px, Len: %x bytes" , dest .val , (PTR )src , n );
119119
120120 KERNEL_PHASE_VALIDATE (KERNEL_PHASE_STATE_VMM_READY );
121121
122122 Physical l_dest = dest ;
123- PTR l_src = src ;
123+ PTR l_src = src + srcOffset ;
124124 SIZE remBytes = n ;
125125
126126 // Copy whole pages worth of bytes
127127 while (remBytes >= CONFIG_PAGE_FRAME_SIZE_BYTES ) {
128- k_memcpy (kpg_temporaryMap (l_dest ), (void * )l_src , CONFIG_PAGE_FRAME_SIZE_BYTES );
128+ PTR dest_va = (PTR )kpg_temporaryMap (l_dest ) + destOffset ;
129+ destOffset = 0 ; // No offset from the 2nd iteration.
130+ k_memcpy ((void * )dest_va , (void * )l_src , CONFIG_PAGE_FRAME_SIZE_BYTES );
129131 kpg_temporaryUnmap ();
130132 remBytes -= CONFIG_PAGE_FRAME_SIZE_BYTES ;
131133 l_dest .val += CONFIG_PAGE_FRAME_SIZE_BYTES ;
132134 l_src += CONFIG_PAGE_FRAME_SIZE_BYTES ;
133135 }
134136
135137 // Copy remaining bytes
136- void * bin_va = kpg_temporaryMap (l_dest );
137- k_memcpy (bin_va , (void * )l_src , remBytes );
138+ PTR dest_va = ( PTR ) kpg_temporaryMap (l_dest ) + destOffset ;
139+ k_memcpy (( void * ) dest_va , (void * )l_src , remBytes );
138140 kpg_temporaryUnmap ();
139141}
140142
0 commit comments