11708Sstevel /* 21708Sstevel * CDDL HEADER START 31708Sstevel * 41708Sstevel * The contents of this file are subject to the terms of the 5*1772Sjl139090 * Common Development and Distribution License (the "License"). 6*1772Sjl139090 * You may not use this file except in compliance with the License. 71708Sstevel * 81708Sstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91708Sstevel * or http://www.opensolaris.org/os/licensing. 101708Sstevel * See the License for the specific language governing permissions 111708Sstevel * and limitations under the License. 121708Sstevel * 131708Sstevel * When distributing Covered Code, include this CDDL HEADER in each 141708Sstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151708Sstevel * If applicable, add the following below this CDDL HEADER, with the 161708Sstevel * fields enclosed by brackets "[]" replaced with your own identifying 171708Sstevel * information: Portions Copyright [yyyy] [name of copyright owner] 181708Sstevel * 191708Sstevel * CDDL HEADER END 201708Sstevel */ 211708Sstevel /* 22*1772Sjl139090 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 231708Sstevel * Use is subject to license terms. 241708Sstevel */ 251708Sstevel 261708Sstevel #ifndef _SYS_LIBPRTDIAG_H 271708Sstevel #define _SYS_LIBPRTDIAG_H 281708Sstevel 291708Sstevel #pragma ident "%Z%%M% %I% %E% SMI" 301708Sstevel 311708Sstevel #ifdef __cplusplus 321708Sstevel extern "C" { 331708Sstevel #endif 341708Sstevel 351708Sstevel #include <sys/openpromio.h> 361708Sstevel #include <sys/cheetahregs.h> 371708Sstevel #include "pdevinfo.h" 381708Sstevel #include "display.h" 391708Sstevel #include "pdevinfo_sun4u.h" 401708Sstevel #include "display_sun4u.h" 411708Sstevel 421708Sstevel #ifdef DEBUG 431708Sstevel #define D_PRINTF printf 441708Sstevel #else 451708Sstevel #define D_PRINTF 461708Sstevel #endif 471708Sstevel 481708Sstevel #define EXIT_MSG(msg, err) \ 491708Sstevel { printf("\n%s failed with %d\n", msg, err); exit(err); } 501708Sstevel 511708Sstevel /* global data */ 521708Sstevel #define PCI_DEVICE(x) ((x >> 11) & 0x1f) 531708Sstevel #define PCI_REG_TO_DEV(x) ((x & 0xf800) >> 11) 541708Sstevel #define PCI_REG_TO_FUNC(x) ((x & 0x700) >> 8) 551708Sstevel #define BUS_TYPE "UPA" 561708Sstevel #define MAX_SLOTS_PER_IO_BD 8 571708Sstevel 581708Sstevel 591708Sstevel int sys_clk; /* System clock freq. (in MHz) */ 601708Sstevel 611708Sstevel /* 621708Sstevel * Defines for identifying PCI devices 631708Sstevel */ 641708Sstevel #define PCI_BRIDGE_CLASS 0x6 651708Sstevel #define PCI_CLASS_SHIFT 0x10 661708Sstevel #define PCI_PCI_BRIDGE_SUBCLASS 0x4 671708Sstevel #define PCI_SUBCLASS_SHIFT 0x8 681708Sstevel #define PCI_SUBCLASS_MASK 0xFF00 691708Sstevel #define PCI_SUBCLASS_OTHER 0x80 701708Sstevel 711708Sstevel #define CLASS_REG_TO_SUBCLASS(class) (((class) & PCI_SUBCLASS_MASK) \ 721708Sstevel >> PCI_SUBCLASS_SHIFT) 731708Sstevel #define CLASS_REG_TO_CLASS(class) ((class) >> PCI_CLASS_SHIFT) 741708Sstevel 751708Sstevel /* 761708Sstevel * display functions 771708Sstevel */ 781708Sstevel int error_check(Sys_tree *tree, struct system_kstat_data *kstats); 791708Sstevel int disp_fail_parts(Sys_tree *tree); 801708Sstevel void display_hp_fail_fault(Sys_tree *tree, struct system_kstat_data *kstats); 811708Sstevel void display_diaginfo(int flag, Prom_node *root, Sys_tree *tree, 821708Sstevel struct system_kstat_data *kstats); 831708Sstevel void resolve_board_types(Sys_tree *); 841708Sstevel void display_boardnum(int num); 851708Sstevel void display_platform_specific_header(void); 861708Sstevel 871708Sstevel /* 881708Sstevel * cpu functions 891708Sstevel */ 901708Sstevel void display_cpu_devices(Sys_tree *); 911708Sstevel void display_cpus(Board_node *); 921708Sstevel void display_mid(int mid); 93*1772Sjl139090 uint_t get_cpu_freq(Prom_node *); 941708Sstevel int get_ecache_size(Prom_node *); 951708Sstevel 961708Sstevel /* 971708Sstevel * io functions 981708Sstevel */ 991708Sstevel Prom_node *find_pci_bus(Prom_node *, int, int); 1001708Sstevel int get_pci_bus(Prom_node *); 1011708Sstevel int get_pci_device(Prom_node *); 1021708Sstevel int get_pci_to_pci_device(Prom_node *); 1031708Sstevel void free_io_cards(struct io_card *); 1041708Sstevel struct io_card *insert_io_card(struct io_card *, struct io_card *); 1051708Sstevel char *fmt_manf_id(unsigned int, char *); 1061708Sstevel int get_sbus_slot(Prom_node *); 1071708Sstevel void display_io_devices(Sys_tree *tree); 1081708Sstevel void display_pci(Board_node *bnode); 1091708Sstevel void display_io_cards(struct io_card *); 1101708Sstevel void display_ffb(Board_node *, int); 1111708Sstevel void display_sbus(Board_node *); 1121708Sstevel int populate_slot_name_arr(Prom_node *pci, int *slot_name_bits, 1131708Sstevel char **slot_name_arr, int num_slots); 1141708Sstevel int get_card_frequency(Prom_node *pci); 1151708Sstevel void get_dev_func_num(Prom_node *card_node, int *dev_no, int *func_no); 1161708Sstevel void get_pci_class_codes(Prom_node *card_node, int *class_code, 1171708Sstevel int *subclass_code); 1181708Sstevel int is_pci_bridge(Prom_node *card_node, char *name); 1191708Sstevel int is_pci_bridge_other(Prom_node *card_node, char *name); 1201708Sstevel void get_pci_card_model(Prom_node *card_node, char *model); 1211708Sstevel void create_io_card_name(Prom_node *card_node, char *name, 1221708Sstevel char *card_name); 1231708Sstevel void display_psycho_pci(Board_node *bnode); 1241708Sstevel void get_slot_number_str(struct io_card *card, char **slot_name_arr, 1251708Sstevel int slot_name_bits); 1261708Sstevel void distinguish_identical_io_cards(char *name, Prom_node *node, 1271708Sstevel struct io_card *card); 1281708Sstevel void decode_qlc_card_model_prop(Prom_node *card_node, struct io_card *card); 1291708Sstevel 1301708Sstevel /* 1311708Sstevel * kstat functions 1321708Sstevel */ 1331708Sstevel void read_platform_kstats(Sys_tree *tree, 1341708Sstevel struct system_kstat_data *sys_kstat, 1351708Sstevel struct bd_kstat_data *bdp, struct envctrl_kstat_data *ep); 1361708Sstevel void read_sun4u_kstats(Sys_tree *, struct system_kstat_data *); 1371708Sstevel 1381708Sstevel /* 1391708Sstevel * memory functions 1401708Sstevel */ 1411708Sstevel void display_memorysize(Sys_tree *tree, struct system_kstat_data *kstats, 1421708Sstevel struct grp_info *grps, struct mem_total *memory_total); 1431708Sstevel void display_memoryconf(Sys_tree *tree, struct grp_info *grps); 1441708Sstevel 1451708Sstevel /* 1461708Sstevel * prom functions 1471708Sstevel */ 1481708Sstevel void platform_disp_prom_version(Sys_tree *); 1491708Sstevel void disp_prom_version(Prom_node *); 1501708Sstevel void add_node(Sys_tree *, Prom_node *); 1511708Sstevel Prom_node *find_device(Board_node *, int, char *); 1521708Sstevel Prom_node *walk(Sys_tree *, Prom_node *, int); 1531708Sstevel int get_pci_class_code_reg(Prom_node *); 1541708Sstevel 1551708Sstevel /* 1561708Sstevel * libdevinfo functions 1571708Sstevel */ 1581708Sstevel int do_devinfo(int, char *, int, int); 1591708Sstevel 1601708Sstevel /* 1611708Sstevel * mc-us3 memory functions and structs 1621708Sstevel */ 1631708Sstevel typedef struct memory_bank { 1641708Sstevel int id; 1651708Sstevel int portid; 1661708Sstevel ushort_t valid; 1671708Sstevel ushort_t uk; 1681708Sstevel uint_t um; 1691708Sstevel uchar_t lk; 1701708Sstevel uchar_t lm; 1711708Sstevel uint64_t bank_size; 1721708Sstevel char *bank_status; 1731708Sstevel struct memory_bank *next; /* mc in the devtree */ 1741708Sstevel struct memory_bank *seg_next; /* in the segment */ 1751708Sstevel } memory_bank_t; 1761708Sstevel 1771708Sstevel typedef struct memory_seg { 1781708Sstevel int id; 1791708Sstevel int intlv; /* interleave for this segment */ 1801708Sstevel uint64_t base; /* base address for this segment */ 1811708Sstevel uint64_t size; /* size of this segment */ 1821708Sstevel int nbanks; /* number of banks in this segment */ 1831708Sstevel memory_bank_t *banks; /* pointer to the banks of this seg */ 1841708Sstevel struct memory_seg *next; 1851708Sstevel } memory_seg_t; 1861708Sstevel 1871708Sstevel #define NUM_MBANKS_PER_MC 4 1881708Sstevel 1891708Sstevel int get_us3_mem_regs(Board_node *bnode); 1901708Sstevel void display_us3_banks(void); 1911708Sstevel int display_us3_failed_banks(int system_failed); 1921708Sstevel void print_us3_memory_line(int portid, int bank_id, uint64_t bank_size, 1931708Sstevel char *bank_status, uint64_t dimm_size, uint32_t intlv, int seg_id); 1941708Sstevel void print_us3_failed_memory_line(int portid, int bank_id, 1951708Sstevel char *bank_status); 1961708Sstevel 1971708Sstevel #ifdef __cplusplus 1981708Sstevel } 1991708Sstevel #endif 2001708Sstevel 2011708Sstevel #endif /* _SYS_LIBPRTDIAG_H */ 202