static void save_v1(const struct ipt_ip *ip, const struct ipt_entry_match *match) { const struct ipt_multiport_v1 *multiinfo = (const struct ipt_multiport_v1 *)match->data; unsigned int i; switch (multiinfo->flags) { case IPT_MULTIPORT_SOURCE: printf("--sports "); break; case IPT_MULTIPORT_DESTINATION: printf("--dports "); break; case IPT_MULTIPORT_EITHER: printf("--ports "); break; } if (multiinfo->invert) printf("! "); for (i=0; i < multiinfo->count; i++) { printf("%s", i ? "," : ""); print_port(multiinfo->ports[i], ip->proto, 1); if (multiinfo->pflags[i]) { printf(":"); print_port(multiinfo->ports[++i], ip->proto, 1); } } printf(" "); }
static int typedef_test(IC_Env *env) { m_banan mbi, mbo; /* erlang_port */ m_apa mai; /* ETERM* */ m_apa mao = NULL; long tl; strcpy(mbi.node,"node"); mbi.id = 15; mbi.creation = 1; fprintf(stdout, "\n======== m_i_typedef test ======\n\n"); mai = erl_format("[{hej, 1, 23}, \"string\", {1.23, 45}]"); tl = m_i_typedef_test(NULL, mai, &mbi, &mao, &mbo, env); CHECK_EXCEPTION(env); RETURN_IF_OK(erl_match(mai, mao) && cmp_port(&mbi, &mbo) && tl == 4711); if (!erl_match(mai, mao)) { fprintf(stdout, " out parameter error (term), sent:\n"); print_term(mai); fprintf(stdout, "got:\n"); print_term(mao); } if (!cmp_port(&mbi, &mbo)) { fprintf(stdout, " out parameter error (port), sent:\n"); print_port(&mbi); fprintf(stdout, "got:\n"); print_port(&mbo); } if (tl != 4711) { fprintf(stdout, " result error, sent: 4711, got %ld\n", tl); } erl_free_term(mai); erl_free_term(mao); return -1; }
/* Saves the union ip6t_matchinfo in parsable form to stdout. */ static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match) { const struct ip6t_multiport *multiinfo = (const struct ip6t_multiport *)match->data; unsigned int i; switch (multiinfo->flags) { case IP6T_MULTIPORT_SOURCE: printf("--sports "); break; case IP6T_MULTIPORT_DESTINATION: printf("--dports "); break; case IP6T_MULTIPORT_EITHER: printf("--ports "); break; } for (i=0; i < multiinfo->count; i++) { printf("%s", i ? "," : ""); print_port(multiinfo->ports[i], ip->proto, 1); } printf(" "); }
static void print(const struct ipt_ip *ip, const struct ipt_entry_match *match, int numeric) { const struct ipt_multiport *multiinfo = (const struct ipt_multiport *)match->data; unsigned int i; printf("multiport "); switch (multiinfo->flags) { case IPT_MULTIPORT_SOURCE: printf("sports "); break; case IPT_MULTIPORT_DESTINATION: printf("dports "); break; case IPT_MULTIPORT_EITHER: printf("ports "); break; default: printf("ERROR "); break; } for (i=0; i < multiinfo->count; i++) { printf("%s", i ? "," : ""); print_port(multiinfo->ports[i], ip->proto, numeric); } printf(" "); }
static void print_info(struct cfg *cfg) { const char *c; int i; c = strrchr(cfg->controlfile, '/'); if (c != NULL) c = c + 1; else c = cfg->controlfile; if (cfg->verbose) { printf("%s: %s with %d ports and %d VLAN groups\n", c, cfg->info.es_name, cfg->info.es_nports, cfg->info.es_nvlangroups); printf("%s: ", c); printb("VLAN capabilities", cfg->info.es_vlan_caps, ETHERSWITCH_VLAN_CAPS_BITS); printf("\n"); } print_config(cfg); for (i=0; i<cfg->info.es_nports; i++) { print_port(cfg, i); } for (i=0; i<cfg->info.es_nvlangroups; i++) { print_vlangroup(cfg, i); } }
int main(int argc, char* argv[]) { int sockd, sockd2; socklen_t addrlen; struct sockaddr_in my_name, peer_name; int status; /* create a socket */ sockd = socket(AF_INET, SOCK_STREAM, 0); if (sockd == -1) { perror("Socket creation error"); exit(1); } if (argc < 2) { fprintf(stderr, "Usage: %s port_number\n", argv[0]); exit(1); } /* server address */ my_name.sin_family = AF_INET; my_name.sin_addr.s_addr = INADDR_ANY; my_name.sin_port = htons(atoi(argv[1])); status = bind(sockd, (struct sockaddr*)&my_name, sizeof(my_name)); if (status == -1) { perror("Binding error"); exit(1); } // find port print_port(sockd, my_name); status = listen(sockd, 5); if (status == -1) { perror("Listening error"); exit(1); } for(;;) { /* wait for a connection */ addrlen = sizeof(peer_name); sockd2 = accept(sockd, (struct sockaddr*)&peer_name, &addrlen); if (sockd2 == -1) { perror("Wrong connection"); exit(1); } write(sockd2, "Hello!\n", 7); close(sockd2); } return 0; }
/* Prints out the matchinfo. */ static void print(const struct ipt_ip *ip, const struct ipt_entry_match *match, int numeric) { const struct ipt_mport *minfo = (const struct ipt_mport *)match->data; unsigned int i; u_int16_t pflags = minfo->pflags; printf("mport "); switch (minfo->flags) { case IPT_MPORT_SOURCE: printf("sports "); break; case IPT_MPORT_DESTINATION: printf("dports "); break; case IPT_MPORT_EITHER: printf("ports "); break; default: printf("ERROR "); break; } for (i=0; i < IPT_MULTI_PORTS; i++) { if (pflags & (1<<i) && minfo->ports[i] == 65535) break; if (i == IPT_MULTI_PORTS-1 && minfo->ports[i-1] == minfo->ports[i]) break; printf("%s", i ? "," : ""); print_port(minfo->ports[i], ip->proto, numeric); if (pflags & (1<<i)) { printf(":"); print_port(minfo->ports[++i], ip->proto, numeric); } } printf(" "); }
static void print_ports(const char *name, uint16_t min, uint16_t max, int invert, int numeric) { const char *inv = invert ? "!" : ""; if (min != 0 || max != 0xFFFF || invert) { printf(" %s", name); if (min == max) { printf(":%s", inv); print_port(min, numeric); } else { printf("s:%s", inv); print_port(min, numeric); printf(":"); print_port(max, numeric); } } }
static void __multiport_print_v1(const struct xt_entry_match *match, int numeric, u_int16_t proto) { const struct xt_multiport_v1 *multiinfo = (const struct xt_multiport_v1 *)match->data; unsigned int i; printf("multiport "); switch (multiinfo->flags) { case XT_MULTIPORT_SOURCE: printf("sports "); break; case XT_MULTIPORT_DESTINATION: printf("dports "); break; case XT_MULTIPORT_EITHER: printf("ports "); break; default: printf("ERROR "); break; } if (multiinfo->invert) printf("! "); for (i=0; i < multiinfo->count; i++) { printf("%s", i ? "," : ""); print_port(multiinfo->ports[i], proto, numeric); if (multiinfo->pflags[i]) { printf(":"); print_port(multiinfo->ports[++i], proto, numeric); } } printf(" "); }
int main() { unsigned long mem_fd; volatile uint32_t *gpio_base; mem_fd = open("/dev/mem", O_RDWR); gpio_base = (uint32_t *)mmap(0, GPIO_SIZE, \ PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, GPIO_BASE); printf("PORT A:\n"); print_port(gpio_base, GPIO_PORTA); printf("PORT B:\n"); print_port(gpio_base, GPIO_PORTB); printf("PORT C:\n"); print_port(gpio_base, GPIO_PORTC); printf("PORT D:\n"); print_port(gpio_base, GPIO_PORTD); printf("PORT E:\n"); print_port(gpio_base, GPIO_PORTE); printf("PORT F:\n"); print_port(gpio_base, GPIO_PORTF); munmap((void *)gpio_base, GPIO_SIZE); close(mem_fd); return 0; }
static int port_test(IC_Env *env) { erlang_port porti = {"node", 5, 1}, porto, portr; fprintf(stdout, "\n======== m_i_port test ======\n\n"); portr = m_i_port_test(NULL, &porti, &porto, env); CHECK_EXCEPTION(env); RETURN_IF_OK(cmp_port(&porti, &porto) && cmp_port(&porti, &portr)); if (!cmp_port(&porti, &porto)) { fprintf(stdout, " out parameter error, sent:\n"); print_port(&porti); fprintf(stdout, "got:\n"); print_port(&porto); } if (!cmp_port(&porti, &portr)) { fprintf(stdout, " result error, sent:\n"); print_port(&porti); fprintf(stdout, "got:\n"); print_port(&portr); } return -1; }
static void newmode(struct cfg *cfg, enum cmdmode mode) { if (mode == cfg->mode) return; switch (cfg->mode) { case MODE_NONE: break; case MODE_PORT: print_port(cfg, cfg->unit); break; case MODE_VLANGROUP: print_vlangroup(cfg, cfg->unit); break; case MODE_REGISTER: case MODE_PHYREG: break; } cfg->mode = mode; }
static void print_info(struct cfg *cfg) { const char *c; int i; c = strrchr(cfg->controlfile, '/'); if (c != NULL) c = c + 1; else c = cfg->controlfile; if (cfg->verbose) printf("%s: %s with %d ports and %d VLAN groups\n", c, cfg->info.es_name, cfg->info.es_nports, cfg->info.es_nvlangroups); for (i=0; i<cfg->info.es_nports; i++) { print_port(cfg, i); } for (i=0; i<cfg->info.es_nvlangroups; i++) { print_vlangroup(cfg, i); } }
int16_t parse_cmd_io(char *cmd, char *output, uint16_t len) { (void) output; (void) len; #ifdef DEBUG_ECMD_PORTIO debug_printf("called parse_cmd_io_set with rest: \"%s\"\n", cmd); #endif volatile uint8_t *ioptr; uint8_t getorset; uint8_t iotypeoffset; uint8_t value; uint8_t mask = 0xFF; uint8_t sysmask = 0; /* skip spaces */ while (*cmd == ' ') cmd ++; /* test of 'g'et or 's'et */ switch (*cmd) { case 'g': getorset = 1; break; case 's': getorset = 0; break; default: return ECMD_ERR_PARSE_ERROR; } /* skip non spaces */ while (*cmd != ' ') cmd ++; /* skip spaces */ while (*cmd == ' ') cmd ++; /* skip first char of ddr,port,pin*/ cmd ++; /* test of p'i'n, d'd'r, p'o'rt or m'a'sk case insensitiv */ switch (*cmd & 0xDF) { case 'I' : iotypeoffset = 0; break; case 'D' : iotypeoffset = 1; break; case 'O' : iotypeoffset = 2; break; #ifndef TEENSY_SUPPORT case 'A' : iotypeoffset = 3; cmd += 3; break; #endif default: return ECMD_ERR_PARSE_ERROR; } cmd ++; /* skip the rest of registertyp and spaces*/ while (*cmd == ' ' || (*cmd & 0xDF) >= 'N') cmd ++; /* get the port number */ cmd = parse_hex(cmd, &value); if (cmd == 0) return ECMD_ERR_PARSE_ERROR; /* translate it to the portaddress */ switch (value) { #ifdef PINA case 0: ioptr = &PINA; sysmask = PORTIO_MASK_A; break; case 1: ioptr = &PINB; sysmask = PORTIO_MASK_B; break; case 2: ioptr = &PINC; sysmask = PORTIO_MASK_C; break; case 3: ioptr = &PIND; sysmask = PORTIO_MASK_D; break; #else case 0: ioptr = &PINB; sysmask = PORTIO_MASK_B; break; case 1: ioptr = &PINC; sysmask = PORTIO_MASK_C; break; case 2: ioptr = &PIND; sysmask = PORTIO_MASK_D; break; #endif default: return ECMD_ERR_PARSE_ERROR; } ioptr += iotypeoffset; #ifndef TEENSY_SUPPORT if (iotypeoffset == 3) return ECMD_FINAL(print_port(output, len, value, ~sysmask)); #endif if(getorset) /* when get request return the port value */ return ECMD_FINAL(print_port(output, len, value, *ioptr)); /* get register write value */ cmd = parse_hex(cmd, &value); if (cmd == 0) return ECMD_ERR_PARSE_ERROR; /* if a mask value present get it */ parse_hex(cmd, &mask); *ioptr = (*ioptr & ~(mask & sysmask)) | (value & mask & sysmask); return ECMD_FINAL_OK; }
int main(int argc, char *argv[]) { struct addrinfo hints; struct addrinfo *result, *rp; int sfd, s; struct sockaddr_storage peer_addr; socklen_t peer_addr_len; ssize_t nread; char buf[BUF_SIZE]; if (argc != 2) { fprintf(stderr, "Usage: %s port\n", argv[0]); exit(EXIT_FAILURE); } memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */ hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */ hints.ai_protocol = 0; /* Any protocol */ hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; s = getaddrinfo(NULL, argv[1], &hints, &result); if (s != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s)); exit(EXIT_FAILURE); } /* getaddrinfo() returns a list of address structures. Try each address until we successfully bind(2). If socket(2) (or bind(2)) fails, we (close the socket and) try the next address. family: 2(AF_INET), ai_socktype: 2(SOCK_DGRAM), ai_protocol: 17(IPPRORO_UDP) addr: 0.0.0.0 family: 10(AF_INET6), ai_socktype: 2, ai_protocol: 17 addr: :: family: 2, ai_socktype: 1(SOCK_STREAM), ai_protocol: 6(IPPROTO_TCP) addr: 0.0.0.0 family: 10, ai_socktype: 1, ai_protocol: 6 addr: :: */ for (rp = result; rp != NULL; rp = rp->ai_next) { char s[INET6_ADDRSTRLEN]; inet_ntop(rp->ai_family, get_in_addr((struct sockaddr *)rp->ai_addr), s, sizeof s); printf("family: %d, ai_socktype: %d, ai_protocol: %d addr: %s\n", rp->ai_family, rp->ai_socktype, rp->ai_protocol, s); sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sfd == -1) continue; if (bind(sfd, rp->ai_addr, rp->ai_addrlen) == 0) break; close(sfd); } print_port(sfd); if (rp == NULL) { /* No address succeeded */ fprintf(stderr, "Could not bind\n"); exit(EXIT_FAILURE); } freeaddrinfo(result); /* No longer needed */ /* Read datagrams and echo them back to sender */ for (;;) { peer_addr_len = sizeof(struct sockaddr_storage); nread = recvfrom(sfd, buf, BUF_SIZE, 0, (struct sockaddr *) &peer_addr, &peer_addr_len); if (nread == -1) continue; /* Ignore failed request */ char host[NI_MAXHOST], service[NI_MAXSERV]; s = getnameinfo((struct sockaddr *) &peer_addr, peer_addr_len, host, NI_MAXHOST, service, NI_MAXSERV, NI_NUMERICSERV); if (s == 0) printf("Received %zd bytes from %s:%s\n", nread, host, service); else fprintf(stderr, "getnameinfo: %s\n", gai_strerror(s)); if (sendto(sfd, buf, nread, 0, (struct sockaddr *) &peer_addr, peer_addr_len) != nread) fprintf(stderr, "Error sending response\n"); } }
static int print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp) { smbios_info_t info; int hex = opt_x; const char *s; if (opt_t != -1 && opt_t != sp->smbstr_type) return (0); /* skip struct if type doesn't match -t */ if (!opt_O && (sp->smbstr_type == SMB_TYPE_MEMCTL || sp->smbstr_type == SMB_TYPE_MEMMOD)) return (0); /* skip struct if type is obsolete */ if (g_hdr++ == 0 || !opt_s) oprintf(fp, "%-5s %-4s %s\n", "ID", "SIZE", "TYPE"); oprintf(fp, "%-5u %-4lu", (uint_t)sp->smbstr_id, (ulong_t)sp->smbstr_size); if ((s = smbios_type_name(sp->smbstr_type)) != NULL) oprintf(fp, " %s (type %u)", s, sp->smbstr_type); else if (sp->smbstr_type > SMB_TYPE_OEM_LO && sp->smbstr_type < SMB_TYPE_OEM_HI) oprintf(fp, " %s+%u (type %u)", "SMB_TYPE_OEM_LO", sp->smbstr_type - SMB_TYPE_OEM_LO, sp->smbstr_type); else oprintf(fp, " %u", sp->smbstr_type); if ((s = smbios_type_desc(sp->smbstr_type)) != NULL) oprintf(fp, " (%s)\n", s); else oprintf(fp, "\n"); if (opt_s) return (0); /* only print header line if -s specified */ if (smbios_info_common(shp, sp->smbstr_id, &info) == 0) { oprintf(fp, "\n"); print_common(&info, fp); } switch (sp->smbstr_type) { case SMB_TYPE_BIOS: oprintf(fp, "\n"); print_bios(shp, fp); break; case SMB_TYPE_SYSTEM: oprintf(fp, "\n"); print_system(shp, fp); break; case SMB_TYPE_BASEBOARD: oprintf(fp, "\n"); print_bboard(shp, sp->smbstr_id, fp); break; case SMB_TYPE_CHASSIS: oprintf(fp, "\n"); print_chassis(shp, sp->smbstr_id, fp); break; case SMB_TYPE_PROCESSOR: oprintf(fp, "\n"); print_processor(shp, sp->smbstr_id, fp); break; case SMB_TYPE_CACHE: oprintf(fp, "\n"); print_cache(shp, sp->smbstr_id, fp); break; case SMB_TYPE_PORT: oprintf(fp, "\n"); print_port(shp, sp->smbstr_id, fp); break; case SMB_TYPE_SLOT: oprintf(fp, "\n"); print_slot(shp, sp->smbstr_id, fp); break; case SMB_TYPE_OBDEVS: oprintf(fp, "\n"); print_obdevs(shp, sp->smbstr_id, fp); break; case SMB_TYPE_OEMSTR: case SMB_TYPE_SYSCONFSTR: oprintf(fp, "\n"); print_strtab(shp, sp->smbstr_id, fp); break; case SMB_TYPE_LANG: oprintf(fp, "\n"); print_lang(shp, sp->smbstr_id, fp); break; case SMB_TYPE_EVENTLOG: oprintf(fp, "\n"); print_evlog(shp, sp->smbstr_id, fp); break; case SMB_TYPE_MEMARRAY: oprintf(fp, "\n"); print_memarray(shp, sp->smbstr_id, fp); break; case SMB_TYPE_MEMDEVICE: oprintf(fp, "\n"); print_memdevice(shp, sp->smbstr_id, fp); break; case SMB_TYPE_MEMARRAYMAP: oprintf(fp, "\n"); print_memarrmap(shp, sp->smbstr_id, fp); break; case SMB_TYPE_MEMDEVICEMAP: oprintf(fp, "\n"); print_memdevmap(shp, sp->smbstr_id, fp); break; case SMB_TYPE_SECURITY: oprintf(fp, "\n"); print_hwsec(shp, fp); break; case SMB_TYPE_BOOT: oprintf(fp, "\n"); print_boot(shp, fp); break; case SMB_TYPE_IPMIDEV: oprintf(fp, "\n"); print_ipmi(shp, fp); break; case SMB_TYPE_OBDEVEXT: oprintf(fp, "\n"); print_obdevs_ext(shp, sp->smbstr_id, fp); break; case SUN_OEM_EXT_PROCESSOR: oprintf(fp, "\n"); print_extprocessor(shp, sp->smbstr_id, fp); break; case SUN_OEM_EXT_PORT: oprintf(fp, "\n"); print_extport(shp, sp->smbstr_id, fp); break; case SUN_OEM_PCIEXRC: oprintf(fp, "\n"); print_pciexrc(shp, sp->smbstr_id, fp); break; case SUN_OEM_EXT_MEMARRAY: oprintf(fp, "\n"); print_extmemarray(shp, sp->smbstr_id, fp); break; case SUN_OEM_EXT_MEMDEVICE: oprintf(fp, "\n"); print_extmemdevice(shp, sp->smbstr_id, fp); break; default: hex++; } if (hex) print_bytes(sp->smbstr_data, sp->smbstr_size, fp); else oprintf(fp, "\n"); return (0); }
void debugger(void) { extern u_int history[3]; extern int irq0_pending; static int in_debugger = 0; char buf[80], buf2[80], reg[4]; u_int i, j, k; if (in_debugger) return; in_debugger ++; no_exceptions = 1; #if 0 char *textbuf; textbuf = (char*)malloc(TEXT_SIZE); if (!textbuf) { leaveemu(ERR_MEM); } memcpy(textbuf, SCR_STATE.virt_address, TEXT_SIZE); #endif push_debug_flags(); DEBUG_OFF(); for(;;) { printf("\ndbg> "); if (fgets(buf, 80, stdin) == NULL) leaveemu(0); buf[strlen(buf)-1] = 0; /* kill \n */ if (*buf==0) { continue; } else if (!strcmp(buf, "help")) { usage(); } else if (!strcmp(buf, "r")) { show_regs(0, 0); } else if (!strcmp(buf, "logue")) { printf("prologue: 0x%08x\n", UAREA.u_entprologue); printf("epilogue: 0x%08x\n", UAREA.u_entepilogue); } else if (!strcmp(buf, "exc")) { printf("current exception: #0x%x, 0x%x\n", vm86s.trapno, vm86s.err); printf("pending guest exception: "); if (vmstate.exc) printf("#0x%x, 0x%x\n", vmstate.exc_vect, vmstate.exc_erc); else printf("none\n"); } else if (!strcmp(buf, "cr")) { show_cregs(); } else if (!strcmp(buf, "g")) { REG(eflags) &= ~TF_MASK; break; } else if (!strcmp(buf, "q") || !strcmp(buf, "quit")) { leaveemu(0); } else if (!strcmp(buf, "disks")) { print_disks(); } else if (!strcmp(buf, "ptmap")) { /* everything is in k to avoid overflows */ u_int granularity = 4*1024; u_int width = 64; printf("granularity: 0x%08x\n", granularity*1024); for (i=0; i < (4*1024*1024)/(width*granularity); i++) { u_int start = i*width*granularity; printf("0x%08x ", start*1024); for (j=0; j<width; j++) { int gp = 0, hp = 0; for (k=0; k < granularity/NBPG; k++) { u_int pte, err=0; pte = sys_read_pte(k*NBPG + (j*granularity + i*width*granularity)*1024, 0, vmstate.eid, &err); if (err == -E_NOT_FOUND) { err = pte = 0; } if (err == 0) { if (pte&1) { if (pte & PG_GUEST) gp = 1; else hp = 1; } } } if (!gp && !hp) printf("-"); else if (gp && hp) printf("+"); else if (gp && !hp) printf("g"); else printf("h"); } printf("\n"); } #if 0 } else if (!strcmp(buf, "memmap")) { memcheck_dump(); #endif } else if (sscanf(buf, "port %x", &i) == 1) { print_port(i); } else if (sscanf(buf, "int %x", &i) == 1) { pop_debug_flags(); push_debug_flags(); no_exceptions = 0; do_int(i); no_exceptions = 1; DEBUG_OFF(); } else if (sscanf(buf, "gdt %x", &i) == 1) { struct descr *sd; if (set_get_any(&vmstate.g_gdt_base, (u_int*)&sd)) { printf("no gdt is defined\n"); continue; } print_dt_entry(i, sd); } else if (sscanf(buf, "idt %x", &i) == 1) { print_dt_entry(i, (struct descr *)vmstate.g_idt_base); } else if (sscanf(buf, "ro %x", &i) == 1) { protect_range(PGROUNDDOWN(i), NBPG); } else if (sscanf(buf, "rw %x", &i) == 1) { unprotect_range(PGROUNDDOWN(i), NBPG); } else if (!strcmp(buf, "history")) { printf("most recent trap eip: %x %x %x\n", history[2], history[1], history[0]); } else if (!strcmp(buf, "irq")) { struct gate_descr *sg = (struct gate_descr *)vmstate.g_idt_base + hardware_irq_number(0); for (i=0; i<16; i++) { printf("irq %2d %s, handled by idt[%2d], function @ 0x%08x\n", i, irq_disabled(i) ? "disabled" : " enabled", hardware_irq_number(i), GATE_OFFSET(sg+i)); } } else if (sscanf(buf, "dump %x:%x %x", &i, &j, &k) == 2) { dump_memory((i<<4)+j, k); } else if (sscanf(buf, "dump %x:%x", &i, &j) == 2) { dump_memory((i<<4)+j, 0x80); } else if (sscanf(buf, "dump %x %x", &i, &j) == 2) { dump_memory(i, j); } else if (sscanf(buf, "dump %x", &i) == 1) { dump_memory(i, 0x80); } else if (!strcmp(buf, "dump")) { dump_memory(dump_offset, 0x80); } else if (sscanf(buf, "search %x %79s", &i, buf2) == 2) { search_memory(i, buf2); } else if (!strcmp(buf, "debug on")) { pop_debug_flags(); DEBUG_ON(); push_debug_flags(); } else if (!strcmp(buf, "debug off")) { pop_debug_flags(); DEBUG_OFF(); push_debug_flags(); } else if (sscanf(buf, "pte %x", &i) == 1) { Bit32u host_pte = 0; if (! (vmstate.cr[0] & PG_MASK)) { printf("guest paging not enabled\n"); printf("guest_phys_to_host_phys(0x%08x) = 0x%08x\n", i, guest_phys_to_host_phys(i)); } else { Bit32u gpte = guest_pte(i); printf("guest cr3 0x%08x\n", vmstate.cr[3]); printf("guest 0x%08x -> 0x%08x\n", i, gpte); printf("guest_phys_to_host_phys(0x%08x) = 0x%08x\n", gpte & ~PGMASK, guest_phys_to_host_phys(gpte & ~PGMASK)); } get_host_pte(i, &host_pte); printf("host 0x%08x -> 0x%08x\n", i, host_pte); } else if (sscanf(buf, "gp2hp %x", &i) == 1) { printf("&vmstate.gp2hp[0] = %p, 0x%x mappings\n", vmstate.gp2hp, vmstate.ppages); if (i<vmstate.ppages) printf("gp2hp[%x] = 0x%08x\n", i, vmstate.gp2hp[i]); } else if (!strcmp(buf, "cr3")) { u_int cr3; Set *set = &vmstate.cr3; printf("cr3 register: 0x%08x\n", vmstate.cr[3]); printf("cr3 set : "); for(set_iter_init(set); set_iter_get(set, &cr3); set_iter_next(set)) { printf("0x%08x ", cr3); } printf("\n"); } else if (!strcmp(buf, "dt")) { print_dt_mappings(); printf("h gdt base:lim 0x%08x:0x%04x\n", vmstate.h_gdt_base, vmstate.h_gdt_limit); printf("h idt base:lim 0x%08x:0x%04x\n", vmstate.h_idt_base, vmstate.h_idt_limit); } else if (!strcmp(buf, "memory")) { printf("0x%08x real physical pages (%3d megs)\n", PHYSICAL_PAGES, PHYSICAL_MEGS_RAM); printf("0x%08x fake physical pages (%3d megs)\n", vmstate.ppages, config.phys_mem_size/1024); #if 0 printf("Eavesdropping on Linux:\n"); printf("RAM %dk\n", *((Bit32u*)0x901e0)); printf("pointing device? 0x%x\n", *((Bit16u*)0x901ff)); printf("APM? 0x%x\n", *((Bit16u*)0x90040)); #endif ASSERT(vmstate.ppages == config.phys_mem_size*1024/NBPG); } else if (sscanf(buf, "%2s=%x", reg, &i) == 2 || sscanf(buf, "%3s=%x", reg, &i) == 2) { int r = reg_s2i(reg); if (r == -1) { printf("unknown register\n"); } else if (r==14) { REG(eip) = i; } else if (r<=REGNO_EDI) { set_reg(r, i, 4); /* normal regs */ } else { set_reg(r, i, 2); /* segment regs */ } } else { printf("huh?\n"); } } pop_debug_flags(); #if 0 if (debug_flags == 0) memcpy(SCR_STATE.virt_address, textbuf, TEXT_SIZE); free(textbuf); #endif REG(eflags) |= RF; in_debugger --; no_exceptions = 0; irq0_pending = 0; }
static void print_port_and_subs(snd_seq_t *seq, snd_seq_client_info_t *cinfo, snd_seq_port_info_t *pinfo, int count) { print_port(seq, cinfo, pinfo, count); list_subscribers(seq, snd_seq_port_info_get_addr(pinfo)); }