void show_mem(void) { int i, free = 0, total = 0, reserved = 0; int shared = 0, cached = 0; printk("Mem-info:\n"); show_free_areas(); printk("Free swap: %6dkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); i = max_mapnr; while (i-- > 0) { total++; if (PageReserved(mem_map+i)) reserved++; else if (PageSwapCache(mem_map+i)) cached++; else if (!atomic_read(&mem_map[i].count)) free++; else shared += atomic_read(&mem_map[i].count) - 1; } printk("%d pages of RAM\n", total); printk("%d reserved pages\n", reserved); printk("%d pages shared\n", shared); printk("%d pages swap cached\n",cached); printk("%ld pages in page table cache\n",pgtable_cache_size); printk("%d free pages\n", free); show_buffers(); #ifdef CONFIG_NET show_net_buffers(); #endif }
void show_mem(void) { int i,free = 0,total = 0,reserved = 0; int shared = 0; printk("Mem-info:\n"); show_free_areas(); printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); i = high_memory >> PAGE_SHIFT; while (i-- > 0) { total++; if (PageReserved(mem_map+i)) reserved++; else if (!mem_map[i].count) free++; else shared += mem_map[i].count-1; } printk("%d pages of RAM\n",total); printk("%d free pages\n",free); printk("%d reserved pages\n",reserved); printk("%d pages shared\n",shared); show_buffers(); #ifdef CONFIG_NET show_net_buffers(); #endif }
void show_mem(void) { struct sysinfo si; int i,free = 0,total = 0,reserved = 0; int shared = 0; si_swapinfo(&si); printk("Mem-info:\n"); show_free_areas(); printk("Free swap: %6ldkB\n", si.freeswap >> 10); i = MAP_NR(high_memory); while (i-- > 0) { total++; if (PageReserved(mem_map+i)) reserved++; else if (!mem_map[i].count) free++; else shared += mem_map[i].count-1; } printk("%d pages of RAM\n",total); printk("%d free pages\n",free); printk("%d reserved pages\n",reserved); printk("%d pages shared\n",shared); show_buffers(); #ifdef CONFIG_INET show_net_buffers(); #endif }
static void receive_chars(struct m68k_serial *info, 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(0); show_buffers(); /* show_net_buffers(); */ return; } else if (ch == 0x12) { /* ^R */ emergency_restart(); return; #endif /* CONFIG_MAGIC_SYSRQ */ } } if(!tty) goto clear_and_exit; 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; }
char *parse_next_string_field() { char *field = &entry->line_buf[0] + offset; int nscanned = sscanf(line + offset, "%s %n", field, &offset_delta); if (nscanned != 1) return NULL; offset += offset_delta; show_buffers(); return field; }
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; }
int main (int argc, char **argv) { int c; errno = 0; if (argc < 2) usage(argv); if (strcmp(argv[1], "report") == 0) { trace_report(argc, argv); exit(0); } else if (strcmp(argv[1], "snapshot") == 0) { trace_snapshot(argc, argv); exit(0); } else if (strcmp(argv[1], "hist") == 0) { trace_hist(argc, argv); exit(0); } else if (strcmp(argv[1], "mem") == 0) { trace_mem(argc, argv); exit(0); } else if (strcmp(argv[1], "listen") == 0) { trace_listen(argc, argv); exit(0); } else if (strcmp(argv[1], "split") == 0) { trace_split(argc, argv); exit(0); } else if (strcmp(argv[1], "restore") == 0) { trace_restore(argc, argv); exit(0); } else if (strcmp(argv[1], "stack") == 0) { trace_stack(argc, argv); exit(0); } else if (strcmp(argv[1], "check-events") == 0) { const char *tracing; int ret; struct pevent *pevent = NULL; struct plugin_list *list = NULL; while ((c = getopt(argc-1, argv+1, "+hN")) >= 0) { switch (c) { case 'h': default: usage(argv); break; case 'N': tracecmd_disable_plugins = 1; break; } } tracing = tracecmd_get_tracing_dir(); if (!tracing) { printf("Can not find or mount tracing directory!\n" "Either tracing is not configured for this " "kernel\n" "or you do not have the proper permissions to " "mount the directory"); exit(EINVAL); } pevent = pevent_alloc(); if (!pevent) exit(EINVAL); list = tracecmd_load_plugins(pevent); ret = tracecmd_fill_local_events(tracing, pevent); if (ret || pevent->parsing_failures) ret = EINVAL; tracecmd_unload_plugins(list, pevent); pevent_free(pevent); exit(ret); } else if (strcmp(argv[1], "record") == 0 || strcmp(argv[1], "start") == 0 || strcmp(argv[1], "extract") == 0 || strcmp(argv[1], "stop") == 0 || strcmp(argv[1], "stream") == 0 || strcmp(argv[1], "profile") == 0 || strcmp(argv[1], "restart") == 0 || strcmp(argv[1], "reset") == 0) { trace_record(argc, argv); exit(0); } else if (strcmp(argv[1], "stat") == 0) { trace_stat(argc, argv); exit(0); } else if (strcmp(argv[1], "options") == 0) { show_plugin_options(); exit(0); } else if (strcmp(argv[1], "show") == 0) { const char *buffer = NULL; const char *file = "trace"; const char *cpu = NULL; struct buffer_instance *instance = &top_instance; char cpu_path[128]; char *path; int snap = 0; int pipe = 0; int show_name = 0; int option_index = 0; int stop = 0; static struct option long_options[] = { {"tracing_on", no_argument, NULL, OPT_tracing_on}, {"current_tracer", no_argument, NULL, OPT_current_tracer}, {"buffer_size", no_argument, NULL, OPT_buffer_size_kb}, {"buffer_total_size", no_argument, NULL, OPT_buffer_total_size_kb}, {"ftrace_filter", no_argument, NULL, OPT_ftrace_filter}, {"ftrace_notrace", no_argument, NULL, OPT_ftrace_notrace}, {"ftrace_pid", no_argument, NULL, OPT_ftrace_pid}, {"graph_function", no_argument, NULL, OPT_graph_function}, {"graph_notrace", no_argument, NULL, OPT_graph_notrace}, {"cpumask", no_argument, NULL, OPT_cpumask}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; while ((c = getopt_long(argc-1, argv+1, "B:c:fsp", long_options, &option_index)) >= 0) { switch (c) { case 'h': usage(argv); break; case 'B': if (buffer) die("Can only show one buffer at a time"); buffer = optarg; instance = create_instance(optarg); if (!instance) die("Failed to create instance"); break; case 'c': if (cpu) die("Can only show one CPU at a time"); cpu = optarg; break; case 'f': show_name = 1; break; case 's': snap = 1; if (pipe) die("Can not have -s and -p together"); break; case 'p': pipe = 1; if (snap) die("Can not have -s and -p together"); break; case OPT_tracing_on: show_instance_file(instance, "tracing_on"); stop = 1; break; case OPT_current_tracer: show_instance_file(instance, "current_tracer"); stop = 1; break; case OPT_buffer_size_kb: show_instance_file(instance, "buffer_size_kb"); stop = 1; break; case OPT_buffer_total_size_kb: show_instance_file(instance, "buffer_total_size_kb"); stop = 1; break; case OPT_ftrace_filter: show_instance_file(instance, "set_ftrace_filter"); stop = 1; break; case OPT_ftrace_notrace: show_instance_file(instance, "set_ftrace_notrace"); stop = 1; break; case OPT_ftrace_pid: show_instance_file(instance, "set_ftrace_pid"); stop = 1; break; case OPT_graph_function: show_instance_file(instance, "set_graph_function"); stop = 1; break; case OPT_graph_notrace: show_instance_file(instance, "set_graph_notrace"); stop = 1; break; case OPT_cpumask: show_instance_file(instance, "tracing_cpumask"); stop = 1; break; default: usage(argv); } } if (stop) exit(0); if (pipe) file = "trace_pipe"; else if (snap) file = "snapshot"; if (cpu) { snprintf(cpu_path, 128, "per_cpu/cpu%d/%s", atoi(cpu), file); file = cpu_path; } if (buffer) { path = malloc(strlen(buffer) + strlen("instances//") + strlen(file) + 1); if (path) die("Failed to allocate instance path %s", file); sprintf(path, "instances/%s/%s", buffer, file); file = path; } if (show_name) { char *name; name = tracecmd_get_tracing_file(file); printf("%s\n", name); tracecmd_put_tracing_file(name); } show_file(file); if (buffer) free(path); exit(0); } else if (strcmp(argv[1], "list") == 0) { int events = 0; int tracer = 0; int options = 0; int funcs = 0; int buffers = 0; int clocks = 0; int plug = 0; int plug_op = 0; int flags = 0; int show_all = 1; int i; const char *arg; const char *funcre = NULL; const char *eventre = NULL; for (i = 2; i < argc; i++) { arg = NULL; if (argv[i][0] == '-') { if (i < argc - 1) { if (argv[i+1][0] != '-') arg = argv[i+1]; } switch (argv[i][1]) { case 'h': usage(argv); break; case 'e': events = 1; eventre = arg; show_all = 0; break; case 'B': buffers = 1; show_all = 0; break; case 'C': clocks = 1; show_all = 0; break; case 'F': flags |= SHOW_EVENT_FORMAT; break; case 'R': flags |= SHOW_EVENT_TRIGGER; break; case 'l': flags |= SHOW_EVENT_FILTER; break; case 'p': case 't': tracer = 1; show_all = 0; break; case 'P': plug = 1; show_all = 0; break; case 'O': plug_op = 1; show_all = 0; break; case 'o': options = 1; show_all = 0; break; case 'f': funcs = 1; funcre = arg; show_all = 0; break; default: fprintf(stderr, "list: invalid option -- '%c'\n", argv[optind][1]); usage(argv); } } } if (events) show_events(eventre, flags); if (tracer) show_tracers(); if (options) show_options(); if (plug) show_plugins(); if (plug_op) show_plugin_options(); if (funcs) show_functions(funcre); if (buffers) show_buffers(); if (clocks) show_clocks(); if (show_all) { printf("events:\n"); show_events(NULL, 0); printf("\ntracers:\n"); show_tracers(); printf("\noptions:\n"); show_options(); } exit(0); } else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "help") == 0) { usage(argv); } else { fprintf(stderr, "unknown command: %s\n", argv[1]); usage(argv); } return 0; }
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; }
int make_tux3(struct sb *sb) { struct inode *dir = &(struct inode){ .i_sb = sb, .i_mode = S_IFDIR | 0755, }; struct tux_iattr *iattr = &(struct tux_iattr){}; int err; err = clear_other_magic(sb); if (err) return err; trace("create inode table"); init_btree(itable_btree(sb), sb, no_root, &itable_ops); trace("create bitmap"); sb->bitmap = __tux_create_inode(dir, TUX_BITMAP_INO, iattr, 0); if (IS_ERR(sb->bitmap)) { err = PTR_ERR(sb->bitmap); goto eek; } assert(sb->bitmap->inum == TUX_BITMAP_INO); sb->bitmap->i_size = (sb->volblocks + 7) >> 3; /* should this?, tuxtruncate(sb->bitmap, (sb->volblocks + 7) >> 3); */ trace("reserve superblock"); /* Always 8K regardless of blocksize */ int reserve = 1 << (sb->blockbits > 13 ? 0 : 13 - sb->blockbits); for (int i = 0; i < reserve; i++) { block_t block = balloc_from_range(sb, i, 1, 1); if (block == -1) goto eek; trace("reserve %Lx", (L)block); // error ??? } trace("create version table"); sb->vtable = __tux_create_inode(dir, TUX_VTABLE_INO, iattr, 0); if (IS_ERR(sb->vtable)) { err = PTR_ERR(sb->vtable); goto eek; } assert(sb->vtable->inum == TUX_VTABLE_INO); trace("create atom dictionary"); sb->atable = __tux_create_inode(dir, TUX_ATABLE_INO, iattr, 0); if (IS_ERR(sb->atable)) { err = PTR_ERR(sb->atable); goto eek; } assert(sb->atable->inum == TUX_ATABLE_INO); sb->atomref_base = 1 << (40 - sb->blockbits); // see xattr.c sb->unatom_base = sb->atomref_base + (1 << (34 - sb->blockbits)); sb->atomgen = 1; // atom 0 not allowed, means end of atom freelist trace("create root directory"); struct tux_iattr root_iattr = { .mode = S_IFDIR | 0755, }; sb->rootdir = __tux_create_inode(dir, TUX_ROOTDIR_INO, &root_iattr, 0); if (IS_ERR(sb->rootdir)) { err = PTR_ERR(sb->rootdir); goto eek; } assert(sb->rootdir->inum == TUX_ROOTDIR_INO); if ((err = sync_super(sb))) goto eek; show_buffers(mapping(sb->bitmap)); show_buffers(mapping(sb->rootdir)); show_buffers(sb->volmap->map); return 0; eek: if (err) warn("eek, %s", strerror(-err)); iput(sb->bitmap); sb->bitmap = NULL; return err ? err : -ENOSPC; // just guess }
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; }
int main(int argc, char *argv[]) { unsigned abits = DATA_BTREE_BIT|CTIME_SIZE_BIT|MODE_OWNER_BIT|LINK_COUNT_BIT|MTIME_BIT; struct dev *dev = &(struct dev){ .bits = 8, .fd = open(argv[1], O_CREAT|O_RDWR, S_IRUSR|S_IWUSR) }; assert(!ftruncate(dev->fd, 1 << 24)); init_buffers(dev, 1 << 20, 0); struct sb *sb = rapid_sb(dev, .version = 0, .atomref_base = 1 << 10, .unatom_base = 1 << 11, .atomgen = 1); struct inode *inode = rapid_open_inode(sb, NULL, S_IFDIR | 0x666, .present = abits, .i_uid = 0x12121212, .i_gid = 0x34343434, .i_ctime = spectime(0xdec0debeadULL), .i_mtime = spectime(0xbadfaced00dULL)); inode->btree = (struct btree){ .root = { .block = 0xcaba1f00dULL, .depth = 3 } }; sb->atable = inode; for (int i = 0; i < 2; i++) { struct buffer_head *buffer = blockget(mapping(inode), tux_sb(inode->i_sb)->atomref_base + i); memset(bufdata(buffer), 0, sb->blocksize); blockput_dirty(buffer); } if (1) { warn("---- test positive and negative refcount carry ----"); use_atom(inode, 6, 1 << 15); use_atom(inode, 6, (1 << 15)); use_atom(inode, 6, -(1 << 15)); use_atom(inode, 6, -(1 << 15)); } warn("---- test atom table ----"); printf("atom = %Lx\n", (L)make_atom(inode, "foo", 3)); printf("atom = %Lx\n", (L)make_atom(inode, "foo", 3)); printf("atom = %Lx\n", (L)make_atom(inode, "bar", 3)); printf("atom = %Lx\n", (L)make_atom(inode, "foo", 3)); printf("atom = %Lx\n", (L)make_atom(inode, "bar", 3)); warn("---- test inode xattr cache ----"); int err; err = xcache_update(inode, 0x666, "hello", 5, 0); if (err) printf("err %d\n", err); err = xcache_update(inode, 0x777, "world!", 6, 0); if (err) printf("err %d\n", err); xcache_dump(inode); struct xattr *xattr = xcache_lookup(tux_inode(inode)->xcache, 0x777); if (!IS_ERR(xattr)) printf("atom %x => %.*s\n", xattr->atom, xattr->size, xattr->body); err = xcache_update(inode, 0x111, "class", 5, 0); if (err) printf("err %d\n", err); err = xcache_update(inode, 0x666, NULL, 0, 0); if (err) printf("err %d\n", err); err = xcache_update(inode, 0x222, "boooyah", 7, 0); if (err) printf("err %d\n", err); xcache_dump(inode); warn("---- test xattr inode table encode and decode ----"); char attrs[1000] = { }; char *top = encode_xattrs(inode, attrs, sizeof(attrs)); hexdump(attrs, top - attrs); printf("predicted size = %x, encoded size = %Lx\n", encode_xsize(inode), (L)(top - attrs)); inode->xcache->size = offsetof(struct xcache, xattrs); char *newtop = decode_attrs(inode, attrs, top - attrs); printf("predicted size = %x, xcache size = %x\n", decode_xsize(inode, attrs, top - attrs), inode->xcache->size); assert(top == newtop); xcache_dump(inode); free(inode->xcache); inode->xcache = NULL; warn("---- xattr update ----"); set_xattr(inode, "hello", 5, "world!", 6, 0); set_xattr(inode, "empty", 5, "zot", 0, 0); set_xattr(inode, "foo", 3, "foobar", 6, 0); xcache_dump(inode); warn("---- xattr remove ----"); // del_xattr(inode, "hello", 5); xcache_dump(inode); warn("---- xattr lookup ----"); for (int i = 0, len; i < 3; i++) { char *namelist[] = { "hello", "foo", "world" }, *name = namelist[i]; char data[100]; int size = get_xattr(inode, name, len = strlen(name), data, sizeof(data)); if (size < 0) printf("xattr %.*s not found (%s)\n", len, name, strerror(-size)); else printf("found xattr %.*s => %.*s\n", len, name, size, data); } warn("---- list xattrs ----"); int len = xattr_list(inode, attrs, sizeof(attrs)); printf("xattr list length = %i\n", xattr_list(inode, NULL, 0)); hexdump(attrs, len); warn("---- atom reverse map ----"); for (int i = 0; i < 5; i++) { unsigned atom = i, offset; struct buffer_head *buffer = blockread_unatom(inode, atom, &offset); loff_t where = from_be_u64(((be_u64 *)bufdata(buffer))[offset]); blockput_dirty(buffer); buffer = blockread(mapping(inode), where >> sb->blockbits); printf("atom %.3Lx at dirent %.4Lx, ", (L)atom, (L)where); hexdump(bufdata(buffer) + (where & sb->blockmask), 16); blockput(buffer); } warn("---- atom recycle ----"); set_xattr(inode, "hello", 5, NULL, 0, 0); show_freeatoms(sb); printf("got free atom %x\n", get_freeatom(inode)); printf("got free atom %x\n", get_freeatom(inode)); printf("got free atom %x\n", get_freeatom(inode)); warn("---- dump atom table ----"); dump_atoms(inode); show_buffers(inode->map); exit(0); }
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; }
void show_mem(void) { int i,free = 0,total = 0,reserved = 0; int shared = 0, cached = 0; struct task_struct *p; int highmem = 0; printk("Mem-info:\n"); show_free_areas(); printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); i = max_mapnr; while (i-- > 0) { total++; if (PageHighMem(mem_map+i)) highmem++; if (PageReserved(mem_map+i)) reserved++; else if (PageSwapCache(mem_map+i)) cached++; else if (!page_count(mem_map+i)) free++; else shared += atomic_read(&mem_map[i].count) - 1; } printk("%d pages of RAM\n",total); printk("%d pages of HIGHMEM\n", highmem); printk("%d free pages\n",free); printk("%d reserved pages\n",reserved); printk("%d pages shared\n",shared); printk("%d pages swap cached\n",cached); printk("%d pages in page table cache\n",(int)pgtable_cache_size); show_buffers(); printk("%-8s %3s %8s %8s %8s %9s %8s", "Process", "Pid", "Ctx", "Ctx<<4", "Last Sys", "pc", "task"); #ifdef CONFIG_SMP printk(" %3s", "CPU"); #endif /* CONFIG_SMP */ printk("\n"); for_each_task(p) { printk("%-8.8s %3d %8ld %8ld %8ld %c%08lx %08lx ", p->comm,p->pid, (p->mm)?p->mm->context:0, (p->mm)?(p->mm->context<<4):0, p->thread.last_syscall, (p->thread.regs)?user_mode(p->thread.regs) ? 'u' : 'k' : '?', (p->thread.regs)?p->thread.regs->nip:0, (ulong)p); { int iscur = 0; #ifdef CONFIG_SMP printk("%3d ", p->processor); if ( (p->processor != NO_PROC_ID) && (p == current_set[p->processor]) ) { iscur = 1; printk("current"); } #else if ( p == current ) { iscur = 1; printk("current"); } if ( p == last_task_used_math ) { if ( iscur ) printk(","); printk("last math"); } #endif /* CONFIG_SMP */ printk("\n"); } } }
int make_tux3(struct sb *sb) { int err; err = clear_other_magic(sb); if (err) return err; change_begin_atomic(sb); trace("create bitmap"); sb->bitmap = create_internal_inode(sb, TUX_BITMAP_INO, NULL); if (IS_ERR(sb->bitmap)) { err = PTR_ERR(sb->bitmap); goto error_change_end; } change_end_atomic(sb); /* Set fake backend mark to modify backend objects. */ tux3_start_backend(sb); err = reserve_superblock(sb); tux3_end_backend(); if (err) goto error; change_begin_atomic(sb); #if 0 trace("create version table"); sb->vtable = create_internal_inode(sb, TUX_VTABLE_INO, NULL); if (IS_ERR(sb->vtable)) { err = PTR_ERR(sb->vtable); goto error_change_end; } #endif trace("create atom dictionary"); sb->atable = create_internal_inode(sb, TUX_ATABLE_INO, NULL); if (IS_ERR(sb->atable)) { err = PTR_ERR(sb->atable); goto error_change_end; } trace("create root directory"); struct tux_iattr root_iattr = { .mode = S_IFDIR | 0755, }; sb->rootdir = create_internal_inode(sb, TUX_ROOTDIR_INO, &root_iattr); if (IS_ERR(sb->rootdir)) { err = PTR_ERR(sb->rootdir); goto error_change_end; } change_end_atomic(sb); err = sync_super(sb); if (err) goto error; show_buffers(mapping(sb->bitmap)); show_buffers(mapping(sb->rootdir)); show_buffers(sb->volmap->map); return 0; error_change_end: change_end_atomic(sb); error: tux3_err(sb, "eek, %s", strerror(-err)); iput(sb->bitmap); sb->bitmap = NULL; return err; } int tux3_init_mem(void) { return tux3_init_hole_cache(); } void tux3_exit_mem(void) { tux3_destroy_hole_cache(); }
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; }