Changeset 8b655705 in mainline for kernel/generic/src/lib/memfnc.c


Ignore:
Timestamp:
2011-04-15T19:38:07Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9dd730d1
Parents:
6b9e85b (diff), b2fb47f (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.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/lib/memfnc.c

    r6b9e85b r8b655705  
    1 /*
    2  * Copyright (c) 2007 Jan Hudecek
    3  * Copyright (c) 2008 Martin Decky
     1        /*
     2 * Copyright (c) 2011 Martin Decky
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup genericproc
     29/** @addtogroup generic
    3130 * @{
    3231 */
    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.
    3540 */
    3641
    37 #ifndef KERN_TASKLET_H_
    38 #define KERN_TASKLET_H_
     42#include <lib/memfnc.h>
     43#include <typedefs.h>
    3944
    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 */
     56void *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}
    4166
    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 */
     79void *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;
    5683       
    57         /** Callback to call */
    58         tasklet_callback_t callback;
     84        while (cnt-- != 0)
     85                        *dp++ = *sp++;
    5986       
    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}
    7189
    7290/** @}
Note: See TracChangeset for help on using the changeset viewer.