Example #1
0
// Software virtual interrupt ( For ISR usage only ! Do NOT call from "main"!)
bgrt_bool_t vsmp_vinterrupt_isr( bgrt_cpuid_t vm, vinterrupt_t * vector )
{
    if( vector->num_pending++ ) return (bgrt_bool_t)0;
    if( vm_state[vm].int_fifo )
    {
        bgrt_item_insert( (bgrt_item_t *)vector, (bgrt_item_t *)vm_state[vm].int_fifo );
    }
    else
    {
        vm_state[vm].int_fifo = (bgrt_item_t *)vector;
    }
    return (bgrt_bool_t)1;
}
Example #2
0
int main()
{
    bgrt_item_t
    bgrt_item_1 = BGRT_ITEM_T_INIT(bgrt_item_1),
                  bgrt_item_2 = BGRT_ITEM_T_INIT(bgrt_item_2),
                                bgrt_item_3 = BGRT_ITEM_T_INIT(bgrt_item_3);

    bgrt_item_t * head;
    bgrt_xlist_t list;
    int test, i;

    printf("Test 1: bgrt_xlist_init function: ");

    bgrt_xlist_init(&list);

    test = (list.map != (bgrt_map_t)0);
    for (i=0; i<BGRT_BITS_IN_INDEX_T; i++)
    {
        test |= (list.item[i]!=(bgrt_item_t*)0);
    }

    print_test_res(test);

    printf("Test 2: bgrt_xlist_head function: ");

    list.map = 5;
    list.item[0] = &bgrt_item_1;
    list.item[2] = &bgrt_item_2;
    bgrt_item_insert(&bgrt_item_3, list.item[0]);

    head = bgrt_xlist_head(&list);

    print_test_res((head != &bgrt_item_1));

    printf("Test 3: bgrt_xlist_switch function: ");

    bgrt_xlist_switch(&list, 0);
    head = bgrt_xlist_head(&list);
    print_test_res((head != &bgrt_item_3));

    return 0;
}
Example #3
0
int main()
{
    bgrt_item_t bgrt_item_1 = BGRT_ITEM_T_INIT( bgrt_item_1 );
    bgrt_item_t bgrt_item_2, bgrt_item_3;
    bgrt_item_t * head;
    int test;

    printf("Test 1: BGRT_ITEM_T_INIT macro: ");
    if( (bgrt_item_1.next != &bgrt_item_1) || (bgrt_item_1.prev != &bgrt_item_1) )
    {
        print_fail();
        return 0;
    }
    else
    {
        print_ok();
    }

    printf("Test 2: bgrt_item_init function: ");
    bgrt_item_init( &bgrt_item_2 );
    bgrt_item_init( &bgrt_item_3 );
    if( (bgrt_item_2.next != &bgrt_item_2) || (bgrt_item_2.prev != &bgrt_item_2) )
    {
        print_fail();
        return 0;
    }
    else
    {
        print_ok();
    }

    printf("Test 3: bgrt_item_insert function: ");
    head = &bgrt_item_1;

    bgrt_item_insert( &bgrt_item_2, head );

    test = (bgrt_item_1.next != &bgrt_item_2) || (bgrt_item_1.prev != &bgrt_item_2);
    test |= (bgrt_item_2.next != &bgrt_item_1) || (bgrt_item_2.prev != &bgrt_item_1);

    bgrt_item_insert( &bgrt_item_3, head );

    test |= (bgrt_item_1.next != &bgrt_item_2) || (bgrt_item_1.prev != &bgrt_item_3);
    test |= (bgrt_item_2.next != &bgrt_item_3) || (bgrt_item_2.prev != &bgrt_item_1);
    test |= (bgrt_item_3.next != &bgrt_item_1) || (bgrt_item_3.prev != &bgrt_item_2);

    if( test )
    {
        print_fail();
        return 0;
    }
    else
    {
        print_ok();
    }

    printf("Test 4: bgrt_item_cut function: ");

    bgrt_item_cut( &bgrt_item_3 );

    test = (bgrt_item_1.next != &bgrt_item_2) || (bgrt_item_1.prev != &bgrt_item_2);
    test |= (bgrt_item_2.next != &bgrt_item_1) || (bgrt_item_2.prev != &bgrt_item_1);

    bgrt_item_cut( &bgrt_item_2 );

    test |= (bgrt_item_1.next != &bgrt_item_1) || (bgrt_item_1.prev != &bgrt_item_1);

    if( test )
    {
        print_fail();
        return 0;
    }
    else
    {
        print_ok();
    }

    return 0;
}