Index: atari/atari_init.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/atari/atari_init.c,v retrieving revision 1.65 diff -u -r1.65 atari_init.c --- atari/atari_init.c 24 Dec 2005 22:45:34 -0000 1.65 +++ atari/atari_init.c 25 Dec 2008 15:01:14 -0000 @@ -83,14 +83,14 @@ static void atari_hwinit __P((void)); static void cpu_init_kcorehdr __P((u_long)); static void initcpu __P((void)); -static void mmu030_setup __P((st_entry_t *, u_int, pt_entry_t *, u_int, - pt_entry_t *, u_int, u_int)); +static void mmu030_setup __P((u_int, pt_entry_t *, u_int, + u_int, u_int)); static void map_io_areas __P((pt_entry_t *, u_int, u_int)); static void set_machtype __P((void)); #if defined(M68040) || defined(M68060) -static void mmu040_setup __P((st_entry_t *, u_int, pt_entry_t *, u_int, - pt_entry_t *, u_int, u_int)); +static void mmu040_setup __P((u_int, pt_entry_t *, u_int, + u_int, u_int)); #endif /* @@ -122,10 +122,8 @@ extern u_int Sysptsize, Sysseg_pa, proc0paddr; extern pt_entry_t *Sysptmap; extern st_entry_t *Sysseg; -u_int *Sysmap; int machineid, mmutype, cputype, astpending; char *vmmap; -pv_entry_t pv_table; #if defined(M68040) || defined(M68060) extern int protostfree; #endif @@ -202,6 +200,7 @@ u_int end_loaded; u_long kbase; u_int kstsize; + u_int Sysptmap_pa; #if defined(_MILANHW_) /* XXX @@ -238,8 +237,9 @@ * the kernel ends at end() or esym. */ if(esym == NULL) - end_loaded = (u_int)end; - else end_loaded = (u_int)esym; + end_loaded = (u_int) &end; + else + end_loaded = (u_int) esym; /* * If we have enough fast-memory to put the kernel in and the @@ -269,7 +269,14 @@ pstart = (u_int)end_loaded; pstart = m68k_round_page(pstart); avail = stphysize - pstart; - + + /* + * Save KVA of proc0 user-area and allocate it + */ + proc0paddr = pstart; + pstart += USPACE; + avail -= USPACE; + /* * Calculate the number of pages needed for Sysseg. * For the 68030, we need 256 descriptors (segment-table-entries). @@ -291,7 +298,15 @@ Sysseg_pa = (u_int)Sysseg + kbase; pstart += kstsize * PAGE_SIZE; avail -= kstsize * PAGE_SIZE; - + + /* + * allocate kernel page table map + */ + Sysptmap = (pt_entry_t *)pstart; + Sysptmap_pa = pstart; + pstart += PAGE_SIZE; + avail -= PAGE_SIZE; + /* * Determine the number of pte's we need for extra's like * ST I/O map's. @@ -306,7 +321,7 @@ if (machineid & ATARI_MILAN) ptextra += btoc(PCI_IO_SIZE + PCI_MEM_SIZE); ptextra += btoc(BOOTM_VA_POOL); - + /* * The 'pt' (the initial kernel pagetable) has to map the kernel and * the I/O areas. The various I/O areas are mapped (virtually) at @@ -316,44 +331,22 @@ ptsize = (Sysptsize + howmany(ptextra, NPTEPG)) << PGSHIFT; pstart += ptsize; avail -= ptsize; - - /* - * allocate kernel page table map - */ - Sysptmap = (pt_entry_t *)pstart; - pstart += PAGE_SIZE; - avail -= PAGE_SIZE; - /* - * Set Sysmap; mapped after page table pages. Because I too (LWP) - * didn't understand the reason for this, I borrowed the following - * (sligthly modified) comment from mac68k/locore.s: - * LAK: There seems to be some confusion here about the next line, - * so I'll explain. The kernel needs some way of dynamically modifying - * the page tables for its own virtual memory. What it does is that it - * has a page table map. This page table map is mapped right after the - * kernel itself (in our implementation; in HP's it was after the I/O - * space). Therefore, the first three (or so) entries in the segment - * table point to the first three pages of the page tables (which - * point to the kernel) and the next entry in the segment table points - * to the page table map (this is done later). Therefore, the value - * of the pointer "Sysmap" will be something like 16M*3 = 48M. When - * the kernel addresses this pointer (e.g., Sysmap[0]), it will get - * the first longword of the first page map (== pt[0]). Since the - * page map mirrors the segment table, addressing any index of Sysmap - * will give you a PTE of the page maps which map the kernel. + /* + * We want Sysmap to be the first address mapped by Sysptmap. + * Sysmap is now placed at the end of Supervisor virtual address space. */ - Sysmap = (u_int *)(ptsize << (SEGSHIFT - PGSHIFT)); + Sysmap = (u_int *) ((u_int *)-(NPTEPG * PAGE_SIZE)); /* * Initialize segment tables */ #if defined(M68040) || defined(M68060) if (mmutype == MMU_68040) - mmu040_setup(Sysseg, kstsize, pt, ptsize, Sysptmap, 1, kbase); + mmu040_setup(kstsize, pt, ptsize, Sysptmap_pa, kbase); else #endif /* defined(M68040) || defined(M68060) */ - mmu030_setup(Sysseg, kstsize, pt, ptsize, Sysptmap, 1, kbase); + mmu030_setup(kstsize, pt, ptsize, Sysptmap_pa, kbase); /* * initialize kernel page table page(s). @@ -363,7 +356,8 @@ */ pg_proto = (0 + kbase) | PG_RO | PG_V; pg = pt; - *pg++ = PG_NV; pg_proto += PAGE_SIZE; + *pg++ = PG_NV; + pg_proto += PAGE_SIZE; for(i = PAGE_SIZE; i < (u_int)etext; i += PAGE_SIZE, pg_proto += PAGE_SIZE) *pg++ = pg_proto; @@ -390,6 +384,7 @@ pg_proto = (pg_proto & ~PG_CCB) | PG_CI; for (; i < pstart; i += PAGE_SIZE, pg_proto += PAGE_SIZE) *pg++ = pg_proto; + pg_proto = (pg_proto & ~PG_CI); if (kernel_copyback) pg_proto |= PG_CCB; @@ -400,13 +395,13 @@ * go till end of data allocated so far * plus proc0 u-area (to be allocated) */ - for(; i < pstart + USPACE; i += PAGE_SIZE, pg_proto += PAGE_SIZE) + for (; i < pstart; i += PAGE_SIZE, pg_proto += PAGE_SIZE) *pg++ = pg_proto; /* * invalidate remainder of kernel PT */ - while(pg < &pt[ptsize/sizeof(pt_entry_t)]) + while((pt_entry_t *)pg < &pt[ptsize/sizeof(pt_entry_t)]) *pg++ = PG_NV; /* @@ -415,13 +410,6 @@ map_io_areas(pt, ptsize, ptextra); /* - * Save KVA of proc0 user-area and allocate it - */ - proc0paddr = pstart; - pstart += USPACE; - avail -= USPACE; - - /* * At this point, virtual and physical allocation starts to divert. */ vstart = pstart; @@ -491,11 +479,11 @@ for (i = 0, physmem = 0; usable_segs[i].start; i++) physmem += usable_segs[i].end - usable_segs[i].start; physmem >>= PGSHIFT; - + /* * get the pmap module in sync with reality. */ - pmap_bootstrap(vstart, stio_addr, ptextra); + pmap_bootstrap(vstart, stio_addr); /* * Prepare to enable the MMU. @@ -553,7 +541,7 @@ tc = 0x82d08b00; __asm volatile ("pmove %0@,%%tc" : : "a" (&tc)); } - + /* Is this to fool the optimizer?? */ i = *(int *)proc0paddr; *(volatile int *)proc0paddr = i; @@ -906,29 +894,25 @@ } void -mmu030_setup(sysseg, kstsize, pt, ptsize, sysptmap, sysptsize, kbase) - st_entry_t *sysseg; /* System segment table */ +mmu030_setup(kstsize, pt, ptsize, sysptmap_pa, kbase) u_int kstsize; /* size of 'sysseg' in pages */ pt_entry_t *pt; /* Kernel page table */ u_int ptsize; /* size of 'pt' in bytes */ - pt_entry_t *sysptmap; /* System page table */ - u_int sysptsize; /* size of 'sysptmap' in pages */ + u_int sysptmap_pa; /* System page table */ u_int kbase; { st_entry_t sg_proto, *sg; pt_entry_t pg_proto, *pg, *epg; - sg_proto = ((u_int)pt + kbase) | SG_RW | SG_V; - pg_proto = ((u_int)pt + kbase) | PG_RW | PG_CI | PG_V; - /* * Map the page table pages in both the HW segment table - * and the software Sysptmap. Note that Sysptmap is also - * considered a PT page, hence the +sysptsize. + * and the software Sysptmap. */ - sg = sysseg; - pg = sysptmap; - epg = &pg[(ptsize >> PGSHIFT) + sysptsize]; + sg = (u_int *)Sysseg_pa; + pg = (u_int *)sysptmap_pa; + epg = &pg[ptsize >> PGSHIFT]; + sg_proto = ((u_int)pt + kbase) | SG_RW | SG_V; + pg_proto = ((u_int)pt + kbase) | PG_RW | PG_CI | PG_V; while(pg < epg) { *sg++ = sg_proto; *pg++ = pg_proto; @@ -939,22 +923,23 @@ /* * invalidate the remainder of the tables */ - epg = &sysptmap[sysptsize * NPTEPG]; + /* XXX PAGE_SIZE dependent constant: 256 or 1024 */ + epg = (u_int *)(sysptmap_pa + (256 - 1) * sizeof(st_entry_t)); while(pg < epg) { *sg++ = SG_NV; *pg++ = PG_NV; } + *sg = sysptmap_pa | SG_RW | SG_V; + *pg = sysptmap_pa | PG_RW | PG_CI | PG_V; } #if defined(M68040) || defined(M68060) void -mmu040_setup(sysseg, kstsize, pt, ptsize, sysptmap, sysptsize, kbase) - st_entry_t *sysseg; /* System segment table */ +mmu040_setup(kstsize, pt, ptsize, sysptmap_pa, kbase) u_int kstsize; /* size of 'sysseg' in pages */ pt_entry_t *pt; /* Kernel page table */ u_int ptsize; /* size of 'pt' in bytes */ - pt_entry_t *sysptmap; /* System page table */ - u_int sysptsize; /* size of 'sysptmap' in pages */ + u_int sysptmap_pa; /* System page table */ u_int kbase; { int i; @@ -965,22 +950,22 @@ * First invalidate the entire "segment table" pages * (levels 1 and 2 have the same "invalid" values). */ - sg = sysseg; + sg = (u_int *)Sysseg_pa; esg = &sg[kstsize * NPTEPG]; while (sg < esg) *sg++ = SG_NV; /* * Initialize level 2 descriptors (which immediately - * follow the level 1 table). These should map 'pt' + 'sysptmap'. + * follow the level 1 table). * We need: * NPTEPG / SG4_LEV3SIZE * level 2 descriptors to map each of the nptpages + 1 * pages of PTEs. Note that we set the "used" bit * now to save the HW the expense of doing it. */ - i = ((ptsize >> PGSHIFT) + sysptsize) * (NPTEPG / SG4_LEV3SIZE); - sg = &sysseg[SG4_LEV1SIZE]; + i = (ptsize >> PGSHIFT) * (NPTEPG / SG4_LEV3SIZE); + sg = &((u_int *)Sysseg_pa)[SG4_LEV1SIZE]; esg = &sg[i]; sg_proto = ((u_int)pt + kbase) | SG_U | SG_RW | SG_V; while (sg < esg) { @@ -994,8 +979,8 @@ * level 1 descriptors to map the 'num' level 2's. */ i = roundup(i, SG4_LEV2SIZE) / SG4_LEV2SIZE; - protostfree = (-1 << (i + 1)) /* & ~(-1 << MAXKL2SIZE) */; - sg = sysseg; + protostfree = (-1 << (i + 2)) /* & ~(-1 << MAXKL2SIZE) */; + sg = (u_int *)Sysseg_pa; esg = &sg[i]; sg_proto = ((u_int)&sg[SG4_LEV1SIZE] + kbase) | SG_U | SG_RW |SG_V; while (sg < esg) { @@ -1003,22 +988,44 @@ sg_proto += (SG4_LEV2SIZE * sizeof(st_entry_t)); } + /* Sysmap is last entry in level 1 */ + sg = (u_int *)Sysseg_pa; + sg = &sg[SG4_LEV1SIZE - 1]; + *sg = sg_proto; + /* - * Initialize sysptmap + * Kernel segment table at end of next level 2 table + */ + /* XXX fix calculations XXX */ + i = ((((ptsize >> PGSHIFT) + 3) & -2) - 1) * (NPTEPG / SG4_LEV3SIZE); + sg = &((u_int *)Sysseg_pa)[SG4_LEV1SIZE + i]; + esg = &sg[NPTEPG / SG4_LEV3SIZE]; + sg_proto = sysptmap_pa | SG_U | SG_RW | SG_V; + while (sg < esg) { + *sg++ = sg_proto; + sg_proto += (SG4_LEV3SIZE * sizeof (st_entry_t)); + } + + /* + * Initialize Sysptmap */ - sg = sysptmap; - esg = &sg[(ptsize >> PGSHIFT) + sysptsize]; + sg = (u_int *) sysptmap_pa; + esg = &sg[ptsize >> PGSHIFT]; pg_proto = ((u_int)pt + kbase) | PG_RW | PG_CI | PG_V; while (sg < esg) { - *sg++ = pg_proto; + *sg++ = pg_proto; pg_proto += PAGE_SIZE; } + /* * Invalidate rest of Sysptmap page */ - esg = &sysptmap[sysptsize * NPTEPG]; + esg = (u_int *)(sysptmap_pa + PAGE_SIZE - sizeof(st_entry_t)); while (sg < esg) *sg++ = SG_NV; + sg = (u_int *) Sysptmap; + sg = &sg[256 - 1]; /* XXX */ + *sg = sysptmap_pa | PG_RW | PG_CI | PG_V; } #endif /* M68040 */ @@ -1122,7 +1129,7 @@ s = stp; { - es = s + (ATARI_STSIZE >> 2); + es = s + (M68K_STSIZE >> 2); shift = SG_ISHIFT; } Index: atari/be_bus.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/atari/be_bus.c,v retrieving revision 1.7 diff -u -r1.7 be_bus.c --- atari/be_bus.c 11 Dec 2005 12:16:54 -0000 1.7 +++ atari/be_bus.c 25 Dec 2008 15:01:14 -0000 @@ -168,15 +168,15 @@ /* * Don't force a function call overhead on these primitives... */ -#define __read_1(h, o) *((u_int8_t *)((h) + (o))) -#define __read_2(h, o) *((u_int16_t *)((h) + (o))) -#define __read_4(h, o) *((u_int32_t *)((h) + (o))) -#define __read_8(h, o) *((u_int64_t *)((h) + (o))) - -#define __write_1(h, o, v) *((u_int8_t *)((h) + (o))) = (v) -#define __write_2(h, o, v) *((u_int16_t *)((h) + (o))) = (v) -#define __write_4(h, o, v) *((u_int32_t *)((h) + (o))) = (v) -#define __write_8(h, o, v) *((u_int64_t *)((h) + (o))) = (v) +#define __read_1(h, o) *((volatile u_int8_t *)((h) + (o))) +#define __read_2(h, o) *((volatile u_int16_t *)((h) + (o))) +#define __read_4(h, o) *((volatile u_int32_t *)((h) + (o))) +#define __read_8(h, o) *((volatile u_int64_t *)((h) + (o))) + +#define __write_1(h, o, v) *((volatile u_int8_t *)((h) + (o))) = (v) +#define __write_2(h, o, v) *((volatile u_int16_t *)((h) + (o))) = (v) +#define __write_4(h, o, v) *((volatile u_int32_t *)((h) + (o))) = (v) +#define __write_8(h, o, v) *((volatile u_int64_t *)((h) + (o))) = (v) bus_space_tag_t beb_alloc_bus_space_tag(storage) Index: atari/genassym.cf =================================================================== RCS file: /cvsroot/src/sys/arch/atari/atari/genassym.cf,v retrieving revision 1.23 diff -u -r1.23 genassym.cf --- atari/genassym.cf 11 Dec 2005 12:16:54 -0000 1.23 +++ atari/genassym.cf 25 Dec 2008 15:01:14 -0000 @@ -177,7 +177,6 @@ define PCB_PS offsetof(struct pcb, pcb_ps) define PCB_USP offsetof(struct pcb, pcb_usp) define PCB_REGS offsetof(struct pcb, pcb_regs) -define PCB_CMAP2 offsetof(struct pcb, pcb_cmap2) define PCB_ONFAULT offsetof(struct pcb, pcb_onfault) define PCB_FPCTX offsetof(struct pcb, pcb_fpregs) define SIZEOF_PCB sizeof(struct pcb) Index: atari/intr.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/atari/intr.c,v retrieving revision 1.11 diff -u -r1.11 intr.c --- atari/intr.c 11 Dec 2005 12:16:54 -0000 1.11 +++ atari/intr.c 25 Dec 2008 15:01:14 -0000 @@ -308,6 +308,17 @@ return; } ih->ih_intrcnt[0]++; +#if 0 + if (ih->ih_intrcnt[0] > 10000) { + if (vector < (AVEC_LOC+AVEC_MAX) && vector >= AVEC_LOC) + printf("%s: 10000 intrs on autovec intr %d\n", + __func__, vector - AVEC_LOC); + else if (vector <= (UVEC_LOC+UVEC_MAX) && vector >= UVEC_LOC) + printf("%s: 10000 intrs on vectored intr %d\n", + __func__, vector - UVEC_LOC); + Debugger(); + } +#endif /* Give all the handlers a chance. */ for ( ; ih != NULL; ih = ih->ih_link.le_next) Index: atari/le_bus.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/atari/le_bus.c,v retrieving revision 1.11 diff -u -r1.11 le_bus.c --- atari/le_bus.c 29 Jan 2006 21:42:41 -0000 1.11 +++ atari/le_bus.c 25 Dec 2008 15:01:14 -0000 @@ -250,15 +250,15 @@ /* * Don't force a function call overhead on these primitives... */ -#define __read_1(h, o) *((u_int8_t *)((h) + (o))) -#define __read_2(h, o) swap16(*((u_int16_t *)((h) + (o)))) -#define __read_4(h, o) swap32(*((u_int32_t *)((h) + (o)))) -#define __read_8(h, o) bswap64(*((u_int64_t *)((h) + (o)))) - -#define __write_1(h, o, v) *((u_int8_t *)((h) + (o))) = (v) -#define __write_2(h, o, v) *((u_int16_t *)((h) + (o))) = swap16(v) -#define __write_4(h, o, v) *((u_int32_t *)((h) + (o))) = swap32(v) -#define __write_8(h, o, v) *((u_int64_t *)((h) + (o))) = bswap64(v) +#define __read_1(h, o) *((volatile u_int8_t *)((h) + (o))) +#define __read_2(h, o) swap16(*((volatile u_int16_t *)((h) + (o)))) +#define __read_4(h, o) swap32(*((volatile u_int32_t *)((h) + (o)))) +#define __read_8(h, o) bswap64(*((volatile u_int64_t *)((h) + (o)))) + +#define __write_1(h, o, v) *((volatile u_int8_t *)((h) + (o))) = (v) +#define __write_2(h, o, v) *((volatile u_int16_t *)((h) + (o))) = swap16(v) +#define __write_4(h, o, v) *((volatile u_int32_t *)((h) + (o))) = swap32(v) +#define __write_8(h, o, v) *((volatile u_int64_t *)((h) + (o))) = bswap64(v) bus_space_tag_t leb_alloc_bus_space_tag(storage) @@ -493,7 +493,7 @@ bus_space_handle_t h; bus_size_t o; { - return(*((u_int16_t *)(h + o))); + return(*((volatile u_int16_t *)(h + o))); } static u_int32_t @@ -502,7 +502,7 @@ bus_space_handle_t h; bus_size_t o; { - return(*((u_int32_t *)(h + o))); + return(*((volatile u_int32_t *)(h + o))); } static u_int64_t @@ -511,7 +511,7 @@ bus_space_handle_t h; bus_size_t o; { - return(*((u_int64_t *)(h + o))); + return(*((volatile u_int64_t *)(h + o))); } /* @@ -528,7 +528,7 @@ bus_size_t o; u_int16_t v; { - *((u_int16_t *)(h + o)) = v; + *((volatile u_int16_t *)(h + o)) = v; } static void @@ -538,7 +538,7 @@ bus_size_t o; u_int32_t v; { - *((u_int32_t *)(h + o)) = v; + *((volatile u_int32_t *)(h + o)) = v; } static void @@ -548,7 +548,7 @@ bus_size_t o; u_int64_t v; { - *((u_int64_t *)(h + o)) = v; + *((volatile u_int64_t *)(h + o)) = v; } /* @@ -675,7 +675,7 @@ u_int16_t *a; { for (; c; a++, c--) - *a = *((u_int16_t *)(h + o)); + *a = *((volatile u_int16_t *)(h + o)); } static void @@ -686,7 +686,7 @@ u_int32_t *a; { for (; c; a++, c--) - *a = *((u_int32_t *)(h + o)); + *a = *((volatile u_int32_t *)(h + o)); } static void @@ -697,7 +697,7 @@ u_int64_t *a; { for (; c; a++, c--) - *a = *((u_int64_t *)(h + o)); + *a = *((volatile u_int64_t *)(h + o)); } /* @@ -717,7 +717,7 @@ const u_int16_t *a; { for (; c; a++, c--) - *((u_int16_t *)(h + o)) = *a; + *((volatile u_int16_t *)(h + o)) = *a; } static void @@ -728,7 +728,7 @@ const u_int32_t *a; { for (; c; a++, c--) - *((u_int32_t *)(h + o)) = *a; + *((volatile u_int32_t *)(h + o)) = *a; } static void @@ -739,7 +739,7 @@ const u_int64_t *a; { for (; c; a++, c--) - *((u_int64_t *)(h + o)) = *a; + *((volatile u_int64_t *)(h + o)) = *a; } /* @@ -865,7 +865,7 @@ u_int16_t *a; { for (; c; a++, o += 2, c--) - *a = *(u_int16_t *)(h + o); + *a = *(volatile u_int16_t *)(h + o); } static void @@ -876,7 +876,7 @@ u_int32_t *a; { for (; c; a++, o += 4, c--) - *a = *(u_int32_t *)(h + o); + *a = *(volatile u_int32_t *)(h + o); } static void @@ -887,7 +887,7 @@ u_int64_t *a; { for (; c; a++, o += 8, c--) - *a = *(u_int64_t *)(h + o); + *a = *(volatile u_int64_t *)(h + o); } /* @@ -907,7 +907,7 @@ const u_int16_t *a; { for (; c; a++, o += 2, c--) - *((u_int16_t *)(h + o)) = *a; + *((volatile u_int16_t *)(h + o)) = *a; } static void @@ -918,7 +918,7 @@ const u_int32_t *a; { for (; c; a++, o += 4, c--) - *((u_int32_t *)(h + o)) = *a; + *((volatile u_int32_t *)(h + o)) = *a; } static void @@ -929,7 +929,7 @@ const u_int64_t *a; { for (; c; a++, o += 8, c--) - *((u_int64_t *)(h + o)) = *a; + *((volatile u_int64_t *)(h + o)) = *a; } /* @@ -961,7 +961,7 @@ { v = swap16(v); for (; c; c--) - *((u_int16_t *)(h + o)) = v; + *((volatile u_int16_t *)(h + o)) = v; } static void @@ -973,7 +973,7 @@ { v = swap32(v); for (; c; c--) - *((u_int32_t *)(h + o)) = v; + *((volatile u_int32_t *)(h + o)) = v; } static void @@ -985,7 +985,7 @@ { v = bswap64(v); for (; c; c--) - *((u_int64_t *)(h + o)) = v; + *((volatile u_int64_t *)(h + o)) = v; } /* @@ -1016,7 +1016,7 @@ { v = swap16(v); for (; c; o += 2, c--) - *((u_int16_t *)(h + o)) = v; + *((volatile u_int16_t *)(h + o)) = v; } static void @@ -1028,7 +1028,7 @@ { v = swap32(v); for (; c; o += 4, c--) - *((u_int32_t *)(h + o)) = v; + *((volatile u_int32_t *)(h + o)) = v; } static void @@ -1040,5 +1040,5 @@ { v = bswap64(v); for (; c; o += 8, c--) - *((u_int64_t *)(h + o)) = v; + *((volatile u_int64_t *)(h + o)) = v; } Index: atari/mainbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/atari/mainbus.c,v retrieving revision 1.4 diff -u -r1.4 mainbus.c --- atari/mainbus.c 11 Dec 2005 12:16:54 -0000 1.4 +++ atari/mainbus.c 25 Dec 2008 15:01:14 -0000 @@ -149,25 +149,25 @@ ((u_long)(base) + ((off) << (stride)) + (wm)) #define __read_1(t, h, o) \ - (*((u_int8_t *)(calc_addr(h, o, (t)->stride, (t)->wo_1)))) + (*((volatile u_int8_t *)(calc_addr(h, o, (t)->stride, (t)->wo_1)))) #define __read_2(t, h, o) \ - (*((u_int16_t *)(calc_addr(h, o, (t)->stride, (t)->wo_2)))) + (*((volatile u_int16_t *)(calc_addr(h, o, (t)->stride, (t)->wo_2)))) #define __read_4(t, h, o) \ - (*((u_int32_t *)(calc_addr(h, o, (t)->stride, (t)->wo_4)))) + (*((volatile u_int32_t *)(calc_addr(h, o, (t)->stride, (t)->wo_4)))) #define __read_8(t, h, o) \ - (*((u_int64_t *)(calc_addr(h, o, (t)->stride, (t)->wo_8)))) + (*((volatile u_int64_t *)(calc_addr(h, o, (t)->stride, (t)->wo_8)))) #define __write_1(t, h, o, v) \ - *((u_int8_t *)(calc_addr(h, o, (t)->stride, (t)->wo_1))) = v + *((volatile u_int8_t *)(calc_addr(h, o, (t)->stride, (t)->wo_1))) = v #define __write_2(t, h, o, v) \ - *((u_int16_t *)(calc_addr(h, o, (t)->stride, (t)->wo_2))) = v + *((volatile u_int16_t *)(calc_addr(h, o, (t)->stride, (t)->wo_2))) = v #define __write_4(t, h, o, v) \ - *((u_int32_t *)(calc_addr(h, o, (t)->stride, (t)->wo_4))) = v + *((volatile u_int32_t *)(calc_addr(h, o, (t)->stride, (t)->wo_4))) = v #define __write_8(t, h, o, v) \ - *((u_int64_t *)(calc_addr(h, o, (t)->stride, (t)->wo_8))) = v + *((volatile u_int64_t *)(calc_addr(h, o, (t)->stride, (t)->wo_8))) = v bus_space_tag_t mb_alloc_bus_space_tag() @@ -371,9 +371,9 @@ bus_size_t o, c; u_int8_t *a; { - u_int8_t *ba; + volatile u_int8_t *ba; - ba = (u_int8_t *)calc_addr(h, o, t->stride, t->wo_1); + ba = (volatile u_int8_t *)calc_addr(h, o, t->stride, t->wo_1); for (; c; a++, c--) *a = *ba; } @@ -385,9 +385,9 @@ bus_size_t o, c; u_int16_t *a; { - u_int16_t *ba; + volatile u_int16_t *ba; - ba = (u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); + ba = (volatile u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); for (; c; a++, c--) *a = *ba; } @@ -399,9 +399,9 @@ bus_size_t o, c; u_int32_t *a; { - u_int32_t *ba; + volatile u_int32_t *ba; - ba = (u_int32_t *)calc_addr(h, o, t->stride, t->wo_4); + ba = (volatile u_int32_t *)calc_addr(h, o, t->stride, t->wo_4); for (; c; a++, c--) *a = *ba; } @@ -413,9 +413,9 @@ bus_size_t o, c; u_int64_t *a; { - u_int64_t *ba; + volatile u_int64_t *ba; - ba = (u_int64_t *)calc_addr(h, o, t->stride, t->wo_8); + ba = (volatile u_int64_t *)calc_addr(h, o, t->stride, t->wo_8); for (; c; a++, c--) *a = *ba; } @@ -427,9 +427,9 @@ bus_size_t o, c; const u_int8_t *a; { - u_int8_t *ba; + volatile u_int8_t *ba; - ba = (u_int8_t *)calc_addr(h, o, t->stride, t->wo_1); + ba = (volatile u_int8_t *)calc_addr(h, o, t->stride, t->wo_1); for (; c; a++, c--) *ba = *a; } @@ -441,9 +441,9 @@ bus_size_t o, c; const u_int16_t *a; { - u_int16_t *ba; + volatile u_int16_t *ba; - ba = (u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); + ba = (volatile u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); for (; c; a++, c--) *ba = *a; } @@ -455,9 +455,9 @@ bus_size_t o, c; const u_int32_t *a; { - u_int32_t *ba; + volatile u_int32_t *ba; - ba = (u_int32_t *)calc_addr(h, o, t->stride, t->wo_4); + ba = (volatile u_int32_t *)calc_addr(h, o, t->stride, t->wo_4); for (; c; a++, c--) *ba = *a; } @@ -469,9 +469,9 @@ bus_size_t o, c; const u_int64_t *a; { - u_int64_t *ba; + volatile u_int64_t *ba; - ba = (u_int64_t *)calc_addr(h, o, t->stride, t->wo_8); + ba = (volatile u_int64_t *)calc_addr(h, o, t->stride, t->wo_8); for (; c; a++, c--) *ba = *a; } @@ -597,9 +597,9 @@ bus_size_t o, c; u_int8_t v; { - u_int8_t *ba; + volatile u_int8_t *ba; - ba = (u_int8_t *)calc_addr(h, o, t->stride, t->wo_1); + ba = (volatile u_int8_t *)calc_addr(h, o, t->stride, t->wo_1); for (; c; c--) *ba = v; } @@ -611,9 +611,9 @@ bus_size_t o, c; u_int16_t v; { - u_int16_t *ba; + volatile u_int16_t *ba; - ba = (u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); + ba = (volatile u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); for (; c; c--) *ba = v; } @@ -625,9 +625,9 @@ bus_size_t o, c; u_int32_t v; { - u_int32_t *ba; + volatile u_int32_t *ba; - ba = (u_int32_t *)calc_addr(h, o, t->stride, t->wo_4); + ba = (volatile u_int32_t *)calc_addr(h, o, t->stride, t->wo_4); for (; c; c--) *ba = v; } @@ -639,9 +639,9 @@ bus_size_t o, c; u_int64_t v; { - u_int64_t *ba; + volatile u_int64_t *ba; - ba = (u_int64_t *)calc_addr(h, o, t->stride, t->wo_8); + ba = (volatile u_int64_t *)calc_addr(h, o, t->stride, t->wo_8); for (; c; c--) *ba = v; } Index: atari/pmap.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/atari/pmap.c,v retrieving revision 1.94.4.1 diff -u -r1.94.4.1 pmap.c --- atari/pmap.c 30 May 2007 22:58:05 -0000 1.94.4.1 +++ atari/pmap.c 25 Dec 2008 15:01:15 -0000 @@ -117,13 +117,12 @@ #include -#include -#include - #include #include #include +#include + /* * Allocate various and sundry SYSMAPs used in the days of old VM * and not yet converted. XXX. @@ -184,8 +183,8 @@ #define PMAP_DPRINTF(l, x) if (pmapdebug & (l)) printf x -static void pmap_check_wiring __P((char *, vaddr_t)); -static void pmap_pvdump __P((paddr_t)); +static void pmap_check_wiring(const char *, vaddr_t); +static void pmap_pvdump(paddr_t); #else #define PMAP_DPRINTF(l, x) #endif @@ -194,22 +193,26 @@ * Get STEs and PTEs for user/kernel address space */ #if defined(M68040) || defined(M68060) - -#define pmap_ste(m, v) (&((m)->pm_stab[(vaddr_t)(v) >> pmap_ishift])) +#if defined(M68020) || defined(M68030) +#define pmap_ste(m, v) (&((m)->pm_stab[(vaddr_t)(v) \ + >> (mmutype == MMU_68040 ? SG4_SHIFT1 : SG_ISHIFT)])) +#else +#define pmap_ste(m, v) (&((m)->pm_stab[(vaddr_t)(v) >> SG4_SHIFT1])) +#endif #define pmap_ste1(m, v) (&((m)->pm_stab[(vaddr_t)(v) >> SG4_SHIFT1])) /* XXX assumes physically contiguous ST pages (if more than one) */ #define pmap_ste2(m, v) \ - (&((m)->pm_stab[(u_int *)(*(u_int *)pmap_ste1(m,v) & SG4_ADDR1) \ + (&((m)->pm_stab[(st_entry_t *)(*(u_int *)pmap_ste1(m,v) & SG4_ADDR1) \ - (m)->pm_stpa + (((v) & SG4_MASK2) >> SG4_SHIFT2)])) #define pmap_ste_v(m, v) \ - (mmutype == MMU_68040 \ - ? ((*pmap_ste1(m, v) & SG_V) && \ + (mmutype == MMU_68040 \ + ? ((*pmap_ste1(m, v) & SG_V) && \ (*pmap_ste2(m, v) & SG_V)) \ : (*pmap_ste(m, v) & SG_V)) -#else /* defined(M68040) || defined(M68060) */ -#define pmap_ste(m, v) (&((m)->pm_stab[(vaddr_t)(v) >> SG_ISHIFT])) +#else /* defined(M68040) || defined(M68060) */ +#define pmap_ste(m, v) (&((m)->pm_stab[(vaddr_t)(v) >> SG_ISHIFT])) #define pmap_ste_v(m, v) (*pmap_ste(m, v) & SG_V) -#endif /* defined(M68040) || defined(M68060) */ +#endif /* defined(M68040) || defined(M68060) */ #define pmap_pte(m, v) (&((m)->pm_ptab[(vaddr_t)(v) >> PG_SHIFT])) @@ -272,16 +275,17 @@ * reference something. */ u_int *Sysseg, *Sysseg_pa; -u_int *Sysmap, *Sysptmap; -u_int *Segtabzero, *Segtabzeropa; +pt_entry_t *Sysmap, *Sysptmap; +st_entry_t *Segtabzero, *Segtabzeropa; vsize_t Sysptsize = VM_KERNEL_PT_PAGES; +struct pv_entry *pv_table; /* array of entries, one per page */ + struct pmap kernel_pmap_store; struct vm_map *pt_map; struct vm_map_kernel pt_map_store; vsize_t mem_size; /* memory size in bytes */ -paddr_t avail_end; /* PA of last available physical page */ vaddr_t virtual_avail; /* VA of first avail page (after kernel bss)*/ vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */ int page_cnt; /* number of pages managed by the VM system */ @@ -290,25 +294,29 @@ TAILQ_HEAD(pv_page_list, pv_page) pv_page_freelist; int pv_nfree; #if defined(M68040) || defined(M68060) -static int pmap_ishift; /* segment table index shift */ int protostfree; /* prototype (default) free ST map */ #endif -extern caddr_t msgbufaddr; -extern vaddr_t msgbufpa; +pt_entry_t *caddr1_pte; /* PTE for CADDR1 */ +pt_entry_t *caddr2_pte; /* PTE for CADDR2 */ + +extern void * msgbufaddr; +extern paddr_t msgbufpa; + +extern vaddr_t reserve_dumppages(vaddr_t); -static boolean_t pmap_testbit __P((paddr_t, int)); -static int pmap_enter_ptpage __P((pmap_t, vaddr_t, boolean_t)); -static struct pv_entry* pmap_alloc_pv __P((void)); -static void pmap_free_pv __P((struct pv_entry *)); -static void pmap_pinit __P((pmap_t)); -static void pmap_ptpage_addref __P((vaddr_t)); -static int pmap_ptpage_delref __P((vaddr_t)); -static void pmap_release __P((pmap_t)); -static void pmap_remove_mapping __P((pmap_t, vaddr_t, pt_entry_t *, - int)); -static void atari_protection_init __P((void)); -static void pmap_collect1 __P((pmap_t, paddr_t, paddr_t)); +boolean_t pmap_testbit(paddr_t, int); +int pmap_enter_ptpage(pmap_t, vaddr_t, boolean_t); +static void pmap_ptpage_addref(vaddr_t); +static int pmap_ptpage_delref(vaddr_t); +static void pmap_changebit(vaddr_t, int, boolean_t); +struct pv_entry* pmap_alloc_pv(void); +void pmap_free_pv(struct pv_entry *); +void pmap_pinit(pmap_t); +void pmap_release(pmap_t); +static void pmap_remove_mapping(pmap_t, vaddr_t, pt_entry_t *, int); + +void pmap_collect1(pmap_t, paddr_t, paddr_t); /* pmap_remove_mapping flags */ #define PRM_TFLUSH 0x01 @@ -319,9 +327,9 @@ * All those kernel PT submaps that BSD is so fond of */ caddr_t CADDR1, CADDR2; -u_int *CMAP1, *CMAP2, *vmpte, *msgbufmap; +char *vmmap; -#define PAGE_IS_MANAGED(pa) (pmap_initialized \ +#define PAGE_IS_MANAGED(pa) (pmap_initialized \ && vm_physseg_find(atop((pa)), NULL) != -1) #define pa_to_pvh(pa) \ @@ -341,118 +349,11 @@ }) /* - * The preallocated virtual memory range used by the I/O area. Their - * values are passed to pmap_bootstrap(). - */ -static u_int atarihwaddr; -static u_int atarihwpg; - -/* - * Bootstrap the system enough to run with virtual memory. - * Map the kernel's code and data, and allocate the system page table. - * - * On the HP this is called after mapping has already been enabled - * and just syncs the pmap module with what has already been done. - * [We can't call it easily with mapping off since the kernel is not - * mapped with PA == VA, hence we would have to relocate every address - * from the linked base (virtual) address 0 to the actual (physical) - * address of 0xFFxxxxxx.] + * Initialize the pmap module. + * Called by vm_init, to initialize any structures that the pmap + * system needs to map virtual memory. */ void -pmap_bootstrap(kernel_size, hw_addr, hw_pages) -psize_t kernel_size; -u_int hw_addr, hw_pages; -{ - vaddr_t va; - u_int *pte; - int i; - - /* - * Record start & size of I/O area for use by pmap_init() - */ - atarihwaddr = hw_addr; - atarihwpg = hw_pages; - - /* - * Announce page-size to the VM-system - */ - uvmexp.pagesize = NBPG; - uvm_setpagesize(); - - /* - * Setup physical address ranges - */ - for (i = 0; usable_segs[i+1].start; i++) - ; - /* XXX: allow for msgbuf */ - usable_segs[i].end -= m68k_round_page(MSGBUFSIZE); - avail_end = msgbufpa = usable_segs[i].end; - - /* - * Count physical memory - */ - for (i = mem_size = 0; i < NMEM_SEGS; i++) { - if (boot_segs[i].start == boot_segs[i].end) - break; - mem_size += boot_segs[i].end - boot_segs[i].start; - } - - /* - * Announce available memory to the VM-system - */ - for (i = 0; usable_segs[i].start; i++) - uvm_page_physload(atop(usable_segs[i].start), - atop(usable_segs[i].end), - atop(usable_segs[i].start), - atop(usable_segs[i].end), - VM_FREELIST_DEFAULT); - - virtual_avail = VM_MIN_KERNEL_ADDRESS + kernel_size; - virtual_end = VM_MAX_KERNEL_ADDRESS; - - /* - * Initialize protection array. - */ - atari_protection_init(); - - /* - * Kernel page/segment table allocated in locore, - * just initialize pointers. - */ - pmap_kernel()->pm_stpa = Sysseg_pa; - pmap_kernel()->pm_stab = Sysseg; - pmap_kernel()->pm_ptab = Sysmap; -#if defined(M68040) || defined(M68060) - if (mmutype == MMU_68040) { - pmap_ishift = SG4_SHIFT1; - pmap_kernel()->pm_stfree = protostfree; - } - else pmap_ishift = SG_ISHIFT; -#endif - - simple_lock_init(&pmap_kernel()->pm_lock); - pmap_kernel()->pm_count = 1; - - /* - * Allocate all the submaps we need - */ -#define SYSMAP(c, p, v, n) \ - v = (c)va; va += ((n)*PAGE_SIZE); p = pte; pte += (n); - - va = virtual_avail; - pte = pmap_pte(pmap_kernel(), va); - - SYSMAP(caddr_t ,CMAP1 ,CADDR1 ,1 ) - SYSMAP(caddr_t ,CMAP2 ,CADDR2 ,1 ) - SYSMAP(caddr_t ,vmpte ,vmmap ,1 ) - SYSMAP(caddr_t ,msgbufmap ,msgbufaddr ,btoc(MSGBUFSIZE) ) - - DCIS(); - - virtual_avail = reserve_dumppages(va); -} - -void pmap_init() { vaddr_t addr, addr2; @@ -461,45 +362,27 @@ struct pv_entry *pv; char *attr; int rv, bank; -#ifdef M68060 +#if defined(M68060) struct kpt_page *kptp; + paddr_t paddr; #endif #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) printf("pmap_init()\n"); #endif + /* - * Now that kernel map has been allocated, we can mark as - * unavailable regions which we have mapped in atari_init.c. + * Before we do anything else, initialize the PTE pointers + * used by pmap_zero_page() and pmap_copy_page(). */ - addr = atarihwaddr; - if (uvm_map(kernel_map, &addr, - ptoa(atarihwpg), - NULL, UVM_UNKNOWN_OFFSET, 0, - UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, - UVM_INH_NONE, UVM_ADV_RANDOM, - UVM_FLAG_FIXED)) != 0) - goto bogons; - addr = (vaddr_t) Sysmap; - if (uvm_map(kernel_map, &addr, ATARI_KPTSIZE, - NULL, UVM_UNKNOWN_OFFSET, 0, - UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, - UVM_INH_NONE, UVM_ADV_RANDOM, - UVM_FLAG_FIXED)) != 0) { - /* - * If this fails, it is probably because the static - * portion of the kernel page table isn't big enough - * and we overran the page table map. - */ - bogons: - panic("pmap_init: bogons in the VM system!"); - } + caddr1_pte = pmap_pte(pmap_kernel(), CADDR1); + caddr2_pte = pmap_pte(pmap_kernel(), CADDR2); #ifdef DEBUG if (pmapdebug & PDB_INIT) { printf("pmap_init: Sysseg %p, Sysmap %p, Sysptmap %p\n", - Sysseg, Sysmap, Sysptmap); + Sysseg, Sysmap, Sysptmap); printf(" vstart %lx, vend %lx\n", virtual_avail, virtual_end); } #endif @@ -516,18 +399,19 @@ vm_physmem[bank].end << PGSHIFT, page_cnt << PGSHIFT); #endif } - s = ATARI_STSIZE; /* Segtabzero */ - s += page_cnt * sizeof(struct pv_entry); /* pv table */ + s = M68K_STSIZE; /* Segtabzero */ + s += page_cnt * sizeof(struct pv_entry); /* pv table */ s += page_cnt * sizeof(char); /* attribute table */ s = round_page(s); addr = uvm_km_alloc(kernel_map, s, 0, UVM_KMF_WIRED | UVM_KMF_ZERO); if (addr == 0) panic("pmap_init: can't allocate data structures"); - Segtabzero = (u_int *) addr; + Segtabzero = (u_int *) addr; (void) pmap_extract(pmap_kernel(), addr, (paddr_t *)(void *)&Segtabzeropa); - addr += ATARI_STSIZE; - pv_table = (pv_entry_t) addr; + addr += M68K_STSIZE; + + pv_table = (struct pv_entry *) addr; addr += page_cnt * sizeof(struct pv_entry); pmap_attributes = (char *) addr; @@ -555,16 +439,16 @@ /* * Allocate physical memory for kernel PT pages and their management. - * we need enough pages to map the page tables for each process + * we need enough pages to map the page tables for each process * plus some slop. */ - npg = howmany(((maxproc + 16) * ATARI_UPTSIZE / NPTEPG), PAGE_SIZE); + npg = howmany(((maxproc + 16) * M68K_MAX_PTSIZE / NPTEPG), PAGE_SIZE); #ifdef NKPTADD npg += NKPTADD; #else npg += mem_size >> NKPTADDSHIFT; #endif -#ifdef DEBUG +#if 1/*def DEBUG*/ printf("Maxproc %d, mem_size %ld MB: allocating %d KPT pages\n", maxproc, mem_size>>20, npg); #endif @@ -600,40 +484,36 @@ kpt_pages->kpt_va = addr2; (void) pmap_extract(pmap_kernel(), addr2, (paddr_t *)&kpt_pages->kpt_pa); - } while (addr != addr2); + #ifdef DEBUG kpt_stats.kpttotal = atop(s); if (pmapdebug & PDB_INIT) printf("pmap_init: KPT: %ld pages from %lx to %lx\n", - atop(s), addr, addr + s); + atop(s), addr, addr + s); #endif /* - * Slightly modified version of kmem_suballoc() to get page table - * map where we want it. + * Allocate the segment table map and the page table map. */ - addr = ATARI_UPTBASE; - if (ATARI_UPTMAXSIZE / ATARI_UPTSIZE < maxproc) { - s = ATARI_UPTMAXSIZE; + addr = M68K_PTBASE; + if (M68K_PTMAXSIZE / M68K_MAX_PTSIZE < maxproc) { + s = M68K_PTMAXSIZE; /* * XXX We don't want to hang when we run out of page * tables, so we lower maxproc so that fork will fail - * instead. Note that root could still raise this + * instead. Note that root could still raise this * value through sysctl(3). */ - maxproc = ATARI_UPTMAXSIZE / ATARI_UPTSIZE; + maxproc = M68K_PTMAXSIZE / M68K_MAX_PTSIZE; } - else s = maxproc * ATARI_UPTSIZE; + else + s = maxproc * M68K_MAX_PTSIZE; pt_map = uvm_km_suballoc(kernel_map, &addr, &addr2, s, 0, TRUE, &pt_map_store); -#ifdef DEBUG - if (pmapdebug & PDB_INIT) - printf("pmap_init: pt_map [%lx - %lx)\n", addr, addr2); -#endif #if defined(M68040) || defined(M68060) if (mmutype == MMU_68040) protostfree = ~1 & ~(-1 << MAXUL2SIZE); @@ -660,11 +540,11 @@ kptp = kptp->kpt_next; } - addr2 = (vaddr_t)Segtabzeropa; - while (addr2 < (vaddr_t)Segtabzeropa + ATARI_STSIZE) { - pmap_changebit(addr2, PG_CCB, 0); - pmap_changebit(addr2, PG_CI, 1); - addr2 += PAGE_SIZE; + paddr = (paddr_t)Segtabzeropa; + while (paddr < (paddr_t)Segtabzeropa + M68K_STSIZE) { + pmap_changebit(paddr, PG_CCB, 0); + pmap_changebit(paddr, PG_CI, 1); + paddr += PAGE_SIZE; } DCIS(); @@ -711,7 +591,7 @@ pmap_free_pv(pv) struct pv_entry *pv; { - register struct pv_page *pvp; + struct pv_page *pvp; pvp = (struct pv_page *) trunc_page((vaddr_t)pv); switch (++pvp->pvp_pgi.pgi_nfree) { @@ -730,6 +610,7 @@ } } + /* * Used to map a range of physical addresses into kernel * virtual address space. @@ -742,7 +623,7 @@ vaddr_t virt; paddr_t start; paddr_t end; - int prot; + int prot; { #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) @@ -772,7 +653,7 @@ pmap_t pmap_create() { - register pmap_t pmap; + pmap_t pmap; #ifdef DEBUG if (pmapdebug & (PDB_FOLLOW|PDB_CREATE)) @@ -789,9 +670,9 @@ * Initialize a preallocated and zeroed pmap structure, * such as one in a vmspace structure. */ -static void +void pmap_pinit(pmap) - register pmap_t pmap; + pmap_t pmap; { #ifdef DEBUG @@ -811,7 +692,6 @@ pmap->pm_stfree = protostfree; #endif pmap->pm_count = 1; - simple_lock_init(&pmap->pm_lock); } /* @@ -821,7 +701,7 @@ */ void pmap_destroy(pmap) - register pmap_t pmap; + pmap_t pmap; { int count; @@ -829,9 +709,7 @@ if (pmapdebug & PDB_FOLLOW) printf("pmap_destroy(%p)\n", pmap); #endif - simple_lock(&pmap->pm_lock); count = --pmap->pm_count; - simple_unlock(&pmap->pm_lock); if (count == 0) { pmap_release(pmap); free((caddr_t)pmap, M_VMPMAP); @@ -843,9 +721,9 @@ * Called when a pmap initialized by pmap_pinit is being released. * Should only be called if the map contains no valid mappings. */ -static void +void pmap_release(pmap) - register pmap_t pmap; + pmap_t pmap; { #ifdef DEBUG @@ -854,17 +732,16 @@ #endif #ifdef notdef /* DIAGNOSTIC */ /* count would be 0 from pmap_destroy... */ - simple_lock(&pmap->pm_lock); if (pmap->pm_count != 1) panic("pmap_release count"); #endif if (pmap->pm_ptab) { pmap_remove(pmap_kernel(), (vaddr_t)pmap->pm_ptab, - (vaddr_t)pmap->pm_ptab + ATARI_UPTSIZE); + (vaddr_t)pmap->pm_ptab + M68K_MAX_PTSIZE); uvm_km_pgremove((vaddr_t)pmap->pm_ptab, - (vaddr_t)pmap->pm_ptab + ATARI_UPTSIZE); + (vaddr_t)pmap->pm_ptab + M68K_MAX_PTSIZE); uvm_km_free(pt_map, (vaddr_t)pmap->pm_ptab, - ATARI_UPTSIZE, UVM_KMF_VAONLY); + M68K_MAX_PTSIZE, UVM_KMF_VAONLY); } KASSERT(pmap->pm_stab == Segtabzero); } @@ -881,9 +758,7 @@ printf("pmap_reference(%p)\n", pmap); #endif if (pmap != NULL) { - simple_lock(&pmap->pm_lock); pmap->pm_count++; - simple_unlock(&pmap->pm_lock); } } @@ -895,12 +770,12 @@ */ void pmap_remove(pmap, sva, eva) - register pmap_t pmap; + pmap_t pmap; vaddr_t sva, eva; { - register paddr_t pa; - register vaddr_t va; - register u_int *pte; + paddr_t pa; + vaddr_t va; + u_int *pte; int flags; #ifdef DEBUG @@ -910,22 +785,22 @@ #endif flags = active_pmap(pmap) ? PRM_TFLUSH : 0; for (va = sva; va < eva; va += PAGE_SIZE) { - /* - * Weed out invalid mappings. - * Note: we assume that the segment table is always allocated. - */ - if (!pmap_ste_v(pmap, va)) { - /* XXX: avoid address wrap around */ - if (va >= m68k_trunc_seg((vaddr_t)-1)) - break; - va = m68k_round_seg(va + PAGE_SIZE) - PAGE_SIZE; - continue; - } - pte = pmap_pte(pmap, va); - pa = pmap_pte_pa(pte); - if (pa == 0) - continue; - pmap_remove_mapping(pmap, va, pte, flags); + /* + * Weed out invalid mappings. + * Note: we assume that the segment table is always allocated. + */ + if (!pmap_ste_v(pmap, va)) { + /* XXX: avoid address wrap around */ + if (va >= m68k_trunc_seg((vaddr_t)-1)) + break; + va = m68k_round_seg(va + PAGE_SIZE) - PAGE_SIZE; + continue; + } + pte = pmap_pte(pmap, va); + pa = pmap_pte_pa(pte); + if (pa == 0) + continue; + pmap_remove_mapping(pmap, va, pte, flags); } } @@ -939,9 +814,9 @@ struct vm_page *pg; vm_prot_t prot; { - paddr_t pa = VM_PAGE_TO_PHYS(pg); - register pv_entry_t pv; + struct pv_entry *pv; int s; + paddr_t pa = VM_PAGE_TO_PHYS(pg); #ifdef DEBUG if ((pmapdebug & (PDB_FOLLOW|PDB_PROTECT)) || @@ -961,22 +836,22 @@ pv = pa_to_pvh(pa); s = splvm(); while (pv->pv_pmap != NULL) { - pt_entry_t *pte; + pt_entry_t *pte; - pte = pmap_pte(pv->pv_pmap, pv->pv_va); + pte = pmap_pte(pv->pv_pmap, pv->pv_va); #ifdef DEBUG - if (!pmap_ste_v(pv->pv_pmap,pv->pv_va) || + if (!pmap_ste_v(pv->pv_pmap,pv->pv_va) || pmap_pte_pa(pte) != pa) { - printf ("pmap_page_protect: va %08lx, pmap_ste_v %d pmap_pte_pa %08x/%08lx\n", - pv->pv_va, pmap_ste_v(pv->pv_pmap,pv->pv_va), - pmap_pte_pa(pmap_pte(pv->pv_pmap,pv->pv_va)),pa); - printf (" pvh %p pv %p pv_next %p\n", pa_to_pvh(pa), pv, pv->pv_next); + printf ("pmap_page_protect: va %lx, pmap_ste_v %d pmap_pte_pa %08x/%lx\n", + pv->pv_va, pmap_ste_v(pv->pv_pmap,pv->pv_va), + pmap_pte_pa(pmap_pte(pv->pv_pmap,pv->pv_va)),pa); + printf (" pvh %p pv %p pv_next %p\n", pa_to_pvh(pa), pv, pv->pv_next); panic("pmap_page_protect: bad mapping"); } #endif - pmap_remove_mapping(pv->pv_pmap, pv->pv_va, - pte, PRM_TFLUSH|PRM_CFLUSH); + pmap_remove_mapping(pv->pv_pmap, pv->pv_va, + pte, PRM_TFLUSH|PRM_CFLUSH); } splx(s); break; @@ -989,12 +864,12 @@ */ void pmap_protect(pmap, sva, eva, prot) - register pmap_t pmap; - vaddr_t sva, eva; - vm_prot_t prot; + pmap_t pmap; + vaddr_t sva, eva; + vm_prot_t prot; { - register u_int *pte; - register vaddr_t va; + u_int *pte; + vaddr_t va; boolean_t needtflush; int isro; @@ -1066,14 +941,14 @@ int pmap_enter(pmap, va, pa, prot, flags) - register pmap_t pmap; + pmap_t pmap; vaddr_t va; - register paddr_t pa; + paddr_t pa; vm_prot_t prot; int flags; { - register u_int *pte; - register int npte; + u_int *pte; + int npte; paddr_t opa; boolean_t cacheable = TRUE; boolean_t checkpv = TRUE; @@ -1083,7 +958,7 @@ #ifdef DEBUG if (pmapdebug & (PDB_FOLLOW|PDB_ENTER)) printf("pmap_enter(%p, %lx, %lx, %x, %x)\n", - pmap, va, pa, prot, wired); + pmap, va, pa, prot, wired); if (pmap == pmap_kernel()) enter_stats.kernel++; else @@ -1093,8 +968,8 @@ * For user mapping, allocate kernel VM resources if necessary. */ if (pmap->pm_ptab == NULL) - pmap->pm_ptab = (u_int *) - uvm_km_alloc(pt_map, ATARI_UPTSIZE, 0, + pmap->pm_ptab = (pt_entry_t *) + uvm_km_alloc(pt_map, M68K_MAX_PTSIZE, 0, UVM_KMF_VAONLY | (can_fail ? UVM_KMF_NOWAIT : UVM_KMF_WAITVA)); if (pmap->pm_ptab == NULL) @@ -1181,7 +1056,7 @@ * since pmap_enter can be called at interrupt time. */ if (PAGE_IS_MANAGED(pa)) { - register pv_entry_t pv, npv; + struct pv_entry *pv, *npv; int s; #ifdef DEBUG @@ -1258,23 +1133,23 @@ */ #if defined(M68040) || defined(M68060) #if DEBUG - if (pmapdebug & 0x10000 && mmutype == MMU_68040 && + if (pmapdebug & 0x10000 && mmutype == MMU_68040 && pmap == pmap_kernel()) { + const char *s; struct proc *cp = curproc; - char *s; - if (va >= ATARI_UPTBASE && - va < (ATARI_UPTBASE + ATARI_UPTMAXSIZE)) + if (va >= M68K_PTBASE && + va < (M68K_PTBASE + (u_int)M68K_PTMAXSIZE)) s = "UPT"; else if (va >= (u_int)Sysmap && - va < ((u_int)Sysmap + ATARI_KPTSIZE)) + va < ((u_int)Sysmap + M68K_MAX_KPTSIZE)) s = "KPT"; else if (va >= (u_int)pmap->pm_stab && - va < ((u_int)pmap->pm_stab + ATARI_STSIZE)) + va < ((u_int)pmap->pm_stab + M68K_STSIZE)) s = "KST"; - else if (cp && + else if (cp && va >= (u_int)cp->p_vmspace->vm_map.pmap->pm_stab && va < ((u_int)cp->p_vmspace->vm_map.pmap->pm_stab + - ATARI_STSIZE)) + M68K_STSIZE)) s = "UST"; else s = "other"; @@ -1284,8 +1159,8 @@ } #endif if (mmutype == MMU_68040 && pmap == pmap_kernel() && ( - (va >= ATARI_UPTBASE && va < (ATARI_UPTBASE + ATARI_UPTMAXSIZE)) || - (va >= (u_int)Sysmap && va < ((u_int)Sysmap + ATARI_KPTSIZE)))) + (va >= M68K_PTBASE && va < (M68K_PTBASE + (u_int)M68K_PTMAXSIZE)) || + (va >= (u_int)Sysmap && va < ((u_int)Sysmap + M68K_MAX_KPTSIZE)))) cacheable = FALSE; /* don't cache user page tables */ #endif npte = (pa & PG_FRAME) | pte_prot(pmap, prot) | PG_V; @@ -1293,10 +1168,18 @@ if (wired) npte |= PG_W; if (!checkpv && !cacheable) +#if defined(M68060) && defined(NO_SLOW_CIRRUS) +#if defined(M68040) || defined(M68030) || defined(M68020) npte |= (cputype == CPU_68060 ? PG_CIN : PG_CI); +#else + npte |= PG_CIN; +#endif +#else + npte |= PG_CI; +#endif #if defined(M68040) || defined(M68060) else if (mmutype == MMU_68040 && (npte & PG_PROT) == PG_RW && - (kernel_copyback || pmap != pmap_kernel())) + (kernel_copyback || pmap != pmap_kernel())) npte |= PG_CCB; /* cache copyback */ #endif if (flags & VM_PROT_ALL) { @@ -1326,11 +1209,9 @@ #ifdef DEBUG if ((pmapdebug & PDB_WIRING) && pmap != pmap_kernel()) { va -= PAGE_SIZE; - pmap_check_wiring("enter", - trunc_page((vaddr_t)pmap_pte(pmap, va))); + pmap_check_wiring("enter", trunc_page((vaddr_t) pmap_pte(pmap, va))); } #endif - return 0; } @@ -1351,7 +1232,7 @@ * Segment table entry not valid, we need a new PT page */ - if (!pmap_ste_v(pmap, va)) { + if (!pmap_ste_v(pmap, va)) { s = splvm(); pmap_enter_ptpage(pmap, va, false); splx(s); @@ -1471,10 +1352,10 @@ */ void pmap_unwire(pmap, va) - register pmap_t pmap; + pmap_t pmap; vaddr_t va; { - register u_int *pte; + u_int *pte; pte = pmap_pte(pmap, va); #ifdef DEBUG @@ -1525,12 +1406,12 @@ boolean_t pmap_extract(pmap, va, pap) - register pmap_t pmap; + pmap_t pmap; vaddr_t va; paddr_t *pap; { boolean_t rv = FALSE; - paddr_t pa; + paddr_t pa = 0; u_int pte; #ifdef DEBUG @@ -1623,22 +1504,22 @@ * Helper function for pmap_collect(). Do the actual * garbage-collection of range of physical addresses. */ -static void +void pmap_collect1(pmap, startpa, endpa) - pmap_t pmap; - paddr_t startpa, endpa; + pmap_t pmap; + paddr_t startpa, endpa; { paddr_t pa; struct pv_entry *pv; pt_entry_t *pte; paddr_t kpa; #ifdef DEBUG - int *ste; + st_entry_t *ste; int opmapdebug = 0; #endif for (pa = startpa; pa < endpa; pa += PAGE_SIZE) { - register struct kpt_page *kpt, **pkpt; + struct kpt_page *kpt, **pkpt; /* * Locate physical pages which are being used as kernel @@ -1655,7 +1536,7 @@ continue; #ifdef DEBUG if (pv->pv_va < (vaddr_t)Sysmap || - pv->pv_va >= (vaddr_t)Sysmap + ATARI_KPTSIZE) + pv->pv_va >= (vaddr_t)Sysmap + M68K_MAX_KPTSIZE) printf("collect: kernel PT VA out of range\n"); else goto ok; @@ -1716,7 +1597,7 @@ if (*ste) printf("collect: kernel STE at %p still valid (%x)\n", ste, *ste); - ste = (int *)&Sysptmap[(u_int *)ste-pmap_ste(pmap_kernel(), 0)]; + ste = &Sysptmap[ste - pmap_ste(pmap_kernel(), 0)]; if (*ste) printf("collect: kernel PTmap at %p still valid (%x)\n", ste, *ste); @@ -1763,7 +1644,7 @@ */ void pmap_zero_page(phys) - register paddr_t phys; + paddr_t phys; { int s; int dst_pte = PG_RW | PG_V; @@ -1785,7 +1666,7 @@ s = splvm(); - *CMAP1 = phys | dst_pte; + *caddr1_pte = phys | dst_pte; TBIS((vaddr_t)CADDR1); zeropage(CADDR1); @@ -1794,7 +1675,7 @@ * XXX: Invalidating is not strictly necessary.... Not doing it * is saving us a few cycles */ - *CMAP1 = PG_NV; + *caddr1_pte = PG_NV; TBIS((vaddr_t)CADDR1); #endif @@ -1814,7 +1695,7 @@ */ void pmap_copy_page(src, dst) - register paddr_t src, dst; + paddr_t src, dst; { int s; int src_pte = PG_RO | PG_V; @@ -1836,9 +1717,9 @@ #endif s = splvm(); - *CMAP1 = src | src_pte; + *caddr1_pte = src | src_pte; TBIS((vaddr_t)CADDR1); - *CMAP2 = dst | dst_pte; + *caddr2_pte = dst | dst_pte; TBIS((vaddr_t)CADDR2); copypage(CADDR1, CADDR2); @@ -1848,9 +1729,9 @@ * XXX: Invalidating is not strictly necessary.... Not doing it * is saving us a few cycles */ - *CMAP1 = PG_NV; + *caddr1_pte = PG_NV; TBIS((vaddr_t)CADDR1); - *CMAP2 = PG_NV; + *caddr2_pte = PG_NV; TBIS((vaddr_t)CADDR2); #endif @@ -1865,13 +1746,14 @@ pmap_clear_modify(pg) struct vm_page *pg; { - paddr_t pa = VM_PAGE_TO_PHYS(pg); boolean_t rv; + paddr_t pa = VM_PAGE_TO_PHYS(pg); #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) printf("pmap_clear_modify(%lx)\n", pa); #endif + rv = pmap_testbit(pa, PG_M); pmap_changebit(pa, PG_M, FALSE); return rv; @@ -1887,13 +1769,14 @@ pmap_clear_reference(pg) struct vm_page *pg; { - paddr_t pa = VM_PAGE_TO_PHYS(pg); boolean_t rv; + paddr_t pa = VM_PAGE_TO_PHYS(pg); #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) printf("pmap_clear_reference(%lx)\n", pa); #endif + rv = pmap_testbit(pa, PG_U); pmap_changebit(pa, PG_U, FALSE); return rv; @@ -1910,7 +1793,7 @@ pmap_is_referenced(pg) struct vm_page *pg; { - paddr_t pa = VM_PAGE_TO_PHYS(pg); + paddr_t pa = VM_PAGE_TO_PHYS(pg); #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) { @@ -1933,7 +1816,7 @@ pmap_is_modified(pg) struct vm_page *pg; { - paddr_t pa = VM_PAGE_TO_PHYS(pg); + paddr_t pa = VM_PAGE_TO_PHYS(pg); #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) { @@ -2045,20 +1928,20 @@ */ if (refs == 0 && (flags & PRM_KEEPPTPAGE) == 0) { #ifdef DIAGNOSTIC - struct pv_entry *pve; + struct pv_entry *_pv; #endif - paddr_t paddr; + paddr_t _pa; - paddr = pmap_pte_pa(pmap_pte(pmap_kernel(), ptpva)); + _pa = pmap_pte_pa(pmap_pte(pmap_kernel(), ptpva)); #ifdef DIAGNOSTIC - if (PAGE_IS_MANAGED(paddr) == 0) + if (PAGE_IS_MANAGED(_pa) == 0) panic("pmap_remove_mapping: unmanaged PT page"); - pve = pa_to_pvh(paddr); - if (pve->pv_ptste == NULL) + _pv = pa_to_pvh(_pa); + if (_pv->pv_ptste == NULL) panic("pmap_remove_mapping: ptste == NULL"); - if (pve->pv_pmap != pmap_kernel() || - pve->pv_va != ptpva || - pve->pv_next != NULL) + if (_pv->pv_pmap != pmap_kernel() || + _pv->pv_va != ptpva || + _pv->pv_next != NULL) panic("pmap_remove_mapping: " "bad PT page pmap %p, va 0x%lx, next %p", pve->pv_pmap, pve->pv_va, pve->pv_next); @@ -2066,12 +1949,12 @@ pmap_remove_mapping(pmap_kernel(), ptpva, NULL, PRM_TFLUSH|PRM_CFLUSH); simple_lock(&uvm.kernel_object->vmobjlock); - uvm_pagefree(PHYS_TO_VM_PAGE(paddr)); + uvm_pagefree(PHYS_TO_VM_PAGE(_pa)); simple_unlock(&uvm.kernel_object->vmobjlock); #ifdef DEBUG if (pmapdebug & (PDB_REMOVE|PDB_PTPAGE)) printf("remove: PT page 0x%lx (0x%lx) freed\n", - ptpva, paddr); + ptpva, _pa); #endif } } @@ -2170,8 +2053,7 @@ ptpmap->pm_stab, ptpmap->pm_sref - 1); if ((pmapdebug & PDB_PARANOIA) && - ptpmap->pm_stab != - (st_entry_t *)trunc_page((vaddr_t)ste)) + ptpmap->pm_stab != (st_entry_t *)trunc_page((vaddr_t) ste)) panic("remove: bogus ste"); #endif if (--(ptpmap->pm_sref) == 0) { @@ -2181,7 +2063,7 @@ ptpmap->pm_stab); #endif uvm_km_free(kernel_map, - (vaddr_t)ptpmap->pm_stab, ATARI_STSIZE, + (vaddr_t)ptpmap->pm_stab, M68K_STSIZE, UVM_KMF_WIRED); ptpmap->pm_stab = Segtabzero; ptpmap->pm_stpa = Segtabzeropa; @@ -2197,10 +2079,6 @@ if (active_user_pmap(ptpmap)) PMAP_ACTIVATE(ptpmap, 1); } -#ifdef DEBUG - else if (ptpmap->pm_sref < 0) - panic("remove: sref < 0"); -#endif } #if 0 /* @@ -2258,39 +2136,14 @@ return (rv); } -static void -atari_protection_init() -{ - register int *kp, prot; - - kp = protection_codes; - for (prot = 0; prot < 8; prot++) { - switch (prot) { - case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_NONE: - *kp++ = 0; - break; - case VM_PROT_READ | VM_PROT_NONE | VM_PROT_NONE: - case VM_PROT_READ | VM_PROT_NONE | VM_PROT_EXECUTE: - case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_EXECUTE: - *kp++ = PG_RO; - break; - case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_NONE: - case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_EXECUTE: - case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_NONE: - case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE: - *kp++ = PG_RW; - break; - } - } -} - -static boolean_t +/* static */ +boolean_t pmap_testbit(pa, bit) - register paddr_t pa; + paddr_t pa; int bit; { - register pv_entry_t pv; - register int *pte; + struct pv_entry *pv; + int *pte; int s; pv = pa_to_pvh(pa); @@ -2323,24 +2176,24 @@ return(FALSE); } -void +static void pmap_changebit(pa, bit, setem) - register paddr_t pa; + paddr_t pa; int bit; boolean_t setem; { - register pv_entry_t pv; - register int *pte, npte; + struct pv_entry *pv; + int *pte, npte; vaddr_t va; - int s; boolean_t firstpage; + int s; firstpage = TRUE; #ifdef DEBUG if (pmapdebug & PDB_BITS) printf("pmap_changebit(%lx, %x, %s)\n", - pa, bit, setem ? "set" : "clear"); + pa, bit, setem ? "set" : "clear"); #endif pv = pa_to_pvh(pa); @@ -2352,10 +2205,12 @@ if (!setem) *pa_to_attribute(pa) &= ~bit; + /* * Loop over all current mappings setting/clearing as appropos * If setting RO do we need to clear the VAC? */ + if (pv->pv_pmap == NULL) { splx(s); return; @@ -2368,11 +2223,13 @@ else npte = *pte & ~bit; if (*pte != npte) { + /* * If we are changing caching status or * protection make sure the caches are * flushed (but only once). */ + #if defined(M68040) || defined(M68060) if (firstpage && mmutype == MMU_68040 && ((bit == PG_RO && setem) || (bit & PG_CMASK))) { @@ -2389,7 +2246,8 @@ splx(s); } -static int +/* static */ +int pmap_enter_ptpage(pmap, va, can_fail) pmap_t pmap; vaddr_t va; @@ -2397,11 +2255,11 @@ { paddr_t ptpa; struct vm_page *pg; - pv_entry_t pv; + struct pv_entry *pv; #ifdef M68060 u_int stpa; -#endif /* M68060 */ - u_int *ste; +#endif + st_entry_t *ste; int s; #ifdef DEBUG @@ -2417,16 +2275,17 @@ * reference count drops to zero. */ if (pmap->pm_stab == Segtabzero) { - pmap->pm_stab = (u_int *) - uvm_km_alloc(kernel_map, ATARI_STSIZE, 0, - UVM_KMF_WIRED | UVM_KMF_ZERO | - (can_fail ? UVM_KMF_NOWAIT : 0)); + /* XXX Atari uses kernel_map here: */ + pmap->pm_stab = (st_entry_t *) + uvm_km_alloc(kernel_map, M68K_STSIZE, 0, + UVM_KMF_WIRED | UVM_KMF_ZERO | + (can_fail ? UVM_KMF_NOWAIT : 0)); if (pmap->pm_stab == NULL) { pmap->pm_stab = Segtabzero; return ENOMEM; } - (void) pmap_extract(pmap_kernel(), - (vaddr_t)pmap->pm_stab, (paddr_t *)&pmap->pm_stpa); + (void) pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_stab, + (paddr_t *)&pmap->pm_stpa); #if defined(M68040) || defined(M68060) if (mmutype == MMU_68040) { #if defined(M68060) @@ -2435,8 +2294,8 @@ pt_entry_t *pte; pte = pmap_pte(pmap_kernel(), pmap->pm_stab); - while (stpa < (u_int)pmap->pm_stpa + - ATARI_STSIZE) { + while (stpa < (u_int)pmap->pm_stpa + + M68K_STSIZE) { *pte = (*pte & ~PG_CMASK) | PG_CI; ++pte; stpa += PAGE_SIZE; @@ -2499,8 +2358,7 @@ pmap_ste2(pmap, va), ste); #endif } -#endif /* defined(M68040) || defined(M68060) */ - +#endif va = trunc_page((vaddr_t)pmap_pte(pmap, va)); /* @@ -2509,7 +2367,7 @@ * pmap_enter). */ if (pmap == pmap_kernel()) { - register struct kpt_page *kpt; + struct kpt_page *kpt; s = splvm(); if ((kpt = kpt_free_list) == NULL) { @@ -2631,7 +2489,7 @@ */ #if defined(M68040) || defined(M68060) if (mmutype == MMU_68040) { - u_int *este; + st_entry_t *este; for (este = &ste[NPTEPG / SG4_LEV3SIZE]; ste < este; ++ste) { *ste = ptpa | SG_U | SG_RW | SG_V; @@ -2661,46 +2519,12 @@ return 0; } -/* - * Routine: pmap_virtual_space - * - * Function: - * Report the range of available kernel virtual address - * space to the VM system during bootstrap. Called by - * vm_bootstrap_steal_memory(). - */ -void -pmap_virtual_space(vstartp, vendp) - vaddr_t *vstartp, *vendp; -{ - - *vstartp = virtual_avail; - *vendp = virtual_end; -} - -/* - * Routine: pmap_procwr - * - * Function: - * Synchronize caches corresponding to [addr, addr+len) in - * p. - * - */ -void -pmap_procwr(p, va, len) - struct proc *p; - vaddr_t va; - u_long len; -{ - (void)cachectl1(0x80000004, va, len, p); -} - #ifdef DEBUG -static void +void pmap_pvdump(pa) paddr_t pa; { - register pv_entry_t pv; + struct pv_entry *pv; printf("pa %lx", pa); for (pv = pa_to_pvh(pa); pv; pv = pv->pv_next) @@ -2717,9 +2541,9 @@ * and ensure that it is consistent with the number of wirings * to that page that the VM system has. */ -static void +void pmap_check_wiring(str, va) - char *str; + const char *str; vaddr_t va; { pt_entry_t *pte; @@ -2739,7 +2563,8 @@ } count = 0; - for (pte = (pt_entry_t *)va; pte < (pt_entry_t *)(va + PAGE_SIZE); pte++) + for (pte = (pt_entry_t *)va; pte < (pt_entry_t *)(va + PAGE_SIZE); + pte++) if (*pte) count++; if (pg->wire_count != count) @@ -2747,3 +2572,37 @@ str, va, pg->wire_count, count); } #endif + +/* + * Routine: pmap_virtual_space + * + * Function: + * Report the range of available kernel virtual address + * space to the VM system during bootstrap. Called by + * vm_bootstrap_steal_memory(). + */ +void +pmap_virtual_space(vstartp, vendp) + vaddr_t *vstartp, *vendp; +{ + + *vstartp = virtual_avail; + *vendp = virtual_end; +} + +/* + * Routine: pmap_procwr + * + * Function: + * Synchronize caches corresponding to [addr, addr+len) in + * p. + * + */ +void +pmap_procwr(p, va, len) + struct proc *p; + vaddr_t va; + size_t len; +{ + (void)cachectl1(0x80000004, va, len, p); +} Index: conf/files.atari =================================================================== RCS file: /cvsroot/src/sys/arch/atari/conf/files.atari,v retrieving revision 1.108 diff -u -r1.108 files.atari --- conf/files.atari 11 Dec 2005 12:16:54 -0000 1.108 +++ conf/files.atari 25 Dec 2008 15:01:15 -0000 @@ -203,6 +203,7 @@ file arch/atari/atari/mainbus.c file arch/atari/atari/mem.c file arch/atari/atari/pmap.c +file arch/atari/atari/pmap_bootstrap.c file arch/atari/atari/trap.c file arch/atari/atari/stalloc.c file arch/atari/atari/fpu.c @@ -210,6 +211,7 @@ file arch/atari/atari/intr.c file arch/m68k/m68k/cacheops.c file arch/m68k/m68k/db_memrw.c ddb +#file arch/m68k/m68k/pmap_motorola.c file arch/m68k/m68k/procfs_machdep.c procfs file arch/m68k/m68k/sys_machdep.c file arch/m68k/m68k/vm_machdep.c Index: dev/dma.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/dev/dma.c,v retrieving revision 1.17 diff -u -r1.17 dma.c --- dev/dma.c 11 Dec 2005 12:16:54 -0000 1.17 +++ dev/dma.c 25 Dec 2008 15:01:15 -0000 @@ -236,9 +236,9 @@ if(!BASEPRI(sr)) add_sicallback((si_farg)int_func, softc, 0); else { - spl1(); + int s = splraise1(); (*int_func)(softc); - spl0(); + splx(s); } return 1; } Index: dev/kbd.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/dev/kbd.c,v retrieving revision 1.29 diff -u -r1.29 kbd.c --- dev/kbd.c 11 Dec 2005 12:16:54 -0000 1.29 +++ dev/kbd.c 25 Dec 2008 15:01:15 -0000 @@ -418,8 +418,9 @@ if (!kbd_soft++) add_sicallback(kbdsoft, 0, 0); } else { - spl1(); + int s = splraise1(); kbdsoft(NULL, NULL); + splx(s); } } } Index: dev/md_root.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/dev/md_root.c,v retrieving revision 1.20.24.2 diff -u -r1.20.24.2 md_root.c --- dev/md_root.c 30 Nov 2008 13:03:50 -0000 1.20.24.2 +++ dev/md_root.c 25 Dec 2008 15:01:15 -0000 @@ -250,7 +250,6 @@ printf("\n"); done = bp->b_bcount - bp->b_resid; - brelse(bp); bytes_left -= done; rsp->offset += done; @@ -335,7 +334,6 @@ printf("\n"); done = bp->b_bcount - bp->b_resid; - brelse(bp); nbyte -= done; nread += done; Index: dev/wdc_mb.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/dev/wdc_mb.c,v retrieving revision 1.28.22.1 diff -u -r1.28.22.1 wdc_mb.c --- dev/wdc_mb.c 2 Feb 2008 03:34:04 -0000 1.28.22.1 +++ dev/wdc_mb.c 25 Dec 2008 15:01:15 -0000 @@ -290,9 +290,9 @@ bus_size_t o, c; u_int16_t *a; { - u_int16_t *ba; + volatile u_int16_t *ba; - ba = (u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); + ba = (volatile u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); for (; c; a++, c--) *a = bswap16(*ba); } @@ -304,9 +304,9 @@ bus_size_t o, c; const u_int16_t *a; { - u_int16_t *ba; + volatile u_int16_t *ba; - ba = (u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); + ba = (volatile u_int16_t *)calc_addr(h, o, t->stride, t->wo_2); for (; c; a++, c--) *ba = bswap16(*a); } Index: dev/zs.c =================================================================== RCS file: /cvsroot/src/sys/arch/atari/dev/zs.c,v retrieving revision 1.51 diff -u -r1.51 zs.c --- dev/zs.c 1 Oct 2006 20:31:50 -0000 1.51 +++ dev/zs.c 25 Dec 2008 15:01:15 -0000 @@ -585,7 +585,7 @@ register struct zs_chanstate *a; #define b (a + 1) register volatile struct zschan *zc; - register int rr3, intflags = 0, v, i; + register int rr3, intflags = 0, v, i, rv; do { intflags &= ~4; @@ -633,9 +633,11 @@ if(intflags & 1) { if(BASEPRI(sr)) { - spl1(); + int s = splraise1(); zsshortcuts++; - return(zssoft(sr)); + rv = zssoft(sr); + splx(s); + return rv; } else if(!cb_scheduled) { cb_scheduled++; Index: include/pcb.h =================================================================== RCS file: /cvsroot/src/sys/arch/atari/include/pcb.h,v retrieving revision 1.6 diff -u -r1.6 pcb.h --- include/pcb.h 11 Dec 2005 12:16:59 -0000 1.6 +++ include/pcb.h 25 Dec 2008 15:01:15 -0000 @@ -1,115 +1,3 @@ /* $NetBSD: pcb.h,v 1.6 2005/12/11 12:16:59 christos Exp $ */ -/* - * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: pcb.h 1.13 89/04/23$ - * - * @(#)pcb.h 7.4 (Berkeley) 5/4/91 - */ -/* - * Copyright (c) 1988 University of Utah. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: pcb.h 1.13 89/04/23$ - * - * @(#)pcb.h 7.4 (Berkeley) 5/4/91 - */ - -#ifndef _MACHINE_PCB_H_ -#define _MACHINE_PCB_H_ - -#include - -/* - * ATARI process control block - */ -struct pcb -{ - short pcb_flags; /* misc. process flags (+0) */ - short pcb_ps; /* processor status word (+2) */ - int __pcb_spare0; - int pcb_usp; /* user stack pointer (+8) */ - int pcb_regs[12]; /* D2-D7, A2-A7 (+C) */ - int pcb_cmap2; /* temporary copy PTE */ - caddr_t pcb_onfault; /* for copyin/out faults */ - struct fpframe pcb_fpregs; /* 68881/2 context save area */ - int pcb_exec[16]; /* exec structure for core dumps */ -}; - -/* Positions within pcb_regs[] of A6 and A7 (FP and SP). For m68k DDB. */ -#define PCB_REGS_FP 10 -#define PCB_REGS_SP 11 - -/* flags (none currently used) */ - -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. For the hp300, this includes an HP-UX exec header - * which is dumped for HP-UX processes. - */ -struct md_coredump { - int md_exec[16]; /* exec structure for HP-UX core dumps */ -}; - -#endif /* !_MACHINE_PCB_H_ */ +#include Index: include/pmap.h =================================================================== RCS file: /cvsroot/src/sys/arch/atari/include/pmap.h,v retrieving revision 1.34 diff -u -r1.34 pmap.h --- include/pmap.h 16 Feb 2006 20:17:13 -0000 1.34 +++ include/pmap.h 25 Dec 2008 15:01:15 -0000 @@ -76,47 +76,7 @@ #ifndef _MACHINE_PMAP_H_ #define _MACHINE_PMAP_H_ -/* - * Pmap stuff - */ -struct pmap { - pt_entry_t *pm_ptab; /* KVA of page table */ - st_entry_t *pm_stab; /* KVA of segment table */ - int pm_stfree; /* 040: free lev2 blocks */ - u_int *pm_stpa; /* 040: ST phys. address */ - short pm_sref; /* segment table ref count */ - short pm_count; /* pmap reference count */ - long pm_ptpages; /* more stats: PT pages */ - struct simplelock pm_lock; /* lock on pmap */ - struct pmap_statistics pm_stats; /* pmap statistics */ -}; - -typedef struct pmap *pmap_t; - -/* - * On the 040 we keep track of which level 2 blocks are already in use - * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB - * (block 31). For convenience, the level 1 table is considered to be - * block 0. - * - * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed. - * for the kernel and users. 16 implies only the initial "segment table" - * page is used. WARNING: don't change MAXUL2SIZE unless you can allocate - * physically contiguous pages for the ST in pmap.c! - */ -#define MAXKL2SIZE 32 -#define MAXUL2SIZE 16 -#define l2tobm(n) (1 << (n)) -#define bmtol2(n) (ffs(n) - 1) - -/* - * Macros for speed - */ -#define PMAP_ACTIVATE(pmap, loadhw) \ -{ \ - if ((loadhw)) \ - loadustp(m68k_btop((pmap)->pm_stpa)); \ -} +#include /* * Description of the memory segments. Build in atari_init/start_c(). @@ -125,44 +85,9 @@ */ #define NMEM_SEGS 8 struct memseg { - paddr_t start; /* PA of first page in segment */ - paddr_t end; /* PA of last page in segment */ - int first_page; /* relative page# of 'start' */ -}; - -/* - * For each struct vm_page, there is a list of all currently valid virtual - * mappings of that page. An entry is a pv_entry_t, the list is pv_table. - */ -typedef struct pv_entry { - struct pv_entry *pv_next; /* next pv_entry */ - struct pmap *pv_pmap; /* pmap where mapping lies */ - vaddr_t pv_va; /* virtual address for mapping */ - u_int *pv_ptste; /* non-zero if VA maps a PT page */ - struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ - int pv_flags; /* flags */ -} *pv_entry_t; - -#define PV_CI 0x01 /* all entries must be cache inhibited */ -#define PV_PTPAGE 0x02 /* entry maps a page table page */ - -struct pv_page; - -struct pv_page_info { - TAILQ_ENTRY(pv_page) pgi_list; - struct pv_entry *pgi_freelist; - int pgi_nfree; -}; - -/* - * This is basically: - * ((PAGE_SIZE - sizeof(struct pv_page_info)) / sizeof(struct pv_entry)) - */ -#define NPVPPG 340 - -struct pv_page { - struct pv_page_info pvp_pgi; - struct pv_entry pvp_pv[NPVPPG]; + paddr_t start; /* PA of first page in segment */ + paddr_t end; /* PA of last page in segment */ + int first_page; /* relative page# of 'start' */ }; #ifdef _KERNEL @@ -177,33 +102,9 @@ struct memseg boot_segs[NMEM_SEGS]; struct memseg usable_segs[NMEM_SEGS]; -pv_entry_t pv_table; /* array of entries, one per page */ -u_int *Sysmap; -char *vmmap; /* map for mem, dumps, etc. */ struct pmap kernel_pmap_store; -#define pmap_kernel() (&kernel_pmap_store) -#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) -#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) - -#define pmap_update(pmap) /* nothing (yet) */ - -static __inline void -pmap_remove_all(struct pmap *pmap) -{ - /* Nothing. */ -} - -#define active_user_pmap(pm) \ - (curproc && \ - (pm) != pmap_kernel() && (pm) == curproc->p_vmspace->vm_map.pmap) - -void pmap_bootstrap __P((psize_t, u_int, u_int)); -void pmap_changebit __P((paddr_t, int, boolean_t)); - -vaddr_t pmap_map __P((vaddr_t, paddr_t, paddr_t, int)); -void pmap_procwr __P((struct proc *, vaddr_t, u_long)); -#define PMAP_NEED_PROCWR +void pmap_bootstrap __P((psize_t, u_int)); #endif /* _KERNEL */ Index: include/pte.h =================================================================== RCS file: /cvsroot/src/sys/arch/atari/include/pte.h,v retrieving revision 1.7 diff -u -r1.7 pte.h --- include/pte.h 11 Dec 2005 12:16:59 -0000 1.7 +++ include/pte.h 25 Dec 2008 15:01:15 -0000 @@ -1,188 +1,3 @@ /* $NetBSD: pte.h,v 1.7 2005/12/11 12:16:59 christos Exp $ */ -/* - * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: pte.h 1.11 89/09/03$ - * - * @(#)pte.h 7.3 (Berkeley) 5/8/91 - */ -/* - * Copyright (c) 1988 University of Utah. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: pte.h 1.11 89/09/03$ - * - * @(#)pte.h 7.3 (Berkeley) 5/8/91 - */ - -#ifndef _MACHINE_PTE_H_ -#define _MACHINE_PTE_H_ - -/* - * ATARI hardware segment/page table entries - */ - -struct pte { - u_int pte; -}; - -typedef u_int pt_entry_t; - -struct ste { - u_int ste; -}; - -typedef u_int st_entry_t; - -#define PT_ENTRY_NULL ((pt_entry_t *) 0) -#define ST_ENTRY_NULL ((st_entry_t *) 0) - -#define SG_V 0x00000002 /* segment is valid */ -#define SG_NV 0x00000000 -#define SG_PROT 0x00000004 /* access protection mask */ -#define SG_RO 0x00000004 -#define SG_RW 0x00000000 -#define SG_U 0x00000008 /* modified bit (68040) */ -#define SG_FRAME 0xffffe000 -#define SG_IMASK 0xff000000 -#define SG_ISHIFT 24 -#define SG_PMASK 0x00ffe000 -#define SG_PSHIFT 13 - -/* 68040 additions */ -#define SG4_MASK1 0xfe000000 /* pointer table 1 index mask */ -#define SG4_SHIFT1 25 -#define SG4_MASK2 0x01fc0000 /* pointer table 2 index mask */ -#define SG4_SHIFT2 18 -#define SG4_MASK3 0x0003e000 /* page table index mask */ -#define SG4_SHIFT3 13 -#define SG4_ADDR1 0xfffffe00 /* pointer table address mask */ -#define SG4_ADDR2 0xffffff80 /* page table address mask */ -#define SG4_LEV1SIZE 128 /* entries in pointer table 1 */ -#define SG4_LEV2SIZE 128 /* entries in pointer table 2 */ -#define SG4_LEV3SIZE 32 /* entries in page table */ - -#define PG_V 0x00000001 -#define PG_NV 0x00000000 -#define PG_PROT 0x00000004 -#define PG_U 0x00000008 -#define PG_M 0x00000010 -/* - * XXX The Milan uses the U0 pin to switch the pci-bridge between little & big - * endian mode. That's why I moved the 'wired' flag to U1 leo 10Apr/2001. - */ -#if 0 -#define PG_W 0x00000100 -#else -#define PG_W 0x00000200 -#endif -#define PG_RO 0x00000004 -#define PG_RW 0x00000000 -#define PG_FRAME 0xffffe000 -#define PG_CI 0x00000040 -#define PG_SHIFT 13 -#define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT) - -/* 68040 additions */ -#define PG_CMASK 0x00000060 /* cache mode mask */ -#define PG_CWT 0x00000000 /* writethrough caching */ -#define PG_CCB 0x00000020 /* copyback caching */ -#define PG_CIS 0x00000040 /* cache inhibited serialized */ -#define PG_CIN 0x00000060 /* cache inhibited nonserialized */ -#define PG_SO 0x00000080 /* supervisor only */ - -#define ATARI_STSIZE (MAXUL2SIZE*SG4_LEV2SIZE*sizeof(st_entry_t)) - -/* - * ATARI_MAX_COREUPT maximum number of incore user page tables - * ATARI_USER_PTSIZE the number of bytes for user pagetables - * ATARI_PTBASE the VA start of the map from which upt's are allocated - * ATARI_PTSIZE the size of the map from which upt's are allocated - * ATARI_KPTSIZE size of kernel page table - * ATARI_MAX_KPTSIZE the most number of bytes for kpt pages - * ATARI_MAX_PTSIZE the number of bytes to map everything - */ -#define ATARI_MAX_COREUPT 1024 -#define ATARI_UPTSIZE roundup(VM_MAXUSER_ADDRESS / NPTEPG, PAGE_SIZE) -#define ATARI_UPTBASE 0x10000000 -#define ATARI_UPTMAXSIZE \ - roundup((ATARI_MAX_COREUPT * ATARI_UPTSIZE), PAGE_SIZE) -#define ATARI_MAX_KPTSIZE \ - (ATARI_MAX_COREUPT * ATARI_UPTSIZE / NPTEPG) -#define ATARI_KPTSIZE \ - roundup((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / NPTEPG, PAGE_SIZE) -#define ATARI_MAX_PTSIZE roundup(0xffffffff / NPTEPG, PAGE_SIZE) - -/* - * Kernel virtual address to page table entry and to physical address. - */ -#define kvtopte(va) \ - (&Sysmap[((unsigned)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT]) -#define ptetokv(pt) \ - ((((u_int *)(pt) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS) -#define kvtophys(va) \ - ((kvtopte(va)->pg_pfnum << PGSHIFT) | ((int)(va) & PGOFSET)) - - -#endif /* !_MACHINE_PTE_H_ */ +#include Index: include/vmparam.h =================================================================== RCS file: /cvsroot/src/sys/arch/atari/include/vmparam.h,v retrieving revision 1.21 diff -u -r1.21 vmparam.h --- include/vmparam.h 11 Dec 2005 12:16:59 -0000 1.21 +++ include/vmparam.h 25 Dec 2008 15:01:15 -0000 @@ -152,7 +152,7 @@ #define VM_MAX_ADDRESS ((vaddr_t)(USRSTACK)) #define VM_MAXUSER_ADDRESS ((vaddr_t)(VM_MAX_ADDRESS)) #define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0) -#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE)) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-(NPTEPG * PAGE_SIZE)) /* * virtual sizes (bytes) for various kernel submaps --- /dev/null 2008-12-25 23:50:24.000000000 +0900 +++ atari/pmap_bootstrap.c 2008-12-25 22:52:37.000000000 +0900 @@ -0,0 +1,219 @@ +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1991 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)pmap.c 7.5 (Berkeley) 5/10/91 + */ + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +/* + * Kernel segment/page table and page table map. + * The page table map gives us a level of indirection we need to dynamically + * expand the page table. It is essentially a copy of the segment table + * with PTEs instead of STEs. All are initialized in locore at boot time. + * Sysmap will initially contain VM_KERNEL_PT_PAGES pages of PTEs. + * Segtabzero is an empty segment table which all processes share til they + * reference something. + */ +u_int *Sysseg, *Sysseg_pa; +pt_entry_t *Sysmap, *Sysptmap; + +vsize_t mem_size; /* memory size in bytes */ +paddr_t avail_end; /* PA of last available physical page */ +vaddr_t virtual_avail; /* VA of first avail page (after kernel bss)*/ +vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */ +#if defined(M68040) || defined(M68060) +int protostfree; /* prototype (default) free ST map */ +#endif + +extern void * msgbufaddr; +extern paddr_t msgbufpa; + +/* + * All those kernel PT submaps that BSD is so fond of + */ +void *CADDR1, *CADDR2; +char *vmmap; + +extern int protection_codes[]; + +/* + * Bootstrap the system enough to run with virtual memory. + * Map the kernel's code and data, and allocate the system page table. + * + * On the HP this is called after mapping has already been enabled + * and just syncs the pmap module with what has already been done. + * [We can't call it easily with mapping off since the kernel is not + * mapped with PA == VA, hence we would have to relocate every address + * from the linked base (virtual) address 0 to the actual (physical) + * address of 0xFFxxxxxx.] + */ +void +pmap_bootstrap(kernel_size, hw_addr) +psize_t kernel_size; +u_int hw_addr; +{ + vaddr_t va; + int i; + + /* + * Announce page-size to the VM-system + */ + uvmexp.pagesize = NBPG; + uvm_setpagesize(); + + /* + * Setup physical address ranges + */ + for (i = 0; usable_segs[i+1].start; i++) + ; + /* XXX: allow for msgbuf */ + usable_segs[i].end -= m68k_round_page(MSGBUFSIZE); + avail_end = msgbufpa = usable_segs[i].end; + + /* + * Count physical memory + */ + for (i = mem_size = 0; i < NMEM_SEGS; i++) { + if (boot_segs[i].start == boot_segs[i].end) + break; + mem_size += boot_segs[i].end - boot_segs[i].start; + } + + /* + * Announce available memory to the VM-system + */ + for (i = 0; usable_segs[i].start; i++) + uvm_page_physload(atop(usable_segs[i].start), + atop(usable_segs[i].end), + atop(usable_segs[i].start), + atop(usable_segs[i].end), + VM_FREELIST_DEFAULT); + + virtual_avail = VM_MIN_KERNEL_ADDRESS + kernel_size; + virtual_end = VM_MAX_KERNEL_ADDRESS; + + /* + * Initialize protection array. + * XXX don't use a switch statement, it might produce an + * absolute "jmp" table. + */ + { + int *kp; + + kp = (int *)&protection_codes; + kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_NONE] = 0; + kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_NONE] = PG_RO; + kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO; + kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO; + kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW; + kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW; + kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW; + kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW; + } + + /* + * Kernel page/segment table allocated in locore, + * just initialize pointers. + */ + pmap_kernel()->pm_stpa = Sysseg_pa; + pmap_kernel()->pm_stab = Sysseg; + pmap_kernel()->pm_ptab = Sysmap; +#if defined(M68040) || defined(M68060) + if (mmutype == MMU_68040) { + pmap_kernel()->pm_stfree = protostfree; + } +#endif + + simple_lock_init(&pmap_kernel()->pm_lock); + pmap_kernel()->pm_count = 1; + + /* + * Allocate all the submaps we need + */ +#define SYSMAP(c, v, n) \ + v = (c)va; va += ((n)*PAGE_SIZE); + + va = virtual_avail; + + SYSMAP(void * ,CADDR1 ,1 ) + SYSMAP(void * ,CADDR2 ,1 ) + SYSMAP(void * ,vmmap ,1 ) + SYSMAP(void * ,msgbufaddr ,btoc(MSGBUFSIZE) ) + + DCIS(); + + virtual_avail = reserve_dumppages(va); +}