7 #include "../../gsmstate.h" 9 #ifdef GSM_ENABLE_SERIALDEVICE 12 #include "../../gsmcomon.h" 13 #include "../../misc/coding/coding.h" 23 #include <sys/farptr.h> 24 #include <sys/movedata.h> 27 extern unsigned short __djgpp_ds_alias;
28 extern void SVAsyncProtISR(
void);
30 static unsigned char SVAsyncStatus=0;
32 static void lock_interrupt_memory(
void);
33 static void unlock_interrupt_memory(
void);
35 #define Ctrl8259_0 0x020 36 #define Ctrl8259_1 0x021 39 static unsigned char VectorNum;
40 static unsigned char EnableIRQ;
41 static unsigned char DisableIRQ;
42 static _go32_dpmi_seginfo ProtVector;
43 static _go32_dpmi_seginfo info;
46 static unsigned short Port;
61 unsigned volatile char RecBuffer[BufSize] = { 0 };
62 unsigned volatile int RecHead, RecTail;
65 static void SVAsyncStop(
void)
67 if(!SVAsyncStatus)
return;
71 outportb(Ctrl8259_1, (inportb(Ctrl8259_1) | DisableIRQ));
74 outportb(LCR, (inportb(LCR) & 0x7F));
78 outportb(MCR, (inportb(MCR) & 0xF7));
81 _go32_dpmi_set_protected_mode_interrupt_vector(VectorNum, &ProtVector);
85 static void SVAsyncClear(
void)
98 void SVAsyncSet(
unsigned int Baud,
unsigned int Control)
101 unsigned char divlow, divhigh;
105 divisor = 115200 / Baud;
109 outportb(LCR, Control | 0x80);
110 divlow = divisor & 0x000000ff;
111 divhigh = (divisor >> 8) & 0x000000ff;
112 outportb(BRDL, divlow);
113 outportb(BRDH, divhigh);
115 outportb(LCR, Control & 0x007F);
121 void SVAsyncHand(
unsigned int Hand)
123 outportb(MCR, Hand | 0x08);
126 static void lock_interrupt_memory(
void)
130 unsigned long address;
132 __dpmi_get_segment_base_address(_my_ds(), &address);
134 info.address = (int) address + (
int) &RDR;
135 info.size =
sizeof(RDR);
136 errval = __dpmi_lock_linear_region(&info);
137 if(errval == -1) printf(
"Error in locking memory\n!");
139 info.address = (int) address + (
int) &LSR;
140 info.size =
sizeof(LSR);
141 errval = __dpmi_lock_linear_region(&info);
142 if(errval == -1) printf(
"Error in locking memory\n!");
144 info.address = (int) address + (
int) &RecHead;
145 info.size =
sizeof(RecHead);
146 errval = __dpmi_lock_linear_region(&info);
147 if(errval == -1) printf(
"Error in locking memory\n!");
149 info.address = (int) address + (
int) &RecBuffer;
150 info.size =
sizeof(RecBuffer);
151 errval = __dpmi_lock_linear_region(&info);
152 if(errval == -1) printf(
"Error in locking memory\n!");
154 info.address = (int) address + (
int) RecBuffer;
156 errval = __dpmi_lock_linear_region(&info);
157 if(errval == -1) printf(
"Error in locking memory\n!");
159 __dpmi_get_segment_base_address(_my_cs(), &address);
161 info.address = (int) address + (
int) SVAsyncProtISR;
163 errval = __dpmi_lock_linear_region(&info);
164 if(errval == -1) printf(
"Error in locking memory\n!");
167 static void unlock_interrupt_memory(
void)
170 unsigned long address;
172 __dpmi_get_segment_base_address(_my_ds(), &address);
173 info.address = (int) address + (
int) &RDR;
174 info.size =
sizeof(RDR);
175 __dpmi_unlock_linear_region(&info);
176 info.address = (int) address + (
int) &LSR;
177 info.size =
sizeof(LSR);
178 __dpmi_unlock_linear_region(&info);
179 info.address = (int) address + (
int) &RecHead;
180 info.size =
sizeof(RecHead);
181 __dpmi_unlock_linear_region(&info);
182 info.address = (int) address + (
int) &RecBuffer;
183 info.size =
sizeof(RecBuffer);
184 __dpmi_unlock_linear_region(&info);
185 info.address = (int) address + (
int) RecBuffer;
187 __dpmi_unlock_linear_region(&info);
189 __dpmi_get_segment_base_address(_my_cs(), &address);
191 info.address = (int) address + (
int) SVAsyncProtISR;
193 __dpmi_unlock_linear_region(&info);
249 lock_interrupt_memory();
250 atexit(unlock_interrupt_memory);
252 outportb(MCR, (inportb(MCR) & 0xF7));
256 _go32_dpmi_get_protected_mode_interrupt_vector(VectorNum, &ProtVector);
258 info.pm_offset = (int) SVAsyncProtISR;
259 info.pm_selector = _my_cs();
260 _go32_dpmi_set_protected_mode_interrupt_vector(VectorNum, &info);
265 outportb(Ctrl8259_1, (inportb(Ctrl8259_1) & EnableIRQ));
268 outportb(LCR, (inportb(LCR) & 0x7F));
283 }
while(!(temp & 1));
286 outportb(MCR, (inportb(MCR) | 0x08));
297 if (inportb(SCR) == 0x55) {
302 if (inportb(SCR) == 0xAA) {
318 smprintf(s,
"UART 16450 or UART 8250 with scratch pad\n");
319 }
else if ((i&0x40) == 0) {
320 smprintf(s,
"UART 16550 - broken FIFO\n");
334 if ((inportb(IIR) & 0xc0) != 0xc0) {
341 smprintf(s,
"UART 16450A - FIFO disabled\n");
343 smprintf(s,
"UART 16450A - FIFO enabled\n");
351 d->Control = BITS_8 | STOP_1;
354 SVAsyncSet(d->Speed,d->Control | NO_PARITY);
366 SVAsyncSet(d->Speed, d->Control | ODD_PARITY);
368 SVAsyncSet(d->Speed, d->Control | NO_PARITY);
377 SVAsyncHand(DTR | RTS);
396 SVAsyncSet(d->Speed, d->Control | ODD_PARITY);
398 SVAsyncSet(d->Speed, d->Control | NO_PARITY);
406 if(RecTail == RecHead)
return 0;
409 buf[0] = RecBuffer[RecTail++];
410 if(RecTail >= BufSize) RecTail = 0;
420 for (i=0;i<nbytes;i++) {
421 while(~inportb(LSR) & 0x20);
422 outportb(THR, buf[i]);
GSM_Config * CurrentConfig
union GSM_Device::@0 Data
int smprintf(GSM_StateMachine *s, const char *format,...)