x86_64-asm.S revision 1.6
11.6Smlelstv/*	$NetBSD: x86_64-asm.S,v 1.6 2019/05/10 16:42:57 mlelstv Exp $	*/
21.1Sad
31.1Sad/*-
41.1Sad * Copyright (c) 2007 The NetBSD Foundation, Inc.
51.1Sad * All rights reserved.
61.1Sad *
71.1Sad * Redistribution and use in source and binary forms, with or without
81.1Sad * modification, are permitted provided that the following conditions
91.1Sad * are met:
101.1Sad * 1. Redistributions of source code must retain the above copyright
111.1Sad *    notice, this list of conditions and the following disclaimer.
121.1Sad * 2. Redistributions in binary form must reproduce the above copyright
131.1Sad *    notice, this list of conditions and the following disclaimer in the
141.1Sad *    documentation and/or other materials provided with the distribution.
151.1Sad *
161.1Sad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
171.1Sad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
181.1Sad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
191.1Sad * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
201.1Sad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
211.1Sad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
221.1Sad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
231.1Sad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
241.1Sad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
251.1Sad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
261.1Sad * POSSIBILITY OF SUCH DAMAGE.
271.1Sad */
281.1Sad
291.1Sad#include <machine/asm.h>
301.1Sad
311.6Smlelstv/* From sys/arch/x86/include/cpufunc.h */
321.6Smlelstv#define	OPTERON_MSR_PASSCODE	0x9c5a203aU
331.6Smlelstv
341.1Sad	.text
351.1Sad
361.1SadENTRY(x86_cpuid2)
371.1Sad	pushq	%rbx
381.1Sad	movq	%rdi, %rax
391.1Sad	movq	%rsi, %rcx
401.1Sad	movq	%rdx, %rsi
411.1Sad	cpuid
421.1Sad	movl	%eax, 0(%rsi)
431.1Sad	movl	%ebx, 4(%rsi)
441.1Sad	movl	%ecx, 8(%rsi)
451.1Sad	movl	%edx, 12(%rsi)
461.1Sad	popq	%rbx
471.1Sad	ret
481.1Sad
491.4SdslENTRY(x86_xgetbv)
501.5Stnn	xorl	%ecx, %ecx
511.4Sdsl	xgetbv
521.4Sdsl	ret
531.4Sdsl
541.1SadENTRY(x86_identify)
551.3Sdsl	movl	$-1,%eax
561.1Sad	ret
571.6Smlelstv
581.6SmlelstvENTRY(rdmsr)
591.6Smlelstv	movq	%rdi, %rcx
601.6Smlelstv	xorq	%rax, %rax
611.6Smlelstv	movl	$OPTERON_MSR_PASSCODE, %edi
621.6Smlelstv	rdmsr
631.6Smlelstv	shlq	$32, %rdx
641.6Smlelstv	orq	%rdx, %rax
651.6Smlelstv	ret
66