Ejemplo n.º 1
0
static
void
show_results(ms_bitfield_info * output)
{
    int elements = ms_get_size(output); 
    int i = 0;
    
        
    /* Show banner */
    if ((no_results(output) != 0) && (flag_fb_showerrors == 0))
    {
        goto done;
    }   
    
    /* Show results */
    for (i = 0; i < elements; ++i)
    {       
        if ((ms_get_status(output, i) == 0) || (flag_fb_showerrors == 1))
        {   
            printf("[cpu%d/%s/%s/%d/%s/%s/%s/%s]: 0x%llx (%s) (%d)\n", 
            ms_get_cpu(output, i),
            ms_get_partnumber_string(output, i),
            ms_get_decode_string(output, i),
            ms_get_epl(output, i),
            ms_get_group_string(output, i),
            ms_get_register_string(output, i),                          
            ms_get_stamp(output, i),            
            ms_get_bitfield_string(output, i),
            ms_get_value(output, i),
            ms_get_description_string(output, i),
            ms_get_status(output, i));
        }
    }
done:
    
    return;
}
Ejemplo n.º 2
0
static void
prepare_for_new_results(Boolean clear)
{
    results_not_found = False;
    const config_t *conf = config();

    clear_menu(clear);

    choices_cnt = g_list_length(results);

    if (choices_cnt == 0) {
        no_results();
    }

    list_items = (ITEM**) calloc(choices_cnt + 1, sizeof(ITEM*));

    for (int i = 0; i < choices_cnt; i++) {
        if (results_not_found) {
            if (query_len == 0) {
                list_items[i] = new_item("Start typing to search", "");
            } else {
                list_items[i] = new_item("No results, sorry", "");
            }
        } else {
            GList *l = g_list_nth(results, i);
            char *path = l->data;

            char *name = g_path_get_basename(path);
            names = g_list_prepend(names, name);

            if (conf->section_main->numeric_shortcuts) {
                if (i < 10) {
                    list_items[i] = new_item(digits[i], name);
                }
                else
                    list_items[i] = new_item(" ", name);
            } else {
                list_items[i] = new_item(name, (char*) NULL);
            }
        }
    }

    list_items[choices_cnt] = new_item((char*) NULL, (char*) NULL);

    menu_list = new_menu((ITEM**) list_items);

    window = newwin(
        30, // rows
        30, // cols
        2,
        0
    );

    keypad(window, TRUE);
    /* nodelay(window, TRUE); */

    set_menu_win(menu_list, window);
    set_menu_mark(menu_list, "");
    set_menu_fore(menu_list, COLOR_PAIR(XS_COLOR_PAIR_1));
    set_menu_format(menu_list, 10, 1);

    post_menu(menu_list);

    update_info_bar();

    refresh();
}
Ejemplo n.º 3
0
int
main(int argc, char ** argv)
{
    int c;
    int result = -1;    
    int i = 0;
    char arg_arch[MAX_ARCH_BUFFER];
    char arg_impl[MAX_IMPL_BUFFER];   
    char arg_calc[MAX_CALC_BUFFER]; 
    ms_bitfield_info * output = NULL;
    ms_bitfield_info * toshow = NULL;   
    int arg_core = -1;    
    int option_index = 0;   
    int ppl = 0;    
    int m = 0;
    
    if (argc == 1)
    {
        show_banner(1, 0, 0);
    }

    while ((c = getopt_long(argc, argv, "t:a:i:c:v:", long_options, &option_index)) != -1)
    {           
        switch(c)
        {   
            case 0:
                break;
            case 'a':               
                strncpy(arg_arch, optarg, MAX_ARCH_BUFFER - 1);             
                break;
            case 'i':                           
                strncpy(arg_impl, optarg, MAX_ARCH_BUFFER - 1);
                break;
            case 'c':               
                arg_core = atoi(optarg);
                break;
            case 'v':               
                strncpy(arg_calc, optarg, MAX_CALC_BUFFER - 1);
                flag_fb_calc = 1;
                break;
            case '?':
            case 'h':               
                print_usage();
                break;
            default:
                show_banner(1, 0, 0);
                return -1;
        }
    }
    
    if (flag_fb_show_info)
    {
        switch(flag_fb_show_info)
        {
            case FLAG_SHOW_GROUPS:
                ms_get_groups(&toshow);
                no_results(toshow);
                for (i = 0; i < ms_get_size(toshow); ++i)
                {       
                    printf("%s\n", ms_get_group_string(toshow, i));         
                }               
                ms_free_result(&toshow);
                break;
            case FLAG_SHOW_BITFIELDS:
                ms_get_bitfields(&toshow);
                no_results(toshow);
                for (i = 0; i < ms_get_size(toshow); ++i)
                {       
                    printf("0x%08x (%s.%s.%s)\n", 
                                            ms_get_uid(toshow, i),
                                            ms_get_decode_string(toshow, i),
                                            ms_get_register_string(toshow, i),
                                            ms_get_bitfield_string(toshow, i));         
                }
                ms_free_result(&toshow);
                break;
            case FLAG_SHOW_REGISTERS:
                ms_get_registers(&toshow);
                no_results(toshow);
                for (i = 0; i < ms_get_size(toshow); ++i)
                {       
                    printf("%s\n", ms_get_register_string(toshow, i));          
                }
                ms_free_result(&toshow);
                break;
            default:
                break;
        }       
        goto done;
    }
    
    ppl = get_ppl_from_flag(flag_fb_el0, flag_fb_el1);
    if (flag_fb_bitfield)
    {
        if (optind < argc)
        {   
            if (ms_find_by_bitfield(arg_arch,
                                    arg_impl,
                                    strtol(argv[optind], NULL, 16),
                                    arg_core,
                                    ppl,
                                    flag_fb_noparse,
                                    &output) != 0)
            {               
                goto done;
            }               
        }
    }
    else if (flag_fb_group)
    {
        if (optind < argc)
        {           
            if (ms_find_by_group(arg_arch,
                                 arg_impl,
                                 argv[optind],
                                 arg_core,
                                 ppl,
                                 flag_fb_noparse,
                                 &output) != 0)
            {               
                goto done;
            }   
        }
    }
    else if (flag_fb_register)
    {
        if (optind < argc)
        {
            if (flag_fb_calc)
            {
                if (ms_find_by_register(arg_arch,
                                        arg_impl,
                                        argv[optind],
                                        arg_core,
                                        ppl,
                                        flag_fb_noparse,
                                        arg_calc,
                                        &output) != 0)
                {               
                    goto done;
                }   
            }
            else
            {
                if (ms_find_by_register(arg_arch,
                                        arg_impl,
                                        argv[optind],
                                        arg_core,
                                        ppl,
                                        flag_fb_noparse,
                                        NULL,
                                        &output) != 0)
                {               
                    goto done;
                }   
            }
        }
    }   
    else if (flag_fb_all)
    {
        ms_get_groups(&toshow);
        for (i = 0; i < ms_get_size(toshow); ++i)
        {                       
            if (ms_find_by_group(arg_arch,
                                 arg_impl,
                                 ms_get_group_string(toshow, i),
                                 arg_core,
                                 ppl,
                                 flag_fb_noparse,
                                 &output) != 0)
            {               
                goto done;
            }           
            show_results(output);
            ms_free_result(&output);
        }       
    }   
    else
    {           
        goto done;
    }   

    show_results(output);
    
    result = 0;
    
done:
    ms_free_result(&toshow);
    ms_free_result(&output);
    printf("\n# Leaving the kernel module installed compromises the security of your system.\n# Use 'rmmod maplesyrup_mod' to unload the module.\n");
    return result;
}