kernel: Use NULL for DRIVER_MODULE()'s evh & arg (which are pointers).
[dragonfly.git] / sys / platform / pc32 / i386 / bzero.s
1 /*
2  * Copyright (c) 2003,2004 The DragonFly Project.  All rights reserved.
3  * 
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 /*
35  * void bzero(void *buf, u_int len)     (arguments passed on stack)
36  */
37
38 #include <machine/asmacros.h>
39 #include <machine/cputypes.h>
40 #include <machine/pmap.h>
41 #include <machine/specialreg.h>
42
43 #include "assym.s"
44
45         .text
46
47 /*
48  * NOTE: GCC-4.x may call memset directly, we can't use an indirect pointer.
49  */
50 ENTRY(memset)
51         pushl   %edi
52         movl    4+4(%esp),%edi
53         movl    12+4(%esp),%ecx
54         movzbl  8+4(%esp),%eax
55         movl    %eax,%edx
56         shll    $8,%edx
57         orl     %edx,%eax
58         movl    %eax,%edx
59         shll    $16,%edx
60         orl     %edx,%eax
61         jmp     2f
62
63 /*
64  * Ignore inefficiencies due to alignment.  Most callers will supply
65  * reasonably aligned pointers.
66  */
67 ENTRY(bzero)
68         pushl   %edi
69         subl    %eax,%eax
70         movl    4+4(%esp),%edi
71         movl    8+4(%esp),%ecx
72         jmp     2f
73         SUPERALIGN_TEXT
74 1:
75         movl    %eax,(%edi)
76         movl    %eax,4(%edi)
77         addl    $8,%edi
78 2:
79         subl    $8,%ecx
80         jae     1b
81         addl    $8,%ecx
82         jz      3f
83         cld
84         rep
85         stosb
86 3:
87         popl    %edi
88         ret
89
90 ENTRY(i686_pagezero)
91         pushl   %edi
92         pushl   %ebx
93
94         movl    12(%esp), %edi
95         movl    $1024, %ecx
96         cld
97
98         ALIGN_TEXT
99 1:
100         xorl    %eax, %eax
101         repe
102         scasl   
103         jnz     2f
104
105         popl    %ebx
106         popl    %edi
107         ret
108
109         ALIGN_TEXT
110
111 2:
112         incl    %ecx
113         subl    $4, %edi
114
115         movl    %ecx, %edx
116         cmpl    $16, %ecx
117
118         jge     3f
119
120         movl    %edi, %ebx
121         andl    $0x3f, %ebx
122         shrl    %ebx
123         shrl    %ebx
124         movl    $16, %ecx
125         subl    %ebx, %ecx
126
127 3:
128         subl    %ecx, %edx
129         rep
130         stosl
131
132         movl    %edx, %ecx
133         testl   %edx, %edx
134         jnz     1b
135
136         popl    %ebx
137         popl    %edi
138         ret
139