Changeset cb4f078 in mainline
- Timestamp:
- 2011-03-28T20:53:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8caaea7
- Parents:
- 603c8740
- Location:
- kernel
- Files:
-
- 8 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/asm.S
r603c8740 rcb4f078 37 37 .global read_efer_flag 38 38 .global set_efer_flag 39 .global memsetb40 .global memsetw41 .global memcpy42 39 .global memcpy_from_uspace 43 40 .global memcpy_to_uspace … … 46 43 .global early_putchar 47 44 48 /* Wrapper for generic memsetb */49 memsetb:50 jmp _memsetb51 52 /* Wrapper for generic memsetw */53 memsetw:54 jmp _memsetw55 56 45 #define MEMCPY_DST %rdi 57 46 #define MEMCPY_SRC %rsi … … 74 63 * 75 64 */ 76 memcpy:77 65 memcpy_from_uspace: 78 66 memcpy_to_uspace: -
kernel/arch/arm32/src/asm.S
r603c8740 rcb4f078 29 29 .text 30 30 31 .global memsetb32 .global memsetw33 .global memcpy34 31 .global memcpy_from_uspace 35 32 .global memcpy_to_uspace … … 38 35 .global early_putchar 39 36 40 memsetb:41 b _memsetb42 43 memsetw:44 b _memsetw45 46 memcpy:47 37 memcpy_from_uspace: 48 38 memcpy_to_uspace: -
kernel/arch/arm32/src/exception.c
r603c8740 rcb4f078 35 35 36 36 #include <arch/exception.h> 37 #include <arch/memstr.h>38 37 #include <arch/regutils.h> 39 38 #include <arch/machine_func.h> -
kernel/arch/ia32/src/asm.S
r603c8740 rcb4f078 38 38 .global paging_on 39 39 .global enable_l_apic_in_msr 40 .global memsetb41 .global memsetw42 .global memcpy43 40 .global memcpy_from_uspace 44 41 .global memcpy_from_uspace_failover_address … … 47 44 .global early_putchar 48 45 49 /* Wrapper for generic memsetb */50 memsetb:51 jmp _memsetb52 53 /* Wrapper for generic memsetw */54 memsetw:55 jmp _memsetw56 57 46 #define MEMCPY_DST 4 58 47 #define MEMCPY_SRC 8 … … 74 63 * 75 64 */ 76 memcpy:77 65 memcpy_from_uspace: 78 66 memcpy_to_uspace: -
kernel/arch/ia64/src/asm.S
r603c8740 rcb4f078 30 30 31 31 .text 32 .global memcpy33 32 .global memcpy_from_uspace 34 33 .global memcpy_to_uspace … … 39 38 * 40 39 * This memcpy() has been taken from the assembler output of 41 * the generic _memcpy() and modified to have the failover part. 40 * a plain C implementation of memcpy() modified to have the 41 * failover part. 42 42 * 43 43 * @param in0 Destination address. … … 46 46 * 47 47 */ 48 memcpy:49 48 memcpy_from_uspace: 50 49 memcpy_to_uspace: … … 141 140 br.ret.sptk.many rp 142 141 143 .global memsetb144 memsetb:145 br _memsetb146 147 .global memsetw148 memsetw:149 br _memsetw150 151 142 .global cpu_halt 152 143 cpu_halt: -
kernel/arch/mips32/src/asm.S
r603c8740 rcb4f078 57 57 nop 58 58 59 .global memsetb60 memsetb:61 j _memsetb62 nop63 64 .global memsetw65 memsetw:66 j _memsetw67 nop68 69 .global memcpy70 59 .global memcpy_from_uspace 71 60 .global memcpy_to_uspace 72 61 .global memcpy_from_uspace_failover_address 73 62 .global memcpy_to_uspace_failover_address 74 memcpy:75 63 memcpy_from_uspace: 76 64 memcpy_to_uspace: -
kernel/arch/ppc32/src/asm.S
r603c8740 rcb4f078 35 35 .global iret 36 36 .global iret_syscall 37 .global memsetb38 .global memsetw39 .global memcpy40 37 .global memcpy_from_uspace 41 38 .global memcpy_to_uspace … … 208 205 rfi 209 206 210 memsetb:211 b _memsetb212 213 memsetw:214 b _memsetw215 216 memcpy:217 207 memcpy_from_uspace: 218 208 memcpy_to_uspace: -
kernel/arch/sparc64/src/asm.S
r603c8740 rcb4f078 34 34 .register %g2, #scratch 35 35 .register %g3, #scratch 36 37 /*38 * This is the assembly language version of our _memcpy() generated by gcc.39 */40 .global memcpy41 memcpy:42 mov %o0, %o3 /* save dst */43 add %o1, 7, %g144 and %g1, -8, %g145 cmp %o1, %g146 be,pn %xcc, 3f47 add %o0, 7, %g148 mov 0, %g349 50 0:51 52 brz,pn %o2, 2f53 mov 0, %g254 55 1:56 57 ldub [%g3 + %o1], %g158 add %g2, 1, %g259 cmp %o2, %g260 stb %g1, [%g3 + %o0]61 bne,pt %xcc, 1b62 mov %g2, %g363 64 2:65 66 jmp %o7 + 8 /* exit point */67 mov %o3, %o068 69 3:70 71 and %g1, -8, %g172 cmp %o0, %g173 bne,pt %xcc, 0b74 mov 0, %g375 srlx %o2, 3, %g476 brz,pn %g4, 5f77 mov 0, %g578 79 4:80 81 sllx %g3, 3, %g282 add %g5, 1, %g383 ldx [%o1 + %g2], %g184 mov %g3, %g585 cmp %g4, %g386 bne,pt %xcc, 4b87 stx %g1, [%o0 + %g2]88 89 5:90 91 and %o2, 7, %o292 brz,pn %o2, 2b93 sllx %g4, 3, %g194 mov 0, %g295 add %g1, %o0, %o096 add %g1, %o1, %g497 mov 0, %g398 99 6:100 101 ldub [%g2 + %g4], %g1102 stb %g1, [%g2 + %o0]103 add %g3, 1, %g2104 cmp %o2, %g2105 bne,pt %xcc, 6b106 mov %g2, %g3107 108 jmp %o7 + 8 /* exit point */109 mov %o3, %o0110 36 111 37 /* … … 264 190 mov %g0, %o0 /* return 0 on failure */ 265 191 266 .global memsetb267 memsetb:268 ba %xcc, _memsetb269 nop270 271 .global memsetw272 memsetw:273 ba %xcc, _memsetw274 nop275 276 192 .global early_putchar 277 193 early_putchar: -
kernel/arch/sparc64/src/mm/sun4u/as.c
r603c8740 rcb4f078 43 43 44 44 #include <arch/mm/tsb.h> 45 #include <arch/memstr.h>46 45 #include <arch/asm.h> 47 46 #include <mm/frame.h> -
kernel/arch/sparc64/src/mm/sun4v/as.c
r603c8740 rcb4f078 46 46 47 47 #include <arch/mm/tsb.h> 48 #include <arch/memstr.h>49 48 #include <arch/asm.h> 50 49 #include <mm/frame.h> -
kernel/genarch/src/ofw/ebus.c
r603c8740 rcb4f078 39 39 #include <genarch/ofw/ebus.h> 40 40 #include <genarch/ofw/pci.h> 41 #include <arch/memstr.h>42 41 #include <str.h> 43 42 #include <panic.h> -
kernel/genarch/src/ofw/fhc.c
r603c8740 rcb4f078 39 39 #include <genarch/ofw/fhc.h> 40 40 #include <arch/drivers/fhc.h> 41 #include <arch/memstr.h>42 41 #include <str.h> 43 42 #include <panic.h> -
kernel/genarch/src/ofw/ofw_tree.c
r603c8740 rcb4f078 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <arch/memstr.h>40 39 #include <mm/slab.h> 41 40 #include <str.h> -
kernel/genarch/src/ofw/pci.c
r603c8740 rcb4f078 40 40 #include <arch/drivers/pci.h> 41 41 #include <arch/trap/interrupt.h> 42 #include <arch/memstr.h>43 42 #include <str.h> 44 43 #include <panic.h> -
kernel/genarch/src/ofw/upa.c
r603c8740 rcb4f078 38 38 #include <genarch/ofw/ofw_tree.h> 39 39 #include <genarch/ofw/upa.h> 40 #include <arch/memstr.h>41 40 #include <func.h> 42 41 #include <panic.h> -
kernel/generic/include/memstr.h
r603c8740 rcb4f078 37 37 38 38 #include <typedefs.h> 39 #include <arch/memstr.h>40 39 41 /* 42 * Architecture independent variants. 43 */ 44 extern void * _memcpy(void *dst, const void *src, size_t cnt);45 extern void _memsetb(void *dst, size_t cnt, uint8_t x); 46 extern void _memsetw(void *dst, size_t cnt, uint16_t x);47 extern void *memmove(void * dst, const void *src, size_t cnt);40 41 extern void memsetb(void *, size_t, uint8_t); 42 extern void memsetw(void *, size_t, uint16_t); 43 extern void *memset(void *, int, size_t); 44 45 extern void *memcpy(void *, const void *, size_t); 46 extern void *memmove(void *, const void *, size_t); 48 47 49 48 #endif -
kernel/generic/src/lib/memstr.c
r603c8740 rcb4f078 28 28 */ 29 29 30 /** @addtogroup generic 30 /** @addtogroup generic 31 31 * @{ 32 32 */ … … 34 34 /** 35 35 * @file 36 * @brief 36 * @brief Memory string operations. 37 37 * 38 * This file provides architecture independent functions to manipulate blocks of 39 * memory. These functions are optimized as much as generic functions of this 40 * type can be. However, architectures are free to provide even more optimized 41 * versions of these functions. 38 * This file provides architecture independent functions to manipulate blocks 39 * of memory. These functions are optimized as much as generic functions of 40 * this type can be. 42 41 */ 43 42 … … 46 45 #include <align.h> 47 46 48 /** Copyblock of memory.47 /** Fill block of memory. 49 48 * 50 * Copy cnt bytes from src address to dst address. The copying is done 51 * word-by-word and then byte-by-byte. The source and destination memory areas 52 * cannot overlap. 49 * Fill cnt bytes at dst address with the value val. 53 50 * 54 * @param src Source address to copy from.55 * @param dst Destination address to copy to.56 * @param cnt Number of bytes to copy.51 * @param dst Destination address to fill. 52 * @param cnt Number of bytes to fill. 53 * @param val Value to fill. 57 54 * 58 * @return Destination address.59 55 */ 60 void *_memcpy(void *dst, const void *src, size_t cnt)56 void memsetb(void *dst, size_t cnt, uint8_t val) 61 57 { 62 unsigned int i, j; 58 __builtin_memset(dst, val, cnt); 59 } 60 61 /** Fill block of memory. 62 * 63 * Fill cnt words at dst address with the value val. The filling 64 * is done word-by-word. 65 * 66 * @param dst Destination address to fill. 67 * @param cnt Number of words to fill. 68 * @param val Value to fill. 69 * 70 */ 71 void memsetw(void *dst, size_t cnt, uint16_t val) 72 { 73 size_t i; 74 uint16_t *ptr = (uint16_t *) dst; 63 75 64 if (ALIGN_UP((uintptr_t) src, sizeof(sysarg_t)) != (uintptr_t) src || 65 ALIGN_UP((uintptr_t) dst, sizeof(sysarg_t)) != (uintptr_t) dst) { 66 for (i = 0; i < cnt; i++) 67 ((uint8_t *) dst)[i] = ((uint8_t *) src)[i]; 68 } else { 69 for (i = 0; i < cnt / sizeof(sysarg_t); i++) 70 ((sysarg_t *) dst)[i] = ((sysarg_t *) src)[i]; 71 72 for (j = 0; j < cnt % sizeof(sysarg_t); j++) 73 ((uint8_t *)(((sysarg_t *) dst) + i))[j] = 74 ((uint8_t *)(((sysarg_t *) src) + i))[j]; 75 } 76 77 return (char *) dst; 76 for (i = 0; i < cnt; i++) 77 ptr[i] = val; 78 } 79 80 /** Fill block of memory. 81 * 82 * Fill cnt bytes at dst address with the value val. 83 * 84 * @param dst Destination address to fill. 85 * @param val Value to fill. 86 * @param cnt Number of bytes to fill. 87 * 88 * @return Destination address. 89 * 90 */ 91 void *memset(void *dst, int val, size_t cnt) 92 { 93 return __builtin_memset(dst, val, cnt); 94 } 95 96 /** Move memory block without overlapping. 97 * 98 * Copy cnt bytes from src address to dst address. The source 99 * and destination memory areas cannot overlap. 100 * 101 * @param dst Destination address to copy to. 102 * @param src Source address to copy from. 103 * @param cnt Number of bytes to copy. 104 * 105 * @return Destination address. 106 * 107 */ 108 void *memcpy(void *dst, const void *src, size_t cnt) 109 { 110 return __builtin_memcpy(dst, src, cnt); 78 111 } 79 112 80 113 /** Move memory block with possible overlapping. 81 114 * 82 * Copy cnt bytes from src address to dst address. The source and destination83 * memory areas may overlap.115 * Copy cnt bytes from src address to dst address. The source 116 * and destination memory areas may overlap. 84 117 * 85 * @param src Source address to copy from.86 * @param dst Destination address to copy to.87 * @param cnt 118 * @param dst Destination address to copy to. 119 * @param src Source address to copy from. 120 * @param cnt Number of bytes to copy. 88 121 * 89 * @return Destination address. 122 * @return Destination address. 123 * 90 124 */ 91 void *memmove(void *dst, const void *src, size_t n)125 void *memmove(void *dst, const void *src, size_t cnt) 92 126 { 93 const uint8_t *sp;94 uint8_t *dp;95 96 127 /* Nothing to do? */ 97 128 if (src == dst) 98 129 return dst; 99 130 100 131 /* Non-overlapping? */ 101 if (dst >= src + n || src >= dst + n) { 102 return memcpy(dst, src, n); 103 } 104 132 if ((dst >= src + cnt) || (src >= dst + cnt)) 133 return memcpy(dst, src, cnt); 134 135 const uint8_t *sp; 136 uint8_t *dp; 137 105 138 /* Which direction? */ 106 139 if (src > dst) { … … 108 141 sp = src; 109 142 dp = dst; 110 111 while ( n-- != 0)143 144 while (cnt-- != 0) 112 145 *dp++ = *sp++; 113 146 } else { 114 147 /* Backwards. */ 115 sp = src + ( n- 1);116 dp = dst + ( n- 1);117 118 while ( n-- != 0)148 sp = src + (cnt - 1); 149 dp = dst + (cnt - 1); 150 151 while (cnt-- != 0) 119 152 *dp-- = *sp--; 120 153 } 121 154 122 155 return dst; 123 }124 125 /** Fill block of memory126 *127 * Fill cnt bytes at dst address with the value x. The filling is done128 * byte-by-byte.129 *130 * @param dst Destination address to fill.131 * @param cnt Number of bytes to fill.132 * @param x Value to fill.133 *134 */135 void _memsetb(void *dst, size_t cnt, uint8_t x)136 {137 unsigned int i;138 uint8_t *p = (uint8_t *) dst;139 140 for (i = 0; i < cnt; i++)141 p[i] = x;142 }143 144 /** Fill block of memory.145 *146 * Fill cnt words at dst address with the value x. The filling is done147 * word-by-word.148 *149 * @param dst Destination address to fill.150 * @param cnt Number of words to fill.151 * @param x Value to fill.152 *153 */154 void _memsetw(void *dst, size_t cnt, uint16_t x)155 {156 unsigned int i;157 uint16_t *p = (uint16_t *) dst;158 159 for (i = 0; i < cnt; i++)160 p[i] = x;161 156 } 162 157
Note:
See TracChangeset
for help on using the changeset viewer.