- Timestamp:
- 2011-03-29T21:38:40Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d6b81941
- Parents:
- ebebd38 (diff), eaf4c393 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel
- Files:
-
- 6 deleted
- 27 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/Makefile
rebebd38 r3abfe9a8 240 240 generic/src/lib/func.c \ 241 241 generic/src/lib/memstr.c \ 242 generic/src/lib/memfnc.c \ 242 243 generic/src/lib/sort.c \ 243 244 generic/src/lib/str.c \ -
kernel/arch/amd64/Makefile.inc
rebebd38 r3abfe9a8 33 33 34 34 FPU_NO_CFLAGS = -mno-sse -mno-sse2 35 CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer 35 36 # 37 # FIXME: 38 # 39 # The -fno-optimize-sibling-calls should be removed as soon as a bug 40 # in GCC concerning the "large" memory model and tail call optimization 41 # is fixed. 42 # 43 # If GCC generates a code for tail call, instead of generating .. 44 # 45 # jmp *fnc 46 # 47 # it generates an assembly code with an illegal immediate prefix: 48 # 49 # jmp *$fnc 50 # 51 52 CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer -fno-optimize-sibling-calls 36 53 GCC_CFLAGS += $(CMN1) 37 54 ICC_CFLAGS += $(CMN1) -
kernel/arch/amd64/_link.ld.in
rebebd38 r3abfe9a8 26 26 .mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)) : AT (SIZEOF(.unmapped)) { 27 27 ktext_start = .; 28 *(.text );28 *(.text .text.*); 29 29 ktext_end = .; 30 30 31 31 kdata_start = .; 32 *(.data); /* initialized data */33 *(.rodata *);/* string literals */32 *(.data); /* initialized data */ 33 *(.rodata .rodata.*); /* string literals */ 34 34 hardcoded_load_address = .; 35 35 QUAD(PA2KA(BOOT_OFFSET)); -
kernel/arch/amd64/src/asm.S
rebebd38 r3abfe9a8 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
rebebd38 r3abfe9a8 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
rebebd38 r3abfe9a8 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/_link.ld.in
rebebd38 r3abfe9a8 25 25 .mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)): AT (SIZEOF(.unmapped)) { 26 26 ktext_start = .; 27 *(.text );27 *(.text .text.*); 28 28 ktext_end = .; 29 29 30 30 kdata_start = .; 31 31 *(.data); /* initialized data */ 32 *(.rodata *);/* string literals */32 *(.rodata .rodata.*); /* string literals */ 33 33 *(COMMON); /* global variables */ 34 34 hardcoded_load_address = .; -
kernel/arch/ia32/src/asm.S
rebebd38 r3abfe9a8 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/ia32/src/cpu/cpu.c
rebebd38 r3abfe9a8 92 92 void cpu_arch_init(void) 93 93 { 94 cpuid_extended_feature_info efi;95 94 cpu_info_t info; 96 95 uint32_t help = 0; … … 104 103 105 104 CPU->arch.fi.word = info.cpuid_edx; 106 efi.word = info.cpuid_ecx;107 105 108 106 if (CPU->arch.fi.bits.fxsr) -
kernel/arch/ia64/_link.ld.in
rebebd38 r3abfe9a8 16 16 ktext_start = .; 17 17 *(K_TEXT_START); 18 *(.text )18 *(.text .text.*) 19 19 ktext_end = .; 20 20 … … 36 36 *(.bss) 37 37 *(COMMON); 38 38 39 39 . = ALIGN(8); 40 41 42 40 symbol_table = .; 41 *(symtab.*); /* Symbol table, must be LAST symbol!*/ 42 43 43 kdata_end = .; 44 44 } 45 45 46 46 /DISCARD/ : { 47 47 *(*); 48 48 } 49 50 49 } -
kernel/arch/ia64/src/asm.S
rebebd38 r3abfe9a8 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/ia64/src/mm/tlb.c
rebebd38 r3abfe9a8 475 475 void alternate_instruction_tlb_fault(uint64_t vector, istate_t *istate) 476 476 { 477 region_register_t rr;478 rid_t rid;479 477 uintptr_t va; 480 478 pte_t *t; 481 479 482 480 va = istate->cr_ifa; /* faulting address */ 483 rr.word = rr_read(VA2VRN(va));484 rid = rr.map.rid;485 481 486 482 page_table_lock(AS, true); … … 649 645 void data_dirty_bit_fault(uint64_t vector, istate_t *istate) 650 646 { 651 region_register_t rr;652 rid_t rid;653 647 uintptr_t va; 654 648 pte_t *t; 655 649 656 650 va = istate->cr_ifa; /* faulting address */ 657 rr.word = rr_read(VA2VRN(va));658 rid = rr.map.rid;659 651 660 652 page_table_lock(AS, true); … … 686 678 void instruction_access_bit_fault(uint64_t vector, istate_t *istate) 687 679 { 688 region_register_t rr;689 rid_t rid;690 680 uintptr_t va; 691 681 pte_t *t; 692 682 693 683 va = istate->cr_ifa; /* faulting address */ 694 rr.word = rr_read(VA2VRN(va));695 rid = rr.map.rid;696 684 697 685 page_table_lock(AS, true); … … 723 711 void data_access_bit_fault(uint64_t vector, istate_t *istate) 724 712 { 725 region_register_t rr;726 rid_t rid;727 713 uintptr_t va; 728 714 pte_t *t; 729 715 730 716 va = istate->cr_ifa; /* faulting address */ 731 rr.word = rr_read(VA2VRN(va));732 rid = rr.map.rid;733 717 734 718 page_table_lock(AS, true); … … 760 744 void data_access_rights_fault(uint64_t vector, istate_t *istate) 761 745 { 762 region_register_t rr;763 rid_t rid;764 746 uintptr_t va; 765 747 pte_t *t; 766 748 767 749 va = istate->cr_ifa; /* faulting address */ 768 rr.word = rr_read(VA2VRN(va));769 rid = rr.map.rid;770 750 771 751 /* … … 792 772 void page_not_present(uint64_t vector, istate_t *istate) 793 773 { 794 region_register_t rr;795 rid_t rid;796 774 uintptr_t va; 797 775 pte_t *t; 798 776 799 777 va = istate->cr_ifa; /* faulting address */ 800 rr.word = rr_read(VA2VRN(va));801 rid = rr.map.rid;802 778 803 779 page_table_lock(AS, true); -
kernel/arch/mips32/src/asm.S
rebebd38 r3abfe9a8 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/_link.ld.in
rebebd38 r3abfe9a8 36 36 kdata_start = .; 37 37 *(K_DATA_START); 38 *(.rodata); 39 *(.rodata.*); 38 *(.rodata .rodata.*); 40 39 *(.data); /* initialized data */ 41 40 *(.sdata); -
kernel/arch/ppc32/src/asm.S
rebebd38 r3abfe9a8 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/_link.ld.in
rebebd38 r3abfe9a8 15 15 ktext_start = .; 16 16 *(K_TEXT_START) 17 *(.text );17 *(.text .text.*); 18 18 ktext_end = .; 19 19 20 20 kdata_start = .; 21 21 *(K_DATA_START) 22 *(.rodata); 23 *(.rodata.*); 22 *(.rodata .rodata.*); 24 23 *(.data); /* initialized data */ 25 24 *(.sdata); -
kernel/arch/sparc64/src/asm.S
rebebd38 r3abfe9a8 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
rebebd38 r3abfe9a8 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
rebebd38 r3abfe9a8 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/drivers/via-cuda/cuda.c
rebebd38 r3abfe9a8 239 239 cuda_instance_t *instance = irq->instance; 240 240 cuda_t *dev = instance->cuda; 241 uint8_t data,b;242 241 uint8_t b; 242 243 243 b = pio_read_8(&dev->b); 244 data =pio_read_8(&dev->sr);245 244 pio_read_8(&dev->sr); 245 246 246 if ((b & TREQ) == 0) { 247 247 instance->xstate = cx_receive; … … 251 251 cuda_send_start(instance); 252 252 } 253 254 255 253 254 memcpy(buf, instance->rcv_buf, instance->bidx); 255 *len = instance->bidx; 256 256 instance->bidx = 0; 257 257 } -
kernel/genarch/src/ofw/ebus.c
rebebd38 r3abfe9a8 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
rebebd38 r3abfe9a8 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
rebebd38 r3abfe9a8 37 37 38 38 #include <genarch/ofw/ofw_tree.h> 39 #include <arch/memstr.h>40 39 #include <mm/slab.h> 40 #include <memstr.h> 41 41 #include <str.h> 42 42 #include <panic.h> -
kernel/genarch/src/ofw/pci.c
rebebd38 r3abfe9a8 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
rebebd38 r3abfe9a8 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/lib/memfnc.h
rebebd38 r3abfe9a8 1 1 /* 2 * Copyright (c) 20 05 Sergey Bondari2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup ia6429 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_ ia64_MEMSTR_H_36 #define KERN_ ia64_MEMSTR_H_35 #ifndef KERN_LIB_MEMFNC_H_ 36 #define KERN_LIB_MEMFNC_H_ 37 37 38 # define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))38 #include <typedefs.h> 39 39 40 extern void memsetw(void *, size_t, uint16_t);41 extern void memsetb(void *, size_t, uint8_t);40 extern void *memset(void *, int, size_t); 41 extern void *memcpy(void *, const void *, size_t); 42 42 43 43 #endif -
kernel/generic/include/memstr.h
rebebd38 r3abfe9a8 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 #define memset(dst, val, cnt) __builtin_memset((dst), (val), (cnt)) 41 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 42 43 extern void memsetb(void *, size_t, uint8_t); 44 extern void memsetw(void *, size_t, uint16_t); 45 extern void *memmove(void *, const void *, size_t); 48 46 49 47 #endif -
kernel/generic/src/lib/memfnc.c
rebebd38 r3abfe9a8 1 /*2 * Copyright (c) 20 05 Sergey Bondari1 /* 2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup amd6429 /** @addtogroup generic 30 30 * @{ 31 31 */ 32 /** @file 32 33 /** 34 * @file 35 * @brief Memory string functions. 36 * 37 * This file provides architecture independent functions to manipulate blocks 38 * of memory. These functions are optimized as much as generic functions of 39 * this type can be. 33 40 */ 34 41 35 #i fndef KERN_amd64_MEMSTR_H_36 # define KERN_amd64_MEMSTR_H_42 #include <lib/memfnc.h> 43 #include <typedefs.h> 37 44 38 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 45 /** Fill block of memory. 46 * 47 * Fill cnt bytes at dst address with the value val. 48 * 49 * @param dst Destination address to fill. 50 * @param val Value to fill. 51 * @param cnt Number of bytes to fill. 52 * 53 * @return Destination address. 54 * 55 */ 56 void *memset(void *dst, int val, size_t cnt) 57 { 58 size_t i; 59 uint8_t *ptr = (uint8_t *) dst; 60 61 for (i = 0; i < cnt; i++) 62 ptr[i] = val; 63 64 return dst; 65 } 39 66 40 extern void memsetw(void *, size_t, uint16_t); 41 extern void memsetb(void *, size_t, uint8_t); 42 43 #endif 67 /** Move memory block without overlapping. 68 * 69 * Copy cnt bytes from src address to dst address. The source 70 * and destination memory areas cannot overlap. 71 * 72 * @param dst Destination address to copy to. 73 * @param src Source address to copy from. 74 * @param cnt Number of bytes to copy. 75 * 76 * @return Destination address. 77 * 78 */ 79 void *memcpy(void *dst, const void *src, size_t cnt) 80 { 81 uint8_t *dp = (uint8_t *) dst; 82 const uint8_t *sp = (uint8_t *) src; 83 84 while (cnt-- != 0) 85 *dp++ = *sp++; 86 87 return dst; 88 } 44 89 45 90 /** @} -
kernel/generic/src/lib/memstr.c
rebebd38 r3abfe9a8 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 44 43 #include <memstr.h> 45 44 #include <typedefs.h> 46 #include <align.h>47 45 48 /** Copyblock of memory.46 /** Fill block of memory. 49 47 * 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. 48 * Fill cnt bytes at dst address with the value val. 53 49 * 54 * @param src Source address to copy from.55 * @param dst Destination address to copy to.56 * @param cnt Number of bytes to copy.50 * @param dst Destination address to fill. 51 * @param cnt Number of bytes to fill. 52 * @param val Value to fill. 57 53 * 58 * @return Destination address.59 54 */ 60 void *_memcpy(void *dst, const void *src, size_t cnt)55 void memsetb(void *dst, size_t cnt, uint8_t val) 61 56 { 62 unsigned int i, j; 57 memset(dst, val, cnt); 58 } 59 60 /** Fill block of memory. 61 * 62 * Fill cnt words at dst address with the value val. The filling 63 * is done word-by-word. 64 * 65 * @param dst Destination address to fill. 66 * @param cnt Number of words to fill. 67 * @param val Value to fill. 68 * 69 */ 70 void memsetw(void *dst, size_t cnt, uint16_t val) 71 { 72 size_t i; 73 uint16_t *ptr = (uint16_t *) dst; 63 74 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; 75 for (i = 0; i < cnt; i++) 76 ptr[i] = val; 78 77 } 79 78 80 79 /** Move memory block with possible overlapping. 81 80 * 82 * Copy cnt bytes from src address to dst address. The source and destination83 * memory areas may overlap.81 * Copy cnt bytes from src address to dst address. The source 82 * and destination memory areas may overlap. 84 83 * 85 * @param src Source address to copy from.86 * @param dst Destination address to copy to.87 * @param cnt 84 * @param dst Destination address to copy to. 85 * @param src Source address to copy from. 86 * @param cnt Number of bytes to copy. 88 87 * 89 * @return Destination address. 88 * @return Destination address. 89 * 90 90 */ 91 void *memmove(void *dst, const void *src, size_t n)91 void *memmove(void *dst, const void *src, size_t cnt) 92 92 { 93 const uint8_t *sp;94 uint8_t *dp;95 96 93 /* Nothing to do? */ 97 94 if (src == dst) 98 95 return dst; 99 96 100 97 /* Non-overlapping? */ 101 if (dst >= src + n || src >= dst + n) { 102 return memcpy(dst, src, n); 103 } 104 98 if ((dst >= src + cnt) || (src >= dst + cnt)) 99 return memcpy(dst, src, cnt); 100 101 uint8_t *dp; 102 const uint8_t *sp; 103 105 104 /* Which direction? */ 106 105 if (src > dst) { 107 106 /* Forwards. */ 107 dp = dst; 108 108 sp = src; 109 dp = dst; 110 111 while (n-- != 0) 109 110 while (cnt-- != 0) 112 111 *dp++ = *sp++; 113 112 } else { 114 113 /* Backwards. */ 115 sp = src + (n- 1);116 dp = dst + (n- 1);117 118 while ( n-- != 0)114 dp = dst + (cnt - 1); 115 sp = src + (cnt - 1); 116 117 while (cnt-- != 0) 119 118 *dp-- = *sp--; 120 119 } 121 120 122 121 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 122 } 162 123
Note:
See TracChangeset
for help on using the changeset viewer.