Changeset b910455 in mainline for kernel/generic/src/lib/memfnc.c
- Timestamp:
- 2011-04-07T09:46:11Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6639ae1
- Parents:
- f6bffee (diff), 8e80d3f (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
rf6bffee rb910455 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.h 34 * @brief Tasklets declarations 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 #i fndef KERN_TASKLET_H_38 # define KERN_TASKLET_H_42 #include <lib/memfnc.h> 43 #include <typedefs.h> 39 44 40 #include <adt/list.h> 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 } 41 66 42 /** Tasklet callback type */ 43 typedef void (* tasklet_callback_t)(void *arg); 44 45 /** Tasklet state */ 46 typedef enum { 47 NotActive, 48 Scheduled, 49 InProgress, 50 Disabled 51 } tasklet_state_t; 52 53 /** Structure describing a tasklet */ 54 typedef struct tasklet_descriptor { 55 link_t link; 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; 56 83 57 /** Callback to call */58 tasklet_callback_t callback;84 while (cnt-- != 0) 85 *dp++ = *sp++; 59 86 60 /** Argument passed to the callback */ 61 void *arg; 62 63 /** State of the tasklet */ 64 tasklet_state_t state; 65 } tasklet_descriptor_t; 66 67 68 extern void tasklet_init(void); 69 70 #endif 87 return dst; 88 } 71 89 72 90 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.