phys_memset improvements

. verify length argument
	. use rep stosl / stosb
This commit is contained in:
Arne Welzel 2012-09-21 14:15:44 +02:00 committed by Ben Gras
parent 8a3b6ca3bb
commit 629829e69c

View file

@ -316,49 +316,35 @@ ENTRY(__user_copy_msg_pointer_failure)
/* phys_memset */ /* phys_memset */
/*===========================================================================*/ /*===========================================================================*/
/* /*
* PUBLIC void phys_memset(phys_bytes source, unsigned long pattern, * PUBLIC void phys_memset(phys_bytes dst, unsigned long pattern,
* phys_bytes bytecount); * phys_bytes bytecount);
* Fill a block of physical memory with pattern. * Fill a block of physical memory with pattern.
*/ */
ENTRY(phys_memset) ENTRY(phys_memset)
push %ebp push %ebp
mov %esp, %ebp mov %esp, %ebp
push %esi push %edi
push %ebx cld
mov 8(%ebp), %edi
mov 16(%ebp), %ecx
mov 12(%ebp), %eax
shr $2, %ecx
rep stosl
mov 8(%ebp), %esi
mov 16(%ebp), %eax
mov 12(%ebp), %ebx
shr $2, %eax
fill_start:
mov %ebx, (%esi)
add $4, %esi
dec %eax
jne fill_start
/* Any remaining bytes? */ /* Any remaining bytes? */
mov 16(%ebp), %eax mov 16(%ebp), %ecx
and $3, %eax and $3, %ecx
remain_fill: rep stosb
cmp $0, %eax
je fill_done
movb 12(%ebp), %bl
movb %bl, (%esi)
add $1, %esi
inc %ebp
dec %eax
jmp remain_fill
fill_done:
LABEL(memset_fault) /* kernel can send us here */ LABEL(memset_fault) /* kernel can send us here */
mov $0, %eax /* 0 means: no fault */ mov $0, %eax /* 0 means: no fault */
pop %ebx pop %edi
pop %esi
pop %ebp pop %ebp
ret ret
LABEL(memset_fault_in_kernel) /* kernel can send us here */ LABEL(memset_fault_in_kernel) /* kernel can send us here */
pop %ebx pop %edi
pop %esi
pop %ebp pop %ebp
mov %cr2, %eax mov %cr2, %eax
ret ret