Date:2011-11-20 20:30:29 (7 years 8 months ago)
Author:Werner Almesberger
Commit:58da15e017387155427765aa0b66c9b53fd70ac7
Message:rtems patches: added new UART and IRQ rearrangement, plus include fix

Some of the include paths don't work. Not sure whether my patch is a
correct fix or merely an awkward way to work around a problem that's
somewhere else.
Files: m1/patches/rtems/fix-sysconf-includes.patch (1 diff)
m1/patches/rtems/milkymist-new-uart.patch (1 diff)
m1/patches/rtems/series (1 diff)

Change Details

m1/patches/rtems/fix-sysconf-includes.patch
1Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c
2===================================================================
3--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c 2011-11-20 16:20:21.000000000 -0300
4@@ -19,7 +19,7 @@
5 #include <rtems/termiostypes.h>
6 #include <bsp/irq-generic.h>
7
8-#include "../include/system_conf.h"
9+#include "../../milkymist/include/system_conf.h"
10 #include "uart.h"
11
12 BSP_output_char_function_type BSP_output_char = BSP_uart_polled_write;
13Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c
14===================================================================
15--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c 2011-11-20 16:20:38.000000000 -0300
16@@ -14,7 +14,7 @@
17
18 #include <rtems.h>
19 #include <rtems/libio.h>
20-#include "../include/system_conf.h"
21+#include "../../milkymist/include/system_conf.h"
22 #include "uart.h"
23
24 void BSP_uart_init(int baud)
25Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_midi/midi.c
26===================================================================
27--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_midi/midi.c 2011-11-20 16:21:11.000000000 -0300
28@@ -20,7 +20,7 @@
29 #include <bsp.h>
30 #include <bsp/irq-generic.h>
31 #include <rtems/libio.h>
32-#include "../include/system_conf.h"
33+#include "../../milkymist/include/system_conf.h"
34 #include "milkymist_midi.h"
35
36 #define DEVICE_NAME "/dev/midi"
m1/patches/rtems/milkymist-new-uart.patch
1Index: rtems/c/src/lib/libbsp/lm32/milkymist/include/system_conf.h
2===================================================================
3--- rtems.orig/c/src/lib/libbsp/lm32/milkymist/include/system_conf.h 2011-08-01 10:48:11.000000000 -0300
4@@ -26,6 +26,16 @@
5 /* UART */
6 #define MM_UART_RXTX (0xe0000000)
7 #define MM_UART_DIV (0xe0000004)
8+#define MM_UART_STAT (0xe0000008)
9+#define MM_UART_CTRL (0xe000000c)
10+
11+#define UART_STAT_THRE (0x1)
12+#define UART_STAT_RX_EVT (0x2)
13+#define UART_STAT_TX_EVT (0x4)
14+
15+#define UART_CTRL_RX_INT (0x1)
16+#define UART_CTRL_TX_INT (0x2)
17+#define UART_CTRL_THRU (0x4)
18
19 /* Timers */
20 #define MM_TIMER1_COMPARE (0xe0001024)
21@@ -225,8 +235,17 @@
22
23 /* MIDI */
24 #define MM_MIDI_RXTX (0xe000b000)
25-#define MM_MIDI_DIVISOR (0xe000b004)
26-#define MM_MIDI_THRU (0xe000b008)
27+#define MM_MIDI_DIV (0xe000b004)
28+#define MM_MIDI_STAT (0xe000b008)
29+#define MM_MIDI_CTRL (0xe000b00c)
30+
31+#define MIDI_STAT_THRE (0x1)
32+#define MIDI_STAT_RX_EVT (0x2)
33+#define MIDI_STAT_TX_EVT (0x4)
34+
35+#define MIDI_CTRL_RX_INT (0x1)
36+#define MIDI_CTRL_TX_INT (0x2)
37+#define MIDI_CTRL_THRU (0x4)
38
39 /* IR */
40 #define MM_IR_RX (0xe000e000)
41@@ -248,24 +267,22 @@
42 #define BT656_FILTER_INFRAME (0x4)
43
44 /* Interrupts */
45-#define MM_IRQ_UARTRX (0)
46-#define MM_IRQ_UARTTX (1)
47-#define MM_IRQ_GPIO (2)
48-#define MM_IRQ_TIMER0 (3)
49-#define MM_IRQ_TIMER1 (4)
50-#define MM_IRQ_AC97CRREQUEST (5)
51-#define MM_IRQ_AC97CRREPLY (6)
52-#define MM_IRQ_AC97DMAR (7)
53-#define MM_IRQ_AC97DMAW (8)
54-#define MM_IRQ_PFPU (9)
55-#define MM_IRQ_TMU (10)
56-#define MM_IRQ_ETHRX (11)
57-#define MM_IRQ_ETHTX (12)
58-#define MM_IRQ_VIDEOIN (13)
59-#define MM_IRQ_MIDIRX (14)
60-#define MM_IRQ_MIDITX (15)
61-#define MM_IRQ_IR (16)
62-#define MM_IRQ_USB (17)
63+#define MM_IRQ_UART (0)
64+#define MM_IRQ_GPIO (1)
65+#define MM_IRQ_TIMER0 (2)
66+#define MM_IRQ_TIMER1 (3)
67+#define MM_IRQ_AC97CRREQUEST (4)
68+#define MM_IRQ_AC97CRREPLY (5)
69+#define MM_IRQ_AC97DMAR (6)
70+#define MM_IRQ_AC97DMAW (7)
71+#define MM_IRQ_PFPU (8)
72+#define MM_IRQ_TMU (9)
73+#define MM_IRQ_ETHRX (10)
74+#define MM_IRQ_ETHTX (11)
75+#define MM_IRQ_VIDEOIN (12)
76+#define MM_IRQ_MIDI (13)
77+#define MM_IRQ_IR (14)
78+#define MM_IRQ_USB (15)
79
80 /* Flash layout */
81 #define FLASH_BASE (0x80000000)
82Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c
83===================================================================
84--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c 2011-08-01 10:48:39.000000000 -0300
85@@ -119,25 +119,24 @@
86   rtems_interrupt_level level;
87
88   rtems_interrupt_disable(level);
89- BSP_uart_txbusy = true;
90   MM_WRITE(MM_UART_RXTX, *buf);
91   rtems_interrupt_enable(level);
92   return 0;
93 }
94
95-static rtems_isr mmconsole_txdone(rtems_vector_number n)
96-{
97- BSP_uart_txbusy = false;
98- lm32_interrupt_ack(1 << MM_IRQ_UARTTX);
99- rtems_termios_dequeue_characters(tty, 1);
100-}
101-
102-static rtems_isr mmconsole_rxdone(rtems_vector_number n)
103+static rtems_isr mmconsole_interrupt(rtems_vector_number n)
104 {
105   char c;
106- c = MM_READ(MM_UART_RXTX);
107- lm32_interrupt_ack(1 << MM_IRQ_UARTRX);
108- rtems_termios_enqueue_raw_characters(tty, &c, 1);
109+ while (MM_READ(MM_UART_STAT) & UART_STAT_RX_EVT) {
110+ c = MM_READ(MM_UART_RXTX);
111+ MM_WRITE(MM_UART_STAT, UART_STAT_RX_EVT);
112+ rtems_termios_enqueue_raw_characters(tty, &c, 1);
113+ }
114+ if (MM_READ(MM_UART_STAT) & UART_STAT_TX_EVT) {
115+ MM_WRITE(MM_UART_STAT, UART_STAT_TX_EVT);
116+ rtems_termios_dequeue_characters(tty, 1);
117+ }
118+ lm32_interrupt_ack(1 << MM_IRQ_UART);
119 }
120
121 static const rtems_termios_callbacks mmconsole_callbacks = {
122@@ -166,10 +165,9 @@
123   if (status != RTEMS_SUCCESSFUL)
124     rtems_fatal_error_occurred(status);
125
126- rtems_interrupt_catch(mmconsole_txdone, MM_IRQ_UARTTX, &dummy);
127- rtems_interrupt_catch(mmconsole_rxdone, MM_IRQ_UARTRX, &dummy);
128- bsp_interrupt_vector_enable(MM_IRQ_UARTTX);
129- bsp_interrupt_vector_enable(MM_IRQ_UARTRX);
130+ rtems_interrupt_catch(mmconsole_interrupt, MM_IRQ_UART, &dummy);
131+ bsp_interrupt_vector_enable(MM_IRQ_UART);
132+ MM_WRITE(MM_UART_CTRL, UART_CTRL_RX_INT|UART_CTRL_TX_INT);
133
134   return RTEMS_SUCCESSFUL;
135 }
136Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c
137===================================================================
138--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c 2011-08-01 10:48:39.000000000 -0300
139@@ -17,8 +17,6 @@
140 #include "../include/system_conf.h"
141 #include "uart.h"
142
143-bool BSP_uart_txbusy;
144-
145 void BSP_uart_init(int baud)
146 {
147   MM_WRITE(MM_UART_DIV, CPU_FREQUENCY/baud/16);
148@@ -26,40 +24,24 @@
149
150 void BSP_uart_polled_write(char ch)
151 {
152- int ip;
153   rtems_interrupt_level level;
154
155   rtems_interrupt_disable(level);
156- if (BSP_uart_txbusy) {
157- /* wait for the end of the transmission by the IRQ-based driver */
158- do {
159- lm32_read_interrupts(ip);
160- } while (!(ip & (1 << MM_IRQ_UARTTX)));
161- lm32_interrupt_ack(1 << MM_IRQ_UARTTX);
162- }
163+ while(!(MM_READ(MM_UART_STAT) & UART_STAT_THRE));
164   MM_WRITE(MM_UART_RXTX, ch);
165- do {
166- lm32_read_interrupts(ip);
167- } while (!(ip & (1 << MM_IRQ_UARTTX)));
168- /* if TX was busy, do not ack the IRQ
169- * so that the IRQ-based driver ISR is run */
170- if (!BSP_uart_txbusy)
171- lm32_interrupt_ack(1 << MM_IRQ_UARTTX);
172+ while(!(MM_READ(MM_UART_STAT) & UART_STAT_THRE));
173   rtems_interrupt_enable(level);
174 }
175
176 int BSP_uart_polled_read(void)
177 {
178- int ip;
179   char r;
180   rtems_interrupt_level level;
181
182   rtems_interrupt_disable(level);
183- do {
184- lm32_read_interrupts(ip);
185- } while (!(ip & (1 << MM_IRQ_UARTRX)));
186- lm32_interrupt_ack(1 << MM_IRQ_UARTRX);
187+ while(!(MM_READ(MM_UART_STAT) & UART_STAT_RX_EVT));
188   r = MM_READ(MM_UART_RXTX);
189+ MM_WRITE(MM_UART_STAT, UART_STAT_RX_EVT);
190   rtems_interrupt_enable(level);
191
192   return r;
193Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h
194===================================================================
195--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h 2011-08-01 10:48:39.000000000 -0300
196@@ -1,21 +1,16 @@
197 /*
198- * This file contains definitions for LatticeMico32 UART
199+ * This file contains definitions for the Milkymist UART
200  *
201  * The license and distribution terms for this file may be
202  * found in the file LICENSE in this distribution or at
203  * http://www.rtems.com/license/LICENSE.
204  *
205  * $Id: uart.h,v 1.2 2011/08/01 13:48:39 joel Exp $
206- *
207- * COPYRIGHT (c) Yann Sionneau <yann.sionneau@telecom-sudparis.eu> (GSoC 2010)
208- * Telecom SudParis
209  */
210
211 #ifndef _BSPUART_H
212 #define _BSPUART_H
213
214-extern bool BSP_uart_txbusy;
215-
216 void BSP_uart_init(int baud);
217 void BSP_uart_polled_write(char ch);
218 int BSP_uart_polled_read(void);
219Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_midi/midi.c
220===================================================================
221--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_midi/midi.c 2011-08-01 10:48:40.000000000 -0300
222@@ -31,9 +31,12 @@
223 {
224   unsigned char msg;
225
226- lm32_interrupt_ack(1 << MM_IRQ_MIDIRX);
227- msg = MM_READ(MM_MIDI_RXTX);
228- rtems_message_queue_send(midi_q, &msg, 1);
229+ while (MM_READ(MM_MIDI_STAT) & MIDI_STAT_RX_EVT) {
230+ msg = MM_READ(MM_MIDI_RXTX);
231+ MM_WRITE(MM_MIDI_STAT, MIDI_STAT_RX_EVT);
232+ rtems_message_queue_send(midi_q, &msg, 1);
233+ }
234+ lm32_interrupt_ack(1 << MM_IRQ_MIDI);
235 }
236
237 rtems_device_driver midi_initialize(
238@@ -57,11 +60,10 @@
239   );
240   RTEMS_CHECK_SC(sc, "create MIDI queue");
241
242- rtems_interrupt_catch(interrupt_handler, MM_IRQ_MIDIRX, &dummy);
243- bsp_interrupt_vector_enable(MM_IRQ_MIDIRX);
244-
245+ rtems_interrupt_catch(interrupt_handler, MM_IRQ_MIDI, &dummy);
246+ bsp_interrupt_vector_enable(MM_IRQ_MIDI);
247   /* Only MIDI THRU mode is supported atm */
248- MM_WRITE(MM_MIDI_THRU, 1);
249+ MM_WRITE(MM_MIDI_CTRL, MIDI_CTRL_RX_INT|MIDI_CTRL_THRU);
250
251   return RTEMS_SUCCESSFUL;
252 }
m1/patches/rtems/series
22rbtree-container-of.patch
33chain-first-last.patch
44coremsgsubmit-race.patch
5milkymist-new-uart.patch
6fix-sysconf-includes.patch

Archive Download the corresponding diff file

Branches:
master



interactive