Changeset 8a5a902 in mainline for kernel/arch/ia32/src/asm.S


Ignore:
Timestamp:
2013-03-29T16:26:39Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ca441c
Parents:
2d1195c0
Message:

GCC 4.8 recognizes parts of our C implementation of memset() and memcpy() and actually emits a call to memset() and memcpy()
(which is of course futile and only causes an infinite recursion)
switch to a hand-written memset() and memcpy()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/asm.S

    r2d1195c0 r8a5a902  
    3838.global paging_on
    3939.global enable_l_apic_in_msr
     40.global memset
     41.global memcpy
    4042.global memcpy_from_uspace
    4143.global memcpy_from_uspace_failover_address
     
    4446.global early_putchar
    4547
     48#define MEMSET_DST   4
     49#define MEMSET_VAL   8
     50#define MEMSET_SIZE  12
     51
    4652#define MEMCPY_DST   4
    4753#define MEMCPY_SRC   8
    4854#define MEMCPY_SIZE  12
     55
     56/* Fill memory with byte pattern
     57 *
     58 * This is a conventional memset().
     59 *
     60 * @param MEMSET_DST(%esp)  Destination address.
     61 * @param MEMSET_VAL(%esp)  Value to fill.
     62 * @param MEMSET_SIZE(%esp) Size.
     63 *
     64 * @return MEMSET_DST(%esp).
     65 *
     66 */
     67memset:
     68        movl %edi, %edx  /* save %edi */
     69       
     70        movl MEMSET_DST(%esp), %edi
     71        movl MEMSET_VAL(%esp), %ecx
     72       
     73        /* Create byte pattern */
     74        movb %cl, %ch
     75        movw %cx, %ax
     76        shll $16, %eax
     77        orw %cx, %ax
     78       
     79        movl MEMSET_SIZE(%esp), %ecx
     80        shrl $2, %ecx  /* size / 4 */
     81       
     82        /* Write whole words */
     83        rep stosl
     84       
     85        movl MEMSET_SIZE(%esp), %ecx
     86        andl $3, %ecx  /* size % 4 */
     87        jz 0f
     88       
     89        /* Copy the rest byte by byte */
     90        rep stosb
     91       
     92        0:
     93       
     94                movl %edx, %edi
     95               
     96                /* MEMSET_DST(%esp), success */
     97                movl MEMSET_DST(%esp), %eax
     98                ret
    4999
    50100/** Copy memory to/from userspace.
     
    63113 *
    64114 */
     115memcpy:
    65116memcpy_from_uspace:
    66117memcpy_to_uspace:
Note: See TracChangeset for help on using the changeset viewer.