aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/lib/memset.c
diff options
context:
space:
mode:
authorMichal Simek <monstr@monstr.eu>2009-03-27 09:25:21 -0400
committerMichal Simek <monstr@monstr.eu>2009-03-27 09:25:21 -0400
commit322ae8eb91c1730728400c5b8dd1108aef1205b8 (patch)
treed5c74be5b85ba2938f98172e72727b31fc214eaa /arch/microblaze/lib/memset.c
parent16bfeaf23ead78d937b3eacfb5c7cdc7bff6d3da (diff)
microblaze_v8: supported function for memory - kernel/lib
Reviewed-by: Ingo Molnar <mingo@elte.hu> Acked-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com> Acked-by: John Linn <john.linn@xilinx.com> Acked-by: John Williams <john.williams@petalogix.com> Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze/lib/memset.c')
-rw-r--r--arch/microblaze/lib/memset.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/arch/microblaze/lib/memset.c b/arch/microblaze/lib/memset.c
new file mode 100644
index 000000000000..941dc8f94b03
--- /dev/null
+++ b/arch/microblaze/lib/memset.c
@@ -0,0 +1,82 @@
1/*
2 * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2008-2009 PetaLogix
4 * Copyright (C) 2007 John Williams
5 *
6 * Reasonably optimised generic C-code for memset on Microblaze
7 * This is generic C code to do efficient, alignment-aware memcpy.
8 *
9 * It is based on demo code originally Copyright 2001 by Intel Corp, taken from
10 * http://www.embedded.com/showArticle.jhtml?articleID=19205567
11 *
12 * Attempts were made, unsuccesfully, to contact the original
13 * author of this code (Michael Morrow, Intel). Below is the original
14 * copyright notice.
15 *
16 * This software has been developed by Intel Corporation.
17 * Intel specifically disclaims all warranties, express or
18 * implied, and all liability, including consequential and
19 * other indirect damages, for the use of this program, including
20 * liability for infringement of any proprietary rights,
21 * and including the warranties of merchantability and fitness
22 * for a particular purpose. Intel does not assume any
23 * responsibility for and errors which may appear in this program
24 * not any responsibility to update it.
25 */
26
27#include <linux/types.h>
28#include <linux/stddef.h>
29#include <linux/compiler.h>
30#include <linux/module.h>
31#include <linux/string.h>
32
33#ifdef __HAVE_ARCH_MEMSET
34void *memset(void *v_src, int c, __kernel_size_t n)
35{
36
37 char *src = v_src;
38#ifdef CONFIG_OPT_LIB_FUNCTION
39 uint32_t *i_src;
40 uint32_t w32;
41#endif
42 /* Truncate c to 8 bits */
43 c = (c & 0xFF);
44
45#ifdef CONFIG_OPT_LIB_FUNCTION
46 /* Make a repeating word out of it */
47 w32 = c;
48 w32 |= w32 << 8;
49 w32 |= w32 << 16;
50
51 if (n >= 4) {
52 /* Align the destination to a word boundary */
53 /* This is done in an endian independant manner */
54 switch ((unsigned) src & 3) {
55 case 1:
56 *src++ = c;
57 --n;
58 case 2:
59 *src++ = c;
60 --n;
61 case 3:
62 *src++ = c;
63 --n;
64 }
65
66 i_src = (void *)src;
67
68 /* Do as many full-word copies as we can */
69 for (; n >= 4; n -= 4)
70 *i_src++ = w32;
71
72 src = (void *)i_src;
73 }
74#endif
75 /* Simple, byte oriented memset or the rest of count. */
76 while (n--)
77 *src++ = c;
78
79 return v_src;
80}
81EXPORT_SYMBOL(memset);
82#endif /* __HAVE_ARCH_MEMSET */