aboutsummaryrefslogtreecommitdiff
path: root/test/ui/v1/allos/ui.c
blob: 1a02c30dd20d26e240443c953769d2721ec7723e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#if !defined(COMMAND_NEW)
#error
#endif

#if CLONES != 2
#error
#endif

#define CHILD_SIZE 4

void check_new_proc(void) {
    const struct Proc *proc = proc_get(g_cores, g_cores->plst);
    assert(proc->mb0s == CHILD_SIZE);
    assert(proc->mb1a == 0);
    assert(proc->mb1s == 0);
    assert(proc->r0x == 0);
    assert(proc->r1x == 0);
    assert(proc->r2x == 0);
    assert(proc->r3x == 0);
    assert(proc->s0 == 0);
    assert(proc->s1 == 0);
    assert(proc->s2 == 0);
    assert(proc->s3 == 0);
    assert(proc->s4 == 0);
    assert(proc->s5 == 0);
    assert(proc->s6 == 0);
    assert(proc->s7 == 0);

    uint64_t birth_addr = (uint64_t)-1;

    switch (g_cores->plst) {
    case 2:
        birth_addr = ANC_SIZE;
        break;
    case 3:
        birth_addr = ANC_SIZE + (MVEC_SIZE / 2);
        break;
    case 4:
        birth_addr = ANC_SIZE + CHILD_SIZE;
        break;
    case 5:
        birth_addr = ANC_SIZE + CHILD_SIZE + (MVEC_SIZE / 2);
        break;
    case 6:
        birth_addr = (MVEC_SIZE / 2) - CHILD_SIZE;
        break;
    default:
        assert(false);
    }

    assert(proc->ip == birth_addr);
    assert(proc->sp == birth_addr);
    assert(proc->mb0a == birth_addr);
}

int main(void) {
    salis_init();

    while (mvec_is_proc_owner(g_cores, proc_fetch(g_cores, 1)->ip, 1)) {
        const struct Proc *proc_next = proc_get(g_cores, (g_cores->pcur + 1) % g_cores->pnum);
        bool will_split = mvec_get_inst(g_cores, proc_next->ip) == splt && proc_next->mb1s;
        uint64_t pnum = g_cores->pnum;

        salis_step(1);

        if (will_split) {
            assert(g_cores->pnum == pnum + 1);
            assert(g_cores->plst == pnum);

            switch (g_cores->pnum) {
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                check_new_proc();
                break;
            default:
                assert(false);
            }
        }
    }

    assert(mvec_is_proc_owner(g_cores, proc_fetch(g_cores, 0)->ip, 0));
    assert(g_cores->pnum == 7);
    assert(g_cores->pvec[0].sp > MVEC_SIZE);

    salis_free();
    return 0;
}