Changeset e3c762cd in mainline for arch/amd64/src/asm_utils.S


Ignore:
Timestamp:
2006-05-05T11:59:19Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
de07bcf
Parents:
22cf454d
Message:

Complete implementation of copy_from_uspace() and copy_to_uspace()
for amd64 and ia32. Other architectures still compile and run,
but need to implement their own assembly-only memcpy(), memcpy_from_uspace(),
memcpy_to_uspace() and their failover parts. For these architectures
only dummy implementations are provided.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/src/asm_utils.S

    r22cf454d re3c762cd  
    6161        jmp printf
    6262
    63 .global memcpy
    64 memcpy:
    65         jmp _memcpy
    66        
    6763.global cpuid
    6864.global has_cpuid
     
    7066.global read_efer_flag
    7167.global set_efer_flag
    72        
     68.global memcpy
     69.global memcpy_from_uspace
     70.global memcpy_to_uspace
     71.global memcpy_from_uspace_failover_address
     72.global memcpy_to_uspace_failover_address
     73
     74#define MEMCPY_DST      %rdi
     75#define MEMCPY_SRC      %rsi
     76#define MEMCPY_SIZE     %rdx
     77
     78/**
     79 * Copy memory from/to userspace.
     80 *
     81 * This is almost conventional memcpy().
     82 * The difference is that there is a failover part
     83 * to where control is returned from a page fault if
     84 * the page fault occurs during copy_from_uspace()
     85 * or copy_to_uspace().
     86 *
     87 * @param MEMCPY_DST    Destination address.
     88 * @param MEMCPY_SRC    Source address.
     89 * @param MEMCPY_SIZE   Number of bytes to copy.
     90 *
     91 * @retrun MEMCPY_SRC on success, 0 on failure.
     92 */
     93memcpy:
     94memcpy_from_uspace:
     95memcpy_to_uspace:
     96        movq MEMCPY_SRC, %rax
     97
     98        movq MEMCPY_SIZE, %rcx
     99        shrq $3, %rcx                   /* size / 8 */
     100       
     101        rep movsq                       /* copy as much as possible word by word */
     102
     103        movq MEMCPY_SIZE, %rcx
     104        andq $7, %rcx                   /* size % 8 */
     105        jz 0f
     106       
     107        rep movsb                       /* copy the rest byte by byte */
     108       
     1090:
     110        ret                             /* return MEMCPY_SRC, success */
     111
     112memcpy_from_uspace_failover_address:
     113memcpy_to_uspace_failover_address:
     114        xorq %rax, %rax                 /* return 0, failure */
     115        ret
     116
    73117## Determine CPUID support
    74118#
Note: See TracChangeset for help on using the changeset viewer.