Exemplo n.º 1
0
static int cmd_cmdline(int argc, const cmd_args *argv, uint32_t flags) {
    if (argc == 1) {
        char cmdline_buf[DEBUG_CMDLINE_MAX];
        memset(cmdline_buf, 0, DEBUG_CMDLINE_MAX);
        const char* cmdline = cmdline_get(NULL);
        for (size_t i = 0; i < DEBUG_CMDLINE_MAX; i++) {
            if (cmdline[i] == '\0') {
                if (cmdline[i+1] == '\0') {
                    break;
                }
                cmdline_buf[i] = ' ';
            } else {
                cmdline_buf[i] = cmdline[i];
            }
        }
        printf("cmdline: %s\n", cmdline_buf);
    } else {
        const char* key = argv[1].str;
        const char* val = cmdline_get(key);
        if (!val) {
            printf("cmdline: %s not found\n", key);
        } else {
            printf("cmdline: %s=%s\n", key, val);
        }
    }

    return 0;
}
Exemplo n.º 2
0
/* The Main Interface Launcher */
int launch_gfmgui(void)
{
    GladeXML *xml;
    GtkWidget *widget;

    // Load the GFM Dialog from gfm.glade
    xml = glade_xml_new(paths_build_glade("gfm.glade"), "gfm_dbox", NULL);

    // Glade File Error
    if (!xml)
        g_error("Failure GFM GUI (%s)!\n", __FILE__);
		
    // Connect The Symbols
    glade_xml_signal_autoconnect(xml);
		
    // Retrieve the dialog widget
    widget = glade_xml_get_widget(xml, "gfm_dbox");

    // Global Widget Access
	gfm_widget.tree = glade_xml_get_widget(xml, "treeview1");
	gfm_widget.model = glade_xml_get_widget(xml, "label6");
	gfm_widget.entries = glade_xml_get_widget(xml, "label7");
	gfm_widget.comment = glade_xml_get_widget(xml, "button1");
	gfm_widget.ram = glade_xml_get_widget(xml, "label9");
	gfm_widget.flash = glade_xml_get_widget(xml, "label10");
	gfm_widget.save = glade_xml_get_widget(xml, "toolbutton3");
	//gfm_widget.test = glade_xml_get_widget(xml, "label11");
	gfm_widget.pbar = glade_xml_get_widget(xml, "progressbar1");

	// Inits global vars
	enable_save(FALSE);
	enable_tree(FALSE);

	// Show the Widget
	ctree_init();
    gtk_widget_show(widget);

	if(cmdline_get() != NULL)
		on_open_clicked(NULL, (gpointer)cmdline_get());

    // Return
    return 0;
}
Exemplo n.º 3
0
int main(int ac, char** av)
{
  grid_t g;
  state_t state;
  bfs_t b;
  cmdline_t cmd;
  rulset_t rulset;
  const rule_t* ru;
  unsigned int i;

  grid_init(&g, 5);
  state_init(&state);
  rulset_init(&rulset);

  /* start with first rule */
  state.cur_rule = rulset.rules;

  while (state.is_done == 0)
  {
    cmdline_get(&cmd);

    switch (cmd.op)
    {
    case CMDLINE_OP_PUT_BLOCK:
      if (state.items[state.cur_color])
      {
	if (*grid_at(&g, cmd.x, cmd.y) == BLOCK_COLOR_INVALID)
        {
	  *grid_at(&g, cmd.x, cmd.y) = state.cur_color;
	  --state.items[state.cur_color];
	}
      }
      break ;

    case CMDLINE_OP_GET_BLOCK:
      if (*grid_at(&g, cmd.x, cmd.y) != BLOCK_COLOR_INVALID)
      {
	++state.items[*grid_at(&g, cmd.x, cmd.y)];
	*grid_at(&g, cmd.x, cmd.y) = BLOCK_COLOR_INVALID;
      }
      break ;

    case CMDLINE_OP_SEL_COLOR:
      state.cur_color = cmd.color;
      break ;

    case CMDLINE_OP_SEL_RULE:
      ru = rulset.rules;
      for (i = 0; ru && (i < cmd.rule); ++i, ru = ru->next) ;
      state.cur_rule = (rule_t*)ru;
      if (ru == NULL) { printf("no such rule\n"); break ; }
      goto eval_rule_case;
      break ;

    case CMDLINE_OP_LIST_RULES:
      ru = rulset.rules;
      for (i = 0; ru; ++i, ru = ru->next)
	printf("[%u] %u\n", i, ru->outcome);
      break ;

    case CMDLINE_OP_LIST_ITEMS:
      for (i = 0; i < 3; ++i) printf(" %u", state.items[i]);
      printf("\n");
      break ;

    case CMDLINE_OP_EVAL_RULE:
    eval_rule_case:
      if (state.cur_rule == NULL)
      {
	printf("no rule selected\n");
	break ;
      }

      bfs_do(&b, &g, state.cur_rule);
      state.cur_dist = b.dist;
      printf("distance: %u\n", state.cur_dist);

      break ;

    case CMDLINE_OP_PRINT_GRID:
      grid_print(&g);
      break ;

    case CMDLINE_OP_QUIT:
      state.is_done = 1;
      break ;

    case CMDLINE_OP_INVALID:
    default:
      break ;
    }
  }

  grid_fini(&g);
  rulset_fini(&rulset);

  return 0;
}
Exemplo n.º 4
0
static void pc_init_timer(uint level) {
    const struct x86_model_info* cpu_model = x86_get_model();

    constant_tsc = false;
    if (x86_vendor == X86_VENDOR_INTEL) {
        /* This condition taken from Intel 3B 17.15 (Time-Stamp Counter).  This
         * is the negation of the non-Constant TSC section, since the Constant
         * TSC section is incomplete (the behavior is architectural going
         * forward, and modern CPUs are not on the list). */
        constant_tsc = !((cpu_model->family == 0x6 && cpu_model->model == 0x9) ||
                         (cpu_model->family == 0x6 && cpu_model->model == 0xd) ||
                         (cpu_model->family == 0xf && cpu_model->model < 0x3));
    }
    invariant_tsc = x86_feature_test(X86_FEATURE_INVAR_TSC);

    bool has_pvclock = pvclock_is_present();
    if (has_pvclock) {
        zx_status_t status = pvclock_init();
        if (status == ZX_OK) {
            invariant_tsc = pvclock_is_stable();
        } else {
            has_pvclock = false;
        }
    }

    bool has_hpet = hpet_is_present();
    if (has_hpet) {
        calibration_clock = CLOCK_HPET;
        const uint64_t hpet_ms_rate = hpet_ticks_per_ms();
        ASSERT(hpet_ms_rate <= UINT32_MAX);
        printf("HPET frequency: %" PRIu64 " ticks/ms\n", hpet_ms_rate);
        fp_32_64_div_32_32(&ns_per_hpet, 1000 * 1000, static_cast<uint32_t>(hpet_ms_rate));
        // Add 1ns to conservatively deal with rounding
        ns_per_hpet_rounded_up = u32_mul_u64_fp32_64(1, ns_per_hpet) + 1;
    } else {
        calibration_clock = CLOCK_PIT;
    }

    const char* force_wallclock = cmdline_get("kernel.wallclock");
    bool use_invariant_tsc = invariant_tsc && (!force_wallclock || !strcmp(force_wallclock, "tsc"));

    use_tsc_deadline = use_invariant_tsc &&
                       x86_feature_test(X86_FEATURE_TSC_DEADLINE);
    if (!use_tsc_deadline) {
        calibrate_apic_timer();
    }

    if (use_invariant_tsc) {
        calibrate_tsc(has_pvclock);

        // Program PIT in the software strobe configuration, but do not load
        // the count.  This will pause the PIT.
        outp(I8253_CONTROL_REG, 0x38);
        wall_clock = CLOCK_TSC;
    } else {
        if (constant_tsc || invariant_tsc) {
            // Calibrate the TSC even though it's not as good as we want, so we
            // can still let folks still use it for cheap timing.
            calibrate_tsc(has_pvclock);
        }

        if (has_hpet && (!force_wallclock || !strcmp(force_wallclock, "hpet"))) {
            wall_clock = CLOCK_HPET;
            hpet_set_value(0);
            hpet_enable();
        } else {
            if (force_wallclock && strcmp(force_wallclock, "pit")) {
                panic("Could not satisfy kernel.wallclock choice\n");
            }

            wall_clock = CLOCK_PIT;

            set_pit_frequency(1000); // ~1ms granularity

            uint32_t irq = apic_io_isa_to_global(ISA_IRQ_PIT);
            zx_status_t status = register_int_handler(irq, &pit_timer_tick, NULL);
            DEBUG_ASSERT(status == ZX_OK);
            unmask_interrupt(irq);
        }
    }

    printf("timer features: constant_tsc %d invariant_tsc %d tsc_deadline %d\n",
           constant_tsc, invariant_tsc, use_tsc_deadline);
    printf("Using %s as wallclock\n", clock_name[wall_clock]);
}