17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright (c) 1991-1994 Sun Microsystems, Inc. 24*1f0c5e61SRobert Mustacchi * Copyright 2016 Joyent, Inc. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_DDIMAPREQ_H 287c478bd9Sstevel@tonic-gate #define _SYS_DDIMAPREQ_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/mman.h> 317c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef _KERNEL 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * Mapping requests are for an rnumber or for a regspec. 417c478bd9Sstevel@tonic-gate * 427c478bd9Sstevel@tonic-gate * A regspec is a generic triple, usually representing 437c478bd9Sstevel@tonic-gate * type, offset, length 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * And is interpreted privately between the child and parent. 467c478bd9Sstevel@tonic-gate * The triple should be sufficient for representing byte addressable devices. 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate typedef union { 507c478bd9Sstevel@tonic-gate int rnumber; 517c478bd9Sstevel@tonic-gate struct regspec *rp; 527c478bd9Sstevel@tonic-gate } ddi_map_obj_t; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate typedef enum { 557c478bd9Sstevel@tonic-gate DDI_MT_RNUMBER = 0, 567c478bd9Sstevel@tonic-gate DDI_MT_REGSPEC 577c478bd9Sstevel@tonic-gate } ddi_map_type_t; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * Mapping operators: 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate typedef enum { 637c478bd9Sstevel@tonic-gate DDI_MO_MAP_UNLOCKED = 0, /* Create mapping, do not lock down */ 647c478bd9Sstevel@tonic-gate DDI_MO_MAP_LOCKED, /* Create locked down mapping */ 657c478bd9Sstevel@tonic-gate DDI_MO_MAP_HANDLE, /* Create handle, do not map */ 667c478bd9Sstevel@tonic-gate DDI_MO_UNMAP, /* Unmap (implies unlock, if locked) */ 677c478bd9Sstevel@tonic-gate DDI_MO_UNLOCK /* Unlock mapping, do *not* unmap */ 687c478bd9Sstevel@tonic-gate } ddi_map_op_t; 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* 717c478bd9Sstevel@tonic-gate * Mapping request structure... 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate typedef struct { 757c478bd9Sstevel@tonic-gate ddi_map_op_t map_op; 767c478bd9Sstevel@tonic-gate ddi_map_type_t map_type; 777c478bd9Sstevel@tonic-gate ddi_map_obj_t map_obj; 78*1f0c5e61SRobert Mustacchi uint_t map_flags; /* See below... */ 797c478bd9Sstevel@tonic-gate int map_prot; /* Prot bits (see sys/mman.h) */ 807c478bd9Sstevel@tonic-gate ddi_acc_hdl_t *map_handlep; 817c478bd9Sstevel@tonic-gate int map_vers; 827c478bd9Sstevel@tonic-gate } ddi_map_req_t; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * version number 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate #define DDI_MAP_VERSION 0x0001 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Mappings subject to the following flags: 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * Make mapping suitable for user program use. 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate #define DDI_MF_USER_MAPPING 0x1 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * Make mapping suitable for kernel mapping. 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate #define DDI_MF_KERNEL_MAPPING 0x2 1027c478bd9Sstevel@tonic-gate #define DDI_MF_DEVICE_MAPPING 0x4 1037c478bd9Sstevel@tonic-gate 104*1f0c5e61SRobert Mustacchi /* 105*1f0c5e61SRobert Mustacchi * The upper bits of map_flags are reserved for platform-specific flags. These 106*1f0c5e61SRobert Mustacchi * start with the highest bit and then work their way down. Currently only one 107*1f0c5e61SRobert Mustacchi * bit is used, and only on x86. 108*1f0c5e61SRobert Mustacchi */ 109*1f0c5e61SRobert Mustacchi /* 110*1f0c5e61SRobert Mustacchi * Indicates that there is an extended register 111*1f0c5e61SRobert Mustacchi * specification (fully 64-bit aware) being used. This 112*1f0c5e61SRobert Mustacchi * should only be used by children of the x86 root nexus 113*1f0c5e61SRobert Mustacchi * driver. 114*1f0c5e61SRobert Mustacchi */ 115*1f0c5e61SRobert Mustacchi #define DDI_MF_EXT_REGSPEC 0x80000000 116*1f0c5e61SRobert Mustacchi 1177c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* 1207c478bd9Sstevel@tonic-gate * Error (non-zero) return codes from DDI mapping functions... 1217c478bd9Sstevel@tonic-gate */ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #define DDI_ME_GENERIC (-1) /* Generic un-enumerated error */ 1247c478bd9Sstevel@tonic-gate #define DDI_ME_UNIMPLEMENTED (-2) /* Unimplemented operator */ 1257c478bd9Sstevel@tonic-gate #define DDI_ME_NORESOURCES (-3) /* No resources, try later? */ 1267c478bd9Sstevel@tonic-gate #define DDI_ME_UNSUPPORTED (-4) /* Op is not supported in impl. */ 1277c478bd9Sstevel@tonic-gate #define DDI_ME_REGSPEC_RANGE (-5) /* Addressing range error */ 1287c478bd9Sstevel@tonic-gate #define DDI_ME_RNUMBER_RANGE (-6) /* Addressing range error */ 1297c478bd9Sstevel@tonic-gate #define DDI_ME_INVAL (-7) /* Invalid input parameter */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate #endif 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate #endif /* _SYS_DDIMAPREQ_H */ 136