Changeset 3abfe9a8 in mainline


Ignore:
Timestamp:
2011-03-29T21:38:40Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d6b81941
Parents:
ebebd38 (diff), eaf4c393 (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:

separate memset/memcpy redirection to builtin functions and fallback C implementations

Files:
6 deleted
52 edited
2 moved

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    rebebd38 r3abfe9a8  
    240240        generic/src/lib/func.c \
    241241        generic/src/lib/memstr.c \
     242        generic/src/lib/memfnc.c \
    242243        generic/src/lib/sort.c \
    243244        generic/src/lib/str.c \
  • kernel/arch/amd64/Makefile.inc

    rebebd38 r3abfe9a8  
    3333
    3434FPU_NO_CFLAGS = -mno-sse -mno-sse2
    35 CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
     35
     36#
     37# FIXME:
     38#
     39# The -fno-optimize-sibling-calls should be removed as soon as a bug
     40# in GCC concerning the "large" memory model and tail call optimization
     41# is fixed.
     42#
     43# If GCC generates a code for tail call, instead of generating ..
     44#
     45#   jmp *fnc
     46#
     47# it generates an assembly code with an illegal immediate prefix:
     48#
     49#   jmp *$fnc
     50#
     51
     52CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer -fno-optimize-sibling-calls
    3653GCC_CFLAGS += $(CMN1)
    3754ICC_CFLAGS += $(CMN1)
  • kernel/arch/amd64/_link.ld.in

    rebebd38 r3abfe9a8  
    2626        .mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)) : AT (SIZEOF(.unmapped)) {
    2727                ktext_start = .;
    28                 *(.text);
     28                *(.text .text.*);
    2929                ktext_end = .;
    3030               
    3131                kdata_start = .;
    32                 *(.data);       /* initialized data */
    33                 *(.rodata*);    /* string literals */
     32                *(.data);              /* initialized data */
     33                *(.rodata .rodata.*);  /* string literals */
    3434                hardcoded_load_address = .;
    3535                QUAD(PA2KA(BOOT_OFFSET));
  • kernel/arch/amd64/src/asm.S

    rebebd38 r3abfe9a8  
    3737.global read_efer_flag
    3838.global set_efer_flag
    39 .global memsetb
    40 .global memsetw
    41 .global memcpy
    4239.global memcpy_from_uspace
    4340.global memcpy_to_uspace
     
    4643.global early_putchar
    4744
    48 /* Wrapper for generic memsetb */
    49 memsetb:
    50         jmp _memsetb
    51 
    52 /* Wrapper for generic memsetw */
    53 memsetw:
    54         jmp _memsetw
    55 
    5645#define MEMCPY_DST   %rdi
    5746#define MEMCPY_SRC   %rsi
     
    7463 *
    7564 */
    76 memcpy:
    7765memcpy_from_uspace:
    7866memcpy_to_uspace:
  • kernel/arch/arm32/src/asm.S

    rebebd38 r3abfe9a8  
    2929.text
    3030
    31 .global memsetb
    32 .global memsetw
    33 .global memcpy
    3431.global memcpy_from_uspace
    3532.global memcpy_to_uspace
     
    3835.global early_putchar
    3936
    40 memsetb:
    41         b _memsetb
    42 
    43 memsetw:
    44         b _memsetw
    45 
    46 memcpy:
    4737memcpy_from_uspace:
    4838memcpy_to_uspace:
  • kernel/arch/arm32/src/exception.c

    rebebd38 r3abfe9a8  
    3535
    3636#include <arch/exception.h>
    37 #include <arch/memstr.h>
    3837#include <arch/regutils.h>
    3938#include <arch/machine_func.h>
  • kernel/arch/ia32/_link.ld.in

    rebebd38 r3abfe9a8  
    2525        .mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)): AT (SIZEOF(.unmapped)) {
    2626                ktext_start = .;
    27                 *(.text);
     27                *(.text .text.*);
    2828                ktext_end = .;
    2929               
    3030                kdata_start = .;
    3131                *(.data);               /* initialized data */
    32                 *(.rodata*);            /* string literals */
     32                *(.rodata .rodata.*);   /* string literals */
    3333                *(COMMON);              /* global variables */
    3434                hardcoded_load_address = .;
  • kernel/arch/ia32/src/asm.S

    rebebd38 r3abfe9a8  
    3838.global paging_on
    3939.global enable_l_apic_in_msr
    40 .global memsetb
    41 .global memsetw
    42 .global memcpy
    4340.global memcpy_from_uspace
    4441.global memcpy_from_uspace_failover_address
     
    4744.global early_putchar
    4845
    49 /* Wrapper for generic memsetb */
    50 memsetb:
    51         jmp _memsetb
    52 
    53 /* Wrapper for generic memsetw */
    54 memsetw:
    55         jmp _memsetw
    56 
    5746#define MEMCPY_DST   4
    5847#define MEMCPY_SRC   8
     
    7463 *
    7564 */
    76 memcpy:
    7765memcpy_from_uspace:
    7866memcpy_to_uspace:
  • kernel/arch/ia32/src/cpu/cpu.c

    rebebd38 r3abfe9a8  
    9292void cpu_arch_init(void)
    9393{
    94         cpuid_extended_feature_info efi;
    9594        cpu_info_t info;
    9695        uint32_t help = 0;
     
    104103       
    105104        CPU->arch.fi.word = info.cpuid_edx;
    106         efi.word = info.cpuid_ecx;
    107105       
    108106        if (CPU->arch.fi.bits.fxsr)
  • kernel/arch/ia64/_link.ld.in

    rebebd38 r3abfe9a8  
    1616                ktext_start = .;
    1717                *(K_TEXT_START);
    18                 *(.text)
     18                *(.text .text.*)
    1919                ktext_end = .;
    2020               
     
    3636                *(.bss)
    3737                *(COMMON);
    38 
     38               
    3939                . = ALIGN(8);
    40                 symbol_table = .;
    41                 *(symtab.*);            /* Symbol table, must be LAST symbol!*/
    42 
     40                symbol_table = .;
     41                *(symtab.*);            /* Symbol table, must be LAST symbol!*/
     42               
    4343                kdata_end = .;
    4444        }
    45 
     45       
    4646        /DISCARD/ : {
    4747                *(*);
    4848        }
    49 
    5049}
  • kernel/arch/ia64/src/asm.S

    rebebd38 r3abfe9a8  
    3030
    3131.text
    32 .global memcpy
    3332.global memcpy_from_uspace
    3433.global memcpy_to_uspace
     
    3938 *
    4039 * This memcpy() has been taken from the assembler output of
    41  * the generic _memcpy() and modified to have the failover part.
     40 * a plain C implementation of memcpy() modified to have the
     41 * failover part.
    4242 *
    4343 * @param in0 Destination address.
     
    4646 *
    4747 */
    48 memcpy:
    4948memcpy_from_uspace:
    5049memcpy_to_uspace:
     
    141140        br.ret.sptk.many rp
    142141
    143 .global memsetb
    144 memsetb:
    145         br _memsetb
    146 
    147 .global memsetw
    148 memsetw:
    149         br _memsetw
    150 
    151142.global cpu_halt
    152143cpu_halt:
  • kernel/arch/ia64/src/mm/tlb.c

    rebebd38 r3abfe9a8  
    475475void alternate_instruction_tlb_fault(uint64_t vector, istate_t *istate)
    476476{
    477         region_register_t rr;
    478         rid_t rid;
    479477        uintptr_t va;
    480478        pte_t *t;
    481479       
    482480        va = istate->cr_ifa; /* faulting address */
    483         rr.word = rr_read(VA2VRN(va));
    484         rid = rr.map.rid;
    485481       
    486482        page_table_lock(AS, true);
     
    649645void data_dirty_bit_fault(uint64_t vector, istate_t *istate)
    650646{
    651         region_register_t rr;
    652         rid_t rid;
    653647        uintptr_t va;
    654648        pte_t *t;
    655649       
    656650        va = istate->cr_ifa;  /* faulting address */
    657         rr.word = rr_read(VA2VRN(va));
    658         rid = rr.map.rid;
    659651       
    660652        page_table_lock(AS, true);
     
    686678void instruction_access_bit_fault(uint64_t vector, istate_t *istate)
    687679{
    688         region_register_t rr;
    689         rid_t rid;
    690680        uintptr_t va;
    691681        pte_t *t;
    692682       
    693683        va = istate->cr_ifa;  /* faulting address */
    694         rr.word = rr_read(VA2VRN(va));
    695         rid = rr.map.rid;
    696684       
    697685        page_table_lock(AS, true);
     
    723711void data_access_bit_fault(uint64_t vector, istate_t *istate)
    724712{
    725         region_register_t rr;
    726         rid_t rid;
    727713        uintptr_t va;
    728714        pte_t *t;
    729715       
    730716        va = istate->cr_ifa;  /* faulting address */
    731         rr.word = rr_read(VA2VRN(va));
    732         rid = rr.map.rid;
    733717       
    734718        page_table_lock(AS, true);
     
    760744void data_access_rights_fault(uint64_t vector, istate_t *istate)
    761745{
    762         region_register_t rr;
    763         rid_t rid;
    764746        uintptr_t va;
    765747        pte_t *t;
    766748       
    767749        va = istate->cr_ifa;  /* faulting address */
    768         rr.word = rr_read(VA2VRN(va));
    769         rid = rr.map.rid;
    770750       
    771751        /*
     
    792772void page_not_present(uint64_t vector, istate_t *istate)
    793773{
    794         region_register_t rr;
    795         rid_t rid;
    796774        uintptr_t va;
    797775        pte_t *t;
    798776       
    799777        va = istate->cr_ifa;  /* faulting address */
    800         rr.word = rr_read(VA2VRN(va));
    801         rid = rr.map.rid;
    802778       
    803779        page_table_lock(AS, true);
  • kernel/arch/mips32/src/asm.S

    rebebd38 r3abfe9a8  
    5757        nop
    5858
    59 .global memsetb
    60 memsetb:
    61         j _memsetb
    62         nop
    63 
    64 .global memsetw
    65 memsetw:
    66         j _memsetw
    67         nop
    68 
    69 .global memcpy
    7059.global memcpy_from_uspace
    7160.global memcpy_to_uspace
    7261.global memcpy_from_uspace_failover_address
    7362.global memcpy_to_uspace_failover_address
    74 memcpy:
    7563memcpy_from_uspace:
    7664memcpy_to_uspace:
  • kernel/arch/ppc32/_link.ld.in

    rebebd38 r3abfe9a8  
    3636                kdata_start = .;
    3737                *(K_DATA_START);
    38                 *(.rodata);
    39                 *(.rodata.*);
     38                *(.rodata .rodata.*);
    4039                *(.data);       /* initialized data */
    4140                *(.sdata);
  • kernel/arch/ppc32/src/asm.S

    rebebd38 r3abfe9a8  
    3535.global iret
    3636.global iret_syscall
    37 .global memsetb
    38 .global memsetw
    39 .global memcpy
    4037.global memcpy_from_uspace
    4138.global memcpy_to_uspace
     
    208205        rfi
    209206
    210 memsetb:
    211         b _memsetb
    212 
    213 memsetw:
    214         b _memsetw
    215 
    216 memcpy:
    217207memcpy_from_uspace:
    218208memcpy_to_uspace:
  • kernel/arch/sparc64/_link.ld.in

    rebebd38 r3abfe9a8  
    1515                ktext_start = .;
    1616                *(K_TEXT_START)
    17                 *(.text);
     17                *(.text .text.*);
    1818                ktext_end = .;
    1919               
    2020                kdata_start = .;
    2121                *(K_DATA_START)
    22                 *(.rodata);
    23                 *(.rodata.*);
     22                *(.rodata .rodata.*);
    2423                *(.data);                   /* initialized data */
    2524                *(.sdata);
  • kernel/arch/sparc64/src/asm.S

    rebebd38 r3abfe9a8  
    3434.register %g2, #scratch
    3535.register %g3, #scratch
    36 
    37 /*
    38  * This is the assembly language version of our _memcpy() generated by gcc.
    39  */
    40 .global memcpy
    41 memcpy:
    42         mov %o0, %o3  /* save dst */
    43         add %o1, 7, %g1
    44         and %g1, -8, %g1
    45         cmp %o1, %g1
    46         be,pn %xcc, 3f
    47         add %o0, 7, %g1
    48         mov 0, %g3
    49        
    50         0:
    51        
    52                 brz,pn %o2, 2f
    53                 mov 0, %g2
    54        
    55         1:
    56        
    57                 ldub [%g3 + %o1], %g1
    58                 add %g2, 1, %g2
    59                 cmp %o2, %g2
    60                 stb %g1, [%g3 + %o0]
    61                 bne,pt %xcc, 1b
    62                 mov %g2, %g3
    63        
    64         2:
    65        
    66                 jmp %o7 + 8  /* exit point */
    67                 mov %o3, %o0
    68        
    69         3:
    70        
    71                 and %g1, -8, %g1
    72                 cmp %o0, %g1
    73                 bne,pt %xcc, 0b
    74                 mov 0, %g3
    75                 srlx %o2, 3, %g4
    76                 brz,pn %g4, 5f
    77                 mov 0, %g5
    78        
    79         4:
    80        
    81                 sllx %g3, 3, %g2
    82                 add %g5, 1, %g3
    83                 ldx [%o1 + %g2], %g1
    84                 mov %g3, %g5
    85                 cmp %g4, %g3
    86                 bne,pt %xcc, 4b
    87                 stx %g1, [%o0 + %g2]
    88        
    89         5:
    90        
    91                 and %o2, 7, %o2
    92                 brz,pn %o2, 2b
    93                 sllx %g4, 3, %g1
    94                 mov 0, %g2
    95                 add %g1, %o0, %o0
    96                 add %g1, %o1, %g4
    97                 mov 0, %g3
    98        
    99         6:
    100        
    101                 ldub [%g2 + %g4], %g1
    102                 stb %g1, [%g2 + %o0]
    103                 add %g3, 1, %g2
    104                 cmp %o2, %g2
    105                 bne,pt %xcc, 6b
    106                 mov %g2, %g3
    107                
    108                 jmp %o7 + 8  /* exit point */
    109                 mov %o3, %o0
    11036
    11137/*
     
    264190        mov %g0, %o0  /* return 0 on failure */
    265191
    266 .global memsetb
    267 memsetb:
    268         ba %xcc, _memsetb
    269         nop
    270 
    271 .global memsetw
    272 memsetw:
    273         ba %xcc, _memsetw
    274         nop
    275 
    276192.global early_putchar
    277193early_putchar:
  • kernel/arch/sparc64/src/mm/sun4u/as.c

    rebebd38 r3abfe9a8  
    4343
    4444#include <arch/mm/tsb.h>
    45 #include <arch/memstr.h>
    4645#include <arch/asm.h>
    4746#include <mm/frame.h>
  • kernel/arch/sparc64/src/mm/sun4v/as.c

    rebebd38 r3abfe9a8  
    4646
    4747#include <arch/mm/tsb.h>
    48 #include <arch/memstr.h>
    4948#include <arch/asm.h>
    5049#include <mm/frame.h>
  • kernel/genarch/src/drivers/via-cuda/cuda.c

    rebebd38 r3abfe9a8  
    239239        cuda_instance_t *instance = irq->instance;
    240240        cuda_t *dev = instance->cuda;
    241         uint8_t data, b;
    242 
     241        uint8_t b;
     242       
    243243        b = pio_read_8(&dev->b);
    244         data = pio_read_8(&dev->sr);
    245 
     244        pio_read_8(&dev->sr);
     245       
    246246        if ((b & TREQ) == 0) {
    247247                instance->xstate = cx_receive;
     
    251251                cuda_send_start(instance);
    252252        }
    253 
    254         memcpy(buf, instance->rcv_buf, instance->bidx);
    255         *len = instance->bidx;
     253       
     254        memcpy(buf, instance->rcv_buf, instance->bidx);
     255        *len = instance->bidx;
    256256        instance->bidx = 0;
    257257}
  • kernel/genarch/src/ofw/ebus.c

    rebebd38 r3abfe9a8  
    3939#include <genarch/ofw/ebus.h>
    4040#include <genarch/ofw/pci.h>
    41 #include <arch/memstr.h>
    4241#include <str.h>
    4342#include <panic.h>
  • kernel/genarch/src/ofw/fhc.c

    rebebd38 r3abfe9a8  
    3939#include <genarch/ofw/fhc.h>
    4040#include <arch/drivers/fhc.h>
    41 #include <arch/memstr.h>
    4241#include <str.h>
    4342#include <panic.h>
  • kernel/genarch/src/ofw/ofw_tree.c

    rebebd38 r3abfe9a8  
    3737
    3838#include <genarch/ofw/ofw_tree.h>
    39 #include <arch/memstr.h>
    4039#include <mm/slab.h>
     40#include <memstr.h>
    4141#include <str.h>
    4242#include <panic.h>
  • kernel/genarch/src/ofw/pci.c

    rebebd38 r3abfe9a8  
    4040#include <arch/drivers/pci.h>
    4141#include <arch/trap/interrupt.h>
    42 #include <arch/memstr.h>
    4342#include <str.h>
    4443#include <panic.h>
  • kernel/genarch/src/ofw/upa.c

    rebebd38 r3abfe9a8  
    3838#include <genarch/ofw/ofw_tree.h>
    3939#include <genarch/ofw/upa.h>
    40 #include <arch/memstr.h>
    4140#include <func.h>
    4241#include <panic.h>
  • kernel/generic/include/lib/memfnc.h

    rebebd38 r3abfe9a8  
    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

    rebebd38 r3abfe9a8  
    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/lib/memfnc.c

    rebebd38 r3abfe9a8  
    1 /*
    2  * Copyright (c) 2005 Sergey Bondari
     1        /*
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup amd64
     29/** @addtogroup generic
    3030 * @{
    3131 */
    32 /** @file
     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.
    3340 */
    3441
    35 #ifndef KERN_amd64_MEMSTR_H_
    36 #define KERN_amd64_MEMSTR_H_
     42#include <lib/memfnc.h>
     43#include <typedefs.h>
    3744
    38 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     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}
    3966
    40 extern void memsetw(void *, size_t, uint16_t);
    41 extern void memsetb(void *, size_t, uint8_t);
    42 
    43 #endif
     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}
    4489
    4590/** @}
  • kernel/generic/src/lib/memstr.c

    rebebd38 r3abfe9a8  
    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
  • tools/autotool.py

    rebebd38 r3abfe9a8  
    501501                cross_prefix = os.environ['CROSS_PREFIX']
    502502        else:
    503                 cross_prefix = "/usr/local"
     503                cross_prefix = "/usr/local/cross"
    504504       
    505505        # Prefix binutils tools on Solaris
  • tools/toolchain.sh

    rebebd38 r3abfe9a8  
    5252#endif
    5353EOF
     54
     55BINUTILS_VERSION="2.21"
     56GCC_VERSION="4.6.0"
     57
     58BASEDIR="`pwd`"
     59BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
     60GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
     61GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
     62GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
    5463
    5564#
     
    139148        echo " sparc64    SPARC V9"
    140149        echo " all        build all targets"
     150        echo " parallel   same as 'all', but in parallel"
    141151        echo
    142152        echo "The toolchain will be installed to the directory specified by"
    143153        echo "the CROSS_PREFIX environment variable. If the variable is not"
    144         echo "defined, /usr/local will be used by default."
     154        echo "defined, /usr/local/cross will be used by default."
    145155        echo
    146156       
     
    194204}
    195205
    196 download_check() {
     206download_fetch() {
    197207        SOURCE="$1"
    198208        FILE="$2"
     
    208218}
    209219
     220source_check() {
     221        FILE="$1"
     222       
     223        if [ ! -f "${FILE}" ]; then
     224                echo
     225                echo "File ${FILE} not found."
     226               
     227                exit 4
     228        fi
     229}
     230
    210231cleanup_dir() {
    211232        DIR="$1"
     
    241262}
    242263
    243 patch_binutils() {
    244         PLATFORM="$1"
    245        
    246         if [ "${PLATFORM}" == "arm32" ] ; then
    247                 patch -p1 <<EOF
    248 diff -Naur binutils-2.20.orig/gas/config/tc-arm.c binutils-2.20/gas/config/tc-arm.c
    249 --- binutils-2.20.orig/gas/config/tc-arm.c      2009-08-30 00:10:59.000000000 +0200
    250 +++ binutils-2.20/gas/config/tc-arm.c   2009-11-02 14:25:11.000000000 +0100
    251 @@ -2485,8 +2485,9 @@
    252        know (frag->tc_frag_data.first_map == NULL);
    253        frag->tc_frag_data.first_map = symbolP;
    254      }
    255 -  if (frag->tc_frag_data.last_map != NULL)
    256 +  if (frag->tc_frag_data.last_map != NULL) {
    257      know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));
    258 +  }
    259    frag->tc_frag_data.last_map = symbolP;
    260  }
    261 EOF
    262                 check_error $? "Error patching binutils"
    263         fi
     264prepare() {
     265        show_dependencies
     266        check_dependecies
     267        show_countdown 10
     268       
     269        BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
     270        GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
     271       
     272        download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "c84c5acc9d266f1a7044b51c85a823f5"
     273        download_fetch "${GCC_SOURCE}" "${GCC_CORE}" "b1957f3209080b2f55bc3756d3a62b7c"
     274        download_fetch "${GCC_SOURCE}" "${GCC_OBJC}" "120d4675366ee82ea52f9ed65b57da04"
     275        download_fetch "${GCC_SOURCE}" "${GCC_CPP}" "a30090fa655d0db4c970740d353c81f1"
    264276}
    265277
     
    268280        TARGET="$2"
    269281       
    270         BINUTILS_VERSION="2.20"
    271         GCC_VERSION="4.5.1"
    272        
    273         BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
    274         GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
    275         GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
    276         GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
    277        
    278         BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
    279         GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
    280        
    281         WORKDIR="`pwd`"
     282        WORKDIR="${BASEDIR}/${PLATFORM}"
    282283        BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
    283284        GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
     
    285286       
    286287        if [ -z "${CROSS_PREFIX}" ] ; then
    287                 CROSS_PREFIX="/usr/local"
     288                CROSS_PREFIX="/usr/local/cross"
    288289        fi
    289290       
     
    291292       
    292293        echo ">>> Downloading tarballs"
    293         download_check "${BINUTILS_SOURCE}" "${BINUTILS}" "ee2d3e996e9a2d669808713360fa96f8"
    294         download_check "${GCC_SOURCE}" "${GCC_CORE}" "dc8959e31b01a65ce10d269614815054"
    295         download_check "${GCC_SOURCE}" "${GCC_OBJC}" "3c11b7037896e967eddf8178af2ddd98"
    296         download_check "${GCC_SOURCE}" "${GCC_CPP}" "b294953ff0bb2f20c7acb2bf005d832a"
     294        source_check "${BASEDIR}/${BINUTILS}"
     295        source_check "${BASEDIR}/${GCC_CORE}"
     296        source_check "${BASEDIR}/${GCC_OBJC}"
     297        source_check "${BASEDIR}/${GCC_CPP}"
    297298       
    298299        echo ">>> Removing previous content"
    299300        cleanup_dir "${PREFIX}"
    300         cleanup_dir "${OBJDIR}"
    301         cleanup_dir "${BINUTILSDIR}"
    302         cleanup_dir "${GCCDIR}"
     301        cleanup_dir "${WORKDIR}"
    303302       
    304303        create_dir "${PREFIX}" "destination directory"
     
    306305       
    307306        echo ">>> Unpacking tarballs"
    308         unpack_tarball "${BINUTILS}" "binutils"
    309         unpack_tarball "${GCC_CORE}" "GCC Core"
    310         unpack_tarball "${GCC_OBJC}" "Objective C"
    311         unpack_tarball "${GCC_CPP}" "C++"
     307        cd "${WORKDIR}"
     308        check_error $? "Change directory failed."
     309       
     310        unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
     311        unpack_tarball "${BASEDIR}/${GCC_CORE}" "GCC Core"
     312        unpack_tarball "${BASEDIR}/${GCC_OBJC}" "Objective C"
     313        unpack_tarball "${BASEDIR}/${GCC_CPP}" "C++"
    312314       
    313315        echo ">>> Processing binutils (${PLATFORM})"
    314316        cd "${BINUTILSDIR}"
    315317        check_error $? "Change directory failed."
    316         patch_binutils "${PLATFORM}"
    317318       
    318319        change_title "binutils: configure (${PLATFORM})"
     
    336337        check_error $? "Error compiling/installing GCC."
    337338       
    338         cd "${WORKDIR}"
     339        cd "${BASEDIR}"
    339340        check_error $? "Change directory failed."
    340341       
    341342        echo ">>> Cleaning up"
    342         cleanup_dir "${OBJDIR}"
    343         cleanup_dir "${BINUTILSDIR}"
    344         cleanup_dir "${GCCDIR}"
     343        cleanup_dir "${WORKDIR}"
    345344       
    346345        echo
     
    352351fi
    353352
    354 show_dependencies
    355 check_dependecies
    356 show_countdown 10
    357 
    358353case "$1" in
    359354        "amd64")
     355                prepare
    360356                build_target "amd64" "amd64-linux-gnu"
    361357                ;;
    362358        "arm32")
     359                prepare
    363360                build_target "arm32" "arm-linux-gnu"
    364361                ;;
    365362        "ia32")
     363                prepare
    366364                build_target "ia32" "i686-pc-linux-gnu"
    367365                ;;
    368366        "ia64")
     367                prepare
    369368                build_target "ia64" "ia64-pc-linux-gnu"
    370369                ;;
    371         "ia64")
    372                 build_target "ia64" "ia64-pc-linux-gnu"
    373                 ;;
    374370        "mips32")
     371                prepare
    375372                build_target "mips32" "mipsel-linux-gnu"
    376373                ;;
    377374        "mips32eb")
     375                prepare
    378376                build_target "mips32eb" "mips-linux-gnu"
    379377                ;;
    380378        "mips64")
     379                prepare
    381380                build_target "mips64" "mips64el-linux-gnu"
    382381                ;;
    383382        "ppc32")
     383                prepare
    384384                build_target "ppc32" "ppc-linux-gnu"
    385385                ;;
    386386        "ppc64")
     387                prepare
    387388                build_target "ppc64" "ppc64-linux-gnu"
    388389                ;;
    389390        "sparc64")
     391                prepare
    390392                build_target "sparc64" "sparc64-linux-gnu"
    391393                ;;
    392394        "all")
     395                prepare
    393396                build_target "amd64" "amd64-linux-gnu"
    394397                build_target "arm32" "arm-linux-gnu"
    395398                build_target "ia32" "i686-pc-linux-gnu"
    396                 build_target "ia64" "ia64-pc-linux-gnu"
    397399                build_target "ia64" "ia64-pc-linux-gnu"
    398400                build_target "mips32" "mipsel-linux-gnu"
     
    403405                build_target "sparc64" "sparc64-linux-gnu"
    404406                ;;
     407        "parallel")
     408                prepare
     409                build_target "amd64" "amd64-linux-gnu" &
     410                build_target "arm32" "arm-linux-gnu" &
     411                build_target "ia32" "i686-pc-linux-gnu" &
     412                build_target "ia64" "ia64-pc-linux-gnu" &
     413                build_target "mips32" "mipsel-linux-gnu" &
     414                build_target "mips32eb" "mips-linux-gnu" &
     415                build_target "mips64" "mips64el-linux-gnu" &
     416                build_target "ppc32" "ppc-linux-gnu" &
     417                build_target "ppc64" "ppc64-linux-gnu" &
     418                build_target "sparc64" "sparc64-linux-gnu" &
     419                wait
     420                ;;
    405421        *)
    406422                show_usage
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    rebebd38 r3abfe9a8  
    164164{
    165165        int fd, bytes = 0, count = 0, reads = 0;
    166         off64_t total = 0;
    167166        char *buff = NULL;
    168167        int i;
     
    174173                return 1;
    175174        }
    176 
    177         total = lseek(fd, 0, SEEK_END);
    178         lseek(fd, 0, SEEK_SET);
    179175
    180176        if (NULL == (buff = (char *) malloc(blen + 1))) {
  • uspace/app/sbi/src/run_expr.c

    rebebd38 r3abfe9a8  
    25292529        if (rc1 == EOK)
    25302530                rc2 = os_str_get_char(string->value, elem_index, &cval);
     2531        else
     2532                rc2 = EOK;
    25312533
    25322534        if (rc1 != EOK || rc2 != EOK) {
  • uspace/app/tester/fault/fault2.c

    rebebd38 r3abfe9a8  
    2929
    3030#include "../tester.h"
     31#include <stdio.h>
    3132
    3233typedef int __attribute__((may_alias)) aliasing_int;
     
    3839       
    3940        var1 = *((aliasing_int *) (((char *) (&var)) + 1));
     41        printf("Read %d\n", var1);
    4042       
    4143        return "Survived unaligned read";
  • uspace/app/trace/trace.c

    rebebd38 r3abfe9a8  
    872872static display_mask_t parse_display_mask(const char *text)
    873873{
    874         display_mask_t dm;
     874        display_mask_t dm = 0;
    875875        const char *c = text;
    876876       
  • uspace/lib/c/arch/abs32le/_link.ld.in

    rebebd38 r3abfe9a8  
    1111       
    1212        .text : {
    13                 *(.text);
    14                 *(.rodata*);
     13                *(.text .text.*);
     14                *(.rodata .rodata.*);
    1515        } :text
    1616       
  • uspace/lib/c/arch/amd64/_link.ld.in

    rebebd38 r3abfe9a8  
    1616       
    1717        .text : {
    18                 *(.text);
    19                 *(.rodata*);
     18                *(.text .text.*);
     19                *(.rodata .rodata.*);
    2020        } :text
    2121       
  • uspace/lib/c/arch/arm32/_link.ld.in

    rebebd38 r3abfe9a8  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/arch/ia32/_link.ld.in

    rebebd38 r3abfe9a8  
    1616       
    1717        .text : {
    18                 *(.text);
    19                 *(.rodata*);
     18                *(.text .text.*);
     19                *(.rodata .rodata.*);
    2020        } :text
    2121       
  • uspace/lib/c/arch/ia64/_link.ld.in

    rebebd38 r3abfe9a8  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
     
    2323        .got : {
    2424                _gp = .;
    25                 *(.got*);
     25                *(.got .got.*);
    2626        } :data
    2727       
  • uspace/lib/c/arch/mips32/_link.ld.in

    rebebd38 r3abfe9a8  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/arch/ppc32/_link.ld.in

    rebebd38 r3abfe9a8  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/arch/sparc64/_link.ld.in

    rebebd38 r3abfe9a8  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/generic/vfs/vfs.c

    rebebd38 r3abfe9a8  
    756756{
    757757        struct stat stat;
    758         int rc;
    759 
    760         rc = fstat(fildes, &stat);
    761 
     758       
     759        int rc = fstat(fildes, &stat);
     760        if (rc != 0)
     761                return rc;
     762       
    762763        if (!stat.device)
    763764                return -1;
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.c

    rebebd38 r3abfe9a8  
    367367static void cuda_irq_rcv_end(void *buf, size_t *len)
    368368{
    369         uint8_t data, b;
    370 
     369        uint8_t b;
     370       
    371371        b = pio_read_8(&dev->b);
    372         data = pio_read_8(&dev->sr);
    373 
     372        pio_read_8(&dev->sr);
     373       
    374374        if ((b & TREQ) == 0) {
    375375                instance->xstate = cx_receive;
     
    379379                cuda_send_start();
    380380        }
    381 
    382         memcpy(buf, instance->rcv_buf, instance->bidx);
    383         *len = instance->bidx;
     381       
     382        memcpy(buf, instance->rcv_buf, instance->bidx);
     383        *len = instance->bidx;
    384384        instance->bidx = 0;
    385385}
  • uspace/srv/loader/arch/abs32le/_link.ld.in

    rebebd38 r3abfe9a8  
    2121       
    2222        .text : {
    23                 *(.text);
    24                 *(.rodata*);
     23                *(.text .text.*);
     24                *(.rodata .rodata.*);
    2525        } :text
    2626       
  • uspace/srv/loader/arch/amd64/_link.ld.in

    rebebd38 r3abfe9a8  
    2727       
    2828        .text : {
    29                 *(.text);
    30                 *(.rodata*);
     29                *(.text .text.*);
     30                *(.rodata .rodata.*);
    3131        } :text
    3232       
  • uspace/srv/loader/arch/arm32/_link.ld.in

    rebebd38 r3abfe9a8  
    2525       
    2626        .text : {
    27                 *(.text);
    28                 *(.rodata*);
     27                *(.text .text.*);
     28                *(.rodata .rodata.*);
    2929        } :text
    3030       
  • uspace/srv/loader/arch/ia32/_link.ld.in

    rebebd38 r3abfe9a8  
    2626       
    2727        .text : {
    28                 *(.text);
    29                 *(.rodata*);
     28                *(.text .text.*);
     29                *(.rodata .rodata.*);
    3030        } :text
    3131       
  • uspace/srv/loader/arch/ia64/_link.ld.in

    rebebd38 r3abfe9a8  
    2121       
    2222        .text : {
    23                 *(.text);
    24                 *(.rodata*);
     23                *(.text .text.*);
     24                *(.rodata .rodata.*);
    2525        } :text
    2626       
     
    2929        .got : {
    3030                _gp = .;
    31                 *(.got*);
     31                *(.got .got.*);
    3232        } :data
    3333       
  • uspace/srv/loader/arch/mips32/_link.ld.in

    rebebd38 r3abfe9a8  
    2525       
    2626        .text : {
    27                 *(.text);
    28                 *(.rodata*);
     27                *(.text .text.*);
     28                *(.rodata .rodata.*);
    2929        } :text
    3030       
  • uspace/srv/loader/arch/ppc32/_link.ld.in

    rebebd38 r3abfe9a8  
    2525       
    2626        .text : {
    27                 *(.text);
    28                 *(.rodata*);
     27                *(.text .text.*);
     28                *(.rodata .rodata.*);
    2929        } :text
    3030       
  • uspace/srv/loader/arch/sparc64/_link.ld.in

    rebebd38 r3abfe9a8  
    2020       
    2121        .text : {
    22                 *(.text);
    23                 *(.rodata*);
     22                *(.text .text.*);
     23                *(.rodata .rodata.*);
    2424        } :text
    2525       
  • uspace/srv/loader/main.c

    rebebd38 r3abfe9a8  
    407407                        /* Not reached */
    408408                default:
    409                         retval = ENOENT;
     409                        retval = EINVAL;
    410410                        break;
    411411                }
    412                 if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) {
    413                         DPRINTF("Responding EINVAL to method %d.\n",
    414                             IPC_GET_IMETHOD(call));
    415                         async_answer_0(callid, EINVAL);
    416                 }
     412               
     413                if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP)
     414                        async_answer_0(callid, retval);
    417415        }
    418416}
Note: See TracChangeset for help on using the changeset viewer.