diff options
author | peter <peter@FreeBSD.org> | 2007-10-26 03:23:54 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2007-10-26 03:23:54 +0000 |
commit | 9c4d4d9a16e6f080b2248887812143e7cc0abf3f (patch) | |
tree | f39a0a61a976bda4b6ff5fcbced8330ff0a6dc72 /sys/amd64 | |
parent | 6349ab663a1b206161fc89983f0be884809286f7 (diff) | |
download | FreeBSD-src-9c4d4d9a16e6f080b2248887812143e7cc0abf3f.zip FreeBSD-src-9c4d4d9a16e6f080b2248887812143e7cc0abf3f.tar.gz |
Split /dev/nvram driver out of isa/clock.c for i386 and amd64. I have not
refactored it to be a generic device.
Instead of being part of the standard kernel, there is now a 'nvram' device
for i386/amd64. It is in DEFAULTS like io and mem, and can be turned off
with 'nodevice nvram'. This matches the previous behavior when it was
first committed.
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/conf/DEFAULTS | 1 | ||||
-rw-r--r-- | sys/amd64/include/clock.h | 3 | ||||
-rw-r--r-- | sys/amd64/isa/clock.c | 97 |
3 files changed, 4 insertions, 97 deletions
diff --git a/sys/amd64/conf/DEFAULTS b/sys/amd64/conf/DEFAULTS index e98b169..519198c 100644 --- a/sys/amd64/conf/DEFAULTS +++ b/sys/amd64/conf/DEFAULTS @@ -11,6 +11,7 @@ device isa # Pseudo devices. device mem # Memory and kernel memory devices device io # I/O device +device nvram # Access to rtc cmos via /dev/nvram # UART chips on this platform device uart_ns8250 diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h index 30c2f26..9a6876e 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 0e5c8fc..2809828 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 */ |