2010-02-02 17:21:19 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Boot Loader
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: boot/armllb/envir.c
|
|
|
|
* PURPOSE: LLB Environment Variable Routines
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2010-02-03 03:14:59 +00:00
|
|
|
ULONG LlbEnvHwPageSize;
|
2010-11-23 16:42:00 +00:00
|
|
|
ULONG LlbEnvHwMemStart = 0;
|
|
|
|
ULONG LlbEnvHwMemSize = 0;
|
|
|
|
ULONG LlbEnvRamDiskStart = 0;
|
|
|
|
ULONG LlbEnvRamDiskSize = 0;
|
|
|
|
ULONG LlbEnvHwRevision;
|
2010-02-03 03:14:59 +00:00
|
|
|
CHAR LlbEnvCmdLine[256];
|
2010-02-04 15:59:22 +00:00
|
|
|
CHAR LlbValueData[32];
|
|
|
|
|
2010-02-03 03:14:59 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
LlbEnvParseArguments(IN PATAG Arguments)
|
|
|
|
{
|
|
|
|
PATAG Atag;
|
|
|
|
|
|
|
|
/* Parse the ATAGs */
|
|
|
|
Atag = Arguments;
|
|
|
|
while (Atag->Hdr.Size)
|
|
|
|
{
|
|
|
|
/* Check tag type */
|
|
|
|
switch (Atag->Hdr.Tag)
|
|
|
|
{
|
|
|
|
case ATAG_CORE:
|
|
|
|
|
|
|
|
/* Save page size */
|
|
|
|
LlbEnvHwPageSize = Atag->u.Core.PageSize;
|
|
|
|
break;
|
|
|
|
|
2010-11-23 16:42:00 +00:00
|
|
|
case ATAG_REVISION:
|
|
|
|
|
|
|
|
/* Save page size */
|
|
|
|
LlbEnvHwRevision = Atag->u.Revision.Rev;
|
|
|
|
break;
|
|
|
|
|
2010-02-03 03:14:59 +00:00
|
|
|
case ATAG_MEM:
|
|
|
|
|
|
|
|
/* Save RAM start and size */
|
2010-11-23 16:42:00 +00:00
|
|
|
if (!LlbEnvHwMemStart) LlbEnvHwMemStart = Atag->u.Mem.Start;
|
|
|
|
LlbEnvHwMemSize += Atag->u.Mem.Size;
|
2010-02-03 03:14:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ATAG_INITRD2:
|
|
|
|
|
|
|
|
/* Save RAMDISK start and size */
|
|
|
|
LlbEnvRamDiskStart = Atag->u.InitRd2.Start;
|
|
|
|
LlbEnvRamDiskSize = Atag->u.InitRd2.Size;
|
2010-02-04 19:52:13 +00:00
|
|
|
|
2010-11-23 16:42:00 +00:00
|
|
|
#ifdef _BEAGLE_
|
2010-02-04 19:52:13 +00:00
|
|
|
/* Make sure it's 16MB-aligned */
|
|
|
|
LlbEnvRamDiskSize = (LlbEnvRamDiskSize + (16 * 1024 * 1024) - 1)
|
|
|
|
&~ ((16 * 1024 * 1024) - 1);
|
|
|
|
|
|
|
|
/* The RAMDISK actually starts 16MB later */
|
|
|
|
LlbEnvRamDiskStart += 16 * 1024 * 1024;
|
|
|
|
LlbEnvRamDiskSize -= 16 * 1024 * 1024;
|
2010-11-23 16:42:00 +00:00
|
|
|
#endif
|
2010-02-03 03:14:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ATAG_CMDLINE:
|
|
|
|
|
|
|
|
/* Save command line */
|
|
|
|
strncpy(LlbEnvCmdLine,
|
|
|
|
Atag->u.CmdLine.CmdLine,
|
|
|
|
Atag->Hdr.Size * sizeof(ULONG));
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Nothing left to handle */
|
|
|
|
case ATAG_NONE:
|
|
|
|
default:
|
2010-11-23 16:42:00 +00:00
|
|
|
break;
|
2010-02-03 03:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Next tag */
|
|
|
|
Atag = (PATAG)((PULONG)Atag + Atag->Hdr.Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* For debugging */
|
2010-11-23 16:42:00 +00:00
|
|
|
DbgPrint("[BOOTROM] Board Revision: %lx PageSize: %dKB RAM: %dMB CMDLINE: %s\n"
|
|
|
|
"[RAMDISK] Base: %lx Size: %dMB\n",
|
|
|
|
LlbEnvHwRevision,
|
|
|
|
LlbEnvHwPageSize / 1024, LlbEnvHwMemSize / 1024 / 1024, LlbEnvCmdLine,
|
|
|
|
LlbEnvRamDiskStart, LlbEnvRamDiskSize / 1024 / 1024);
|
2010-02-03 03:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
LlbEnvGetMemoryInformation(IN PULONG Base,
|
|
|
|
IN PULONG Size)
|
|
|
|
{
|
|
|
|
/* Return RAM information */
|
|
|
|
*Base = LlbEnvHwMemStart;
|
|
|
|
*Size = LlbEnvHwMemSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
LlbEnvGetRamDiskInformation(IN PULONG Base,
|
|
|
|
IN PULONG Size)
|
|
|
|
{
|
|
|
|
/* Do we have a ramdisk? */
|
|
|
|
if (LlbEnvRamDiskSize == 0)
|
|
|
|
{
|
|
|
|
/* No */
|
|
|
|
*Base = 0;
|
|
|
|
*Size = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return ramdisk information */
|
|
|
|
*Base = LlbEnvRamDiskStart;
|
|
|
|
*Size = LlbEnvRamDiskSize;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-02-02 17:21:19 +00:00
|
|
|
PCHAR
|
|
|
|
NTAPI
|
|
|
|
LlbEnvRead(IN PCHAR ValueName)
|
|
|
|
{
|
2010-02-04 15:59:22 +00:00
|
|
|
PCHAR ValuePointer;
|
|
|
|
ULONG Length = 0;
|
2010-02-03 03:14:59 +00:00
|
|
|
|
|
|
|
/* Search for the value name */
|
2010-02-04 15:59:22 +00:00
|
|
|
ValuePointer = strstr(LlbEnvCmdLine, ValueName);
|
|
|
|
if (ValuePointer)
|
|
|
|
{
|
|
|
|
/* Get the value data and its length */
|
|
|
|
ValuePointer += strlen(ValueName) + 1;
|
|
|
|
if (strchr(ValuePointer, ','))
|
|
|
|
{
|
|
|
|
/* Stop before next parameter */
|
|
|
|
Length = strchr(ValuePointer, ',') - ValuePointer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Stop before the string ends */
|
|
|
|
Length = strlen(ValuePointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy it */
|
|
|
|
strncpy(LlbValueData, ValuePointer, Length);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the data */
|
|
|
|
LlbValueData[Length] = ANSI_NULL;
|
2010-02-03 03:14:59 +00:00
|
|
|
|
|
|
|
/* Return the data */
|
2010-02-04 15:59:22 +00:00
|
|
|
return LlbValueData;
|
2010-02-02 17:21:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|
|
|
|
|