ReactOS  0.4.15-dev-2956-g61e7ea5
legacy.c File Reference
#include "serial.h"
#include <debug.h>
Include dependency graph for legacy.c:

Go to the source code of this file.

Functions

UART_TYPE SerialDetectUartType (IN PUCHAR BaseAddress)
 

Function Documentation

◆ SerialDetectUartType()

UART_TYPE SerialDetectUartType ( IN PUCHAR  BaseAddress)

Definition at line 16 of file legacy.c.

18 {
19  UCHAR Lcr, TestLcr;
20  UCHAR OldScr, Scr5A, ScrA5;
22  UCHAR NewFifoStatus;
23 
25  WRITE_PORT_UCHAR(SER_LCR(BaseAddress), Lcr ^ 0xFF);
26  TestLcr = READ_PORT_UCHAR(SER_LCR(BaseAddress)) ^ 0xFF;
28 
29  /* Accessing the LCR must work for a usable serial port */
30  if (TestLcr != Lcr)
31  return UartUnknown;
32 
33  /* Ensure that all following accesses are done as required */
42 
43  /* Test scratch pad */
50 
51  /* When non-functional, we have a 8250 */
52  if (Scr5A != 0x5A || ScrA5 != 0xA5)
53  return Uart8250;
54 
55  /* Test FIFO type */
58  NewFifoStatus = READ_PORT_UCHAR(SER_IIR(BaseAddress)) & 0xC0;
59  if (!FifoEnabled)
61  switch (NewFifoStatus)
62  {
63  case 0x00:
64  return Uart16450;
65  case 0x40:
66  case 0x80:
67  /* Not sure about this but the documentation says that 0x40
68  * indicates an unusable FIFO but my tests only worked
69  * with 0x80 */
70  return Uart16550;
71  }
72 
73  /* FIFO is only functional for 16550A+ */
74  return Uart16550A;
75 }
#define SER_FCR(x)
Definition: serial.h:127
#define SER_RBR(x)
Definition: serial.h:109
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
BOOLEAN FifoEnabled
Definition: cport_pc98.c:33
#define SER_LCR(x)
Definition: serial.h:135
#define SER_MSR(x)
Definition: serial.h:161
unsigned char BOOLEAN
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define SER_IIR(x)
Definition: serial.h:120
#define SR_FCR_ENABLE_FIFO
Definition: serial.h:128
unsigned char UCHAR
Definition: xmlstorage.h:181
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define SER_SCR(x)
Definition: serial.h:170
#define SER_LSR(x)
Definition: serial.h:152
#define SER_MCR(x)
Definition: serial.h:149
#define SER_IER(x)
Definition: serial.h:112

Referenced by SerialPnpStartDevice().