xref: /onnv-gate/usr/src/uts/sun4u/sys/prom_plat.h (revision 5648:161f8007cab9)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51772Sjl139090  * Common Development and Distribution License (the "License").
61772Sjl139090  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*5648Ssetje  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_PROM_PLAT_H
270Sstevel@tonic-gate #define	_SYS_PROM_PLAT_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/feature_tests.h>
320Sstevel@tonic-gate #include <sys/cpuvar.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #if !defined(_LONGLONG_TYPE)
390Sstevel@tonic-gate #error "This header won't work without long long support"
400Sstevel@tonic-gate #endif
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * This file contains external platform-specific promif interface definitions.
440Sstevel@tonic-gate  * There may be none.  This file is included by reference in <sys/promif.h>
450Sstevel@tonic-gate  *
460Sstevel@tonic-gate  * This version of the file is for the IEEE 1275-1994 compliant sun4u prom.
470Sstevel@tonic-gate  */
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /*
500Sstevel@tonic-gate  * Memory allocation plus memory/mmu interfaces:
510Sstevel@tonic-gate  *
520Sstevel@tonic-gate  * Routines with fine-grained memory and MMU control are platform-dependent.
530Sstevel@tonic-gate  *
540Sstevel@tonic-gate  * MMU node virtualized "mode" arguments and results for Spitfire MMU:
550Sstevel@tonic-gate  *
560Sstevel@tonic-gate  * The default virtualized "mode" for client program mappings created
570Sstevel@tonic-gate  * by the firmware is as follows:
580Sstevel@tonic-gate  *
590Sstevel@tonic-gate  * G (global)		Clear
600Sstevel@tonic-gate  * L (locked)		Clear
610Sstevel@tonic-gate  * W (write)		Set
620Sstevel@tonic-gate  * R (read - soft)	Set (Prom is not required to implement soft bits)
630Sstevel@tonic-gate  * X (exec - soft)	Set (Prom is not required to implement soft bits)
640Sstevel@tonic-gate  * CV,CP (Cacheable)	Set if memory page, Clear if IO page
650Sstevel@tonic-gate  * E (side effects)	Clear if memory page; Set if IO page
660Sstevel@tonic-gate  * IE (Invert endian.)	Clear
670Sstevel@tonic-gate  *
680Sstevel@tonic-gate  * The following fields are initialized as follows in the TTE-data for any
690Sstevel@tonic-gate  * mappings created by the firmware on behalf of the client program:
700Sstevel@tonic-gate  *
710Sstevel@tonic-gate  * P (Priviledged)	Set
720Sstevel@tonic-gate  * V (Valid)		Set
730Sstevel@tonic-gate  * NFO (No Fault Only)	Clear
740Sstevel@tonic-gate  * Context		0
750Sstevel@tonic-gate  * Soft bits		< private to the firmware implementation >
760Sstevel@tonic-gate  *
770Sstevel@tonic-gate  * Page size of Prom mappings are typically 8k, "modify" cannot change
780Sstevel@tonic-gate  * page sizes. Mappings created by "map" are 8k pages.
790Sstevel@tonic-gate  *
800Sstevel@tonic-gate  * If the virtualized "mode" is -1, the defaults as shown above are used,
810Sstevel@tonic-gate  * otherwise the virtualized "mode" is set (and returned) based on the
820Sstevel@tonic-gate  * following virtualized "mode" abstractions. The mmu node "translations"
830Sstevel@tonic-gate  * property contains the actual tte-data, not the virtualized "mode".
840Sstevel@tonic-gate  *
850Sstevel@tonic-gate  * Note that client programs may not create locked mappings by setting
860Sstevel@tonic-gate  * the LOCKED bit. There are Spitfire specific client interfaces to create
870Sstevel@tonic-gate  * and remove locked mappings. (SUNW,{i,d}tlb-load).
880Sstevel@tonic-gate  * The LOCKED bit is defined here since it may be returned by the
890Sstevel@tonic-gate  * "translate" method.
900Sstevel@tonic-gate  *
910Sstevel@tonic-gate  * The PROM is not required to implement the Read and eXecute soft bits,
920Sstevel@tonic-gate  * and is not required to track them for the client program. They may be
930Sstevel@tonic-gate  * set on calls to "map" and "modfify" and may be ignored by the firmware,
940Sstevel@tonic-gate  * and are not necessarily returned from "translate".
950Sstevel@tonic-gate  *
960Sstevel@tonic-gate  * The TTE soft bits are private to the firmware.  No assumptions may
970Sstevel@tonic-gate  * be made regarding the contents of the TTE soft bits.
980Sstevel@tonic-gate  *
990Sstevel@tonic-gate  * Changing a mapping from cacheable to non-cacheable implies a flush
1000Sstevel@tonic-gate  * or invalidate operation, if necessary.
1010Sstevel@tonic-gate  *
1020Sstevel@tonic-gate  * NB: The "map" MMU node method should NOT be used to create IO device
1030Sstevel@tonic-gate  * mappings. The correct way to do this is to call the device's parent
1040Sstevel@tonic-gate  * "map-in" method using the CALL-METHOD client interface service.
1050Sstevel@tonic-gate  */
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate #define	PROM_MMU_MODE_DEFAULT	((int)-1)	/* Default "mode", see above */
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate /*
1100Sstevel@tonic-gate  * NB: These are not implemented in PROM version P1.0 ...
1110Sstevel@tonic-gate  */
1120Sstevel@tonic-gate #define	PROM_MMU_MODE_WRITE	0x0001	/* Translation is Writable */
1130Sstevel@tonic-gate #define	PROM_MMU_MODE_READ	0x0002	/* Soft: Readable, See above */
1140Sstevel@tonic-gate #define	PROM_MMU_MODE_EXEC	0x0004	/* Soft: eXecutable, See above */
1150Sstevel@tonic-gate #define	PROM_MMU_MODE_RWX_MASK	0x0007	/* Mask for R-W-X bits */
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate #define	PROM_MMU_MODE_LOCKED	0x0010	/* Read-only: Locked; see above */
1180Sstevel@tonic-gate #define	PROM_MMU_MODE_CACHED	0x0020	/* Set means both CV,CP bits */
1190Sstevel@tonic-gate #define	PROM_MMU_MODE_EFFECTS	0x0040	/* side Effects bit in MMU */
1200Sstevel@tonic-gate #define	PROM_MMU_MODE_GLOBAL	0x0080	/* Global bit */
1210Sstevel@tonic-gate #define	PROM_MMU_MODE_INVERT	0x0100	/* Invert Endianness */
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate /*
1240Sstevel@tonic-gate  * resource allocation group: OBP only. (mapping functions are platform
1250Sstevel@tonic-gate  * dependent because they use physical address arguments.)
1260Sstevel@tonic-gate  */
1270Sstevel@tonic-gate extern	caddr_t		prom_map(caddr_t virthint,
1280Sstevel@tonic-gate 			    unsigned long long physaddr, uint_t size);
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate /*
1310Sstevel@tonic-gate  * prom_alloc is platform dependent and has historical semantics
1320Sstevel@tonic-gate  * associated with the align argument and the return value.
1330Sstevel@tonic-gate  * prom_malloc is the generic memory allocator.
1340Sstevel@tonic-gate  */
1350Sstevel@tonic-gate extern	caddr_t		prom_malloc(caddr_t virt, size_t size, uint_t align);
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate extern	caddr_t		prom_allocate_virt(uint_t align, size_t size);
1380Sstevel@tonic-gate extern	caddr_t		prom_claim_virt(size_t size, caddr_t virt);
1390Sstevel@tonic-gate extern	void		prom_free_virt(size_t size, caddr_t virt);
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate extern	int		prom_allocate_phys(size_t size, uint_t align,
1420Sstevel@tonic-gate 			    unsigned long long *physaddr);
1430Sstevel@tonic-gate extern	int		prom_claim_phys(size_t size,
1440Sstevel@tonic-gate 			    unsigned long long physaddr);
1450Sstevel@tonic-gate extern	void		prom_free_phys(size_t size,
1460Sstevel@tonic-gate 			    unsigned long long physaddr);
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate extern	int		prom_map_phys(int mode, size_t size, caddr_t virt,
1490Sstevel@tonic-gate 			    unsigned long long physaddr);
1500Sstevel@tonic-gate extern	void		prom_unmap_phys(size_t size, caddr_t virt);
1510Sstevel@tonic-gate extern	void		prom_unmap_virt(size_t size, caddr_t virt);
1520Sstevel@tonic-gate 
153*5648Ssetje extern	int		prom_phys_installed_len(void);
154*5648Ssetje extern	int		prom_phys_avail_len(void);
155*5648Ssetje extern	int		prom_virt_avail_len(void);
156*5648Ssetje 
157*5648Ssetje extern	int		prom_phys_installed(caddr_t);
158*5648Ssetje extern	int		prom_phys_avail(caddr_t);
159*5648Ssetje extern	int		prom_virt_avail(caddr_t);
160*5648Ssetje 
1610Sstevel@tonic-gate /*
1620Sstevel@tonic-gate  * prom_retain allocates or returns retained physical memory
1630Sstevel@tonic-gate  * identified by the arguments of name string "id", "size" and "align".
1640Sstevel@tonic-gate  */
1650Sstevel@tonic-gate extern	int		prom_retain(char *id, size_t size, uint_t align,
1660Sstevel@tonic-gate 			    unsigned long long *physaddr);
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate /*
1690Sstevel@tonic-gate  * prom_translate_virt returns the physical address and virtualized "mode"
1700Sstevel@tonic-gate  * for the given virtual address. After the call, if *valid is non-zero,
1710Sstevel@tonic-gate  * a mapping to 'virt' exists and the physical address and virtualized
1720Sstevel@tonic-gate  * "mode" were returned to the caller.
1730Sstevel@tonic-gate  */
1740Sstevel@tonic-gate extern	int		prom_translate_virt(caddr_t virt, int *valid,
1750Sstevel@tonic-gate 			    unsigned long long *physaddr, int *mode);
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate /*
1780Sstevel@tonic-gate  * prom_modify_mapping changes the "mode" of an existing mapping or
1790Sstevel@tonic-gate  * repeated mappings. virt is the virtual address whose "mode" is to
1800Sstevel@tonic-gate  * be changed; size is some multiple of the fundamental pagesize.
1810Sstevel@tonic-gate  * This method cannot be used to change the pagesize of an MMU mapping,
1820Sstevel@tonic-gate  * nor can it be used to Lock a translation into the i or d tlb.
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate extern	int	prom_modify_mapping(caddr_t virt, size_t size, int mode);
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /*
1870Sstevel@tonic-gate  * Client interfaces for managing the {i,d}tlb handoff to client programs.
1880Sstevel@tonic-gate  */
1890Sstevel@tonic-gate extern	int		prom_itlb_load(int index,
1900Sstevel@tonic-gate 			    unsigned long long tte_data, caddr_t virt);
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate extern	int		prom_dtlb_load(int index,
1930Sstevel@tonic-gate 			    unsigned long long tte_data, caddr_t virt);
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate /*
1960Sstevel@tonic-gate  * Administrative group: OBP only and SMCC platform specific.
1970Sstevel@tonic-gate  * XXX: IDPROM related stuff should be replaced with specific data-oriented
1980Sstevel@tonic-gate  * XXX: functions.
1990Sstevel@tonic-gate  */
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate extern	int		prom_heartbeat(int msecs);
2020Sstevel@tonic-gate extern	int		prom_get_unum(int syn_code, unsigned long long physaddr,
2030Sstevel@tonic-gate 				char *buf, uint_t buflen, int *ustrlen);
2040Sstevel@tonic-gate extern	int		prom_serengeti_get_ecacheunum(int cpuid,
2050Sstevel@tonic-gate 				unsigned long long physaddr, char *buf,
2060Sstevel@tonic-gate 				uint_t buflen, int *ustrlen);
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate extern	int		prom_getidprom(caddr_t addr, int size);
2090Sstevel@tonic-gate extern	int		prom_getmacaddr(ihandle_t hd, caddr_t ea);
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate /*
2120Sstevel@tonic-gate  * CPU Control Group: MP's only.
2130Sstevel@tonic-gate  */
214789Sahrens extern	int		prom_startcpu(pnode_t node, caddr_t pc, int arg);
2150Sstevel@tonic-gate extern	int		prom_startcpu_bycpuid(int cpuid, caddr_t pc, int arg);
2160Sstevel@tonic-gate extern	int		prom_stopcpu_bycpuid(int);
2170Sstevel@tonic-gate extern	int		prom_sunfire_cpu_off(void);	/* SunFire only */
218789Sahrens extern	int		prom_wakeupcpu(pnode_t node);
219789Sahrens extern	int		prom_serengeti_wakeupcpu(pnode_t node);
2200Sstevel@tonic-gate extern	int		prom_hotaddcpu(int cpuid);
2210Sstevel@tonic-gate extern	int		prom_hotremovecpu(int cpuid);
2220Sstevel@tonic-gate extern	void		promsafe_pause_cpus(void);
2230Sstevel@tonic-gate extern	void		promsafe_xc_attention(cpuset_t cpuset);
224789Sahrens extern	int		prom_serengeti_cpu_off(pnode_t node);
2250Sstevel@tonic-gate 
2260Sstevel@tonic-gate /*
2270Sstevel@tonic-gate  * Set trap table
2280Sstevel@tonic-gate  */
2290Sstevel@tonic-gate extern	void		prom_set_traptable(void *tba_addr);
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate /*
2320Sstevel@tonic-gate  * Power-off
2330Sstevel@tonic-gate  */
2340Sstevel@tonic-gate extern	void		prom_power_off(void);
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate /*
2370Sstevel@tonic-gate  * sunfire attach/detach
2380Sstevel@tonic-gate  */
2390Sstevel@tonic-gate extern	int		prom_sunfire_attach_board(uint_t board);
2400Sstevel@tonic-gate extern	int		prom_sunfire_detach_board(uint_t board);
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate /*
2430Sstevel@tonic-gate  * Serengeti console switch
2440Sstevel@tonic-gate  */
2450Sstevel@tonic-gate extern	char		*prom_serengeti_set_console_input(char *new_value);
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate /*
2480Sstevel@tonic-gate  * Serengeti attach/detach
2490Sstevel@tonic-gate  */
2500Sstevel@tonic-gate extern	int		prom_serengeti_attach_board(uint_t node, uint_t board);
2510Sstevel@tonic-gate extern	int		prom_serengeti_detach_board(uint_t node, uint_t board);
2520Sstevel@tonic-gate extern	int		prom_serengeti_tunnel_switch(uint_t node, uint_t board);
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate /*
2550Sstevel@tonic-gate  * Starcat-specific routines
2560Sstevel@tonic-gate  */
2570Sstevel@tonic-gate extern	int		prom_starcat_switch_tunnel(uint_t portid,
2580Sstevel@tonic-gate 			    uint_t msgtype);
2590Sstevel@tonic-gate extern	int		prom_starcat_iosram_read(uint32_t key, uint32_t offset,
2600Sstevel@tonic-gate 			    uint32_t len, caddr_t buf);
2610Sstevel@tonic-gate extern	int		prom_starcat_iosram_write(uint32_t key, uint32_t offset,
2620Sstevel@tonic-gate 			    uint32_t len, caddr_t buf);
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate /*
2650Sstevel@tonic-gate  * Starfire-specific routines
2660Sstevel@tonic-gate  */
2670Sstevel@tonic-gate extern	int		prom_starfire_add_brd(uint_t cpuid);
2680Sstevel@tonic-gate extern	int		prom_starfire_rm_brd(uint_t brdnum);
2690Sstevel@tonic-gate extern	void		prom_starfire_add_cpu(uint_t cpuid);
2700Sstevel@tonic-gate extern	void		prom_starfire_rm_cpu(uint_t cpuid);
2710Sstevel@tonic-gate extern	int		prom_starfire_move_cpu0(uint_t cpuid);
2720Sstevel@tonic-gate extern	void		prom_starfire_init_console(uint_t cpuid);
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate /*
2751772Sjl139090  * OPL-specific routines
2761772Sjl139090  */
2771772Sjl139090 extern	void		prom_opl_get_tod(time_t *time, int64_t *stickval);
2781772Sjl139090 extern	void		prom_opl_set_diff(int64_t diff);
2791772Sjl139090 extern	int		prom_attach_notice(int bn);
2801772Sjl139090 extern	int		prom_detach_notice(int bn);
2811772Sjl139090 extern	int		prom_opl_switch_console(int bn);
2821772Sjl139090 
2831772Sjl139090 /*
2840Sstevel@tonic-gate  * The client program implementation is required to provide a wrapper
2850Sstevel@tonic-gate  * to the client handler, for the 32 bit client program to 64 bit cell-sized
2860Sstevel@tonic-gate  * client interface handler (switch stack, etc.).  This function is not
2870Sstevel@tonic-gate  * to be used externally!
2880Sstevel@tonic-gate  */
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate extern	int		client_handler(void *cif_handler, void *arg_array);
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate /*
2930Sstevel@tonic-gate  * The 'format' of the "translations" property in the 'mmu' node ...
2940Sstevel@tonic-gate  */
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate struct translation {
2970Sstevel@tonic-gate 	uint32_t virt_hi;	/* upper 32 bits of vaddr */
2980Sstevel@tonic-gate 	uint32_t virt_lo;	/* lower 32 bits of vaddr */
2990Sstevel@tonic-gate 	uint32_t size_hi;	/* upper 32 bits of size in bytes */
3000Sstevel@tonic-gate 	uint32_t size_lo;	/* lower 32 bits of size in bytes */
3010Sstevel@tonic-gate 	uint32_t tte_hi;	/* higher 32 bites of tte */
3020Sstevel@tonic-gate 	uint32_t tte_lo;	/* lower 32 bits of tte */
3030Sstevel@tonic-gate };
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate #ifdef	__cplusplus
3060Sstevel@tonic-gate }
3070Sstevel@tonic-gate #endif
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate #endif /* _SYS_PROM_PLAT_H */
310