|
|
1.1 root 1: NRW DMA - driver usage
2:
3: DMA procedure, block mode devices
4: {
5: shut down possible DMA in progress, dequeue descriptors (not
6: normally done);
7: /*
8: * enable interrupts at device/channel level. Output devices
9: * should rely on device-level I/O complete interrupts; input
10: * devices can use DMA descriptor interrupts.
11: */
12: enable device error and all channel interrupts;
13: if output operation
14: enable device I/O complete interrupts;
15: enqueue the dma frame, enabling descriptor interrupt for input only;
16: assert reset_chan and chan_{input,output};
17: enable interrupt notification at kernel level;
18: assert load_desc;
19: assert enable_chan;
20: enable device-specific logic;
21: wait for interrupt or timeout;
22: if any errors (timeout, channel errors, device-specific errors) {
23: error recovery;
24: }
25: else if input operation {
26: if descriptor interrupt {
27: /* I/O Complete */
28: clear descriptor interrupt bit;
29: dequeue DMA frame;
30: }
31: else {
32: spurious interrupt (error);
33: }
34: }
35: else {
36: if Device I/O complete interrupt {
37: /* I/O Complete */
38: clear device interrupt bit;
39: dequeue DMA frame;
40: }
41: else {
42: spurious interrupt (error);
43: }
44: }
45: }
46:
47: DMA procedure, Streaming mode devices
48: {
49: /*
50: * initialize channel for normal operation.
51: */
52: assert reset_chan and chan_{input,output};
53: enable device error and all channel interrupts;
54:
55: /*
56: * Main loop, run forever.
57: */
58: while(1) {
59: wait for interrupt or new command;
60: if(new command) {
61: enqueue the DMA frame, enabling descriptor interrupt
62: and interrupt notification;
63: if descriptor list empty {
64: assert load_desc;
65: assert enable_chan;
66: }
67: if device logic idle
68: enable device-specific logic;
69: }
70: else {
71: /*
72: * Interrupt.
73: */
74: if any errors (timeout, channel errors,
75: device-specific errors) {
76: error recovery;
77: }
78: else if descriptor interrupt {
79:
80: /*
81: * Dequeue all completed frames.
82: */
83: clear descriptor interrupt bit;
84: do {
85: dequeue_frame(completed only, enable
86: interrupts if no more);
87: I/O complete for that frame;
88: } while(descriptors available);
89: }
90: else {
91: spurious interrupt;
92: }
93: }
94: }
95: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.