1: /* 2: * Copyright (c) 1986 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)seg.h 1.2 (2.11BSD GTE) 1/1/93 7: */ 8: 9: #ifndef _SEG_ 10: #define _SEG_ 11: 12: /* 13: * Access abilities 14: */ 15: #define RO 02 /* Read only */ 16: #define RW 06 /* Read and write */ 17: #define NOACC 0 /* Abort all accesses */ 18: #define ACCESS 07 /* Mask for access field */ 19: #define ED 010 /* Extension direction */ 20: #define TX 020 /* Software: text segment */ 21: #define ABS 040 /* Software: absolute address */ 22: 23: #ifndef SUPERVISOR 24: u_short *ka6; /* nonseparate: KISA6; separate: KDSA6 */ 25: u_int kdsa6; /* saved KDSA6, if any */ 26: #endif 27: 28: /* 29: * Addresses and bits for DEC's KT-11 30: * and macros for remapping kernel data space. 31: */ 32: #define UISD ((u_short *) 0177600) /* first user I-space descriptor */ 33: #define UDSD ((u_short *) 0177620) /* first user D-space descriptor */ 34: 35: #ifdef ENABLE34 36: # define DEC_UISA7 ((u_short *) 0177656) 37: extern u_short *UISA, *UDSA, *KISA0, *KDSA1, *KDSA2, *KDSA5, *KDSA6; 38: #else 39: # define UISA ((u_short *) 0177640) /* first user I-space address */ 40: # define UDSA ((u_short *) 0177660) /* first user D-space address */ 41: #endif 42: 43: #ifndef ENABLE34 44: # define KISA0 ((u_short *) 0172340) 45: # define KISA1 ((u_short *) 0172342) 46: # define KISA5 ((u_short *) 0172352) 47: # define KISA6 ((u_short *) 0172354) 48: # define SSR3 ((u_short *) 0172516) 49: #endif 50: 51: #define SISD0 ((u_short *) 0172200) 52: #define SDSD0 ((u_short *) 0172220) 53: #define SISA0 ((u_short *) 0172240) 54: #define SDSA0 ((u_short *) 0172260) 55: #define KISD1 ((u_short *) 0172302) 56: #define KISD5 ((u_short *) 0172312) 57: #define KISD6 ((u_short *) 0172314) 58: 59: #ifdef KERN_NONSEP 60: # ifndef ENABLE34 61: # define KDSA5 KISA5 62: # define KDSA6 KISA6 63: # endif !ENABLE34 64: # define KDSD5 KISD5 65: # define KDSD6 KISD6 66: #else 67: # ifndef ENABLE34 68: # define SDSA5 ((u_short *) 0172272) 69: # define SDSA6 ((u_short *) 0172274) 70: # define KDSA5 ((u_short *) 0172372) 71: # define KDSA6 ((u_short *) 0172374) 72: # endif !ENABLE34 73: # define SDSD5 ((u_short *) 0172232) 74: # define SDSD6 ((u_short *) 0172234) 75: # define KDSD5 ((u_short *) 0172332) 76: # define KDSD6 ((u_short *) 0172334) 77: #endif 78: 79: /* start of possibly mapped area; see machdep.c */ 80: #ifndef SUPERVISOR 81: #define REMAP_AREA ((caddr_t)&proc[0]) 82: #endif 83: #define SEG5 ((caddr_t) 0120000) 84: #define SEG6 ((caddr_t) 0140000) 85: #define SEG7 ((caddr_t) 0160000) 86: 87: #ifdef COMMENT 88: * Macros for resetting the kernel segmentation registers to map in 89: * out-of-address space data. If KDSA5 is used for kernel data space 90: * only proc, file and text tables are allowed in that range. Routines 91: * can repoint KDSA5 to map in data such as buffers or clists without 92: * raising processor priority by calling these macros. Copy (in mch.s) uses 93: * two registers, KDSA5 and 6. If KDSA6 is in use, the prototype register 94: * kdsa6 will be non-zero, and the kernel will be running on a temporary stack 95: * in bss. Interrupt routines that access any of the structures in this range 96: * or the u. must call savemap (in machdep.c) to save the current mapping 97: * information in a local structure and restore it before returning. 98: * 99: * USAGE: 100: * To repoint KDSA5 from the top level, 101: * mapseg5(addr, desc); /* KDSA5 now points at addr */ 102: * ... 103: * normalseg5(); /* normal mapping */ 104: * 105: * To repoint KDSA5 from interrupt or top level, 106: * segm saveregs; 107: * saveseg5(saveregs); /* save previous mapping of segment 5 */ 108: * mapseg5(addr, desc); /* KDSA5 now points at addr */ 109: * ... 110: * restorseg5(saveregs); /* restore previous mapping */ 111: * 112: * To access proc, text, file or user structures from interrupt level, 113: * mapinfo map; /* save ALL mapping information, */ 114: * savemap(map); /* restore normal mapping of KA5 */ 115: * ... /* and 6 */ 116: * restormap(map); /* restore previous mapping */ 117: #endif /* COMMENT */ 118: 119: /* 120: * Structure to hold a saved PAR/PDR pair. 121: */ 122: struct segm_reg { 123: u_int se_desc; 124: u_int se_addr; 125: }; 126: typedef struct segm_reg segm; 127: typedef struct segm_reg mapinfo[2]; /* KA5, KA6 */ 128: 129: #ifndef DIAGNOSTIC 130: # define mapout(bp) normalseg5() 131: #endif 132: 133: /* use segment 5 to access the given address. */ 134: #ifdef SUPERVISOR 135: #define mapseg5(addr,desc) { \ 136: *SDSD5 = desc; \ 137: *SDSA5 = addr; \ 138: } 139: #else 140: #define mapseg5(addr,desc) { \ 141: *KDSD5 = desc; \ 142: *KDSA5 = addr; \ 143: } 144: #endif 145: 146: /* save the previous contents of KDSA5/KDSD5. */ 147: #ifdef SUPERVISOR 148: #define saveseg5(save) { \ 149: save.se_addr = *SDSA5; \ 150: save.se_desc = *SDSD5; \ 151: } 152: #else 153: #define saveseg5(save) { \ 154: save.se_addr = *KDSA5; \ 155: save.se_desc = *KDSD5; \ 156: } 157: #endif 158: 159: /* restore normal kernel map for seg5. */ 160: extern segm seg5; /* prototype KDSA5, KDSD5 */ 161: #define normalseg5() restorseg5(seg5) 162: 163: /* restore the previous contents of KDSA5/KDSD5. */ 164: #ifdef SUPERVISOR 165: #define restorseg5(save) { \ 166: *SDSD5 = save.se_desc; \ 167: *SDSA5 = save.se_addr; \ 168: } 169: #else 170: #define restorseg5(save) { \ 171: *KDSD5 = save.se_desc; \ 172: *KDSA5 = save.se_addr; \ 173: } 174: caddr_t mapin(); 175: #endif 176: #endif /* _SEG_ */