summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoryokota <yokota@FreeBSD.org>1998-08-03 09:17:06 +0000
committeryokota <yokota@FreeBSD.org>1998-08-03 09:17:06 +0000
commit513eb689bc0fd059b1bf339249f3ee2b3f23c134 (patch)
treed4f943dfe2069e25cacdcd5ba286a0f0ccee159b /sys
parent8c6ba1f58e8d974f042a5cd8a379066435c2a99b (diff)
downloadFreeBSD-src-513eb689bc0fd059b1bf339249f3ee2b3f23c134.zip
FreeBSD-src-513eb689bc0fd059b1bf339249f3ee2b3f23c134.tar.gz
Fix the bug which always reallocated the cut buffer whenever
the screen mode is changed even if another vty has larger size. Reallocate the buffer only when the new screen size is larger than the current cut buffer size.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/syscons/syscons.c25
-rw-r--r--sys/i386/isa/syscons.c25
-rw-r--r--sys/isa/syscons.c25
3 files changed, 54 insertions, 21 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 000f9d7..b996d39 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/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.268 1998/08/03 09:09:34 yokota Exp $
+ * $Id: syscons.c,v 1.269 1998/08/03 09:15:36 yokota Exp $
*/
#include "sc.h"
@@ -184,6 +184,7 @@ static char vgaregs[MODE_PARAM_SIZE];
static char vgaregs2[MODE_PARAM_SIZE];
static int rows_offset = 1;
static char *cut_buffer;
+static int cut_buffer_size;
static int mouse_level = 0; /* sysmouse protocol level */
static mousestatus_t mouse_status = { 0, 0, 0, 0, 0, 0 };
static u_short mouse_and_mask[16] = {
@@ -720,7 +721,10 @@ scattach(struct isa_device *dev)
scp = console[0];
if (crtc_vga) {
- cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
+ cut_buffer_size = scp->xsize * scp->ysize + 1;
+ cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
+ if (cut_buffer != NULL)
+ cut_buffer[0] = '\0';
}
scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
@@ -1289,7 +1293,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
else
psignal(cur_console->mouse_proc, cur_console->mouse_signal);
}
- else if (mouse->operation == MOUSE_ACTION) {
+ else if (mouse->operation == MOUSE_ACTION && cut_buffer != NULL) {
/* process button presses */
if ((cur_console->mouse_buttons ^ mouse->u.data.buttons) &&
!(cur_console->status & UNKNOWN_MODE)) {
@@ -1356,7 +1360,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
- if (cur_console->status & UNKNOWN_MODE)
+ if ((cur_console->status & UNKNOWN_MODE) || (cut_buffer == NULL))
break;
switch (mouse->u.event.id) {
@@ -1641,9 +1645,16 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
scp->mouse_pos = scp->mouse_oldpos =
scp->scr_buf + (scp->mouse_ypos / scp->font_size) * scp->xsize
+ scp->mouse_xpos / 8;
- free(cut_buffer, M_DEVBUF);
- cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
- cut_buffer[0] = 0x00;
+ /* allocate a larger cut buffer if necessary */
+ if ((cut_buffer == NULL)
+ || (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
+ if (cut_buffer != NULL)
+ free(cut_buffer, M_DEVBUF);
+ cut_buffer_size = scp->xsize * scp->ysize + 1;
+ cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
+ if (cut_buffer != NULL)
+ cut_buffer[0] = '\0';
+ }
splx(s);
usp = scp->history;
diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c
index 000f9d7..b996d39 100644
--- a/sys/i386/isa/syscons.c
+++ b/sys/i386/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.268 1998/08/03 09:09:34 yokota Exp $
+ * $Id: syscons.c,v 1.269 1998/08/03 09:15:36 yokota Exp $
*/
#include "sc.h"
@@ -184,6 +184,7 @@ static char vgaregs[MODE_PARAM_SIZE];
static char vgaregs2[MODE_PARAM_SIZE];
static int rows_offset = 1;
static char *cut_buffer;
+static int cut_buffer_size;
static int mouse_level = 0; /* sysmouse protocol level */
static mousestatus_t mouse_status = { 0, 0, 0, 0, 0, 0 };
static u_short mouse_and_mask[16] = {
@@ -720,7 +721,10 @@ scattach(struct isa_device *dev)
scp = console[0];
if (crtc_vga) {
- cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
+ cut_buffer_size = scp->xsize * scp->ysize + 1;
+ cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
+ if (cut_buffer != NULL)
+ cut_buffer[0] = '\0';
}
scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
@@ -1289,7 +1293,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
else
psignal(cur_console->mouse_proc, cur_console->mouse_signal);
}
- else if (mouse->operation == MOUSE_ACTION) {
+ else if (mouse->operation == MOUSE_ACTION && cut_buffer != NULL) {
/* process button presses */
if ((cur_console->mouse_buttons ^ mouse->u.data.buttons) &&
!(cur_console->status & UNKNOWN_MODE)) {
@@ -1356,7 +1360,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
- if (cur_console->status & UNKNOWN_MODE)
+ if ((cur_console->status & UNKNOWN_MODE) || (cut_buffer == NULL))
break;
switch (mouse->u.event.id) {
@@ -1641,9 +1645,16 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
scp->mouse_pos = scp->mouse_oldpos =
scp->scr_buf + (scp->mouse_ypos / scp->font_size) * scp->xsize
+ scp->mouse_xpos / 8;
- free(cut_buffer, M_DEVBUF);
- cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
- cut_buffer[0] = 0x00;
+ /* allocate a larger cut buffer if necessary */
+ if ((cut_buffer == NULL)
+ || (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
+ if (cut_buffer != NULL)
+ free(cut_buffer, M_DEVBUF);
+ cut_buffer_size = scp->xsize * scp->ysize + 1;
+ cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
+ if (cut_buffer != NULL)
+ cut_buffer[0] = '\0';
+ }
splx(s);
usp = scp->history;
diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c
index 000f9d7..b996d39 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.268 1998/08/03 09:09:34 yokota Exp $
+ * $Id: syscons.c,v 1.269 1998/08/03 09:15:36 yokota Exp $
*/
#include "sc.h"
@@ -184,6 +184,7 @@ static char vgaregs[MODE_PARAM_SIZE];
static char vgaregs2[MODE_PARAM_SIZE];
static int rows_offset = 1;
static char *cut_buffer;
+static int cut_buffer_size;
static int mouse_level = 0; /* sysmouse protocol level */
static mousestatus_t mouse_status = { 0, 0, 0, 0, 0, 0 };
static u_short mouse_and_mask[16] = {
@@ -720,7 +721,10 @@ scattach(struct isa_device *dev)
scp = console[0];
if (crtc_vga) {
- cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
+ cut_buffer_size = scp->xsize * scp->ysize + 1;
+ cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
+ if (cut_buffer != NULL)
+ cut_buffer[0] = '\0';
}
scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
@@ -1289,7 +1293,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
else
psignal(cur_console->mouse_proc, cur_console->mouse_signal);
}
- else if (mouse->operation == MOUSE_ACTION) {
+ else if (mouse->operation == MOUSE_ACTION && cut_buffer != NULL) {
/* process button presses */
if ((cur_console->mouse_buttons ^ mouse->u.data.buttons) &&
!(cur_console->status & UNKNOWN_MODE)) {
@@ -1356,7 +1360,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
- if (cur_console->status & UNKNOWN_MODE)
+ if ((cur_console->status & UNKNOWN_MODE) || (cut_buffer == NULL))
break;
switch (mouse->u.event.id) {
@@ -1641,9 +1645,16 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
scp->mouse_pos = scp->mouse_oldpos =
scp->scr_buf + (scp->mouse_ypos / scp->font_size) * scp->xsize
+ scp->mouse_xpos / 8;
- free(cut_buffer, M_DEVBUF);
- cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
- cut_buffer[0] = 0x00;
+ /* allocate a larger cut buffer if necessary */
+ if ((cut_buffer == NULL)
+ || (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
+ if (cut_buffer != NULL)
+ free(cut_buffer, M_DEVBUF);
+ cut_buffer_size = scp->xsize * scp->ysize + 1;
+ cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
+ if (cut_buffer != NULL)
+ cut_buffer[0] = '\0';
+ }
splx(s);
usp = scp->history;
OpenPOWER on IntegriCloud