Author: ion
Date: Wed Aug 14 04:20:17 2013
New Revision: 59732
URL:
http://svn.reactos.org/svn/reactos?rev=59732&view=rev
Log:
[SACDRV]: fix a bug in ChannelReferenceToOneByIndexwithLock and ChanMgrCreateChannel.
[SACDRV]: implement SacTranslateUnicodeToUtf8.
[NTOSKRNL]: implement HadlessCmdPutData.
EMS bringup is now functional:
"
Computer is booting, SAC started and initialized.\n\nUse the \"ch -?\" command
for information about using channels.\nUse the \"?\" command for general help.
SAC>%0
"
Modified:
trunk/reactos/drivers/sac/driver/chanmgr.c
trunk/reactos/drivers/sac/driver/util.c
trunk/reactos/ntoskrnl/ex/hdlsterm.c
Modified: trunk/reactos/drivers/sac/driver/chanmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/sac/driver/chanmgr…
==============================================================================
--- trunk/reactos/drivers/sac/driver/chanmgr.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/sac/driver/chanmgr.c [iso-8859-1] Wed Aug 14 04:20:17 2013
@@ -111,8 +111,7 @@
ChannelReferenceToOneByIndexWithLock(IN LONG Index)
{
ChannelSlotLock(Index);
- ASSERT(ChannelGetReferenceCount((Index)) == 1);
- _InterlockedExchange(&ChannelRefCount[Index], 1);
+ ChannelReferenceToOneByIndex(Index);
ChannelSlotUnlock(Index);
}
@@ -359,7 +358,7 @@
ChannelLockCreates();
/* Is the channel manager initialized? */
- if (ChannelCreateEnabled)
+ if (!ChannelCreateEnabled)
{
/* Nope, bail out */
Status = STATUS_UNSUCCESSFUL;
@@ -405,7 +404,7 @@
if (i == SAC_MAX_CHANNELS)
{
/* Bail out */
- Status = STATUS_UNSUCCESSFUL;
+ SAC_DBG(SAC_DBG_INIT, "failing here: %d %lx\n", __LINE__, Status);
goto ReturnStatus;
}
@@ -439,6 +438,7 @@
else
{
/* We couldn't create it, free the buffer */
+ SAC_DBG(SAC_DBG_INIT, "failing here: %d %lx\n", __LINE__, Status);
SacFreePool(NewChannel);
}
Modified: trunk/reactos/drivers/sac/driver/util.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/sac/driver/util.c?…
==============================================================================
--- trunk/reactos/drivers/sac/driver/util.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/sac/driver/util.c [iso-8859-1] Wed Aug 14 04:20:17 2013
@@ -41,8 +41,43 @@
OUT PULONG UTF8Count,
OUT PULONG ProcessedCount)
{
- ASSERT(FALSE);
- return FALSE;
+ *UTF8Count = 0;
+ *ProcessedCount = 0;
+
+ while ((*SourceBuffer) &&
+ (*UTF8Count < DestinationBufferSize) &&
+ (*ProcessedCount < SourceBufferLength))
+ {
+ if (*SourceBuffer & 0xFF80)
+ {
+ if (*SourceBuffer & 0xF800)
+ {
+ if ((*UTF8Count + 3) >= DestinationBufferSize) break;
+ DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 12) & 0xF) |
0xE0;
+ ++*UTF8Count;
+ DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 6) & 0x3F) |
0x80;
+ }
+ else
+ {
+ if ((*UTF8Count + 2) >= DestinationBufferSize) break;
+ DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 6) & 31) |
0xC0;
+ }
+ ++*UTF8Count;
+ DestinationBuffer[*UTF8Count] = (*SourceBuffer & 0x3F) | 0x80;
+ }
+ else
+ {
+ DestinationBuffer[*UTF8Count] = (*SourceBuffer & 0x7F);
+ }
+
+ ++*UTF8Count;
+ ++*ProcessedCount;
+ ++SourceBuffer;
+ }
+
+ ASSERT(*ProcessedCount <= SourceBufferLength);
+ ASSERT(*UTF8Count <= DestinationBufferSize);
+ return TRUE;
}
PWCHAR
Modified: trunk/reactos/ntoskrnl/ex/hdlsterm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/hdlsterm.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/hdlsterm.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/hdlsterm.c [iso-8859-1] Wed Aug 14 04:20:17 2013
@@ -171,9 +171,19 @@
VOID
NTAPI
-HdlspPutString(
- IN PUCHAR String
- )
+HdlspPutData(IN PUCHAR Data,
+ IN ULONG DataSize)
+{
+ ULONG i;
+ for (i = 0; i < DataSize; i++)
+ {
+ InbvPortPutByte(HeadlessGlobals->TerminalPort, Data[i]++);
+ }
+}
+
+VOID
+NTAPI
+HdlspPutString(IN PUCHAR String)
{
PUCHAR Dest = HeadlessGlobals->TmpBuffer;
UCHAR Char = 0;
@@ -306,17 +316,18 @@
break;
}
- /* Terminal should be on */
- if (HeadlessGlobals->TerminalEnabled)
- {
- /* Print each byte in the string making sure VT100 chars are used */
- PutString = InputBuffer;
- HdlspPutString(PutString->String);
- }
-
- /* Return success either way */
- Status = STATUS_SUCCESS;
- break;
+ /* Terminal should be on */
+ if (HeadlessGlobals->TerminalEnabled)
+ {
+ /* Print each byte in the string making sure VT100 chars are used */
+ PutString = InputBuffer;
+ HdlspPutString(PutString->String);
+ }
+
+ /* Return success either way */
+ Status = STATUS_SUCCESS;
+ break;
+
case HeadlessCmdClearDisplay:
break;
case HeadlessCmdClearToEndOfDisplay:
@@ -403,10 +414,29 @@
case HeadlessCmdQueryGUID:
break;
case HeadlessCmdPutData:
- break;
- default:
- break;
- }
+
+ /* Validate the existence of an input buffer */
+ if (!(InputBuffer) || !(InputBufferSize))
+ {
+ Status = STATUS_INVALID_PARAMETER;
+ break;
+ }
+
+ /* Terminal should be on */
+ if (HeadlessGlobals->TerminalEnabled)
+ {
+ /* Print each byte in the string making sure VT100 chars are used */
+ PutString = InputBuffer;
+ HdlspPutData(PutString->String, InputBufferSize);
+ }
+
+ /* Return success either way */
+ Status = STATUS_SUCCESS;
+ break;
+
+ default:
+ break;
+ }
/* Unset processing state */
if ((Command != HeadlessCmdAddLogEntry) &&