sys/pci_tools.h
author Albert Lee <trisk@forkgnu.org>
Mon, 19 Apr 2010 14:26:19 -0400
changeset 1 6c022a2f0c47
permissions -rw-r--r--
Import pci_tools.h for use outside ON.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     1
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     2
 * CDDL HEADER START
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     3
 *
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     7
 *
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    11
 * and limitations under the License.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    12
 *
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    18
 *
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    19
 * CDDL HEADER END
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    20
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    21
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    23
 * Use is subject to license terms.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    24
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    25
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    26
#ifndef _SYS_PCI_TOOLS_H
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    27
#define	_SYS_PCI_TOOLS_H
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    28
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    29
#include <sys/modctl.h>
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    30
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    31
#ifdef	__cplusplus
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    32
extern "C" {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    33
#endif
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    34
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    35
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    36
 * Versioning.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    37
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    38
#define	PCITOOL_V1	1
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    39
#define	PCITOOL_V2	2
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    40
#define	PCITOOL_VERSION	PCITOOL_V2
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    41
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    42
/* File suffixes for nexus pcitool nodes. */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    43
#define	PCI_MINOR_REG	"reg"
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    44
#define	PCI_MINOR_INTR	"intr"
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    45
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    46
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    47
 * Ioctls for PCI tools.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    48
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    49
#define	PCITOOL_IOC		(('P' << 24) | ('C' << 16) | ('T' << 8))
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    50
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    51
/* Read/write a device on a PCI bus, in physical space. */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    52
#define	PCITOOL_DEVICE_GET_REG		(PCITOOL_IOC | 1)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    53
#define	PCITOOL_DEVICE_SET_REG		(PCITOOL_IOC | 2)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    54
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    55
/* Read/write the PCI nexus bridge, in physical space. */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    56
#define	PCITOOL_NEXUS_GET_REG		(PCITOOL_IOC | 3)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    57
#define	PCITOOL_NEXUS_SET_REG		(PCITOOL_IOC | 4)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    58
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    59
/* Get/set interrupt-CPU mapping for PCI devices. */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    60
#define	PCITOOL_DEVICE_GET_INTR		(PCITOOL_IOC | 5)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    61
#define	PCITOOL_DEVICE_SET_INTR		(PCITOOL_IOC | 6)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    62
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    63
/* Get system interrupt information */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    64
#define	PCITOOL_SYSTEM_INTR_INFO	(PCITOOL_IOC | 8)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    65
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    66
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    67
 * This file contains data structures for the pci tool.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    68
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    69
#define	PCITOOL_CONFIG	0
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    70
#define	PCITOOL_BAR0	1
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    71
#define	PCITOOL_BAR1	2
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    72
#define	PCITOOL_BAR2	3
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    73
#define	PCITOOL_BAR3	4
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    74
#define	PCITOOL_BAR4	5
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    75
#define	PCITOOL_BAR5	6
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    76
#define	PCITOOL_ROM	7
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    77
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    78
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    79
 * Pass this through barnum to signal to use a base addr instead.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    80
 * This is for platforms which do not have a way to automatically map
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    81
 * a selected bank to a base addr.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    82
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    83
#define	PCITOOL_BASE	0xFF
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    84
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    85
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    86
 * BAR corresponding to space desired.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    87
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    88
typedef enum {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    89
    config = PCITOOL_CONFIG,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    90
    bar0 = PCITOOL_BAR0,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    91
    bar1 = PCITOOL_BAR1,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    92
    bar2 = PCITOOL_BAR2,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    93
    bar3 = PCITOOL_BAR3,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    94
    bar4 = PCITOOL_BAR4,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    95
    bar5 = PCITOOL_BAR5,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    96
    rom = PCITOOL_ROM
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    97
} pcitool_bars_t;
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    98
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
    99
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   100
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   101
 * PCITOOL error numbers.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   102
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   103
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   104
typedef enum {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   105
	PCITOOL_SUCCESS = 0x0,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   106
	PCITOOL_INVALID_CPUID,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   107
	PCITOOL_INVALID_INO,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   108
	PCITOOL_INVALID_MSI,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   109
	PCITOOL_PENDING_INTRTIMEOUT,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   110
	PCITOOL_REGPROP_NOTWELLFORMED,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   111
	PCITOOL_INVALID_ADDRESS,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   112
	PCITOOL_NOT_ALIGNED,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   113
	PCITOOL_OUT_OF_RANGE,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   114
	PCITOOL_END_OF_RANGE,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   115
	PCITOOL_ROM_DISABLED,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   116
	PCITOOL_ROM_WRITE,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   117
	PCITOOL_IO_ERROR,
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   118
	PCITOOL_INVALID_SIZE
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   119
} pcitool_errno_t;
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   120
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   121
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   122
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   123
 * PCITOOL_DEVICE_SET_INTR ioctl data structure to re-assign the interrupts.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   124
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   125
typedef struct pcitool_intr_set {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   126
	uint16_t user_version;	/* Userland program version - to krnl */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   127
	uint16_t drvr_version;	/* Driver version - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   128
	uint32_t ino;		/* interrupt to set - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   129
	uint32_t msi;		/* Specific MSI to set - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   130
	uint32_t cpu_id;	/* to: cpu to set / from: old cpu returned */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   131
	uint32_t flags;		/* to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   132
	pcitool_errno_t status;	/* from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   133
} pcitool_intr_set_t;
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   134
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   135
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   136
 * Flags for pcitool_intr_get/set_t/info_t
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   137
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   138
#define	PCITOOL_INTR_FLAG_SET_GROUP	0x1
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   139
#define	PCITOOL_INTR_FLAG_GET_MSI	0x2
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   140
#define	PCITOOL_INTR_FLAG_SET_MSI	0x4
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   141
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   142
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   143
 * PCITOOL_DEVICE_GET_INTR ioctl data structure to dump out the
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   144
 * ino mapping information.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   145
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   146
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   147
typedef struct pcitool_intr_dev {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   148
	uint32_t	dev_inst;	/* device instance - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   149
	char		driver_name[MAXMODCONFNAME];	/* from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   150
	char		path[MAXPATHLEN]; /* device path - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   151
} pcitool_intr_dev_t;
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   152
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   153
typedef struct pcitool_intr_get {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   154
	uint16_t user_version;		/* Userland program version - to krnl */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   155
	uint16_t drvr_version;		/* Driver version - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   156
	uint32_t	ino;		/* interrupt number - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   157
	uint32_t	msi;		/* MSI number - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   158
	uint8_t		num_devs_ret;	/* room for this # of devs to be */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   159
					/* returned - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   160
					/* # devs returned - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   161
	uint8_t		num_devs;	/* # devs on this ino - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   162
					/* intrs enabled for devs if > 0 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   163
	uint8_t		ctlr;		/* controller number - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   164
	uint32_t	cpu_id;		/* cpu of interrupt - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   165
	uint32_t	flags;		/* to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   166
	pcitool_errno_t status;		/* returned status - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   167
	pcitool_intr_dev_t	dev[1];	/* start of variable device list */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   168
					/* from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   169
} pcitool_intr_get_t;
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   170
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   171
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   172
 * Get the size needed to return the number of devices wanted.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   173
 * Can't say num_devs - 1 as num_devs may be unsigned.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   174
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   175
#define	PCITOOL_IGET_SIZE(num_devs) \
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   176
	(sizeof (pcitool_intr_get_t) - \
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   177
	sizeof (pcitool_intr_dev_t) + \
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   178
	(num_devs * sizeof (pcitool_intr_dev_t)))
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   179
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   180
typedef struct pcitool_intr_info {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   181
	uint16_t user_version;		/* Userland program version - to krnl */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   182
	uint16_t drvr_version;		/* Driver version - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   183
	uint32_t flags;			/* to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   184
	uint32_t num_intr;		/* Number of intrs suppt by nexus */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   185
	uint32_t ctlr_version;		/* Intr ctlr HW version - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   186
	uchar_t	ctlr_type;		/* A PCITOOL_CTLR_TYPE - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   187
} pcitool_intr_info_t;
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   188
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   189
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   190
 * Interrupt controller types
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   191
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   192
#define	PCITOOL_CTLR_TYPE_UNKNOWN	0
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   193
#define	PCITOOL_CTLR_TYPE_RISC		1
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   194
#define	PCITOOL_CTLR_TYPE_UPPC		2
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   195
#define	PCITOOL_CTLR_TYPE_PCPLUSMP	3
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   196
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   197
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   198
 * Size and endian fields for acc_attr bitmask.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   199
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   200
#define	PCITOOL_ACC_ATTR_SIZE_MASK	0x3
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   201
#define	PCITOOL_ACC_ATTR_SIZE_1		0x0
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   202
#define	PCITOOL_ACC_ATTR_SIZE_2		0x1
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   203
#define	PCITOOL_ACC_ATTR_SIZE_4		0x2
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   204
#define	PCITOOL_ACC_ATTR_SIZE_8		0x3
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   205
#define	PCITOOL_ACC_ATTR_SIZE(x)	(1 << (x & PCITOOL_ACC_ATTR_SIZE_MASK))
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   206
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   207
#define	PCITOOL_ACC_ATTR_ENDN_MASK	0x100
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   208
#define	PCITOOL_ACC_ATTR_ENDN_LTL	0x0
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   209
#define	PCITOOL_ACC_ATTR_ENDN_BIG	0x100
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   210
#define	PCITOOL_ACC_IS_BIG_ENDIAN(x)	(x & PCITOOL_ACC_ATTR_ENDN_BIG)
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   211
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   212
/*
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   213
 * Data stucture to read and write to pci device registers.
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   214
 * This is the argument to the following ioctls:
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   215
 *	PCITOOL_DEVICE_SET/GET_REG
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   216
 *	PCITOOL_NEXUS_SET/GET_REG
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   217
 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   218
typedef struct pcitool_reg {
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   219
	uint16_t	user_version;	/* Userland program version - to krnl */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   220
	uint16_t	drvr_version;	/* Driver version - from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   221
	uint8_t		bus_no;		/* pci bus - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   222
	uint8_t		dev_no;		/* pci dev - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   223
	uint8_t		func_no;	/* pci function - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   224
	uint8_t		barnum;		/* bank (DEVCTL_NEXUS_SET/GET_REG) or */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   225
					/*   BAR from pcitools_bar_t */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   226
					/*   (DEVCTL_DEVICE_SET/GET_REG) */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   227
					/*   to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   228
	uint64_t	offset;		/* to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   229
	uint32_t	acc_attr;	/* access attributes - to kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   230
	uint32_t	padding1;	/* 8-byte align next uint64_t for X86 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   231
	uint64_t	data;		/* to/from kernel, 64-bit alignment */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   232
	uint32_t	status;		/* from kernel */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   233
	uint32_t	padding2;	/* 8-byte align next uint64_t for X86 */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   234
	uint64_t	phys_addr;	/* from kernel, 64-bit alignment */
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   235
} pcitool_reg_t;
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   236
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   237
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   238
#ifdef	__cplusplus
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   239
}
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   240
#endif
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   241
6c022a2f0c47 Import pci_tools.h for use outside ON.
Albert Lee <trisk@forkgnu.org>
parents:
diff changeset
   242
#endif	/* _SYS_PCI_TOOLS_H */