*/
#include <mach_rt.h>
-#include <platforms.h>
-#include <mach_kdb.h>
-#include <mach_kgdb.h>
#include <mach_kdp.h>
-#include <stat_time.h>
#include <mach_assert.h>
#include <sys/errno.h>
#define _ARCH_I386_ASM_HELP_H_ /* Prevent inclusion of user header */
#include <mach/i386/syscall_sw.h>
-#include <i386/mp.h>
-
/*
* Fault recovery.
*/
rdmsr_fail:
movq $1, %rax
ret
+/*
+ * int rdmsr64_carefully(uint32_t msr, uint64_t *val);
+ */
+
+ENTRY(rdmsr64_carefully)
+ movl %edi, %ecx
+ RECOVERY_SECTION
+ RECOVER(rdmsr64_carefully_fail)
+ rdmsr
+ movl %eax, (%rsi)
+ movl %edx, 4(%rsi)
+ xorl %eax, %eax
+ ret
+rdmsr64_carefully_fail:
+ movl $1, %eax
+ ret
+/*
+ * int wrmsr64_carefully(uint32_t msr, uint64_t val);
+ */
+
+ENTRY(wrmsr_carefully)
+ movl %edi, %ecx
+ movl %esi, %eax
+ shr $32, %rsi
+ movl %esi, %edx
+ RECOVERY_SECTION
+ RECOVER(wrmsr_fail)
+ wrmsr
+ xorl %eax, %eax
+ ret
+wrmsr_fail:
+ movl $1, %eax
+ ret
.globl EXT(thread_exception_return)
.globl EXT(thread_bootstrap_return)
* Copyin/out from user/kernel address space.
* rdi: source address
* rsi: destination address
- * rdx: byte count
+ * rdx: byte count (in fact, always < 64MB -- see copyio)
*/
Entry(_bcopy)
-// TODO not pop regs; movq; think about 32 bit or 64 bit byte count
- xchgq %rdi, %rsi /* source %rsi, dest %rdi */
+ xchg %rdi, %rsi /* source %rsi, dest %rdi */
cld /* count up */
- movl %edx,%ecx /* move by longwords first */
- shrl $3,%ecx
+ mov %rdx, %rcx /* move by longwords first */
+ shr $3, %rcx
RECOVERY_SECTION
RECOVER(_bcopy_fail)
rep
movsq /* move longwords */
- movl %edx,%ecx /* now move remaining bytes */
- andl $7,%ecx
+ movl %edx, %ecx /* now move remaining bytes */
+ andl $7, %ecx
RECOVERY_SECTION
RECOVER(_bcopy_fail)
rep
xor %eax, %eax
ret
+/*
+ * 2-byte copy used by ml_copy_phys().
+ * rdi: source address
+ * rsi: destination address
+ */
+Entry(_bcopy2)
+ RECOVERY_SECTION
+ RECOVER(_bcopy_fail)
+ movw (%rdi), %cx
+ RECOVERY_SECTION
+ RECOVER(_bcopy_fail)
+ movw %cx, (%rsi)
+
+ xorl %eax,%eax /* return 0 for success */
+ ret /* and return */
+
+/*
+ * 4-byte copy used by ml_copy_phys().
+ * rdi: source address
+ * rsi: destination address
+ */
+Entry(_bcopy4)
+ RECOVERY_SECTION
+ RECOVER(_bcopy_fail)
+ movl (%rdi), %ecx
+ RECOVERY_SECTION
+ RECOVER(_bcopy_fail)
+ mov %ecx, (%rsi)
+
+ xorl %eax,%eax /* return 0 for success */
+ ret /* and return */
+
+/*
+ * 8-byte copy used by ml_copy_phys().
+ * rdi: source address
+ * rsi: destination address
+ */
+Entry(_bcopy8)
+ RECOVERY_SECTION
+ RECOVER(_bcopy_fail)
+ movq (%rdi), %rcx
+ RECOVERY_SECTION
+ RECOVER(_bcopy_fail)
+ mov %rcx, (%rsi)
+
+ xorl %eax,%eax /* return 0 for success */
+ ret /* and return */
+
/*