Codex 69521e54e0 Add 15 embedded repair tasks and correct grader-read controls
Complete batch 20261016-C-embedded-2: 45 verified GLM/Pi samples, independent regrades and archives; preserve difficulty misses and Salty blockage.
2026-10-16 14:23:48 +08:00

4320 lines
58 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"kind": "dma",
"candidate_files": [
"driver.c",
"descriptor.c",
"completion.c"
],
"events": [
[
"R"
],
[
"Q",
71,
1
],
[
"D",
1,
1,
0
],
[
"D",
1,
1,
0
],
[
"Q",
72,
3
],
[
"D",
2,
3,
0
],
[
"D",
2,
3,
0
],
[
"R"
],
[
"Q",
71,
1
],
[
"D",
1,
1,
0
],
[
"D",
1,
1,
0
],
[
"Q",
72,
3
],
[
"D",
2,
2,
0
],
[
"D",
2,
2,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"R"
],
[
"Q",
71,
2
],
[
"D",
1,
2,
0
],
[
"D",
1,
2,
0
],
[
"Q",
72,
3
],
[
"D",
2,
3,
0
],
[
"D",
2,
3,
0
],
[
"R"
],
[
"Q",
71,
2
],
[
"D",
1,
1,
0
],
[
"D",
1,
1,
0
],
[
"D",
2,
1,
0
],
[
"D",
2,
1,
0
],
[
"Q",
72,
3
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"R"
],
[
"Q",
71,
6
],
[
"D",
1,
6,
0
],
[
"D",
1,
6,
0
],
[
"Q",
72,
3
],
[
"D",
2,
3,
0
],
[
"D",
2,
3,
0
],
[
"R"
],
[
"Q",
71,
6
],
[
"D",
1,
1,
0
],
[
"D",
1,
1,
0
],
[
"D",
2,
3,
0
],
[
"D",
2,
3,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"Q",
72,
3
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
6,
2,
0
],
[
"D",
6,
2,
0
],
[
"R"
],
[
"Q",
71,
7
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"Q",
72,
3
],
[
"D",
2,
3,
0
],
[
"D",
2,
3,
0
],
[
"R"
],
[
"Q",
71,
7
],
[
"D",
1,
6,
0
],
[
"D",
1,
6,
0
],
[
"D",
2,
1,
0
],
[
"D",
2,
1,
0
],
[
"Q",
72,
3
],
[
"D",
3,
2,
0
],
[
"D",
3,
2,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"R"
],
[
"Q",
71,
8
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
1,
0
],
[
"D",
2,
1,
0
],
[
"Q",
72,
3
],
[
"D",
3,
3,
0
],
[
"D",
3,
3,
0
],
[
"R"
],
[
"Q",
71,
8
],
[
"D",
1,
5,
0
],
[
"D",
1,
5,
0
],
[
"D",
2,
3,
0
],
[
"D",
2,
3,
0
],
[
"Q",
72,
3
],
[
"D",
3,
2,
0
],
[
"D",
3,
2,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"R"
],
[
"Q",
71,
13
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
6,
0
],
[
"D",
2,
6,
0
],
[
"Q",
72,
3
],
[
"D",
3,
3,
0
],
[
"D",
3,
3,
0
],
[
"R"
],
[
"Q",
71,
13
],
[
"D",
1,
5,
0
],
[
"D",
1,
5,
0
],
[
"D",
2,
1,
0
],
[
"D",
2,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
4,
6,
0
],
[
"D",
4,
6,
0
],
[
"Q",
72,
3
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
6,
1,
0
],
[
"D",
6,
1,
0
],
[
"D",
7,
1,
0
],
[
"D",
7,
1,
0
],
[
"R"
],
[
"Q",
71,
14
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
2,
7,
0
],
[
"Q",
72,
3
],
[
"D",
3,
3,
0
],
[
"D",
3,
3,
0
],
[
"R"
],
[
"Q",
71,
14
],
[
"D",
1,
5,
0
],
[
"D",
1,
5,
0
],
[
"D",
2,
5,
0
],
[
"D",
2,
5,
0
],
[
"D",
3,
3,
0
],
[
"D",
3,
3,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"Q",
72,
3
],
[
"D",
5,
2,
0
],
[
"D",
5,
2,
0
],
[
"D",
6,
1,
0
],
[
"D",
6,
1,
0
],
[
"R"
],
[
"Q",
71,
15
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"Q",
72,
3
],
[
"D",
4,
3,
0
],
[
"D",
4,
3,
0
],
[
"R"
],
[
"Q",
71,
15
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
1,
0
],
[
"D",
2,
1,
0
],
[
"D",
3,
4,
0
],
[
"D",
3,
4,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
6,
1,
0
],
[
"D",
6,
1,
0
],
[
"Q",
72,
3
],
[
"D",
7,
3,
0
],
[
"D",
7,
3,
0
],
[
"R"
],
[
"Q",
71,
31
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
7,
0
],
[
"D",
4,
7,
0
],
[
"D",
5,
3,
0
],
[
"D",
5,
3,
0
],
[
"Q",
72,
3
],
[
"D",
6,
3,
0
],
[
"D",
6,
3,
0
],
[
"R"
],
[
"Q",
71,
31
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
2,
0
],
[
"D",
2,
2,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
5,
0
],
[
"D",
4,
5,
0
],
[
"D",
5,
2,
0
],
[
"D",
5,
2,
0
],
[
"D",
6,
3,
0
],
[
"D",
6,
3,
0
],
[
"D",
7,
3,
0
],
[
"D",
7,
3,
0
],
[
"D",
8,
1,
0
],
[
"D",
8,
1,
0
],
[
"D",
9,
1,
0
],
[
"D",
9,
1,
0
],
[
"Q",
72,
3
],
[
"D",
10,
1,
0
],
[
"D",
10,
1,
0
],
[
"D",
11,
1,
0
],
[
"D",
11,
1,
0
],
[
"D",
12,
1,
0
],
[
"D",
12,
1,
0
],
[
"R"
],
[
"Q",
71,
63
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
7,
0
],
[
"D",
4,
7,
0
],
[
"D",
5,
7,
0
],
[
"D",
5,
7,
0
],
[
"D",
6,
7,
0
],
[
"D",
6,
7,
0
],
[
"D",
7,
7,
0
],
[
"D",
7,
7,
0
],
[
"D",
8,
7,
0
],
[
"D",
8,
7,
0
],
[
"D",
9,
7,
0
],
[
"D",
9,
7,
0
],
[
"Q",
72,
3
],
[
"D",
10,
3,
0
],
[
"D",
10,
3,
0
],
[
"R"
],
[
"Q",
71,
63
],
[
"D",
1,
4,
0
],
[
"D",
1,
4,
0
],
[
"D",
2,
3,
0
],
[
"D",
2,
3,
0
],
[
"D",
3,
4,
0
],
[
"D",
3,
4,
0
],
[
"D",
4,
3,
0
],
[
"D",
4,
3,
0
],
[
"D",
5,
5,
0
],
[
"D",
5,
5,
0
],
[
"D",
6,
5,
0
],
[
"D",
6,
5,
0
],
[
"D",
7,
2,
0
],
[
"D",
7,
2,
0
],
[
"D",
8,
7,
0
],
[
"D",
8,
7,
0
],
[
"D",
9,
3,
0
],
[
"D",
9,
3,
0
],
[
"D",
10,
7,
0
],
[
"D",
10,
7,
0
],
[
"D",
11,
7,
0
],
[
"D",
11,
7,
0
],
[
"D",
12,
1,
0
],
[
"D",
12,
1,
0
],
[
"D",
13,
1,
0
],
[
"D",
13,
1,
0
],
[
"D",
14,
2,
0
],
[
"D",
14,
2,
0
],
[
"D",
15,
6,
0
],
[
"D",
15,
6,
0
],
[
"D",
16,
1,
0
],
[
"D",
16,
1,
0
],
[
"D",
17,
2,
0
],
[
"D",
17,
2,
0
],
[
"Q",
72,
3
],
[
"D",
18,
1,
0
],
[
"D",
18,
1,
0
],
[
"D",
19,
1,
0
],
[
"D",
19,
1,
0
],
[
"D",
20,
1,
0
],
[
"D",
20,
1,
0
],
[
"R"
],
[
"Q",
71,
64
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
2,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
7,
0
],
[
"D",
4,
7,
0
],
[
"D",
5,
7,
0
],
[
"D",
5,
7,
0
],
[
"D",
6,
7,
0
],
[
"D",
6,
7,
0
],
[
"D",
7,
7,
0
],
[
"D",
7,
7,
0
],
[
"D",
8,
7,
0
],
[
"D",
8,
7,
0
],
[
"D",
9,
7,
0
],
[
"D",
9,
7,
0
],
[
"D",
10,
1,
0
],
[
"D",
10,
1,
0
],
[
"Q",
72,
3
],
[
"D",
11,
3,
0
],
[
"D",
11,
3,
0
],
[
"R"
],
[
"Q",
71,
64
],
[
"D",
1,
7,
0
],
[
"D",
1,
7,
0
],
[
"D",
2,
6,
0
],
[
"D",
2,
6,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
4,
5,
0
],
[
"D",
4,
5,
0
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
6,
4,
0
],
[
"D",
6,
4,
0
],
[
"D",
7,
7,
0
],
[
"D",
7,
7,
0
],
[
"D",
8,
1,
0
],
[
"D",
8,
1,
0
],
[
"D",
9,
2,
0
],
[
"D",
9,
2,
0
],
[
"D",
10,
5,
0
],
[
"D",
10,
5,
0
],
[
"D",
11,
4,
0
],
[
"D",
11,
4,
0
],
[
"D",
12,
7,
0
],
[
"D",
12,
7,
0
],
[
"D",
13,
4,
0
],
[
"D",
13,
4,
0
],
[
"D",
14,
5,
0
],
[
"D",
14,
5,
0
],
[
"D",
15,
5,
0
],
[
"D",
15,
5,
0
],
[
"Q",
72,
3
],
[
"D",
16,
3,
0
],
[
"D",
16,
3,
0
],
[
"R"
],
[
"Q",
1,
0
],
[
"R"
],
[
"Q",
1,
65
],
[
"R"
],
[
"Q",
1,
128
],
[
"R"
],
[
"Q",
0,
1
],
[
"D",
0,
1,
0
],
[
"C",
1
],
[
"R"
],
[
"Q",
1,
1
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"C",
1
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
2,
0
],
[
"D",
3,
2,
0
],
[
"D",
4,
5,
0
],
[
"D",
4,
5,
0
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"R"
],
[
"Q",
1,
1
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
1,
19
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
5,
0
],
[
"D",
3,
5,
0
],
[
"D",
4,
3,
0
],
[
"D",
4,
3,
0
],
[
"R"
],
[
"Q",
1,
1
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
0,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
2,
0
],
[
"D",
3,
2,
0
],
[
"D",
4,
6,
0
],
[
"D",
4,
6,
0
],
[
"R"
],
[
"Q",
1,
1
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
2,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"R"
],
[
"Q",
1,
7
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"C",
1
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
6,
0
],
[
"D",
3,
6,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"R"
],
[
"Q",
1,
7
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
1,
19
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
3,
0
],
[
"D",
3,
3,
0
],
[
"D",
4,
2,
0
],
[
"D",
4,
2,
0
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
6,
2,
0
],
[
"D",
6,
2,
0
],
[
"R"
],
[
"Q",
1,
7
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
0,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"R"
],
[
"Q",
1,
7
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
8,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"R"
],
[
"Q",
1,
8
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"C",
1
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
7,
0
],
[
"D",
3,
7,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"R"
],
[
"Q",
1,
8
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
1,
19
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
4,
3,
0
],
[
"D",
4,
3,
0
],
[
"D",
5,
1,
0
],
[
"D",
5,
1,
0
],
[
"D",
6,
1,
0
],
[
"D",
6,
1,
0
],
[
"D",
7,
2,
0
],
[
"D",
7,
2,
0
],
[
"R"
],
[
"Q",
1,
8
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
0,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
4,
3,
0
],
[
"D",
4,
3,
0
],
[
"D",
5,
2,
0
],
[
"D",
5,
2,
0
],
[
"D",
6,
1,
0
],
[
"D",
6,
1,
0
],
[
"D",
7,
1,
0
],
[
"D",
7,
1,
0
],
[
"R"
],
[
"Q",
1,
8
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
8,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
4,
0
],
[
"D",
3,
4,
0
],
[
"D",
4,
4,
0
],
[
"D",
4,
4,
0
],
[
"R"
],
[
"Q",
1,
64
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"C",
1
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
6,
0
],
[
"D",
3,
6,
0
],
[
"D",
4,
2,
0
],
[
"D",
4,
2,
0
],
[
"R"
],
[
"Q",
1,
64
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
1,
19
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
3,
1,
0
],
[
"D",
4,
7,
0
],
[
"D",
4,
7,
0
],
[
"R"
],
[
"Q",
1,
64
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
0,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
4,
0
],
[
"D",
3,
4,
0
],
[
"D",
4,
1,
0
],
[
"D",
4,
1,
0
],
[
"D",
5,
3,
0
],
[
"D",
5,
3,
0
],
[
"R"
],
[
"Q",
1,
64
],
[
"Q",
2,
1
],
[
"C",
99
],
[
"D",
1,
8,
0
],
[
"D",
1,
1,
255
],
[
"Q",
2,
8
],
[
"D",
1,
1,
0
],
[
"D",
3,
3,
0
],
[
"D",
3,
3,
0
],
[
"D",
4,
5,
0
],
[
"D",
4,
5,
0
],
[
"R"
],
[
"Q",
515,
8
],
[
"Q",
503,
32
],
[
"D",
1,
6,
0
],
[
"D",
1,
2,
0
],
[
"D",
2,
0,
0
],
[
"Q",
464,
2
],
[
"D",
4,
2,
93
],
[
"Q",
580,
2
],
[
"D",
6,
0,
0
],
[
"R"
],
[
"Q",
614,
1
],
[
"D",
1,
0,
0
],
[
"Q",
35,
14
],
[
"D",
3,
0,
0
],
[
"Q",
495,
2
],
[
"D",
5,
1,
0
],
[
"D",
6,
1,
0
],
[
"Q",
787,
14
],
[
"D",
6,
7,
0
],
[
"D",
6,
7,
0
],
[
"Q",
593,
44
],
[
"D",
7,
7,
173
],
[
"R"
],
[
"Q",
242,
14
],
[
"D",
1,
2,
0
],
[
"D",
2,
2,
0
],
[
"Q",
495,
5
],
[
"C",
242
],
[
"Q",
208,
64
],
[
"C",
1001
],
[
"D",
5,
6,
0
],
[
"C",
208
],
[
"Q",
682,
64
],
[
"D",
7,
7,
0
],
[
"R"
],
[
"Q",
455,
64
],
[
"C",
455
],
[
"Q",
6,
8
],
[
"D",
2,
7,
0
],
[
"D",
2,
7,
0
],
[
"R"
],
[
"Q",
535,
64
],
[
"D",
1,
7,
81
],
[
"Q",
317,
1
],
[
"D",
2,
1,
0
],
[
"D",
3,
1,
0
],
[
"Q",
89,
7
],
[
"C",
1001
],
[
"D",
4,
7,
153
],
[
"Q",
392,
1
],
[
"Q",
431,
27
],
[
"D",
6,
1,
0
],
[
"Q",
834,
15
],
[
"D",
7,
0,
0
],
[
"Q",
499,
1
],
[
"D",
9,
1,
165
],
[
"R"
],
[
"Q",
383,
2
],
[
"Q",
422,
31
],
[
"D",
1,
0,
0
],
[
"Q",
889,
64
],
[
"D",
3,
7,
99
],
[
"Q",
196,
15
],
[
"D",
5,
7,
0
],
[
"D",
5,
7,
0
],
[
"D",
6,
2,
0
],
[
"D",
7,
6,
55
],
[
"Q",
37,
7
],
[
"D",
9,
5,
0
],
[
"D",
9,
2,
0
],
[
"D",
10,
0,
0
],
[
"Q",
480,
64
],
[
"R"
],
[
"Q",
641,
8
],
[
"D",
1,
6,
0
],
[
"D",
2,
2,
0
],
[
"Q",
156,
1
],
[
"D",
3,
1,
101
],
[
"R"
],
[
"Q",
468,
14
],
[
"C",
468
],
[
"Q",
92,
14
],
[
"R"
],
[
"Q",
769,
64
],
[
"D",
1,
0,
0
],
[
"Q",
719,
7
],
[
"R"
],
[
"Q",
738,
7
],
[
"D",
1,
0,
0
],
[
"Q",
262,
1
],
[
"D",
3,
1,
0
],
[
"Q",
745,
8
],
[
"D",
4,
3,
0
],
[
"D",
4,
5,
0
],
[
"D",
5,
5,
94
],
[
"Q",
398,
14
],
[
"R"
],
[
"Q",
359,
1
],
[
"Q",
999,
50
],
[
"C",
359
],
[
"Q",
28,
15
],
[
"C",
1001
],
[
"C",
1001
],
[
"D",
3,
0,
0
],
[
"Q",
519,
7
],
[
"C",
519
],
[
"Q",
244,
64
],
[
"R"
],
[
"Q",
917,
1
],
[
"R"
],
[
"Q",
139,
14
],
[
"D",
0,
7,
0
],
[
"D",
1,
7,
8
],
[
"Q",
472,
7
],
[
"D",
2,
7,
0
],
[
"C",
1001
],
[
"C",
472
],
[
"Q",
758,
64
],
[
"C",
1001
],
[
"R"
],
[
"Q",
658,
14
],
[
"D",
1,
3,
0
],
[
"D",
2,
0,
0
],
[
"Q",
522,
2
],
[
"D",
4,
2,
0
],
[
"Q",
797,
2
],
[
"D",
4,
2,
0
],
[
"D",
4,
2,
0
],
[
"C",
1001
],
[
"C",
1001
],
[
"Q",
818,
19
],
[
"R"
],
[
"Q",
331,
15
],
[
"C",
331
],
[
"Q",
186,
14
],
[
"Q",
658,
32
],
[
"D",
3,
2,
0
],
[
"D",
4,
1,
0
],
[
"D",
5,
6,
0
],
[
"D",
6,
4,
0
],
[
"D",
7,
1,
126
],
[
"Q",
977,
64
],
[
"Q",
67,
40
],
[
"R"
],
[
"Q",
602,
14
],
[
"D",
1,
0,
0
],
[
"Q",
238,
15
],
[
"D",
3,
0,
0
],
[
"Q",
5,
1
],
[
"R"
],
[
"Q",
930,
8
],
[
"R"
],
[
"Q",
356,
1
],
[
"D",
1,
1,
0
],
[
"Q",
119,
2
],
[
"R"
],
[
"Q",
763,
2
],
[
"C",
763
],
[
"Q",
98,
7
],
[
"D",
3,
1,
0
],
[
"D",
4,
0,
0
],
[
"Q",
553,
1
],
[
"C",
1001
],
[
"Q",
42,
24
],
[
"R"
],
[
"Q",
218,
15
],
[
"D",
0,
7,
0
],
[
"C",
218
],
[
"Q",
549,
64
],
[
"C",
1001
],
[
"D",
3,
4,
0
],
[
"R"
],
[
"Q",
133,
15
],
[
"D",
1,
7,
107
],
[
"Q",
560,
14
],
[
"R"
],
[
"Q",
926,
1
],
[
"D",
1,
1,
0
],
[
"Q",
908,
8
],
[
"R"
],
[
"Q",
526,
1
],
[
"D",
0,
1,
0
],
[
"D",
1,
1,
0
],
[
"Q",
391,
15
],
[
"R"
],
[
"Q",
584,
15
],
[
"C",
1001
],
[
"D",
1,
1,
0
],
[
"D",
2,
0,
0
],
[
"Q",
527,
15
],
[
"D",
4,
2,
0
],
[
"D",
5,
7,
70
],
[
"Q",
372,
64
],
[
"D",
6,
7,
0
],
[
"D",
7,
5,
0
],
[
"D",
8,
7,
143
],
[
"Q",
814,
1
],
[
"D",
10,
1,
13
],
[
"Q",
673,
8
],
[
"D",
12,
5,
0
],
[
"R"
],
[
"Q",
503,
14
],
[
"Q",
686,
8
],
[
"D",
0,
7,
0
],
[
"R"
],
[
"Q",
703,
64
],
[
"Q",
429,
7
],
[
"C",
703
],
[
"Q",
699,
7
],
[
"D",
3,
7,
41
],
[
"Q",
865,
64
],
[
"D",
5,
2,
0
],
[
"D",
6,
5,
0
],
[
"D",
7,
7,
110
],
[
"Q",
815,
14
],
[
"D",
9,
4,
0
],
[
"R"
],
[
"Q",
94,
8
],
[
"D",
0,
7,
0
],
[
"D",
1,
5,
0
],
[
"D",
2,
3,
180
],
[
"R"
],
[
"Q",
125,
64
],
[
"Q",
891,
26
],
[
"D",
0,
7,
0
],
[
"D",
1,
0,
0
],
[
"R"
],
[
"Q",
450,
7
],
[
"R"
],
[
"Q",
91,
64
],
[
"D",
1,
2,
0
]
],
"readonly": {
"Makefile": "CC = gcc\nCFLAGS = -std=c11 -O2 -Wall -Wextra -Werror\n.PHONY: all clean\nall: hal-demo traffic\nhal-demo: harness.c registers.c input.c driver.c descriptor.c completion.c lab.h input.h\n\t$(CC) $(CFLAGS) harness.c registers.c input.c driver.c descriptor.c completion.c -o $@\ntraffic: traffic.c lab.h\n\t$(CC) $(CFLAGS) traffic.c -o $@\nclean:\n\trm -f hal-demo traffic\n",
"lab.h": "#ifndef LAB_H\n#define LAB_H\n#include <stddef.h>\n#include <stdint.h>\n#define DMA_LIMIT 64u\n#define DMA_SEGMENT 7u\n\ntypedef struct {\n unsigned token;\n unsigned offset;\n unsigned length;\n unsigned total;\n unsigned valid;\n} dma_descriptor;\n\ntypedef struct {\n unsigned id;\n unsigned length;\n} request_t;\n\ntypedef struct {\n unsigned operation;\n dma_descriptor programmed;\n unsigned enabled;\n unsigned program_count;\n unsigned abort_count;\n unsigned cache_count;\n unsigned callback_count;\n unsigned last_cache_offset;\n unsigned last_cache_length;\n} registers_t;\n\ntypedef struct {\n unsigned completed;\n unsigned cancelled;\n unsigned failed;\n unsigned rejected;\n unsigned stale;\n} counters_t;\n\ntypedef struct {\n registers_t *registers;\n request_t request;\n unsigned active;\n unsigned token;\n unsigned offset;\n unsigned chunk;\n dma_descriptor descriptor;\n counters_t counters;\n} driver_t;\n\ntypedef struct {\n unsigned id;\n unsigned token;\n unsigned offset;\n unsigned chunk;\n counters_t counters;\n} snapshot_t;\n\ntypedef struct {\n unsigned token;\n unsigned amount;\n unsigned error;\n} completion_t;\n\nvoid descriptor_reset(dma_descriptor *descriptor);\nunsigned descriptor_build(dma_descriptor *descriptor, unsigned token,\n unsigned offset, unsigned total);\nunsigned descriptor_length(const dma_descriptor *descriptor);\nunsigned descriptor_offset(const dma_descriptor *descriptor);\nunsigned descriptor_token(const dma_descriptor *descriptor);\nunsigned descriptor_matches(const driver_t *driver, unsigned token);\nunsigned descriptor_remaining(const driver_t *driver);\nvoid descriptor_program(driver_t *driver);\nvoid descriptor_clear(driver_t *driver);\nvoid descriptor_advance(driver_t *driver, unsigned amount);\nvoid token_advance(driver_t *driver);\ntypedef enum {\n COMPLETION_IDLE,\n COMPLETION_STALE,\n COMPLETION_INVALID,\n COMPLETION_READY\n} completion_class;\n\ncompletion_class completion_classify(const driver_t *driver, const completion_t *completion);\nunsigned completion_valid(const driver_t *driver, const completion_t *completion);\nvoid completion_accept(driver_t *driver, const completion_t *completion);\nvoid driver_finish(driver_t *driver, unsigned result);\nvoid reg_init(registers_t *registers);\nvoid reg_program(registers_t *registers, const dma_descriptor *descriptor);\nvoid reg_abort(registers_t *registers, unsigned token);\nvoid reg_cache(registers_t *registers, unsigned offset, unsigned amount);\nvoid reg_done(registers_t *registers, unsigned id, unsigned result);\nvoid reg_reject(registers_t *registers, unsigned id);\nvoid reg_state(const registers_t *registers, const driver_t *driver);\nvoid driver_init(driver_t *driver, registers_t *registers);\nvoid driver_submit(driver_t *driver, const request_t *request);\nvoid driver_complete(driver_t *driver, unsigned token, unsigned amount, unsigned error);\nvoid driver_cancel(driver_t *driver, unsigned id);\nvoid driver_snapshot(const driver_t *driver, snapshot_t *snapshot);\n#endif\n",
"harness.c": "#include \"lab.h\"\n#include \"input.h\"\n#include <stdio.h>\n#include <string.h>\n\nstatic int submit_command(const input_t *input, driver_t *driver)\n{\n request_t request;\n if (!input_count(input, 3u) ||\n !input_unsigned(input, 1u, 1000000u, &request.id) ||\n !input_unsigned(input, 2u, 128u, &request.length)) {\n return 0;\n }\n driver_submit(driver, &request);\n return 1;\n}\n\nstatic int completion_command(const input_t *input, driver_t *driver)\n{\n unsigned token;\n unsigned amount;\n unsigned error;\n if (!input_count(input, 4u) ||\n !input_unsigned(input, 1u, 1000000u, &token) ||\n !input_unsigned(input, 2u, 128u, &amount) ||\n !input_unsigned(input, 3u, 255u, &error)) {\n return 0;\n }\n driver_complete(driver, token, amount, error);\n return 1;\n}\n\nstatic int cancel_command(const input_t *input, driver_t *driver)\n{\n unsigned id;\n if (!input_count(input, 2u) ||\n !input_unsigned(input, 1u, 1000000u, &id)) {\n return 0;\n }\n driver_cancel(driver, id);\n return 1;\n}\n\nstatic int dispatch(const input_t *input,\n driver_t *driver,\n registers_t *registers)\n{\n if (input_command(input, \"Q\")) {\n return submit_command(input, driver);\n }\n if (input_command(input, \"D\")) {\n return completion_command(input, driver);\n }\n if (input_command(input, \"C\")) {\n return cancel_command(input, driver);\n }\n if (input_command(input, \"R\") && input_count(input, 1u)) {\n driver_init(driver, registers);\n return 1;\n }\n return 0;\n}\n\nint main(void)\n{\n registers_t registers;\n driver_t driver;\n input_t input;\n unsigned operation = 0u;\n int result;\n memset(&registers, 0, sizeof(registers));\n input_init(&input);\n driver_init(&driver, &registers);\n while ((result = input_next(&input, stdin)) > 0) {\n registers.operation = ++operation;\n if (!dispatch(&input, &driver, &registers)) {\n input_error(&input, \"invalid DMA command\");\n return 2;\n }\n reg_state(&registers, &driver);\n }\n return result < 0 || input.failed ? 2 : 0;\n}\n",
"input.c": "#include \"input.h\"\n#include <string.h>\n#include <ctype.h>\n#include <limits.h>\n\nvoid input_init(input_t *input)\n{\n memset(input, 0, sizeof(*input));\n}\n\nstatic int whitespace(unsigned char byte)\n{\n return byte == ' ' || byte == '\\t' || byte == '\\r' || byte == '\\n';\n}\n\nstatic int split_line(input_t *input)\n{\n char *cursor = input->storage;\n input->count = 0u;\n while (*cursor != '\\0') {\n while (whitespace((unsigned char)*cursor)) {\n cursor += 1;\n }\n if (*cursor == '\\0' || *cursor == '#') {\n break;\n }\n if (input->count == INPUT_WORDS) {\n input_error(input, \"too many words\");\n return 0;\n }\n input->words[input->count++] = cursor;\n while (*cursor != '\\0' && !whitespace((unsigned char)*cursor)) {\n cursor += 1;\n }\n if (*cursor != '\\0') {\n *cursor++ = '\\0';\n }\n }\n return 1;\n}\n\nstatic int read_line(input_t *input, FILE *stream)\n{\n size_t used;\n if (fgets(input->storage, sizeof(input->storage), stream) == NULL) {\n if (ferror(stream)) {\n input_error(input, \"input read failed\");\n return -1;\n }\n return 0;\n }\n input->line += 1u;\n used = strlen(input->storage);\n if (used == sizeof(input->storage) - 1u &&\n input->storage[used - 1u] != '\\n') {\n input_error(input, \"input line too long\");\n return -1;\n }\n return 1;\n}\n\nint input_next(input_t *input, FILE *stream)\n{\n int result;\n if (input->failed) {\n return -1;\n }\n for (;;) {\n result = read_line(input, stream);\n if (result <= 0) {\n return result;\n }\n if (!split_line(input)) {\n return -1;\n }\n if (input->count != 0u) {\n return 1;\n }\n }\n}\n\nint input_count(const input_t *input, size_t count)\n{\n return input->count == count;\n}\n\nstatic int decimal(const char *text, uint32_t maximum, uint32_t *value)\n{\n uint32_t result = 0u;\n const unsigned char *cursor = (const unsigned char *)text;\n if (*cursor == '\\0') {\n return 0;\n }\n while (*cursor != '\\0') {\n unsigned digit;\n if (*cursor < '0' || *cursor > '9') {\n return 0;\n }\n digit = *cursor - '0';\n if (result > maximum / 10u ||\n (result == maximum / 10u && digit > maximum % 10u)) {\n return 0;\n }\n result = result * 10u + digit;\n cursor += 1;\n }\n *value = result;\n return 1;\n}\n\nint input_u32(const input_t *input,\n size_t index,\n uint32_t maximum,\n uint32_t *value)\n{\n if (index >= input->count) {\n return 0;\n }\n return decimal(input->words[index], maximum, value);\n}\n\nint input_unsigned(const input_t *input,\n size_t index,\n unsigned maximum,\n unsigned *value)\n{\n uint32_t result;\n uint32_t bound = maximum;\n if (!input_u32(input, index, bound, &result)) {\n return 0;\n }\n *value = (unsigned)result;\n return 1;\n}\n\nint input_byte(const input_t *input, size_t index, uint8_t *value)\n{\n unsigned result;\n if (!input_unsigned(input, index, 255u, &result)) {\n return 0;\n }\n *value = (uint8_t)result;\n return 1;\n}\n\nint input_command(const input_t *input, const char *command)\n{\n if (input->count == 0u) {\n return 0;\n }\n return strcmp(input->words[0], command) == 0;\n}\n\nvoid input_error(input_t *input, const char *message)\n{\n input->failed = 1u;\n fprintf(stderr, \"input line %u: %s\\n\", input->line, message);\n}\n",
"registers.c": "#include \"lab.h\"\n#include <stdio.h>\n#include <string.h>\n\nstatic void record(const registers_t *registers,\n const char *name,\n unsigned first,\n unsigned second)\n{\n printf(\"E %u %s %u %u\\n\",\n registers->operation,\n name,\n first,\n second);\n}\n\nvoid reg_init(registers_t *registers)\n{\n unsigned operation = registers->operation;\n memset(registers, 0, sizeof(*registers));\n registers->operation = operation;\n}\n\nvoid reg_program(registers_t *registers, const dma_descriptor *descriptor)\n{\n unsigned encoded;\n registers->programmed = *descriptor;\n registers->enabled = 1u;\n registers->program_count += 1u;\n encoded = descriptor->offset * 256u + descriptor->length;\n record(registers, \"PROGRAM\", descriptor->token, encoded);\n}\n\nvoid reg_abort(registers_t *registers, unsigned token)\n{\n registers->enabled = 0u;\n registers->abort_count += 1u;\n record(registers, \"ABORT\", token, 0u);\n}\n\nvoid reg_cache(registers_t *registers, unsigned offset, unsigned amount)\n{\n registers->last_cache_offset = offset;\n registers->last_cache_length = amount;\n registers->cache_count += 1u;\n record(registers, \"CACHE\", offset, amount);\n}\n\nvoid reg_done(registers_t *registers, unsigned id, unsigned result)\n{\n registers->enabled = 0u;\n registers->callback_count += 1u;\n record(registers, \"DONE\", id, result);\n}\n\nvoid reg_reject(registers_t *registers, unsigned id)\n{\n record(registers, \"REJECT\", id, 0u);\n}\n\nvoid reg_state(const registers_t *registers, const driver_t *driver)\n{\n snapshot_t snapshot;\n driver_snapshot(driver, &snapshot);\n printf(\"S %u %u %u %u %u %u %u %u %u %u\\n\",\n registers->operation,\n snapshot.id,\n snapshot.token,\n snapshot.offset,\n snapshot.chunk,\n snapshot.counters.completed,\n snapshot.counters.cancelled,\n snapshot.counters.failed,\n snapshot.counters.rejected,\n snapshot.counters.stale);\n}\n",
"input.h": "#ifndef HAL_INPUT_H\n#define HAL_INPUT_H\n#include <stdio.h>\n#include <stdint.h>\n#include <stddef.h>\n#define INPUT_LINE 4096u\n#define INPUT_WORDS 128u\n\ntypedef struct {\n char storage[INPUT_LINE];\n char *words[INPUT_WORDS];\n size_t count;\n unsigned line;\n unsigned failed;\n} input_t;\n\nvoid input_init(input_t *input);\nint input_next(input_t *input, FILE *stream);\nint input_count(const input_t *input, size_t count);\nint input_u32(const input_t *input, size_t index, uint32_t maximum, uint32_t *value);\nint input_unsigned(const input_t *input, size_t index, unsigned maximum, unsigned *value);\nint input_byte(const input_t *input, size_t index, uint8_t *value);\nint input_command(const input_t *input, const char *command);\nvoid input_error(input_t *input, const char *message);\n#endif\n",
"traffic.c": "#include \"lab.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdint.h>\n#include <errno.h>\n\nstatic uint32_t random_state;\nstatic unsigned token;\n\nstatic unsigned random_value(void)\n{\n random_state ^= random_state << 13;\n random_state ^= random_state >> 17;\n random_state ^= random_state << 5;\n return random_state;\n}\n\nstatic int argument(const char *text, unsigned *value)\n{\n unsigned long parsed;\n char *end;\n errno = 0;\n parsed = strtoul(text, &end, 10);\n if (errno || !*text || *end || parsed > 1000000ul) {\n return 0;\n }\n *value = (unsigned)parsed;\n return 1;\n}\n\nstatic unsigned segment(unsigned remaining)\n{\n return remaining < DMA_SEGMENT ? remaining : DMA_SEGMENT;\n}\n\nstatic void reset(void)\n{\n puts(\"R\");\n token = 0u;\n}\n\nstatic void request(unsigned id, unsigned length)\n{\n printf(\"Q %u %u\\n\", id, length);\n token += 1u;\n}\n\nstatic void completion(unsigned amount, unsigned error, unsigned last)\n{\n printf(\"D %u %u %u\\n\", token, amount, error);\n if (error || !amount) {\n token += 1u;\n } else if (!last) {\n token += 1u;\n }\n}\n\nstatic void finish(unsigned remaining)\n{\n while (remaining != 0u) {\n unsigned amount = segment(remaining);\n unsigned partial = 1u + random_value() % amount;\n completion(partial, 0u, partial == remaining);\n remaining -= partial;\n }\n}\n\nstatic void normal(unsigned id, unsigned length)\n{\n request(id, length);\n finish(length);\n}\n\nstatic void cancelled(unsigned id)\n{\n unsigned old;\n request(id, 16u);\n old = token;\n completion(2u, 0u, 0u);\n printf(\"C %u\\n\", id);\n token += 1u;\n printf(\"D %u 2 0\\n\", old);\n request(id + 1u, 2u);\n printf(\"D %u 1 0\\n\", old);\n completion(2u, 0u, 1u);\n}\n\nstatic void hardware_error(unsigned id)\n{\n unsigned old;\n request(id, 15u);\n old = token;\n completion(2u, 17u, 0u);\n printf(\"D %u 2 0\\n\", old);\n normal(id + 1u, 3u);\n}\n\nstatic void invalid_amount(unsigned id)\n{\n request(id, 9u);\n completion(0u, 0u, 0u);\n normal(id + 1u, 1u);\n}\n\nstatic void late_callback(unsigned id)\n{\n unsigned old;\n request(id, 7u);\n old = token;\n completion(7u, 0u, 1u);\n printf(\"D %u 7 0\\n\", old);\n request(id + 1u, 1u);\n printf(\"D %u 1 0\\n\", old);\n completion(1u, 0u, 1u);\n}\n\nstatic void rejection(unsigned id)\n{\n request(id, 8u);\n printf(\"Q %u 1\\n\", id + 1u);\n printf(\"C %u\\n\", id + 1u);\n finish(8u);\n puts(\"Q 0 1\");\n printf(\"Q %u 0\\n\", id);\n printf(\"Q %u 65\\n\", id);\n}\n\nstatic void oversized(unsigned id)\n{\n request(id, 3u);\n completion(4u, 0u, 0u);\n normal(id + 1u, 2u);\n}\n\nstatic void stale_error(unsigned id)\n{\n unsigned old;\n request(id, 4u);\n old = token;\n completion(1u, 0u, 0u);\n printf(\"D %u 0 19\\n\", old);\n printf(\"D %u 128 255\\n\", old);\n finish(3u);\n}\n\nstatic void immediate_error(unsigned id)\n{\n request(id, 1u);\n completion(1u, 1u, 0u);\n request(id + 1u, 1u);\n completion(1u, 0u, 1u);\n}\n\nstatic void segment_boundaries(unsigned id)\n{\n normal(id, 6u);\n normal(id + 1u, 7u);\n normal(id + 2u, 8u);\n normal(id + 3u, 14u);\n normal(id + 4u, 15u);\n}\n\nstatic void suite(unsigned base)\n{\n normal(base, 64u);\n normal(base + 1u, 1u);\n cancelled(base + 2u);\n hardware_error(base + 4u);\n invalid_amount(base + 6u);\n late_callback(base + 8u);\n rejection(base + 10u);\n oversized(base + 12u);\n stale_error(base + 14u);\n immediate_error(base + 16u);\n segment_boundaries(base + 18u);\n}\n\nint main(int argc, char **argv)\n{\n unsigned seed = 1u;\n unsigned rounds = 2u;\n unsigned index;\n if (argc > 3 ||\n (argc > 1 && !argument(argv[1], &seed)) ||\n (argc > 2 && !argument(argv[2], &rounds))) {\n fputs(\"usage: traffic [seed] [rounds] (0..1000000)\\n\", stderr);\n return 2;\n }\n random_state = seed ? seed : 1u;\n for (index = 0u; index < rounds; ++index) {\n reset();\n suite(1u);\n }\n return ferror(stdout) ? 2 : 0;\n}\n",
"README.md": "# 修复 DMA 分段完成与过期回调\n\n原创离线软件练习模拟以下症状:短DMA请求有时正常,跨描述符、部分完成、取消后快速\n重用通道、错误之后再提交时,会出现跳过数据区间、重复完成、错误缓存维护或旧回调\n结束新请求。当前为完整C11工程,含描述符模块、完成分发、寄存器桩和调试输入生成器。\n修复`driver.c`、`descriptor.c`、`completion.c`,保持lab.h签名;其余工程为只读上下文。\n只验证软件描述符生命周期/回调与缓存维护调用,不验证真实DMA硬件或CPU缓存一致性。\n\n## P1 构建、输入与原始观察\n\n`make`使用gcc C11、`-O2 -Wall -Wextra -Werror`,生成hal-demo和traffic。\n`./hal-demo`从stdin逐行读取十进制命令,空行/#注释忽略:\n\n- `R`:静默复位所有驱动、寄存器、token和计数,建立新的回调时间轴。\n- `Q id length`:提交一次连续缓冲区接收,id=0..1000000、length=0..128。\n- `D token amount error`:一次DMA完成事件,token=0..1000000、amount=0..128、error=0..255。\n- `C id`:取消,id=0..1000000。\n\n输入格式正确,最多20000操作,计数和token不溢出;R之前的硬件事件不跨R注入。\n同一R周期内会注入已完成/取消/失败描述符的延迟和重复事件。EOF不隐式完成。\n构建20秒、程序10秒、评分120秒;正常退出0、格式错误退出2。库不得自行打印。\n\n原始事件`E op name a b`:PROGRAM token packed(packed=offset*256+chunk);\nCACHE offset amount;ABORT token 0;DONE id status;REJECT id 0。\n每条命令全部事件后:\n`S op active_id token offset chunk completed cancelled failed rejected stale`。\n操作编号op从1递增,R不重置编号;无活动请求时active_id=offset=chunk=0。\n缓存区间按字节的offset和amount精确记录,不作对齐/舍入。\n\n## P2 提交、token和描述符\n\n合法请求id非零且length=1..64;当前有活动请求时任何Q都拒绝。拒绝仅rejected加1并\nREJECT,不改token、进度或正在传输的请求。长度0/65..128用于验证拒绝。\n没有等待队列。接受时复制id/length,活动进度offset=0,按以下规则编程第一描述符。\n\n每次PROGRAM先将全局token加1(R后初值0),chunk=min(7,length-offset),\n描述符保存此token、offset、chunk和总length,再输出PROGRAM(token,offset*256+chunk)。\n每次后续分段或部分完成后重新编程都取得新token,即使继续处理同一请求。\n不能按提交次数而忽略中间描述符,不能重用取消/错误撤销的token。\n\n## P3 完成事件、缓存与错误优先级\n\nD首先检查是否有活动请求、token是否等于当前描述符token。没有活动请求或token\n不匹配时,只stale加1,忽略amount/error,不产生CACHE/ABORT/DONE/PROGRAM,\n不能改变当前请求、token或进度。此检查优先于任何完成错误或长度错误。\n\n当前描述符token匹配时,error非零、amount=0、amount>chunk均表示失败:\n先ABORT(当前token,0),再将全局token加1使该描述符失效,failed加1,\nDONE(id,1),清空活动身份与offset/chunk。不得输出CACHE或自动启动新请求。\n失败后可提交独立请求;旧描述符的重复事件只能计stale。\n\n匹配且error=0、1<=amount<=chunk时:先CACHE(完成前offset,amount),\n再offset+=amount。只维护实际完成字节区间,不把未完成部分当作已完成。\n若offset==length,completed加1、DONE(id,0),清空活动身份与offset/chunk;\n本次成功完成不额外增加token。否则立即按P2重新PROGRAM剩余区间,\n新chunk=min(7,length-新offset),包括amount<上次chunk的部分完成。\n事件顺序严格CACHE、可选PROGRAM或DONE,不得重放此前已完成区间。\n\n## P4 取消、恢复与模块接口\n\nC只在匹配活动id时生效:ABORT(当前token,0),全局token加1,cancelled加1,\nDONE(id,3),清空活动身份与offset/chunk。未知或空闲id不产生事件、不改计数。\n取消后的下一次Q继续从该全局token再加1;旧回调不能结束新的活动请求。\nR不回调,无条件清零token、进度、所有计数和寄存器;完成、失败、取消后均可重用id。\n\nlab.h全部接口指针有效。descriptor_reset清空描述符。descriptor_build在token非零、\n1<=total<=64、offset<total时构建P2描述符并返回1,否则返回0且不改输出。\nlength/offset/token getter只读;invalid描述符的length为0。descriptor_matches检查当前\n有效描述符及其token/offset/length/total与驱动对应,并比较给定token;remaining为空闲\n时0,否则为length-offset。token_advance只令全局token加1;descriptor_clear仅清空\noffset/chunk和描述符;descriptor_advance仅按amount推进offset;descriptor_program遵P2。\ncompletion_valid只校验当前amount/error;completion_classify依P3先区分空闲、过期、\n无效完成、合法完成,accept/driver_complete据此处理;driver_finish按结果计数、DONE并\n释放活动请求。driver_snapshot仅观察。对模块内部辅助调用,调用方保证已有合法活动状态。\n\n## P5 自测与提交\n\n```sh\nmake\nprintf 'Q 1 8\\nD 1 2 0\\nD 1 1 0\\nD 2 6 0\\n' | ./hal-demo\n./traffic 17 2 | ./hal-demo\n```\n\n首例PROGRAM(1,7),CACHE(0,2)、PROGRAM(2,518),旧token1仅计stale,\n最后CACHE(2,6)、DONE(1,0)。可自行测试6/7/8、14/15、最大64、部分完成多次分段、\n取消后重用通道、无效amount、错误完成、过期事件携带错误码、未知取消、重复完成。\n最终只冻结三个候选文件,原样上下文重建,不使用新增文件、旧构建产物、网络或隐藏判据。\n"
}
}