17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 525cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 625cf1a30Sjl139090 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*c9d93b53SJames Anderson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_CPU_MODULE_H 277c478bd9Sstevel@tonic-gate #define _SYS_CPU_MODULE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/pte.h> 307c478bd9Sstevel@tonic-gate #include <sys/async.h> 317c478bd9Sstevel@tonic-gate #include <sys/x_call.h> 327c478bd9Sstevel@tonic-gate #include <sys/conf.h> 337c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef _KERNEL 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * The are functions that are expected of the cpu modules. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate extern struct module_ops *moduleops; 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate struct kdi; 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * module initialization 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate void cpu_setup(void); 547c478bd9Sstevel@tonic-gate void cpu_kdi_init(struct kdi *); 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * set CPU implementation details 587c478bd9Sstevel@tonic-gate * 5935b14535Ssusans * set Panther CPU implementation details 6035b14535Ssusans * 6125cf1a30Sjl139090 * On Panther-only domains and Olympus-C, mmu_init_mmu_page_sizes 6225cf1a30Sjl139090 * changes the mmu_page_sizes variable from the default 4 page sizes 6325cf1a30Sjl139090 * to 6 page sizes and is called from fillsysinfo.c:check_cpus_set 6425cf1a30Sjl139090 * at early bootup time. 657c478bd9Sstevel@tonic-gate */ 66fa9e4066Sahrens void cpu_fiximp(pnode_t dnode); 6735b14535Ssusans #pragma weak cpu_fix_allpanther 6835b14535Ssusans void cpu_fix_allpanther(void); 69e98fafb9Sjl139090 #pragma weak cpu_fix_alljupiter 70e98fafb9Sjl139090 void cpu_fix_alljupiter(void); 717c478bd9Sstevel@tonic-gate #pragma weak mmu_init_mmu_page_sizes 727c478bd9Sstevel@tonic-gate int mmu_init_mmu_page_sizes(int cinfo); 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * virtual demap flushes (tlbs & virtual tag caches) 767c478bd9Sstevel@tonic-gate */ 771e2e7a75Shuah void vtag_flushpage(caddr_t addr, uint64_t sfmmup); 787c478bd9Sstevel@tonic-gate void vtag_flushall(void); 791e2e7a75Shuah #pragma weak vtag_flushall_uctxs 801e2e7a75Shuah void vtag_flushall_uctxs(void); 811e2e7a75Shuah void vtag_flushpage_tl1(uint64_t addr, uint64_t sfmmup); 821e2e7a75Shuah void vtag_flush_pgcnt_tl1(uint64_t addr, uint64_t sfmmup_pgcnt); 837c478bd9Sstevel@tonic-gate void vtag_flushall_tl1(uint64_t dummy1, uint64_t dummy2); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * virtual alias flushes (virtual address caches) 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate void vac_flushpage(pfn_t pf, int color); 897c478bd9Sstevel@tonic-gate void vac_flushpage_tl1(uint64_t pf, uint64_t color); 907c478bd9Sstevel@tonic-gate void vac_flushcolor(int color, pfn_t pf); 917c478bd9Sstevel@tonic-gate void vac_flushcolor_tl1(uint64_t color, uint64_t dummy); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * sending x-calls 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate void init_mondo(xcfunc_t *func, uint64_t arg1, uint64_t arg2); 977c478bd9Sstevel@tonic-gate void send_one_mondo(int cpuid); 987c478bd9Sstevel@tonic-gate #ifdef _MACHDEP 997c478bd9Sstevel@tonic-gate void send_mondo_set(cpuset_t set); 1007c478bd9Sstevel@tonic-gate #endif 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1031e2e7a75Shuah * flag to support optimal dtlb pagesize setting, for ISM and mpss, to support 1041e2e7a75Shuah * cpus with non-fully-associative dtlbs. Page size is stored in hat sfmmu_cext 1057c478bd9Sstevel@tonic-gate */ 1061e2e7a75Shuah extern uint_t cpu_impl_dual_pgsz; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * flush instruction cache if needed 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate void flush_instr_mem(caddr_t addr, size_t len); 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* 1147c478bd9Sstevel@tonic-gate * flush instruction and data caches 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate void kdi_flush_caches(void); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /* 1197c478bd9Sstevel@tonic-gate * take pending fp traps if fpq present 1207c478bd9Sstevel@tonic-gate * this function is also defined in fpusystm.h 1217c478bd9Sstevel@tonic-gate */ 1227c478bd9Sstevel@tonic-gate void syncfpu(void); 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Cpu-specific error and ecache handling routines 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate void ce_err(void); 1287c478bd9Sstevel@tonic-gate void ce_err_tl1(void); 1297c478bd9Sstevel@tonic-gate void async_err(void); 1307c478bd9Sstevel@tonic-gate void cpu_flush_ecache(void); 1317c478bd9Sstevel@tonic-gate void cpu_disable_errors(void); 1327c478bd9Sstevel@tonic-gate /* It could be removed later if prom enables errors */ 1337c478bd9Sstevel@tonic-gate void cpu_enable_errors(void); 1347c478bd9Sstevel@tonic-gate void cpu_faulted_enter(struct cpu *); 1357c478bd9Sstevel@tonic-gate void cpu_faulted_exit(struct cpu *); 1367c478bd9Sstevel@tonic-gate void cpu_ce_count_unum(struct async_flt *ecc, int len, char *unum); 1377c478bd9Sstevel@tonic-gate void cpu_ce_scrub_mem_err(struct async_flt *, boolean_t); 1387c478bd9Sstevel@tonic-gate void cpu_ce_log_err(struct async_flt *, errorq_elem_t *); 1397c478bd9Sstevel@tonic-gate void cpu_ue_log_err(struct async_flt *); 1407c478bd9Sstevel@tonic-gate int cpu_aflt_size(void); 1417c478bd9Sstevel@tonic-gate void cpu_async_panic_callb(void); 1427c478bd9Sstevel@tonic-gate void cpu_check_allcpus(struct async_flt *aflt); 1437c478bd9Sstevel@tonic-gate int cpu_get_cpu_unum(int cpuid, char *buf, int buflen, int *lenp); 144d00f0155Sayznaga 145d00f0155Sayznaga /* Interfaces for getting memory-related information */ 1467c478bd9Sstevel@tonic-gate int cpu_get_mem_name(uint64_t synd, uint64_t *afsr, uint64_t afar, 1477c478bd9Sstevel@tonic-gate char *buf, int buflen, int *lenp); 1487c478bd9Sstevel@tonic-gate int cpu_get_mem_info(uint64_t synd, uint64_t afar, 1497c478bd9Sstevel@tonic-gate uint64_t *mem_sizep, uint64_t *seg_sizep, uint64_t *bank_sizep, 1507c478bd9Sstevel@tonic-gate int *segsp, int *banksp, int *mcidp); 1517c478bd9Sstevel@tonic-gate size_t cpu_get_name_bufsize(); 152d00f0155Sayznaga extern int cpu_get_mem_addr(char *unum, char *sid, uint64_t offset, 153d00f0155Sayznaga uint64_t *addrp); 154d00f0155Sayznaga 155d00f0155Sayznaga /* 156d00f0155Sayznaga * FMA Event Memory Routines 157d00f0155Sayznaga * 158d00f0155Sayznaga * The following routines are used by FMA Event generators to retrieve data 159d00f0155Sayznaga * to store in memory ereports. These routines may call through to platform- 160d00f0155Sayznaga * specific code and/or drivers, and can be called from passive context, low- 161d00f0155Sayznaga * level interrupt context, or panic context. They may grab adaptive locks, 162d00f0155Sayznaga * but should not be allocating new data structures or calling cv_wait(). 163d00f0155Sayznaga */ 164d00f0155Sayznaga int cpu_get_mem_unum(int synd_status, ushort_t synd, uint64_t afsr, 165d00f0155Sayznaga uint64_t afar, int cpuid, int flt_in_memory, 166d00f0155Sayznaga ushort_t flt_status, char *buf, int buflen, int *lenp); 167d00f0155Sayznaga int cpu_get_mem_unum_aflt(int synd_status, struct async_flt *aflt, 168d00f0155Sayznaga char *buf, int buflen, int *lenp); 169d00f0155Sayznaga extern int cpu_get_mem_sid(char *unum, char *buf, int buflen, int *lenp); 170d00f0155Sayznaga extern int cpu_get_mem_offset(uint64_t flt_addr, uint64_t *offp); 171d00f0155Sayznaga 1727c478bd9Sstevel@tonic-gate void read_ecc_data(struct async_flt *ecc, short verbose, short ce_err); 1737c478bd9Sstevel@tonic-gate /* add clr_datapath to aviod lint warning for ac_test.c temporarily */ 1747c478bd9Sstevel@tonic-gate void clr_datapath(void); 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate #pragma weak itlb_parity_trap 1777c478bd9Sstevel@tonic-gate void itlb_parity_trap(void); 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate #pragma weak dtlb_parity_trap 1807c478bd9Sstevel@tonic-gate void dtlb_parity_trap(void); 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * FMA Protocol and error handling support routines 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate void cpu_ereport_post(struct async_flt *); 1877c478bd9Sstevel@tonic-gate void cpu_run_bus_error_handlers(struct async_flt *, int); 1887c478bd9Sstevel@tonic-gate void cpu_errorq_dispatch(char *, void *, size_t, errorq_t *, uint_t); 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate /* 1917c478bd9Sstevel@tonic-gate * retrieve information from the specified tlb entry. these functions are 1927c478bd9Sstevel@tonic-gate * called by "cpr" module 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate void itlb_rd_entry(uint_t entry, tte_t *tte, uint64_t *va_tag); 1957c478bd9Sstevel@tonic-gate void dtlb_rd_entry(uint_t entry, tte_t *tte, uint64_t *va_tag); 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate /* 1987c478bd9Sstevel@tonic-gate * this symbol appears as a second label for vtag_flushall 1997c478bd9Sstevel@tonic-gate * only for cpus that implement DEMAP_ALL_TYPE 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate #pragma weak demap_all 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate /* 2047c478bd9Sstevel@tonic-gate * change cpu speed 2057c478bd9Sstevel@tonic-gate */ 2067c478bd9Sstevel@tonic-gate void cpu_change_speed(uint64_t divisor, uint64_t arg2); 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * ecache scrub operations 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate void cpu_init_cache_scrub(void); 2127c478bd9Sstevel@tonic-gate void cpu_idle_ecache_scrub(struct cpu *); 2137c478bd9Sstevel@tonic-gate void cpu_busy_ecache_scrub(struct cpu *); 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate /* 2167c478bd9Sstevel@tonic-gate * Cpu private initialize/uninitialize, including ecache scrubber. 2177c478bd9Sstevel@tonic-gate */ 2187c478bd9Sstevel@tonic-gate void cpu_init_private(struct cpu *); 2197c478bd9Sstevel@tonic-gate void cpu_uninit_private(struct cpu *); 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate #pragma weak cpu_mp_init 2227c478bd9Sstevel@tonic-gate void cpu_mp_init(void); 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate #pragma weak cpu_feature_init 2257c478bd9Sstevel@tonic-gate void cpu_feature_init(void); 2267c478bd9Sstevel@tonic-gate 227*c9d93b53SJames Anderson #pragma weak cpu_early_feature_init 228*c9d93b53SJames Anderson void cpu_early_feature_init(void); 229*c9d93b53SJames Anderson 2307c478bd9Sstevel@tonic-gate #pragma weak cpu_error_init 2317c478bd9Sstevel@tonic-gate void cpu_error_init(int); 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate /* 2347c478bd9Sstevel@tonic-gate * clock/tick register operations 2357c478bd9Sstevel@tonic-gate */ 2367c478bd9Sstevel@tonic-gate void cpu_clearticknpt(void); 2377c478bd9Sstevel@tonic-gate void cpu_init_tick_freq(void); 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate /* 2407c478bd9Sstevel@tonic-gate * stick synchronization 2417c478bd9Sstevel@tonic-gate */ 2427c478bd9Sstevel@tonic-gate void sticksync_slave(void); 2437c478bd9Sstevel@tonic-gate void sticksync_master(void); 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate /* 2467c478bd9Sstevel@tonic-gate * flags for calling cpu_check_ce 2477c478bd9Sstevel@tonic-gate */ 2487c478bd9Sstevel@tonic-gate #define SCRUBBER_CEEN_CHECK 0 2497c478bd9Sstevel@tonic-gate #define TIMEOUT_CEEN_CHECK 1 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate /* 2527c478bd9Sstevel@tonic-gate * Check for Correctable Errors that may have occurred 2537c478bd9Sstevel@tonic-gate * while CEEN was disabled. 2547c478bd9Sstevel@tonic-gate */ 2557c478bd9Sstevel@tonic-gate void cpu_check_ce(int, uint64_t, caddr_t, uint_t); 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate /* initialize kernel context pgsz codes in DMMU primary context register */ 2587c478bd9Sstevel@tonic-gate void mmu_init_kernel_pgsz(struct hat *hat); 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* get large page size for kernel heap */ 2617c478bd9Sstevel@tonic-gate size_t mmu_get_kernel_lpsize(size_t value); 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2667c478bd9Sstevel@tonic-gate } 2677c478bd9Sstevel@tonic-gate #endif 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate #endif /* _SYS_CPU_MODULE_H */ 270