swap.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.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#ifndef _SYS_SWAP_H
#define _SYS_SWAP_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/isa_defs.h>
#include <sys/feature_tests.h>
#ifdef __cplusplus
extern "C" {
#endif
#error "Cannot use swapctl in the large files compilation environment"
#endif
/* The following are for the swapctl system call */
typedef struct swapres {
char *sr_name; /* pathname of the resource specified */
} swapres_t;
typedef struct swapent {
char *ste_path; /* get the name of the swap file */
long ste_pages; /* numbers of pages for swapping */
long ste_free; /* numbers of ste_pages free */
int ste_flags; /* see below */
} swapent_t;
typedef struct swaptable {
int swt_n; /* number of swapents following */
} swaptbl_t;
#if defined(_SYSCALL32)
/* Kernel's view of user ILP32 swapres and swapent structures */
typedef struct swapres32 {
} swapres32_t;
typedef struct swapent32 {
} swapent32_t;
typedef struct swaptable32 {
} swaptbl32_t;
#endif /* _SYSCALL32 */
#if defined(_KERNEL)
extern int swapctl(int, void *, int *);
#if defined(_LP64) && defined(_SYSCALL32)
extern int swapctl32(int, void *, int *);
#endif /* _LP64 && _SYSCALL32 */
#else /* !_KERNEL */
#if defined(__STDC__)
extern int swapctl(int, void *);
#else
extern int swapctl();
#endif
#endif /* _KERNEL */
/* ste_flags values */
/* Prevents others from deleting or */
/* allocating from it */
/* Clearing during deletion signals */
/* that you want to add the file back */
/* again, and will eventually cause */
/* it to be added back */
/*
* VM - virtual swap device.
*/
struct swapinfo {
int si_allocs; /* # of conseq. allocs from this area */
short si_flags; /* flags defined below */
int si_pnamelen; /* swap file name length + 1 */
char *si_pname; /* swap file name */
};
/*
* Stuff to convert an anon slot pointer to a page name.
* Because the address of the slot (ap) is a unique identifier, we
* use it to generate a unique (vp,off), as shown below.
*
* |<-- 11 bits -->|<------32 - 11 --------->|
* vp index bits off bits
*
* The off bits are shifted PAGESHIFT to directly form a page aligned
* offset; the vp index bits map 1-1 to a vnode.
*
* Note: if we go to 64 bit offsets, we could use all the bits as the
* unique offset and just have one vnode.
*/
/* 16 bytes */
/*
* Convert from an anon slot to associated vnode and offset.
*/
{ \
}
#define swap_xlate_nopanic swap_xlate
/*
* Get a vnode name for an anon slot.
* The vnum, offset are derived from anon struct address which is
* 16 bytes aligned. To get swap offset the anon address is shifted
* by additional 11 bits which yields 32K aligned swap offset
* (11 bits plus 4 bits alignment).
* The vnum (vnode index) is created from bits 31-21.
* The 64 bit swap offset is created from bits 63-32 and 20-4.
* The 32 bit offset is created from bits 20-4.
*
* +-----------...----------+--------+-----------------------+----+
* | swap offset | vnum | swap offset |0000|
* +-----------...----------+--------+-----------------------+----+
* 63 32 31 21 20 4 3 0
*/
#define swap_alloc(AP) \
{ \
& AN_VPSIZEMASK); \
}
/*
* Free the page name for the specified anon slot.
* For now there's nothing to do.
*/
/* Flags for swap_phys_alloc */
/* Special error codes for swap_newphysname() */
#ifdef _KERNEL
extern int swap_debug;
#endif /* _KERNEL */
#ifdef SWAP_DEBUG
#define SW_RENAME 0x01
#define SW_RESV 0x02
#define SW_ALLOC 0x04
#define SW_CTL 0x08
if (swap_debug & f) \
#else /* SWAP_DEBUG */
#endif /* SWAP_DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SWAP_H */