예제 #1
0
ipv6_addr_t *gnrc_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_t *dst)
{
    gnrc_ipv6_netif_t *iface = gnrc_ipv6_netif_get(pid);
    ipv6_addr_t *best_src = NULL;
    mutex_lock(&(iface->mutex));
    BITFIELD(candidate_set, GNRC_IPV6_NETIF_ADDR_NUMOF);
    memset(candidate_set, 0, sizeof(candidate_set));

    int first_candidate = _create_candidate_set(iface, dst, candidate_set);
    if (first_candidate >= 0) {
        best_src = _source_address_selection(iface, dst, candidate_set);
        if (best_src == NULL) {
            best_src = &(iface->addrs[first_candidate].addr);
        }
    }
    mutex_unlock(&(iface->mutex));

    return best_src;
}
예제 #2
0
ipv6_addr_t *gnrc_netif_ipv6_addr_best_src(gnrc_netif_t *netif,
                                           const ipv6_addr_t *dst,
                                           bool ll_only)
{
    ipv6_addr_t *best_src = NULL;

    BITFIELD(candidate_set, GNRC_NETIF_IPV6_ADDRS_NUMOF);

    assert((netif != NULL) && (dst != NULL));
    memset(candidate_set, 0, sizeof(candidate_set));
    gnrc_netif_acquire(netif);
    int first_candidate = _create_candidate_set(netif, dst, ll_only,
                                                candidate_set);
    if (first_candidate >= 0) {
        best_src = _src_addr_selection(netif, dst, candidate_set);
        if (best_src == NULL) {
            best_src = &(netif->ipv6.addrs[first_candidate]);
        }
    }
    gnrc_netif_release(netif);
    return best_src;
}
예제 #3
0
  { "OPERAND_TYPE_VEC_DISP8",
    "Vec_Disp8" },
};

typedef struct bitfield
{
  int position;
  int value;
  const char *name;
} bitfield;

#define BITFIELD(n) { n, 0, #n }

static bitfield cpu_flags[] =
{
  BITFIELD (Cpu186),
  BITFIELD (Cpu286),
  BITFIELD (Cpu386),
  BITFIELD (Cpu486),
  BITFIELD (Cpu586),
  BITFIELD (Cpu686),
  BITFIELD (CpuClflush),
  BITFIELD (CpuNop),
  BITFIELD (CpuSYSCALL),
  BITFIELD (Cpu8087),
  BITFIELD (Cpu287),
  BITFIELD (Cpu387),
  BITFIELD (Cpu687),
  BITFIELD (CpuFISTTP),
  BITFIELD (CpuMMX),
  BITFIELD (CpuSSE),
예제 #4
0
int handle_ioregs_read ( unsigned short addr, char *value )
{
    switch ( addr )
    {
        case JOYP:
            *value = BITFIELD(P10_input_right, P11_input_left, P12_input_up, P13_input_down,
                              P14_select_direction_keys, P15_select_button_keys, 0, 0);
            break;

        case SB:
            *value = serial_transfer_data;
            break;

        case SC:
            *value = serial_shift_clock | (serial_transfer_start_flag << 7);
            break;

        case DIV:
            *value = div_reg;
            break;

        case TIMA:
            *value = timer_counter;
            break;

        case TMA:
            *value = timer_modulo;
            break;

        case TAC:
            *value = timer_input_clock_select | (timer_enabled << 2);
            break;

        case NR10:
            *value = channel1_number_of_sweep_shift | (channel1_sweep_increase_decrease << 2) | (channel1_sweep_time << 4);
            break;

        case NR11:
            *value = channel1_wave_pattern_duty << 6;
            break;

        case NR12:
            *value = channel1_number_of_envelope_sweep | (channel1_envelope_direction << 3) |
                     (channel1_initial_volume_of_envelope << 4);
            break;

        case NR13:
            *value = 0;
            break;

        case NR14:
            *value = channel1_counter_consecutive_selection << 6;
            break;

        case NR21:
            *value = channel2_wave_pattern_duty << 6;
            break;

        case NR22:
            *value = channel2_number_of_envelope_sweep | (channel2_envelope_direction << 3) |
                     (channel2_initial_volume_of_envelope << 4);
            break;

        case NR23:
            *value = 0;
            break;

        case NR24:
            *value = channel2_counter_consecutive_selection << 6;
            break;

        case NR30:
            *value = channel3_sound_enabled << 7;
            break;

        case NR31:
            *value = channel3_sound_length;
            break;

        case NR32:
            *value = channel3_select_output_level << 5;
            break;

        case NR33:
            *value = 0;
            break;

        case NR34:
            *value = channel3_counter_consecutive_selection << 6;
            break;

        case NR41:
            *value = channel4_sound_length;
            break;

        case NR42:
            *value = channel4_number_of_envelope_sweep | (channel4_envelope_direction << 3) |
                     (channel4_initial_volume_of_envelope << 4);
            break;

        case NR43:
            *value = channel4_dividing_ratio_of_frequencies | (channel4_counter_step_width << 3) |
                     (channel4_shift_clock_frequency << 4);
            break;

        case NR44:
            *value = channel4_counter_consecutive_selection << 6;
            break;

        case NR50:
            *value = SO1_output_level | (output_vin_to_SO1_terminal << 3) |
                     (SO2_output_level << 4) | (output_vin_to_SO2_terminal << 7);
            break;

        case NR51:
            *value = BITFIELD(output_sound_1_to_SO1_terminal, output_sound_2_to_SO1_terminal,
                              output_sound_3_to_SO1_terminal, output_sound_4_to_SO1_terminal,
                              output_sound_1_to_SO2_terminal, output_sound_2_to_SO2_terminal,
                              output_sound_3_to_SO2_terminal, output_sound_4_to_SO2_terminal);
            break;

        case NR52:
            *value = BITFIELD(sound_1_ON_flag, sound_2_ON_flag, sound_3_ON_flag, sound_4_ON_flag, 0, 0, 0, audio_enabled);
            break;
/*
        case WAVE_PATTERN_RAM:
            break;
*/
        case LCDC:
            *value = BITFIELD(bg_display, sprite_display_enable, sprite_size,
                              bg_tile_map_display_select, bg_window_tile_data_select,
                              window_display_enable, window_tile_map_display_select,
                              lcd_display_enable);
            break;

        case STAT:
            *value = lcd_mode_flag | (lcd_coincidence_flag << 2) | (mode_0_H_Blank_interrupt << 3) |
                     (mode_1_V_Blank_interrupt << 4) | (mode_2_OAM_interrupt << 5) | (LYC_LY_coincidence_interrupt << 6);
            break;

        case SCY:
            *value = lcd_scroll_y;
            break;

        case SCX:
            *value = lcd_scroll_x;
            break;

        case LY:
            *value = lcd_line;
            break;

        case LYC:
            *value = lcd_LY_compare;
            break;

        case DMA:
            /* XXX */
            break;

        case BGP:
            *value = shade_for_color_0 | (shade_for_color_1 << 2) | (shade_for_color_2 << 4) | (shade_for_color_3 << 6);
            break;

        case OBP0:
            *value = (sprite_0_shade_for_color_0 << 2) | (sprite_0_shade_for_color_1 << 4) | (sprite_0_shade_for_color_2 << 6);
            break;

        case OBP1:
            *value = (sprite_1_shade_for_color_0 << 2) | (sprite_1_shade_for_color_1 << 4) | (sprite_1_shade_for_color_2 << 6);
            break;

        case WY:
            *value = window_y_position;
            break;

        case WX:
            *value = window_x_position;
            break;

        case BOOT:
            *value = 0;
            break;

        default:
            return 0;
    }

    return 1;
}
예제 #5
0
파일: i386-gen.c 프로젝트: MIPS/binutils
  { "OPERAND_TYPE_VEC_IMM4",
    "Vec_Imm4" },
};

typedef struct bitfield
{
  int position;
  int value;
  const char *name;
} bitfield;

#define BITFIELD(n) { n, 0, #n }

static bitfield cpu_flags[] =
{
  BITFIELD (Cpu186),
  BITFIELD (Cpu286),
  BITFIELD (Cpu386),
  BITFIELD (Cpu486),
  BITFIELD (Cpu586),
  BITFIELD (Cpu686),
  BITFIELD (CpuClflush),
  BITFIELD (CpuNop),
  BITFIELD (CpuSYSCALL),
  BITFIELD (Cpu8087),
  BITFIELD (Cpu287),
  BITFIELD (Cpu387),
  BITFIELD (Cpu687),
  BITFIELD (CpuFISTTP),
  BITFIELD (CpuMMX),
  BITFIELD (CpuSSE),
예제 #6
0
파일: i386-gen.c 프로젝트: kidaa/HDTheatre
        "Imm32|Imm32S|Imm64|Disp32|Disp64"
    },
};

typedef struct bitfield
{
    int position;
    int value;
    const char *name;
} bitfield;

#define BITFIELD(n) { n, 0, #n }

static bitfield cpu_flags[] =
{
    BITFIELD (Cpu186),
    BITFIELD (Cpu286),
    BITFIELD (Cpu386),
    BITFIELD (Cpu486),
    BITFIELD (Cpu586),
    BITFIELD (Cpu686),
    BITFIELD (CpuP4),
    BITFIELD (CpuK6),
    BITFIELD (CpuK8),
    BITFIELD (CpuMMX),
    BITFIELD (CpuSSE),
    BITFIELD (CpuSSE2),
    BITFIELD (CpuSSE3),
    BITFIELD (CpuSSSE3),
    BITFIELD (CpuSSE4_1),
    BITFIELD (CpuSSE4_2),