1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_PROM_PLAT_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_PROM_PLAT_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 36*7c478bd9Sstevel@tonic-gate extern "C" { 37*7c478bd9Sstevel@tonic-gate #endif 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #if !defined(_LONGLONG_TYPE) 40*7c478bd9Sstevel@tonic-gate #error "This header won't work without long long support" 41*7c478bd9Sstevel@tonic-gate #endif 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate /* 44*7c478bd9Sstevel@tonic-gate * This file contains external platform-specific promif interface definitions. 45*7c478bd9Sstevel@tonic-gate * There may be none. This file is included by reference in <sys/promif.h> 46*7c478bd9Sstevel@tonic-gate * 47*7c478bd9Sstevel@tonic-gate * This version of the file is for the IEEE 1275-1994 compliant sun4u prom. 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate /* 51*7c478bd9Sstevel@tonic-gate * Memory allocation plus memory/mmu interfaces: 52*7c478bd9Sstevel@tonic-gate * 53*7c478bd9Sstevel@tonic-gate * Routines with fine-grained memory and MMU control are platform-dependent. 54*7c478bd9Sstevel@tonic-gate * 55*7c478bd9Sstevel@tonic-gate * MMU node virtualized "mode" arguments and results for Spitfire MMU: 56*7c478bd9Sstevel@tonic-gate * 57*7c478bd9Sstevel@tonic-gate * The default virtualized "mode" for client program mappings created 58*7c478bd9Sstevel@tonic-gate * by the firmware is as follows: 59*7c478bd9Sstevel@tonic-gate * 60*7c478bd9Sstevel@tonic-gate * G (global) Clear 61*7c478bd9Sstevel@tonic-gate * L (locked) Clear 62*7c478bd9Sstevel@tonic-gate * W (write) Set 63*7c478bd9Sstevel@tonic-gate * R (read - soft) Set (Prom is not required to implement soft bits) 64*7c478bd9Sstevel@tonic-gate * X (exec - soft) Set (Prom is not required to implement soft bits) 65*7c478bd9Sstevel@tonic-gate * CV,CP (Cacheable) Set if memory page, Clear if IO page 66*7c478bd9Sstevel@tonic-gate * E (side effects) Clear if memory page; Set if IO page 67*7c478bd9Sstevel@tonic-gate * IE (Invert endian.) Clear 68*7c478bd9Sstevel@tonic-gate * 69*7c478bd9Sstevel@tonic-gate * The following fields are initialized as follows in the TTE-data for any 70*7c478bd9Sstevel@tonic-gate * mappings created by the firmware on behalf of the client program: 71*7c478bd9Sstevel@tonic-gate * 72*7c478bd9Sstevel@tonic-gate * P (Priviledged) Set 73*7c478bd9Sstevel@tonic-gate * V (Valid) Set 74*7c478bd9Sstevel@tonic-gate * NFO (No Fault Only) Clear 75*7c478bd9Sstevel@tonic-gate * Context 0 76*7c478bd9Sstevel@tonic-gate * Soft bits < private to the firmware implementation > 77*7c478bd9Sstevel@tonic-gate * 78*7c478bd9Sstevel@tonic-gate * Page size of Prom mappings are typically 8k, "modify" cannot change 79*7c478bd9Sstevel@tonic-gate * page sizes. Mappings created by "map" are 8k pages. 80*7c478bd9Sstevel@tonic-gate * 81*7c478bd9Sstevel@tonic-gate * If the virtualized "mode" is -1, the defaults as shown above are used, 82*7c478bd9Sstevel@tonic-gate * otherwise the virtualized "mode" is set (and returned) based on the 83*7c478bd9Sstevel@tonic-gate * following virtualized "mode" abstractions. The mmu node "translations" 84*7c478bd9Sstevel@tonic-gate * property contains the actual tte-data, not the virtualized "mode". 85*7c478bd9Sstevel@tonic-gate * 86*7c478bd9Sstevel@tonic-gate * Note that client programs may not create locked mappings by setting 87*7c478bd9Sstevel@tonic-gate * the LOCKED bit. There are Spitfire specific client interfaces to create 88*7c478bd9Sstevel@tonic-gate * and remove locked mappings. (SUNW,{i,d}tlb-load). 89*7c478bd9Sstevel@tonic-gate * The LOCKED bit is defined here since it may be returned by the 90*7c478bd9Sstevel@tonic-gate * "translate" method. 91*7c478bd9Sstevel@tonic-gate * 92*7c478bd9Sstevel@tonic-gate * The PROM is not required to implement the Read and eXecute soft bits, 93*7c478bd9Sstevel@tonic-gate * and is not required to track them for the client program. They may be 94*7c478bd9Sstevel@tonic-gate * set on calls to "map" and "modfify" and may be ignored by the firmware, 95*7c478bd9Sstevel@tonic-gate * and are not necessarily returned from "translate". 96*7c478bd9Sstevel@tonic-gate * 97*7c478bd9Sstevel@tonic-gate * The TTE soft bits are private to the firmware. No assumptions may 98*7c478bd9Sstevel@tonic-gate * be made regarding the contents of the TTE soft bits. 99*7c478bd9Sstevel@tonic-gate * 100*7c478bd9Sstevel@tonic-gate * Changing a mapping from cacheable to non-cacheable implies a flush 101*7c478bd9Sstevel@tonic-gate * or invalidate operation, if necessary. 102*7c478bd9Sstevel@tonic-gate * 103*7c478bd9Sstevel@tonic-gate * NB: The "map" MMU node method should NOT be used to create IO device 104*7c478bd9Sstevel@tonic-gate * mappings. The correct way to do this is to call the device's parent 105*7c478bd9Sstevel@tonic-gate * "map-in" method using the CALL-METHOD client interface service. 106*7c478bd9Sstevel@tonic-gate */ 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_DEFAULT ((int)-1) /* Default "mode", see above */ 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate /* 111*7c478bd9Sstevel@tonic-gate * NB: These are not implemented in PROM version P1.0 ... 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_WRITE 0x0001 /* Translation is Writable */ 114*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_READ 0x0002 /* Soft: Readable, See above */ 115*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_EXEC 0x0004 /* Soft: eXecutable, See above */ 116*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_RWX_MASK 0x0007 /* Mask for R-W-X bits */ 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_LOCKED 0x0010 /* Read-only: Locked; see above */ 119*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_CACHED 0x0020 /* Set means both CV,CP bits */ 120*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_EFFECTS 0x0040 /* side Effects bit in MMU */ 121*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_GLOBAL 0x0080 /* Global bit */ 122*7c478bd9Sstevel@tonic-gate #define PROM_MMU_MODE_INVERT 0x0100 /* Invert Endianness */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* 125*7c478bd9Sstevel@tonic-gate * resource allocation group: OBP only. (mapping functions are platform 126*7c478bd9Sstevel@tonic-gate * dependent because they use physical address arguments.) 127*7c478bd9Sstevel@tonic-gate */ 128*7c478bd9Sstevel@tonic-gate extern caddr_t prom_map(caddr_t virthint, 129*7c478bd9Sstevel@tonic-gate unsigned long long physaddr, uint_t size); 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate /* 132*7c478bd9Sstevel@tonic-gate * prom_alloc is platform dependent and has historical semantics 133*7c478bd9Sstevel@tonic-gate * associated with the align argument and the return value. 134*7c478bd9Sstevel@tonic-gate * prom_malloc is the generic memory allocator. 135*7c478bd9Sstevel@tonic-gate */ 136*7c478bd9Sstevel@tonic-gate extern caddr_t prom_malloc(caddr_t virt, size_t size, uint_t align); 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate extern caddr_t prom_allocate_virt(uint_t align, size_t size); 139*7c478bd9Sstevel@tonic-gate extern caddr_t prom_claim_virt(size_t size, caddr_t virt); 140*7c478bd9Sstevel@tonic-gate extern void prom_free_virt(size_t size, caddr_t virt); 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate extern int prom_allocate_phys(size_t size, uint_t align, 143*7c478bd9Sstevel@tonic-gate unsigned long long *physaddr); 144*7c478bd9Sstevel@tonic-gate extern int prom_claim_phys(size_t size, 145*7c478bd9Sstevel@tonic-gate unsigned long long physaddr); 146*7c478bd9Sstevel@tonic-gate extern void prom_free_phys(size_t size, 147*7c478bd9Sstevel@tonic-gate unsigned long long physaddr); 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate extern int prom_map_phys(int mode, size_t size, caddr_t virt, 150*7c478bd9Sstevel@tonic-gate unsigned long long physaddr); 151*7c478bd9Sstevel@tonic-gate extern void prom_unmap_phys(size_t size, caddr_t virt); 152*7c478bd9Sstevel@tonic-gate extern void prom_unmap_virt(size_t size, caddr_t virt); 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* 155*7c478bd9Sstevel@tonic-gate * prom_retain allocates or returns retained physical memory 156*7c478bd9Sstevel@tonic-gate * identified by the arguments of name string "id", "size" and "align". 157*7c478bd9Sstevel@tonic-gate */ 158*7c478bd9Sstevel@tonic-gate extern int prom_retain(char *id, size_t size, uint_t align, 159*7c478bd9Sstevel@tonic-gate unsigned long long *physaddr); 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate /* 162*7c478bd9Sstevel@tonic-gate * prom_translate_virt returns the physical address and virtualized "mode" 163*7c478bd9Sstevel@tonic-gate * for the given virtual address. After the call, if *valid is non-zero, 164*7c478bd9Sstevel@tonic-gate * a mapping to 'virt' exists and the physical address and virtualized 165*7c478bd9Sstevel@tonic-gate * "mode" were returned to the caller. 166*7c478bd9Sstevel@tonic-gate */ 167*7c478bd9Sstevel@tonic-gate extern int prom_translate_virt(caddr_t virt, int *valid, 168*7c478bd9Sstevel@tonic-gate unsigned long long *physaddr, int *mode); 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate /* 171*7c478bd9Sstevel@tonic-gate * prom_modify_mapping changes the "mode" of an existing mapping or 172*7c478bd9Sstevel@tonic-gate * repeated mappings. virt is the virtual address whose "mode" is to 173*7c478bd9Sstevel@tonic-gate * be changed; size is some multiple of the fundamental pagesize. 174*7c478bd9Sstevel@tonic-gate * This method cannot be used to change the pagesize of an MMU mapping, 175*7c478bd9Sstevel@tonic-gate * nor can it be used to Lock a translation into the i or d tlb. 176*7c478bd9Sstevel@tonic-gate */ 177*7c478bd9Sstevel@tonic-gate extern int prom_modify_mapping(caddr_t virt, size_t size, int mode); 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /* 180*7c478bd9Sstevel@tonic-gate * Client interfaces for managing the {i,d}tlb handoff to client programs. 181*7c478bd9Sstevel@tonic-gate */ 182*7c478bd9Sstevel@tonic-gate extern int prom_itlb_load(int index, 183*7c478bd9Sstevel@tonic-gate unsigned long long tte_data, caddr_t virt); 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate extern int prom_dtlb_load(int index, 186*7c478bd9Sstevel@tonic-gate unsigned long long tte_data, caddr_t virt); 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate /* 189*7c478bd9Sstevel@tonic-gate * Administrative group: OBP only and SMCC platform specific. 190*7c478bd9Sstevel@tonic-gate * XXX: IDPROM related stuff should be replaced with specific data-oriented 191*7c478bd9Sstevel@tonic-gate * XXX: functions. 192*7c478bd9Sstevel@tonic-gate */ 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate extern int prom_get_unum(int syn_code, unsigned long long physaddr, 195*7c478bd9Sstevel@tonic-gate char *buf, uint_t buflen, int *ustrlen); 196*7c478bd9Sstevel@tonic-gate extern int prom_getidprom(caddr_t addr, int size); 197*7c478bd9Sstevel@tonic-gate extern int prom_getmacaddr(ihandle_t hd, caddr_t ea); 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate /* 200*7c478bd9Sstevel@tonic-gate * CPU Control Group: MP's only. 201*7c478bd9Sstevel@tonic-gate */ 202*7c478bd9Sstevel@tonic-gate extern int prom_startcpu(dnode_t node, caddr_t pc, int arg); 203*7c478bd9Sstevel@tonic-gate extern int prom_startcpu_bycpuid(int cpuid, caddr_t pc, int arg); 204*7c478bd9Sstevel@tonic-gate extern int prom_stopcpu_bycpuid(int); 205*7c478bd9Sstevel@tonic-gate extern void promsafe_pause_cpus(void); 206*7c478bd9Sstevel@tonic-gate extern void promsafe_xc_attention(cpuset_t cpuset); 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate /* 209*7c478bd9Sstevel@tonic-gate * Set trap table 210*7c478bd9Sstevel@tonic-gate */ 211*7c478bd9Sstevel@tonic-gate extern void prom_set_mmfsa_traptable(void *tba_addr, 212*7c478bd9Sstevel@tonic-gate uint64_t mmfsa_ra); 213*7c478bd9Sstevel@tonic-gate /* 214*7c478bd9Sstevel@tonic-gate * Power-off 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate extern void prom_power_off(void); 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate /* 219*7c478bd9Sstevel@tonic-gate * The client program implementation is required to provide a wrapper 220*7c478bd9Sstevel@tonic-gate * to the client handler, for the 32 bit client program to 64 bit cell-sized 221*7c478bd9Sstevel@tonic-gate * client interface handler (switch stack, etc.). This function is not 222*7c478bd9Sstevel@tonic-gate * to be used externally! 223*7c478bd9Sstevel@tonic-gate */ 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate extern int client_handler(void *cif_handler, void *arg_array); 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate /* 228*7c478bd9Sstevel@tonic-gate * The 'format' of the "translations" property in the 'mmu' node ... 229*7c478bd9Sstevel@tonic-gate */ 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate struct translation { 232*7c478bd9Sstevel@tonic-gate uint32_t virt_hi; /* upper 32 bits of vaddr */ 233*7c478bd9Sstevel@tonic-gate uint32_t virt_lo; /* lower 32 bits of vaddr */ 234*7c478bd9Sstevel@tonic-gate uint32_t size_hi; /* upper 32 bits of size in bytes */ 235*7c478bd9Sstevel@tonic-gate uint32_t size_lo; /* lower 32 bits of size in bytes */ 236*7c478bd9Sstevel@tonic-gate uint32_t tte_hi; /* higher 32 bites of tte */ 237*7c478bd9Sstevel@tonic-gate uint32_t tte_lo; /* lower 32 bits of tte */ 238*7c478bd9Sstevel@tonic-gate }; 239*7c478bd9Sstevel@tonic-gate 240*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 241*7c478bd9Sstevel@tonic-gate } 242*7c478bd9Sstevel@tonic-gate #endif 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate #endif /* _SYS_PROM_PLAT_H */ 245