arch/m68k/atari/time.c

Source file repositories/reference/linux-study-clean/arch/m68k/atari/time.c

File Facts

System
Linux kernel
Corpus path
arch/m68k/atari/time.c
Extension
.c
Size
8438 bytes
Lines
322
Domain
Architecture Layer
Bucket
arch/m68k
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (op) {
        /* write: prepare values */

        val.sec_ones = t->tm_sec % 10;
        val.sec_tens = t->tm_sec / 10;
        val.min_ones = t->tm_min % 10;
        val.min_tens = t->tm_min / 10;
        hour = t->tm_hour;
        if (!hr24) {
	    if (hour > 11)
		hour += 20 - 12;
	    if (hour == 0 || hour == 20)
		hour += 12;
        }
        val.hr_ones = hour % 10;
        val.hr_tens = hour / 10;
        val.day_ones = t->tm_mday % 10;
        val.day_tens = t->tm_mday / 10;
        val.mon_ones = (t->tm_mon+1) % 10;
        val.mon_tens = (t->tm_mon+1) / 10;
        year = t->tm_year - 80;
        val.year_ones = year % 10;
        val.year_tens = year / 10;
        val.weekday = t->tm_wday;
        mste_write(&val);
        mste_rtc.mode=(mste_rtc.mode | 1);
        val.year_ones = (year % 4);	/* leap year register */
        mste_rtc.mode=(mste_rtc.mode & ~1);
    }
    else {
        mste_read(&val);
        t->tm_sec = val.sec_ones + val.sec_tens * 10;
        t->tm_min = val.min_ones + val.min_tens * 10;
        hour = val.hr_ones + val.hr_tens * 10;
	if (!hr24) {
	    if (hour == 12 || hour == 12 + 20)
		hour -= 12;
	    if (hour >= 20)
                hour += 12 - 20;
        }
	t->tm_hour = hour;
	t->tm_mday = val.day_ones + val.day_tens * 10;
        t->tm_mon  = val.mon_ones + val.mon_tens * 10 - 1;
        t->tm_year = val.year_ones + val.year_tens * 10 + 80;
        t->tm_wday = val.weekday;
    }
    return 0;
}

int atari_tt_hwclk( int op, struct rtc_time *t )
{
    int sec=0, min=0, hour=0, day=0, mon=0, year=0, wday=0;
    unsigned long	flags;
    unsigned char	ctrl;
    int pm = 0;

    ctrl = RTC_READ(RTC_CONTROL); /* control registers are
                                   * independent from the UIP */

    if (op) {
        /* write: prepare values */

        sec  = t->tm_sec;
        min  = t->tm_min;
        hour = t->tm_hour;
        day  = t->tm_mday;
        mon  = t->tm_mon + 1;
        year = t->tm_year - atari_rtc_year_offset;
        wday = t->tm_wday + (t->tm_wday >= 0);

        if (!(ctrl & RTC_24H)) {
	    if (hour > 11) {
		pm = 0x80;
		if (hour != 12)
		    hour -= 12;
	    }
	    else if (hour == 0)
		hour = 12;
        }

        if (!(ctrl & RTC_DM_BINARY)) {
	    sec = bin2bcd(sec);
	    min = bin2bcd(min);
	    hour = bin2bcd(hour);
	    day = bin2bcd(day);
	    mon = bin2bcd(mon);
	    year = bin2bcd(year);
	    if (wday >= 0)
		wday = bin2bcd(wday);
        }

Annotation

Implementation Notes