Changeset 8436590 in mainline for kernel/generic


Ignore:
Timestamp:
2011-04-07T21:38:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
033cbf82
Parents:
3acb285a (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.
Message:

Merge mainline changes.

Location:
kernel/generic
Files:
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/ipc.h

    r3acb285a r8436590  
    115115 */
    116116#define IPC_FF_ROUTE_FROM_ME  (1 << 0)
     117
     118/* Data transfer flags. */
     119#define IPC_XF_NONE             0
     120
     121/** Restrict the transfer size if necessary. */
     122#define IPC_XF_RESTRICT         (1 << 0)
    117123
    118124/** Kernel IPC interfaces
  • kernel/generic/include/lib/memfnc.h

    r3acb285a r8436590  
    11/*
    2  * Copyright (c) 2005 Sergey Bondari
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup ia64
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_ia64_MEMSTR_H_
    36 #define KERN_ia64_MEMSTR_H_
     35#ifndef KERN_LIB_MEMFNC_H_
     36#define KERN_LIB_MEMFNC_H_
    3737
    38 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     38#include <typedefs.h>
    3939
    40 extern void memsetw(void *, size_t, uint16_t);
    41 extern void memsetb(void *, size_t, uint8_t);
     40extern void *memset(void *, int, size_t);
     41extern void *memcpy(void *, const void *, size_t);
    4242
    4343#endif
  • kernel/generic/include/memstr.h

    r3acb285a r8436590  
    3737
    3838#include <typedefs.h>
    39 #include <arch/memstr.h>
    4039
    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
     43extern void memsetb(void *, size_t, uint8_t);
     44extern void memsetw(void *, size_t, uint16_t);
     45extern void *memmove(void *, const void *, size_t);
    4846
    4947#endif
  • kernel/generic/src/ipc/sysipc.c

    r3acb285a r8436590  
    426426        case IPC_M_DATA_READ: {
    427427                size_t size = IPC_GET_ARG2(call->data);
    428                 if ((size <= 0 || (size > DATA_XFER_LIMIT)))
     428                if (size <= 0)
    429429                        return ELIMIT;
    430                
     430                if (size > DATA_XFER_LIMIT) {
     431                        int flags = IPC_GET_ARG3(call->data);
     432                        if (flags & IPC_XF_RESTRICT)
     433                                IPC_SET_ARG2(call->data, DATA_XFER_LIMIT);
     434                        else
     435                                return ELIMIT;
     436                }
    431437                break;
    432438        }
     
    435441                size_t size = IPC_GET_ARG2(call->data);
    436442               
    437                 if (size > DATA_XFER_LIMIT)
    438                         return ELIMIT;
     443                if (size > DATA_XFER_LIMIT) {
     444                        int flags = IPC_GET_ARG3(call->data);
     445                        if (flags & IPC_XF_RESTRICT) {
     446                                size = DATA_XFER_LIMIT;
     447                                IPC_SET_ARG2(call->data, size);
     448                        } else
     449                                return ELIMIT;
     450                }
    439451               
    440452                call->buffer = (uint8_t *) malloc(size, 0);
  • kernel/generic/src/lib/memfnc.c

    r3acb285a r8436590  
    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.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.
    3540 */
    3641
    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>
    4144
    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 */
     56void *memset(void *dst, int val, size_t cnt)
    4957{
    50         unsigned int i;
     58        size_t i;
     59        uint8_t *ptr = (uint8_t *) dst;
    5160       
    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;
    5563       
    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;
    6065}
    6166
     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;
     83       
     84        while (cnt-- != 0)
     85                        *dp++ = *sp++;
     86       
     87        return dst;
     88}
    6289
    6390/** @}
  • kernel/generic/src/lib/memstr.c

    r3acb285a r8436590  
    2828 */
    2929
    30 /** @addtogroup generic 
     30/** @addtogroup generic
    3131 * @{
    3232 */
     
    3434/**
    3535 * @file
    36  * @brief       Memory string operations.
     36 * @brief Memory string operations.
    3737 *
    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.
    4241 */
    4342
    4443#include <memstr.h>
    4544#include <typedefs.h>
    46 #include <align.h>
    4745
    48 /** Copy block of memory.
     46/** Fill block of memory.
    4947 *
    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.
    5349 *
    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.
    5753 *
    58  * @return              Destination address.
    5954 */
    60 void *_memcpy(void *dst, const void *src, size_t cnt)
     55void memsetb(void *dst, size_t cnt, uint8_t val)
    6156{
    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 */
     70void memsetw(void *dst, size_t cnt, uint16_t val)
     71{
     72        size_t i;
     73        uint16_t *ptr = (uint16_t *) dst;
    6374       
    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;
    7877}
    7978
    8079/** Move memory block with possible overlapping.
    8180 *
    82  * Copy cnt bytes from src address to dst address. The source and destination
    83  * memory areas may overlap.
     81 * Copy cnt bytes from src address to dst address. The source
     82 * and destination memory areas may overlap.
    8483 *
    85  * @param src           Source address to copy from.
    86  * @param dst           Destination address to copy to.
    87  * @param cnt           Number of bytes to copy.
     84 * @param dst Destination address to copy to.
     85 * @param src Source address to copy from.
     86 * @param cnt Number of bytes to copy.
    8887 *
    89  * @return              Destination address.
     88 * @return Destination address.
     89 *
    9090 */
    91 void *memmove(void *dst, const void *src, size_t n)
     91void *memmove(void *dst, const void *src, size_t cnt)
    9292{
    93         const uint8_t *sp;
    94         uint8_t *dp;
    95 
    9693        /* Nothing to do? */
    9794        if (src == dst)
    9895                return dst;
    99 
     96       
    10097        /* 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       
    105104        /* Which direction? */
    106105        if (src > dst) {
    107106                /* Forwards. */
     107                dp = dst;
    108108                sp = src;
    109                 dp = dst;
    110 
    111                 while (n-- != 0)
     109               
     110                while (cnt-- != 0)
    112111                        *dp++ = *sp++;
    113112        } else {
    114113                /* 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)
    119118                        *dp-- = *sp--;
    120119        }
    121 
     120       
    122121        return dst;
    123 }
    124 
    125 /** Fill block of memory
    126  *
    127  * Fill cnt bytes at dst address with the value x.  The filling is done
    128  * 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 done
    147  * 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;       
    161122}
    162123
  • kernel/generic/src/main/main.c

    r3acb285a r8436590  
    5858#include <proc/thread.h>
    5959#include <proc/task.h>
    60 #include <proc/tasklet.h>
    6160#include <main/kinit.h>
    6261#include <main/version.h>
     
    217216        tlb_init();
    218217        ddi_init();
    219         tasklet_init();
    220218        arch_post_mm_init();
    221219        arch_pre_smp_init();
  • kernel/generic/src/mm/backend_elf.c

    r3acb285a r8436590  
    9191        if (!as_area_check_access(area, access))
    9292                return AS_PF_FAULT;
    93 
    94         ASSERT((addr >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) &&
    95             (addr < entry->p_vaddr + entry->p_memsz));
     93       
     94        if (addr < ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE))
     95                return AS_PF_FAULT;
     96       
     97        if (addr >= entry->p_vaddr + entry->p_memsz)
     98                return AS_PF_FAULT;
     99       
    96100        i = (addr - ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) >> PAGE_WIDTH;
    97101        base = (uintptr_t)
Note: See TracChangeset for help on using the changeset viewer.