vm_page.h (38479) | vm_page.h (38517) |
---|---|
1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 47 unchanged lines hidden (view full) --- 56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 57 * School of Computer Science 58 * Carnegie Mellon University 59 * Pittsburgh PA 15213-3890 60 * 61 * any improvements or extensions that they make and grant Carnegie the 62 * rights to redistribute these changes. 63 * | 1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 47 unchanged lines hidden (view full) --- 56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 57 * School of Computer Science 58 * Carnegie Mellon University 59 * Pittsburgh PA 15213-3890 60 * 61 * any improvements or extensions that they make and grant Carnegie the 62 * rights to redistribute these changes. 63 * |
64 * $Id: vm_page.h,v 1.42 1998/06/30 08:01:30 jmg Exp $ | 64 * $Id: vm_page.h,v 1.43 1998/08/22 15:24:09 mckay Exp $ |
65 */ 66 67/* 68 * Resident memory system definitions. 69 */ 70 71#ifndef _VM_PAGE_ 72#define _VM_PAGE_ 73 74#include "opt_vmpage.h" 75 76#include <vm/pmap.h> | 65 */ 66 67/* 68 * Resident memory system definitions. 69 */ 70 71#ifndef _VM_PAGE_ 72#define _VM_PAGE_ 73 74#include "opt_vmpage.h" 75 76#include <vm/pmap.h> |
77#include <machine/atomic.h> 78 |
|
77/* 78 * Management of resident (logical) pages. 79 * 80 * A small structure is kept for each resident 81 * page, indexed by page number. Each structure 82 * is an element of several lists: 83 * 84 * A hash table bucket used to quickly --- 189 unchanged lines hidden (view full) --- 274 275#define PHYS_TO_VM_PAGE(pa) \ 276 (&vm_page_array[atop(pa) - first_page ]) 277 278/* 279 * Functions implemented as macros 280 */ 281 | 79/* 80 * Management of resident (logical) pages. 81 * 82 * A small structure is kept for each resident 83 * page, indexed by page number. Each structure 84 * is an element of several lists: 85 * 86 * A hash table bucket used to quickly --- 189 unchanged lines hidden (view full) --- 276 277#define PHYS_TO_VM_PAGE(pa) \ 278 (&vm_page_array[atop(pa) - first_page ]) 279 280/* 281 * Functions implemented as macros 282 */ 283 |
284#define PAGE_SET_FLAG(m, bits) atomic_set_short(&(m)->flags, bits) 285 286#define PAGE_CLEAR_FLAG(m, bits) atomic_clear_short(&(m)->flags, bits) 287 |
|
282#define PAGE_ASSERT_WAIT(m, interruptible) { \ | 288#define PAGE_ASSERT_WAIT(m, interruptible) { \ |
283 (m)->flags |= PG_WANTED; \ | 289 PAGE_SET_FLAG(m, PG_WANTED); \ |
284 assert_wait((int) (m), (interruptible)); \ 285} 286 287#define PAGE_WAKEUP(m) { \ | 290 assert_wait((int) (m), (interruptible)); \ 291} 292 293#define PAGE_WAKEUP(m) { \ |
288 (m)->flags &= ~PG_BUSY; \ | 294 PAGE_CLEAR_FLAG(m, PG_BUSY); \ |
289 if (((m)->flags & PG_WANTED) && ((m)->busy == 0)) { \ | 295 if (((m)->flags & PG_WANTED) && ((m)->busy == 0)) { \ |
290 (m)->flags &= ~PG_WANTED; \ | 296 PAGE_CLEAR_FLAG(m, PG_WANTED); \ |
291 wakeup((m)); \ 292 } \ 293} 294 | 297 wakeup((m)); \ 298 } \ 299} 300 |
301#define PAGE_BUSY(m) atomic_add_char(&(m)->busy, 1) 302 |
|
295#define PAGE_BWAKEUP(m) { \ | 303#define PAGE_BWAKEUP(m) { \ |
296 (m)->busy--; \ | 304 atomic_subtract_char(&(m)->busy, 1); \ |
297 if ((((m)->flags & (PG_WANTED | PG_BUSY)) == PG_WANTED) && \ 298 ((m)->busy == 0)) { \ | 305 if ((((m)->flags & (PG_WANTED | PG_BUSY)) == PG_WANTED) && \ 306 ((m)->busy == 0)) { \ |
299 (m)->flags &= ~PG_WANTED; \ | 307 PAGE_CLEAR_FLAG(m, PG_WANTED); \ |
300 wakeup((m)); \ 301 } \ 302} 303 304 305#if PAGE_SIZE == 4096 306#define VM_PAGE_BITS_ALL 0xff 307#endif --- 60 unchanged lines hidden (view full) --- 368} 369 370static __inline void 371vm_page_protect(vm_page_t mem, int prot) 372{ 373 if (prot == VM_PROT_NONE) { 374 if (mem->flags & (PG_WRITEABLE|PG_MAPPED)) { 375 pmap_page_protect(VM_PAGE_TO_PHYS(mem), VM_PROT_NONE); | 308 wakeup((m)); \ 309 } \ 310} 311 312 313#if PAGE_SIZE == 4096 314#define VM_PAGE_BITS_ALL 0xff 315#endif --- 60 unchanged lines hidden (view full) --- 376} 377 378static __inline void 379vm_page_protect(vm_page_t mem, int prot) 380{ 381 if (prot == VM_PROT_NONE) { 382 if (mem->flags & (PG_WRITEABLE|PG_MAPPED)) { 383 pmap_page_protect(VM_PAGE_TO_PHYS(mem), VM_PROT_NONE); |
376 mem->flags &= ~(PG_WRITEABLE|PG_MAPPED); | 384 PAGE_CLEAR_FLAG(mem, PG_WRITEABLE|PG_MAPPED); |
377 } 378 } else if ((prot == VM_PROT_READ) && (mem->flags & PG_WRITEABLE)) { 379 pmap_page_protect(VM_PAGE_TO_PHYS(mem), VM_PROT_READ); | 385 } 386 } else if ((prot == VM_PROT_READ) && (mem->flags & PG_WRITEABLE)) { 387 pmap_page_protect(VM_PAGE_TO_PHYS(mem), VM_PROT_READ); |
380 mem->flags &= ~PG_WRITEABLE; | 388 PAGE_CLEAR_FLAG(mem, PG_WRITEABLE); |
381 } 382} 383 384/* 385 * vm_page_zero_fill: 386 * 387 * Zero-fill the specified page. 388 * Written as a standard pagein routine, to --- 26 unchanged lines hidden --- | 389 } 390} 391 392/* 393 * vm_page_zero_fill: 394 * 395 * Zero-fill the specified page. 396 * Written as a standard pagein routine, to --- 26 unchanged lines hidden --- |