上一篇只是开了个头,这一篇我们来分析,那个数组中的函数。
---------------------------------------------------------------------------------------------------
init_fnc_t *init_sequence[] = {
cpu_init,/* basic cpu dependent setup */
board_init,/* basic board dependent setup */
interrupt_init,/* set up exceptions */
env_init,/* initialize environment */
init_baudrate,/* initialze baudrate settings */
serial_init, /* serial communications setup */
console_init_f,/* stage 1 init of console */
display_banner,/* say that we are here */
#if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo,/* display cpu info (and speed) */
#endif
#if defined(CONFIG_DISPLAY_BOARDINFO)
checkboard, /* display board info */
#endif
dram_init, /* configure available RAM banks */
display_dram_config,
NULL,
};
------------------------------------------------------------------------------------------
1、
int cpu_init (void)
{}
-------------------------------------------------------------------------
2、
int board_init(void)
{
DECLARE_GLOBAL_DATA_PTR;
-------------------------------------------------------------------------------
其中有:
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r8")
------------------------------------------------------------------------------
cs8900_pre_init(); 网卡有关,我们用的不是这个。
gd->bd->bi_arch_number = MACH_TYPE;
gd->bd->bi_boot_params = (PHYS_SDRAM_1+0x100); 有启动参数有关。
----------------------------------------------------------------------------------
还是和那两个数据结构有关,我在其他博客中有详细的说明。其中有如下定义:
/*
* Architecture magic and machine type
*/
#define MACH_TYPE 1626
#define PHYS_SDRAM_1MEMORY_BASE_ADDRESS /* SDRAM Bank #1 */
#define MEMORY_BASE_ADDRESS0x50000000
这和我们物理内存DRAM的连接方式有关。
--------------------------------------------------------------------------------
#if 0
icache_enable();
dcache_enable();
#endif
return 0;
}
----------------------------------------------------------------------------------------
3、
int interrupt_init(void)
{
S3C64XX_TIMERS *const timers = S3C64XX_GetBase_TIMERS();
----------------------------------------------------------------
typedef struct {
S3C64XX_REG32 TCFG0;
S3C64XX_REG32 TCFG1;
S3C64XX_REG32 TCON;
S3C64XX_TIMERch[4];
S3C64XX_REG32 TCNTB4;
S3C64XX_REG32 TCNTO4;
} S3C64XX_TIMERS;
/* PWM TIMER (see manual chapter 10) */
typedef struct {
S3C64XX_REG32 TCNTB;
S3C64XX_REG32 TCMPB;
S3C64XX_REG32 TCNTO;
} /*__attribute__((__packed__))*/ S3C64XX_TIMER;
typedef vu_char S3C64XX_REG8;
typedef vu_short S3C64XX_REG16;
typedef vu_long S3C64XX_REG32;
typedef unsigned charuchar;
typedef volatile unsigned long vu_long;
typedef volatile unsigned short vu_short;
typedef volatile unsigned char vu_char;
-------------------------------
static inline S3C64XX_TIMERS * S3C64XX_GetBase_TIMERS(void)
{
return (S3C64XX_TIMERS *)ELFIN_TIMER_BASE;
}
/*
* PWM timer
*/
#define ELFIN_TIMER_BASE0x7F006000
#define TCFG0_REG__REG(0x7F006000)
#define TCFG1_REG__REG(0x7F006004)
#define TCON_REG__REG(0x7F006008)
#define TCNTB0_REG__REG(0x7F00600c)
#define TCMPB0_REG__REG(0x7F006010)
#define TCNTO0_REG__REG(0x7F006014)
#define TCNTB1_REG__REG(0x7F006018)
#define TCMPB1_REG__REG(0x7F00601c)
#define TCNTO1_REG__REG(0x7F006020)
#define TCNTB2_REG__REG(0x7F006024)
#define TCMPB2_REG__REG(0x7F006028)
#define TCNTO2_REG__REG(0x7F00602c)
#define TCNTB3_REG__REG(0x7F006030)
#define TCMPB3_REG__REG(0x7F006034)
#define TCNTO3_REG__REG(0x7F006038)
#define TCNTB4_REG__REG(0x7F00603c)
#define TCNTO4_REG__REG(0x7F006040)
----------------------------------------------------------------
/* use PWM Timer 4 because it has no output */
/* prescaler for Timer 4 is 16 */
timers->TCFG0 = 0x0f00;
------------看图:
------------------------------------------------------
if (timer_load_val == 0) { ------------- int timer_load_val = 0; ( Interrupts.c (cpu\s3c64xx) )
/*
* for 10 ms clock period @ PCLK with 4 bit divider = 1/2
* (default) and prescaler = 16. Should be 10390
* @33.25MHz and 15625 @ 50 MHz
*/
timer_load_val = get_PCLK() / (2 * 16 * 100);
}
-------这个公式中的 2就是4 bit divider = 1/2,16就是prescaler = 16,100因为我们要的是10ms,所以要除100
/* load value for 10 ms timeout */
lastdec = timers->TCNTB4 = timer_load_val;
/* auto load, manual update of Timer 4 */
timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO | TCON_4_UPDATE;
/* auto load, start Timer 4 */
timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO | COUNT_4_ON;
timestamp = 0;
这里有点不太明白,那就是为什么没有对下面这个寄存器进行操作:
}
--------------------------------------------------------------------------------------------