2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) KATO Takenori, 1997, 1998.
6 * All rights reserved. Unpublished rights reserved under the copyright
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer as
15 * the first lines of this file unmodified.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
37 #include <sys/param.h>
38 #include <sys/kernel.h>
39 #include <sys/systm.h>
40 #include <sys/sysctl.h>
42 #include <machine/cputypes.h>
43 #include <machine/md_var.h>
44 #include <machine/psl.h>
45 #include <machine/specialreg.h>
51 static void init_5x86(void);
52 static void init_bluelightning(void);
53 static void init_486dlc(void);
54 static void init_cy486dx(void);
55 #ifdef CPU_I486_ON_386
56 static void init_i486_on_386(void);
58 static void init_6x86(void);
61 #if defined(I586_CPU) && defined(CPU_WT_ALLOC)
62 static void enable_K5_wt_alloc(void);
63 static void enable_K6_wt_alloc(void);
64 static void enable_K6_2_wt_alloc(void);
68 static void init_6x86MX(void);
69 static void init_ppro(void);
70 static void init_mendocino(void);
73 static int hw_instruction_sse;
74 SYSCTL_INT(_hw, OID_AUTO, instruction_sse, CTLFLAG_RD,
75 &hw_instruction_sse, 0, "SIMD/MMX2 instructions available in CPU");
77 * -1: automatic (default)
78 * 0: keep enable CLFLUSH
79 * 1: force disable CLFLUSH
81 static int hw_clflush_disable = -1;
83 u_int cyrix_did; /* Device ID of Cyrix CPU */
90 init_bluelightning(void)
94 saveintr = intr_disable();
96 load_cr0(rcr0() | CR0_CD | CR0_NW);
99 #ifdef CPU_BLUELIGHTNING_FPU_OP_CACHE
100 wrmsr(0x1000, 0x9c92LL); /* FP operand can be cacheable on Cyrix FPU */
102 wrmsr(0x1000, 0x1c92LL); /* Intel FPU */
104 /* Enables 13MB and 0-640KB cache. */
105 wrmsr(0x1001, (0xd0LL << 32) | 0x3ff);
106 #ifdef CPU_BLUELIGHTNING_3X
107 wrmsr(0x1002, 0x04000000LL); /* Enables triple-clock mode. */
109 wrmsr(0x1002, 0x03000000LL); /* Enables double-clock mode. */
112 /* Enable caching in CR0. */
113 load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
115 intr_restore(saveintr);
119 * Cyrix 486SLC/DLC/SR/DR series
127 saveintr = intr_disable();
130 ccr0 = read_cyrix_reg(CCR0);
131 #ifndef CYRIX_CACHE_WORKS
132 ccr0 |= CCR0_NC1 | CCR0_BARB;
133 write_cyrix_reg(CCR0, ccr0);
137 #ifndef CYRIX_CACHE_REALLY_WORKS
138 ccr0 |= CCR0_NC1 | CCR0_BARB;
142 #ifdef CPU_DIRECT_MAPPED_CACHE
143 ccr0 |= CCR0_CO; /* Direct mapped mode. */
145 write_cyrix_reg(CCR0, ccr0);
147 /* Clear non-cacheable region. */
148 write_cyrix_reg(NCR1+2, NCR_SIZE_0K);
149 write_cyrix_reg(NCR2+2, NCR_SIZE_0K);
150 write_cyrix_reg(NCR3+2, NCR_SIZE_0K);
151 write_cyrix_reg(NCR4+2, NCR_SIZE_0K);
153 write_cyrix_reg(0, 0); /* dummy write */
155 /* Enable caching in CR0. */
156 load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
158 #endif /* !CYRIX_CACHE_WORKS */
159 intr_restore(saveintr);
164 * Cyrix 486S/DX series
172 saveintr = intr_disable();
175 ccr2 = read_cyrix_reg(CCR2);
177 ccr2 |= CCR2_SUSP_HLT;
180 write_cyrix_reg(CCR2, ccr2);
181 intr_restore(saveintr);
192 u_char ccr2, ccr3, ccr4, pcr0;
194 saveintr = intr_disable();
196 load_cr0(rcr0() | CR0_CD | CR0_NW);
199 (void)read_cyrix_reg(CCR3); /* dummy */
201 /* Initialize CCR2. */
202 ccr2 = read_cyrix_reg(CCR2);
205 ccr2 |= CCR2_SUSP_HLT;
207 ccr2 &= ~CCR2_SUSP_HLT;
210 write_cyrix_reg(CCR2, ccr2);
212 /* Initialize CCR4. */
213 ccr3 = read_cyrix_reg(CCR3);
214 write_cyrix_reg(CCR3, CCR3_MAPEN0);
216 ccr4 = read_cyrix_reg(CCR4);
219 #ifdef CPU_FASTER_5X86_FPU
220 ccr4 |= CCR4_FASTFPE;
222 ccr4 &= ~CCR4_FASTFPE;
224 ccr4 &= ~CCR4_IOMASK;
225 /********************************************************************
226 * WARNING: The "BIOS Writers Guide" mentions that I/O recovery time
227 * should be 0 for errata fix.
228 ********************************************************************/
230 ccr4 |= CPU_IORT & CCR4_IOMASK;
232 write_cyrix_reg(CCR4, ccr4);
234 /* Initialize PCR0. */
235 /****************************************************************
236 * WARNING: RSTK_EN and LOOP_EN could make your system unstable.
237 * BTB_EN might make your system unstable.
238 ****************************************************************/
239 pcr0 = read_cyrix_reg(PCR0);
256 /****************************************************************
257 * WARNING: if you use a memory mapped I/O device, don't use
258 * DISABLE_5X86_LSSER option, which may reorder memory mapped
260 * IF YOUR MOTHERBOARD HAS PCI BUS, DON'T DISABLE LSSER.
261 ****************************************************************/
262 #ifdef CPU_DISABLE_5X86_LSSER
267 write_cyrix_reg(PCR0, pcr0);
270 write_cyrix_reg(CCR3, ccr3);
272 (void)read_cyrix_reg(0x80); /* dummy */
274 /* Unlock NW bit in CR0. */
275 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_LOCK_NW);
276 load_cr0((rcr0() & ~CR0_CD) | CR0_NW); /* CD = 0, NW = 1 */
277 /* Lock NW bit in CR0. */
278 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_LOCK_NW);
280 intr_restore(saveintr);
283 #ifdef CPU_I486_ON_386
285 * There are i486 based upgrade products for i386 machines.
286 * In this case, BIOS doesn't enable CPU cache.
289 init_i486_on_386(void)
293 saveintr = intr_disable();
295 load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0, NW = 0 */
297 intr_restore(saveintr);
304 * XXX - What should I do here? Please let me know.
312 saveintr = intr_disable();
314 load_cr0(rcr0() | CR0_CD | CR0_NW);
317 /* Initialize CCR0. */
318 write_cyrix_reg(CCR0, read_cyrix_reg(CCR0) | CCR0_NC1);
320 /* Initialize CCR1. */
321 #ifdef CPU_CYRIX_NO_LOCK
322 write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) | CCR1_NO_LOCK);
324 write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) & ~CCR1_NO_LOCK);
327 /* Initialize CCR2. */
329 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_SUSP_HLT);
331 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_SUSP_HLT);
334 ccr3 = read_cyrix_reg(CCR3);
335 write_cyrix_reg(CCR3, CCR3_MAPEN0);
337 /* Initialize CCR4. */
338 ccr4 = read_cyrix_reg(CCR4);
340 ccr4 &= ~CCR4_IOMASK;
342 write_cyrix_reg(CCR4, ccr4 | (CPU_IORT & CCR4_IOMASK));
344 write_cyrix_reg(CCR4, ccr4 | 7);
347 /* Initialize CCR5. */
349 write_cyrix_reg(CCR5, read_cyrix_reg(CCR5) | CCR5_WT_ALLOC);
353 write_cyrix_reg(CCR3, ccr3);
355 /* Unlock NW bit in CR0. */
356 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_LOCK_NW);
359 * Earlier revision of the 6x86 CPU could crash the system if
360 * L1 cache is in write-back mode.
362 if ((cyrix_did & 0xff00) > 0x1600)
363 load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
365 /* Revision 2.6 and lower. */
366 #ifdef CYRIX_CACHE_REALLY_WORKS
367 load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
369 load_cr0((rcr0() & ~CR0_CD) | CR0_NW); /* CD = 0 and NW = 1 */
373 /* Lock NW bit in CR0. */
374 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_LOCK_NW);
376 intr_restore(saveintr);
378 #endif /* I486_CPU */
389 * The CMPXCHG8B instruction is always available but hidden.
391 cpu_feature |= CPUID_CX8;
395 * IDT WinChip C6/2/2A/2B/3
397 * http://www.centtech.com/winchip_bios_writers_guide_v4_0.pdf
408 * Set ECX8, DSMC, DTLOCK/EDCTLB, EMMX, and ERETSTK and clear DPDC.
410 fcr |= (1 << 1) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 16);
411 fcr &= ~(1ULL << 11);
414 * Additionally, set EBRPRED, E2MMX and EAMD3D for WinChip 2 and 3.
416 if (CPUID_TO_MODEL(cpu_id) >= 8)
417 fcr |= (1 << 12) | (1 << 19) | (1 << 20);
421 cpu_feature = regs[3];
427 * Cyrix 6x86MX (code-named M2)
429 * XXX - What should I do here? Please let me know.
437 saveintr = intr_disable();
439 load_cr0(rcr0() | CR0_CD | CR0_NW);
442 /* Initialize CCR0. */
443 write_cyrix_reg(CCR0, read_cyrix_reg(CCR0) | CCR0_NC1);
445 /* Initialize CCR1. */
446 #ifdef CPU_CYRIX_NO_LOCK
447 write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) | CCR1_NO_LOCK);
449 write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) & ~CCR1_NO_LOCK);
452 /* Initialize CCR2. */
454 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_SUSP_HLT);
456 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_SUSP_HLT);
459 ccr3 = read_cyrix_reg(CCR3);
460 write_cyrix_reg(CCR3, CCR3_MAPEN0);
462 /* Initialize CCR4. */
463 ccr4 = read_cyrix_reg(CCR4);
464 ccr4 &= ~CCR4_IOMASK;
466 write_cyrix_reg(CCR4, ccr4 | (CPU_IORT & CCR4_IOMASK));
468 write_cyrix_reg(CCR4, ccr4 | 7);
471 /* Initialize CCR5. */
473 write_cyrix_reg(CCR5, read_cyrix_reg(CCR5) | CCR5_WT_ALLOC);
477 write_cyrix_reg(CCR3, ccr3);
479 /* Unlock NW bit in CR0. */
480 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_LOCK_NW);
482 load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
484 /* Lock NW bit in CR0. */
485 write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_LOCK_NW);
487 intr_restore(saveintr);
490 static int ppro_apic_used = -1;
498 * Local APIC should be disabled if it is not going to be used.
500 if (ppro_apic_used != 1) {
501 apicbase = rdmsr(MSR_APICBASE);
502 apicbase &= ~APICBASE_ENABLED;
503 wrmsr(MSR_APICBASE, apicbase);
509 * If the local APIC is going to be used after being disabled above,
510 * re-enable it and don't disable it in the future.
513 ppro_reenable_apic(void)
517 if (ppro_apic_used == 0) {
518 apicbase = rdmsr(MSR_APICBASE);
519 apicbase |= APICBASE_ENABLED;
520 wrmsr(MSR_APICBASE, apicbase);
526 * Initialize BBL_CR_CTL3 (Control register 3: used to configure the
532 #ifdef CPU_PPRO2CELERON
534 u_int64_t bbl_cr_ctl3;
536 saveintr = intr_disable();
538 load_cr0(rcr0() | CR0_CD | CR0_NW);
541 bbl_cr_ctl3 = rdmsr(MSR_BBL_CR_CTL3);
543 /* If the L2 cache is configured, do nothing. */
544 if (!(bbl_cr_ctl3 & 1)) {
545 bbl_cr_ctl3 = 0x134052bLL;
547 /* Set L2 Cache Latency (Default: 5). */
548 #ifdef CPU_CELERON_L2_LATENCY
549 #if CPU_L2_LATENCY > 15
550 #error invalid CPU_L2_LATENCY.
552 bbl_cr_ctl3 |= CPU_L2_LATENCY << 1;
554 bbl_cr_ctl3 |= 5 << 1;
556 wrmsr(MSR_BBL_CR_CTL3, bbl_cr_ctl3);
559 load_cr0(rcr0() & ~(CR0_CD | CR0_NW));
560 intr_restore(saveintr);
561 #endif /* CPU_PPRO2CELERON */
565 * Initialize special VIA features
574 * Explicitly enable CX8 and PGE on C3.
576 * http://www.via.com.tw/download/mainboards/6/13/VIA_C3_EBGA%20datasheet110.pdf
578 if (CPUID_TO_MODEL(cpu_id) <= 9)
579 fcr = (1 << 1) | (1 << 7);
584 * Check extended CPUID for PadLock features.
586 * http://www.via.com.tw/en/downloads/whitepapers/initiatives/padlock/programming_guide.pdf
588 do_cpuid(0xc0000000, regs);
589 if (regs[0] >= 0xc0000001) {
590 do_cpuid(0xc0000001, regs);
595 /* Enable RNG if present. */
596 if ((val & VIA_CPUID_HAS_RNG) != 0) {
597 via_feature_rng = VIA_HAS_RNG;
598 wrmsr(0x110B, rdmsr(0x110B) | VIA_CPUID_DO_RNG);
601 /* Enable PadLock if present. */
602 if ((val & VIA_CPUID_HAS_ACE) != 0)
603 via_feature_xcrypt |= VIA_HAS_AES;
604 if ((val & VIA_CPUID_HAS_ACE2) != 0)
605 via_feature_xcrypt |= VIA_HAS_AESCTR;
606 if ((val & VIA_CPUID_HAS_PHE) != 0)
607 via_feature_xcrypt |= VIA_HAS_SHA;
608 if ((val & VIA_CPUID_HAS_PMM) != 0)
609 via_feature_xcrypt |= VIA_HAS_MM;
610 if (via_feature_xcrypt != 0)
613 wrmsr(0x1107, rdmsr(0x1107) | fcr);
616 #endif /* I686_CPU */
618 #if defined(I586_CPU) || defined(I686_CPU)
624 /* Expose all hidden features. */
625 wrmsr(0x80860004, rdmsr(0x80860004) | ~0UL);
627 cpu_feature = regs[3];
632 * The value for the TSC_AUX MSR and rdtscp/rdpid on the invoking CPU.
634 * Caller should prevent CPU migration.
639 KASSERT((read_eflags() & PSL_I) == 0, ("context switch possible"));
640 return (PCPU_GET(cpuid));
643 extern int elf32_nxstack;
653 init_bluelightning();
664 #ifdef CPU_I486_ON_386
672 #endif /* I486_CPU */
675 switch (cpu_vendor_id) {
678 if (((cpu_id & 0x0f0) > 0) &&
679 ((cpu_id & 0x0f0) < 0x60) &&
680 ((cpu_id & 0x00f) > 3))
681 enable_K5_wt_alloc();
682 else if (((cpu_id & 0x0f0) > 0x80) ||
683 (((cpu_id & 0x0f0) == 0x80) &&
684 (cpu_id & 0x00f) > 0x07))
685 enable_K6_2_wt_alloc();
686 else if ((cpu_id & 0x0f0) > 0x50)
687 enable_K6_wt_alloc();
689 if ((cpu_id & 0xf0) == 0xa0)
691 * Make sure the TSC runs through
692 * suspension, otherwise we can't use
695 wrmsr(0x1900, rdmsr(0x1900) | 0x20ULL);
697 case CPU_VENDOR_CENTAUR:
700 case CPU_VENDOR_TRANSMETA:
703 case CPU_VENDOR_RISE:
714 switch (cpu_vendor_id) {
715 case CPU_VENDOR_INTEL:
716 switch (cpu_id & 0xff0) {
725 #ifdef CPU_ATHLON_SSE_HACK
728 * Sometimes the BIOS doesn't enable SSE instructions.
729 * According to AMD document 20734, the mobile
730 * Duron, the (mobile) Athlon 4 and the Athlon MP
731 * support SSE. These correspond to cpu_id 0x66X
734 if ((cpu_feature & CPUID_XMM) == 0 &&
735 ((cpu_id & ~0xf) == 0x660 ||
736 (cpu_id & ~0xf) == 0x670 ||
737 (cpu_id & ~0xf) == 0x680)) {
739 wrmsr(MSR_HWCR, rdmsr(MSR_HWCR) & ~0x08000);
741 cpu_feature = regs[3];
745 case CPU_VENDOR_CENTAUR:
748 case CPU_VENDOR_TRANSMETA:
757 if ((cpu_feature & CPUID_XMM) && (cpu_feature & CPUID_FXSR)) {
758 load_cr4(rcr4() | CR4_FXSR | CR4_XMM);
759 cpu_fxsr = hw_instruction_sse = 1;
762 msr = rdmsr(MSR_EFER) | EFER_NXE;
763 wrmsr(MSR_EFER, msr);
765 if ((amd_feature & AMDID_RDTSCP) != 0 ||
766 (cpu_stdext_feature2 & CPUID_STDEXT2_RDPID) != 0)
767 wrmsr(MSR_TSC_AUX, cpu_auxmsr());
771 initializecpucache(void)
775 * CPUID with %eax = 1, %ebx returns
776 * Bits 15-8: CLFLUSH line size
777 * (Value * 8 = cache line size in bytes)
779 if ((cpu_feature & CPUID_CLFSH) != 0)
780 cpu_clflush_line_size = ((cpu_procinfo >> 8) & 0xff) * 8;
782 * XXXKIB: (temporary) hack to work around traps generated
783 * when CLFLUSHing APIC register window under virtualization
784 * environments. These environments tend to disable the
785 * CPUID_SS feature even though the native CPU supports it.
787 TUNABLE_INT_FETCH("hw.clflush_disable", &hw_clflush_disable);
788 if (vm_guest != VM_GUEST_NO && hw_clflush_disable == -1) {
789 cpu_feature &= ~CPUID_CLFSH;
790 cpu_stdext_feature &= ~CPUID_STDEXT_CLFLUSHOPT;
793 * The kernel's use of CLFLUSH{,OPT} can be disabled manually
794 * by setting the hw.clflush_disable tunable.
796 if (hw_clflush_disable == 1) {
797 cpu_feature &= ~CPUID_CLFSH;
798 cpu_stdext_feature &= ~CPUID_STDEXT_CLFLUSHOPT;
802 #if defined(I586_CPU) && defined(CPU_WT_ALLOC)
804 * Enable write allocate feature of AMD processors.
805 * Following two functions require the Maxmem variable being set.
808 enable_K5_wt_alloc(void)
814 * Write allocate is supported only on models 1, 2, and 3, with
815 * a stepping of 4 or greater.
817 if (((cpu_id & 0xf0) > 0) && ((cpu_id & 0x0f) > 3)) {
818 saveintr = intr_disable();
819 msr = rdmsr(0x83); /* HWCR */
820 wrmsr(0x83, msr & !(0x10));
823 * We have to tell the chip where the top of memory is,
824 * since video cards could have frame bufferes there,
825 * memory-mapped I/O could be there, etc.
831 msr |= AMD_WT_ALLOC_TME | AMD_WT_ALLOC_FRE;
834 * There is no way to know wheter 15-16M hole exists or not.
835 * Therefore, we disable write allocate for this range.
837 wrmsr(0x86, 0x0ff00f0);
838 msr |= AMD_WT_ALLOC_PRE;
842 wrmsr(0x83, msr|0x10); /* enable write allocate */
843 intr_restore(saveintr);
848 enable_K6_wt_alloc(void)
854 saveintr = intr_disable();
857 #ifdef CPU_DISABLE_CACHE
859 * Certain K6-2 box becomes unstable when write allocation is
863 * The AMD-K6 processer provides the 64-bit Test Register 12(TR12),
864 * but only the Cache Inhibit(CI) (bit 3 of TR12) is supported.
865 * All other bits in TR12 have no effect on the processer's operation.
866 * The I/O Trap Restart function (bit 9 of TR12) is always enabled
869 wrmsr(0x0000000e, (u_int64_t)0x0008);
871 /* Don't assume that memory size is aligned with 4M. */
873 size = ((Maxmem >> 8) + 3) >> 2;
877 /* Limit is 508M bytes. */
880 whcr = (rdmsr(0xc0000082) & ~(0x7fLL << 1)) | (size << 1);
882 #if defined(NO_MEMORY_HOLE)
883 if (whcr & (0x7fLL << 1))
887 * There is no way to know wheter 15-16M hole exists or not.
888 * Therefore, we disable write allocate for this range.
892 wrmsr(0x0c0000082, whcr);
894 intr_restore(saveintr);
898 enable_K6_2_wt_alloc(void)
904 saveintr = intr_disable();
907 #ifdef CPU_DISABLE_CACHE
909 * Certain K6-2 box becomes unstable when write allocation is
913 * The AMD-K6 processer provides the 64-bit Test Register 12(TR12),
914 * but only the Cache Inhibit(CI) (bit 3 of TR12) is supported.
915 * All other bits in TR12 have no effect on the processer's operation.
916 * The I/O Trap Restart function (bit 9 of TR12) is always enabled
919 wrmsr(0x0000000e, (u_int64_t)0x0008);
921 /* Don't assume that memory size is aligned with 4M. */
923 size = ((Maxmem >> 8) + 3) >> 2;
927 /* Limit is 4092M bytes. */
930 whcr = (rdmsr(0xc0000082) & ~(0x3ffLL << 22)) | (size << 22);
932 #if defined(NO_MEMORY_HOLE)
933 if (whcr & (0x3ffLL << 22))
937 * There is no way to know wheter 15-16M hole exists or not.
938 * Therefore, we disable write allocate for this range.
940 whcr &= ~(1LL << 16);
942 wrmsr(0x0c0000082, whcr);
944 intr_restore(saveintr);
946 #endif /* I585_CPU && CPU_WT_ALLOC */
952 DB_SHOW_COMMAND(cyrixreg, cyrixreg)
956 u_char ccr1, ccr2, ccr3;
957 u_char ccr0 = 0, ccr4 = 0, ccr5 = 0, pcr0 = 0;
960 if (cpu_vendor_id == CPU_VENDOR_CYRIX) {
961 saveintr = intr_disable();
964 if ((cpu != CPU_M1SC) && (cpu != CPU_CY486DX)) {
965 ccr0 = read_cyrix_reg(CCR0);
967 ccr1 = read_cyrix_reg(CCR1);
968 ccr2 = read_cyrix_reg(CCR2);
969 ccr3 = read_cyrix_reg(CCR3);
970 if ((cpu == CPU_M1SC) || (cpu == CPU_M1) || (cpu == CPU_M2)) {
971 write_cyrix_reg(CCR3, CCR3_MAPEN0);
972 ccr4 = read_cyrix_reg(CCR4);
973 if ((cpu == CPU_M1) || (cpu == CPU_M2))
974 ccr5 = read_cyrix_reg(CCR5);
976 pcr0 = read_cyrix_reg(PCR0);
977 write_cyrix_reg(CCR3, ccr3); /* Restore CCR3. */
979 intr_restore(saveintr);
981 if ((cpu != CPU_M1SC) && (cpu != CPU_CY486DX))
982 printf("CCR0=%x, ", (u_int)ccr0);
984 printf("CCR1=%x, CCR2=%x, CCR3=%x",
985 (u_int)ccr1, (u_int)ccr2, (u_int)ccr3);
986 if ((cpu == CPU_M1SC) || (cpu == CPU_M1) || (cpu == CPU_M2)) {
987 printf(", CCR4=%x, ", (u_int)ccr4);
989 printf("PCR0=%x\n", pcr0);
991 printf("CCR5=%x\n", ccr5);
994 printf("CR0=%x\n", cr0);