void SendACKFun(void *ptr) { printf("create send ack thread\n"); char ackframe[7] = "*00ACK/"; while(1) { if(needsendACK == 1) { printf("sending ACK frame....\n"); SendFrame(fd, ackframe, 7); needsendACK = 0; show_state(); } usleep(100); } }
void dump_syscall_tables_uniarch(void) { unsigned int i; outputstd("syscalls: %d\n", max_nr_syscalls); for_each_syscall(i) { outputstd("entrypoint %d %s : ", syscalls[i].entry->number, syscalls[i].entry->name); show_state(syscalls[i].entry->flags & ACTIVE); if (syscalls[i].entry->flags & AVOID_SYSCALL) outputstd(" AVOID"); outputstd("\n"); } }
irqreturn_t mac_nmi_handler(int irq, void *dev_id, struct pt_regs *fp) { int i; /* * generate debug output on NMI switch if 'debug' kernel option given * (only works with Penguin!) */ in_nmi++; for (i=0; i<100; i++) udelay(1000); if (in_nmi == 1) { nmi_hold = 1; printk("... pausing, press NMI to resume ..."); } else { printk(" ok!\n"); nmi_hold = 0; } barrier(); while (nmi_hold == 1) udelay(1000); if ( console_loglevel >= 8 ) { #if 0 show_state(); printk("PC: %08lx\nSR: %04x SP: %p\n", fp->pc, fp->sr, fp); printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n", fp->d0, fp->d1, fp->d2, fp->d3); printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n", fp->d4, fp->d5, fp->a0, fp->a1); if (STACK_MAGIC != *(unsigned long *)current->kernel_stack_page) printk("Corrupted stack page\n"); printk("Process %s (pid: %d, stackpage=%08lx)\n", current->comm, current->pid, current->kernel_stack_page); if (intr_count == 1) dump_stack((struct frame *)fp); #else /* printk("NMI "); */ #endif } in_nmi--; return IRQ_HANDLED; }
static void receive_chars(struct m68k_serial *info, unsigned short rx) { m68328_uart *uart = &uart_addr[info->line]; unsigned char ch, flag; /* * This do { } while() loop will get ALL chars out of Rx FIFO */ #ifndef CONFIG_XCOPILOT_BUGS do { #endif ch = GET_FIELD(rx, URX_RXDATA); if(info->is_cons) { if(URX_BREAK & rx) { /* whee, break received */ return; #ifdef CONFIG_MAGIC_SYSRQ } else if (ch == 0x10) { /* ^P */ show_state(); show_free_areas(0); show_buffers(); /* show_net_buffers(); */ return; } else if (ch == 0x12) { /* ^R */ emergency_restart(); return; #endif /* CONFIG_MAGIC_SYSRQ */ } } flag = TTY_NORMAL; if (rx & URX_PARITY_ERROR) flag = TTY_PARITY; else if (rx & URX_OVRUN) flag = TTY_OVERRUN; else if (rx & URX_FRAME_ERROR) flag = TTY_FRAME; tty_insert_flip_char(&info->tport, ch, flag); #ifndef CONFIG_XCOPILOT_BUGS } while((rx = uart->urx.w) & URX_DATA_READY); #endif tty_schedule_flip(&info->tport); }
static void panic_print_sys_info(void) { if (panic_print & PANIC_PRINT_TASK_INFO) show_state(); if (panic_print & PANIC_PRINT_MEM_INFO) show_mem(0, NULL); if (panic_print & PANIC_PRINT_TIMER_INFO) sysrq_timer_list_show(); if (panic_print & PANIC_PRINT_LOCK_INFO) debug_show_all_locks(); if (panic_print & PANIC_PRINT_FTRACE_INFO) ftrace_dump(DUMP_ALL); }
static void show_event(int index) { int screen_count = s_active_item_count + 1; int height = bounds.size.h * (screen_count + 2); destroy_property_animation(&prop_animation); bool invert = false; GRect from_rect = GRect(0, -(current_item + 1) * bounds.size.h, bounds.size.w, height); if(index < 0) { index = screen_count - 1; from_rect.origin.y = -(screen_count + 1) * bounds.size.h; invert = true; } else if(index >= screen_count) { index = 0; from_rect.origin.y = 0; invert = true; } GRect to_rect = GRect(0, -(index + 1) * bounds.size.h, bounds.size.w, height); prop_animation = property_animation_create_layer_frame(events_layer, &from_rect, &to_rect); animation_set_duration((Animation*) prop_animation, 400); animation_schedule((Animation*) prop_animation); // if state is about to be shown or hidden then animate it if (index == 0 || current_item == 0) { int stateFrom = 0, stateTo = 0; if (current_item == 1) stateFrom = -1; else if (current_item > 1) stateFrom = 1; if (index == 1) stateTo = -1; else if (index > 1) stateTo = 1; if (invert && screen_count == 2) { stateFrom = -stateFrom; stateTo = -stateTo; } show_state(stateFrom, stateTo); } current_item = index; layer_mark_dirty(navi_layer); }
static int nmi_debug_notify(struct notifier_block *self, unsigned long val, void *data) { struct die_args *args = data; if (likely(val != DIE_NMI)) return NOTIFY_DONE; if (nmi_actions & NMI_SHOW_STATE) show_state(); if (nmi_actions & NMI_SHOW_REGS) show_regs(args->regs); if (nmi_actions & NMI_DEBOUNCE) mdelay(10); if (nmi_actions & NMI_DIE) return NOTIFY_BAD; return NOTIFY_OK; }
static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id) { struct pxa_i2c *i2c = dev_id; u32 isr = readl(_ISR(i2c)); if (i2c_debug > 2 && 0) { dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n", __func__, isr, readl(_ICR(i2c)), readl(_IBMR(i2c))); decode_ISR(isr); } if (i2c->irqlogidx < ARRAY_SIZE(i2c->isrlog)) i2c->isrlog[i2c->irqlogidx++] = isr; show_state(i2c); /* * Always clear all pending IRQs. */ writel(isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED), _ISR(i2c)); if (isr & ISR_SAD) i2c_pxa_slave_start(i2c, isr); if (isr & ISR_SSD) i2c_pxa_slave_stop(i2c); if (i2c_pxa_is_slavemode(i2c)) { if (isr & ISR_ITE) i2c_pxa_slave_txempty(i2c, isr); if (isr & ISR_IRF) i2c_pxa_slave_rxfull(i2c, isr); } else if (i2c->msg) { if (isr & ISR_ITE) i2c_pxa_irq_txempty(i2c, isr); if (isr & ISR_IRF) i2c_pxa_irq_rxfull(i2c, isr); } else { i2c_pxa_scream_blue_murder(i2c, "spurious irq"); } return IRQ_HANDLED; }
static void i2c_vr_abort(struct vr_i2c *i2c) { struct i2c_vr_regs __iomem *regs = i2c->regs; unsigned long timeout = jiffies + HZ / 4; u32 icr; while (time_before(jiffies, timeout) && (readl(®s->ibmr) & 0x1) == 0) { icr = readl(®s->icr); icr &= ~ICR_START; icr |= ICR_ACKNAK | ICR_STOP | ICR_TB; writel(icr, ®s->icr); show_state(i2c); msleep(1); } icr = readl(®s->icr) & ~(ICR_MA | ICR_START | ICR_STOP); writel(icr, ®s->icr); }
static void receive_chars(struct tty_struct *tty, struct pt_regs *regs) { unsigned char ch; static unsigned char seen_esc = 0; while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) { if ( ch == 27 && seen_esc == 0 ) { seen_esc = 1; continue; } else { if ( seen_esc==1 && ch == 'O' ) { seen_esc = 2; continue; } else if ( seen_esc == 2 ) { if ( ch == 'P' ) show_state(); /* F1 key */ #ifdef CONFIG_KDB if ( ch == 'S' ) kdb(KDB_REASON_KEYBOARD, 0, (kdb_eframe_t) regs); #endif seen_esc = 0; continue; } } seen_esc = 0; if (tty->flip.count >= TTY_FLIPBUF_SIZE) break; *tty->flip.char_buf_ptr = ch; *tty->flip.flag_buf_ptr = 0; tty->flip.flag_buf_ptr++; tty->flip.char_buf_ptr++; tty->flip.count++; } tty_flip_buffer_push(tty); }
static void receive_chars(struct tty_struct *tty, struct pt_regs *regs) { unsigned char ch; static unsigned char seen_esc = 0; while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) { if ( ch == 27 && seen_esc == 0 ) { seen_esc = 1; continue; } else { if ( seen_esc==1 && ch == 'O' ) { seen_esc = 2; continue; } else if ( seen_esc == 2 ) { if ( ch == 'P' ) /* F1 */ show_state(); #ifdef CONFIG_MAGIC_SYSRQ if ( ch == 'S' ) { /* F4 */ do ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR); while (!ch); handle_sysrq(ch, regs, NULL); } #endif seen_esc = 0; continue; } } seen_esc = 0; if (tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) break; } tty_flip_buffer_push(tty); }
static int try_to_freeze_tasks(bool sig_only) { struct task_struct *g, *p; unsigned long end_time; unsigned int todo; struct timeval start, end; u64 elapsed_csecs64; unsigned int elapsed_csecs; unsigned int wakeup = 0; do_gettimeofday(&start); end_time = jiffies + TIMEOUT; do { todo = 0; read_lock(&tasklist_lock); do_each_thread(g, p) { if (frozen(p) || !freezeable(p)) continue; if (!freeze_task(p, sig_only)) continue; /* * Now that we've done set_freeze_flag, don't * perturb a task in TASK_STOPPED or TASK_TRACED. * It is "frozen enough". If the task does wake * up, it will immediately call try_to_freeze. * * Because freeze_task() goes through p's * scheduler lock after setting TIF_FREEZE, it's * guaranteed that either we see TASK_RUNNING or * try_to_stop() after schedule() in ptrace/signal * stop sees TIF_FREEZE. */ if (!task_is_stopped_or_traced(p) && !freezer_should_skip(p)) todo++; } while_each_thread(g, p); read_unlock(&tasklist_lock); yield(); /* Yield is okay here */ if (todo && has_wake_lock(WAKE_LOCK_SUSPEND)) { wakeup = 1; break; } if (time_after(jiffies, end_time)) break; } while (todo); do_gettimeofday(&end); elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start); do_div(elapsed_csecs64, NSEC_PER_SEC / 100); elapsed_csecs = elapsed_csecs64; if (todo) { /* This does not unfreeze processes that are already frozen * (we have slightly ugly calling convention in that respect, * and caller must call thaw_processes() if something fails), * but it cleans up leftover PF_FREEZE requests. */ printk("\n"); printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds " "(%d tasks refusing to freeze):\n", wakeup ? "aborted" : "failed", elapsed_csecs / 100, elapsed_csecs % 100, todo); if(!wakeup) show_state(); read_lock(&tasklist_lock); do_each_thread(g, p) { task_lock(p); if (freezing(p) && !freezer_should_skip(p) && elapsed_csecs > 100) printk(KERN_ERR " %s\n", p->comm); cancel_freezing(p); task_unlock(p); } while_each_thread(g, p); read_unlock(&tasklist_lock); } else {
void handle_sysrq(int key, struct pt_regs *pt_regs, struct kbd_struct *kbd, struct tty_struct *tty) { int orig_log_level = console_loglevel; if (!key) return; console_loglevel = 7; printk(KERN_INFO "SysRq: "); switch (key) { case 'r': /* R -- Reset raw mode */ if (kbd) { kbd->kbdmode = VC_XLATE; printk("Keyboard mode set to XLATE\n"); } break; #ifdef CONFIG_VT case 'k': /* K -- SAK */ printk("SAK\n"); if (tty) do_SAK(tty); reset_vc(fg_console); break; #endif case 'b': /* B -- boot immediately */ printk("Resetting\n"); machine_restart(NULL); break; case 'o': /* O -- power off */ if (sysrq_power_off) { printk("Power off\n"); sysrq_power_off(); } break; case 's': /* S -- emergency sync */ printk("Emergency Sync\n"); emergency_sync_scheduled = EMERG_SYNC; wakeup_bdflush(0); break; case 'u': /* U -- emergency remount R/O */ printk("Emergency Remount R/O\n"); emergency_sync_scheduled = EMERG_REMOUNT; wakeup_bdflush(0); break; case 'p': /* P -- show PC */ printk("Show Regs\n"); if (pt_regs) show_regs(pt_regs); break; case 't': /* T -- show task info */ printk("Show State\n"); show_state(); break; case 'm': /* M -- show memory info */ printk("Show Memory\n"); show_mem(); break; case '0' ... '9': /* 0-9 -- set console logging level */ orig_log_level = key - '0'; printk("Log level set to %d\n", orig_log_level); break; case 'e': /* E -- terminate all user processes */ printk("Terminate All Tasks\n"); send_sig_all(SIGTERM, 0); orig_log_level = 8; /* We probably have killed syslogd */ break; case 'i': /* I -- kill all user processes */ printk("Kill All Tasks\n"); send_sig_all(SIGKILL, 0); orig_log_level = 8; break; case 'l': /* L -- kill all processes including init */ printk("Kill ALL Tasks (even init)\n"); send_sig_all(SIGKILL, 1); orig_log_level = 8; break; default: /* Unknown: help */ if (kbd) printk("unRaw "); #ifdef CONFIG_VT if (tty) printk("saK "); #endif printk("Boot "); if (sysrq_power_off) printk("Off "); printk("Sync Unmount showPc showTasks showMem loglevel0-8 tErm kIll killalL\n"); /* Don't use 'A' as it's handled specially on the Sparc */ } console_loglevel = orig_log_level; }
static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx) { struct tty_struct *tty = info->tty; #ifndef CONFIG_XCOPILOT_BUGS m68328_uart *uart = &uart_addr[info->line]; #endif unsigned char ch; /* * This do { } while() loop will get ALL chars out of Rx FIFO */ #ifndef CONFIG_XCOPILOT_BUGS do { #endif ch = GET_FIELD(rx, URX_RXDATA); if(info->is_cons) { if(URX_BREAK & rx) { /* whee, break received */ status_handle(info, rx); return; #ifdef CONFIG_MAGIC_SYSRQ } else if (ch == 0x10) { /* ^P */ show_state(); show_free_areas(); show_buffers(); /* show_net_buffers(); */ return; } else if (ch == 0x12) { /* ^R */ machine_restart(NULL); return; #endif /* CONFIG_MAGIC_SYSRQ */ } } if(!tty) goto clear_and_exit; /* * Make sure that we do not overflow the buffer */ if (tty->flip.count >= TTY_FLIPBUF_SIZE) { queue_task(&tty->flip.tqueue, &tq_timer); return; } if(rx & URX_PARITY_ERROR) { *tty->flip.flag_buf_ptr++ = TTY_PARITY; status_handle(info, rx); } else if(rx & URX_OVRUN) { *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; status_handle(info, rx); } else if(rx & URX_FRAME_ERROR) { *tty->flip.flag_buf_ptr++ = TTY_FRAME; status_handle(info, rx); } else { *tty->flip.flag_buf_ptr++ = 0; /* XXX */ } *tty->flip.char_buf_ptr++ = ch; tty->flip.count++; #ifndef CONFIG_XCOPILOT_BUGS } while((rx = uart->urx.w) & URX_DATA_READY); #endif queue_task(&tty->flip.tqueue, &tq_timer); clear_and_exit: return; }
static _INLINE_ void receive_chars(struct NIOS_serial *info, struct pt_regs *regs, unsigned short rx) { struct tty_struct *tty = info->tty; unsigned char ch; np_uart * uart= (np_uart *)(info->port); /* * This do { } while() loop will get ALL chars out of Rx FIFO */ do { ch = uart->np_uartrxdata; if(info->is_cons) { #ifdef CONFIG_MAGIC_SYSRQ if(rx & np_uartstatus_brk_mask) { batten_down_hatches(); return; } else if (ch == 0x10) { /* ^P */ show_state(); show_mem(); return; } else if (ch == 0x12) { /* ^R */ hard_reset_now(); return; #ifdef DEBUG } else if (ch == 0x02) { /* ^B */ batten_down_hatches(); return; } else if (ch == 0x01) { /* ^A */ asm("trap 0"); /* Back to monitor */ return; /* (won't be coming back) */ #endif } #endif /* CONFIG_MAGIC_SYSRQ */ } if(!tty) goto clear_and_exit; /* * Make sure that we do not overflow the buffer */ if (tty->flip.count >= TTY_FLIPBUF_SIZE) { queue_task(&tty->flip.tqueue, &tq_timer); return; } if(rx & np_uartstatus_pe_mask) { *tty->flip.flag_buf_ptr++ = TTY_PARITY; status_handle(info, rx); } else if(rx & np_uartstatus_roe_mask) { *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; status_handle(info, rx); } else if(rx & np_uartstatus_fe_mask) { *tty->flip.flag_buf_ptr++ = TTY_FRAME; status_handle(info, rx); } else if(rx & np_uartstatus_brk_mask) { *tty->flip.flag_buf_ptr++ = TTY_BREAK; status_handle(info, rx); } else { *tty->flip.flag_buf_ptr++ = 0; /* XXX */ } *tty->flip.char_buf_ptr++ = ch; tty->flip.count++; } while((rx = uart->np_uartstatus) & np_uartstatus_rrdy_mask); queue_task(&tty->flip.tqueue, &tq_timer); clear_and_exit: return; }
static _INLINE_ void receive_chars(struct bf535_serial *info, struct pt_regs *regs, unsigned short rx) { struct tty_struct *tty = info->tty; unsigned char ch; int idx = info->hub2; /* * This do { } while() loop will get ALL chars out of Rx FIFO */ do { ch = (unsigned char) rx; if(info->is_cons) { if (UART_LSR(idx) & UART_LSR_BI){ /* break received */ status_handle(info, UART_LSR(idx)); return; } else if (ch == 0x10) { /* ^P */ show_state(); show_free_areas(); show_buffers(); /* show_net_buffers(); */ return; } else if (ch == 0x12) { /* ^R */ machine_restart(NULL); return; } } if(!tty){ printk("no tty\n"); goto clear_and_exit; } /* * Make sure that we do not overflow the buffer */ if (tty->flip.count >= TTY_FLIPBUF_SIZE) { queue_task(&tty->flip.tqueue, &tq_timer); return; } if(UART_LSR(idx) & UART_LSR_PE) { *tty->flip.flag_buf_ptr++ = TTY_PARITY; status_handle(info, UART_LSR(idx)); } else if(UART_LSR(idx) & UART_LSR_OE) { *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; status_handle(info, UART_LSR(idx)); } else if(UART_LSR(idx) & UART_LSR_FE) { *tty->flip.flag_buf_ptr++ = TTY_FRAME; status_handle(info, UART_LSR(idx)); } else { *tty->flip.flag_buf_ptr++ = 0; /* XXX */ } tty->flip.count++; *tty->flip.char_buf_ptr++ = ch; ACCESS_PORT_IER(idx) /* change access to port data */ rx = UART_RBR(idx); } while(UART_LSR(idx) & UART_LSR_DR); queue_task(&tty->flip.tqueue, &tq_timer); clear_and_exit: return; }
static int try_to_freeze_tasks(int freeze_user_space) { struct task_struct *g, *p; unsigned long end_time; unsigned int todo; struct timeval start, end; s64 elapsed_csecs64; unsigned int elapsed_csecs; do_gettimeofday(&start); end_time = jiffies + TIMEOUT; do { todo = 0; read_lock(&tasklist_lock); do_each_thread(g, p) { if (frozen(p) || !freezeable(p)) continue; if (p->state == TASK_TRACED && frozen(p->parent)) { cancel_freezing(p); continue; } if (!freeze_task(p, freeze_user_space)) continue; if (!freezer_should_skip(p)) todo++; } while_each_thread(g, p); read_unlock(&tasklist_lock); yield(); /* Yield is okay here */ if (time_after(jiffies, end_time)) break; } while (todo); do_gettimeofday(&end); elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start); do_div(elapsed_csecs64, NSEC_PER_SEC / 100); elapsed_csecs = elapsed_csecs64; if (todo) { /* This does not unfreeze processes that are already frozen * (we have slightly ugly calling convention in that respect, * and caller must call thaw_processes() if something fails), * but it cleans up leftover PF_FREEZE requests. */ printk("\n"); printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds " "(%d tasks refusing to freeze):\n", elapsed_csecs / 100, elapsed_csecs % 100, todo); show_state(); read_lock(&tasklist_lock); do_each_thread(g, p) { task_lock(p); if (freezing(p) && !freezer_should_skip(p)) printk(KERN_ERR " %s\n", p->comm); cancel_freezing(p); task_unlock(p); } while_each_thread(g, p); read_unlock(&tasklist_lock); } else {
/* main function is a recv-thread, it is used to receive messages * * sending from the senrver. * * if it receives a control-message, it will set needsendACK = 1 * * (to tell send thread that he should send an ACK to the server * * saying "got it"). * * if receive a ACK message, it will set haverecvACK = 1, to let * * the send thread knows that the server had received a temperature * * message. */ int main() { pthread_t sendthread, sendACKthread; char recvframe[MAX_FRAME_SIZE] = "ABCDEFG"; // char *device = "/dev/ttyAMA0"; // char *device = "/dev/ttyUSB0"; char *device = "/dev/pts/4"; fre = 1; stop = 0; haverecvACK = 0; needsendACK = 0; pthread_mutex_init(&stop_mutex, NULL); pthread_mutex_init(&fre_mutex, NULL); pthread_mutex_init(&have_recv_ack_mutex, NULL); pthread_mutex_init(&need_send_ack_mutex, NULL); fd = OpenPort(device); if(fd < 0) return -1; pthread_create(&sendthread, NULL, (void *)&SendThreadFun, NULL); pthread_create(&sendACKthread, NULL, (void *)&SendACKFun, NULL); while(stop != 1) { /*receive a frame and analyse it*/ RecvFrame(fd, recvframe); int recvmode = AnalyseFrame(recvframe); if(recvmode == 0) { printf("recv: ACK\n"); pthread_mutex_lock(&have_recv_ack_mutex); haverecvACK = 1; show_state(); pthread_mutex_unlock(&have_recv_ack_mutex); } /* if it receives a frequency-message, it will set needsendACK = 1 * * (to tell send thread that he should send an ACK to the server * * saying "got it"). */ if(recvmode == 2 ) { printf("recv: change frequency %d\n", fre); char delayAscii[7]; /*extract the number from the recv frame */ memcpy(delayAscii, recvframe + 3, 6); delayAscii[6] = '\0'; pthread_mutex_lock(&fre_mutex); fre = atol((const char *) delayAscii); pthread_mutex_unlock(&fre_mutex); pthread_mutex_lock(&need_send_ack_mutex); needsendACK = 1; show_state(); pthread_mutex_unlock(&need_send_ack_mutex); } /* if it receives a stop-message, it will set needsendACK = 1 * * (to tell send thread that he should send an ACK to the server * * saying "got it"). */ if(recvmode == 3) { printf("recv: STOP!\n"); pthread_mutex_lock(&stop_mutex); stop = 1; pthread_mutex_unlock(&stop_mutex); pthread_mutex_lock(&need_send_ack_mutex); needsendACK = 1; show_state(); pthread_mutex_unlock(&need_send_ack_mutex); } memset(recvframe, '\0', MAX_FRAME_SIZE); //usleep(500000); } pthread_join(sendthread, NULL); pthread_join(sendACKthread, NULL); return 0; }
static int try_to_freeze_tasks(bool sig_only) { struct task_struct *g, *p; unsigned long end_time; unsigned int todo; struct timeval start, end; u64 elapsed_csecs64; unsigned int elapsed_csecs; long wl_timeout; unsigned int wakeup = 0; do_gettimeofday(&start); end_time = jiffies + TIMEOUT; do { todo = 0; read_lock(&tasklist_lock); do_each_thread(g, p) { if (frozen(p) || !freezeable(p)) continue; if (!freeze_task(p, sig_only)) continue; /* * Now that we've done set_freeze_flag, don't * perturb a task in TASK_STOPPED or TASK_TRACED. * It is "frozen enough". If the task does wake * up, it will immediately call try_to_freeze. */ if (!task_is_stopped_or_traced(p) && !freezer_should_skip(p)) todo++; } while_each_thread(g, p); read_unlock(&tasklist_lock); yield(); /* Yield is okay here */ wl_timeout = has_wake_lock_debug(WAKE_LOCK_SUSPEND); if (todo && wl_timeout) { printk(KERN_ERR "Suspend prevented for %ld jiffies\n", wl_timeout); wakeup = 1; break; } if (time_after(jiffies, end_time)) { printk(KERN_ERR "Suspend attempts timed out\n"); break; } } while (todo); do_gettimeofday(&end); elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start); do_div(elapsed_csecs64, NSEC_PER_SEC / 100); elapsed_csecs = elapsed_csecs64; if (todo) { /* This does not unfreeze processes that are already frozen * (we have slightly ugly calling convention in that respect, * and caller must call thaw_processes() if something fails), * but it cleans up leftover PF_FREEZE requests. */ if(wakeup) { printk("\n"); printk(KERN_ERR "Freezing of %s aborted\n", sig_only ? "user space " : "tasks "); } else { printk("\n"); printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds " "(%d tasks refusing to freeze):\n", elapsed_csecs / 100, elapsed_csecs % 100, todo); show_state(); } read_lock(&tasklist_lock); do_each_thread(g, p) { task_lock(p); if (freezing(p) && !freezer_should_skip(p)) printk(KERN_ERR " %s\n", p->comm); cancel_freezing(p); task_unlock(p); } while_each_thread(g, p); read_unlock(&tasklist_lock); } else {
static void sysrq_handle_showstate(int key, struct tty_struct *tty) { show_state(); }
static int try_to_freeze_tasks(bool sig_only) { struct task_struct *g, *p; unsigned long end_time; unsigned int todo; struct timeval start, end; u64 elapsed_csecs64; unsigned int elapsed_csecs; do_gettimeofday(&start); end_time = jiffies + TIMEOUT; while (true) { todo = 0; read_lock(&tasklist_lock); do_each_thread(g, p) { if (frozen(p) || !freezeable(p)) continue; if (!freeze_task(p, sig_only)) continue; /* * Now that we've done set_freeze_flag, don't * perturb a task in TASK_STOPPED or TASK_TRACED. * It is "frozen enough". If the task does wake * up, it will immediately call try_to_freeze. */ if (!task_is_stopped_or_traced(p) && !freezer_should_skip(p)) todo++; } while_each_thread(g, p); read_unlock(&tasklist_lock); if (!todo || time_after(jiffies, end_time)) break; /* * We need to retry, but first give the freezing tasks some * time to enter the regrigerator. */ msleep(10); } do_gettimeofday(&end); elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start); do_div(elapsed_csecs64, NSEC_PER_SEC / 100); elapsed_csecs = elapsed_csecs64; if (todo) { /* This does not unfreeze processes that are already frozen * (we have slightly ugly calling convention in that respect, * and caller must call thaw_processes() if something fails), * but it cleans up leftover PF_FREEZE requests. */ printk("\n"); printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds " "(%d tasks refusing to freeze):\n", elapsed_csecs / 100, elapsed_csecs % 100, todo); show_state(); read_lock(&tasklist_lock); do_each_thread(g, p) { task_lock(p); if (freezing(p) && !freezer_should_skip(p)) printk(KERN_ERR " %s\n", p->comm); cancel_freezing(p); task_unlock(p); } while_each_thread(g, p); read_unlock(&tasklist_lock); } else {
/** Show debug monitor prompt and execute user command */ static void do_debug(t_state *s, uint32_t no_prompt){ int ch; int i, j=0, watch=0, addr; j = s->breakpoint; s->pc_next = s->pc + 4; s->skip = 0; s->wakeup = 0; printf("Starting simulation.\n"); if(no_prompt){ ch = '5'; /* 'go' command */ //printf("\n\n"); } else{ show_state(s); ch = ' '; } for(;;){ if(ch != 'n' && !no_prompt){ if(watch){ printf("0x%8.8x=0x%8.8x\n", watch, mem_read(s, 4, watch,0)); } printf("1=Debug 2=Trace 3=Step 4=BreakPt 5=Go "); printf("6=Memory 7=Watch 8=Jump\n"); printf("9=Quit A=Dump L=LogTrg C=Disasm "); printf("> "); } if(ch==' ') ch = getch(); if(ch != 'n'){ printf("\n"); } switch(ch){ case 'a': case 'A': dump_trace_buffer(s); break; case '1': case 'd': case ' ': cycle(s, 0); show_state(s); break; case 'n': cycle(s, 1); break; case '2': case 't': cycle(s, 0); printf("*"); cycle(s, 10); break; case '3': case 's': printf("Count> "); scanf("%d", &j); for(i = 0; i < j; ++i){ cycle(s, 1); } show_state(s); break; case '4': case 'b': printf("Line> "); scanf("%x", &j); printf("break point=0x%x\n", j); break; case '5': case 'g': s->wakeup = 0; cycle(s, 0); while(s->wakeup == 0){ if(s->pc == j){ printf("\n\nStop: pc = 0x%08x\n\n", j); break; } cycle(s, 0); } if(no_prompt) return; show_state(s); break; case 'G': s->wakeup = 0; cycle(s, 1); while(s->wakeup == 0){ if(s->pc == j){ break; } cycle(s, 1); } show_state(s); break; case '6': case 'm': printf("Memory> "); scanf("%x", &j); for(i = 0; i < 8; ++i){ printf("%8.8x ", mem_read(s, 4, j+i*4, 0)); } printf("\n"); break; case '7': case 'w': printf("Watch> "); scanf("%x", &watch); break; case '8': case 'j': printf("Jump> "); scanf("%x", &addr); s->pc = addr; s->pc_next = addr + 4; show_state(s); break; case '9': case 'q': return; case 'l': printf("Address> "); scanf("%x", &(s->t.log_trigger_address)); printf("Log trigger address=0x%x\n", s->t.log_trigger_address); break; case 'c': case 'C': j = s->pc; for(i = 1; i <= 16; ++i){ printf("%c", i==0 ? '*' : ' '); s->pc = s->t.disasm_ptr + i * 4; cycle(s, 10); } s->t.disasm_ptr = s->pc; s->pc = j; } ch = ' '; } }
static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx) { struct tty_struct *tty = info->tty; m68328_uart *uart = &uart_addr[info->line]; unsigned char ch, flag; /* * This do { } while() loop will get ALL chars out of Rx FIFO */ #ifndef CONFIG_XCOPILOT_BUGS do { #endif ch = GET_FIELD(rx, URX_RXDATA); if(info->is_cons) { if(URX_BREAK & rx) { /* whee, break received */ status_handle(info, rx); return; #ifdef CONFIG_MAGIC_SYSRQ } else if (ch == 0x10) { /* ^P */ show_state(); show_free_areas(); show_buffers(); /* show_net_buffers(); */ return; } else if (ch == 0x12) { /* ^R */ emergency_restart(); return; #endif /* CONFIG_MAGIC_SYSRQ */ } /* It is a 'keyboard interrupt' ;-) */ #ifdef CONFIG_CONSOLE wake_up(&keypress_wait); #endif } if(!tty) goto clear_and_exit; /* * Make sure that we do not overflow the buffer */ if (tty_request_buffer_room(tty, 1) == 0) { tty_schedule_flip(tty); return; } flag = TTY_NORMAL; if(rx & URX_PARITY_ERROR) { flag = TTY_PARITY; status_handle(info, rx); } else if(rx & URX_OVRUN) { flag = TTY_OVERRUN; status_handle(info, rx); } else if(rx & URX_FRAME_ERROR) { flag = TTY_FRAME; status_handle(info, rx); } tty_insert_flip_char(tty, ch, flag); #ifndef CONFIG_XCOPILOT_BUGS } while((rx = uart->urx.w) & URX_DATA_READY); #endif tty_schedule_flip(tty); clear_and_exit: return; }
static _INLINE_ void receive_chars(struct LEON_serial *info, struct pt_regs *regs, unsigned short rx) { struct tty_struct *tty = info->tty; unsigned char ch; /* * This do { } while() loop will get ALL chars out of Rx FIFO */ do { ch = leon->uartdata1; if(info->is_cons) { if(0 /* LEON does not report break */ & rx) { /* whee, break received */ status_handle(info, rx); return; } else if (ch == 0x10) { /* ^P */ show_state(); show_free_areas(); show_buffers(); show_net_buffers(); return; } else if (ch == 0x12) { /* ^R */ hard_reset_now(); return; } /* It is a 'keyboard interrupt' ;-) */ wake_up(&keypress_wait); } if(!tty) goto clear_and_exit; /* * Make sure that we do not overflow the buffer */ if (tty->flip.count >= TTY_FLIPBUF_SIZE) { queue_task_irq_off(&tty->flip.tqueue, &tq_timer); return; } if(rx & USTAT_PE) { *tty->flip.flag_buf_ptr++ = TTY_PARITY; status_handle(info, rx); } else if(rx & USTAT_OV) { *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; status_handle(info, rx); } else if(rx & USTAT_FE) { *tty->flip.flag_buf_ptr++ = TTY_FRAME; status_handle(info, rx); } else { *tty->flip.flag_buf_ptr++ = 0; /* XXX */ } *tty->flip.char_buf_ptr++ = ch; tty->flip.count++; } while((rx = leon->uartstatus1) & USTAT_DR); queue_task_irq_off(&tty->flip.tqueue, &tq_timer); clear_and_exit: return; }
static asmlinkage void netpoll_netdump(struct pt_regs *regs, void *platform_arg) { reply_t reply; char *tmp = command_tmp; extern unsigned long totalram_pages; struct pt_regs myregs; req_t *req; /* * Just in case we are crashing within the networking code * ... attempt to fix up. */ netpoll_reset_locks(&np); platform_fix_regs(); platform_timestamp(t0); netpoll_set_trap(1); /* bypass networking stack */ local_irq_disable(); local_bh_disable(); printk("< netdump activated - performing handshake with the server. >\n"); netdump_startup_handshake(&np); printk("< handshake completed - listening for dump requests. >\n"); while (netdump_mode) { Dprintk("main netdump loop: polling controller ...\n"); netpoll_poll(&np); req = get_new_req(); if (!req) continue; Dprintk("got new req, command %d.\n", req->command); print_status(req); switch (req->command) { case COMM_NONE: Dprintk("got NO command.\n"); break; case COMM_SEND_MEM: Dprintk("got MEM command.\n"); send_netdump_mem(&np, req); break; case COMM_EXIT: Dprintk("got EXIT command.\n"); netdump_mode = 0; netpoll_set_trap(0); break; case COMM_REBOOT: Dprintk("got REBOOT command.\n"); printk("netdump: rebooting in 3 seconds.\n"); netdump_mdelay(3000); machine_restart(NULL); break; case COMM_HELLO: sprintf(tmp, "Hello, this is netdump version 0.%02d\n", NETDUMP_VERSION); reply.code = REPLY_HELLO; reply.nr = req->nr; reply.info = NETDUMP_VERSION; send_netdump_msg(&np, tmp, strlen(tmp), &reply); break; case COMM_GET_PAGE_SIZE: sprintf(tmp, "PAGE_SIZE: %ld\n", PAGE_SIZE); reply.code = REPLY_PAGE_SIZE; reply.nr = req->nr; reply.info = PAGE_SIZE; send_netdump_msg(&np, tmp, strlen(tmp), &reply); break; case COMM_GET_REGS: reply.code = REPLY_REGS; reply.nr = req->nr; reply.info = (u32)totalram_pages; send_netdump_msg(&np, tmp, platform_get_regs(tmp, &myregs), &reply); break; case COMM_GET_NR_PAGES: reply.code = REPLY_NR_PAGES; reply.nr = req->nr; reply.info = platform_max_pfn(); sprintf(tmp, "Number of pages: %ld\n", platform_max_pfn()); send_netdump_msg(&np, tmp, strlen(tmp), &reply); break; case COMM_SHOW_STATE: /* send response first */ reply.code = REPLY_SHOW_STATE; reply.nr = req->nr; reply.info = 0; netdump_mode = 0; if (regs) show_regs(regs); show_state(); show_mem(); netdump_mode = 1; send_netdump_msg(&np, tmp, strlen(tmp), &reply); break; default: reply.code = REPLY_ERROR; reply.nr = req->nr; reply.info = req->command; Dprintk("got UNKNOWN command!\n"); sprintf(tmp, "Got unknown command code %d!\n", req->command); send_netdump_msg(&np, tmp, strlen(tmp), &reply); break; } kfree(req); req = NULL; } sprintf(tmp, "NETDUMP end.\n"); reply.code = REPLY_END_NETDUMP; reply.nr = 0; reply.info = 0; send_netdump_msg(&np, tmp, strlen(tmp), &reply); printk("NETDUMP END!\n"); }
static void i2c_vr_irq_txempty(struct vr_i2c *i2c, u32 isr) { struct i2c_vr_regs __iomem *regs = i2c->regs; u32 icr; icr = readl(®s->icr) & ~(ICR_START | ICR_STOP | ICR_ACKNAK | ICR_TB); again: /* * If ISR_ALD is set, we lost arbitration. */ if (isr & ISR_ALD) { /* * Do we need to do anything here? The docs * are vague about what happens. */ i2c_vr_scream_blue_murder(i2c, "ALD set"); /* * We ignore this error. We seem to see spurious ALDs * for seemingly no reason. If we handle them as I think * they should, we end up causing an I2C error, which * is painful for some systems. */ return; /* ignore */ } if (isr & ISR_BED) { int ret = I2C_VR_BUS_ERROR; /* * I2C bus error - either the device NAK'd us, or * something more serious happened. If we were NAK'd * on the initial address phase, we can retry. */ if (isr & ISR_ACKNAK) { if (i2c->msg_ptr == 0 && i2c->msg_idx == 0) ret = I2C_RETRY; else ret = I2C_VR_XFER_NAKED; } i2c_vr_master_complete(i2c, ret); } else if (isr & ISR_RWM) { /* * Read mode. We have just sent the address byte, and * now we must initiate the transfer. */ if (i2c->msg_ptr == i2c->msg->len - 1 && i2c->msg_idx == i2c->msg_num - 1) icr |= ICR_STOP | ICR_ACKNAK; icr |= ICR_ALDIE | ICR_TB; } else if (i2c->msg_ptr < i2c->msg->len) { /* * Write mode. Write the next data byte. */ writel(i2c->msg->buf[i2c->msg_ptr++], ®s->idbr); icr |= ICR_ALDIE | ICR_TB; /* * If this is the last byte of the last message, send * a STOP. */ if (i2c->msg_ptr == i2c->msg->len && i2c->msg_idx == i2c->msg_num - 1) icr |= ICR_STOP; } else if (i2c->msg_idx < i2c->msg_num - 1) { /* * Next segment of the message. */ i2c->msg_ptr = 0; i2c->msg_idx++; i2c->msg++; /* * If we aren't doing a repeated start and address, * go back and try to send the next byte. Note that * we do not support switching the R/W direction here. */ if (i2c->msg->flags & I2C_M_NOSTART) goto again; /* * Write the next address. */ writel(i2c_vr_addr_byte(i2c->msg), ®s->idbr); /* * And trigger a repeated start, and send the byte. */ icr &= ~ICR_ALDIE; icr |= ICR_START | ICR_TB; } else { if (i2c->msg->len == 0) { /* * Device probes have a message length of zero * and need the bus to be reset before it can * be used again. */ i2c_vr_reset(i2c); } i2c_vr_master_complete(i2c, 0); } i2c->icrlog[i2c->irqlogidx - 1] = icr; writel(icr, ®s->icr); show_state(i2c); }
static void sysrq_handle_showstate(int key) { show_state(); }
static inline void receive_chars(struct cnxt_serial *info, unsigned long status) { unsigned char ch; struct uart_regs *uart = info->uart; #if 0 // hack to receive chars by polling from anywhere struct tty_struct *tty = info->tty; if (!(info->flags & S_INITIALIZED)) return; #else struct tty_struct *tty = info->tty; if (!(info->flags & S_INITIALIZED)) return; #endif ch = (unsigned char)uart->fifo; if(info->is_cons) { if (ch == 0x10) { show_state(); show_free_areas(); show_buffers(); //show_net_buffers(); return; } else if (ch == 0x12) { HARD_RESET_NOW(); return; } } /* Look for kgdb 'stop' character, consult the gdb documentation * for remote target debugging and arch/sparc/kernel/sparc-stub.c * to see how all this works. */ if(!tty) { printk("no tty\n"); goto clear_and_exit; } #if 0 if (tty->flip.count >= TTY_FLIPBUF_SIZE) queue_task_irq_off(&tty->flip.tqueue, &tq_timer); tty->flip.count++; if(status & US_PARE) *tty->flip.flag_buf_ptr++ = TTY_PARITY; else if(status & US_OVRE) *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; else if(status & US_FRAME) *tty->flip.flag_buf_ptr++ = TTY_FRAME; else *tty->flip.flag_buf_ptr++ = 0; #endif tty->flip.count++; *tty->flip.flag_buf_ptr++ = 0; *tty->flip.char_buf_ptr++ = ch; queue_task(&tty->flip.tqueue, &tq_timer); clear_and_exit: return; }