Lines Matching +full:offset +full:- +full:y
1 // SPDX-License-Identifier: GPL-2.0
3 * Miscellaneous Mac68K-specific stuff
31 * Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and PMU
33 * need to be changed to interpret wrapped times as post-2040.
42 static unsigned char cuda_pram_read_byte(int offset) in cuda_pram_read_byte() argument
47 (offset >> 8) & 0xFF, offset & 0xFF) < 0) in cuda_pram_read_byte()
54 static void cuda_pram_write_byte(unsigned char data, int offset) in cuda_pram_write_byte() argument
59 (offset >> 8) & 0xFF, offset & 0xFF, data) < 0) in cuda_pram_write_byte()
67 static unsigned char pmu_pram_read_byte(int offset) in pmu_pram_read_byte() argument
72 offset & 0xFF, 1) < 0) in pmu_pram_read_byte()
79 static void pmu_pram_write_byte(unsigned char data, int offset) in pmu_pram_write_byte() argument
84 offset & 0xFF, 1, data) < 0) in pmu_pram_write_byte()
157 * Inside Mac has no information about two-byte RTC commands but
168 * data should point to a one-byte buffer for the
190 if (command & 0xFF00) { /* extended (two-byte) command */ in via_rtc_command()
194 } else { /* one-byte command */ in via_rtc_command()
212 static unsigned char via_pram_read_byte(int offset) in via_pram_read_byte() argument
216 via_rtc_command(RTC_CMD_XPRAM_READ | RTC_CMD_XPRAM_ARG(offset), &temp); in via_pram_read_byte()
221 static void via_pram_write_byte(unsigned char data, int offset) in via_pram_write_byte() argument
229 via_rtc_command(RTC_CMD_XPRAM_WRITE | RTC_CMD_XPRAM_ARG(offset), &temp); in via_pram_write_byte()
239 * This only works on machines with the VIA-based PRAM/RTC, which
240 * is basically any machine with Mac II-style ADB.
272 return (time64_t)result.idata - RTC_OFFSET; in via_read_time()
289 * This only works on machines with the VIA-based PRAM/RTC, which
290 * is basically any machine with Mac II-style ADB.
302 time = mktime64(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, in via_set_rtc_time()
303 tm->tm_hour, tm->tm_min, tm->tm_sec); in via_set_rtc_time()
337 oss->rom_ctrl = OSS_POWEROFF; in oss_shutdown()
359 switch (macintosh_config->ident) { in cuda_shutdown()
374 *-------------------------------------------------------------------
377 *-------------------------------------------------------------------
383 switch (macintosh_config->adb_type) { in mac_pram_read_byte()
404 switch (macintosh_config->adb_type) { in mac_pram_write_byte()
436 } else if (macintosh_config->adb_type == MAC_ADB_II) { in mac_poweroff()
439 } else if (macintosh_config->adb_type == MAC_ADB_EGRET || in mac_poweroff()
440 macintosh_config->adb_type == MAC_ADB_CUDA) { in mac_poweroff()
444 } else if (macintosh_config->adb_type == MAC_ADB_PB2) { in mac_poweroff()
457 if (macintosh_config->adb_type == MAC_ADB_EGRET || in mac_reset()
458 macintosh_config->adb_type == MAC_ADB_CUDA) { in mac_reset()
463 if (macintosh_config->adb_type == MAC_ADB_PB2) { in mac_reset()
468 /* 030-specific reset routine. The idea is general, but the in mac_reset()
469 * specific registers to reset are '030-specific. Until I in mac_reset()
470 * have a non-030 machine, I can't test anything else. in mac_reset()
471 * -- C. Scott Ananian <cananian@alumni.princeton.edu> in mac_reset()
476 /* make a 1-to-1 mapping, using the transparent tran. reg. */ in mac_reset()
480 unsigned long offset = phys-virt; in mac_reset() local
514 : : "r" (offset), "a" (rombase) : "a0"); in mac_reset()
547 static void unmktime(time64_t time, long offset, in unmktime() argument
551 /* How many days come before each month (0-12). */ in unmktime()
559 int days, rem, y, wday; in unmktime() local
563 rem += offset; in unmktime()
566 --days; in unmktime()
569 rem -= SECS_PER_DAY; in unmktime()
579 y = 1970; in unmktime()
581 #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0)) in unmktime()
582 #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) in unmktime() argument
586 while (days < 0 || days >= (__isleap (y) ? 366 : 365)) in unmktime()
589 long int yg = y + days / 365 - (days % 365 < 0); in unmktime()
591 /* Adjust DAYS and Y to match the guessed year. */ in unmktime()
592 days -= (yg - y) * 365 + in unmktime()
593 LEAPS_THRU_END_OF(yg - 1) - LEAPS_THRU_END_OF(y - 1); in unmktime()
594 y = yg; in unmktime()
596 *yearp = y - 1900; in unmktime()
597 ip = __mon_yday[__isleap(y)]; in unmktime()
598 for (y = 11; days < (long int) ip[y]; --y) in unmktime()
600 days -= ip[y]; in unmktime()
601 *monp = y; in unmktime()
615 switch (macintosh_config->adb_type) { in mac_hwclk()
636 t->tm_wday = 0; in mac_hwclk()
638 &t->tm_year, &t->tm_mon, &t->tm_mday, in mac_hwclk()
639 &t->tm_hour, &t->tm_min, &t->tm_sec); in mac_hwclk()
644 switch (macintosh_config->adb_type) { in mac_hwclk()
662 return -ENODEV; in mac_hwclk()