Changeset 8436590 in mainline for kernel/generic/src/lib/memfnc.c
- Timestamp:
- 2011-04-07T21:38:17Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 033cbf82
- Parents:
- 3acb285 (diff), ccca251 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/lib/memfnc.c
r3acb285 r8436590 1 /* 2 * Copyright (c) 2007 Jan Hudecek 3 * Copyright (c) 2008 Martin Decky 1 /* 2 * Copyright (c) 2011 Martin Decky 4 3 * All rights reserved. 5 4 * … … 28 27 */ 29 28 30 /** @addtogroup generic proc29 /** @addtogroup generic 31 30 * @{ 32 31 */ 33 /** @file tasklet.c 34 * @brief Tasklet implementation 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. 35 40 */ 36 41 37 #include <proc/tasklet.h> 38 #include <synch/spinlock.h> 39 #include <mm/slab.h> 40 #include <config.h> 42 #include <lib/memfnc.h> 43 #include <typedefs.h> 41 44 42 /** Spinlock protecting list of tasklets */ 43 SPINLOCK_INITIALIZE(tasklet_lock); 44 45 /** Array of tasklet lists for every CPU */ 46 tasklet_descriptor_t **tasklet_list; 47 48 void tasklet_init(void) 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) 49 57 { 50 unsigned int i; 58 size_t i; 59 uint8_t *ptr = (uint8_t *) dst; 51 60 52 tasklet_list = malloc(sizeof(tasklet_descriptor_t *) * config.cpu_count, 0); 53 if (!tasklet_list) 54 panic("Error initializing tasklets."); 61 for (i = 0; i < cnt; i++) 62 ptr[i] = val; 55 63 56 for (i = 0; i < config.cpu_count; i++) 57 tasklet_list[i] = NULL; 58 59 spinlock_initialize(&tasklet_lock, "tasklet_lock"); 64 return dst; 60 65 } 61 66 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 } 62 89 63 90 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.