diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index cc934e16ed8e..eff54459e293 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.141 1995/09/09 18:09:45 davidg Exp $ + * $Id: machdep.c,v 1.142 1995/09/10 21:34:52 bde Exp $ */ #include "npx.h" @@ -386,6 +386,15 @@ again: */ vm_bounce_init(); #endif + /* + * XXX allocate a contiguous area for ISA (non busmaster) DMA + * operations. This _should_ only be done if the DMA channels + * will actually be used, but for now we do it always. + */ +#define DMAPAGES 8 + isaphysmem = + vm_page_alloc_contig(DMAPAGES * PAGE_SIZE, 0, 0xfffffful, 64*1024); + printf("avail memory = %d (%dK bytes)\n", ptoa(cnt.v_free_count), ptoa(cnt.v_free_count) / 1024); diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 79d4f0e7be31..12ee5147c0c7 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -39,7 +39,7 @@ * SUCH DAMAGE. * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 - * $Id: pmap.c,v 1.59 1995/07/13 08:47:26 davidg Exp $ + * $Id: pmap.c,v 1.60 1995/07/28 11:21:06 davidg Exp $ */ /* @@ -90,6 +90,7 @@ #include #include #include +#include #include #include @@ -100,12 +101,6 @@ #include -/* - * Allocate various and sundry SYSMAPs used in the days of old VM - * and not yet converted. XXX. - */ -#define BSDVM_COMPAT 1 - /* * Get PDEs and PTEs for user/kernel address space */ @@ -138,7 +133,6 @@ vm_offset_t avail_end; /* PA of last available physical page */ vm_size_t mem_size; /* memory size in bytes */ vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss) */ vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */ -int i386pagesperpage; /* PAGE_SIZE / I386_PAGE_SIZE */ boolean_t pmap_initialized = FALSE; /* Has pmap_init completed? */ vm_offset_t vm_first_phys, vm_last_phys; @@ -148,13 +142,9 @@ static void pmap_alloc_pv_entry(); static inline pv_entry_t get_pv_entry(); int nkpt; - extern vm_offset_t clean_sva, clean_eva; extern int cpu_class; -#if BSDVM_COMPAT -#include - /* * All those kernel PT submaps that BSD is so fond of */ @@ -164,7 +154,6 @@ caddr_t CADDR1, CADDR2, ptvmmap; pt_entry_t *msgbufmap; struct msgbuf *msgbufp; -#endif void init_pv_entries(int); @@ -326,33 +315,34 @@ pmap_activate(pmap, pcbp) /* * Bootstrap the system enough to run with virtual memory. - * Map the kernel's code and data, and allocate the system page table. * - * On the I386 this is called after mapping has already been enabled + * On the i386 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 "KERNBASE" to the actual * (physical) address starting relative to 0] */ - -#define DMAPAGES 8 void pmap_bootstrap(firstaddr, loadaddr) vm_offset_t firstaddr; vm_offset_t loadaddr; { -#if BSDVM_COMPAT vm_offset_t va; pt_entry_t *pte; -#endif + avail_start = firstaddr; - avail_start = firstaddr + DMAPAGES * NBPG; - - virtual_avail = (vm_offset_t) KERNBASE + avail_start; + /* + * XXX The calculation of virtual_avail is wrong. It's NKPT*NBPG too + * large. It should instead be correctly calculated in locore.s and + * not based on 'first' (which is a physical address, not a virtual + * address, for the start of unused physical memory). The kernel + * page tables are NOT double mapped and thus should not be included + * in this calculation. + */ + virtual_avail = (vm_offset_t) KERNBASE + firstaddr; virtual_end = VM_MAX_KERNEL_ADDRESS; - i386pagesperpage = PAGE_SIZE / NBPG; /* * Initialize protection array. @@ -371,9 +361,9 @@ pmap_bootstrap(firstaddr, loadaddr) kernel_pmap->pm_count = 1; nkpt = NKPT; -#if BSDVM_COMPAT /* - * Allocate all the submaps we need + * Reserve some special page table entries/VA space for temporary + * mapping of pages. */ #define SYSMAP(c, p, v, n) \ v = (c)va; va += ((n)*NBPG); p = pte; pte += (n); @@ -381,26 +371,26 @@ pmap_bootstrap(firstaddr, loadaddr) va = virtual_avail; pte = pmap_pte(kernel_pmap, va); - SYSMAP(caddr_t, CMAP1, CADDR1, 1) - SYSMAP(caddr_t, CMAP2, CADDR2, 1) - SYSMAP(caddr_t, ptmmap, ptvmmap, 1) - SYSMAP(struct msgbuf *, msgbufmap, msgbufp, 1) - virtual_avail = va; -#endif /* - * Reserve special hunk of memory for use by bus dma as a bounce - * buffer (contiguous virtual *and* physical memory). + * CMAP1/CMAP2 are used for zeroing and copying pages. */ - { - isaphysmem = va; + SYSMAP(caddr_t, CMAP1, CADDR1, 1) + SYSMAP(caddr_t, CMAP2, CADDR2, 1) - virtual_avail = pmap_map(va, firstaddr, - firstaddr + DMAPAGES * NBPG, VM_PROT_ALL); - } + /* + * ptmmap is used for reading arbitrary physical pages via /dev/mem. + */ + SYSMAP(caddr_t, ptmmap, ptvmmap, 1) + + /* + * msgbufmap is used to map the system message buffer. + */ + SYSMAP(struct msgbuf *, msgbufmap, msgbufp, 1) + + virtual_avail = va; *(int *) CMAP1 = *(int *) CMAP2 = *(int *) PTD = 0; pmap_update(); - } /* @@ -418,19 +408,6 @@ pmap_init(phys_start, phys_end) vm_size_t npg, s; int i; - /* - * Now that kernel map has been allocated, we can mark as unavailable - * regions which we have mapped in locore. - */ - addr = atdevbase; - (void) vm_map_find(kernel_map, NULL, (vm_offset_t) 0, - &addr, (0x100000 - 0xa0000), FALSE); - - addr = (vm_offset_t) KERNBASE + IdlePTD; - vm_object_reference(kernel_object); - (void) vm_map_find(kernel_map, kernel_object, addr, - &addr, (4 + NKPDE) * NBPG, FALSE); - /* * calculate the number of pv_entries needed */ diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index cc934e16ed8e..eff54459e293 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.141 1995/09/09 18:09:45 davidg Exp $ + * $Id: machdep.c,v 1.142 1995/09/10 21:34:52 bde Exp $ */ #include "npx.h" @@ -386,6 +386,15 @@ again: */ vm_bounce_init(); #endif + /* + * XXX allocate a contiguous area for ISA (non busmaster) DMA + * operations. This _should_ only be done if the DMA channels + * will actually be used, but for now we do it always. + */ +#define DMAPAGES 8 + isaphysmem = + vm_page_alloc_contig(DMAPAGES * PAGE_SIZE, 0, 0xfffffful, 64*1024); + printf("avail memory = %d (%dK bytes)\n", ptoa(cnt.v_free_count), ptoa(cnt.v_free_count) / 1024); diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 79d4f0e7be31..12ee5147c0c7 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -39,7 +39,7 @@ * SUCH DAMAGE. * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 - * $Id: pmap.c,v 1.59 1995/07/13 08:47:26 davidg Exp $ + * $Id: pmap.c,v 1.60 1995/07/28 11:21:06 davidg Exp $ */ /* @@ -90,6 +90,7 @@ #include #include #include +#include #include #include @@ -100,12 +101,6 @@ #include -/* - * Allocate various and sundry SYSMAPs used in the days of old VM - * and not yet converted. XXX. - */ -#define BSDVM_COMPAT 1 - /* * Get PDEs and PTEs for user/kernel address space */ @@ -138,7 +133,6 @@ vm_offset_t avail_end; /* PA of last available physical page */ vm_size_t mem_size; /* memory size in bytes */ vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss) */ vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */ -int i386pagesperpage; /* PAGE_SIZE / I386_PAGE_SIZE */ boolean_t pmap_initialized = FALSE; /* Has pmap_init completed? */ vm_offset_t vm_first_phys, vm_last_phys; @@ -148,13 +142,9 @@ static void pmap_alloc_pv_entry(); static inline pv_entry_t get_pv_entry(); int nkpt; - extern vm_offset_t clean_sva, clean_eva; extern int cpu_class; -#if BSDVM_COMPAT -#include - /* * All those kernel PT submaps that BSD is so fond of */ @@ -164,7 +154,6 @@ caddr_t CADDR1, CADDR2, ptvmmap; pt_entry_t *msgbufmap; struct msgbuf *msgbufp; -#endif void init_pv_entries(int); @@ -326,33 +315,34 @@ pmap_activate(pmap, pcbp) /* * Bootstrap the system enough to run with virtual memory. - * Map the kernel's code and data, and allocate the system page table. * - * On the I386 this is called after mapping has already been enabled + * On the i386 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 "KERNBASE" to the actual * (physical) address starting relative to 0] */ - -#define DMAPAGES 8 void pmap_bootstrap(firstaddr, loadaddr) vm_offset_t firstaddr; vm_offset_t loadaddr; { -#if BSDVM_COMPAT vm_offset_t va; pt_entry_t *pte; -#endif + avail_start = firstaddr; - avail_start = firstaddr + DMAPAGES * NBPG; - - virtual_avail = (vm_offset_t) KERNBASE + avail_start; + /* + * XXX The calculation of virtual_avail is wrong. It's NKPT*NBPG too + * large. It should instead be correctly calculated in locore.s and + * not based on 'first' (which is a physical address, not a virtual + * address, for the start of unused physical memory). The kernel + * page tables are NOT double mapped and thus should not be included + * in this calculation. + */ + virtual_avail = (vm_offset_t) KERNBASE + firstaddr; virtual_end = VM_MAX_KERNEL_ADDRESS; - i386pagesperpage = PAGE_SIZE / NBPG; /* * Initialize protection array. @@ -371,9 +361,9 @@ pmap_bootstrap(firstaddr, loadaddr) kernel_pmap->pm_count = 1; nkpt = NKPT; -#if BSDVM_COMPAT /* - * Allocate all the submaps we need + * Reserve some special page table entries/VA space for temporary + * mapping of pages. */ #define SYSMAP(c, p, v, n) \ v = (c)va; va += ((n)*NBPG); p = pte; pte += (n); @@ -381,26 +371,26 @@ pmap_bootstrap(firstaddr, loadaddr) va = virtual_avail; pte = pmap_pte(kernel_pmap, va); - SYSMAP(caddr_t, CMAP1, CADDR1, 1) - SYSMAP(caddr_t, CMAP2, CADDR2, 1) - SYSMAP(caddr_t, ptmmap, ptvmmap, 1) - SYSMAP(struct msgbuf *, msgbufmap, msgbufp, 1) - virtual_avail = va; -#endif /* - * Reserve special hunk of memory for use by bus dma as a bounce - * buffer (contiguous virtual *and* physical memory). + * CMAP1/CMAP2 are used for zeroing and copying pages. */ - { - isaphysmem = va; + SYSMAP(caddr_t, CMAP1, CADDR1, 1) + SYSMAP(caddr_t, CMAP2, CADDR2, 1) - virtual_avail = pmap_map(va, firstaddr, - firstaddr + DMAPAGES * NBPG, VM_PROT_ALL); - } + /* + * ptmmap is used for reading arbitrary physical pages via /dev/mem. + */ + SYSMAP(caddr_t, ptmmap, ptvmmap, 1) + + /* + * msgbufmap is used to map the system message buffer. + */ + SYSMAP(struct msgbuf *, msgbufmap, msgbufp, 1) + + virtual_avail = va; *(int *) CMAP1 = *(int *) CMAP2 = *(int *) PTD = 0; pmap_update(); - } /* @@ -418,19 +408,6 @@ pmap_init(phys_start, phys_end) vm_size_t npg, s; int i; - /* - * Now that kernel map has been allocated, we can mark as unavailable - * regions which we have mapped in locore. - */ - addr = atdevbase; - (void) vm_map_find(kernel_map, NULL, (vm_offset_t) 0, - &addr, (0x100000 - 0xa0000), FALSE); - - addr = (vm_offset_t) KERNBASE + IdlePTD; - vm_object_reference(kernel_object); - (void) vm_map_find(kernel_map, kernel_object, addr, - &addr, (4 + NKPDE) * NBPG, FALSE); - /* * calculate the number of pv_entries needed */