#sccs "@(#)uts/kern/sys:pte.h 1.2" /* Convergent Technologies - System V - Jun 1983 */ #ifndef pte_h #define pte_h #include /* * Incore page table entry * * There are two major kinds of pte's: those which have ever existed (and are * thus either now in core or on the swap device), and those which have * never existed, but which will be filled on demand at first reference. * There is a structure describing each. There is also an ancillary * structure used in page clustering. */ /* The format of a pte in the map */ struct pte { ushort pt_wp:1, /* write permission */ pt_acc:2, /* access status */ :3, /* non h/w flags */ pt_pfnum:10; /* core page frame number */ }; /* The format of a pte in memory (our RAM) */ struct mpte { ushort pg_ipte; /* index of hardware pte */ ushort pt_wp:1, /* write permission */ pg_acc:2, /* access control */ pg_fod:1, /* is fill on demand (=0) */ pg_swapm:1, /* have to write back to swap */ pg_pageo:1, /* page is being paged out */ pg_pfnum:10; /* core page frame number or 0 */ }; struct fpte { ushort pg_blkno; /* file system block number */ ushort pt_wp:1, /* write permission */ pg_acc:2, /* access control */ pg_fod:1, /* is fill on demand (=0) */ pg_swapm:1, /* have to write back to swap */ pg_pageo:1, /* page is being paged out */ pg_last:1, /* last data page */ pg_lastsec:2, /* disk sectors in the last data page*/ pg_fileno:7; /* file no for the page */ }; #define PG_PROT ((ushort)0x00008000) #define PG_STAT ((ushort)0x00006000) #define PG_STA_SHFT 13 /* shift to get usage field */ #define PG_ACC ((ushort)0x00004000) #define PG_V ((ushort)0x00002000) #define PG_M ((ushort)0x00006000) #define PG_FOD ((ushort)0x00001000) #define PG_PFNUM ((ushort)0x000003ff) #define PG_FZERO (nofile) #define PG_FTEXT (nofile+1) #define PG_LTEXT (PG_FTEXT+1) #define PG_FMAX (PG_LTEXT) /* * Pte related macros */ #define dirty(pte) ((pte)->pg_fod == 0 && (pte)->pg_pfnum && (pte)->pg_swapm) #ifdef mega #define pgaccess(pte) (*(unsigned short *)(PG_BASE+(pte)->pg_ipte) & PG_STAT == PG_ACC) #define setpgvalid(pte) (*(unsigned short *)(PG_BASE+(pte)->pg_ipte) = (pte)->pg_pfnum | PG_V) #endif #define setpginvalid(hpte) ((hpte)->pt_acc = 0) #define pagevalid(hpte) ((hpte)->pt_acc != 0) #define reference(hpte) (*(unsigned short *)(hpte) & (unsigned short) PG_ACC) #define resetref(hpte) (*(unsigned short *)(hpte) = (*(unsigned short *)(hpte) & (~PG_STAT)) | PG_V) #define modified(hpte) ((*(unsigned short *)(hpte) & PG_STAT) == PG_M) /* * The following variables are defined in end.s and start.s */ extern unsigned long cmaptmp; extern unsigned long ecmaptmp; extern unsigned long eend; extern unsigned long freemem; extern unsigned long ncmaptmp; extern struct pte *ptefork; extern struct pte *ptemutl; extern struct pte *pteswp1; extern struct pte *pteswp2; extern struct pte *ptetmp1; extern struct pte *ptetmp2; extern struct pte *ptevfutl; extern struct pte *mmpte; extern ushort epg; extern ushort epgdata; extern ushort epgtext; extern ushort esg; extern ushort esgdata; extern ushort esgtext; extern ushort upg; extern ushort usg; extern ushort usrcore; struct vaddress { unsigned v_region:2, /* Region of memory(ram,map+regs,rom,i/o) */ v_vpn:10, /* Virtual page number */ v_byte:12; /* Byte within the page */ }; /* Definition of a physical address. */ struct paddress { unsigned p_mbz:11, /* Must be zero */ p_pfn:9, /* Page frame number */ p_byte:12; /* Byte within the page */ }; /* Memory mapping hardware */ #define PG_BASE ((unsigned short *)0x400000) /* address of page table */ #define USER_MAP (unsigned short *)(0x400100) /* address of user part of page table */ #define MAP_TOP (unsigned short *)(0x400800 - 2*KVMEM_VPAGES) /* address past end of memory map */ #define DMA_MAP (unsigned short *)(0x4000c0) /* Disk dma uses segment 6 for i/o */ #define DMA_XFR_ADR 0x60000 /* virtual address corresponding to DMA_MAP */ #define DMA_UPTR (unsigned short *)(0x4000dc) /* Disk dma pte's to access U page */ #define UPTE ((unsigned short *)0x4000E0) /* address of UPAGE pte */ /* Page table entry. * WE bit 15 =1 user can write page, =0 user can read page * USE bits 14-13 value 0=not present, 1=present, not accessed * value 2=accessed not written, 3=written to * PAGEADDR bits 8-0 PHYSADDR=(PAGEADDR*4096) + byte within page * STATES: * page not in memory: WE set as needed and rest=0 * page in memory: WE, PAGEADDR set as needed and USE non zero */ #define PROT_MASK ((ushort)0x8000) /* mask for write bit */ #define USE_MASK ((ushort)0x6000) /* mask for usage bits */ #define PG_MASK 0x1ff /* page address mask */ #define PG_WRITE ((ushort)0x8000) /* user write enable */ #define NO_PAGE 0x0 /* to initialize pte's */ #define PG_IN 0x7fff /* AND mask */ #define PG_PRESENT 0x2000 /* pte&USE_MASK page just in */ #define PG_NOT_DIRTY 0x4000 /* pte&USE_MASK = accessed */ #define PAGE_DIRTY 0x6000 /* pte&USE_MASK = written to */ #define P_ACCESS_CHECK 0x6000 /* AND mask */ #define NO_ACCESS 0 #define TOTAL_PTES 1024 #define TOTAL_PAGES 1024 #define PAGES_IN_PROC 1024-KVMEM_PAGES-SHLIB_PAGES #define BYTES_PER_PAGE 0x1000 #define PAGESHIFT 12 /* gets page number from addr */ /* 4 Mbyte logical address space */ #define MAX_MEM 0x400000 /* 2 Mbyte physical address space */ #define MAX_PHYS_MEM 0x200000 #define PAGES_PER_SEG 16 /* needed to correspond to megaframe rounding */ #define USRSIZE 4096 /* size of usrtbl (upage) in bytes */ #define SEGSIZE 0x10000 /* size of a segment */ /* some defines that lie about some things */ #define SEGS_PER_PROC 64 /* miniframe doesn't have segments */ #define SEGSHIFT 4 /* seg to page */ #define PG_KR 0 /* the kernel can read anything */ #define PG_KW 0 /* the kernel can write to anything */ #endif pte_h