void vTestKernel3(void *pvAddress)
{
    char send_buf[BUF_SIZE];
    char recv_buf[BUF_SIZE];
    unsigned int rtn;
    char ch = 'A';
    while (1) {
        send_buf[0] = ch;
        send_buf[1] = '\0';
        ch = (char)((unsigned int)ch + 1);
        if(ch > 'Z') {
            ch = 'A';
        }
        rtn = wireless_send(send_buf);
        if (rtn > 0) {
            term_printf("<<<Task 3>>> sent by wifi: %s\r\n", send_buf);
            vTaskDelay(500 / portTICK_RATE_MS);
            rtn = wireless_recv(recv_buf, 1);
            if(rtn > 0) {
                term_printf("<<<Task 3>>> received: %s\r\n", recv_buf);
            }
            else {
                term_printf("<<<Task 3>>> received nothing by wifi!\r\n");
            }
        }
        else {
            term_printf("<<<Task 3>>> failed to send data by wifi!\r\n");
        }
    }
}
示例#2
0
文件: mm.c 项目: gerow/redwood
int mm_init(multiboot_info_t *boot_info) {
  if (!(boot_info->flags & MULTIBOOT_INFO_MEMORY)) {
    term_print("Boot info memory entries invalid, bailing out\n");
    return -1;
  }
  term_printf("Upper memory %dk\n", boot_info->mem_upper);
  term_printf("Lower memory %dk\n", boot_info->mem_lower);

  if (!(boot_info->flags & MULTIBOOT_INFO_MEM_MAP)) {
    term_print("Boot info mem map invalid, bailing out\n");
    return -1;
  }
  multiboot_memory_map_t *mmap = (void *)boot_info->mmap_addr;
  term_print("Memory map:\n");
  while ((multiboot_uint32_t)mmap < boot_info->mmap_addr + boot_info->mmap_length) {
    const char *type =
      mmap->type == MULTIBOOT_MEMORY_AVAILABLE ? "Available" : "Reserved ";
    /* 
     * These are technically 64-bit values, so we need to convert them before passing 
     * them to printf
     */
    uint32_t start = mmap->addr;
    uint32_t len = mmap->len;
    term_printf("  %s [0x%lx - 0x%lx]\n", type, start, start + len);
    mmap = (void *)((uintptr_t)mmap + mmap->size + 4);
  }

  return 0;
}
示例#3
0
文件: pata.c 项目: orodley/studix
void init_ata()
{
	// First, check for a floating bus (no drives attached)
	uint8_t pri_status = inb(PRIMARY_BASE   + COM_STAT);
	uint8_t sec_status = inb(SECONDARY_BASE + COM_STAT);
	bool    primary_floating   = false;
	bool    secondary_floating = false;
	if (pri_status == 0xFF)
		primary_floating = true;
	if (sec_status == 0xFF)
		secondary_floating = true;

	// Both buses are floating
	if (primary_floating && secondary_floating) {
		term_puts("No drives attached! What's going on?");
		return;
	}

	// Non-0xFF values are not definitive; we need to do some more checks
	check_drive(PRIMARY_BASE,   SEL_MASTER);
	check_drive(PRIMARY_BASE,   SEL_SLAVE);
	check_drive(SECONDARY_BASE, SEL_MASTER);
	check_drive(SECONDARY_BASE, SEL_SLAVE);

	if (sel_base_port == 0) // We didn't find a (PATA) drive
		term_puts("No drives attached! What's going on?");
	else {
		term_printf("Found a drive!\nSelected drive is the %s on the %s bus\n",
				sel_master_or_slave == SEL_MASTER ? "master"  : "slave",
				sel_base_port == PRIMARY_BASE     ? "primary" : "secondary");
		term_printf("Max LBA value is %d\n", max_sector);
	}
}
示例#4
0
文件: conf.c 项目: lucky521/MixStuff
/* Parse configuration file */
void check_ini(char *path_ini)
{
  struct cnfnode *cn_root;
  struct cnfmodule *mod_ini;
  struct cnfresult *cnf_res;

  register_ini(NULL);
  mod_ini = find_cnfmodule("ini");
  cn_root = cnfmodule_parse_file(mod_ini, path_ini);

  if (cn_root == NULL) {
    term_printf ("Could not find INI file: %s\n", path_ini);
    return;
  }

  /* Parse configuration flags */
  set_bool_from_ini(cn_root, "general/trace_only_after_first_taint",
    &conf_trace_only_after_first_taint);
  set_bool_from_ini(cn_root, "general/log_external_calls",
    &conf_log_external_calls);
  set_bool_from_ini(cn_root, "general/write_ops_at_insn_end",
    &conf_write_ops_at_insn_end);
  set_bool_from_ini(cn_root, "general/save_state_at_trace_stop",
    &conf_save_state_at_trace_stop);
  set_bool_from_ini(cn_root, "tracing/tracing_table_lookup",
    &tracing_table_lookup);
  set_bool_from_ini(cn_root, "tracing/tracing_tainted_only",
    &conf_tainted_only);
  set_bool_from_ini(cn_root, "tracing/tracing_kernel",
    &conf_tracing_kernel_all);
  set_bool_from_ini(cn_root, "tracing/tracing_kernel_tainted",
    &conf_tracing_kernel_tainted);
  set_bool_from_ini(cn_root, "tracing/tracing_kernel_partial",
    &conf_tracing_kernel_partial);

  /* Parse network configuration */
  set_bool_from_ini(cn_root, "network/ignore_dns",
    &conf_ignore_dns);
  check_filter_conf(cn_root);
  print_nic_filter();


  /* Find hook configuration file */
  cnf_res = cnf_find_entry(cn_root, "function hooks/plugin_ini");
  if (cnf_res)
  strncpy(hook_plugins_filename, cnf_res->cnfnode->value, 255);
  hook_plugins_filename[255] = '\0';
  term_printf("Loading plugin options from: %s\n", hook_plugins_filename);

  /* Find hooks directory */
  cnf_res = cnf_find_entry(cn_root, "function hooks/plugin_directory");
  if (cnf_res) {
    strncpy(hook_dirname, cnf_res->cnfnode->value, 255);
    hook_dirname[255] = '\0';
  }
  term_printf("Loading plugins from: %s\n", hook_dirname);

  destroy_cnftree(cn_root);
}
示例#5
0
文件: heap.c 项目: orodley/studix
void print_block(Header *header, Footer *footer)
{
	term_printf("%X  <= %X =>  %X  <= %X =>  %X  <= %X =>  %X\n",
		header, sizeof(Header), (uintptr_t)header + sizeof(Header),
		header->size - sizeof(Header) - sizeof(Footer),
		footer, sizeof(Footer), (uintptr_t)header + header->size);
	term_printf("Footer says header at %p, end at %p\n",
		footer->header, (uintptr_t)footer + sizeof(Footer));
}
示例#6
0
文件: trace.c 项目: anhkgg/temu
/* Print the statistics variables */
void print_trace_stats() {
  term_printf("Number of instructions decoded: %ld\n", 
    tstats.insn_counter_decoded);
  term_printf("Number of operands decoded: %ld\n", 
    tstats.operand_counter);
  term_printf("Number of instructions written to trace: %ld\n",
    tstats.insn_counter_traced);
  term_printf("Number of tainted instructions written to trace: %ld\n",
    tstats.insn_counter_traced_tainted);
}
示例#7
0
文件: conf.c 项目: lucky521/MixStuff
void set_tainted_only(int state)
{
  if (state) {
    conf_tainted_only = 1;
    term_printf("Taint-only flag on.\n");
  }
  else {
    conf_tainted_only = 0;
    term_printf("Taint-only flag off.\n");
  }
}
示例#8
0
文件: conf.c 项目: lucky521/MixStuff
void set_ignore_dns(int state)
{
  if (state) {
    conf_ignore_dns = 1;
    term_printf("Ignore DNS flag on.\n");
  }
  else {
    conf_ignore_dns = 0;
    term_printf("Ignore DNS flag off.\n");
  }
}
示例#9
0
文件: conf.c 项目: lucky521/MixStuff
void set_kernel_all(int state)
{
  if (state) {
    conf_tracing_kernel_all = 1;
    term_printf("Kernel-all flag on.\n");
  }
  else {
    conf_tracing_kernel_all = 0;
    term_printf("Kernel-all flag off.\n");
  }
}
示例#10
0
文件: conf.c 项目: lucky521/MixStuff
void set_kernel_tainted(int state)
{
  if (state) {
    conf_tracing_kernel_tainted = 1;
    term_printf("Kernel-tainted flag on.\n");
  }
  else {
    conf_tracing_kernel_tainted = 0;
    term_printf("Kernel-tainted flag off.\n");
  }
}
示例#11
0
文件: conf.c 项目: lucky521/MixStuff
/* Print configuration variables */
void print_conf_vars()
{
  term_printf(
      "TABLE_LOOKUP: %d\n"
      "TRACE_AFTER_FIRST_TAINT: %d\n"
      "LOG_EXTERNAL_CALLS: %d\n"
      "WRITE_OPS_AT_INSN_END: %d\n"
      "SAVE_STATE_AT_TRACE_STOP: %d\n"
      "PROTOS_IGNOREDNS: %d\n"
      "TAINTED_ONLY: %d\n" 
      "TRACING_KERNEL_ALL: %d\n"
      "TRACING_KERNEL_TAINTED: %d\n" 
      "TRACING_KERNEL_PARTIAL: %d\n",
      tracing_table_lookup,
      conf_trace_only_after_first_taint,
      conf_log_external_calls,
      conf_write_ops_at_insn_end,
      conf_save_state_at_trace_stop,
      conf_ignore_dns, 
      conf_tainted_only,
      conf_tracing_kernel_all,
      conf_tracing_kernel_tainted,
      conf_tracing_kernel_partial
  );
}
示例#12
0
文件: errormsg.c 项目: fachat/XD2031
void set_error_tsd(errormsg_t *err, uint8_t errornum, uint8_t track, uint8_t sector, int8_t drive) {
	char *msg = (char *)err->error_buffer;
	err->errorno = errornum;
  	err->readp = 0;

	rom_sprintf(msg, IN_ROM_STR("%2.2d,"), errornum);	// error number
	rom_strcat(msg, errmsg(errornum));			// error message from flash memory
	if (drive < 0) {
		rom_sprintf(msg + strlen(msg), IN_ROM_STR(",%2.2d,%2.2d\r"), track%100, sector%100); // track & sector
	} else {
		rom_sprintf(msg + strlen(msg), IN_ROM_STR(",%2.2d,%2.2d,%1.1d\r"), track, sector, drive); // track & sector & drive
	}

	if (errornum != CBM_ERROR_OK         &&
	    errornum != CBM_ERROR_DOSVERSION &&
	    errornum != CBM_ERROR_SCRATCHED) {
		led_set(ERROR);
		term_printf("Setting status to: %s\n", err->error_buffer);
	} else {
		led_set(OFF); // same as idle, but clears error
	}

#ifdef DEBUG_ERROR
debug_printf("Set status to: %s\n", err->error_buffer);
#endif
}
示例#13
0
void vTestKernel2(void *pvAddress)
{
    while (1) {
        term_printf("Task 2 is running.\r\n");
        vTaskDelay(6000 / portTICK_RATE_MS);
    }
}
示例#14
0
static void term_show_prompt2(void)
{
    term_printf("%s", term_prompt);
    term_flush();
    term_last_cmd_buf_index = 0;
    term_last_cmd_buf_size = 0;
    term_esc_state = IS_NORM;
}
void vTestKernel4(void *pvAddress)
{
    float sen, mem1, mem2, core;
    int gain_ctrl = 0;
    int rtn;
    while (1) {
        rtn = read_pow(gain_ctrl, &sen, &mem1, &mem2, &core);
        if (rtn == 0) {
            term_printf("<<<Task 4>>> failed to read power sensors!\r\n");
        }
        else {
            term_printf("<<<Task 4>>> power_sensor reading ---gain_ctrl: %d, sen: %f, mem1: %f, mem2: %f, core: %f\r\n", gain_ctrl, sen, mem1, mem2, core);
        }
        vTaskDelay(5000 / portTICK_RATE_MS);
        gain_ctrl = 1 - gain_ctrl;
    }
}
示例#16
0
static void wav_capture_info (void *opaque)
{
    WAVState *wav = opaque;
    char *path = wav->path;

    term_printf ("Capturing audio(%d,%d,%d) to %s: %d bytes\n",
                 wav->freq, wav->bits, wav->nchannels,
                 path ? path : "<not available>", wav->bytes);
}
示例#17
0
文件: conf.c 项目: lucky521/MixStuff
/* Parse boolean from configuration file */
static void set_bool_from_ini(struct cnfnode *cn_root, char *entry, int* flag) {
  struct cnfresult *cnf_res;

  cnf_res = cnf_find_entry(cn_root, entry);
  if (cnf_res) {
    if (strcasecmp(cnf_res->cnfnode->value, "yes") == 0) {
      *flag = 1;
      term_printf("%s is enabled.\n",entry);
    }
    else if (strcasecmp(cnf_res->cnfnode->value, "no") == 0) {
      *flag = 0;
      term_printf("%s is disabled.\n",entry);
    }
    else {
      term_printf("%s has incorrect value. Try <yes|no>.\n",entry);
    }
  }

}
示例#18
0
文件: conditions.c 项目: anhkgg/temu
int tc_address_stop_hook(void *opaque)
{
  term_printf("tc_address_stop_hook(*) called\n");
  if ((tracing_kernel_all() ||
    (temu_plugin->monitored_cr3 == TEMU_cpu_cr[3])) &&
    (tc_stop_counter++ == tc_stop_at))
  {
    tracing_start_condition = 0;
    if (gettimeofday(&trace_stop_time, 0) == 0) {
      term_printf("Trace ending time: %ld.%ld\n", trace_start_time.tv_sec, trace_start_time.tv_usec);
      term_printf("Total elapsed time: %ld usec\n",
      trace_stop_time.tv_sec*1000000 + trace_stop_time.tv_usec - trace_start_time.tv_sec*1000000 - trace_start_time.tv_usec);
    }
    /* remove the hook */
    hookapi_remove_hook(tc_stop_hook_handle);
  }

  return 0;
}
示例#19
0
void vTestKernel(void *pvAddress)
{
    char line[BUF_SIZE];
    long type, id;
    while (1) {
        inet_printf("Input type and id for sensor reading.\r\n");
        inet_gets(line, BUF_SIZE);
        sscanf(line, "%d %d", &type, &id);
        term_printf("sensor reading is: %d\r\n", sensor_read(type, id));
    }
}
示例#20
0
文件: avr.c 项目: fachat/XD2031
void fuse_info(void) {
	uint8_t lowfuse, hifuse, extfuse, lockfuse;

	cli();
	lowfuse = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
	hifuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
	extfuse = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
	lockfuse = boot_lock_fuse_bits_get(GET_LOCK_BITS);
	sei();
	term_printf("\r\nFuses: l=%02X h=%02X e=%02X l=%02X\r\n", lowfuse, hifuse, extfuse, lockfuse);
}
示例#21
0
文件: ext2.c 项目: orodley/studix
void ext2_init_fs()
{
	load_superblock();
	load_bgdt();

	// Read the root inode, just for fun
	Ext2_inode root_inode;
	read_inode(&root_inode, ROOT_INODE);
	term_printf(" / creation time = %d\n",   root_inode.creation_time);
	term_printf(" / uid           = %d\n",   root_inode.uid);
	term_printf(" / type & perms  = 0x%X\n", root_inode.type_and_permissions);
	term_printf(" / size          = %d\n",   root_inode.size);

	// Enumerate the files in it
	term_puts(" / files:");

	Ext2_file file;
	ext2_open_inode(ROOT_INODE, &file);
	Ext2_dirent dirent;

	while (ext2_next_dirent(&file, &dirent)) {
		term_printf("  inode %d, name `%s'\n", dirent.inode_num, dirent.name);
	}

	kfree(file.buf);

	// Look for a file
	term_putsn(" looking for file `/bar/baz/quux'...");
	uint32_t inode = ext2_look_up_path("/bar/baz/quux");
	if (inode == 0)
		term_puts(" not found");
	else
		term_printf(" found: inode = %d\n", inode);
}
示例#22
0
文件: migration.c 项目: CPFL/gxen
void do_info_migrate(void)
{
    MigrationState *s = current_migration;
    
    if (s) {
        term_printf("Migration status: ");
        switch (s->get_status(s)) {
        case MIG_STATE_ACTIVE:
            term_printf("active\n");
            break;
        case MIG_STATE_COMPLETED:
            term_printf("completed\n");
            break;
        case MIG_STATE_ERROR:
            term_printf("failed\n");
            break;
        case MIG_STATE_CANCELLED:
            term_printf("cancelled\n");
            break;
        }
    }
}
示例#23
0
文件: migration.c 项目: CPFL/gxen
void do_migrate(int detach, const char *uri)
{
    MigrationState *s = NULL;
    const char *p;

    if (strstart(uri, "tcp:", &p))
        s = tcp_start_outgoing_migration(p, max_throttle, detach);
#if !defined(WIN32)
    else if (strstart(uri, "exec:", &p))
        s = exec_start_outgoing_migration(p, max_throttle, detach);
#endif
    else
        term_printf("unknown migration protocol: %s\n", uri);

    if (s == NULL)
        term_printf("migration failed\n");
    else {
        if (current_migration)
            current_migration->release(current_migration);

        current_migration = s;
    }
}
示例#24
0
文件: conditions.c 项目: anhkgg/temu
int tc_address_start_hook(void *opaque)
{
  term_printf("tc_address_start_hook(*) called\n");
  if ((tracing_kernel_all() ||
    (temu_plugin->monitored_cr3 == TEMU_cpu_cr[3])) &&
    (tc_start_counter++ == tc_start_at))
  {
    tracing_start_condition = 1;
    tc_stop_counter = 0; // reset the tc_stop_counter at the execution saving
    /* remove the hook */
    hookapi_remove_hook(cond_func_hook_handle);
  }

  return 0;
}
示例#25
0
文件: conditions.c 项目: anhkgg/temu
void tc_address(uint32_t address)
{
  /* Check if there is a conflict with conf_trace_only_after_first_taint */
  if (conf_trace_only_after_first_taint) {
    term_printf("tc_address_start conflicts with "
      "conf_trace_only_after_first_taint\n"
      "Disabling conf_trace_only_after_first_taint\n");
    conf_trace_only_after_first_taint = 0;
  }
  /* add a hook at address */
  tracing_start_condition = 0;
  cond_func_hook_handle = hookapi_hook_function(0, address, tc_address_hook, 
		NULL, 0);
  cond_func_address = address;
}
示例#26
0
// initialize a runtime config block
void rtconfig_init_rtc(rtconfig_t *rtc, uint8_t devaddr) {
	// Default values
	rtc->device_address = devaddr;
	rtc->last_used_drive = 0;
	rtc->advanced_wildcards = false;
	rtc->errmsg_with_drive = true;

	if(nv_restore_config(rtc)) nv_save_config(rtc);

	if (num_rtcs < MAX_RTCONFIG) {
		rtcs[num_rtcs] = rtc;
		num_rtcs++;
	} else {
		term_printf("too many rtconfigs!\n");
	}
}
/*
 * Read sys file-system device file
 *
 * @line address of buffer to put file contents in
 * @line_size size of line
 * @device_file path to device file (printf format string)
 * @device_name device being opened (inserted into device_file)
 *
 * @return 0 failed, 1 succeeded ('line' contains data)
 */
static int usb_host_read_file(char *line, size_t line_size, const char *device_file, const char *device_name)
{
    FILE *f;
    int ret = 0;
    char filename[PATH_MAX];

    snprintf(filename, PATH_MAX, USBSYSBUS_PATH "/devices/%s/%s", device_name,
             device_file);
    f = fopen(filename, "r");
    if (f) {
        fgets(line, line_size, f);
        fclose(f);
        ret = 1;
    } else {
        term_printf("husb: could not open %s\n", filename);
    }

    return ret;
}
USBDevice *usb_host_device_open(const char *devname)
{
    int bus_num, addr;
    char product_name[PRODUCT_NAME_SZ];

    if (strstr(devname, "auto:")) {
        usb_host_auto_add(devname);
        return NULL;
    }

    if (usb_host_find_device(&bus_num, &addr, product_name, sizeof(product_name),
                             devname) < 0)
        return NULL;

    if (hostdev_find(bus_num, addr)) {
       term_printf("husb: host usb device %d.%d is already open\n", bus_num, addr);
       return NULL;
    }

    return usb_host_device_open_addr(bus_num, addr, product_name);
}
示例#29
0
文件: ext2.c 项目: orodley/studix
static void load_superblock()
{
	uint16_t buf[SUPERBLOCK_LENGTH / 2];

	// We can't just copy into superblock directly, as it isn't long enough
	read_abs_sectors(SUPERBLOCK_LBA, SUPERBLOCK_SECTORS, buf);
	memcpy(&superblock, buf, sizeof(Ext2_superblock));

	block_size = 1024 << superblock.log2_block_size;
	num_groups = superblock.total_blocks / superblock.blocks_per_group;

	// Print some interesting stuff to check it loaded correctly
	ASSERT(superblock.signature == EXT2_SIGNATURE);
	term_printf(" total inodes    = 0x%X\n", superblock.total_inodes);
	term_printf(" total blocks    = 0x%X\n", superblock.total_blocks);
	term_printf(" block size      = %b\n",   block_size);
	term_printf(" num blocks      = %d\n",   superblock.total_blocks);
	term_printf(" blocks/group    = %d\n",   superblock.blocks_per_group);
	term_printf(" inodes/group    = %d\n",   superblock.inodes_per_group);
	term_printf(" num groups      = %d\n",   num_groups);
}
示例#30
0
/* update the displayed command line */
static void term_update(void)
{
    int i, delta, len;

    if (term_cmd_buf_size != term_last_cmd_buf_size ||
        memcmp(term_cmd_buf, term_last_cmd_buf, term_cmd_buf_size) != 0) {
        for(i = 0; i < term_last_cmd_buf_index; i++) {
            term_printf("\033[D");
        }
        term_cmd_buf[term_cmd_buf_size] = '\0';
        if (term_is_password) {
            len = strlen(term_cmd_buf);
            for(i = 0; i < len; i++)
                term_printf("*");
        } else {
            term_printf("%s", term_cmd_buf);
        }
        term_printf("\033[K");
        memcpy(term_last_cmd_buf, term_cmd_buf, term_cmd_buf_size);
        term_last_cmd_buf_size = term_cmd_buf_size;
        term_last_cmd_buf_index = term_cmd_buf_size;
    }
    if (term_cmd_buf_index != term_last_cmd_buf_index) {
        delta = term_cmd_buf_index - term_last_cmd_buf_index;
        if (delta > 0) {
            for(i = 0;i < delta; i++) {
                term_printf("\033[C");
            }
        } else {
            delta = -delta;
            for(i = 0;i < delta; i++) {
                term_printf("\033[D");
            }
        }
        term_last_cmd_buf_index = term_cmd_buf_index;
    }
    term_flush();
}