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

上一篇主要与NAND和环境变量有关,这一篇接着分析。

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

#ifdef CONFIG_VFD
/* must do this after the framebuffer is allocated */
drv_vfd_init();
#endif /* CONFIG_VFD */    --------前面说过,我们没定义。


/* IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");    -----从环境变量中获得

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

IPaddr_t getenv_IPaddr (char *var)
{
return (string_to_ip(getenv(var)));
}

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


/* MAC Address */
{
int i;
ulong reg;
char *s, *e;
char tmp[64];


i = getenv_r ("ethaddr", tmp, sizeof (tmp));
s = (i > 0) ? tmp : NULL;


for (reg = 0; reg < 6; ++reg) {
gd->bd->bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}


#ifdef CONFIG_HAS_ETH1
i = getenv_r ("eth1addr", tmp, sizeof (tmp));
s = (i > 0) ? tmp : NULL;


for (reg = 0; reg < 6; ++reg) {
gd->bd->bi_enet1addr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}
#endif
}


devices_init (); /* get the devices list going. */  ---有待于以后查看。这些好像都与输入和输出有关,如IIC,Serial等

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

int devices_init (void)
{
#ifndef CONFIG_ARM     /* already relocated for current ARM implementation */
ulong relocation_offset = gd->reloc_off;
int i;


/* relocate device name pointers */
for (i = 0; i < (sizeof (stdio_names) / sizeof (char *)); ++i) {
stdio_names[i] = (char *) (((ulong) stdio_names[i]) +
relocation_offset);
}
#endif


/* Initialize the list */
devlist = ListCreate (sizeof (device_t));

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

list_t devlist = 0;

typedef struct ListStructTag **list_t;        /* The list abstract data type */

typedef struct ListStructTag
    {
    int signature;              /* debugging aid */
    int percentIncrease;        /* %of current size to increase by when list is out of space */
    int minNumItemsIncrease;    /* fixed number of items to increase by when list is out of space */
    int listSize;               /* number of items than can fit in the currently allocated memory */
    int itemSize;               /* the size of each item in the list (same for every item) */
    int numItems;               /* number of items currently in the list */
    unsigned char itemList[1];  /* resizable array of list elements */
    } ListStruct;



device_t *stdio_devices[] = { NULL, NULL, NULL };
char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };



/* Device information */
typedef struct {
int flags; /* Device flags: input/output/system */
int ext; /* Supported extensions */
char name[16]; /* Device name */


/* GENERAL functions */


int (*start) (void); /* To start the device */
int (*stop) (void); /* To stop the device */


/* OUTPUT functions */


void (*putc) (const char c); /* To put a char */
void (*puts) (const char *s); /* To put a string (accelerator) */


/* INPUT functions */


int (*tstc) (void); /* To test if a char is ready... */
int (*getc) (void); /* To get that char */


/* Other functions */


void *priv; /* Private extensions */
}
device_t;

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


if (devlist == NULL) {
eputs ("Cannot initialize the list of devices!\n");
return -1;
}
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
vga_init();
#endif
#ifdef CONFIG_LCD
drv_lcd_init ();
#endif
#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
drv_video_init ();
#endif
#ifdef CONFIG_KEYBOARD
drv_keyboard_init ();
#endif
#ifdef CONFIG_LOGBUFFER
drv_logbuff_init ();
#endif
drv_system_init ();
#ifdef CONFIG_SERIAL_MULTI
serial_devices_init ();
#endif
#ifdef CONFIG_USB_TTY
drv_usbtty_init ();
#endif
#ifdef CONFIG_NETCONSOLE
drv_nc_init ();
#endif
if(0)
{

uchar chip=0xEC;
uint addr=0x04;
int alen=1;
uchar buffer[1]={0x55};
int len=1;
//i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
i2c_write (chip, addr, alen, buffer, len);


//printf("iic_write %d \n",f);
}


return (0);
}

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


#ifdef CONFIG_CMC_PU2    ------没定义
load_sernum_ethaddr ();
#endif /* CONFIG_CMC_PU2 */


jumptable_init ();

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

      还是与那个全局量gd有关

void jumptable_init (void)
{
int i;


gd->jt = (void **) malloc (XF_MAX * sizeof (void *));
for (i = 0; i < XF_MAX; i++)
gd->jt[i] = (void *) dummy;


gd->jt[XF_get_version] = (void *) get_version;
gd->jt[XF_malloc] = (void *) malloc;
gd->jt[XF_free] = (void *) free;
gd->jt[XF_getenv] = (void *) getenv;
gd->jt[XF_setenv] = (void *) setenv;
gd->jt[XF_get_timer] = (void *) get_timer;
gd->jt[XF_simple_strtoul] = (void *) simple_strtoul;
gd->jt[XF_udelay] = (void *) udelay;
#if defined(CONFIG_I386) || defined(CONFIG_PPC)
gd->jt[XF_install_hdlr] = (void *) irq_install_handler;
gd->jt[XF_free_hdlr] = (void *) irq_free_handler;
#endif /* I386 || PPC */
#if (CONFIG_COMMANDS & CFG_CMD_I2C)
gd->jt[XF_i2c_write] = (void *) i2c_write;
gd->jt[XF_i2c_read] = (void *) i2c_read;
#endif /* CFG_CMD_I2C */
}

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


console_init_r (); /* fully init console as a device */


#if defined(CONFIG_MISC_INIT_R)    ------没定义
/* miscellaneous platform dependent initialisations */
misc_init_r ();
#endif


/* enable exceptions */
enable_interrupts ();   -----看下面

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

#ifdef CONFIG_USE_IRQ   
/* enable IRQ interrupts */
void enable_interrupts(void)
{
unsigned long temp;
__asm__ __volatile__("mrs %0, cpsr\n" "bic %0, %0, #0x80\n" "msr cpsr_c, %0":"=r"(temp)
    ::"memory");
}

#else
void enable_interrupts(void)
{
return;
}

#endif

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


/* Perform network card initialisation if necessary */      
#ifdef CONFIG_DRIVER_CS8900
//cs8900_get_enetaddr (gd->bd->bi_enetaddr);
#endif


#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
if (getenv ("ethaddr")) {
smc_set_mac_addr(gd->bd->bi_enetaddr);
}
#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */

                                                                                    ------------上面都没定义


/* Initialize from environment */
if ((s = getenv ("loadaddr")) != NULL) {
load_addr = simple_strtoul (s, NULL, 16);
}
#if (CONFIG_COMMANDS & CFG_CMD_NET)
if ((s = getenv ("bootfile")) != NULL) {
copy_filename (BootFile, s, sizeof (BootFile));
}
#endif /* CFG_CMD_NET */


#ifdef BOARD_LATE_INIT        -----#define BOARD_LATE_INIT
board_late_init ();
#endif

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

int board_late_init (void)
{
uint *magic = (uint*)(PHYS_SDRAM_1);

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

#define PHYS_SDRAM_1 MEMORY_BASE_ADDRESS /* SDRAM Bank #1 */

-----------------------------------------------
char boot_cmd[100];


if ((0x24564236 == magic[0]) && (0x20764316 == magic[1])) {     ----这个不知在那里赋的值,好像没有。
sprintf(boot_cmd, "nand erase 0 40000;nand write %08x 0 40000", PHYS_SDRAM_1 + 0x8000);
magic[0] = 0;
magic[1] = 0;
printf("\nready for self-burning U-Boot image\n\n");
setenv("bootdelay", "0");
setenv("bootcmd", boot_cmd);
}


return 0;
}

-----------------------------------------------------------------------
#if (CONFIG_COMMANDS & CFG_CMD_NET)
#if defined(CONFIG_NET_MULTI)
puts ("Net:     ");
#endif
eth_initialize(gd->bd);
#endif
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;) {
main_loop ();
}   ------终于到这个函数了,也意味着我们的分析将要结束了。



/* NOTREACHED - no way out of command loop except booting */
}

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





你可能感兴趣的:(list,cmd,null,语言,三星,Pointers)