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*986fd29aSsetje * Copyright 2007 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_PROM_PLAT_H 277c478bd9Sstevel@tonic-gate #define _SYS_PROM_PLAT_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 327c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #if !defined(_LONGLONG_TYPE) 397c478bd9Sstevel@tonic-gate #error "This header won't work without long long support" 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * This file contains external platform-specific promif interface definitions. 447c478bd9Sstevel@tonic-gate * There may be none. This file is included by reference in <sys/promif.h> 457c478bd9Sstevel@tonic-gate * 467c478bd9Sstevel@tonic-gate * This version of the file is for the IEEE 1275-1994 compliant sun4u prom. 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Memory allocation plus memory/mmu interfaces: 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * Routines with fine-grained memory and MMU control are platform-dependent. 537c478bd9Sstevel@tonic-gate * 547c478bd9Sstevel@tonic-gate * MMU node virtualized "mode" arguments and results for Spitfire MMU: 557c478bd9Sstevel@tonic-gate * 567c478bd9Sstevel@tonic-gate * The default virtualized "mode" for client program mappings created 577c478bd9Sstevel@tonic-gate * by the firmware is as follows: 587c478bd9Sstevel@tonic-gate * 597c478bd9Sstevel@tonic-gate * G (global) Clear 607c478bd9Sstevel@tonic-gate * L (locked) Clear 617c478bd9Sstevel@tonic-gate * W (write) Set 627c478bd9Sstevel@tonic-gate * R (read - soft) Set (Prom is not required to implement soft bits) 637c478bd9Sstevel@tonic-gate * X (exec - soft) Set (Prom is not required to implement soft bits) 647c478bd9Sstevel@tonic-gate * CV,CP (Cacheable) Set if memory page, Clear if IO page 657c478bd9Sstevel@tonic-gate * E (side effects) Clear if memory page; Set if IO page 667c478bd9Sstevel@tonic-gate * IE (Invert endian.) Clear 677c478bd9Sstevel@tonic-gate * 687c478bd9Sstevel@tonic-gate * The following fields are initialized as follows in the TTE-data for any 697c478bd9Sstevel@tonic-gate * mappings created by the firmware on behalf of the client program: 707c478bd9Sstevel@tonic-gate * 717c478bd9Sstevel@tonic-gate * P (Priviledged) Set 727c478bd9Sstevel@tonic-gate * V (Valid) Set 737c478bd9Sstevel@tonic-gate * NFO (No Fault Only) Clear 747c478bd9Sstevel@tonic-gate * Context 0 757c478bd9Sstevel@tonic-gate * Soft bits < private to the firmware implementation > 767c478bd9Sstevel@tonic-gate * 777c478bd9Sstevel@tonic-gate * Page size of Prom mappings are typically 8k, "modify" cannot change 787c478bd9Sstevel@tonic-gate * page sizes. Mappings created by "map" are 8k pages. 797c478bd9Sstevel@tonic-gate * 807c478bd9Sstevel@tonic-gate * If the virtualized "mode" is -1, the defaults as shown above are used, 817c478bd9Sstevel@tonic-gate * otherwise the virtualized "mode" is set (and returned) based on the 827c478bd9Sstevel@tonic-gate * following virtualized "mode" abstractions. The mmu node "translations" 837c478bd9Sstevel@tonic-gate * property contains the actual tte-data, not the virtualized "mode". 847c478bd9Sstevel@tonic-gate * 857c478bd9Sstevel@tonic-gate * Note that client programs may not create locked mappings by setting 867c478bd9Sstevel@tonic-gate * the LOCKED bit. There are Spitfire specific client interfaces to create 877c478bd9Sstevel@tonic-gate * and remove locked mappings. (SUNW,{i,d}tlb-load). 887c478bd9Sstevel@tonic-gate * The LOCKED bit is defined here since it may be returned by the 897c478bd9Sstevel@tonic-gate * "translate" method. 907c478bd9Sstevel@tonic-gate * 917c478bd9Sstevel@tonic-gate * The PROM is not required to implement the Read and eXecute soft bits, 927c478bd9Sstevel@tonic-gate * and is not required to track them for the client program. They may be 937c478bd9Sstevel@tonic-gate * set on calls to "map" and "modfify" and may be ignored by the firmware, 947c478bd9Sstevel@tonic-gate * and are not necessarily returned from "translate". 957c478bd9Sstevel@tonic-gate * 967c478bd9Sstevel@tonic-gate * The TTE soft bits are private to the firmware. No assumptions may 977c478bd9Sstevel@tonic-gate * be made regarding the contents of the TTE soft bits. 987c478bd9Sstevel@tonic-gate * 997c478bd9Sstevel@tonic-gate * Changing a mapping from cacheable to non-cacheable implies a flush 1007c478bd9Sstevel@tonic-gate * or invalidate operation, if necessary. 1017c478bd9Sstevel@tonic-gate * 1027c478bd9Sstevel@tonic-gate * NB: The "map" MMU node method should NOT be used to create IO device 1037c478bd9Sstevel@tonic-gate * mappings. The correct way to do this is to call the device's parent 1047c478bd9Sstevel@tonic-gate * "map-in" method using the CALL-METHOD client interface service. 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_DEFAULT ((int)-1) /* Default "mode", see above */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * NB: These are not implemented in PROM version P1.0 ... 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_WRITE 0x0001 /* Translation is Writable */ 1137c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_READ 0x0002 /* Soft: Readable, See above */ 1147c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_EXEC 0x0004 /* Soft: eXecutable, See above */ 1157c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_RWX_MASK 0x0007 /* Mask for R-W-X bits */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_LOCKED 0x0010 /* Read-only: Locked; see above */ 1187c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_CACHED 0x0020 /* Set means both CV,CP bits */ 1197c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_EFFECTS 0x0040 /* side Effects bit in MMU */ 1207c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_GLOBAL 0x0080 /* Global bit */ 1217c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_INVERT 0x0100 /* Invert Endianness */ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * resource allocation group: OBP only. (mapping functions are platform 1257c478bd9Sstevel@tonic-gate * dependent because they use physical address arguments.) 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate extern caddr_t prom_map(caddr_t virthint, 1287c478bd9Sstevel@tonic-gate unsigned long long physaddr, uint_t size); 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate /* 1317c478bd9Sstevel@tonic-gate * prom_alloc is platform dependent and has historical semantics 1327c478bd9Sstevel@tonic-gate * associated with the align argument and the return value. 1337c478bd9Sstevel@tonic-gate * prom_malloc is the generic memory allocator. 1347c478bd9Sstevel@tonic-gate */ 1357c478bd9Sstevel@tonic-gate extern caddr_t prom_malloc(caddr_t virt, size_t size, uint_t align); 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate extern caddr_t prom_allocate_virt(uint_t align, size_t size); 1387c478bd9Sstevel@tonic-gate extern caddr_t prom_claim_virt(size_t size, caddr_t virt); 1397c478bd9Sstevel@tonic-gate extern void prom_free_virt(size_t size, caddr_t virt); 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate extern int prom_allocate_phys(size_t size, uint_t align, 1427c478bd9Sstevel@tonic-gate unsigned long long *physaddr); 1437c478bd9Sstevel@tonic-gate extern int prom_claim_phys(size_t size, 1447c478bd9Sstevel@tonic-gate unsigned long long physaddr); 1457c478bd9Sstevel@tonic-gate extern void prom_free_phys(size_t size, 1467c478bd9Sstevel@tonic-gate unsigned long long physaddr); 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate extern int prom_map_phys(int mode, size_t size, caddr_t virt, 1497c478bd9Sstevel@tonic-gate unsigned long long physaddr); 1507c478bd9Sstevel@tonic-gate extern void prom_unmap_phys(size_t size, caddr_t virt); 1517c478bd9Sstevel@tonic-gate extern void prom_unmap_virt(size_t size, caddr_t virt); 1527c478bd9Sstevel@tonic-gate 153*986fd29aSsetje extern int prom_phys_installed_len(void); 154*986fd29aSsetje extern int prom_phys_avail_len(void); 155*986fd29aSsetje extern int prom_virt_avail_len(void); 156*986fd29aSsetje 157*986fd29aSsetje extern int prom_phys_installed(caddr_t); 158*986fd29aSsetje extern int prom_phys_avail(caddr_t); 159*986fd29aSsetje extern int prom_virt_avail(caddr_t); 160*986fd29aSsetje 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * prom_retain allocates or returns retained physical memory 1637c478bd9Sstevel@tonic-gate * identified by the arguments of name string "id", "size" and "align". 1647c478bd9Sstevel@tonic-gate */ 1657c478bd9Sstevel@tonic-gate extern int prom_retain(char *id, size_t size, uint_t align, 1667c478bd9Sstevel@tonic-gate unsigned long long *physaddr); 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * prom_translate_virt returns the physical address and virtualized "mode" 1707c478bd9Sstevel@tonic-gate * for the given virtual address. After the call, if *valid is non-zero, 1717c478bd9Sstevel@tonic-gate * a mapping to 'virt' exists and the physical address and virtualized 1727c478bd9Sstevel@tonic-gate * "mode" were returned to the caller. 1737c478bd9Sstevel@tonic-gate */ 1747c478bd9Sstevel@tonic-gate extern int prom_translate_virt(caddr_t virt, int *valid, 1757c478bd9Sstevel@tonic-gate unsigned long long *physaddr, int *mode); 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* 1787c478bd9Sstevel@tonic-gate * prom_modify_mapping changes the "mode" of an existing mapping or 1797c478bd9Sstevel@tonic-gate * repeated mappings. virt is the virtual address whose "mode" is to 1807c478bd9Sstevel@tonic-gate * be changed; size is some multiple of the fundamental pagesize. 1817c478bd9Sstevel@tonic-gate * This method cannot be used to change the pagesize of an MMU mapping, 1827c478bd9Sstevel@tonic-gate * nor can it be used to Lock a translation into the i or d tlb. 1837c478bd9Sstevel@tonic-gate */ 1847c478bd9Sstevel@tonic-gate extern int prom_modify_mapping(caddr_t virt, size_t size, int mode); 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate /* 1877c478bd9Sstevel@tonic-gate * Client interfaces for managing the {i,d}tlb handoff to client programs. 1887c478bd9Sstevel@tonic-gate */ 1897c478bd9Sstevel@tonic-gate extern int prom_itlb_load(int index, 1907c478bd9Sstevel@tonic-gate unsigned long long tte_data, caddr_t virt); 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate extern int prom_dtlb_load(int index, 1937c478bd9Sstevel@tonic-gate unsigned long long tte_data, caddr_t virt); 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * Administrative group: OBP only and SMCC platform specific. 1977c478bd9Sstevel@tonic-gate * XXX: IDPROM related stuff should be replaced with specific data-oriented 1987c478bd9Sstevel@tonic-gate * XXX: functions. 1997c478bd9Sstevel@tonic-gate */ 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate extern int prom_heartbeat(int msecs); 2027c478bd9Sstevel@tonic-gate extern int prom_get_unum(int syn_code, unsigned long long physaddr, 2037c478bd9Sstevel@tonic-gate char *buf, uint_t buflen, int *ustrlen); 2047c478bd9Sstevel@tonic-gate extern int prom_serengeti_get_ecacheunum(int cpuid, 2057c478bd9Sstevel@tonic-gate unsigned long long physaddr, char *buf, 2067c478bd9Sstevel@tonic-gate uint_t buflen, int *ustrlen); 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate extern int prom_getidprom(caddr_t addr, int size); 2097c478bd9Sstevel@tonic-gate extern int prom_getmacaddr(ihandle_t hd, caddr_t ea); 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate /* 2127c478bd9Sstevel@tonic-gate * CPU Control Group: MP's only. 2137c478bd9Sstevel@tonic-gate */ 214fa9e4066Sahrens extern int prom_startcpu(pnode_t node, caddr_t pc, int arg); 2157c478bd9Sstevel@tonic-gate extern int prom_startcpu_bycpuid(int cpuid, caddr_t pc, int arg); 2167c478bd9Sstevel@tonic-gate extern int prom_stopcpu_bycpuid(int); 2177c478bd9Sstevel@tonic-gate extern int prom_sunfire_cpu_off(void); /* SunFire only */ 218fa9e4066Sahrens extern int prom_wakeupcpu(pnode_t node); 219fa9e4066Sahrens extern int prom_serengeti_wakeupcpu(pnode_t node); 2207c478bd9Sstevel@tonic-gate extern int prom_hotaddcpu(int cpuid); 2217c478bd9Sstevel@tonic-gate extern int prom_hotremovecpu(int cpuid); 2227c478bd9Sstevel@tonic-gate extern void promsafe_pause_cpus(void); 2237c478bd9Sstevel@tonic-gate extern void promsafe_xc_attention(cpuset_t cpuset); 224fa9e4066Sahrens extern int prom_serengeti_cpu_off(pnode_t node); 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate /* 2277c478bd9Sstevel@tonic-gate * Set trap table 2287c478bd9Sstevel@tonic-gate */ 2297c478bd9Sstevel@tonic-gate extern void prom_set_traptable(void *tba_addr); 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /* 2327c478bd9Sstevel@tonic-gate * Power-off 2337c478bd9Sstevel@tonic-gate */ 2347c478bd9Sstevel@tonic-gate extern void prom_power_off(void); 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate /* 2377c478bd9Sstevel@tonic-gate * sunfire attach/detach 2387c478bd9Sstevel@tonic-gate */ 2397c478bd9Sstevel@tonic-gate extern int prom_sunfire_attach_board(uint_t board); 2407c478bd9Sstevel@tonic-gate extern int prom_sunfire_detach_board(uint_t board); 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate /* 2437c478bd9Sstevel@tonic-gate * Serengeti console switch 2447c478bd9Sstevel@tonic-gate */ 2457c478bd9Sstevel@tonic-gate extern char *prom_serengeti_set_console_input(char *new_value); 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* 2487c478bd9Sstevel@tonic-gate * Serengeti attach/detach 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate extern int prom_serengeti_attach_board(uint_t node, uint_t board); 2517c478bd9Sstevel@tonic-gate extern int prom_serengeti_detach_board(uint_t node, uint_t board); 2527c478bd9Sstevel@tonic-gate extern int prom_serengeti_tunnel_switch(uint_t node, uint_t board); 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate /* 2557c478bd9Sstevel@tonic-gate * Starcat-specific routines 2567c478bd9Sstevel@tonic-gate */ 2577c478bd9Sstevel@tonic-gate extern int prom_starcat_switch_tunnel(uint_t portid, 2587c478bd9Sstevel@tonic-gate uint_t msgtype); 2597c478bd9Sstevel@tonic-gate extern int prom_starcat_iosram_read(uint32_t key, uint32_t offset, 2607c478bd9Sstevel@tonic-gate uint32_t len, caddr_t buf); 2617c478bd9Sstevel@tonic-gate extern int prom_starcat_iosram_write(uint32_t key, uint32_t offset, 2627c478bd9Sstevel@tonic-gate uint32_t len, caddr_t buf); 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate /* 2657c478bd9Sstevel@tonic-gate * Starfire-specific routines 2667c478bd9Sstevel@tonic-gate */ 2677c478bd9Sstevel@tonic-gate extern int prom_starfire_add_brd(uint_t cpuid); 2687c478bd9Sstevel@tonic-gate extern int prom_starfire_rm_brd(uint_t brdnum); 2697c478bd9Sstevel@tonic-gate extern void prom_starfire_add_cpu(uint_t cpuid); 2707c478bd9Sstevel@tonic-gate extern void prom_starfire_rm_cpu(uint_t cpuid); 2717c478bd9Sstevel@tonic-gate extern int prom_starfire_move_cpu0(uint_t cpuid); 2727c478bd9Sstevel@tonic-gate extern void prom_starfire_init_console(uint_t cpuid); 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate /* 27525cf1a30Sjl139090 * OPL-specific routines 27625cf1a30Sjl139090 */ 27725cf1a30Sjl139090 extern void prom_opl_get_tod(time_t *time, int64_t *stickval); 27825cf1a30Sjl139090 extern void prom_opl_set_diff(int64_t diff); 27925cf1a30Sjl139090 extern int prom_attach_notice(int bn); 28025cf1a30Sjl139090 extern int prom_detach_notice(int bn); 28125cf1a30Sjl139090 extern int prom_opl_switch_console(int bn); 28225cf1a30Sjl139090 28325cf1a30Sjl139090 /* 2847c478bd9Sstevel@tonic-gate * The client program implementation is required to provide a wrapper 2857c478bd9Sstevel@tonic-gate * to the client handler, for the 32 bit client program to 64 bit cell-sized 2867c478bd9Sstevel@tonic-gate * client interface handler (switch stack, etc.). This function is not 2877c478bd9Sstevel@tonic-gate * to be used externally! 2887c478bd9Sstevel@tonic-gate */ 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate extern int client_handler(void *cif_handler, void *arg_array); 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* 2937c478bd9Sstevel@tonic-gate * The 'format' of the "translations" property in the 'mmu' node ... 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate struct translation { 2977c478bd9Sstevel@tonic-gate uint32_t virt_hi; /* upper 32 bits of vaddr */ 2987c478bd9Sstevel@tonic-gate uint32_t virt_lo; /* lower 32 bits of vaddr */ 2997c478bd9Sstevel@tonic-gate uint32_t size_hi; /* upper 32 bits of size in bytes */ 3007c478bd9Sstevel@tonic-gate uint32_t size_lo; /* lower 32 bits of size in bytes */ 3017c478bd9Sstevel@tonic-gate uint32_t tte_hi; /* higher 32 bites of tte */ 3027c478bd9Sstevel@tonic-gate uint32_t tte_lo; /* lower 32 bits of tte */ 3037c478bd9Sstevel@tonic-gate }; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3067c478bd9Sstevel@tonic-gate } 3077c478bd9Sstevel@tonic-gate #endif 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate #endif /* _SYS_PROM_PLAT_H */ 310