ARM Packages: Fixed line endings

This large code change only modifies the line endings to be CRLF to be
compliant with the EDK2 coding convention document.



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14088 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin
2013-01-25 11:28:06 +00:00
parent 5767f22fca
commit 1e57a46299
280 changed files with 48862 additions and 48862 deletions

View File

@@ -1,36 +1,36 @@
#/** @file
# Beagle board package.
#
# Copyright (c) 2009, Apple Inc. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License which accompanies this distribution.
# The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
DEC_SPECIFICATION = 0x00010005
PACKAGE_NAME = BeagleBoardPkg
PACKAGE_GUID = 6eba6648-d853-4eb3-9761-528b82d5ab04
PACKAGE_VERSION = 0.1
################################################################################
#
# Include Section - list of Include Paths that are provided by this package.
# Comments are used for Keywords and Module Types.
#
# Supported Module Types:
# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
#
################################################################################
[Includes.common]
Include # Root include for the package
[Guids.common]
gBeagleBoardTokenSpaceGuid = { 0x6834fe45, 0x4aee, 0x4fc6, { 0xbc, 0xb5, 0xff, 0x45, 0xb7, 0xa8, 0x71, 0xe2 } }
#/** @file
# Beagle board package.
#
# Copyright (c) 2009, Apple Inc. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License which accompanies this distribution.
# The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
DEC_SPECIFICATION = 0x00010005
PACKAGE_NAME = BeagleBoardPkg
PACKAGE_GUID = 6eba6648-d853-4eb3-9761-528b82d5ab04
PACKAGE_VERSION = 0.1
################################################################################
#
# Include Section - list of Include Paths that are provided by this package.
# Comments are used for Keywords and Module Types.
#
# Supported Module Types:
# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
#
################################################################################
[Includes.common]
Include # Root include for the package
[Guids.common]
gBeagleBoardTokenSpaceGuid = { 0x6834fe45, 0x4aee, 0x4fc6, { 0xbc, 0xb5, 0xff, 0x45, 0xb7, 0xa8, 0x71, 0xe2 } }

View File

@@ -1,135 +1,135 @@
/** @file
*
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#include <Library/IoLib.h>
#include <Library/ArmPlatformLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Omap3530/Omap3530.h>
#include <BeagleBoard.h>
VOID
PadConfiguration (
BEAGLEBOARD_REVISION Revision
);
VOID
ClockInit (
VOID
);
/**
Detect board revision
@return Board revision
**/
BEAGLEBOARD_REVISION
BeagleBoardGetRevision (
VOID
)
{
UINT32 OldPinDir;
UINT32 Revision;
// Read GPIO 171, 172, 173
OldPinDir = MmioRead32 (GPIO6_BASE + GPIO_OE);
MmioWrite32(GPIO6_BASE + GPIO_OE, (OldPinDir | BIT11 | BIT12 | BIT13));
Revision = MmioRead32 (GPIO6_BASE + GPIO_DATAIN);
// Restore I/O settings
MmioWrite32 (GPIO6_BASE + GPIO_OE, OldPinDir);
return (BEAGLEBOARD_REVISION)((Revision >> 11) & 0x7);
}
/**
Return the current Boot Mode
This function returns the boot reason on the platform
**/
EFI_BOOT_MODE
ArmPlatformGetBootMode (
VOID
)
{
return BOOT_WITH_FULL_CONFIGURATION;
}
/**
Initialize controllers that must setup at the early stage
Some peripherals must be initialized in Secure World.
For example, some L2x0 requires to be initialized in Secure World
**/
RETURN_STATUS
ArmPlatformInitialize (
IN UINTN MpId
)
{
BEAGLEBOARD_REVISION Revision;
Revision = BeagleBoardGetRevision();
// Set up Pin muxing.
PadConfiguration (Revision);
// Set up system clocking
ClockInit ();
// Turn off the functional clock for Timer 3
MmioAnd32 (CM_FCLKEN_PER, 0xFFFFFFFF ^ CM_ICLKEN_PER_EN_GPT3_ENABLE );
ArmDataSyncronizationBarrier ();
// Clear IRQs
MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
ArmDataSyncronizationBarrier ();
return RETURN_SUCCESS;
}
/**
Initialize the system (or sometimes called permanent) memory
This memory is generally represented by the DRAM.
**/
VOID
ArmPlatformInitializeSystemMemory (
VOID
)
{
// We do not need to initialize the System Memory on RTSM
}
VOID
ArmPlatformGetPlatformPpiList (
OUT UINTN *PpiListSize,
OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
)
{
*PpiListSize = 0;
*PpiList = NULL;
}
UINTN
ArmPlatformGetCorePosition (
IN UINTN MpId
)
{
return 1;
}
/** @file
*
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#include <Library/IoLib.h>
#include <Library/ArmPlatformLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Omap3530/Omap3530.h>
#include <BeagleBoard.h>
VOID
PadConfiguration (
BEAGLEBOARD_REVISION Revision
);
VOID
ClockInit (
VOID
);
/**
Detect board revision
@return Board revision
**/
BEAGLEBOARD_REVISION
BeagleBoardGetRevision (
VOID
)
{
UINT32 OldPinDir;
UINT32 Revision;
// Read GPIO 171, 172, 173
OldPinDir = MmioRead32 (GPIO6_BASE + GPIO_OE);
MmioWrite32(GPIO6_BASE + GPIO_OE, (OldPinDir | BIT11 | BIT12 | BIT13));
Revision = MmioRead32 (GPIO6_BASE + GPIO_DATAIN);
// Restore I/O settings
MmioWrite32 (GPIO6_BASE + GPIO_OE, OldPinDir);
return (BEAGLEBOARD_REVISION)((Revision >> 11) & 0x7);
}
/**
Return the current Boot Mode
This function returns the boot reason on the platform
**/
EFI_BOOT_MODE
ArmPlatformGetBootMode (
VOID
)
{
return BOOT_WITH_FULL_CONFIGURATION;
}
/**
Initialize controllers that must setup at the early stage
Some peripherals must be initialized in Secure World.
For example, some L2x0 requires to be initialized in Secure World
**/
RETURN_STATUS
ArmPlatformInitialize (
IN UINTN MpId
)
{
BEAGLEBOARD_REVISION Revision;
Revision = BeagleBoardGetRevision();
// Set up Pin muxing.
PadConfiguration (Revision);
// Set up system clocking
ClockInit ();
// Turn off the functional clock for Timer 3
MmioAnd32 (CM_FCLKEN_PER, 0xFFFFFFFF ^ CM_ICLKEN_PER_EN_GPT3_ENABLE );
ArmDataSyncronizationBarrier ();
// Clear IRQs
MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
ArmDataSyncronizationBarrier ();
return RETURN_SUCCESS;
}
/**
Initialize the system (or sometimes called permanent) memory
This memory is generally represented by the DRAM.
**/
VOID
ArmPlatformInitializeSystemMemory (
VOID
)
{
// We do not need to initialize the System Memory on RTSM
}
VOID
ArmPlatformGetPlatformPpiList (
OUT UINTN *PpiListSize,
OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
)
{
*PpiListSize = 0;
*PpiList = NULL;
}
UINTN
ArmPlatformGetCorePosition (
IN UINTN MpId
)
{
return 1;
}

View File

@@ -1,53 +1,53 @@
#/* @file
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#*/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BeagleBoardLib
FILE_GUID = 736343a0-1d96-11e0-aaaa-0002a5d5c51b
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = ArmPlatformLib
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
Omap35xxPkg/Omap35xxPkg.dec
BeagleBoardPkg/BeagleBoardPkg.dec
[LibraryClasses]
IoLib
ArmLib
# OmapLib
MemoryAllocationLib
[Sources.common]
BeagleBoard.c
BeagleBoardMem.c
PadConfiguration.c
Clock.c
[Protocols]
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
[FixedPcd]
gArmTokenSpaceGuid.PcdFdBaseAddress
gArmTokenSpaceGuid.PcdFdSize
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
#/* @file
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#*/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BeagleBoardLib
FILE_GUID = 736343a0-1d96-11e0-aaaa-0002a5d5c51b
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = ArmPlatformLib
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
Omap35xxPkg/Omap35xxPkg.dec
BeagleBoardPkg/BeagleBoardPkg.dec
[LibraryClasses]
IoLib
ArmLib
# OmapLib
MemoryAllocationLib
[Sources.common]
BeagleBoard.c
BeagleBoardMem.c
PadConfiguration.c
Clock.c
[Protocols]
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
[FixedPcd]
gArmTokenSpaceGuid.PcdFdBaseAddress
gArmTokenSpaceGuid.PcdFdSize
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize

View File

@@ -1,103 +1,103 @@
/** @file
Basic serial IO abstaction for GDB
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Library/GdbSerialLib.h>
#include <Library/PcdLib.h>
#include <Library/IoLib.h>
#include <Library/DebugLib.h>
#include <Library/OmapLib.h>
#include <Omap3530/Omap3530.h>
RETURN_STATUS
EFIAPI
GdbSerialLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return RETURN_SUCCESS;
}
RETURN_STATUS
EFIAPI
GdbSerialInit (
IN UINT64 BaudRate,
IN UINT8 Parity,
IN UINT8 DataBits,
IN UINT8 StopBits
)
{
return RETURN_SUCCESS;
}
BOOLEAN
EFIAPI
GdbIsCharAvailable (
VOID
)
{
UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
if ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_NOT_EMPTY) {
return TRUE;
} else {
return FALSE;
}
}
CHAR8
EFIAPI
GdbGetChar (
VOID
)
{
UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
UINT32 RBR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_RBR_REG;
CHAR8 Char;
while ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_EMPTY);
Char = MmioRead8(RBR);
return Char;
}
VOID
EFIAPI
GdbPutChar (
IN CHAR8 Char
)
{
UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
UINT32 THR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_THR_REG;
while ((MmioRead8(LSR) & UART_LSR_TX_FIFO_E_MASK) == UART_LSR_TX_FIFO_E_NOT_EMPTY);
MmioWrite8(THR, Char);
}
VOID
GdbPutString (
IN CHAR8 *String
)
{
while (*String != '\0') {
GdbPutChar (*String);
String++;
}
}
/** @file
Basic serial IO abstaction for GDB
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Library/GdbSerialLib.h>
#include <Library/PcdLib.h>
#include <Library/IoLib.h>
#include <Library/DebugLib.h>
#include <Library/OmapLib.h>
#include <Omap3530/Omap3530.h>
RETURN_STATUS
EFIAPI
GdbSerialLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return RETURN_SUCCESS;
}
RETURN_STATUS
EFIAPI
GdbSerialInit (
IN UINT64 BaudRate,
IN UINT8 Parity,
IN UINT8 DataBits,
IN UINT8 StopBits
)
{
return RETURN_SUCCESS;
}
BOOLEAN
EFIAPI
GdbIsCharAvailable (
VOID
)
{
UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
if ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_NOT_EMPTY) {
return TRUE;
} else {
return FALSE;
}
}
CHAR8
EFIAPI
GdbGetChar (
VOID
)
{
UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
UINT32 RBR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_RBR_REG;
CHAR8 Char;
while ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_EMPTY);
Char = MmioRead8(RBR);
return Char;
}
VOID
EFIAPI
GdbPutChar (
IN CHAR8 Char
)
{
UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
UINT32 THR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_THR_REG;
while ((MmioRead8(LSR) & UART_LSR_TX_FIFO_E_MASK) == UART_LSR_TX_FIFO_E_NOT_EMPTY);
MmioWrite8(THR, Char);
}
VOID
GdbPutString (
IN CHAR8 *String
)
{
while (*String != '\0') {
GdbPutChar (*String);
String++;
}
}

View File

@@ -1,41 +1,41 @@
#/** @file
#
# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = GdbSerialLib
FILE_GUID = E2423349-EF5D-439B-95F5-8B8D8E3B443F
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = GdbSerialLib
CONSTRUCTOR = GdbSerialLibConstructor
[Sources.common]
GdbSerialLib.c
[Packages]
MdePkg/MdePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
Omap35xxPkg/Omap35xxPkg.dec
[LibraryClasses]
DebugLib
IoLib
OmapLib
[FixedPcd]
gOmap35xxTokenSpaceGuid.PcdOmap35xxConsoleUart
#/** @file
#
# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = GdbSerialLib
FILE_GUID = E2423349-EF5D-439B-95F5-8B8D8E3B443F
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = GdbSerialLib
CONSTRUCTOR = GdbSerialLibConstructor
[Sources.common]
GdbSerialLib.c
[Packages]
MdePkg/MdePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
Omap35xxPkg/Omap35xxPkg.dec
[LibraryClasses]
DebugLib
IoLib
OmapLib
[FixedPcd]
gOmap35xxTokenSpaceGuid.PcdOmap35xxConsoleUart

View File

@@ -75,5 +75,5 @@ InitCache (
ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);
BuildMemoryAllocationHob((EFI_PHYSICAL_ADDRESS)(UINTN)TranslationTableBase, TranslationTableSize, EfiBootServicesData);
BuildMemoryAllocationHob((EFI_PHYSICAL_ADDRESS)(UINTN)TranslationTableBase, TranslationTableSize, EfiBootServicesData);
}

View File

@@ -1,73 +1,73 @@
#/** @file
# SEC - Reset vector code that jumps to C and loads DXE core
#
# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BeagleBoardSec
FILE_GUID = d959e387-7b91-452c-90e0-a1dbac90ddb8
MODULE_TYPE = SEC
VERSION_STRING = 1.0
[Sources.ARM]
Arm/ModuleEntryPoint.S | GCC
Arm/ModuleEntryPoint.asm | RVCT
[Sources.ARM]
Sec.c
Cache.c
PadConfiguration.c
Clock.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
Omap35xxPkg/Omap35xxPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
BaseLib
DebugLib
ArmLib
IoLib
ExtractGuidedSectionLib
LzmaDecompressLib
OmapLib
PeCoffGetEntryPointLib
DebugAgentLib
MemoryAllocationLib
PrePiHobListPointerLib
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
[FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize
gEmbeddedTokenSpaceGuid.PcdFlashFvMainBase
gEmbeddedTokenSpaceGuid.PcdFlashFvMainSize
gEmbeddedTokenSpaceGuid.PcdPrePiStackSize
gEmbeddedTokenSpaceGuid.PcdPrePiStackBase
gEmbeddedTokenSpaceGuid.PcdMemoryBase
gEmbeddedTokenSpaceGuid.PcdMemorySize
gOmap35xxTokenSpaceGuid.PcdOmap35xxConsoleUart
gOmap35xxTokenSpaceGuid.PcdOmap35xxFreeTimer
gArmTokenSpaceGuid.PcdCpuVectorBaseAddress
#/** @file
# SEC - Reset vector code that jumps to C and loads DXE core
#
# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BeagleBoardSec
FILE_GUID = d959e387-7b91-452c-90e0-a1dbac90ddb8
MODULE_TYPE = SEC
VERSION_STRING = 1.0
[Sources.ARM]
Arm/ModuleEntryPoint.S | GCC
Arm/ModuleEntryPoint.asm | RVCT
[Sources.ARM]
Sec.c
Cache.c
PadConfiguration.c
Clock.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
Omap35xxPkg/Omap35xxPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
BaseLib
DebugLib
ArmLib
IoLib
ExtractGuidedSectionLib
LzmaDecompressLib
OmapLib
PeCoffGetEntryPointLib
DebugAgentLib
MemoryAllocationLib
PrePiHobListPointerLib
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
[FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize
gEmbeddedTokenSpaceGuid.PcdFlashFvMainBase
gEmbeddedTokenSpaceGuid.PcdFlashFvMainSize
gEmbeddedTokenSpaceGuid.PcdPrePiStackSize
gEmbeddedTokenSpaceGuid.PcdPrePiStackBase
gEmbeddedTokenSpaceGuid.PcdMemoryBase
gEmbeddedTokenSpaceGuid.PcdMemorySize
gOmap35xxTokenSpaceGuid.PcdOmap35xxConsoleUart
gOmap35xxTokenSpaceGuid.PcdOmap35xxFreeTimer
gArmTokenSpaceGuid.PcdCpuVectorBaseAddress

View File

@@ -1,408 +1,408 @@
/** @file
The data structures in this code come from:
OMAP35x Applications Processor Technical Reference Manual chapter 25
OMAP34xx Multimedia Device Technical Reference Manual chapter 26.4.8.
You should use the OMAP35x manual when possible. Some things, like SectionKey,
are not defined in the OMAP35x manual and you have to use the OMAP34xx manual
to find the data.
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
//TOC structure as defined by OMAP35XX TRM.
typedef struct {
unsigned int Start;
unsigned int Size;
unsigned int Reserved1;
unsigned int Reserved2;
unsigned int Reserved3;
unsigned char Filename[12];
} TOC_DATA;
//NOTE: OMAP3430 TRM has CHSETTINGS and CHRAM structures.
typedef struct {
unsigned int SectionKey;
unsigned char Valid;
unsigned char Version;
unsigned short Reserved;
unsigned int Flags;
unsigned int PRM_CLKSRC_CTRL;
unsigned int PRM_CLKSEL;
unsigned int CM_CLKSEL1_EMU;
unsigned int CM_CLKSEL_CORE;
unsigned int CM_CLKSEL_WKUP;
unsigned int CM_CLKEN_PLL_DPLL3;
unsigned int CM_AUTOIDLE_PLL_DPLL3;
unsigned int CM_CLKSEL1_PLL;
unsigned int CM_CLKEN_PLL_DPLL4;
unsigned int CM_AUTOIDLE_PLL_DPLL4;
unsigned int CM_CLKSEL2_PLL;
unsigned int CM_CLKSEL3_PLL;
unsigned int CM_CLKEN_PLL_MPU;
unsigned int CM_AUTOIDLE_PLL_MPU;
unsigned int CM_CLKSEL1_PLL_MPU;
unsigned int CM_CLKSEL2_PLL_MPU;
unsigned int CM_CLKSTCTRL_MPU;
} CHSETTINGS_DATA;
typedef struct {
unsigned int SectionKey;
unsigned char Valid;
unsigned char Reserved1;
unsigned char Reserved2;
unsigned char Reserved3;
unsigned short SDRC_SYSCONFIG_LSB;
unsigned short SDRC_CS_CFG_LSB;
unsigned short SDRC_SHARING_LSB;
unsigned short SDRC_ERR_TYPE_LSB;
unsigned int SDRC_DLLA_CTRL;
unsigned short Reserved4;
unsigned short Reserved5;
unsigned int SDRC_POWER;
unsigned short MEMORY_TYPE_CS0;
unsigned short Reserved6;
unsigned int SDRC_MCFG_0;
unsigned short SDRC_MR_0_LSB;
unsigned short SDRC_EMR1_0_LSB;
unsigned short SDRC_EMR2_0_LSB;
unsigned short SDRC_EMR3_0_LSB;
unsigned int SDRC_ACTIM_CTRLA_0;
unsigned int SDRC_ACTIM_CTRLB_0;
unsigned int SDRC_RFRCTRL_0;
unsigned short MEMORY_TYPE_CS1;
unsigned short Reserved7;
unsigned int SDRC_MCFG_1;
unsigned short SDRC_MR_1_LSB;
unsigned short SDRC_EMR1_1_LSB;
unsigned short SDRC_EMR2_1_LSB;
unsigned short SDRC_EMR3_1_LSB;
unsigned int SDRC_ACTIM_CTRLA_1;
unsigned int SDRC_ACTIM_CTRLB_1;
unsigned int SDRC_RFRCTRL_1;
unsigned int Reserved8;
unsigned short Flags;
unsigned short Reserved9;
} CHRAM_DATA;
#define CHSETTINGS_START 0xA0
#define CHSETTINGS_SIZE 0x50
#define CHRAM_START 0xF0
#define CHRAM_SIZE 0x5C
#define CLOSING_TOC_ITEM_SIZE 4
unsigned char gConfigurationHeader[512];
unsigned int gImageExecutionAddress;
char *gInputImageFile = NULL;
char *gOutputImageFile = NULL;
char *gDataFile = NULL;
static
void
PrintUsage (
void
)
{
printf("Usage..\n");
}
static
void
PopulateCHSETTINGSData (
FILE *DataFile,
CHSETTINGS_DATA *CHSETTINGSData
)
{
unsigned int Value;
CHSETTINGSData->SectionKey = 0xC0C0C0C1;
CHSETTINGSData->Valid = 0x1;
CHSETTINGSData->Version = 0x1;
CHSETTINGSData->Reserved = 0x00;
CHSETTINGSData->Flags = 0x050001FD;
//General clock settings.
fscanf(DataFile, "PRM_CLKSRC_CTRL=0x%08x\n", &Value);
CHSETTINGSData->PRM_CLKSRC_CTRL = Value;
fscanf(DataFile, "PRM_CLKSEL=0x%08x\n", &Value);
CHSETTINGSData->PRM_CLKSEL = Value;
fscanf(DataFile, "CM_CLKSEL1_EMU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL1_EMU = Value;
//Clock configuration
fscanf(DataFile, "CM_CLKSEL_CORE=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL_CORE = Value;
fscanf(DataFile, "CM_CLKSEL_WKUP=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL_WKUP = Value;
//DPLL3 (Core) settings
fscanf(DataFile, "CM_CLKEN_PLL_DPLL3=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKEN_PLL_DPLL3 = Value;
fscanf(DataFile, "CM_AUTOIDLE_PLL_DPLL3=0x%08x\n", &Value);
CHSETTINGSData->CM_AUTOIDLE_PLL_DPLL3 = Value;
fscanf(DataFile, "CM_CLKSEL1_PLL=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL1_PLL = Value;
//DPLL4 (Peripheral) settings
fscanf(DataFile, "CM_CLKEN_PLL_DPLL4=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKEN_PLL_DPLL4 = Value;
fscanf(DataFile, "CM_AUTOIDLE_PLL_DPLL4=0x%08x\n", &Value);
CHSETTINGSData->CM_AUTOIDLE_PLL_DPLL4 = Value;
fscanf(DataFile, "CM_CLKSEL2_PLL=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL2_PLL = Value;
fscanf(DataFile, "CM_CLKSEL3_PLL=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL3_PLL = Value;
//DPLL1 (MPU) settings
fscanf(DataFile, "CM_CLKEN_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKEN_PLL_MPU = Value;
fscanf(DataFile, "CM_AUTOIDLE_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_AUTOIDLE_PLL_MPU = Value;
fscanf(DataFile, "CM_CLKSEL1_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL1_PLL_MPU = Value;
fscanf(DataFile, "CM_CLKSEL2_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL2_PLL_MPU = Value;
fscanf(DataFile, "CM_CLKSTCTRL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSTCTRL_MPU = Value;
}
static
void
PopulateCHRAMData (
FILE *DataFile,
CHRAM_DATA *CHRAMData
)
{
unsigned int Value;
CHRAMData->SectionKey = 0xC0C0C0C2;
CHRAMData->Valid = 0x1;
fscanf(DataFile, "SDRC_SYSCONFIG_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_SYSCONFIG_LSB = Value;
fscanf(DataFile, "SDRC_CS_CFG_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_CS_CFG_LSB = Value;
fscanf(DataFile, "SDRC_SHARING_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_SHARING_LSB = Value;
fscanf(DataFile, "SDRC_ERR_TYPE_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_ERR_TYPE_LSB = Value;
fscanf(DataFile, "SDRC_DLLA_CTRL=0x%08x\n", &Value);
CHRAMData->SDRC_DLLA_CTRL = Value;
fscanf(DataFile, "SDRC_POWER=0x%08x\n", &Value);
CHRAMData->SDRC_POWER = Value;
fscanf(DataFile, "MEMORY_TYPE_CS0=0x%04x\n", &Value);
CHRAMData->MEMORY_TYPE_CS0 = Value;
fscanf(DataFile, "SDRC_MCFG_0=0x%08x\n", &Value);
CHRAMData->SDRC_MCFG_0 = Value;
fscanf(DataFile, "SDRC_MR_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_MR_0_LSB = Value;
fscanf(DataFile, "SDRC_EMR1_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR1_0_LSB = Value;
fscanf(DataFile, "SDRC_EMR2_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR2_0_LSB = Value;
fscanf(DataFile, "SDRC_EMR3_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR3_0_LSB = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLA_0=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLA_0 = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLB_0=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLB_0 = Value;
fscanf(DataFile, "SDRC_RFRCTRL_0=0x%08x\n", &Value);
CHRAMData->SDRC_RFRCTRL_0 = Value;
fscanf(DataFile, "MEMORY_TYPE_CS1=0x%04x\n", &Value);
CHRAMData->MEMORY_TYPE_CS1 = Value;
fscanf(DataFile, "SDRC_MCFG_1=0x%08x\n", &Value);
CHRAMData->SDRC_MCFG_1 = Value;
fscanf(DataFile, "SDRC_MR_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_MR_1_LSB = Value;
fscanf(DataFile, "SDRC_EMR1_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR1_1_LSB = Value;
fscanf(DataFile, "SDRC_EMR2_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR2_1_LSB = Value;
fscanf(DataFile, "SDRC_EMR3_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR3_1_LSB = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLA_1=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLA_1 = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLB_1=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLB_1 = Value;
fscanf(DataFile, "SDRC_RFRCTRL_1=0x%08x\n", &Value);
CHRAMData->SDRC_RFRCTRL_1 = Value;
CHRAMData->Flags = 0x0003;
}
static
void
PrepareConfigurationHeader (
void
)
{
TOC_DATA Toc;
CHSETTINGS_DATA CHSETTINGSData;
CHRAM_DATA CHRAMData;
unsigned int ConfigurationHdrOffset = 0;
FILE *DataFile;
// Open data file
DataFile = fopen(gDataFile, "rb");
if (DataFile == NULL) {
fprintf(stderr, "Can't open data file %s.\n", gDataFile);
exit(1);
}
//Initialize configuration header.
memset(gConfigurationHeader, 0x00, sizeof(gConfigurationHeader));
//CHSETTINGS TOC
memset(&Toc, 0x00, sizeof(TOC_DATA));
Toc.Start = CHSETTINGS_START;
Toc.Size = CHSETTINGS_SIZE;
strcpy((char *)Toc.Filename, (const char *)"CHSETTINGS");
memcpy(gConfigurationHeader + ConfigurationHdrOffset, &Toc, sizeof(TOC_DATA));
//Populate CHSETTINGS Data
memset(&CHSETTINGSData, 0x00, sizeof(CHSETTINGS_DATA));
PopulateCHSETTINGSData(DataFile, &CHSETTINGSData);
memcpy(gConfigurationHeader + Toc.Start, &CHSETTINGSData, Toc.Size);
//Adjust ConfigurationHdrOffset to point to next TOC
ConfigurationHdrOffset += sizeof(TOC_DATA);
//CHRAM TOC
memset(&Toc, 0x00, sizeof(TOC_DATA));
Toc.Start = CHRAM_START;
Toc.Size = CHRAM_SIZE;
strcpy((char *)Toc.Filename, (const char *)"CHRAM");
memcpy(gConfigurationHeader + ConfigurationHdrOffset, &Toc, sizeof(TOC_DATA));
//Populate CHRAM Data
memset(&CHRAMData, 0x00, sizeof(CHRAM_DATA));
PopulateCHRAMData(DataFile, &CHRAMData);
memcpy(gConfigurationHeader + Toc.Start, &CHRAMData, Toc.Size);
//Adjust ConfigurationHdrOffset to point to next TOC
ConfigurationHdrOffset += sizeof(TOC_DATA);
//Closing TOC item
memset(gConfigurationHeader + ConfigurationHdrOffset, 0xFF, CLOSING_TOC_ITEM_SIZE);
ConfigurationHdrOffset += CLOSING_TOC_ITEM_SIZE;
// Close data file
fclose(DataFile);
}
static
void
ConstructImage (
void
)
{
FILE *InputFile;
FILE *OutputFile;
unsigned int InputImageFileSize;
struct stat FileStat;
char Ch;
unsigned int i;
InputFile = fopen(gInputImageFile, "rb");
if (InputFile == NULL) {
fprintf(stderr, "Can't open input file.\n");
exit(0);
}
// Get the size of the input image.
fstat(fileno(InputFile), &FileStat);
InputImageFileSize = FileStat.st_size;
OutputFile = fopen(gOutputImageFile, "wb");
if (OutputFile == NULL) {
fprintf(stderr, "Can't open output file %s.\n", gOutputImageFile);
exit(0);
}
// Write Configuration header
fwrite(gConfigurationHeader, 1, sizeof(gConfigurationHeader), OutputFile);
// Write image header (Input image size, execution address)
fwrite(&InputImageFileSize, 1, 4, OutputFile);
fwrite(&gImageExecutionAddress, 1, 4, OutputFile);
// Copy input image to the output file.
for (i = 0; i < InputImageFileSize; i++) {
fread(&Ch, 1, 1, InputFile);
fwrite(&Ch, 1, 1, OutputFile);
}
fclose(InputFile);
fclose(OutputFile);
}
int
main (
int argc,
char** argv
)
{
char Ch;
unsigned char *ptr;
int i;
int TwoArg;
if (argc == 1) {
PrintUsage ();
exit(1);
}
for (i=1; i < argc; i++) {
if (argv[i][0] == '-') {
// TwoArg TRUE -E 0x123, FALSE -E0x1234
TwoArg = (argv[i][2] != ' ');
switch (argv[i][1]) {
case 'E': /* Image execution address */
gImageExecutionAddress = strtoul (TwoArg ? argv[i+1] : &argv[i][2], (char **)&ptr, 16);
break;
case 'I': /* Input image file */
gInputImageFile = TwoArg ? argv[i+1] : &argv[i][2];
break;
case 'O': /* Output image file */
gOutputImageFile = TwoArg ? argv[i+1] : &argv[i][2];
break;
case 'D': /* Data file */
gDataFile = TwoArg ? argv[i+1] : &argv[i][2];
break;
default:
abort ();
}
}
}
//Prepare configuration header
PrepareConfigurationHeader ();
//Build image with configuration header + image header + image
ConstructImage ();
return 0;
}
/** @file
The data structures in this code come from:
OMAP35x Applications Processor Technical Reference Manual chapter 25
OMAP34xx Multimedia Device Technical Reference Manual chapter 26.4.8.
You should use the OMAP35x manual when possible. Some things, like SectionKey,
are not defined in the OMAP35x manual and you have to use the OMAP34xx manual
to find the data.
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
//TOC structure as defined by OMAP35XX TRM.
typedef struct {
unsigned int Start;
unsigned int Size;
unsigned int Reserved1;
unsigned int Reserved2;
unsigned int Reserved3;
unsigned char Filename[12];
} TOC_DATA;
//NOTE: OMAP3430 TRM has CHSETTINGS and CHRAM structures.
typedef struct {
unsigned int SectionKey;
unsigned char Valid;
unsigned char Version;
unsigned short Reserved;
unsigned int Flags;
unsigned int PRM_CLKSRC_CTRL;
unsigned int PRM_CLKSEL;
unsigned int CM_CLKSEL1_EMU;
unsigned int CM_CLKSEL_CORE;
unsigned int CM_CLKSEL_WKUP;
unsigned int CM_CLKEN_PLL_DPLL3;
unsigned int CM_AUTOIDLE_PLL_DPLL3;
unsigned int CM_CLKSEL1_PLL;
unsigned int CM_CLKEN_PLL_DPLL4;
unsigned int CM_AUTOIDLE_PLL_DPLL4;
unsigned int CM_CLKSEL2_PLL;
unsigned int CM_CLKSEL3_PLL;
unsigned int CM_CLKEN_PLL_MPU;
unsigned int CM_AUTOIDLE_PLL_MPU;
unsigned int CM_CLKSEL1_PLL_MPU;
unsigned int CM_CLKSEL2_PLL_MPU;
unsigned int CM_CLKSTCTRL_MPU;
} CHSETTINGS_DATA;
typedef struct {
unsigned int SectionKey;
unsigned char Valid;
unsigned char Reserved1;
unsigned char Reserved2;
unsigned char Reserved3;
unsigned short SDRC_SYSCONFIG_LSB;
unsigned short SDRC_CS_CFG_LSB;
unsigned short SDRC_SHARING_LSB;
unsigned short SDRC_ERR_TYPE_LSB;
unsigned int SDRC_DLLA_CTRL;
unsigned short Reserved4;
unsigned short Reserved5;
unsigned int SDRC_POWER;
unsigned short MEMORY_TYPE_CS0;
unsigned short Reserved6;
unsigned int SDRC_MCFG_0;
unsigned short SDRC_MR_0_LSB;
unsigned short SDRC_EMR1_0_LSB;
unsigned short SDRC_EMR2_0_LSB;
unsigned short SDRC_EMR3_0_LSB;
unsigned int SDRC_ACTIM_CTRLA_0;
unsigned int SDRC_ACTIM_CTRLB_0;
unsigned int SDRC_RFRCTRL_0;
unsigned short MEMORY_TYPE_CS1;
unsigned short Reserved7;
unsigned int SDRC_MCFG_1;
unsigned short SDRC_MR_1_LSB;
unsigned short SDRC_EMR1_1_LSB;
unsigned short SDRC_EMR2_1_LSB;
unsigned short SDRC_EMR3_1_LSB;
unsigned int SDRC_ACTIM_CTRLA_1;
unsigned int SDRC_ACTIM_CTRLB_1;
unsigned int SDRC_RFRCTRL_1;
unsigned int Reserved8;
unsigned short Flags;
unsigned short Reserved9;
} CHRAM_DATA;
#define CHSETTINGS_START 0xA0
#define CHSETTINGS_SIZE 0x50
#define CHRAM_START 0xF0
#define CHRAM_SIZE 0x5C
#define CLOSING_TOC_ITEM_SIZE 4
unsigned char gConfigurationHeader[512];
unsigned int gImageExecutionAddress;
char *gInputImageFile = NULL;
char *gOutputImageFile = NULL;
char *gDataFile = NULL;
static
void
PrintUsage (
void
)
{
printf("Usage..\n");
}
static
void
PopulateCHSETTINGSData (
FILE *DataFile,
CHSETTINGS_DATA *CHSETTINGSData
)
{
unsigned int Value;
CHSETTINGSData->SectionKey = 0xC0C0C0C1;
CHSETTINGSData->Valid = 0x1;
CHSETTINGSData->Version = 0x1;
CHSETTINGSData->Reserved = 0x00;
CHSETTINGSData->Flags = 0x050001FD;
//General clock settings.
fscanf(DataFile, "PRM_CLKSRC_CTRL=0x%08x\n", &Value);
CHSETTINGSData->PRM_CLKSRC_CTRL = Value;
fscanf(DataFile, "PRM_CLKSEL=0x%08x\n", &Value);
CHSETTINGSData->PRM_CLKSEL = Value;
fscanf(DataFile, "CM_CLKSEL1_EMU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL1_EMU = Value;
//Clock configuration
fscanf(DataFile, "CM_CLKSEL_CORE=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL_CORE = Value;
fscanf(DataFile, "CM_CLKSEL_WKUP=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL_WKUP = Value;
//DPLL3 (Core) settings
fscanf(DataFile, "CM_CLKEN_PLL_DPLL3=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKEN_PLL_DPLL3 = Value;
fscanf(DataFile, "CM_AUTOIDLE_PLL_DPLL3=0x%08x\n", &Value);
CHSETTINGSData->CM_AUTOIDLE_PLL_DPLL3 = Value;
fscanf(DataFile, "CM_CLKSEL1_PLL=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL1_PLL = Value;
//DPLL4 (Peripheral) settings
fscanf(DataFile, "CM_CLKEN_PLL_DPLL4=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKEN_PLL_DPLL4 = Value;
fscanf(DataFile, "CM_AUTOIDLE_PLL_DPLL4=0x%08x\n", &Value);
CHSETTINGSData->CM_AUTOIDLE_PLL_DPLL4 = Value;
fscanf(DataFile, "CM_CLKSEL2_PLL=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL2_PLL = Value;
fscanf(DataFile, "CM_CLKSEL3_PLL=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL3_PLL = Value;
//DPLL1 (MPU) settings
fscanf(DataFile, "CM_CLKEN_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKEN_PLL_MPU = Value;
fscanf(DataFile, "CM_AUTOIDLE_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_AUTOIDLE_PLL_MPU = Value;
fscanf(DataFile, "CM_CLKSEL1_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL1_PLL_MPU = Value;
fscanf(DataFile, "CM_CLKSEL2_PLL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSEL2_PLL_MPU = Value;
fscanf(DataFile, "CM_CLKSTCTRL_MPU=0x%08x\n", &Value);
CHSETTINGSData->CM_CLKSTCTRL_MPU = Value;
}
static
void
PopulateCHRAMData (
FILE *DataFile,
CHRAM_DATA *CHRAMData
)
{
unsigned int Value;
CHRAMData->SectionKey = 0xC0C0C0C2;
CHRAMData->Valid = 0x1;
fscanf(DataFile, "SDRC_SYSCONFIG_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_SYSCONFIG_LSB = Value;
fscanf(DataFile, "SDRC_CS_CFG_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_CS_CFG_LSB = Value;
fscanf(DataFile, "SDRC_SHARING_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_SHARING_LSB = Value;
fscanf(DataFile, "SDRC_ERR_TYPE_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_ERR_TYPE_LSB = Value;
fscanf(DataFile, "SDRC_DLLA_CTRL=0x%08x\n", &Value);
CHRAMData->SDRC_DLLA_CTRL = Value;
fscanf(DataFile, "SDRC_POWER=0x%08x\n", &Value);
CHRAMData->SDRC_POWER = Value;
fscanf(DataFile, "MEMORY_TYPE_CS0=0x%04x\n", &Value);
CHRAMData->MEMORY_TYPE_CS0 = Value;
fscanf(DataFile, "SDRC_MCFG_0=0x%08x\n", &Value);
CHRAMData->SDRC_MCFG_0 = Value;
fscanf(DataFile, "SDRC_MR_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_MR_0_LSB = Value;
fscanf(DataFile, "SDRC_EMR1_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR1_0_LSB = Value;
fscanf(DataFile, "SDRC_EMR2_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR2_0_LSB = Value;
fscanf(DataFile, "SDRC_EMR3_0_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR3_0_LSB = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLA_0=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLA_0 = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLB_0=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLB_0 = Value;
fscanf(DataFile, "SDRC_RFRCTRL_0=0x%08x\n", &Value);
CHRAMData->SDRC_RFRCTRL_0 = Value;
fscanf(DataFile, "MEMORY_TYPE_CS1=0x%04x\n", &Value);
CHRAMData->MEMORY_TYPE_CS1 = Value;
fscanf(DataFile, "SDRC_MCFG_1=0x%08x\n", &Value);
CHRAMData->SDRC_MCFG_1 = Value;
fscanf(DataFile, "SDRC_MR_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_MR_1_LSB = Value;
fscanf(DataFile, "SDRC_EMR1_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR1_1_LSB = Value;
fscanf(DataFile, "SDRC_EMR2_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR2_1_LSB = Value;
fscanf(DataFile, "SDRC_EMR3_1_LSB=0x%04x\n", &Value);
CHRAMData->SDRC_EMR3_1_LSB = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLA_1=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLA_1 = Value;
fscanf(DataFile, "SDRC_ACTIM_CTRLB_1=0x%08x\n", &Value);
CHRAMData->SDRC_ACTIM_CTRLB_1 = Value;
fscanf(DataFile, "SDRC_RFRCTRL_1=0x%08x\n", &Value);
CHRAMData->SDRC_RFRCTRL_1 = Value;
CHRAMData->Flags = 0x0003;
}
static
void
PrepareConfigurationHeader (
void
)
{
TOC_DATA Toc;
CHSETTINGS_DATA CHSETTINGSData;
CHRAM_DATA CHRAMData;
unsigned int ConfigurationHdrOffset = 0;
FILE *DataFile;
// Open data file
DataFile = fopen(gDataFile, "rb");
if (DataFile == NULL) {
fprintf(stderr, "Can't open data file %s.\n", gDataFile);
exit(1);
}
//Initialize configuration header.
memset(gConfigurationHeader, 0x00, sizeof(gConfigurationHeader));
//CHSETTINGS TOC
memset(&Toc, 0x00, sizeof(TOC_DATA));
Toc.Start = CHSETTINGS_START;
Toc.Size = CHSETTINGS_SIZE;
strcpy((char *)Toc.Filename, (const char *)"CHSETTINGS");
memcpy(gConfigurationHeader + ConfigurationHdrOffset, &Toc, sizeof(TOC_DATA));
//Populate CHSETTINGS Data
memset(&CHSETTINGSData, 0x00, sizeof(CHSETTINGS_DATA));
PopulateCHSETTINGSData(DataFile, &CHSETTINGSData);
memcpy(gConfigurationHeader + Toc.Start, &CHSETTINGSData, Toc.Size);
//Adjust ConfigurationHdrOffset to point to next TOC
ConfigurationHdrOffset += sizeof(TOC_DATA);
//CHRAM TOC
memset(&Toc, 0x00, sizeof(TOC_DATA));
Toc.Start = CHRAM_START;
Toc.Size = CHRAM_SIZE;
strcpy((char *)Toc.Filename, (const char *)"CHRAM");
memcpy(gConfigurationHeader + ConfigurationHdrOffset, &Toc, sizeof(TOC_DATA));
//Populate CHRAM Data
memset(&CHRAMData, 0x00, sizeof(CHRAM_DATA));
PopulateCHRAMData(DataFile, &CHRAMData);
memcpy(gConfigurationHeader + Toc.Start, &CHRAMData, Toc.Size);
//Adjust ConfigurationHdrOffset to point to next TOC
ConfigurationHdrOffset += sizeof(TOC_DATA);
//Closing TOC item
memset(gConfigurationHeader + ConfigurationHdrOffset, 0xFF, CLOSING_TOC_ITEM_SIZE);
ConfigurationHdrOffset += CLOSING_TOC_ITEM_SIZE;
// Close data file
fclose(DataFile);
}
static
void
ConstructImage (
void
)
{
FILE *InputFile;
FILE *OutputFile;
unsigned int InputImageFileSize;
struct stat FileStat;
char Ch;
unsigned int i;
InputFile = fopen(gInputImageFile, "rb");
if (InputFile == NULL) {
fprintf(stderr, "Can't open input file.\n");
exit(0);
}
// Get the size of the input image.
fstat(fileno(InputFile), &FileStat);
InputImageFileSize = FileStat.st_size;
OutputFile = fopen(gOutputImageFile, "wb");
if (OutputFile == NULL) {
fprintf(stderr, "Can't open output file %s.\n", gOutputImageFile);
exit(0);
}
// Write Configuration header
fwrite(gConfigurationHeader, 1, sizeof(gConfigurationHeader), OutputFile);
// Write image header (Input image size, execution address)
fwrite(&InputImageFileSize, 1, 4, OutputFile);
fwrite(&gImageExecutionAddress, 1, 4, OutputFile);
// Copy input image to the output file.
for (i = 0; i < InputImageFileSize; i++) {
fread(&Ch, 1, 1, InputFile);
fwrite(&Ch, 1, 1, OutputFile);
}
fclose(InputFile);
fclose(OutputFile);
}
int
main (
int argc,
char** argv
)
{
char Ch;
unsigned char *ptr;
int i;
int TwoArg;
if (argc == 1) {
PrintUsage ();
exit(1);
}
for (i=1; i < argc; i++) {
if (argv[i][0] == '-') {
// TwoArg TRUE -E 0x123, FALSE -E0x1234
TwoArg = (argv[i][2] != ' ');
switch (argv[i][1]) {
case 'E': /* Image execution address */
gImageExecutionAddress = strtoul (TwoArg ? argv[i+1] : &argv[i][2], (char **)&ptr, 16);
break;
case 'I': /* Input image file */
gInputImageFile = TwoArg ? argv[i+1] : &argv[i][2];
break;
case 'O': /* Output image file */
gOutputImageFile = TwoArg ? argv[i+1] : &argv[i][2];
break;
case 'D': /* Data file */
gDataFile = TwoArg ? argv[i+1] : &argv[i][2];
break;
default:
abort ();
}
}
}
//Prepare configuration header
PrepareConfigurationHeader ();
//Build image with configuration header + image header + image
ConstructImage ();
return 0;
}