|
|
1.1 root 1: /*
2:
1.1.1.3 ! root 3: Copyright 1990,1991,1992 Eric R. Smith.
! 4:
! 5: Copyright 1992 Atari Corporation.
! 6:
! 7: All rights reserved.
1.1 root 8:
9: */
10:
11:
12:
13: #ifndef _mem_h
14:
15: #define _mem_h
16:
17:
18:
1.1.1.2 root 19: #include "file.h"
20:
21:
22:
1.1 root 23: typedef struct memregion {
24:
25: long loc; /* base of memory region */
26:
27: ulong len; /* length of memory region */
28:
29: ushort links; /* number of users of region */
30:
31: ushort mflags; /* e.g. which map this came from */
32:
33: struct memregion *next; /* next region in memory map */
34:
35: } MEMREGION;
36:
37:
38:
39: /* dummy type for virtual addresses */
40:
41: typedef struct vaddr {
42:
43: char dummy;
44:
45: } *virtaddr;
46:
47:
48:
1.1.1.3 ! root 49: /*
! 50:
! 51: * Here's the deal with memory bits:
! 52:
! 53: *
! 54:
! 55: * Mxalloc(long size, int mode) takes these fields in 'mode': BITS 0-2 hold
! 56:
! 57: * values 0-3 for the old GEMDOS mode argument. If bit 3 is on, then only
! 58:
! 59: * F_PROTMODE (bits 4-7) counts, and it encodes the desired protection mode
! 60:
! 61: * to change a block to. Else F_PROTMODE is the desired protection mode for
! 62:
! 63: * the new block you're allocating. In either case, F_PROTMODE turns into
! 64:
! 65: * a PROT_* thusly: if it's zero, you get the F_PROTMODE value from curproc's
! 66:
! 67: * prgflags. Else you get (F_PROTMODE >> F_PROTSHIFT)-1.
! 68:
! 69: *
! 70:
! 71: * The 0x4000 bit is carried along into get_region (but not from there into
! 72:
! 73: * mark_region) and, if set, causes M_KEEP to be set in the region's
! 74:
! 75: * mflags.
! 76:
! 77: */
! 78:
! 79:
! 80:
1.1 root 81: /* flags for memory regions */
82:
1.1.1.2 root 83: #define M_CORE 0x01 /* region came from core map */
84:
85: #define M_ALT 0x02 /* region came from alt map */
86:
87: #define M_SWAP 0x04 /* region came from swap map */
88:
89: #define M_KER 0x08 /* region came from kernel map */
90:
91: #define M_MAP 0x0f /* and with this to pick out map */
92:
93:
94:
95: #define M_SHTEXT 0x10 /* region is a shared text region */
96:
97: #define M_KEEP 0x0100 /* don't free on process termination */
98:
99:
100:
101: /* structure for shared text regions */
102:
103:
104:
105: typedef struct shtextreg {
106:
107: FILEPTR *f; /* what file did this come from? */
108:
109: MEMREGION *text; /* pointer to shared text region */
110:
111: short mtime, mdate; /* date & time for file */
112:
113: struct shtextreg *next;
1.1 root 114:
1.1.1.2 root 115: } SHTEXT;
1.1 root 116:
117:
118:
1.1.1.2 root 119: /* structure of exectuable program headers */
1.1 root 120:
1.1.1.2 root 121: typedef struct fileheader {
1.1 root 122:
1.1.1.2 root 123: short fmagic;
1.1 root 124:
1.1.1.2 root 125: long ftext;
126:
127: long fdata;
128:
129: long fbss;
130:
131: long fsym;
132:
133: long reserved;
134:
135: long flag;
136:
137: short reloc;
138:
139: } FILEHEAD;
140:
141:
142:
143: #define GEMDOS_MAGIC 0x601a
1.1 root 144:
145:
146:
147: /* flags for curproc->memflags */
148:
1.1.1.3 ! root 149: /* also used for program headers PRGFLAGS */
1.1.1.2 root 150:
1.1 root 151: #define F_FASTLOAD 0x01 /* don't zero heap */
152:
153: #define F_ALTLOAD 0x02 /* OK to load in alternate ram */
154:
155: #define F_ALTALLOC 0x04 /* OK to malloc from alt. ram */
156:
1.1.1.2 root 157: #define F_RESERVED 0x08 /* reserved for future use */
158:
159: #define F_MEMFLAGS 0xf0 /* reserved for future use */
160:
161: #define F_SHTEXT 0x800 /* program's text may be shared */
162:
163:
164:
165: #define F_MINALT 0xf0000000L /* used to decide which type of RAM to load in */
166:
1.1 root 167:
168:
1.1.1.3 ! root 169: /* Bit in Mxalloc's arg for "don't auto-free this memory" */
! 170:
! 171: #define F_KEEP 0x4000
! 172:
! 173:
! 174:
! 175: #define F_OS_SPECIAL 0x8000 /* mark as a special process */
! 176:
! 177:
! 178:
! 179: /* flags for curproc->memflags (that is, PRGFLAGS) and also Mxalloc mode. */
! 180:
! 181: /* (Actually, when users call Mxalloc, they add 0x10 to what you see here) */
! 182:
! 183: #define F_PROTMODE 0xf0 /* protection mode bits */
! 184:
! 185: #define F_PROT_P 0x00 /* no read or write */
! 186:
! 187: #define F_PROT_G 0x10 /* any access OK */
1.1 root 188:
1.1.1.3 ! root 189: #define F_PROT_S 0x20 /* any super access OK */
! 190:
! 191: #define F_PROT_PR 0x30 /* any read OK, no write */
! 192:
! 193: #define F_PROT_I 0x40 /* invalid page */
! 194:
! 195:
! 196:
! 197: /* actual values found in page_mode_table and used as args to alloc_region */
! 198:
! 199: #define PROT_P 0
! 200:
! 201: #define PROT_G 1
! 202:
! 203: #define PROT_S 2
! 204:
! 205: #define PROT_PR 3
! 206:
! 207: #define PROT_I 4
! 208:
! 209: #define PROT_PROTMODE 0xf /* these bits are the prot mode */
! 210:
! 211: #define PROT_NOCHANGE -1
! 212:
! 213:
! 214:
! 215: #define F_PROTSHIFT 4
1.1 root 216:
217:
218:
219: typedef MEMREGION **MMAP;
220:
1.1.1.2 root 221:
222:
223: #ifndef GENMAGIC
224:
1.1 root 225: extern MMAP core, alt, ker, swap;
226:
1.1.1.2 root 227: #endif
228:
1.1 root 229:
230:
231: /* compilers differ on what "sizeof" returns */
232:
233: #define SIZEOF (long)sizeof
234:
235:
236:
1.1.1.3 ! root 237: /* QUANTUM: the page size for the mmu: 8K. This is hard-coded elsewhere. */
! 238:
! 239: #define QUANTUM 0x2000L
! 240:
! 241:
! 242:
! 243: /* MiNT leaves this much memory for TOS to use (8K)
1.1 root 244:
245: */
246:
1.1.1.3 ! root 247: #define TOS_MEM (QUANTUM)
1.1 root 248:
249:
250:
251: /* MiNT tries to keep this much memory available for the kernel and other
252:
1.1.1.3 ! root 253: * programs when a program is launched (8K)
1.1 root 254:
255: */
256:
1.1.1.3 ! root 257: #define KEEP_MEM (QUANTUM)
1.1 root 258:
259:
260:
261: /*
262:
1.1.1.3 ! root 263: * how much memory should be allocated to the kernel? (24K)
! 264:
! 265: */
! 266:
! 267: #define KERNEL_MEM (3*QUANTUM)
! 268:
! 269:
! 270:
! 271: /* macro for rounding off region sizes to QUANTUM (page) boundaries */
! 272:
! 273: /* there is code in mem.c that assumes it's OK to put the screen
! 274:
! 275: * in any region, so this should be at least 256 for STs (16 is OK for
! 276:
! 277: * STes, TTs, and Falcons). We actually set a variable in main.c
! 278:
! 279: * that holds the screen boundary stuff.
1.1 root 280:
281: */
282:
1.1.1.3 ! root 283: extern int no_mem_prot;
1.1 root 284:
1.1.1.3 ! root 285: extern int screen_boundary;
1.1 root 286:
287:
288:
1.1.1.3 ! root 289: #define MASKBITS (no_mem_prot ? screen_boundary : (QUANTUM-1))
1.1 root 290:
291: #define ROUND(size) ((size + MASKBITS) & ~MASKBITS)
292:
293:
294:
1.1.1.3 ! root 295: /* interesting memory constants */
! 296:
! 297:
! 298:
! 299: #define EIGHT_K (0x400L*8L)
! 300:
! 301: #define ONE_MEG 0x00100000L
! 302:
! 303: #define LOG2_ONE_MEG 20
! 304:
! 305: #define LOG2_16_MEG 24
! 306:
! 307: #define LOG2_EIGHT_K 13
! 308:
! 309: #define SIXTEEN_MEG (0x400L*0x400L*16L)
! 310:
! 311:
! 312:
! 313: /* macro for turning a curproc->base_table pointer into a 16-byte boundary */
! 314:
! 315: #define ROUND16(ld) ((long_desc *)(((ulong)(ld) + 15) & ~15))
! 316:
! 317:
! 318:
! 319: /* TBL_SIZE is the size in entries of the A, B, and C level tables */
! 320:
! 321: #define TBL_SIZE (16)
! 322:
! 323: #define TBL_SIZE_BYTES (TBL_SIZE * sizeof(long_desc))
! 324:
! 325:
! 326:
! 327: typedef struct {
! 328:
! 329: short limit;
! 330:
! 331: unsigned zeros:14;
! 332:
! 333: unsigned dt:2;
! 334:
! 335: struct long_desc *tbl_address;
! 336:
! 337: } crp_reg;
! 338:
! 339:
! 340:
! 341: /* format of long descriptors, both page descriptors and table descriptors */
! 342:
! 343:
! 344:
! 345: typedef struct {
! 346:
! 347: unsigned limit; /* set to $7fff to disable */
! 348:
! 349: unsigned unused1:6;
! 350:
! 351: unsigned unused2:1;
! 352:
! 353: unsigned s:1; /* 1 grants supervisor access only */
! 354:
! 355: unsigned unused3:1;
! 356:
! 357: unsigned ci:1; /* cache inhibit: used in page desc only */
! 358:
! 359: unsigned unused4:1;
! 360:
! 361: unsigned m:1; /* modified: used in page desc only */
! 362:
! 363: unsigned u:1; /* accessed */
! 364:
! 365: unsigned wp:1; /* write-protected */
! 366:
! 367: unsigned dt:2; /* type */
! 368:
! 369: } page_type;
! 370:
! 371:
! 372:
! 373: typedef struct long_desc {
! 374:
! 375: page_type page_type;
! 376:
! 377: struct long_desc *tbl_address;
! 378:
! 379: } long_desc;
! 380:
! 381:
! 382:
! 383: typedef struct {
! 384:
! 385: unsigned enable:1;
! 386:
! 387: unsigned zeros:5;
! 388:
! 389: unsigned sre:1;
! 390:
! 391: unsigned fcl:1;
! 392:
! 393: unsigned ps:4;
! 394:
! 395: unsigned is:4;
! 396:
! 397: unsigned tia:4;
! 398:
! 399: unsigned tib:4;
! 400:
! 401: unsigned tic:4;
! 402:
! 403: unsigned tid:4;
! 404:
! 405: } tc_reg;
! 406:
! 407:
! 408:
1.1 root 409: #endif /* _mem_h */
410:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.