* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)vm_sw.c 7.3 (Berkeley) 5/6/88
* Indirect driver for multi-controller paging.
register struct swdevt
*sp
;
* A mini-root gets copied into the front of the swap
* and we run over top of the swap area just long
* enough for us to do a mkfs and restor of the real
* root (sure beats rewriting standalone restor).
#define MINIROOTSIZE 4096
bp
->b_blkno
+= MINIROOTSIZE
;
sz
= howmany(bp
->b_bcount
, DEV_BSIZE
);
if (bp
->b_blkno
+sz
> nswap
) {
off
= bp
->b_blkno
% dmmax
;
seg
= bp
->b_blkno
/ dmmax
;
bp
->b_blkno
= seg
*dmmax
+ off
;
(*bdevsw
[major(bp
->b_dev
)].d_strategy
)(bp
);
* System call swapon(name) enables swapping on device name,
* which must be in the swdevsw. Return EBUSY
* if already swapping on this device.
} *uap
= (struct a
*)u
.u_ap
;
register struct inode
*ip
;
register struct swdevt
*sp
;
register struct nameidata
*ndp
= &u
.u_nd
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->name
;
if ((ip
->i_mode
&IFMT
) != IFBLK
) {
if (major(dev
) >= nblkdev
) {
for (sp
= &swdevt
[0]; sp
->sw_dev
; sp
++)
u
.u_error
= swfree(sp
- swdevt
);
* Swfree(index) frees the index'th portion of the swap map.
* Each of the nswdev devices provides 1/nswdev'th of the swap
* space, which is laid out with blocks of dmmax pages circularly
register struct swdevt
*sp
;
if (error
= (*bdevsw
[major(dev
)].d_open
)(dev
, FREAD
|FWRITE
, S_IFBLK
))
for (dvbase
= 0; dvbase
< nblks
; dvbase
+= dmmax
) {
if ((vsbase
= index
*dmmax
+ dvbase
*nswdev
) >= nswap
)
* Can't free a block starting at 0 in the swapmap
* but need some space for argmap so use 1/2 this
* hunk which needs special treatment anyways.
rminit(argmap
, (long)(blk
/2-ctod(CLSIZE
)),
(long)ctod(CLSIZE
), "argmap", ARGMAPSIZE
);
* First of all chunks... initialize the swapmap
* the second half of the hunk.
rminit(swapmap
, (long)blk
/2, (long)blk
/2,
} else if (dvbase
== 0) {
* Don't use the first cluster of the device
* in case it starts with a label or boot block.
rmfree(swapmap
, blk
- ctod(CLSIZE
),
rmfree(swapmap
, blk
, vsbase
);