test/dispatch/machine.ras 1.5 KiB raw
1
//! Exercise real timer-driven switching on hart zero.
2
.text;
3
    call @kernel::boot::initialize;
4
    call @kernel::dispatchcheck::setup;
5
    call @kernel::boot::run;
6
@fail
7
    li %a0 1;
8
    j @failure;
9
@late
10
    li %a0 2;
11
    j @failure;
12
@noProgress
13
    li %a0 3;
14
    j @failure;
15
@noResumption
16
    li %a0 4;
17
    j @failure;
18
@stackCorruption
19
    li %a0 5;
20
@failure
21
    li %t0 0x10001000;
22
    slli %t1 %a0 16;
23
    li %t2 0x3333;
24
    or %t1 %t1 %t2;
25
    sw %t1 0(%t0);
26
.export @kernel::dispatchcheck::memory;
27
.export @kernel::dispatchcheck::kernelGp;
28
.export @kernel::dispatchcheck::worker;
29
.export @kernel::dispatchcheck::completion;
30
.export @kernel::dispatchcheck::finish;
31
.export @kernel::dispatchcheck::failed;
32
@kernel::dispatchcheck::failed
33
    j @failure;
34
@kernel::dispatchcheck::memory
35
    ret;
36
@kernel::dispatchcheck::kernelGp
37
    mv %a0 %gp;
38
    ret;
39
@kernel::dispatchcheck::worker
40
    la %a0 @machineWork;
41
    ret;
42
@kernel::dispatchcheck::completion
43
    la %a0 @complete;
44
    ret;
45
@machineWork
46
    ld %t0 0(%a1);
47
    bgeu %t0 %a2 @late;
48
    ld %s2 0(%a0);
49
    beqz %s2 @noProgress;
50
    addi %sp %sp -16;
51
    li %s3 1234567;
52
    sd %s3 0(%sp);
53
    li %s0 0;
54
    li %s1 0;
55
@workLoop
56
    addi %s0 %s0 1;
57
    ld %t0 0(%sp);
58
    bne %t0 %s3 @stackCorruption;
59
    ld %t0 0(%a1);
60
    bltu %t0 %a3 @workLoop;
61
    ld %t0 0(%a0);
62
    bgeu %s2 %t0 @noResumption;
63
    li %s1 1;
64
    j @workLoop;
65
@complete
66
    call @kernel::dispatchcheck::verify;
67
    j @fail;
68
@kernel::dispatchcheck::finish
69
    li %t0 0x10001000;
70
    li %t1 0x5555;
71
    sw %t1 0(%t0);
72
    j @fail;