📄 init.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
// File: init.c
//
// Samsung SMDK2410X board initialization code.
//
#include <bsp.h>
//------------------------------------------------------------------------------
//
// Function: OEMInit
//
// This is Windows CE OAL initialization function. It is called from kernel
// after basic initialization is made.
//
// 总线宽度控制定义(0表示8位,1表示16位,2表示32位)
#define DW8 (0x0)
#define DW16 (0x1)
#define DW32 (0x2)
#define WAIT (0x1<<2)
#define UBLB (0x1<<3)
#define B3_BWCON (DW16|WAIT|UBLB)
void DM9000_Initialize(void);
void USB2410Dev_Initialize(void);
void S3C2410_InterruptInitialize(void);
void OEMInit()
{
OALMSG(OAL_FUNC, (L"+OEMInit\r\n"));
S3C2410_InterruptInitialize();
USB2410Dev_Initialize();
DM9000_Initialize();
// Set memory size for DrWatson kernel support
dwNKDrWatsonSize = 128 * 1024;
// Initilize cache globals
OALCacheGlobalsInit();
OALLogSerial(
L"DCache: %d sets, %d ways, %d line size, %d size\r\n",
g_oalCacheInfo.L1DSetsPerWay, g_oalCacheInfo.L1DNumWays,
g_oalCacheInfo.L1DLineSize, g_oalCacheInfo.L1DSize
);
OALLogSerial(
L"ICache: %d sets, %d ways, %d line size, %d size\r\n",
g_oalCacheInfo.L1ISetsPerWay, g_oalCacheInfo.L1INumWays,
g_oalCacheInfo.L1ILineSize, g_oalCacheInfo.L1ISize
);
// Initialize interrupts
if (!OALIntrInit()) {
OALMSG(OAL_ERROR, (
L"ERROR: OEMInit: failed to initialize interrupts\r\n"
));
}
// Initialize system clock
OALTimerInit(1, S3C2410X_PCLK/2000, 0);
// Initialize the KITL connection if required
OALKitlStart();
OALMSG(OAL_FUNC, (L"-OEMInit\r\n"));
}
void Delay(int value)
{
int i;
for (i = 0; i < value; i++);
}
void DM9000_Initialize(void)
{
// Local Variables
S3C2410X_MEMCTRL_REG *pMemCtrlReg;
S3C2410X_IOPORT_REG *pIOPortReg;
// Initialize the BANK3 for DM9000
pMemCtrlReg = (S3C2410X_MEMCTRL_REG*)OALPAtoVA(S3C2410X_BASE_REG_PA_MEMCTRL, FALSE);
pIOPortReg = (S3C2410X_IOPORT_REG*)OALPAtoVA(S3C2410X_BASE_REG_PA_IOPORT, FALSE);
pMemCtrlReg->BWSCON &= ~(0xF << 12);
pMemCtrlReg->BWSCON |= B3_BWCON << 12;
pMemCtrlReg->BANKCON3 = (0 << 13)|(3 << 11)|(7 << 8)|(1 << 6)|(3 << 4)|(3 << 2)|(3 << 0);
pIOPortReg->EXTINT0 &= ~0x3;
pIOPortReg->EXTINT0 |= 0x01;
// Reset Pin, DM9000 need to Reset???
pIOPortReg->GPGCON &= ~(0x3 << 4);
pIOPortReg->GPGCON |= (0x1 << 4);
pIOPortReg->GPGDAT &= ~(0x1 << 2);
Delay(5000);
pIOPortReg->GPGDAT |= (0x1 << 2);
Delay(5000);
pIOPortReg->GPGDAT &= ~(0x1 << 2);
//Delay(20000);
}
void USB2410Dev_Initialize(void)
{
// Local Variables
S3C2410X_IOPORT_REG *pIOPortReg;
S3C2410X_CLKPWR_REG *pCLKReg;
pIOPortReg = (S3C2410X_IOPORT_REG*)OALPAtoVA(S3C2410X_BASE_REG_PA_IOPORT, FALSE);
pCLKReg = (S3C2410X_CLKPWR_REG*)OALPAtoVA(S3C2410X_BASE_REG_PA_CLOCK_POWER, FALSE);
/* 要加上时钟锁定代码 */
pCLKReg->UPLLCON = (40 << 12) | (1 << 4) | 2; /* 配置USB Device 时钟为48MHz */
//Delay(0x2000);
//
// SoftConnect USB Deivce : GPG9 = 0
//
pIOPortReg->GPGCON &= ~(0x3 << 18);
pIOPortReg->GPGCON |= (0x1 << 18); // GPG9 is Output
pIOPortReg->GPGDAT &= ~(0x1 << 9); // GPG9 = 0
}
void S3C2410_InterruptInitialize(void)
{
S3C2410X_INTR_REG *pIntrReg;
pIntrReg = (S3C2410X_INTR_REG*)OALPAtoVA(S3C2410X_BASE_REG_PA_INTR, FALSE);
pIntrReg->INTMSK = 0xFFFFFFFF; /* disable all interrupt */
pIntrReg->INTSUBMSK = 0x7ff; /* disable all sub interrupt */
pIntrReg->SRCPND = 0xFFFFFFFF; /* clear all interrupt */
pIntrReg->INTPND = 0xFFFFFFFF; /* clear all IRQ Interrupt */
}
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -