From 9d6218d0885ced0f3475c5f6b042087debc0166e Mon Sep 17 00:00:00 2001 From: Kazutaka YOKOTA Date: Thu, 4 Sep 1997 23:01:06 +0000 Subject: Add a new compile option SC_HISTORY_SIZE to specify the history buffer size in terms of lines (instead of bytes). When changing video mode in ioctl SW_XXX commands, syscons checks scp->history_size and allocate a history buffer at least as large as the new screen size. (This was unnecessary before, because HISTORY_SIZE was as large as 100 lines and this is bigger than the maximum screen size: 60 lines). Similar adjustment is done in ioctl CONS_HISTORY command too. PR: kern/4169 Reviewed by: sos --- sys/isa/syscons.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'sys/isa/syscons.c') diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index 1dc654203599..25bf83153510 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.229 1997/08/08 22:52:30 sos Exp $ + * $Id: syscons.c,v 1.230 1997/08/09 19:24:03 sos Exp $ */ #include "sc.h" @@ -961,16 +961,11 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) return EBUSY; if (scp->history != NULL) free(scp->history, M_DEVBUF); - scp->history_size = *(int*)data; - if (scp->history_size < scp->ysize) - scp->history = NULL; - else { - scp->history_size *= scp->xsize; - scp->history_head = scp->history_pos = scp->history = - (u_short *)malloc(scp->history_size*sizeof(u_short), - M_DEVBUF, M_WAITOK); - bzero(scp->history_head, scp->history_size*sizeof(u_short)); - } + scp->history_size = max(scp->ysize, *(int *)data)*scp->xsize; + scp->history_head = scp->history_pos = scp->history = + (u_short *)malloc(scp->history_size*sizeof(u_short), + M_DEVBUF, M_WAITOK); + bzero(scp->history_head, scp->history_size*sizeof(u_short)); return 0; } else @@ -1183,6 +1178,13 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) free(cut_buffer, M_DEVBUF); cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT); cut_buffer[0] = 0x00; + if (scp->history != NULL) + free(scp->history, M_DEVBUF); + scp->history_size = max(HISTORY_SIZE, scp->xsize*scp->ysize); + scp->history_head = scp->history_pos = scp->history = (u_short *) + malloc(scp->history_size*sizeof(u_short), M_DEVBUF, M_NOWAIT); + if (scp->history != NULL) + bzero(scp->history, scp->history_size*sizeof(u_short)); if (scp == cur_console) set_mode(scp); scp->status &= ~UNKNOWN_MODE; @@ -2812,7 +2814,7 @@ init_scp(scr_stat *scp) scp->proc = NULL; scp->smode.mode = VT_AUTO; scp->history_head = scp->history_pos = scp->history = NULL; - scp->history_size = HISTORY_SIZE; + scp->history_size = max(HISTORY_SIZE, scp->xsize*scp->ysize); } static u_char -- cgit v1.2.3