Rev 1278 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1278 | Rev 1288 | ||
---|---|---|---|
Line 58... | Line 58... | ||
58 | 58 | ||
59 | panic_printf: |
59 | panic_printf: |
60 | movq $halt, (%rsp) |
60 | movq $halt, (%rsp) |
61 | jmp printf |
61 | jmp printf |
62 | 62 | ||
63 | .global memcpy |
- | |
64 | memcpy: |
- | |
65 | jmp _memcpy |
- | |
66 | - | ||
67 | .global cpuid |
63 | .global cpuid |
68 | .global has_cpuid |
64 | .global has_cpuid |
69 | .global rdtsc |
65 | .global rdtsc |
70 | .global read_efer_flag |
66 | .global read_efer_flag |
71 | .global set_efer_flag |
67 | .global set_efer_flag |
- | 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 | */ |
|
- | 93 | memcpy: |
|
- | 94 | memcpy_from_uspace: |
|
- | 95 | memcpy_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 |
|
72 | 106 | ||
- | 107 | rep movsb /* copy the rest byte by byte */ |
|
- | 108 | ||
- | 109 | 0: |
|
- | 110 | ret /* return MEMCPY_SRC, success */ |
|
- | 111 | ||
- | 112 | memcpy_from_uspace_failover_address: |
|
- | 113 | memcpy_to_uspace_failover_address: |
|
- | 114 | xorq %rax, %rax /* return 0, failure */ |
|
- | 115 | ret |
|
- | 116 | ||
73 | ## Determine CPUID support |
117 | ## Determine CPUID support |
74 | # |
118 | # |
75 | # Return 0 in EAX if CPUID is not support, 1 if supported. |
119 | # Return 0 in EAX if CPUID is not support, 1 if supported. |
76 | # |
120 | # |
77 | has_cpuid: |
121 | has_cpuid: |