1#------------------------------------------------------------------------------
2#
3# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4# This program and the accompanying materials
5# are licensed and made available under the terms and conditions of the BSD License
6# which accompanies this distribution.  The full text of the license may be found at
7# http://opensource.org/licenses/bsd-license.php.
8#
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11#
12# Module Name:
13#
14#   SetMem32.asm
15#
16# Abstract:
17#
18#   SetMem32 function
19#
20# Notes:
21#
22#------------------------------------------------------------------------------
23
24ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
25
26#------------------------------------------------------------------------------
27#  VOID *
28#  EFIAPI
29#  InternalMemSetMem32 (
30#    IN VOID   *Buffer,
31#    IN UINTN  Count,
32#    IN UINT32 Value
33#    );
34#------------------------------------------------------------------------------
35ASM_PFX(InternalMemSetMem32):
36    push    %edi
37    movl    12(%esp), %edx
38    movl    8(%esp), %edi
39    xorl    %ecx, %ecx
40    subl    %edi, %ecx
41    andl    $15, %ecx                   # ecx + edi aligns on 16-byte boundary
42    movl    16(%esp), %eax
43    jz      L0
44    shrl    $2, %ecx
45    cmpl    %edx, %ecx
46    cmova   %edx, %ecx
47    subl    %ecx, %edx
48    rep
49    stosl
50L0:
51    movl    %edx, %ecx
52    andl    $3, %edx
53    shrl    $2, %ecx
54    jz      L_SetDwords
55    movd    %eax, %xmm0
56    pshufd  $0, %xmm0, %xmm0
57L1:
58    movntdq %xmm0, (%edi)
59    addl    $16, %edi
60    loop    L1
61    mfence
62L_SetDwords:
63    movl    %edx, %ecx
64    rep
65    stosl
66    movl    8(%esp), %eax
67    pop     %edi
68    ret
69