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


Ignore:
Timestamp:
2011-03-30T13:10:24Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ae90f9
Parents:
6e50466 (diff), d6b81941 (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

    r6e50466 rad7a6c9  
    1 /*
    2  * Copyright (c) 2009 Lukas Mejdrech
     1        /*
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup ip
     29/** @addtogroup generic
    3030 * @{
    3131 */
    3232
    33 /** @file
    34  * IP standalone module implementation.
    35  * Contains skeleton module functions mapping.
    36  * The functions are used by the module skeleton as module specific entry
    37  * points.
     33/**
     34 * @file
     35 * @brief Memory string functions.
    3836 *
    39  * @see module.c
     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.
    4040 */
    4141
    42 #include <async.h>
    43 #include <stdio.h>
    44 #include <ipc/ipc.h>
    45 #include <ipc/services.h>
    46 #include <errno.h>
     42#include <lib/memfnc.h>
     43#include <typedefs.h>
    4744
    48 #include <net/modules.h>
    49 #include <net_interface.h>
    50 #include <net/packet.h>
    51 #include <il_local.h>
    52 
    53 #include "ip.h"
    54 #include "ip_module.h"
    55 
    56 /** IP module global data. */
    57 extern ip_globals_t ip_globals;
    58 
    59 int
    60 il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
    61     ipc_call_t *answer, int *answer_count)
     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)
    6257{
    63         return ip_message_standalone(callid, call, answer, answer_count);
     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;
    6465}
    6566
    66 int il_module_start_standalone(async_client_conn_t client_connection)
     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)
    6780{
    68         sysarg_t phonehash;
    69         int rc;
     81        uint8_t *dp = (uint8_t *) dst;
     82        const uint8_t *sp = (uint8_t *) src;
    7083       
    71         async_set_client_connection(client_connection);
    72         ip_globals.net_phone = net_connect_module();
    73 
    74         rc = pm_init();
    75         if (rc != EOK)
    76                 return rc;
     84        while (cnt-- != 0)
     85                        *dp++ = *sp++;
    7786       
    78         rc = ip_initialize(client_connection);
    79         if (rc != EOK)
    80                 goto out;
    81        
    82         rc = ipc_connect_to_me(PHONE_NS, SERVICE_IP, 0, 0, &phonehash);
    83         if (rc != EOK)
    84                 goto out;
    85        
    86         async_manager();
    87 
    88 out:
    89         pm_destroy();
    90         return rc;
     87        return dst;
    9188}
    9289
Note: See TracChangeset for help on using the changeset viewer.