[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
"


svn path=/trunk/; revision=59732
This commit is contained in:
Alex Ionescu 2013-08-14 04:20:17 +00:00
parent cf0c04f897
commit 7347dd9801
3 changed files with 88 additions and 23 deletions

View file

@ -111,8 +111,7 @@ VOID
ChannelReferenceToOneByIndexWithLock(IN LONG Index)
{
ChannelSlotLock(Index);
ASSERT(ChannelGetReferenceCount((Index)) == 1);
_InterlockedExchange(&ChannelRefCount[Index], 1);
ChannelReferenceToOneByIndex(Index);
ChannelSlotUnlock(Index);
}
@ -359,7 +358,7 @@ ChanMgrCreateChannel(OUT PSAC_CHANNEL *Channel,
ChannelLockCreates();
/* Is the channel manager initialized? */
if (ChannelCreateEnabled)
if (!ChannelCreateEnabled)
{
/* Nope, bail out */
Status = STATUS_UNSUCCESSFUL;
@ -405,7 +404,7 @@ ChanMgrCreateChannel(OUT PSAC_CHANNEL *Channel,
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 @@ ChanMgrCreateChannel(OUT PSAC_CHANNEL *Channel,
else
{
/* We couldn't create it, free the buffer */
SAC_DBG(SAC_DBG_INIT, "failing here: %d %lx\n", __LINE__, Status);
SacFreePool(NewChannel);
}

View file

@ -41,8 +41,43 @@ SacTranslateUnicodeToUtf8(IN PWCHAR SourceBuffer,
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

View file

@ -171,9 +171,19 @@ HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
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;
@ -317,6 +327,7 @@ HdlspDispatch(IN HEADLESS_CMD Command,
/* Return success either way */
Status = STATUS_SUCCESS;
break;
case HeadlessCmdClearDisplay:
break;
case HeadlessCmdClearToEndOfDisplay:
@ -403,7 +414,26 @@ HdlspDispatch(IN HEADLESS_CMD Command,
case HeadlessCmdQueryGUID:
break;
case HeadlessCmdPutData:
/* 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;
}