summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2007-10-29 22:26:36 +0000
committerPeter Wemm <peter@FreeBSD.org>2007-10-29 22:26:36 +0000
commit2e74d23f34315847e650a76eebda1ec2685bab2e (patch)
tree4de0a54901f3ff358401e07156b1712471d83f81
parent14aa857adf47ab7364e1c4eda9e0b4d00306f800 (diff)
Notes
-rw-r--r--sys/amd64/conf/NOTES3
-rw-r--r--sys/amd64/include/clock.h3
-rw-r--r--sys/amd64/isa/clock.c97
-rw-r--r--sys/conf/files.amd641
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/i386/conf/NOTES3
-rw-r--r--sys/i386/include/clock.h3
-rw-r--r--sys/i386/isa/clock.c97
-rw-r--r--sys/modules/Makefile6
9 files changed, 18 insertions, 196 deletions
diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index f0208d933d43..207fa07e037e 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -97,6 +97,9 @@ options CLK_CALIBRATION_LOOP
# clock to actually be used.
options CLK_USE_I8254_CALIBRATION
+# Provide read/write access to the memory in the clock chip.
+device nvram # Access to rtc cmos via /dev/nvram
+
#####################################################################
# MISCELLANEOUS DEVICES AND OPTIONS
diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h
index 30c2f26ec7c6..9a6876e9e8df 100644
--- a/sys/amd64/include/clock.h
+++ b/sys/amd64/include/clock.h
@@ -31,7 +31,8 @@ void i8254_init(void);
int acquire_timer2(int mode);
int release_timer2(void);
-int rtcin(int val);
+int rtcin(int reg);
+void writertc(int reg, unsigned char val);
int sysbeep(int pitch, int period);
void init_TSC(void);
void init_TSC_tc(void);
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c
index 0e5c8fcb73c8..2809828150be 100644
--- a/sys/amd64/isa/clock.c
+++ b/sys/amd64/isa/clock.c
@@ -433,7 +433,7 @@ rtcin(reg)
return (val);
}
-static void
+void
writertc(int reg, u_char val)
{
@@ -934,99 +934,4 @@ static devclass_t attimer_devclass;
DRIVER_MODULE(attimer, isa, attimer_driver, attimer_devclass, 0, 0);
DRIVER_MODULE(attimer, acpi, attimer_driver, attimer_devclass, 0, 0);
-/*
- * Linux-style /dev/nvram driver
- *
- * cmos ram starts at bytes 14 through 128, for a total of 114 bytes.
- * bytes 16 through 31 are checksummed at byte 32.
- * Unlike Linux, you have to take care of the checksums yourself.
- * The driver exposes byte 14 as file offset 0.
- */
-
-#define NVRAM_FIRST RTC_DIAG /* 14 */
-#define NVRAM_LAST 128
-
-static d_open_t nvram_open;
-static d_read_t nvram_read;
-static d_write_t nvram_write;
-
-static struct cdev *nvram_dev;
-
-static struct cdevsw nvram_cdevsw = {
- .d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
- .d_open = nvram_open,
- .d_read = nvram_read,
- .d_write = nvram_write,
- .d_name = "nvram",
-};
-
-static int
-nvram_open(struct cdev *dev __unused, int flags, int fmt __unused,
- struct thread *td)
-{
- int error = 0;
-
- if (flags & FWRITE)
- error = securelevel_gt(td->td_ucred, 0);
-
- return (error);
-}
-
-static int
-nvram_read(struct cdev *dev, struct uio *uio, int flags)
-{
- int nv_off;
- u_char v;
- int error = 0;
-
- while (uio->uio_resid > 0 && error == 0) {
- nv_off = uio->uio_offset + NVRAM_FIRST;
- if (nv_off < NVRAM_FIRST || nv_off >= NVRAM_LAST)
- return (0); /* Signal EOF */
- /* Single byte at a time */
- v = rtcin(nv_off);
- error = uiomove(&v, 1, uio);
- }
- return (error);
-
-}
-
-static int
-nvram_write(struct cdev *dev, struct uio *uio, int flags)
-{
- int nv_off;
- u_char v;
- int error = 0;
-
- while (uio->uio_resid > 0 && error == 0) {
- nv_off = uio->uio_offset + NVRAM_FIRST;
- if (nv_off < NVRAM_FIRST || nv_off >= NVRAM_LAST)
- return (0); /* Signal EOF */
- /* Single byte at a time */
- error = uiomove(&v, 1, uio);
- writertc(nv_off, v);
- }
- return (error);
-}
-
-static int
-nvram_modevent(module_t mod __unused, int type, void *data __unused)
-{
- switch (type) {
- case MOD_LOAD:
- nvram_dev = make_dev(&nvram_cdevsw, 0,
- UID_ROOT, GID_KMEM, 0640, "nvram");
- break;
- case MOD_UNLOAD:
- case MOD_SHUTDOWN:
- destroy_dev(nvram_dev);
- break;
- default:
- return (EOPNOTSUPP);
- }
- return (0);
-}
-DEV_MODULE(nvram, nvram_modevent, NULL);
-
#endif /* DEV_ISA */
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 2a9a60adad54..8f107e74f7e2 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -185,6 +185,7 @@ dev/kbd/kbd.c optional atkbd | sc | ukbd
dev/mem/memutil.c optional mem
dev/nfe/if_nfe.c optional nfe pci
dev/nve/if_nve.c optional nve pci
+dev/nvram/nvram.c optional nvram isa
dev/rr232x/os_bsd.c optional rr232x
dev/rr232x/osm_bsd.c optional rr232x
dev/rr232x/rr232x_config.c optional rr232x
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index fc477980caaa..7cfd54179da1 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -211,6 +211,7 @@ dev/mse/mse.c optional mse
dev/mse/mse_isa.c optional mse isa
dev/nfe/if_nfe.c optional nfe pci
dev/nve/if_nve.c optional nve pci
+dev/nvram/nvram.c optional nvram isa
dev/pcf/pcf_isa.c optional pcf
dev/random/nehemiah.c optional random
dev/rr232x/os_bsd.c optional rr232x
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index 10c99f33c5ba..f73add963c58 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -268,6 +268,9 @@ options CLK_CALIBRATION_LOOP
# clock to actually be used.
options CLK_USE_I8254_CALIBRATION
+# Provide read/write access to the memory in the clock chip.
+device nvram # Access to rtc cmos via /dev/nvram
+
#####################################################################
# MISCELLANEOUS DEVICES AND OPTIONS
diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h
index a91b25248735..9bdd421bf186 100644
--- a/sys/i386/include/clock.h
+++ b/sys/i386/include/clock.h
@@ -31,7 +31,8 @@ void i8254_init(void);
int acquire_timer2(int mode);
int release_timer2(void);
-int rtcin(int val);
+int rtcin(int reg);
+void writertc(int reg, unsigned char val);
int sysbeep(int pitch, int period);
void timer_restore(void);
void init_TSC(void);
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c
index 4b848c4e20a4..a67db3173a5b 100644
--- a/sys/i386/isa/clock.c
+++ b/sys/i386/isa/clock.c
@@ -438,7 +438,7 @@ rtcin(reg)
return (val);
}
-static void
+void
writertc(int reg, u_char val)
{
@@ -938,99 +938,4 @@ static devclass_t attimer_devclass;
DRIVER_MODULE(attimer, isa, attimer_driver, attimer_devclass, 0, 0);
DRIVER_MODULE(attimer, acpi, attimer_driver, attimer_devclass, 0, 0);
-/*
- * Linux-style /dev/nvram driver
- *
- * cmos ram starts at bytes 14 through 128, for a total of 114 bytes.
- * bytes 16 through 31 are checksummed at byte 32.
- * Unlike Linux, you have to take care of the checksums yourself.
- * The driver exposes byte 14 as file offset 0.
- */
-
-#define NVRAM_FIRST RTC_DIAG /* 14 */
-#define NVRAM_LAST 128
-
-static d_open_t nvram_open;
-static d_read_t nvram_read;
-static d_write_t nvram_write;
-
-static struct cdev *nvram_dev;
-
-static struct cdevsw nvram_cdevsw = {
- .d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
- .d_open = nvram_open,
- .d_read = nvram_read,
- .d_write = nvram_write,
- .d_name = "nvram",
-};
-
-static int
-nvram_open(struct cdev *dev __unused, int flags, int fmt __unused,
- struct thread *td)
-{
- int error = 0;
-
- if (flags & FWRITE)
- error = securelevel_gt(td->td_ucred, 0);
-
- return (error);
-}
-
-static int
-nvram_read(struct cdev *dev, struct uio *uio, int flags)
-{
- int nv_off;
- u_char v;
- int error = 0;
-
- while (uio->uio_resid > 0 && error == 0) {
- nv_off = uio->uio_offset + NVRAM_FIRST;
- if (nv_off < NVRAM_FIRST || nv_off >= NVRAM_LAST)
- return (0); /* Signal EOF */
- /* Single byte at a time */
- v = rtcin(nv_off);
- error = uiomove(&v, 1, uio);
- }
- return (error);
-
-}
-
-static int
-nvram_write(struct cdev *dev, struct uio *uio, int flags)
-{
- int nv_off;
- u_char v;
- int error = 0;
-
- while (uio->uio_resid > 0 && error == 0) {
- nv_off = uio->uio_offset + NVRAM_FIRST;
- if (nv_off < NVRAM_FIRST || nv_off >= NVRAM_LAST)
- return (0); /* Signal EOF */
- /* Single byte at a time */
- error = uiomove(&v, 1, uio);
- writertc(nv_off, v);
- }
- return (error);
-}
-
-static int
-nvram_modevent(module_t mod __unused, int type, void *data __unused)
-{
- switch (type) {
- case MOD_LOAD:
- nvram_dev = make_dev(&nvram_cdevsw, 0,
- UID_ROOT, GID_KMEM, 0640, "nvram");
- break;
- case MOD_UNLOAD:
- case MOD_SHUTDOWN:
- destroy_dev(nvram_dev);
- break;
- default:
- return (EOPNOTSUPP);
- }
- return (0);
-}
-DEV_MODULE(nvram, nvram_modevent, NULL);
-
#endif /* DEV_ISA */
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 4c471670be6d..5e304c05c829 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -189,6 +189,7 @@ SUBDIR= ${_3dfx} \
${_nxge} \
nullfs \
${_nve} \
+ ${_nvram} \
${_nwfs} \
${_oltr} \
${_padlock} \
@@ -202,7 +203,6 @@ SUBDIR= ${_3dfx} \
plip \
${_pmc} \
portalfs \
- ${_powermac_nvram} \
ppbus \
ppc \
ppi \
@@ -399,6 +399,7 @@ _mse= mse
_ncp= ncp
.endif
_ncv= ncv
+_nvram= nvram
_ndis= ndis
_nsp= nsp
.if ${MK_NCP} != "no"
@@ -519,6 +520,7 @@ _mly= mly
_ndis= ndis
_nfe= nfe
_nve= nve
+_nvram= nvram
_nxge= nxge
_pccard= pccard
_rr232x= rr232x
@@ -579,7 +581,7 @@ _ath_hal= ath_hal
_ath_rate_amrr= ath_rate_amrr
_ath_rate_onoe= ath_rate_onoe
_ath_rate_sample=ath_rate_sample
-_powermac_nvram= powermac_nvram
+_nvram= powermac_nvram
_smbfs= smbfs
.endif