Print this page
3408 detect socket type of newer AMD CPUs
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>


  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011 by Delphix. All rights reserved.
  24  */
  25 /*
  26  * Copyright (c) 2010, Intel Corporation.
  27  * All rights reserved.
  28  */
  29 /*
  30  * Copyright (c) 2011, Joyent, Inc. All rights reserved.


  31  */
  32 
  33 #ifndef _SYS_X86_ARCHEXT_H
  34 #define _SYS_X86_ARCHEXT_H
  35 
  36 #if !defined(_ASM)
  37 #include <sys/regset.h>
  38 #include <sys/processor.h>
  39 #include <vm/seg_enum.h>
  40 #include <vm/page.h>
  41 #endif  /* _ASM */
  42 
  43 #ifdef  __cplusplus
  44 extern "C" {
  45 #endif
  46 
  47 /*
  48  * cpuid instruction feature flags in %edx (standard function 1)
  49  */
  50 


 510 /*
 511  * Definitions for AMD Family 0xf. Minor revisions C0 and CG are
 512  * sufficiently different that we will distinguish them; in all other
 513  * case we will identify the major revision.
 514  */
 515 #define X86_CHIPREV_AMD_F_REV_B _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0001)
 516 #define X86_CHIPREV_AMD_F_REV_C0 _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0002)
 517 #define X86_CHIPREV_AMD_F_REV_CG _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0004)
 518 #define X86_CHIPREV_AMD_F_REV_D _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0008)
 519 #define X86_CHIPREV_AMD_F_REV_E _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0010)
 520 #define X86_CHIPREV_AMD_F_REV_F _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0020)
 521 #define X86_CHIPREV_AMD_F_REV_G _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0040)
 522 
 523 /*
 524  * Definitions for AMD Family 0x10.  Rev A was Engineering Samples only.
 525  */
 526 #define X86_CHIPREV_AMD_10_REV_A \
 527         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0001)
 528 #define X86_CHIPREV_AMD_10_REV_B \
 529         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0002)
 530 #define X86_CHIPREV_AMD_10_REV_C \
 531         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0004)
 532 #define X86_CHIPREV_AMD_10_REV_D \
 533         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0008)






 534 
 535 /*
 536  * Definitions for AMD Family 0x11.
 537  */
 538 #define X86_CHIPREV_AMD_11 \
 539         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x11, 0x0001)
 540 





 541 
 542 /*

















 543  * Various socket/package types, extended as the need to distinguish
 544  * a new type arises.  The top 8 byte identfies the vendor and the
 545  * remaining 24 bits describe 24 socket types.
 546  */
 547 
 548 #define _X86_SOCKET_VENDOR_SHIFT        24
 549 #define _X86_SOCKET_VENDOR(x)   ((x) >> _X86_SOCKET_VENDOR_SHIFT)
 550 #define _X86_SOCKET_TYPE_MASK   0x00ffffff
 551 #define _X86_SOCKET_TYPE(x)             ((x) & _X86_SOCKET_TYPE_MASK)
 552 
 553 #define _X86_SOCKET_MKVAL(vendor, bitval) \
 554         ((uint32_t)(vendor) << _X86_SOCKET_VENDOR_SHIFT | (bitval))
 555 
 556 #define X86_SOCKET_MATCH(s, mask) \
 557         (_X86_SOCKET_VENDOR(s) == _X86_SOCKET_VENDOR(mask) && \
 558         (_X86_SOCKET_TYPE(s) & _X86_SOCKET_TYPE(mask)) != 0)
 559 
 560 #define X86_SOCKET_UNKNOWN 0x0
 561         /*
 562          * AMD socket types
 563          */
 564 #define X86_SOCKET_754          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000001)
 565 #define X86_SOCKET_939          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000002)
 566 #define X86_SOCKET_940          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000004)
 567 #define X86_SOCKET_S1g1         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000008)
 568 #define X86_SOCKET_AM2          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000010)
 569 #define X86_SOCKET_F1207        _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000020)
 570 #define X86_SOCKET_S1g2         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000040)
 571 #define X86_SOCKET_S1g3         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000080)
 572 #define X86_SOCKET_AM           _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000100)
 573 #define X86_SOCKET_AM2R2        _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000200)
 574 #define X86_SOCKET_AM3          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000400)
 575 #define X86_SOCKET_G34          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000800)
 576 #define X86_SOCKET_ASB2         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x001000)
 577 #define X86_SOCKET_C32          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x002000)








 578 
 579 /*
 580  * xgetbv/xsetbv support
 581  */
 582 
 583 #define XFEATURE_ENABLED_MASK   0x0
 584 /*
 585  * XFEATURE_ENABLED_MASK values (eax)
 586  */
 587 #define XFEATURE_LEGACY_FP      0x1
 588 #define XFEATURE_SSE            0x2
 589 #define XFEATURE_AVX            0x4
 590 #define XFEATURE_MAX            XFEATURE_AVX
 591 #define XFEATURE_FP_ALL         (XFEATURE_LEGACY_FP|XFEATURE_SSE|XFEATURE_AVX)
 592 
 593 #if !defined(_ASM)
 594 
 595 #if defined(_KERNEL) || defined(_KMEMUSER)
 596 
 597 #define NUM_X86_FEATURES        38




  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011 by Delphix. All rights reserved.
  24  */
  25 /*
  26  * Copyright (c) 2010, Intel Corporation.
  27  * All rights reserved.
  28  */
  29 /*
  30  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  31  * Copyright 2012 Jens Elkner <jel+illumos@cs.uni-magdeburg.de>
  32  * Copyright 2012 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
  33  */
  34 
  35 #ifndef _SYS_X86_ARCHEXT_H
  36 #define _SYS_X86_ARCHEXT_H
  37 
  38 #if !defined(_ASM)
  39 #include <sys/regset.h>
  40 #include <sys/processor.h>
  41 #include <vm/seg_enum.h>
  42 #include <vm/page.h>
  43 #endif  /* _ASM */
  44 
  45 #ifdef  __cplusplus
  46 extern "C" {
  47 #endif
  48 
  49 /*
  50  * cpuid instruction feature flags in %edx (standard function 1)
  51  */
  52 


 512 /*
 513  * Definitions for AMD Family 0xf. Minor revisions C0 and CG are
 514  * sufficiently different that we will distinguish them; in all other
 515  * case we will identify the major revision.
 516  */
 517 #define X86_CHIPREV_AMD_F_REV_B _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0001)
 518 #define X86_CHIPREV_AMD_F_REV_C0 _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0002)
 519 #define X86_CHIPREV_AMD_F_REV_CG _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0004)
 520 #define X86_CHIPREV_AMD_F_REV_D _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0008)
 521 #define X86_CHIPREV_AMD_F_REV_E _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0010)
 522 #define X86_CHIPREV_AMD_F_REV_F _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0020)
 523 #define X86_CHIPREV_AMD_F_REV_G _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0040)
 524 
 525 /*
 526  * Definitions for AMD Family 0x10.  Rev A was Engineering Samples only.
 527  */
 528 #define X86_CHIPREV_AMD_10_REV_A \
 529         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0001)
 530 #define X86_CHIPREV_AMD_10_REV_B \
 531         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0002)
 532 #define X86_CHIPREV_AMD_10_REV_C2 \
 533         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0004)
 534 #define X86_CHIPREV_AMD_10_REV_C3 \
 535         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0008)
 536 #define X86_CHIPREV_AMD_10_REV_D0 \
 537         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0010)
 538 #define X86_CHIPREV_AMD_10_REV_D1 \
 539         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0020)
 540 #define X86_CHIPREV_AMD_10_REV_E \
 541         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0040)
 542 
 543 /*
 544  * Definitions for AMD Family 0x11.
 545  */
 546 #define X86_CHIPREV_AMD_11_REV_B \
 547         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x11, 0x0002)
 548 
 549 /*
 550  * Definitions for AMD Family 0x12.
 551  */
 552 #define X86_CHIPREV_AMD_12_REV_B \
 553         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x12, 0x0002)
 554 
 555 /*
 556  * Definitions for AMD Family 0x14.
 557  */
 558 #define X86_CHIPREV_AMD_14_REV_B \
 559         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x14, 0x0002)
 560 #define X86_CHIPREV_AMD_14_REV_C \
 561         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x14, 0x0004)
 562 
 563 /*
 564  * Definitions for AMD Family 0x15
 565  */
 566 #define X86_CHIPREV_AMD_15OR_REV_B2 \
 567         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x15, 0x0001)
 568 
 569 #define X86_CHIPREV_AMD_15TN_REV_A1 \
 570         _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x15, 0x0002)
 571 
 572 /*
 573  * Various socket/package types, extended as the need to distinguish
 574  * a new type arises.  The top 8 byte identfies the vendor and the
 575  * remaining 24 bits describe 24 socket types.
 576  */
 577 
 578 #define _X86_SOCKET_VENDOR_SHIFT        24
 579 #define _X86_SOCKET_VENDOR(x)   ((x) >> _X86_SOCKET_VENDOR_SHIFT)
 580 #define _X86_SOCKET_TYPE_MASK   0x00ffffff
 581 #define _X86_SOCKET_TYPE(x)             ((x) & _X86_SOCKET_TYPE_MASK)
 582 
 583 #define _X86_SOCKET_MKVAL(vendor, bitval) \
 584         ((uint32_t)(vendor) << _X86_SOCKET_VENDOR_SHIFT | (bitval))
 585 
 586 #define X86_SOCKET_MATCH(s, mask) \
 587         (_X86_SOCKET_VENDOR(s) == _X86_SOCKET_VENDOR(mask) && \
 588         (_X86_SOCKET_TYPE(s) & _X86_SOCKET_TYPE(mask)) != 0)
 589 
 590 #define X86_SOCKET_UNKNOWN 0x0
 591         /*
 592          * AMD socket types
 593          */
 594 #define X86_SOCKET_754          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000001)
 595 #define X86_SOCKET_939          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000002)
 596 #define X86_SOCKET_940          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000004)
 597 #define X86_SOCKET_S1g1         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000008)
 598 #define X86_SOCKET_AM2          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000010)
 599 #define X86_SOCKET_F1207        _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000020)
 600 #define X86_SOCKET_S1g2         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000040)
 601 #define X86_SOCKET_S1g3         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000080)
 602 #define X86_SOCKET_AM           _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000100)
 603 #define X86_SOCKET_AM2R2        _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000200)
 604 #define X86_SOCKET_AM3          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000400)
 605 #define X86_SOCKET_G34          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000800)
 606 #define X86_SOCKET_ASB2         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x001000)
 607 #define X86_SOCKET_C32          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x002000)
 608 #define X86_SOCKET_S1g4         _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x004000)
 609 #define X86_SOCKET_FT1          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x008000)
 610 #define X86_SOCKET_FM1          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x010000)
 611 #define X86_SOCKET_FS1          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x020000)
 612 #define X86_SOCKET_AM3R2        _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x040000)
 613 #define X86_SOCKET_FP2          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x080000)
 614 #define X86_SOCKET_FS1R2        _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x100000)
 615 #define X86_SOCKET_FM2          _X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x200000)
 616 
 617 /*
 618  * xgetbv/xsetbv support
 619  */
 620 
 621 #define XFEATURE_ENABLED_MASK   0x0
 622 /*
 623  * XFEATURE_ENABLED_MASK values (eax)
 624  */
 625 #define XFEATURE_LEGACY_FP      0x1
 626 #define XFEATURE_SSE            0x2
 627 #define XFEATURE_AVX            0x4
 628 #define XFEATURE_MAX            XFEATURE_AVX
 629 #define XFEATURE_FP_ALL         (XFEATURE_LEGACY_FP|XFEATURE_SSE|XFEATURE_AVX)
 630 
 631 #if !defined(_ASM)
 632 
 633 #if defined(_KERNEL) || defined(_KMEMUSER)
 634 
 635 #define NUM_X86_FEATURES        38