Hi,
I found some old sources from me where I detect the IRQ and the type
(8250, 16450, 16550, 16550A) of a COM port. I converted the type
detection sources to C.
The detection if there is a COM port at all is made by inverting all
bits of the LCR twice. All chips > 8250 have a scratch pad and all
16550A+ have a usable FIFO.
I attached the diff for reactos/drivers/dd/serial/legacy.c.
BTW: I'm sorry about it but my editor always changes TABs to spaces ...
Regards,
Mark
Index: drivers/dd/serial/legacy.c
===================================================================
--- drivers/dd/serial/legacy.c (revision 14202)
+++ drivers/dd/serial/legacy.c (working copy)
@@ -1,72 +1,101 @@
/* $Id:
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/bus/serial/legacy.c
* PURPOSE: Legacy serial port enumeration
*
* PROGRAMMERS: Hervé Poussineau (poussine(a)freesurf.fr)
*/
#define NDEBUG
#include "serial.h"
+#define SER_TYPE_NONE 0
+#define SER_TYPE_8250 1
+#define SER_TYPE_16450 2
+#define SER_TYPE_16550 3
+#define SER_TYPE_16550A 4
+
+static BYTE
+DetectPortType(PUCHAR BaseAddress)
+{
+ BYTE Lcr, TestLcr;
+ BYTE OldScr, Scr5A, ScrA5;
+ BOOLEAN FifoEnabled;
+ BYTE NewFifoStatus;
+
+ Lcr = READ_PORT_UCHAR(SER_LCR(BaseAddress));
+ WRITE_PORT_UCHAR(BaseAddress, (BYTE) (Lcr ^ 0xFF));
+ TestLcr = (BYTE) (READ_PORT_UCHAR(SER_LCR(BaseAddress)) ^ 0xFF);
+ WRITE_PORT_UCHAR(BaseAddress, Lcr);
+
+ /* Accessing the LCR must work for a usable serial port */
+ if (TestLcr!=Lcr)
+ return SER_TYPE_NONE;
+
+ /* Ensure that all following accesses are done as required */
+ READ_PORT_UCHAR(SER_RBR(BaseAddress));
+ READ_PORT_UCHAR(SER_IER(BaseAddress));
+ READ_PORT_UCHAR(SER_IIR(BaseAddress));
+ READ_PORT_UCHAR(SER_LCR(BaseAddress));
+ READ_PORT_UCHAR(SER_MCR(BaseAddress));
+ READ_PORT_UCHAR(SER_LSR(BaseAddress));
+ READ_PORT_UCHAR(SER_MSR(BaseAddress));
+ READ_PORT_UCHAR(SER_SCR(BaseAddress));
+
+ /* Test scratch pad */
+ OldScr = READ_PORT_UCHAR(SER_SCR(BaseAddress));
+ WRITE_PORT_UCHAR(SER_SCR(BaseAddress), 0x5A);
+ Scr5A = READ_PORT_UCHAR(SER_SCR(BaseAddress));
+ WRITE_PORT_UCHAR(SER_SCR(BaseAddress), 0xA5);
+ ScrA5 = READ_PORT_UCHAR(SER_SCR(BaseAddress));
+ WRITE_PORT_UCHAR(SER_SCR(BaseAddress), OldScr);
+
+ /* When non-functional, we have a 8250 */
+ if (Scr5A!=0x5A || ScrA5!=0xA5)
+ return SER_TYPE_8250;
+
+ /* Test FIFO type */
+ FifoEnabled = (READ_PORT_UCHAR(SER_IIR(BaseAddress)) & 0x80)!=0;
+ WRITE_PORT_UCHAR(SER_FCR(BaseAddress), SR_FCR_ENABLE_FIFO);
+ NewFifoStatus = READ_PORT_UCHAR(SER_IIR(BaseAddress)) & 0xC0;
+ if (!FifoEnabled)
+ WRITE_PORT_UCHAR(SER_FCR(BaseAddress), 0);
+ switch (NewFifoStatus) {
+ case 0x00:
+ return SER_TYPE_16450;
+ case 0x80:
+ return SER_TYPE_16550;
+ }
+
+ /* FIFO is only functional for 16550A+ */
+ return SER_TYPE_16550A;
+}
+
static BOOLEAN
SerialDoesPortExist(PUCHAR BaseAddress)
{
- BOOLEAN Found;
- BYTE Mcr;
- BYTE Msr;
-
- Found = FALSE;
-
- /* save Modem Control Register (MCR) */
- Mcr = READ_PORT_UCHAR(SER_MCR(BaseAddress));
-
- /* enable loop mode (set Bit 4 of the MCR) */
- WRITE_PORT_UCHAR(SER_MCR(BaseAddress), 0x10);
-
- /* clear all modem output bits */
- WRITE_PORT_UCHAR(SER_MCR(BaseAddress), 0x10);
-
- /* read the Modem Status Register */
- Msr = READ_PORT_UCHAR(SER_MSR(BaseAddress));
-
- /*
- * the upper nibble of the MSR (modem output bits) must be
- * equal to the lower nibble of the MCR (modem input bits)
- */
- if ((Msr & 0xf0) == 0x00)
- {
- /* set all modem output bits */
- WRITE_PORT_UCHAR(SER_MCR(BaseAddress), 0x1f);
-
- /* read the Modem Status Register */
- Msr = READ_PORT_UCHAR(SER_MSR(BaseAddress));
-
- /*
- * the upper nibble of the MSR (modem output bits) must be
- * equal to the lower nibble of the MCR (modem input bits)
- */
- if ((Msr & 0xf0) == 0xf0)
- {
- /*
- * setup a resonable state for the port:
- * enable fifo and clear recieve/transmit buffers
- */
- WRITE_PORT_UCHAR(SER_FCR(BaseAddress),
- (SR_FCR_ENABLE_FIFO | SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT));
- WRITE_PORT_UCHAR(SER_FCR(BaseAddress), 0);
- READ_PORT_UCHAR(SER_RBR(BaseAddress));
- WRITE_PORT_UCHAR(SER_IER(BaseAddress), 0);
- Found = TRUE;
- }
- }
-
- /* restore MCR */
- WRITE_PORT_UCHAR(SER_MCR(BaseAddress), Mcr);
-
- return Found;
+ BYTE Type;
+
+ Type = DetectPortType(BaseAddress);
+ if (Type==SER_TYPE_NONE)
+ return FALSE;
+
+ if (Type==SER_TYPE_16550A) {
+ /*
+ * setup a resonable state for the port:
+ * enable fifo and clear recieve/transmit buffers
+ */
+ WRITE_PORT_UCHAR(SER_FCR(BaseAddress),
+ (SR_FCR_ENABLE_FIFO | SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT));
+ WRITE_PORT_UCHAR(SER_FCR(BaseAddress), 0);
+ }
+
+ READ_PORT_UCHAR(SER_RBR(BaseAddress));
+ WRITE_PORT_UCHAR(SER_IER(BaseAddress), 0);
+
+ return TRUE;
}
NTSTATUS
Hi,
Most of the dev team seems to be in agreement with bumping the reported version number to Win2k
but if anyone has any objections speak now or forever maintain a patch. I need Win2k to be
reported as the version number as many newer applications such as Office 2003 will not install
unless that is the latest version. If you find any places where a function, resource or anything
reports a value as NT4 or something ReactOS dependant please change it to match Windows 2000
behavior. Also I propose we just report Service Pack 4.
Thanks
Steven
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
Hi all
Currently when running a BootCD, if I ask to format the partition, I'm
told that the setup could not complete. This is on trunk, not sure
about the 0.2.6 build; can anyone confirm?
Thanks
Jason
This is the text of the final few seconds before the compilation ran out of
steam. The compiler is the standard MinGW32-gcc plus MinGW-g++, etc, in the
MinGW-3.1.0-1.exe package; the computer's a Compaq 4000 Deskpro; the OS is MS
Win95, bog-standard as far as I know.
Wesley Parish
C:/MINGW/include/c++/3.2.3/bits/stl_tree.h:1068: instantiated from
`std::_Rb_t
ree_iterator<_Val, _Val&, _Val*> std::_Rb_tree<_Key, _Val, _KeyOfValue,
_Compare
, _Alloc>::insert_unique(std::_Rb_tree_iterator<_Val, _Val&, _Val*>, const
_Val&
) [with _Key = String, _Val = std::pair<const String, ICON_ID>, _KeyOfValue =
st
d::_Select1st<std::pair<const String, ICON_ID> >, _Compare =
std::less<String>,
_Alloc = std::allocator<std::pair<const String, ICON_ID> >]'
C:/MINGW/include/c++/3.2.3/bits/stl_map.h:262: instantiated from
`std::_Rb_tre
e<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp>
>
, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare,
_Alloc>::insert(std:
:_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const
_Key
, _Tp> >, _Compare, _Alloc>::iterator, const std::pair<const _Key, _Tp>&)
[with
_Key = String, _Tp = ICON_ID, _Compare = std::less<String>, _Alloc =
std::alloca
tor<std::pair<const String, ICON_ID> >]'
C:/MINGW/include/c++/3.2.3/bits/stl_map.h:225: instantiated from `_Tp&
std::ma
p<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = String,
_Tp
= ICON_ID, _Compare = std::less<String>, _Alloc =
std::allocator<std::pair<cons
t String, ICON_ID> >]'
explorer.cpp:398: instantiated from here
C:/MINGW/include/c++/3.2.3/bits/stl_pair.h:88: invalid use of undefined type `
struct String'
utility/utility.h:737: forward declaration of `struct String'
make[1]: *** [explorer.o] Error 1
make: *** [explorer] Error 2
--
Clinersterton beademung, with all of love - RIP James Blish
-----
Mau e ki, he aha te mea nui?
You ask, what is the most important thing?
Maku e ki, he tangata, he tangata, he tangata.
I reply, it is people, it is people, it is people.
same problem here using trunk revision 14208.
tested on qemu using blank and already formated image.
--- Jason Filby <jason.filby(a)gmail.com> wrote:
> Hi all
>
> Currently when running a BootCD, if I ask to format the partition, I'm
> told that the setup could not complete. This is on trunk, not sure
> about the 0.2.6 build; can anyone confirm?
>
> Thanks
> Jason
Kind regards,
Usurp (aka Sylvain Petreolle)
humans are like computers,
yesterday the BIOS was all
- today its just a word
Hi,
I think the affects both the branch and the trunk. At the end of stage 2 setup I get a crash in
ntoskrnl: 319b and 6760c
According to my map.
8006760c <_NtAdjustPrivilegesToken@24+0xbc>
Is called in a few places and 319b is
/* Do the System Call */
call *%eax
80003199: ff d0 call *%eax
movl %eax, KTRAP_FRAME_EAX(%ebp)
8000319b: 89 45 44 mov %eax,0x44(%ebp)
Thanks
Steven
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
.\lib\rtl\largeint.c
There's a sutraction performed in your implementation. But actually it's a
logical negation (asm -> NEG; C -> ~) in this function of the low and high
part:
RtlLargeIntegerNegate()
Oliver
PS: I have no CVS access, so anyone here having it should fix this.
I created bug 585 for a blocking bug in LPC message queueing.
It seams I can't fix it. :(
There is something wrong in lpc/queue.c.
New SM that loads subsystems reading the registry config and CSR that
registers are attached to 585 (code *not* commited yet).
If fixing the LPC bug is not possible easily, I'll change SM to use a
scond thread to avoid cross calling from the same thread.
ea
Hi,
--- ea <ea(a)iol.it> wrote:
> maybe that is what I reported on the irc a few days ago (installing in
> QEMU061/Win32). Thomas could not reproduce it.
If I go through stage 2 setup quickly then it will crash. If I wait and go slowly over each page
ReactOS will not crash.
THanks
Steven
__________________________________
Do you Yahoo!?
Make Yahoo! your home page
http://www.yahoo.com/r/hs
I'd like to close this discussion with a vote.
Should we allow branches (other than trunk) with mixed new development and bugfixes
unrelated to the new development that is on the branch (miscelanea branches) ?
[ ] Yes, do allow miscelanea branches
[ ] No, don't allow miscelanea branches
Casper