Add sysctl parameters to query the CPU and i/o bus frequency:
machdep.cpu_khz and machdep.bus_khz. Fix bug in machdep.console_device parameter.
This commit is contained in:
@@ -108,7 +108,6 @@ main()
|
|||||||
startup();
|
startup();
|
||||||
printf ("\n%s", version);
|
printf ("\n%s", version);
|
||||||
kconfig();
|
kconfig();
|
||||||
cnidentify();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up system process 0 (swapper).
|
* Set up system process 0 (swapper).
|
||||||
|
|||||||
@@ -14,49 +14,48 @@
|
|||||||
#include <machine/uart.h>
|
#include <machine/uart.h>
|
||||||
#include <machine/usb_uart.h>
|
#include <machine/usb_uart.h>
|
||||||
|
|
||||||
dev_t console_device = -1;
|
|
||||||
|
|
||||||
struct tty cnttys [1];
|
struct tty cnttys [1];
|
||||||
|
|
||||||
void cninit()
|
int cnopen(dev_t cn, int flag, int mode)
|
||||||
{
|
{
|
||||||
console_device = makedev(CONS_MAJOR, CONS_MINOR);
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
|
|
||||||
|
return cdevsw[CONS_MAJOR].d_open(dev, flag, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cnidentify()
|
int cnclose (dev_t cn, int flag, int mode)
|
||||||
{
|
{
|
||||||
//printf ("console: %s (%d,%d)\n", cdevname(console_device),
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
// CONS_MAJOR, CONS_MINOR);
|
|
||||||
|
return cdevsw[CONS_MAJOR].d_close(dev, flag, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cnopen(dev_t dev, int flag, int mode)
|
int cnread(dev_t cn, struct uio *uio, int flag)
|
||||||
{
|
{
|
||||||
return cdevsw[CONS_MAJOR].d_open(console_device, flag, mode);
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
|
|
||||||
|
return cdevsw[CONS_MAJOR].d_read(dev, uio, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cnclose (dev_t dev, int flag, int mode)
|
int cnwrite(dev_t cn, struct uio *uio, int flag)
|
||||||
{
|
{
|
||||||
return cdevsw[CONS_MAJOR].d_close(console_device, flag, mode);
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
|
|
||||||
|
return cdevsw[CONS_MAJOR].d_write(dev, uio, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cnread(dev_t dev,register struct uio *uio, int flag)
|
int cnselect(dev_t cn, int rw)
|
||||||
{
|
{
|
||||||
return cdevsw[CONS_MAJOR].d_read(console_device, uio, flag);
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
|
|
||||||
|
return cdevsw[CONS_MAJOR].d_select(dev, rw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cnwrite(dev_t dev,register struct uio *uio, int flag)
|
int cnioctl(dev_t cn, u_int cmd, caddr_t addr, int flag)
|
||||||
{
|
{
|
||||||
return cdevsw[CONS_MAJOR].d_write(console_device, uio, flag);
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
}
|
|
||||||
|
|
||||||
int cnselect(dev_t dev, int rw)
|
return cdevsw[CONS_MAJOR].d_ioctl(dev, cmd, addr, flag);
|
||||||
{
|
|
||||||
return cdevsw[CONS_MAJOR].d_select(console_device, rw);
|
|
||||||
}
|
|
||||||
|
|
||||||
int cnioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag)
|
|
||||||
{
|
|
||||||
return cdevsw[CONS_MAJOR].d_ioctl(console_device, cmd, addr, flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -65,7 +64,9 @@ int cnioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag)
|
|||||||
void cnputc(char c)
|
void cnputc(char c)
|
||||||
{
|
{
|
||||||
if (cdevsw[CONS_MAJOR].r_write) {
|
if (cdevsw[CONS_MAJOR].r_write) {
|
||||||
cdevsw[CONS_MAJOR].r_write(console_device, c);
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
|
|
||||||
|
cdevsw[CONS_MAJOR].r_write(dev, c);
|
||||||
} else {
|
} else {
|
||||||
putc(c, &cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR].t_outq);
|
putc(c, &cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR].t_outq);
|
||||||
ttstart(&cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR]);
|
ttstart(&cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR]);
|
||||||
@@ -78,10 +79,12 @@ void cnputc(char c)
|
|||||||
/*
|
/*
|
||||||
* Receive a symbol from console terminal.
|
* Receive a symbol from console terminal.
|
||||||
*/
|
*/
|
||||||
int cngetc ()
|
int cngetc()
|
||||||
{
|
{
|
||||||
if (cdevsw[CONS_MAJOR].r_read) {
|
if (cdevsw[CONS_MAJOR].r_read) {
|
||||||
return cdevsw[CONS_MAJOR].r_read(console_device);
|
dev_t dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
|
|
||||||
|
return cdevsw[CONS_MAJOR].r_read(dev);
|
||||||
} else {
|
} else {
|
||||||
return getc(&cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR].t_rawq);
|
return getc(&cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR].t_rawq);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
#define CPU_TIMO_WAIT_WDONE 10
|
#define CPU_TIMO_WAIT_WDONE 10
|
||||||
#define CPU_TIMO_WAIT_WSTOP 11
|
#define CPU_TIMO_WAIT_WSTOP 11
|
||||||
#define CPU_TIMO_WAIT_WIDLE 12
|
#define CPU_TIMO_WAIT_WIDLE 12
|
||||||
#define CPU_MAXID 13 /* number of valid machdep ids */
|
#define CPU_FREQ_KHZ 13 /* processor clock in kHz */
|
||||||
|
#define CPU_BUS_KHZ 14 /* i/o bus clock in kHz */
|
||||||
|
#define CPU_MAXID 15 /* number of valid machdep ids */
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
#define CTL_MACHDEP_NAMES { \
|
#define CTL_MACHDEP_NAMES { \
|
||||||
@@ -36,5 +38,7 @@
|
|||||||
{ "sd_timeout_wait_wdone", CTLTYPE_INT }, \
|
{ "sd_timeout_wait_wdone", CTLTYPE_INT }, \
|
||||||
{ "sd_timeout_wait_wstop", CTLTYPE_INT }, \
|
{ "sd_timeout_wait_wstop", CTLTYPE_INT }, \
|
||||||
{ "sd_timeout_wait_widle", CTLTYPE_INT }, \
|
{ "sd_timeout_wait_widle", CTLTYPE_INT }, \
|
||||||
|
{ "cpu_khz", CTLTYPE_INT }, \
|
||||||
|
{ "bus_khz", CTLTYPE_INT }, \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -404,10 +404,6 @@ startup()
|
|||||||
#if CONS_MAJOR == UARTUSB_MAJOR
|
#if CONS_MAJOR == UARTUSB_MAJOR
|
||||||
usbinit();
|
usbinit();
|
||||||
#endif
|
#endif
|
||||||
#if CONS_MAJOR == HXTFT_MAJOR
|
|
||||||
hx8357_init();
|
|
||||||
#endif
|
|
||||||
cninit();
|
|
||||||
|
|
||||||
/* Get total RAM size. */
|
/* Get total RAM size. */
|
||||||
physmem = BMXDRMSZ;
|
physmem = BMXDRMSZ;
|
||||||
|
|||||||
@@ -290,14 +290,15 @@ cpu_sysctl (name, namelen, oldp, oldlenp, newp, newlen)
|
|||||||
void *newp;
|
void *newp;
|
||||||
size_t newlen;
|
size_t newlen;
|
||||||
{
|
{
|
||||||
int i;
|
int i, khz;
|
||||||
|
dev_t dev;
|
||||||
|
|
||||||
switch (name[0]) {
|
switch (name[0]) {
|
||||||
case CPU_CONSDEV:
|
case CPU_CONSDEV:
|
||||||
if (namelen != 1)
|
if (namelen != 1)
|
||||||
return ENOTDIR;
|
return ENOTDIR;
|
||||||
return sysctl_rdstruct (oldp, oldlenp, newp,
|
dev = makedev(CONS_MAJOR, CONS_MINOR);
|
||||||
&cnttys[0].t_dev, sizeof &cnttys[0].t_dev);
|
return sysctl_rdstruct (oldp, oldlenp, newp, &dev, sizeof dev);
|
||||||
#if NTMSCP > 0
|
#if NTMSCP > 0
|
||||||
case CPU_TMSCP:
|
case CPU_TMSCP:
|
||||||
/* All sysctl names at this level are terminal */
|
/* All sysctl names at this level are terminal */
|
||||||
@@ -356,6 +357,17 @@ cpu_sysctl (name, namelen, oldp, oldlenp, newp, newlen)
|
|||||||
case CPU_TIMO_WAIT_WIDLE:
|
case CPU_TIMO_WAIT_WIDLE:
|
||||||
return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_wait_widle);
|
return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_wait_widle);
|
||||||
|
|
||||||
|
case CPU_FREQ_KHZ:
|
||||||
|
if (namelen != 1)
|
||||||
|
return ENOTDIR;
|
||||||
|
khz = CPU_KHZ;
|
||||||
|
return sysctl_rdstruct (oldp, oldlenp, newp, &khz, sizeof khz);
|
||||||
|
case CPU_BUS_KHZ:
|
||||||
|
if (namelen != 1)
|
||||||
|
return ENOTDIR;
|
||||||
|
khz = BUS_KHZ;
|
||||||
|
return sysctl_rdstruct (oldp, oldlenp, newp, &khz, sizeof khz);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return EOPNOTSUPP;
|
return EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user