Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79772
b: refs/heads/master
c: fe599f9
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Gleixner authored and Ingo Molnar committed Jan 30, 2008
1 parent e040355 commit 52c7593
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 118 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6ce60b07e670e800c4c5cfe984ed5188e7a64135
refs/heads/master: fe599f9fbc5d470ec5b55d08f2bbb991ddecbbc8
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/Makefile_32
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CPPFLAGS_vmlinux.lds += -Ui386
obj-y := process_32.o signal_32.o entry_32.o traps_32.o irq_32.o \
ptrace_32.o time_32.o ioport_32.o ldt.o setup_32.o i8259_32.o sys_i386_32.o \
pci-dma_32.o i386_ksyms_32.o i387_32.o bootflag.o e820_32.o\
quirks.o i8237.o topology.o alternative.o i8253.o tsc_32.o io_delay.o
quirks.o i8237.o topology.o alternative.o i8253.o tsc_32.o io_delay.o rtc.o

obj-$(CONFIG_STACKTRACE) += stacktrace.o
obj-y += cpu/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
/*
* include/asm-i386/mach-default/mach_time.h
*
* Machine specific set RTC function for generic.
* Split out from time.c by Osamu Tomita <tomita@cinet.co.jp>
* RTC related functions
*/
#ifndef _MACH_TIME_H
#define _MACH_TIME_H

#include <linux/bcd.h>
#include <linux/mc146818rtc.h>

/* for check timing call set_rtc_mmss() 500ms */
/* used in arch/i386/time.c::do_timer_interrupt() */
#define USEC_AFTER 500000
#define USEC_BEFORE 500000
#include <asm/time.h>

/*
* In order to set the CMOS clock precisely, set_rtc_mmss has to be
Expand All @@ -24,7 +16,7 @@
* BUG: This routine does not handle hour overflow properly; it just
* sets the minutes. Usually you'll only notice that after reboot!
*/
static inline int mach_set_rtc_mmss(unsigned long nowtime)
int mach_set_rtc_mmss(unsigned long nowtime)
{
int retval = 0;
int real_seconds, real_minutes, cmos_minutes;
Expand Down Expand Up @@ -79,7 +71,7 @@ static inline int mach_set_rtc_mmss(unsigned long nowtime)
return retval;
}

static inline unsigned long mach_get_cmos_time(void)
unsigned long mach_get_cmos_time(void)
{
unsigned int year, mon, day, hour, min, sec;

Expand Down Expand Up @@ -108,4 +100,67 @@ static inline unsigned long mach_get_cmos_time(void)
return mktime(year, mon, day, hour, min, sec);
}

#endif /* !_MACH_TIME_H */
DEFINE_SPINLOCK(rtc_lock);
EXPORT_SYMBOL(rtc_lock);

/*
* This is a special lock that is owned by the CPU and holds the index
* register we are working with. It is required for NMI access to the
* CMOS/RTC registers. See include/asm-i386/mc146818rtc.h for details.
*/
volatile unsigned long cmos_lock = 0;
EXPORT_SYMBOL(cmos_lock);

/* Routines for accessing the CMOS RAM/RTC. */
unsigned char rtc_cmos_read(unsigned char addr)
{
unsigned char val;

lock_cmos_prefix(addr);
outb_p(addr, RTC_PORT(0));
val = inb_p(RTC_PORT(1));
lock_cmos_suffix(addr);
return val;
}
EXPORT_SYMBOL(rtc_cmos_read);

void rtc_cmos_write(unsigned char val, unsigned char addr)
{
lock_cmos_prefix(addr);
outb_p(addr, RTC_PORT(0));
outb_p(val, RTC_PORT(1));
lock_cmos_suffix(addr);
}
EXPORT_SYMBOL(rtc_cmos_write);

static int set_rtc_mmss(unsigned long nowtime)
{
int retval;
unsigned long flags;

/* gets recalled with irq locally disabled */
/* XXX - does irqsave resolve this? -johnstul */
spin_lock_irqsave(&rtc_lock, flags);
retval = set_wallclock(nowtime);
spin_unlock_irqrestore(&rtc_lock, flags);

return retval;
}

/* not static: needed by APM */
unsigned long read_persistent_clock(void)
{
unsigned long retval;
unsigned long flags;

spin_lock_irqsave(&rtc_lock, flags);
retval = get_wallclock();
spin_unlock_irqrestore(&rtc_lock, flags);

return retval;
}

int update_persistent_clock(struct timespec now)
{
return set_rtc_mmss(now.tv_sec);
}
105 changes: 4 additions & 101 deletions trunk/arch/x86/kernel/time_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,98 +28,21 @@
* serialize accesses to xtime/lost_ticks).
*/

#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/param.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/smp.h>
#include <linux/module.h>
#include <linux/sysdev.h>
#include <linux/bcd.h>
#include <linux/efi.h>
#include <linux/mca.h>

#include <asm/io.h>
#include <asm/smp.h>
#include <asm/irq.h>
#include <asm/msr.h>
#include <asm/delay.h>
#include <asm/mpspec.h>
#include <asm/uaccess.h>
#include <asm/processor.h>
#include <asm/timer.h>
#include <asm/time.h>

#include "mach_time.h"

#include <linux/timex.h>

#include <asm/hpet.h>

#include <asm/arch_hooks.h>
#include <asm/hpet.h>
#include <asm/time.h>

#include "io_ports.h"

#include <asm/i8259.h>

#include "do_timer.h"

unsigned int cpu_khz; /* Detected as we calibrate the TSC */
EXPORT_SYMBOL(cpu_khz);

DEFINE_SPINLOCK(rtc_lock);
EXPORT_SYMBOL(rtc_lock);

/*
* This is a special lock that is owned by the CPU and holds the index
* register we are working with. It is required for NMI access to the
* CMOS/RTC registers. See include/asm-i386/mc146818rtc.h for details.
*/
volatile unsigned long cmos_lock = 0;
EXPORT_SYMBOL(cmos_lock);

/* Routines for accessing the CMOS RAM/RTC. */
unsigned char rtc_cmos_read(unsigned char addr)
{
unsigned char val;
lock_cmos_prefix(addr);
outb_p(addr, RTC_PORT(0));
val = inb_p(RTC_PORT(1));
lock_cmos_suffix(addr);
return val;
}
EXPORT_SYMBOL(rtc_cmos_read);

void rtc_cmos_write(unsigned char val, unsigned char addr)
{
lock_cmos_prefix(addr);
outb_p(addr, RTC_PORT(0));
outb_p(val, RTC_PORT(1));
lock_cmos_suffix(addr);
}
EXPORT_SYMBOL(rtc_cmos_write);

static int set_rtc_mmss(unsigned long nowtime)
{
int retval;
unsigned long flags;

/* gets recalled with irq locally disabled */
/* XXX - does irqsave resolve this? -johnstul */
spin_lock_irqsave(&rtc_lock, flags);
retval = set_wallclock(nowtime);
spin_unlock_irqrestore(&rtc_lock, flags);

return retval;
}


int timer_ack;

unsigned long profile_pc(struct pt_regs *regs)
Expand All @@ -137,7 +60,7 @@ unsigned long profile_pc(struct pt_regs *regs)
/* Return address is either directly at stack pointer
or above a saved eflags. Eflags has bits 22-31 zero,
kernel addresses don't. */
if (sp[0] >> 22)
if (sp[0] >> 22)
return sp[0];
if (sp[1] >> 22)
return sp[1];
Expand Down Expand Up @@ -193,26 +116,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}

/* not static: needed by APM */
unsigned long read_persistent_clock(void)
{
unsigned long retval;
unsigned long flags;

spin_lock_irqsave(&rtc_lock, flags);

retval = get_wallclock();

spin_unlock_irqrestore(&rtc_lock, flags);

return retval;
}

int update_persistent_clock(struct timespec now)
{
return set_rtc_mmss(now.tv_sec);
}

extern void (*late_time_init)(void);
/* Duplicate of time_init() below, with hpet_enable part added */
void __init hpet_time_init(void)
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/asm-x86/mc146818rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ static inline unsigned char current_lock_cmos_reg(void)
unsigned char rtc_cmos_read(unsigned char addr);
void rtc_cmos_write(unsigned char val, unsigned char addr);

extern int mach_set_rtc_mmss(unsigned long nowtime);
extern unsigned long mach_get_cmos_time(void);

#define RTC_IRQ 8

#endif /* _ASM_MC146818RTC_H */
2 changes: 1 addition & 1 deletion trunk/include/asm-x86/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _ASMi386_TIME_H

#include <linux/efi.h>
#include "mach_time.h"
#include <asm/mc146818rtc.h>

static inline unsigned long native_get_wallclock(void)
{
Expand Down

0 comments on commit 52c7593

Please sign in to comment.