⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 ADS下的bios工程
💻 C
字号:
#include <bios/s3c2410x.h>#include <bios/boot.h>#include <bios/malloc.h>#include <bios/time.h>#include <bios/stdio.h>#include <bios/stdioint.h>#include <bios/string.h>#include <bios/system.h>#include <bios/cmd.h>#include <bios/error.h>//#include <bios/lcd.h>#include <bios/nand.h>#undef DEBUG#ifdef DEBUG#define PRINTF(fmt, args...) printf("%s-%s()[%d]: \      " fmt, __FILE__, __FUNCTION__, __LINE__, ##args)#else#define PRINTF(fmt, args...)#endifextern void vec_init(void);extern void init_IrqAction(void);extern int get_params(void);extern void Usb_Main(void);volatile int    ram_size ;volatile int    bootFlag;REG32    bios_recv_bytes;int    boot_loader_size;extern u32    sysconf_set(void);extern u32    sysconf_view(void);struct BOOT_LOADER boot_loader[] = {    {&boot_rom},    {&boot_net},    {&boot_serial},    {NULL}};#define NUM_BOOT_LOADER (sizeof(boot_loader) / sizeof(struct bootdev *))static void panic(const char *s){    if (s)        printf("%s", s);    printf(" -- System Halted");    while (1)        ;}void auto_boot(void){    struct BOOT_LOADER    *loader;    load_addr = KERNEL_LOAD_BASE;     loader = &boot_loader[0];    printf("\n\nStarting autoboot...\n");    wait_cs(200);    while (loader) {        printf("Trying %s...\n", loader -> fn -> name);        if (!loader -> fn -> init()) {             loader -> fn -> start();            if (!loader -> fn -> load())                 break;            else                 loader -> fn -> stop();        }         loader ++;     }    if (!loader)         panic("No boot devices found");            loader -> fn -> stop();            boot(); }u32 manual_boot(char *dev){    struct BOOT_LOADER    *loader;    int    i;    load_addr = KERNEL_LOAD_BASE;     loader = &boot_loader[0];    for (i = 0; i < NUM_BOOT_LOADER; i ++){        if (!str_ncmp(loader -> fn -> name, dev, strlen(dev)))             break;        loader ++;    }    if (i == NUM_BOOT_LOADER)         return  ERROR_NOT_SUPPORT;    printf("\nTrying %s boot ...\n\n", loader -> fn -> name);    if (!loader -> fn -> init()) {        loader -> fn -> start();        if (!loader -> fn -> load()) {            loader -> fn -> stop();            boot();        }         else {            loader -> fn -> stop();            return  ERROR_BOOT_FAIL;        }    }     else {        loader -> fn -> stop();        return  ERROR_BOOT_DEV_INIT;    }       return  BIOS_SUCCESS;}void start_main(int stack){    CMDPOOL    commandpool[MAX_COMMAND_LIST];    CMDPOOL    *pCmd;    u32    error;    u32    CmdOffSet = 0;    /* Initialize global variables */    PRINTF("stack(%x)\n", stack);    bootFlag = 1 ;    bios_recv_bytes = 0;    boot_loader_size = NUM_BOOT_LOADER;    pCmd = &commandpool[0];    InitCommandPool(commandpool);    /* NAND Flash Block Initialize */    CSR_WRITE(NFCONF, 0xe060);   /* 0xd830 */    //CSR_WRITE(NFCONF, 0xd830);    debug_init();    /* Initialize serial debug console*/    init_IrqAction(); /* Initialize Int_Cntr, and IRQ default handler */    malloc_init();    /* Initialize malloc pool	*/    time_init();      /* Initialize timers, and timer functions */    cli();    printf("\n");    printf("=======================================\n");    printf(" MCLK : %d MHz, MMU : %x, Baud : %d\n", FMPLLout / 1000000,           stack, DEBUG_UBAUD_REG_VAL);    printf(" Type \"help\" on the command line.    \n");    printf("=======================================\n");    get_params();  /* check system flags for parameter setting */	    while (1) {         printf("\nBIOS(%ld)> ", CmdOffSet);        if ((error = ReadCommand(pCmd, &CmdOffSet)) == 0)            break ;                     if ((pCmd -> comlen & ~IS_USED) > MAX_LENGTHOF_COMMANDLINE) {            error_msg(errors(error));            continue;        }                  if ((error = RunCommand(pCmd)) != BIOS_SUCCESS)            error_msg(errors(error));        CmdOffSet ++;        pCmd = pCmd -> nextcmd;     }    auto_boot();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -