source: rtems/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c @ 3299388d

4.104.114.84.95
Last change on this file since 3299388d was 8ad5399, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 18, 2000 at 4:10:50 PM

2000-10-18 Charles-Antoine Gauthier <charles.gauthier@…>

  • comm/i386-stub-glue.c, comm/tty_drv.c, comm/uart.c, comm/uart.h: Add the ability to set parity, number of data bits and number of stop bits to the existing i386 serial drivers.
  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * This software is Copyright (C) 1998 by T.sqware - all rights limited
3 * It is provided in to the public domain "as is", can be freely modified
4 * as far as this copyight notice is kept unchanged, but does not imply
5 * an endorsement by T.sqware of the product in which it is included.
6 *
7 *  $Id$
8 */
9
10#include <rtems/system.h>
11#include <rtems/score/cpu.h>
12#include <bsp.h>
13#include <irq.h>
14#include <uart.h>
15#include <assert.h>
16
17
18int  putDebugChar(int ch);     /* write a single character      */
19int  getDebugChar(void);       /* read and return a single char */
20
21/* assign an exception handler */
22void exceptionHandler(int, void (*handler)(void));   
23
24void BSP_loop(int uart);
25
26/* Current uart used by gdb stub */
27static int uart_current = 0;
28
29/*
30 * Initialize glue code linking i386-stub with the rest of
31 * the system
32 */
33void
34i386_stub_glue_init(int uart)
35{
36  assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
37
38  uart_current = uart;
39
40  BSP_uart_init(uart, 38400, CHR_8_BITS, 0, 0, 0); 
41}
42
43void BSP_uart_on(const rtems_raw_irq_connect_data* used)
44{
45  BSP_irq_enable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
46}
47
48void BSP_uart_off(const rtems_raw_irq_connect_data* used)
49{
50  BSP_irq_disable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
51}
52
53int BSP_uart_isOn(const rtems_raw_irq_connect_data* used)
54{
55  return BSP_irq_enabled_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
56}
57
58
59/*
60 * In order to have a possibility to break into
61 * running program, one has to call this function
62 */
63void i386_stub_glue_init_breakin(void)
64{
65  rtems_raw_irq_connect_data uart_raw_irq_data;
66
67  assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);
68
69  if(uart_current == BSP_UART_COM1)
70    {
71      uart_raw_irq_data.idtIndex = BSP_UART_COM1_IRQ + BSP_IRQ_VECTOR_BASE;
72    }
73  else
74    {
75      uart_raw_irq_data.idtIndex = BSP_UART_COM2_IRQ + BSP_IRQ_VECTOR_BASE;
76    }
77
78  if(!i386_get_current_idt_entry(&uart_raw_irq_data)) 
79    {
80      printk("cannot get idt entry\n");
81      rtems_fatal_error_occurred(1);
82    }
83
84  if(!i386_delete_idt_entry(&uart_raw_irq_data)) 
85    {
86      printk("cannot delete idt entry\n");
87      rtems_fatal_error_occurred(1);
88    }
89
90  uart_raw_irq_data.on  = BSP_uart_on;
91  uart_raw_irq_data.off = BSP_uart_off;
92  uart_raw_irq_data.isOn= BSP_uart_isOn;
93
94  /* Install ISR  */
95  if(uart_current == BSP_UART_COM1)
96    {
97      uart_raw_irq_data.idtIndex = BSP_UART_COM1_IRQ + BSP_IRQ_VECTOR_BASE;
98      uart_raw_irq_data.hdl = BSP_uart_dbgisr_com1;
99    }
100  else
101    {
102      uart_raw_irq_data.idtIndex = BSP_UART_COM2_IRQ + BSP_IRQ_VECTOR_BASE;
103      uart_raw_irq_data.hdl = BSP_uart_dbgisr_com2;
104    }
105
106  if (!i386_set_idt_entry (&uart_raw_irq_data)) 
107    {
108      printk("raw exception handler connection failed\n");
109      rtems_fatal_error_occurred(1);
110    }
111 
112  /* Enable interrupts */
113  BSP_uart_intr_ctrl(uart_current, BSP_UART_INTR_CTRL_GDB);
114
115  return;
116}
117
118
119int
120putDebugChar(int ch)
121{
122  assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);
123
124  BSP_uart_polled_write(uart_current, ch);
125
126  return 1;
127}
128
129int getDebugChar(void)
130{
131  int val;
132
133  assert(uart_current == BSP_UART_COM1 || uart_current == BSP_UART_COM2);
134
135  val = BSP_uart_polled_read(uart_current);
136
137  return val;
138}
139
140static void nop(){}
141static int isOn() {return 1;}
142
143void exceptionHandler(int vector, void (*handler)(void))
144{
145  rtems_raw_irq_connect_data excep_raw_irq_data;
146
147  excep_raw_irq_data.idtIndex = vector;
148
149  if(!i386_get_current_idt_entry(&excep_raw_irq_data)) 
150    {
151      printk("cannot get idt entry\n");
152      rtems_fatal_error_occurred(1);
153    }
154
155  if(!i386_delete_idt_entry(&excep_raw_irq_data)) 
156    {
157      printk("cannot delete idt entry\n");
158      rtems_fatal_error_occurred(1);
159    }
160
161  excep_raw_irq_data.on = nop;
162  excep_raw_irq_data.off = nop;
163  excep_raw_irq_data.isOn = isOn;
164  excep_raw_irq_data.hdl = handler;
165
166  if (!i386_set_idt_entry (&excep_raw_irq_data)) {
167      printk("raw exception handler connection failed\n");
168      rtems_fatal_error_occurred(1);
169    }
170  return;
171}
172
173
174
175 
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
Note: See TracBrowser for help on using the repository browser.