diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-02-27 21:55:26 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-02-27 21:55:26 +0000 |
commit | 557d3a6946bfaeb2b2953ca55428fd9971d8d3ba (patch) | |
tree | 0e489b87ca0a680118201067b6c5687fee111973 /sys/arch | |
parent | b6fe3e00faa5704466adb0b5bb55028925063e86 (diff) |
put a bit more flesh in the sysctl machdep; parts from tom
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 79 | ||||
-rw-r--r-- | sys/arch/amd64/include/biosvar.h | 3 |
2 files changed, 76 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 1fce061fbb2..1f59ad3d2e5 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.13 2004/02/27 17:41:25 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.14 2004/02/27 21:55:25 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -563,6 +563,72 @@ x86_64_init_pcb_tss_ldt(ci) ci->ci_idle_tss_sel = tss_alloc(pcb); } +bios_diskinfo_t * +bios_getdiskinfo(dev) + dev_t dev; +{ + bios_diskinfo_t *pdi; + + if (bios_diskinfo == NULL) + return NULL; + + for (pdi = bios_diskinfo; pdi->bios_number != -1; pdi++) { + if ((dev & B_MAGICMASK) == B_DEVMAGIC) { /* search by bootdev */ + if (pdi->bsd_dev == dev) + break; + } else { + if (pdi->bios_number == dev) + break; + } + } + + if (pdi->bios_number == -1) + return NULL; + else + return pdi; +} + +int +bios_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) + int *name; + u_int namelen; + void *oldp; + size_t *oldlenp; + void *newp; + size_t newlen; + struct proc *p; +{ + bios_diskinfo_t *pdi; + extern dev_t bootdev; + int biosdev; + + /* all sysctl names at this level except diskinfo are terminal */ + if (namelen != 1 && name[0] != BIOS_DISKINFO) + return (ENOTDIR); /* overloaded */ + + if (!(bootapiver & BAPIV_VECTOR)) + return EOPNOTSUPP; + + switch (name[0]) { + case BIOS_DEV: + if ((pdi = bios_getdiskinfo(bootdev)) == NULL) + return ENXIO; + biosdev = pdi->bios_number; + return sysctl_rdint(oldp, oldlenp, newp, biosdev); + case BIOS_DISKINFO: + if (namelen != 2) + return ENOTDIR; + if ((pdi = bios_getdiskinfo(name[1])) == NULL) + return ENXIO; + return sysctl_rdstruct(oldp, oldlenp, newp, pdi, sizeof(*pdi)); + case BIOS_CKSUMLEN: + return sysctl_rdint(oldp, oldlenp, newp, bios_cksumlen); + default: + return EOPNOTSUPP; + } + /* NOTREACHED */ +} + /* * machine dependent system variables. */ @@ -579,12 +645,10 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) dev_t consdev; dev_t dev; - /* all sysctl names at this level are terminal */ - if (namelen != 1) - return (ENOTDIR); /* overloaded */ - switch (name[0]) { case CPU_CONSDEV: + if (namelen != 1) + return (ENOTDIR); /* overloaded */ if (cn_tab != NULL) consdev = cn_tab->cn_dev; else @@ -596,7 +660,12 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) return (ENOTDIR); /* overloaded */ dev = chrtoblk((dev_t)name[1]); return sysctl_rdstruct(oldp, oldlenp, newp, &dev, sizeof(dev)); + case CPU_BIOS: + return bios_sysctl(name + 1, namelen - 1, oldp, oldlenp, + newp, newlen, p); case CPU_ALLOWAPERTURE: + if (namelen != 1) + return (ENOTDIR); /* overloaded */ #ifdef APERTURE if (securelevel > 0) return (sysctl_rdint(oldp, oldlenp, newp, diff --git a/sys/arch/amd64/include/biosvar.h b/sys/arch/amd64/include/biosvar.h index ff959054c5d..b9261e27297 100644 --- a/sys/arch/amd64/include/biosvar.h +++ b/sys/arch/amd64/include/biosvar.h @@ -1,5 +1,5 @@ /* XXX - DSR */ -/* $OpenBSD: biosvar.h,v 1.2 2004/02/03 12:09:47 mickey Exp $ */ +/* $OpenBSD: biosvar.h,v 1.3 2004/02/27 21:55:25 deraadt Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -244,6 +244,7 @@ void bioscnputc(dev_t, int); int bioscngetc(dev_t); void bioscnpollc(dev_t, int); void bios_getopt(void); +bios_diskinfo_t *bios_getdiskinfo(dev_t); /* bios32.c */ int bios32_service(u_int32_t, bios32_entry_t, bios32_entry_info_t); |