2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Serial port driver
4 * FILE: drivers/bus/serial/legacy.c
5 * PURPOSE: Legacy serial port enumeration
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8 * Mark Junker (mjscod@gmx.de)
17 IN PUCHAR BaseAddress
)
20 UCHAR OldScr
, Scr5A
, ScrA5
;
24 Lcr
= READ_PORT_UCHAR(SER_LCR(BaseAddress
));
25 WRITE_PORT_UCHAR(SER_LCR(BaseAddress
), Lcr
^ 0xFF);
26 TestLcr
= READ_PORT_UCHAR(SER_LCR(BaseAddress
)) ^ 0xFF;
27 WRITE_PORT_UCHAR(SER_LCR(BaseAddress
), Lcr
);
29 /* Accessing the LCR must work for a usable serial port */
33 /* Ensure that all following accesses are done as required */
34 READ_PORT_UCHAR(SER_RBR(BaseAddress
));
35 READ_PORT_UCHAR(SER_IER(BaseAddress
));
36 READ_PORT_UCHAR(SER_IIR(BaseAddress
));
37 READ_PORT_UCHAR(SER_LCR(BaseAddress
));
38 READ_PORT_UCHAR(SER_MCR(BaseAddress
));
39 READ_PORT_UCHAR(SER_LSR(BaseAddress
));
40 READ_PORT_UCHAR(SER_MSR(BaseAddress
));
41 READ_PORT_UCHAR(SER_SCR(BaseAddress
));
43 /* Test scratch pad */
44 OldScr
= READ_PORT_UCHAR(SER_SCR(BaseAddress
));
45 WRITE_PORT_UCHAR(SER_SCR(BaseAddress
), 0x5A);
46 Scr5A
= READ_PORT_UCHAR(SER_SCR(BaseAddress
));
47 WRITE_PORT_UCHAR(SER_SCR(BaseAddress
), 0xA5);
48 ScrA5
= READ_PORT_UCHAR(SER_SCR(BaseAddress
));
49 WRITE_PORT_UCHAR(SER_SCR(BaseAddress
), OldScr
);
51 /* When non-functional, we have a 8250 */
52 if (Scr5A
!= 0x5A || ScrA5
!= 0xA5)
56 FifoEnabled
= (READ_PORT_UCHAR(SER_IIR(BaseAddress
)) & 0x80) != 0;
57 WRITE_PORT_UCHAR(SER_FCR(BaseAddress
), SR_FCR_ENABLE_FIFO
);
58 NewFifoStatus
= READ_PORT_UCHAR(SER_IIR(BaseAddress
)) & 0xC0;
60 WRITE_PORT_UCHAR(SER_FCR(BaseAddress
), 0);
61 switch (NewFifoStatus
)
67 /* Not sure about this but the documentation says that 0x40
68 * indicates an unusable FIFO but my tests only worked
73 /* FIFO is only functional for 16550A+ */