1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _PCITOOL_UI_H 27 #define _PCITOOL_UI_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* 34 * This defines the interface between the pcitool_ui.c module which parses the 35 * commandline options, and the other pcitool modules which process them. 36 */ 37 #define SUCCESS 0 /* This does not conflict with errno values. */ 38 #define FAILURE -1 /* General failure. */ 39 40 /* 41 * Flags which get set in the flags field of pcitool_uiargs_t. There is a flag 42 * for each option specified on the commandline. 43 */ 44 #define NEXUS_FLAG 0x1 45 #define LEAF_FLAG 0x2 46 #define INTR_FLAG 0x4 47 #define PROBEDEV_FLAG 0x8 /* Probe a specific device */ 48 #define PROBETREE_FLAG 0x10 /* Probe all devs on a tree */ 49 #define PROBEALL_FLAG 0x20 /* Probe devs on all trees */ 50 #define PROBERNG_FLAG 0x40 /* Probe devs within bus ranges */ 51 /* - mod to PROBEALL and PROBETREE */ 52 #define PROBE_FLAGS (PROBEDEV_FLAG | PROBETREE_FLAG | PROBEALL_FLAG | \ 53 PROBERNG_FLAG) 54 #define ALL_COMMANDS (NEXUS_FLAG | LEAF_FLAG | INTR_FLAG | PROBE_FLAGS) 55 #define READ_FLAG 0x80 56 #define WRITE_FLAG 0x100 57 #define OFFSET_FLAG 0x200 58 #define SIZE_FLAG 0x400 59 #define ENDIAN_FLAG 0x800 60 #define BYTEDUMP_FLAG 0x1000 61 #define CHARDUMP_FLAG 0x2000 62 #define ERRCONT_FLAG 0x4000 63 #define VERBOSE_FLAG 0x8000 64 #define QUIET_FLAG 0x10000 65 #define LOOP_FLAG 0x20000 66 #define SHOWCTLR_FLAG 0x40000 67 #define SETGRP_FLAG 0x80000 68 69 /* Values specified by suboption parser. */ 70 #define BANK_SPEC_FLAG (0x10000ULL << 32) 71 #define BASE_SPEC_FLAG (0x20000ULL << 32) 72 #define BUS_SPEC_FLAG (0x40000ULL << 32) 73 #define DEV_SPEC_FLAG (0x80000ULL << 32) 74 #define FUNC_SPEC_FLAG (0x100000ULL << 32) 75 #define CPU_SPEC_FLAG (0x200000ULL << 32) 76 #define INO_SPEC_FLAG (0x400000ULL << 32) 77 78 /* Macros for a few heavily-used flags. */ 79 #define IS_VERBOSE(flags) (flags & VERBOSE_FLAG) 80 #define IS_QUIET(flags) (flags & QUIET_FLAG) 81 #define IS_LOOP(flags) (flags & LOOP_FLAG) 82 83 /* 84 * This is the structure of flags and parsed values returned from pcitool_ui.c 85 */ 86 typedef struct uiargs { 87 uint64_t write_value; 88 uint64_t base_address; 89 uint64_t flags; 90 uint32_t offset; 91 uint32_t bytedump_amt; 92 uint32_t intr_cpu; 93 uint8_t bus; 94 uint8_t device; 95 uint8_t function; 96 uint8_t size; 97 uint8_t bank; 98 uint8_t intr_ino; 99 boolean_t big_endian; 100 } pcitool_uiargs_t; 101 102 /* Exported functions. */ 103 104 int get_commandline_args(int argc, char *argv[], pcitool_uiargs_t *parsed_args); 105 void usage(char *name); 106 107 #ifdef __cplusplus 108 } 109 #endif 110 111 #endif /* _PCITOOL_UI_H */ 112