16320Sbholler/* 26320Sbholler * CDDL HEADER START 36320Sbholler * 46320Sbholler * The contents of this file are subject to the terms of the 56320Sbholler * Common Development and Distribution License (the "License"). 66320Sbholler * You may not use this file except in compliance with the License. 76320Sbholler * 86320Sbholler * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96320Sbholler * or http://www.opensolaris.org/os/licensing. 106320Sbholler * See the License for the specific language governing permissions 116320Sbholler * and limitations under the License. 126320Sbholler * 136320Sbholler * When distributing Covered Code, include this CDDL HEADER in each 146320Sbholler * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156320Sbholler * If applicable, add the following below this CDDL HEADER, with the 166320Sbholler * fields enclosed by brackets "[]" replaced with your own identifying 176320Sbholler * information: Portions Copyright [yyyy] [name of copyright owner] 186320Sbholler * 196320Sbholler * CDDL HEADER END 206320Sbholler */ 216320Sbholler 226320Sbholler/* 2310024Sbostrovs * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 246812Sraf * Use is subject to license terms. 256812Sraf */ 266812Sraf 276812Sraf/* 28*10583SEdward.Gillett@Sun.COM * Copyright (c) 2009, Intel Corporation 296320Sbholler * All rights reserved. 306320Sbholler */ 316320Sbholler 326320Sbholler/* 3310024Sbostrovs * Portions Copyright 2009 Advanced Micro Devices, Inc. 3410024Sbostrovs */ 3510024Sbostrovs 3610024Sbostrovs/* 376320Sbholler * Assembler support routines to getcpuid information used to set 386320Sbholler * cache size information. Cache information used by memset, strcpy, etc.. 396320Sbholler */ 406812Sraf 416320Sbholler#include <sys/asm_linkage.h> 426320Sbholler#include "proc64_id.h" 436320Sbholler 446320Sbholler .global .memops_method 4510024Sbostrovs .global .amd64cache1, .amd64cache1half, .amd64cache2, .amd64cache2half 4610024Sbostrovs .global .largest_level_cache_size 4710024Sbostrovs 486320Sbholler 496320Sbholler/* 5010024Sbostrovs * Defaults for Core 2 Duo and AMD's SledgeHammer 516320Sbholler */ 526320Sbholler .data 536320Sbholler .balign 8 546320Sbholler.memops_method: 556320Sbholler .int NO_SSE 566320Sbholler 5710024Sbostrovs .balign 8 5810024Sbostrovs.amd64cache1: .quad AMD_DFLT_L1_CACHE_SIZE 5910024Sbostrovs.amd64cache1half: .quad AMD_DFLT_L1_CACHE_SIZE/2 6010024Sbostrovs.amd64cache2: .quad AMD_DFLT_L2_CACHE_SIZE 6110024Sbostrovs.amd64cache2half: .quad AMD_DFLT_L2_CACHE_SIZE/2 6210024Sbostrovs.largest_level_cache_size: 6310024Sbostrovs .int AMD_DFLT_L2_CACHE_SIZE 6410024Sbostrovs 656320Sbholler/* 666320Sbholler * Get cpuid data. 676320Sbholler * (void)__libc_get_cpuid(int cpuid_function, void *out_reg, int cache_index ) 686320Sbholler */ 696320Sbholler .text 706320Sbholler 716320Sbholler ENTRY(__libc_get_cpuid) 726320Sbholler # rdi = cpuid function, rsi = out_reg addr, rdx = cache index(fn 4) 736320Sbholler push %rbx 746320Sbholler mov %edx,%ecx 756320Sbholler mov %edi,%eax 766320Sbholler cpuid 776320Sbholler mov %eax,(%rsi) 786320Sbholler mov %ebx,0x4(%rsi) 796320Sbholler mov %ecx,0x8(%rsi) 806320Sbholler mov %edx,0xc(%rsi) 816320Sbholler pop %rbx 826320Sbholler ret 836320Sbholler SET_SIZE(__libc_get_cpuid) 846320Sbholler 856320Sbholler/* 866320Sbholler * Set memops SSE level to use. 876320Sbholler * void __intel_set_memops_method(long sse_level); 886320Sbholler */ 896320Sbholler ENTRY(__intel_set_memops_method) 906320Sbholler mov %edi,.memops_method(%rip) 916320Sbholler ret 926320Sbholler SET_SIZE(__intel_set_memops_method) 936320Sbholler 946320Sbholler/* 956320Sbholler * Set cache info global variables used by various libc primitives. 9610024Sbostrovs * __set_cache_sizes(long l1_cache_size, long l2_cache_size, 9710024Sbostrovs * long largest_level_cache); 986320Sbholler */ 9910024Sbostrovs ENTRY(__set_cache_sizes) 1006320Sbholler # rdi = l1_cache_size, rsi = l2_cache_size, rdx = largest_level_cache 1016320Sbholler 1026320Sbholler mov %rdi,.amd64cache1(%rip) 1036320Sbholler shr $1, %rdi 1046320Sbholler mov %rdi,.amd64cache1half(%rip) 1056320Sbholler 1066320Sbholler mov %rsi,.amd64cache2(%rip) 1076320Sbholler shr $1, %rsi 1086320Sbholler mov %rsi,.amd64cache2half(%rip) 1096320Sbholler 1106320Sbholler mov %rdx,.largest_level_cache_size(%rip) 1116320Sbholler ret 11210024Sbostrovs SET_SIZE(__set_cache_sizes) 113