Update of /cvsroot/linux-mips/linux/arch/mips/ddb5xxx/common
In directory usw-pr-cvs1:/tmp/cvs-serv32754/arch/mips/ddb5xxx/common
Modified Files:
Makefile rtc_ds1386.c
Added Files:
irq.c
Log Message:
Move to_tm() to common time.c file. Some related ddb5477 changes.
--- NEW FILE: irq.c ---
/***********************************************************************
*
* Copyright 2001 MontaVista Software Inc.
* Author: js...@mv... or js...@ju...
*
* arch/mips/ddb5xxx/common/irq.c
* Common irq code for DDB boards. This really should belong
* arch/mips/kernel/irq.c. Need to talk to Ralf.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
***********************************************************************
*/
#include <linux/config.h>
#include <linux/init.h> /* for __init */
void (*irq_setup)(void);
void __init init_IRQ(void)
{
#ifdef CONFIG_REMOTE_DEBUG
extern void breakpoint(void);
extern void set_debug_traps(void);
printk("Wait for gdb client connection ...\n");
set_debug_traps();
breakpoint();
#endif
/* invoke board-specific irq setup */
irq_setup();
}
Index: Makefile
===================================================================
RCS file: /cvsroot/linux-mips/linux/arch/mips/ddb5xxx/common/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Makefile 2001/06/22 02:29:31 1.1.1.1
--- Makefile 2001/08/23 04:20:15 1.2
***************
*** 14,18 ****
O_TARGET:= ddb5xxx.o
! obj-y += irq_cpu.o nile4.o prom.o pci.o pci_auto.o rtc_ds1386.o
include $(TOPDIR)/Rules.make
--- 14,18 ----
O_TARGET:= ddb5xxx.o
! obj-y += irq.o irq_cpu.o nile4.o prom.o pci.o pci_auto.o rtc_ds1386.o
include $(TOPDIR)/Rules.make
Index: rtc_ds1386.c
===================================================================
RCS file: /cvsroot/linux-mips/linux/arch/mips/ddb5xxx/common/rtc_ds1386.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rtc_ds1386.c 2001/06/22 02:29:31 1.1.1.1
--- rtc_ds1386.c 2001/08/23 04:20:15 1.2
***************
*** 24,28 ****
#include <linux/types.h>
#include <linux/time.h>
- #include <linux/rtc.h>
#include <asm/time.h>
--- 24,27 ----
***************
*** 83,87 ****
}
- void to_tm(unsigned long tim, struct rtc_time * tm);
static int
rtc_ds1386_set_time(unsigned long t)
--- 82,85 ----
***************
*** 173,267 ****
- /* ================================================== */
- #define TICK_SIZE tick
- #define FEBRUARY 2
- #define STARTOFTIME 1970
- #define SECDAY 86400L
- #define SECYR (SECDAY * 365)
- #define leapyear(year) ((year) % 4 == 0)
- #define days_in_year(a) (leapyear(a) ? 366 : 365)
- #define days_in_month(a) (month_days[(a) - 1])
-
- static int month_days[12] = {
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
-
- /*
- * This only works for the Gregorian calendar - i.e. after 1752 (in the UK)
- */
- static void
- GregorianDay(struct rtc_time * tm)
- {
- int leapsToDate;
- int lastYear;
- int day;
- int MonthOffset[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
-
- lastYear=tm->tm_year-1;
-
- /*
- * Number of leap corrections to apply up to end of last year
- */
- leapsToDate = lastYear/4 - lastYear/100 + lastYear/400;
-
- /*
- * This year is a leap year if it is divisible by 4 except when it is
- * divisible by 100 unless it is divisible by 400
- *
- * e.g. 1904 was a leap year, 1900 was not, 1996 is, and 2000 will be
- */
- if((tm->tm_year%4==0) &&
- ((tm->tm_year%100!=0) || (tm->tm_year%400==0)) &&
- (tm->tm_mon>2))
- {
- /*
- * We are past Feb. 29 in a leap year
- */
- day=1;
- }
- else
- {
- day=0;
- }
-
- day += lastYear*365 + leapsToDate + MonthOffset[tm->tm_mon-1] +
- tm->tm_mday;
-
- tm->tm_wday=day%7;
- }
-
-
- void to_tm(unsigned long tim, struct rtc_time * tm)
- {
- register int i;
- register long hms, day;
-
- day = tim / SECDAY;
- hms = tim % SECDAY;
-
- /* Hours, minutes, seconds are easy */
- tm->tm_hour = hms / 3600;
- tm->tm_min = (hms % 3600) / 60;
- tm->tm_sec = (hms % 3600) % 60;
-
- /* Number of years in days */
- for (i = STARTOFTIME; day >= days_in_year(i); i++)
- day -= days_in_year(i);
- tm->tm_year = i;
-
- /* Number of months in days left */
- if (leapyear(tm->tm_year))
- days_in_month(FEBRUARY) = 29;
- for (i = 1; day >= days_in_month(i); i++)
- day -= days_in_month(i);
- days_in_month(FEBRUARY) = 28;
- tm->tm_mon = i;
-
- /* Days are what is left over (+1) from all that. */
- tm->tm_mday = day + 1;
-
- /*
- * Determine the day of week
- */
- GregorianDay(tm);
- }
--- 171,172 ----
|