int main(int argc, char** argv) { char line[MAX_LINE + 1]; int had_a_comment = 1; RTC_t time_before; rtc_gettime(&time_before); int8_t res; char* output[32]; while(fgets(line, MAX_LINE, stdin) != NULL) { line[strlen(line) - 1] = 0; // drop '\n' if(line[0] == '#') { if(!had_a_comment) puts("\n"); puts(line); had_a_comment=1; continue; } else { if(!had_a_comment) puts("\n"); had_a_comment=0; printf("Test: '%s'\n", line); } // -------------------------------------- res = rtc_time(line, output); if(res == -1 ) { printf("before: "); rtc_timestamp(&time_before); printf(" after: "); rtc_timestamp(&time_after); } else if(res > 0) { printf("***** ERROR %d *****\n", res); } else if(res < -1) { printf("***** ERROR %d *****\n", res); } } return 0; }
void rtc_init(struct vmctx *ctx) { size_t himem; size_t lomem; int err; /* XXX init diag/reset code/equipment/checksum ? */ /* * Report guest memory size in nvram cells as required by UEFI. * Little-endian encoding. * 0x34/0x35 - 64KB chunks above 16MB, below 4GB * 0x5b/0x5c/0x5d - 64KB chunks above 4GB */ lomem = (vm_get_lowmem_size(ctx) - m_16MB) / m_64KB; err = vm_rtc_write(ctx, RTC_LMEM_LSB, lomem); assert(err == 0); err = vm_rtc_write(ctx, RTC_LMEM_MSB, lomem >> 8); assert(err == 0); himem = vm_get_highmem_size(ctx) / m_64KB; err = vm_rtc_write(ctx, RTC_HMEM_LSB, himem); assert(err == 0); err = vm_rtc_write(ctx, RTC_HMEM_SB, himem >> 8); assert(err == 0); err = vm_rtc_write(ctx, RTC_HMEM_MSB, himem >> 16); assert(err == 0); err = vm_rtc_settime(ctx, rtc_time(ctx)); assert(err == 0); }
static unsigned long long ia64_sn2_printk_clock(void) { unsigned long rtc_now = rtc_time(); return (rtc_now - sn2_rtc_initial) * (1000000000 / sn_rtc_cycles_per_second); }
static unsigned long kvm_get_itc(struct kvm_vcpu *vcpu) { #if defined(CONFIG_IA64_SGI_SN2) || defined(CONFIG_IA64_GENERIC) if (vcpu->kvm->arch.is_sn2) return rtc_time(); else #endif return ia64_getreg(_IA64_REG_AR_ITC); }
int exec_alarm(void) { leds_toggle(LED_RED); alarm.date = rtc_time() + 5; alarm.exec_cb = exec_alarm; rtc_set_alarm(&alarm); return 0; }
static int cmd_date(int argc, char** argv, void(*callback)(char* result, int exit_status)) { uint32_t date = rtc_date(); uint32_t time = rtc_time(); printf("%s %s %d %02d:%02d:%02d UTC %d\n", weeks[RTC_WEEK(date)], months[RTC_MONTH(date)], RTC_DATE(date), RTC_HOUR(time), RTC_MINUTE(time), RTC_SECOND(time), 2000 + RTC_YEAR(date)); return 0; }
struct qtime_entry * alloc_qtime() { struct qtime_entry *qtime = set_syspage_section(&lsp.qtime, sizeof(*lsp.qtime.p)); const struct startup_info_time *time; qtime->epoch = 1970; if(!(misc_flags & MISC_FLAG_SUPPRESS_BOOTTIME)) { time = find_startup_info(NULL, STARTUP_INFO_TIME); qtime->boot_time = (time != NULL) ? time->time : rtc_time(); qtime->nsec_tod_adjust = qtime->boot_time * (uint64_t)1000000000; } return(qtime); }
void rtc_isr(void) { struct tm open; struct tm close; struct tm *now; time_t time = rtc_time(); now = gmtime(&time); settings_getopen(&open); settings_getclose(&close); if (timcmp(now, &open)) { boom_open(); } else if (timcmp(now, &close)) { boom_close(); } /* The interrupt flag isn't cleared by hardware, we have to do it. */ rtc_clear_flag(RTC_SEC); }
/* * This function must be called with interrupts disabled and preemption off * in order to insure that the setup succeeds in a deterministic time frame. * It will check if the interrupt setup succeeded. */ static int mmtimer_setup(int cpu, int comparator, unsigned long expires) { switch (comparator) { case 0: mmtimer_setup_int_0(cpu, expires); break; case 1: mmtimer_setup_int_1(cpu, expires); break; case 2: mmtimer_setup_int_2(cpu, expires); break; } /* We might've missed our expiration time */ if (rtc_time() <= expires) return 1; /* * If an interrupt is already pending then its okay * if not then we failed */ return mmtimer_int_pending(comparator); }
/** * sn_setup - SN platform setup routine * @cmdline_p: kernel command line * * Handles platform setup for SN machines. This includes determining * the RTC frequency (via a SAL call), initializing secondary CPUs, and * setting up per-node data areas. The console is also initialized here. */ void __init sn_setup(char **cmdline_p) { long status, ticks_per_sec, drift; u32 version = sn_sal_rev(); extern void sn_cpu_init(void); sn2_rtc_initial = rtc_time(); ia64_sn_plat_set_error_handling_features(); // obsolete ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV); ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES); #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) /* * Handle SN vga console. * * SN systems do not have enough ACPI table information * being passed from prom to identify VGA adapters and the legacy * addresses to access them. Until that is done, SN systems rely * on the PCDP table to identify the primary VGA console if one * exists. * * However, kernel PCDP support is optional, and even if it is built * into the kernel, it will not be used if the boot cmdline contains * console= directives. * * So, to work around this mess, we duplicate some of the PCDP code * here so that the primary VGA console (as defined by PCDP) will * work on SN systems even if a different console (e.g. serial) is * selected on the boot line (or CONFIG_EFI_PCDP is off). */ if (! vga_console_membase) sn_scan_pcdp(); if (vga_console_membase) { /* usable vga ... make tty0 the preferred default console */ if (!strstr(*cmdline_p, "console=")) add_preferred_console("tty", 0, NULL); } else { printk(KERN_DEBUG "SGI: Disabling VGA console\n"); if (!strstr(*cmdline_p, "console=")) add_preferred_console("ttySG", 0, NULL); #ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con; #else conswitchp = NULL; #endif /* CONFIG_DUMMY_CONSOLE */ } #endif /* def(CONFIG_VT) && def(CONFIG_VGA_CONSOLE) */ MAX_DMA_ADDRESS = PAGE_OFFSET + MAX_PHYS_MEMORY; /* * Build the tables for managing cnodes. */ build_cnode_tables(); status = ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec, &drift); if (status != 0 || ticks_per_sec < 100000) { printk(KERN_WARNING "unable to determine platform RTC clock frequency, guessing.\n"); /* PROM gives wrong value for clock freq. so guess */ sn_rtc_cycles_per_second = 1000000000000UL / 30000UL; } else sn_rtc_cycles_per_second = ticks_per_sec; platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR; ia64_printk_clock = ia64_sn2_printk_clock; /* * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard * support here so we don't have to listen to failed keyboard probe * messages. */ if (is_shub1() && version <= 0x0209 && acpi_kbd_controller_present) { printk(KERN_INFO "Disabling legacy keyboard support as prom " "is too old and doesn't provide FADT\n"); acpi_kbd_controller_present = 0; } printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF); /* * we set the default root device to /dev/hda * to make simulation easy */ ROOT_DEV = Root_HDA1; /* * Create the PDAs and NODEPDAs for all the cpus. */ sn_init_pdas(cmdline_p); ia64_mark_idle = &snidle; /* * For the bootcpu, we do this here. All other cpus will make the * call as part of cpu_init in slave cpu initialization. */ sn_cpu_init(); #ifdef CONFIG_SMP init_smp_config(); #endif screen_info = sn_screen_info; sn_timer_init(); /* * set pm_power_off to a SAL call to allow * sn machines to power off. The SAL call can be replaced * by an ACPI interface call when ACPI is fully implemented * for sn. */ pm_power_off = ia64_sn_power_down; current->thread.flags |= IA64_THREAD_MIGRATION; }
/* * Notify other partitions to disengage from all references to our memory. */ static void xpc_die_disengage(void) { struct xpc_partition *part; short partid; unsigned long engaged; long time, printmsg_time, disengage_request_timeout; /* keep xpc_hb_checker thread from doing anything (just in case) */ xpc_exiting = 1; xpc_vars->heartbeating_to_mask = 0; /* indicate we're deactivated */ for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) { part = &xpc_partitions[partid]; if (!XPC_SUPPORTS_DISENGAGE_REQUEST(part-> remote_vars_version)) { /* just in case it was left set by an earlier XPC */ xpc_clear_partition_engaged(1UL << partid); continue; } if (xpc_partition_engaged(1UL << partid) || part->act_state != XPC_P_INACTIVE) { xpc_request_partition_disengage(part); xpc_mark_partition_disengaged(part); xpc_IPI_send_disengage(part); } } time = rtc_time(); printmsg_time = time + (XPC_DISENGAGE_PRINTMSG_INTERVAL * sn_rtc_cycles_per_second); disengage_request_timeout = time + (xpc_disengage_request_timelimit * sn_rtc_cycles_per_second); /* wait for all other partitions to disengage from us */ while (1) { engaged = xpc_partition_engaged(-1UL); if (!engaged) { dev_info(xpc_part, "all partitions have disengaged\n"); break; } time = rtc_time(); if (time >= disengage_request_timeout) { for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) { if (engaged & (1UL << partid)) { dev_info(xpc_part, "disengage from " "remote partition %d timed " "out\n", partid); } } break; } if (time >= printmsg_time) { dev_info(xpc_part, "waiting for remote partitions to " "disengage, timeout in %ld seconds\n", (disengage_request_timeout - time) / sn_rtc_cycles_per_second); printmsg_time = time + (XPC_DISENGAGE_PRINTMSG_INTERVAL * sn_rtc_cycles_per_second); } } }
void ccnl_get_timeval(struct timeval *tv) { //gettimeofday(tv, NULL); rtc_time(tv); }