/*===========================================================================* * idle * *===========================================================================*/ PRIVATE void idle() { /* This function is called whenever there is no work to do. * Halt the CPU, and measure how many timestamp counter ticks are * spent not doing anything. This allows test setups to measure * the CPU utiliziation of certain workloads with high precision. */ #ifdef CONFIG_IDLE_TSC u64_t idle_start; read_tsc_64(&idle_start); idle_active = 1; #endif halt_cpu(); #ifdef CONFIG_IDLE_TSC if (idle_active) { IDLE_STOP; printf("Kernel: idle active after resuming CPU\n"); } idle_tsc = add64(idle_tsc, sub64(idle_stop, idle_start)); #endif }
void processor_doshutdown( processor_t processor) { register int cpu = processor->slot_num; timer_switch(&kernel_timer[cpu]); /* * Ok, now exit this cpu. */ PMAP_DEACTIVATE_KERNEL(cpu); cpu_data[cpu].active_thread = THREAD_NULL; active_kloaded[cpu] = THR_ACT_NULL; cpu_down(cpu); thread_wakeup((event_t)processor); halt_cpu(); panic("zombie processor"); /* * The action thread returns to life after the call to * switch_to_shutdown_context above, on some other cpu. */ /*NOTREACHED*/ }
void cycle6 (void) { if (do_cycle6 == 1) { // Set Halt set_halt_until_mbus_tx(); // Copy SRAM data into Flash SRAM (stream) // From 0x00000000, a quarter of SRAM mbus_copy_mem_from_local_to_remote_stream (0, FLS_ADDR, 0x00000000, 511); // Put the Flash SRAM data on the bus (to NODE_A) set_halt_until_mbus_fwd(); mbus_copy_mem_from_remote_to_any_stream (0, FLS_ADDR, 0x00000000, NODE_A_ADDR, 511); // Put the Flash SRAM data (very long) on the bus (to NODE_B). I will use halt_cpu() here. set_halt_until_mbus_tx(); mbus_copy_mem_from_remote_to_any_stream (1, FLS_ADDR, 0x00000000, NODE_B_ADDR, 511); // Halt CPU set_halt_until_mbus_fwd(); // CPU will resume when an MBus FWD operation is done. halt_cpu(); // Halt CPU! // Set Halt set_halt_until_mbus_tx(); } }
void cycle5 (void) { if (do_cycle5 == 1) { // Set Halt set_halt_until_mbus_tx(); // Copy SRAM data into Flash SRAM (bulk) // Source Addr: 0x00000000 ~ 0x0000000F (16 words) // Target Addr: 0x00000000~ mbus_copy_mem_from_local_to_remote_bulk (FLS_ADDR, 0x00000000, 0x00000000, 15); // Put the Flash SRAM data on the bus (to NODE_A) set_halt_until_mbus_fwd(); mbus_copy_mem_from_remote_to_any_bulk (FLS_ADDR, 0x00000000, NODE_A_ADDR, 0x00000000, 15); // Put the Flash SRAM data (very long) on the bus (to NODE_B) set_halt_until_mbus_tx(); mbus_copy_mem_from_remote_to_any_bulk (FLS_ADDR, 0x00000000, NODE_B_ADDR, 0x00000000, 127); // Halt CPU set_halt_until_mbus_fwd(); // CPU will resume when an MBus FWD operation is done. halt_cpu(); // Halt CPU! // Read FLS's REG#0x23 ~ REG#0x27 (5 Registers) set_halt_until_mbus_rx(); mbus_copy_registers_from_remote_to_local (FLS_ADDR, 0x23, 0x00, 4); // Put those register values on the bus (to an fake address) set_halt_until_mbus_tx(); mbus_copy_registers_from_local_to_remote (0xD, 0x15, 0x00, 4); } }
__dead void arch_shutdown(int how) { unsigned char unused_ch; /* Mask all interrupts, including the clock. */ outb( INT_CTLMASK, ~0); /* Empty buffer */ while(direct_read_char(&unused_ch)) ; if(kinfo.minix_panicing) { /* Printing is done synchronously over serial. */ if (kinfo.do_serial_debug) reset(); /* Print accumulated diagnostics buffer and reset. */ direct_cls(); direct_print("Minix panic. System diagnostics buffer:\n\n"); direct_print(kmess.kmess_buf); direct_print("\nSystem has panicked, press any key to reboot"); while (!direct_read_char(&unused_ch)) ; reset(); } switch (how) { case RBT_HALT: /* Hang */ for (; ; ) halt_cpu(); NOT_REACHABLE; case RBT_POWEROFF: /* Power off if possible, hang otherwise */ poweroff(); NOT_REACHABLE; default: case RBT_DEFAULT: case RBT_REBOOT: case RBT_RESET: /* Reset the system by forcing a processor shutdown. * First stop the BIOS memory test by setting a soft * reset flag. */ reset(); NOT_REACHABLE; } NOT_REACHABLE; }
void poweroff(void) { const char *shutdown_str; #ifdef USE_ACPI acpi_poweroff(); #endif /* Bochs/QEMU poweroff */ shutdown_str = "Shutdown"; while (*shutdown_str) outb(0x8900, *(shutdown_str++)); /* fallback option: hang */ for (; ; ) halt_cpu(); }
/*===========================================================================* * idle * *===========================================================================*/ PRIVATE void idle(void) { /* This function is called whenever there is no work to do. * Halt the CPU, and measure how many timestamp counter ticks are * spent not doing anything. This allows test setups to measure * the CPU utiliziation of certain workloads with high precision. */ /* start accounting for the idle time */ context_stop(proc_addr(KERNEL)); halt_cpu(); /* * end of accounting for the idle task does not happen here, the kernel * is handling stuff for quite a while before it gets back here! */ }
void main(void) { memset(&boot_params, 0, sizeof(boot_params)); /* processor */ processor = getprocessor(); /* memory map */ get_memory_map(processor); /* Get environment variables from the parameter sector. */ get_parameters(); if (boot_nucleos() < 0) printf("Error while booting kernel\n"); /* @nucleos: only in case of error */ while (1) halt_cpu(); }
__dead void arch_shutdown(int how) { if((how & RB_POWERDOWN) == RB_POWERDOWN) { /* Power off if possible, hang otherwise */ poweroff(); NOT_REACHABLE; } if(how & RB_HALT) { /* Hang */ for (; ; ) halt_cpu(); NOT_REACHABLE; } /* Reset the system */ reset(); NOT_REACHABLE; while (1); }
__dead void arch_shutdown(int how) { switch (how) { case RBT_HALT: /* Hang */ for (; ; ) halt_cpu(); NOT_REACHABLE; case RBT_POWEROFF: /* Power off if possible, hang otherwise */ poweroff(); NOT_REACHABLE; default: case RBT_DEFAULT: case RBT_REBOOT: case RBT_RESET: /* Reset the system */ reset(); NOT_REACHABLE; } while (1); }
PUBLIC __dead void arch_shutdown(int how) { static char mybuffer[sizeof(params_buffer)]; u16_t magic; vm_stop(); /* Mask all interrupts, including the clock. */ outb( INT_CTLMASK, ~0); if(minix_panicing) { /* We're panicing? Then retrieve and decode currently * loaded segment selectors. */ printseg("cs: ", 1, proc_ptr, read_cs()); printseg("ds: ", 0, proc_ptr, read_ds()); if(read_ds() != read_ss()) { printseg("ss: ", 0, NULL, read_ss()); } } if (how == RBT_DEFAULT) { how = mon_return ? RBT_HALT : RBT_RESET; } if(how != RBT_RESET) { /* return to boot monitor */ outb( INT_CTLMASK, 0); outb( INT2_CTLMASK, 0); /* Return to the boot monitor. Set * the program if not already done. */ if (how != RBT_MONITOR) arch_set_params("", 1); if(minix_panicing) { int source, dest; const char *lead = "echo \\n*** kernel messages:\\n"; const int leadlen = strlen(lead); strcpy(mybuffer, lead); #define DECSOURCE source = (source - 1 + _KMESS_BUF_SIZE) % _KMESS_BUF_SIZE dest = sizeof(mybuffer)-1; mybuffer[dest--] = '\0'; source = kmess.km_next; DECSOURCE; while(dest >= leadlen) { const char c = kmess.km_buf[source]; if(c == '\n') { mybuffer[dest--] = 'n'; mybuffer[dest] = '\\'; } else if(isprint(c) && c != '\'' && c != '"' && c != '\\' && c != ';') { mybuffer[dest] = c; } else mybuffer[dest] = ' '; DECSOURCE; dest--; } arch_set_params(mybuffer, strlen(mybuffer)+1); } if (mon_return) arch_monitor(); /* monitor command with no monitor: reset or poweroff * depending on the parameters */ if (how == RBT_MONITOR) { mybuffer[0] = '\0'; arch_get_params(mybuffer, sizeof(mybuffer)); if (strstr(mybuffer, "boot") || strstr(mybuffer, "menu") || strstr(mybuffer, "reset")) how = RBT_RESET; else how = RBT_HALT; } } switch (how) { case RBT_REBOOT: case RBT_RESET: /* Reset the system by forcing a processor shutdown. * First stop the BIOS memory test by setting a soft * reset flag. */ magic = STOP_MEM_CHECK; phys_copy(vir2phys(&magic), SOFT_RESET_FLAG_ADDR, SOFT_RESET_FLAG_SIZE); reset(); NOT_REACHABLE; case RBT_HALT: /* Poweroff without boot monitor */ arch_bios_poweroff(); NOT_REACHABLE; case RBT_PANIC: /* Allow user to read panic message */ for (; ; ) halt_cpu(); NOT_REACHABLE; default: /* Not possible! trigger panic */ assert(how != RBT_MONITOR); assert(how != RBT_DEFAULT); assert(how < RBT_INVALID); panic("unexpected value for how: %d", how); NOT_REACHABLE; } NOT_REACHABLE; }
void do_fiq_vector(struct pt_regs *regs) { os_printk(LOG_ERROR, "fiq vetor\n"); halt_cpu(); }
void do_notused_vector(struct pt_regs *regs) { os_printk(LOG_ERROR, "not used vector\n"); show_regs(regs); halt_cpu(); }
void do_swi_vector(struct pt_regs *regs) { os_printk(LOG_ERROR, "software interrupt\n"); show_regs(regs); halt_cpu(); }
void do_undintr_vector(struct pt_regs *regs) { os_printk(LOG_ERROR, "undefined instruction\n"); show_regs(regs); halt_cpu(); }
__dead void arch_shutdown(int how) { vm_stop(); /* Mask all interrupts, including the clock. */ outb( INT_CTLMASK, ~0); if(minix_panicing) { unsigned char unused_ch; /* We're panicing? Then retrieve and decode currently * loaded segment selectors. */ printseg("cs: ", 1, get_cpulocal_var(proc_ptr), read_cs()); printseg("ds: ", 0, get_cpulocal_var(proc_ptr), read_ds()); if(read_ds() != read_ss()) { printseg("ss: ", 0, NULL, read_ss()); } /* Printing is done synchronously over serial. */ if (do_serial_debug) reset(); /* Print accumulated diagnostics buffer and reset. */ mb_cls(); mb_print("Minix panic. System diagnostics buffer:\n\n"); mb_print(kmess_buf); mb_print("\nSystem has panicked, press any key to reboot"); while (!mb_read_char(&unused_ch)) ; reset(); } if (how == RBT_DEFAULT) { how = RBT_RESET; } switch (how) { case RBT_HALT: /* Poweroff without boot monitor */ arch_bios_poweroff(); NOT_REACHABLE; case RBT_PANIC: /* Allow user to read panic message */ for (; ; ) halt_cpu(); NOT_REACHABLE; default: case RBT_REBOOT: case RBT_RESET: /* Reset the system by forcing a processor shutdown. * First stop the BIOS memory test by setting a soft * reset flag. */ reset(); NOT_REACHABLE; } NOT_REACHABLE; }
PUBLIC __dead void arch_shutdown(int how) { u16_t magic; vm_stop(); /* Mask all interrupts, including the clock. */ outb( INT_CTLMASK, ~0); if(minix_panicing) { unsigned char unused_ch; /* We're panicing? Then retrieve and decode currently * loaded segment selectors. */ printseg("cs: ", 1, get_cpulocal_var(proc_ptr), read_cs()); printseg("ds: ", 0, get_cpulocal_var(proc_ptr), read_ds()); if(read_ds() != read_ss()) { printseg("ss: ", 0, NULL, read_ss()); } /* Printing is done synchronously over serial. */ if (do_serial_debug) reset(); /* Print accumulated diagnostics buffer and reset. */ mb_cls(); mb_print("Minix panic. System diagnostics buffer:\n\n"); mb_print(kmess_buf); mb_print("\nSystem has panicked, press any key to reboot"); while (!mb_read_char(&unused_ch)) ; reset(); } #if USE_BOOTPARAM if (how == RBT_DEFAULT) { how = mon_return ? RBT_HALT : RBT_RESET; } if(how != RBT_RESET) { /* return to boot monitor */ outb( INT_CTLMASK, 0); outb( INT2_CTLMASK, 0); /* Return to the boot monitor. Set * the program if not already done. */ if (how != RBT_MONITOR) arch_set_params("", 1); if (mon_return) arch_monitor(); /* monitor command with no monitor: reset or poweroff * depending on the parameters */ if (how == RBT_MONITOR) { how = RBT_RESET; } } switch (how) { case RBT_REBOOT: case RBT_RESET: /* Reset the system by forcing a processor shutdown. * First stop the BIOS memory test by setting a soft * reset flag. */ magic = STOP_MEM_CHECK; phys_copy(vir2phys(&magic), SOFT_RESET_FLAG_ADDR, SOFT_RESET_FLAG_SIZE); reset(); NOT_REACHABLE; case RBT_HALT: /* Poweroff without boot monitor */ arch_bios_poweroff(); NOT_REACHABLE; case RBT_PANIC: /* Allow user to read panic message */ for (; ; ) halt_cpu(); NOT_REACHABLE; default: /* Not possible! trigger panic */ assert(how != RBT_MONITOR); assert(how != RBT_DEFAULT); assert(how < RBT_INVALID); panic("unexpected value for how: %d", how); NOT_REACHABLE; } #else /* !USE_BOOTPARAM */ /* Poweroff without boot monitor */ arch_bios_poweroff(); #endif NOT_REACHABLE; }
void do_preabt_vector(struct pt_regs *regs) { os_printk(LOG_ERROR, "prefetch abort\n"); show_regs(regs); halt_cpu(); }
void do_dataabt_vector(struct pt_regs *regs) { os_printk(LOG_ERROR, "data abort\n"); show_regs(regs); halt_cpu(); }
static __dead void halt(void) { for ( ; ; ) halt_cpu(); }