Chinaunix首页 | 论坛 | 博客
  • 博客访问: 611508
  • 博文数量: 120
  • 博客积分: 2284
  • 博客等级: 大尉
  • 技术积分: 1330
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-25 10:49
个人简介

http://guliqun1983.blog.163.com/blog/static/501116852011730535314/

文章分类
文章存档

2013年(23)

2012年(23)

2011年(74)

分类: LINUX

2011-10-08 14:20:53

(5)init_baudrate         lib_arm/board.c

static int init_baudrate (void)
{
DECLARE_GLOBAL_DATA_PTR;

uchar tmp[64];                                                      /* long enough for environment variables */
int i = getenv_r ("baudrate", tmp, sizeof (tmp));

    /* The getenv_r() function obtains the current value of the environment
        variable name and copies it to buf.     If name is not in the current envi-
        ronment, or the string length of the value of name is longer than len
        characters, then -1 is returned and errno is set to indicate the error.*/

gd->bd->bi_baudrate = gd->baudrate = (i > 0)
      ? (int) simple_strtoul (tmp, NULL, 10)        /*以10进制解析tmp的值*/
      : CONFIG_BAUDRATE;

return (0);
}

(6)serial_init       cpu/arm920t/s3c24x0/serial.c

/*
* Initialise the serial port with the given baudrate. The settings
* are always 8 data bits, no parity, 1 stop bit, no start bits.
*
*/
int serial_init (void)
{
serial_setbrg ();

return (0);
}

void serial_setbrg (void)
{
DECLARE_GLOBAL_DATA_PTR;
S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
int i;
unsigned int reg = 0;

/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
reg = get_PCLK() / (16 * gd->baudrate) - 1;                  /*查看手册的314页*/

/* FIFO enable, Tx/Rx FIFO clear */
uart->UFCON = 0x07;               /*UART FIFO CONTROL    REGISTER*/                                          
uart->UMCON = 0x0;                /*UART MODEM CONTROL REGISTER*/
/* Normal,No parity,1 stop,8 bit */
uart->ULCON = 0x3;                /*UART LINE CONTROL REGISTER*/
/*
     * tx=level,rx=edge,disable timeout int.,enable rx error int.,
     * normal,interrupt or polling
     */
uart->UCON = 0x245;               /* UART CONTROL REGISTER*/
uart->UBRDIV = reg;

#ifdef CONFIG_HWFLOW
uart->UMCON = 0x1;                         /* RTS up */
#endif
for (i = 0; i < 100; i++);
}

初始化串口,只是设置了相关寄存器。我的板子上UART0和UART1都和MAX232相连。至于怎么用还不清楚。    还有一个疑问,就是UART和DMA以及中断的关系没有理清。

(7)console_init_f      common/console.c

int console_init_f (void)
{
DECLARE_GLOBAL_DATA_PTR;

gd->have_console = 1;

#ifdef CONFIG_SILENT_CONSOLE
if (getenv("silent") != NULL)
    gd->flags |= GD_FLG_SILENT;
#endif

return (0);
}
(8)    display_banner    lib_arm/board.c

static int display_banner (void)
{
printf ("\n\n%s\n\n", version_string);
printf ("U-Boot code: %08lX -> %08lX    BSS: -> %08lX\n",
    _armboot_start, _bss_start, _bss_end);
#ifdef CONFIG_MODEM_SUPPORT
puts ("Modem Support enabled\n");
#endif
#ifdef CONFIG_USE_IRQ
printf ("IRQ Stack: %08lx\n", IRQ_STACK_START);
printf ("FIQ Stack: %08lx\n", FIQ_STACK_START);
#endif

return (0);
}     

注意,该子程序就是输出到串口的东东,如果没有输出,说明在该函数或之前的某个地方出了问题。但是为什么没有传送的代码呢,用不着吗?

(9)dram_init              board/smdk2410/smdk2410.c

int dram_init (void)                                                                                                                                    {
DECLARE_GLOBAL_DATA_PTR;

gd->bd->bi_dram[0].start = PHYS_SDRAM_1;        /* #define PHYS_SDRAM_1    0x30000000 */
gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; /* #define PHYS_SDRAM_1_SIZE 0x04000000*/
return 0;
}

(10)    display_dram_config           lib_arm/board.c

static int display_dram_config (void)
{
DECLARE_GLOBAL_DATA_PTR;
int i;

puts ("RAM Configuration:\n");

for(i=0; i     printf ("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
    print_size (gd->bd->bi_dram[i].size, "\n");
}

return (0);
}

init_sequence[]终于分析完毕,但尚有些地方没有理解透彻,在调试时要进一步分析。
阅读(3604) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~