ddidevmap.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_DDIDEVMAP_H
#define _SYS_DDIDEVMAP_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
struct devmap_info {
/*
* describes order in which the CPU will reference data.
*/
};
typedef void * ddi_umem_cookie_t;
/*
* umem callback function vector for drivers
*
* NOTE: IMPORTANT! When umem_lockmemory is called with a valid
* umem_callback_ops and DDI_UMEMLOCK_LONGTERM set, the 'cleanup'
* callback function may be called AFTER a call to ddi_umem_lock.
* It is the users responsibility to make sure that ddi_umem_lock is
* called ONLY once for each ddi_umem_lock/umem_lockmemory cookie.
*/
#define UMEM_CALLBACK_VERSION 1
struct umem_callback_ops {
int cbo_umem_callback_version; /* version number */
void (*cbo_umem_lock_cleanup)(ddi_umem_cookie_t *);
};
struct ddi_umem_cookie {
/* KMEM - kvaddr returned from ddi_umem_alloc() */
/* For LOCKEDUMEM - user address of backing store */
/* For TRASH_UMEM - unused */
/*
* Following 4 members are used for UMEM_LOCKED cookie type
*/
void *procp; /* user process owning backing store */
/*
* locked indicates underlying memory locked for KMEM_PAGEABLE
* locked is a count of for how many pages this has been locked
*/
struct umem_callback_ops callbacks;
/*
* cook_refcnt used in UMEM_LOCKED type
*/
void *lockmem_proj; /* project ptr for resource mgmt */
};
typedef struct as *ddi_as_handle_t;
/*
* type of umem_cookie:
* pageable memory allocated from segkp segment driver
* non-pageable memory allocated from kmem_getpages()
* locked umem allocated from ddi_umem_lock
* trash umem maps all user virtual addresses to a common trash page
*/
typedef struct __devmap_pmem_cookie *devmap_pmem_cookie_t;
typedef void *devmap_cookie_t;
struct devmap_callback_ctl {
int devmap_rev; /* devmap_callback_ctl version number */
void **new_pvtp2);
};
struct devmap_softlock {
struct devmap_softlock *next;
int refcnt; /* Number of threads with mappings */
};
struct devmap_ctx {
struct devmap_ctx *next;
int refcnt; /* Number of threads with mappings */
};
/*
* Fault information passed to the driver fault handling routine.
* The DEVMAP_LOCK and DEVMAP_UNLOCK are used by software
* to lock and unlock pages for physical I/O.
*/
enum devmap_fault_type {
DEVMAP_ACCESS, /* invalid page */
DEVMAP_PROT, /* protection fault */
DEVMAP_LOCK, /* software requested locking */
DEVMAP_UNLOCK /* software requested unlocking */
};
/*
* seg_rw gives the access type for a fault operation
*/
enum devmap_rw {
DEVMAP_OTHER, /* unknown or not touched */
DEVMAP_READ, /* read access attempted */
DEVMAP_WRITE, /* write access attempted */
DEVMAP_EXEC, /* execution access attempted */
DEVMAP_CREATE /* create if page doesn't exist */
};
typedef struct devmap_handle {
/*
* physical offset at the beginning of mapping.
*/
/*
* user offset at the beginning of mapping.
*/
/*
* Lock protects fields that can change during remap
* dh_roff, dh_cookie, dh_flags, dh_mmulevel, dh_maxprot,
* dh_pfn, dh_hat_attr
*/
/*
* to sync. faults for remap and unlocked kvaddr.
*/
void *dh_pvtp; /* device mapping private data */
struct devmap_handle *dh_next;
struct devmap_softlock *dh_softlock;
struct devmap_ctx *dh_ctx;
/*
* protection flag possible for attempted mapping.
*/
/*
* Current maximum protection flag for attempted mapping.
* This controls how dh_prot can be changed in segdev_setprot
* See dh_orig_maxprot below also
*/
/*
* mmu level corresponds to the Max page size can be use for
* the mapping.
*/
struct devmap_callback_ctl dh_callbackops;
/*
* orig_maxprot is what the original mmap set maxprot to.
* This is never modified once it is setup during mmap(2)
* This is different from the current dh_maxprot which can
*/
#endif /* _KERNEL */
/*
* define for devmap_rev
*/
#define DEVMAP_OPS_REV 1
/*
* defines for devmap_*_setup flag, called by drivers
*/
#define DEVMAP_DEFAULTS 0x00
/* flags used by drivers */
#define DEVMAP_SETUP_FLAGS \
/*
* defines for dh_flags, these are used internally in devmap
*/
/*
* Flags to pass to ddi_umem_alloc and ddi_umem_iosetup
*/
#define DDI_UMEM_SLEEP 0x0
#define DDI_UMEM_NOSLEEP 0x01
#define DDI_UMEM_PAGEABLE 0x02
#define DDI_UMEM_TRASH 0x04
/*
* Flags to pass to ddi_umem_lock to indicate expected access pattern
* DDI_UMEMLOCK_READ implies the memory being locked will be read
* (e.g., data read from memory is written out to the disk or network)
* DDI_UMEMLOCK_WRITE implies the memory being locked will be written
* (e.g., data from the disk or network is written to memory)
* Both flags may be set in the call to ddi_umem_lock,
* and also correspond to the prots set in devmap
* meaning. Be careful when using it both for I/O and devmap
*
*
*/
#define DDI_UMEMLOCK_READ 0x01
#define DDI_UMEMLOCK_WRITE 0x02
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DDIDEVMAP_H */