Make the bounce buffer code a little more robust when space isn't

available.  If there isn't bounce space available, the bounce code
is disabled.  This will allow most large systems to run properly
when the bounce space is mistakenly allocated above 16MB.
This commit is contained in:
dyson 1998-01-30 10:26:26 +00:00
parent 2f0c56242f
commit bd0dfc98db
4 changed files with 50 additions and 38 deletions

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.283 1998/01/24 02:00:47 dyson Exp $
* $Id: machdep.c,v 1.284 1998/01/25 12:01:16 kato Exp $
*/
#include "apm.h"
@ -279,6 +279,20 @@ again:
(name) = (type *)v; v = (caddr_t)((name)+(num))
#define valloclim(name, type, num, lim) \
(name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
#ifdef BOUNCE_BUFFERS
/*
* If there is more than 16MB of memory, allocate some bounce buffers
*/
if (Maxmem > 4096) {
if (bouncepages == 0) {
bouncepages = 64;
}
v = (caddr_t)((vm_offset_t)round_page(v));
valloc(bouncememory, char, bouncepages * PAGE_SIZE);
}
#endif
valloc(callout, struct callout, ncallout);
valloc(callwheel, struct callout_tailq, callwheelsize);
#ifdef SYSVSHM
@ -307,21 +321,6 @@ again:
valloc(swbuf, struct buf, nswbuf);
valloc(buf, struct buf, nbuf);
#ifdef BOUNCE_BUFFERS
/*
* If there is more than 16MB of memory, allocate some bounce buffers
*/
if (Maxmem > 4096) {
if (bouncepages == 0) {
bouncepages = 64;
bouncepages += ((Maxmem - 4096) / 2048) * 32;
if (bouncepages > 128)
bouncepages = 128;
}
v = (caddr_t)((vm_offset_t)round_page(v));
valloc(bouncememory, char, bouncepages * PAGE_SIZE);
}
#endif
/*
* End of first pass, size has been calculated so allocate memory

View File

@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
* $Id: vm_machdep.c,v 1.95 1998/01/19 04:16:16 tegge Exp $
* $Id: vm_machdep.c,v 1.96 1998/01/22 17:29:32 dyson Exp $
*/
#include "npx.h"
@ -535,8 +535,15 @@ vm_bounce_init()
for(i=0;i<bouncepages;i++) {
vm_offset_t pa;
if( (pa = pmap_kextract((vm_offset_t) bouncememory + i * PAGE_SIZE)) >= SIXTEENMEG)
panic("bounce memory out of range");
if( (pa = pmap_kextract((vm_offset_t) bouncememory + i * PAGE_SIZE)) >= SIXTEENMEG) {
printf("vm_bounce_init: bounce memory out of range -- bounce disabled\n");
free(bounceallocarray, M_TEMP);
bounceallocarray = NULL;
free(bouncepa, M_TEMP);
bouncepa = NULL;
bouncepages = 0;
break;
}
if( pa == 0)
panic("bounce memory not resident");
bouncepa[i] = pa;

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.283 1998/01/24 02:00:47 dyson Exp $
* $Id: machdep.c,v 1.284 1998/01/25 12:01:16 kato Exp $
*/
#include "apm.h"
@ -279,6 +279,20 @@ again:
(name) = (type *)v; v = (caddr_t)((name)+(num))
#define valloclim(name, type, num, lim) \
(name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
#ifdef BOUNCE_BUFFERS
/*
* If there is more than 16MB of memory, allocate some bounce buffers
*/
if (Maxmem > 4096) {
if (bouncepages == 0) {
bouncepages = 64;
}
v = (caddr_t)((vm_offset_t)round_page(v));
valloc(bouncememory, char, bouncepages * PAGE_SIZE);
}
#endif
valloc(callout, struct callout, ncallout);
valloc(callwheel, struct callout_tailq, callwheelsize);
#ifdef SYSVSHM
@ -307,21 +321,6 @@ again:
valloc(swbuf, struct buf, nswbuf);
valloc(buf, struct buf, nbuf);
#ifdef BOUNCE_BUFFERS
/*
* If there is more than 16MB of memory, allocate some bounce buffers
*/
if (Maxmem > 4096) {
if (bouncepages == 0) {
bouncepages = 64;
bouncepages += ((Maxmem - 4096) / 2048) * 32;
if (bouncepages > 128)
bouncepages = 128;
}
v = (caddr_t)((vm_offset_t)round_page(v));
valloc(bouncememory, char, bouncepages * PAGE_SIZE);
}
#endif
/*
* End of first pass, size has been calculated so allocate memory

View File

@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
* $Id: vm_machdep.c,v 1.95 1998/01/19 04:16:16 tegge Exp $
* $Id: vm_machdep.c,v 1.96 1998/01/22 17:29:32 dyson Exp $
*/
#include "npx.h"
@ -535,8 +535,15 @@ vm_bounce_init()
for(i=0;i<bouncepages;i++) {
vm_offset_t pa;
if( (pa = pmap_kextract((vm_offset_t) bouncememory + i * PAGE_SIZE)) >= SIXTEENMEG)
panic("bounce memory out of range");
if( (pa = pmap_kextract((vm_offset_t) bouncememory + i * PAGE_SIZE)) >= SIXTEENMEG) {
printf("vm_bounce_init: bounce memory out of range -- bounce disabled\n");
free(bounceallocarray, M_TEMP);
bounceallocarray = NULL;
free(bouncepa, M_TEMP);
bouncepa = NULL;
bouncepages = 0;
break;
}
if( pa == 0)
panic("bounce memory not resident");
bouncepa[i] = pa;