三星uboot1.1.6源码分析——start.s(8)--C语言部分(2)

上一篇只是开了个头,这一篇我们来分析,那个数组中的函数。

---------------------------------------------------------------------------------------------------

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)

{
/*
* setup up stacks if necessary    看注释,就明白了,还是那个UBOOT内存映射图,那个图这是太重要了。
*/
#ifdef CONFIG_USE_IRQ
IRQ_STACK_START = _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4;
FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
#endif
return 0;

}

-------------------------------------------------------------------------

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;




return (0);


这里有点不太明白,那就是为什么没有对下面这个寄存器进行操作:




}

--------------------------------------------------------------------------------------------







  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值