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