Make the size of the msgbuf (dmesg) a "normal" option.

This commit is contained in:
Poul-Henning Kamp 1998-05-19 08:58:53 +00:00
parent c92e3fa533
commit 58067a9909
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36179
12 changed files with 89 additions and 48 deletions

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static const char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93";
#endif
static const char rcsid[] =
"$Id: dmesg.c,v 1.6 1997/02/22 14:32:13 peter Exp $";
"$Id: dmesg.c,v 1.7 1997/03/29 03:32:14 imp Exp $";
#endif /* not lint */
#include <sys/cdefs.h>
@ -79,7 +79,7 @@ main(argc, argv)
register int ch, newl, skip;
register char *p, *ep;
struct msgbuf *bufp, cur;
char *memf, *nlistf;
char *bp, *memf, *nlistf;
kvm_t *kd;
char buf[5];
@ -116,11 +116,17 @@ main(argc, argv)
errx(1, "%s: msgbufp not found", nlistf ? nlistf : "namelist");
if (KREAD(nl[X_MSGBUF].n_value, bufp) || KREAD((long)bufp, cur))
errx(1, "kvm_read: %s", kvm_geterr(kd));
kvm_close(kd);
if (cur.msg_magic != MSG_MAGIC)
errx(1, "magic number incorrect");
if (cur.msg_bufx >= MSG_BSIZE)
bp = malloc(cur.msg_size);
if (!bp)
errx(1, "malloc failed");
if (kvm_read(kd, (long)cur.msg_ptr, bp, cur.msg_size) !=
cur.msg_size)
errx(1, "kvm_read: %s", kvm_geterr(kd));
if (cur.msg_bufx >= cur.msg_size)
cur.msg_bufx = 0;
kvm_close(kd);
/*
* The message buffer is circular. If the buffer has wrapped, the
@ -129,12 +135,12 @@ main(argc, argv)
* buffer starting at the write pointer and ignore nulls so that
* we effectively start at the oldest data.
*/
p = cur.msg_bufc + cur.msg_bufx;
ep = (cur.msg_bufx == 0 ? cur.msg_bufc + MSG_BSIZE : p);
p = bp + cur.msg_bufx;
ep = (cur.msg_bufx == 0 ? bp + cur.msg_size : p);
newl = skip = 0;
do {
if (p == cur.msg_bufc + MSG_BSIZE)
p = cur.msg_bufc;
if (p == bp + cur.msg_size)
p = bp;
ch = *p;
/* Skip "\n<.*>" syslog sequences. */
if (skip) {

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.294 1998/04/06 15:46:17 peter Exp $
* $Id: machdep.c,v 1.295 1998/05/19 00:00:09 tegge Exp $
*/
#include "apm.h"
@ -44,6 +44,7 @@
#include "opt_cpu.h"
#include "opt_ddb.h"
#include "opt_maxmem.h"
#include "opt_msgbuf.h"
#include "opt_perfmon.h"
#include "opt_smp.h"
#include "opt_sysvipc.h"
@ -146,7 +147,7 @@ int bouncepages = 0;
#endif /* BOUNCE_BUFFERS */
int msgbufmapped = 0; /* set when safe to use msgbuf */
int _udatasel, _ucodesel;
int _udatasel, _ucodesel;
u_int atdevbase;
#if defined(SWTCH_OPTIM_STATS)
@ -1090,6 +1091,7 @@ init386(first)
unsigned biosbasemem, biosextmem;
struct gate_descriptor *gdp;
int gsel_tss;
char *cp;
struct isa_device *idp;
#ifndef SMP
@ -1503,7 +1505,7 @@ init386(first)
* calculation, etc.).
*/
while (phys_avail[pa_indx - 1] + PAGE_SIZE +
round_page(sizeof(struct msgbuf)) >= phys_avail[pa_indx]) {
round_page(MSGBUF_SIZE) >= phys_avail[pa_indx]) {
physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]);
phys_avail[pa_indx--] = 0;
phys_avail[pa_indx--] = 0;
@ -1512,16 +1514,25 @@ init386(first)
Maxmem = atop(phys_avail[pa_indx]);
/* Trim off space for the message buffer. */
phys_avail[pa_indx] -= round_page(sizeof(struct msgbuf));
phys_avail[pa_indx] -= round_page(MSGBUF_SIZE);
avail_end = phys_avail[pa_indx];
/* now running on new page tables, configured,and u/iom is accessible */
/* Map the message buffer. */
for (off = 0; off < round_page(sizeof(struct msgbuf)); off += PAGE_SIZE)
for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
pmap_enter(kernel_pmap, (vm_offset_t)msgbufp + off,
avail_end + off, VM_PROT_ALL, TRUE);
cp = (char *)msgbufp;
msgbufp = (struct msgbuf *) (cp + MSGBUF_SIZE - sizeof(*msgbufp));
if (msgbufp->msg_magic != MSG_MAGIC || msgbufp->msg_ptr != cp) {
bzero(cp, MSGBUF_SIZE);
msgbufp->msg_magic = MSG_MAGIC;
msgbufp->msg_size = (char *)msgbufp - cp;
msgbufp->msg_ptr = cp;
}
msgbufmapped = 1;
/* make a call gate to reenter kernel with */
@ -1565,7 +1576,6 @@ f00f_hack(void *unused) {
struct region_descriptor r_idt;
#endif
vm_offset_t tmp;
int i;
if (!has_f00f_bug)
return;

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* from: @(#)pmap.c 7.7 (Berkeley) 5/12/91
* $Id: pmap.c,v 1.199 1998/05/17 18:53:14 tegge Exp $
* $Id: pmap.c,v 1.200 1998/05/19 00:06:35 tegge Exp $
*/
/*
@ -70,6 +70,7 @@
#include "opt_disable_pse.h"
#include "opt_pmap.h"
#include "opt_msgbuf.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -350,7 +351,7 @@ pmap_bootstrap(firstaddr, loadaddr)
* XXX msgbufmap is not used.
*/
SYSMAP(struct msgbuf *, msgbufmap, msgbufp,
atop(round_page(sizeof(struct msgbuf))))
atop(round_page(MSGBUF_SIZE)))
#if !defined(SMP)
/*

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.430 1998/05/16 14:08:31 des Exp $
# $Id: LINT,v 1.431 1998/05/16 14:10:12 des Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -655,6 +655,9 @@ pseudo-device ccd 4 #Concatenated disk driver
pseudo-device su #scsi user
pseudo-device ssc #super scsi
# Size of the kernel message buffer. Should be N * pagesize.
options "MSGBUF_SIZE=40960"
#####################################################################
# HARDWARE DEVICE CONFIGURATION

View File

@ -1,4 +1,4 @@
# $Id: options,v 1.71 1998/04/20 03:57:21 julian Exp $
# $Id: options,v 1.72 1998/04/20 04:30:41 julian Exp $
#
# On the handling of kernel options
#
@ -227,3 +227,6 @@ VM_KMEM_SIZE_MAX opt_vm.h
# sys/netkey
KEY
KEY_DEBUG opt_key.h
# Size of the kernel message buffer
MSGBUF_SIZE opt_msgbuf.h

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.430 1998/05/16 14:08:31 des Exp $
# $Id: LINT,v 1.431 1998/05/16 14:10:12 des Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -655,6 +655,9 @@ pseudo-device ccd 4 #Concatenated disk driver
pseudo-device su #scsi user
pseudo-device ssc #super scsi
# Size of the kernel message buffer. Should be N * pagesize.
options "MSGBUF_SIZE=40960"
#####################################################################
# HARDWARE DEVICE CONFIGURATION

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.430 1998/05/16 14:08:31 des Exp $
# $Id: LINT,v 1.431 1998/05/16 14:10:12 des Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -655,6 +655,9 @@ pseudo-device ccd 4 #Concatenated disk driver
pseudo-device su #scsi user
pseudo-device ssc #super scsi
# Size of the kernel message buffer. Should be N * pagesize.
options "MSGBUF_SIZE=40960"
#####################################################################
# HARDWARE DEVICE CONFIGURATION

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.294 1998/04/06 15:46:17 peter Exp $
* $Id: machdep.c,v 1.295 1998/05/19 00:00:09 tegge Exp $
*/
#include "apm.h"
@ -44,6 +44,7 @@
#include "opt_cpu.h"
#include "opt_ddb.h"
#include "opt_maxmem.h"
#include "opt_msgbuf.h"
#include "opt_perfmon.h"
#include "opt_smp.h"
#include "opt_sysvipc.h"
@ -146,7 +147,7 @@ int bouncepages = 0;
#endif /* BOUNCE_BUFFERS */
int msgbufmapped = 0; /* set when safe to use msgbuf */
int _udatasel, _ucodesel;
int _udatasel, _ucodesel;
u_int atdevbase;
#if defined(SWTCH_OPTIM_STATS)
@ -1090,6 +1091,7 @@ init386(first)
unsigned biosbasemem, biosextmem;
struct gate_descriptor *gdp;
int gsel_tss;
char *cp;
struct isa_device *idp;
#ifndef SMP
@ -1503,7 +1505,7 @@ init386(first)
* calculation, etc.).
*/
while (phys_avail[pa_indx - 1] + PAGE_SIZE +
round_page(sizeof(struct msgbuf)) >= phys_avail[pa_indx]) {
round_page(MSGBUF_SIZE) >= phys_avail[pa_indx]) {
physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]);
phys_avail[pa_indx--] = 0;
phys_avail[pa_indx--] = 0;
@ -1512,16 +1514,25 @@ init386(first)
Maxmem = atop(phys_avail[pa_indx]);
/* Trim off space for the message buffer. */
phys_avail[pa_indx] -= round_page(sizeof(struct msgbuf));
phys_avail[pa_indx] -= round_page(MSGBUF_SIZE);
avail_end = phys_avail[pa_indx];
/* now running on new page tables, configured,and u/iom is accessible */
/* Map the message buffer. */
for (off = 0; off < round_page(sizeof(struct msgbuf)); off += PAGE_SIZE)
for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
pmap_enter(kernel_pmap, (vm_offset_t)msgbufp + off,
avail_end + off, VM_PROT_ALL, TRUE);
cp = (char *)msgbufp;
msgbufp = (struct msgbuf *) (cp + MSGBUF_SIZE - sizeof(*msgbufp));
if (msgbufp->msg_magic != MSG_MAGIC || msgbufp->msg_ptr != cp) {
bzero(cp, MSGBUF_SIZE);
msgbufp->msg_magic = MSG_MAGIC;
msgbufp->msg_size = (char *)msgbufp - cp;
msgbufp->msg_ptr = cp;
}
msgbufmapped = 1;
/* make a call gate to reenter kernel with */
@ -1565,7 +1576,6 @@ f00f_hack(void *unused) {
struct region_descriptor r_idt;
#endif
vm_offset_t tmp;
int i;
if (!has_f00f_bug)
return;

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* from: @(#)pmap.c 7.7 (Berkeley) 5/12/91
* $Id: pmap.c,v 1.199 1998/05/17 18:53:14 tegge Exp $
* $Id: pmap.c,v 1.200 1998/05/19 00:06:35 tegge Exp $
*/
/*
@ -70,6 +70,7 @@
#include "opt_disable_pse.h"
#include "opt_pmap.h"
#include "opt_msgbuf.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -350,7 +351,7 @@ pmap_bootstrap(firstaddr, loadaddr)
* XXX msgbufmap is not used.
*/
SYSMAP(struct msgbuf *, msgbufmap, msgbufp,
atop(round_page(sizeof(struct msgbuf))))
atop(round_page(MSGBUF_SIZE)))
#if !defined(SMP)
/*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)subr_log.c 8.1 (Berkeley) 6/10/93
* $Id: subr_log.c,v 1.26 1998/01/24 02:54:34 eivind Exp $
* $Id: subr_log.c,v 1.27 1998/02/20 13:46:56 bde Exp $
*/
/*
@ -39,6 +39,7 @@
*/
#include "opt_devfs.h"
#include "opt_msgbuf.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -138,16 +139,16 @@ logread(dev, uio, flag)
while (uio->uio_resid > 0) {
l = mbp->msg_bufx - mbp->msg_bufr;
if (l < 0)
l = MSG_BSIZE - mbp->msg_bufr;
l = mbp->msg_size - mbp->msg_bufr;
l = min(l, uio->uio_resid);
if (l == 0)
break;
error = uiomove((caddr_t)&mbp->msg_bufc[mbp->msg_bufr],
(int)l, uio);
error = uiomove((caddr_t)msgbufp->msg_ptr + mbp->msg_bufr,
(int)l, uio);
if (error)
break;
mbp->msg_bufr += l;
if (mbp->msg_bufr >= MSG_BSIZE)
if (mbp->msg_bufr >= mbp->msg_size)
mbp->msg_bufr = 0;
}
return (error);
@ -215,7 +216,7 @@ logioctl(dev, com, data, flag, p)
l = msgbufp->msg_bufx - msgbufp->msg_bufr;
splx(s);
if (l < 0)
l += MSG_BSIZE;
l += msgbufp->msg_size;
*(int *)data = l;
break;

View File

@ -36,9 +36,11 @@
* SUCH DAMAGE.
*
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
* $Id: subr_prf.c,v 1.43 1997/10/12 20:23:58 phk Exp $
* $Id: subr_prf.c,v 1.44 1997/12/28 05:03:33 bde Exp $
*/
#include "opt_msgbuf.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/msgbuf.h>
@ -586,18 +588,12 @@ msglogchar(int c, void *dummyarg)
if (c != '\0' && c != '\r' && c != 0177 && msgbufmapped) {
mbp = msgbufp;
if (mbp->msg_magic != MSG_MAGIC ||
mbp->msg_bufx >= MSG_BSIZE ||
mbp->msg_bufr >= MSG_BSIZE) {
bzero(mbp, sizeof(struct msgbuf));
mbp->msg_magic = MSG_MAGIC;
}
mbp->msg_bufc[mbp->msg_bufx++] = c;
if (mbp->msg_bufx >= MSG_BSIZE)
mbp->msg_ptr[mbp->msg_bufx++] = c;
if (mbp->msg_bufx >= mbp->msg_size)
mbp->msg_bufx = 0;
/* If the buffer is full, keep the most recent data. */
if (mbp->msg_bufr == mbp->msg_bufx) {
if (++mbp->msg_bufr >= MSG_BSIZE)
if (++mbp->msg_bufr >= mbp->msg_size)
mbp->msg_bufr = 0;
}
}

View File

@ -31,19 +31,23 @@
* SUCH DAMAGE.
*
* @(#)msgbuf.h 8.1 (Berkeley) 6/2/93
* $Id$
* $Id: msgbuf.h,v 1.9 1997/02/22 09:45:37 peter Exp $
*/
#ifndef _SYS_MSGBUF_H_
#define _SYS_MSGBUF_H_
#define MSG_BSIZE (8192 - 3 * sizeof(unsigned int))
#if defined(KERNEL) && !defined(MSGBUF_SIZE)
#define MSGBUF_SIZE 8192
#endif
struct msgbuf {
#define MSG_MAGIC 0x063061
#define MSG_MAGIC 0x063062
unsigned int msg_magic;
unsigned int msg_size; /* MSG_BSIZE */
unsigned int msg_bufx; /* write pointer */
unsigned int msg_bufr; /* read pointer */
char msg_bufc[MSG_BSIZE]; /* buffer */
char * msg_ptr; /* pointer to buffer */
};
#ifdef KERNEL
extern int msgbufmapped;