Implement a proper ARM startup routine. We disable the FIQ and IRQ lines, then disable and flush D and I caches, set up a temporary boot stack, and call ArmInit.

In ArmInit we define the structure that a compatible bootloader has to send us and currently make some assertions on it, before dropping into the common, portable, freeldr startup (BootMain).
This would be the place where we would want to setup UART0 for serial support later on, as well as TIMER0.
In MachInit, we now define the required ARM routines we'll need, all which simply loop for now.
Also fix a bug in RamDiskInit, which could do reads from NULL pointers.


svn path=/trunk/; revision=32148
This commit is contained in:
ReactOS Portable Systems Group 2008-02-06 04:48:22 +00:00
parent c3253b0df9
commit c759455e9e
4 changed files with 271 additions and 10 deletions

View file

@ -10,12 +10,70 @@
//#include <kxarm.h>
#define CPSR_IRQ_DISABLE 0x80
#define CPSR_FIQ_DISABLE 0x40
#define CPSR_THUMB_ENABLE 0x20
#define C1_MMU_CONTROL 0x01
#define C1_ALIGNMENT_CONTROL 0x02
#define C1_DCACHE_CONTROL 0x04
#define C1_ICACHE_CONTROL 0x1000
#define C1_VECTOR_CONTROL 0x2000
/* GLOBALS ********************************************************************/
.global _start
.section startup
/* BOOT CODE ******************************************************************/
_start:
b .
//
// C entrypoint
//
ldr lr, L_ArmInit
//
// Turn off FIQs and IRQs
// FreeLDR runs without interrupts, and without paging, just like on x86
//
mrs r1, cpsr
orr r1, r1, #CPSR_IRQ_DISABLE | CPSR_FIQ_DISABLE
msr cpsr, r1
//
// Turn off caches
//
mrc p15, 0, r1, c1, c0, 0
bic r1, r1, #C1_DCACHE_CONTROL
bic r1, r1, #C1_ICACHE_CONTROL
mcr p15, 0, r1, c1, c0, 0
//
// Flush everything away
//
mov r1, #0
mcr p15, 0, r1, c7, c7, 0
//
// Okay, now give us a stack
//
ldr sp, L_BootStackEnd
//
// Go ahead and call the C initialization code
// r0 contains the ARM_BOARD_CONFIGURATION_DATA structure
//
bx lr
L_BootStackEnd:
.long BootStackEnd
L_ArmInit:
.long ArmInit
.align 4
BootStack:
.space 0x4000
BootStackEnd:
.long 0

View file

@ -12,12 +12,60 @@
/* GLOBALS ********************************************************************/
/* FUNCTIONS ******************************************************************/
VOID
MachInit(IN PCCH CommandLine)
//
// The only things we support
//
typedef enum _ARM_BOARD_TYPE
{
//
// Setup ARM routines
// Marvell Feroceon-based SoC:
// Buffalo Linkstation, KuroBox Pro, D-Link DS323 and others
//
ARM_FEROCEON = 1,
} ARM_BOARD_TYPE;
//
// Compatible boot-loaders should return us this information
//
#define ARM_BOARD_CONFIGURATION_MAJOR_VERSION 1
#define ARM_BOARD_CONFIGURATION_MINOR_VERSION 1
typedef struct _ARM_BOARD_CONFIGURATION_BLOCK
{
ULONG MajorVersion;
ULONG MinorVersion;
ARM_BOARD_TYPE BoardType;
ULONG TimerRegisterBase;
ULONG UartRegisterBase;
PBIOS_MEMORY_MAP MemoryMap;
CHAR CommandLine[256];
} ARM_BOARD_CONFIGURATION_BLOCK, *PARM_BOARD_CONFIGURATION_BLOCK;
/* FUNCTIONS ******************************************************************/
PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
VOID
ArmInit(IN PARM_BOARD_CONFIGURATION_BLOCK BootContext)
{
//
// Remember the pointer
//
ArmBoardBlock = BootContext;
//
// Let's make sure we understand the boot-loader
//
ASSERT(ArmBoardBlock->MajorVersion == ARM_BOARD_CONFIGURATION_MAJOR_VERSION);
ASSERT(ArmBoardBlock->MinorVersion == ARM_BOARD_CONFIGURATION_MINOR_VERSION);
//
// This should probably go away once we support more boards
//
ASSERT(ArmBoardBlock->BoardType == ARM_FEROCEON);
//
// Call FreeLDR's portable entrypoint with our command-line
//
BootMain(ArmBoardBlock->CommandLine);
}

View file

@ -23,3 +23,154 @@ FrLdrStartup(IN ULONG Magic)
// Start the OS
//
}
VOID
ArmConsPutChar(INT Char)
{
while (TRUE);
}
BOOLEAN
ArmConsKbHit(VOID)
{
while (TRUE);
return FALSE;
}
INT
ArmConsGetCh(VOID)
{
while (TRUE);
return FALSE;
}
BOOLEAN
ArmDiskGetBootVolume(IN PULONG DriveNumber,
IN PULONGLONG StartSector,
IN PULONGLONG SectorCount,
OUT PINT FsType)
{
while (TRUE);
return FALSE;
}
VOID
ArmDiskGetBootDevice(OUT PULONG BootDevice)
{
while (TRUE);
}
BOOLEAN
ArmDiskBootingFromFloppy(VOID)
{
while (TRUE);
return FALSE;
}
BOOLEAN
ArmDiskGetSystemVolume(IN PCHAR SystemPath,
OUT PCHAR RemainingPath,
OUT PULONG Device,
OUT PULONG DriveNumber,
OUT PULONGLONG StartSector,
OUT PULONGLONG SectorCount,
OUT PINT FsType)
{
while (TRUE);
return FALSE;
}
BOOLEAN
ArmDiskGetBootPath(IN PCHAR BootPath,
IN unsigned Size)
{
while (TRUE);
return FALSE;
}
BOOLEAN
ArmDiskNormalizeSystemPath(IN PCHAR SystemPath,
IN unsigned Size)
{
while (TRUE);
return FALSE;
}
BOOLEAN
ArmDiskGetDriveGeometry(IN ULONG DriveNumber,
OUT PGEOMETRY Geometry)
{
while (TRUE);
return FALSE;
}
BOOLEAN
ArmDiskGetPartitionEntry(IN ULONG DriveNumber,
IN ULONG PartitionNumber,
OUT PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
while (TRUE);
return FALSE;
}
BOOLEAN
ArmDiskReadLogicalSectors(IN ULONG DriveNumber,
IN ULONGLONG SectorNumber,
IN ULONG SectorCount,
IN PVOID Buffer)
{
while (TRUE);
return FALSE;
}
ULONG
ArmDiskGetCacheableBlockCount(IN ULONG DriveNumber)
{
while (TRUE);
return FALSE;
}
VOID
ArmPrepareForReactOS(IN BOOLEAN Setup)
{
while (TRUE);
}
PCONFIGURATION_COMPONENT_DATA
ArmHwDetect(VOID)
{
while (TRUE);
return NULL;
}
ULONG
ArmMemGetMemoryMap(OUT PBIOS_MEMORY_MAP BiosMemoryMap,
IN ULONG MaxMemoryMapSize)
{
while (TRUE);
return FALSE;
}
VOID
MachInit(IN PCCH CommandLine)
{
//
// Setup ARM routines
//
MachVtbl.ConsPutChar = ArmConsPutChar;
MachVtbl.ConsKbHit = ArmConsKbHit;
MachVtbl.ConsGetCh = ArmConsGetCh;
MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
MachVtbl.DiskGetBootVolume = ArmDiskGetBootVolume;
MachVtbl.DiskGetSystemVolume = ArmDiskGetSystemVolume;
MachVtbl.DiskGetBootPath = ArmDiskGetBootPath;
MachVtbl.DiskGetBootDevice = ArmDiskGetBootDevice;
MachVtbl.DiskBootingFromFloppy = ArmDiskBootingFromFloppy;
MachVtbl.DiskNormalizeSystemPath = ArmDiskNormalizeSystemPath;
MachVtbl.DiskReadLogicalSectors = ArmDiskReadLogicalSectors;
MachVtbl.DiskGetPartitionEntry = ArmDiskGetPartitionEntry;
MachVtbl.DiskGetDriveGeometry = ArmDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = ArmDiskGetCacheableBlockCount;
MachVtbl.HwDetect = ArmHwDetect;
}

View file

@ -168,9 +168,13 @@ VOID
NTAPI
RamDiskInit(IN PCHAR CmdLine)
{
PCHAR Setting;
//
// Get RAM disk parameters
//
gRamDiskBase = (PVOID)atoi(strstr(CmdLine, "rdbase="));
gRamDiskSize = atoi(strstr(CmdLine, "rdsize="));
Setting = strstr(CmdLine, "rdbase=");
if (Setting) gRamDiskBase = (PVOID)atoi(Setting);
Setting = strstr(CmdLine, "rdsize=");
if (Setting) gRamDiskSize = atoi(Setting);
}