static int initr_ide(void) { puts("IDE: "); #if defined(CONFIG_START_IDE) if (board_start_ide()) ide_init(); #else ide_init(); #endif return 0; }
static int initr_ide(void) { #ifdef CONFIG_IDE_8xx_PCCARD puts("PCMCIA:"); #else puts("IDE: "); #endif #if defined(CONFIG_START_IDE) if (board_start_ide()) ide_init(); #else ide_init(); #endif return 0; }
int main( int argc, char *argv[] ) { int i; int failures = 0; int tests = 0; ide_init(); for( i=0; test_cases[i].reg != 0; i++ ) { unsigned int oldval = long_read( test_cases[i].reg ); unsigned int newval; long_write( test_cases[i].reg, test_cases[i].write ); newval = long_read( test_cases[i].reg ); if( test_cases[i].expect == UNCHANGED ) { if( newval != oldval ) { fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n", i+1, test_cases[i].reg, oldval, newval ); failures++; } } else { if( newval != test_cases[i].expect ) { fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n", i+1, test_cases[i].reg, test_cases[i].expect, newval ); failures++; } } long_write( test_cases[i].reg, oldval ); tests++; } fprintf( stdout, "%d/%d test cases passed successfully\n", (tests-failures), tests ); return failures; }
void kmain(u32 init_stack) { init_esp_start = init_stack; init_video(); puts_color_str("Booting Panda OS ...\n", 0x0B); cli(); time_init(); gdt_init(); idt_init(); kb_init(); mm_init(); buf_init(); file_init(); inode_init(); ide_init(); task_init(); timer_init(); sysc_init(); spawn(init_user); sti(); init = 0; while(1) { if(!init) { printk("kernel running ...\n"); init = 1; } sti(); sched(); } }
int __noreturn kern_init(void) { extern char edata[], end[]; memset(edata, 0, end - edata); cons_init(); // init the console const char *message = "(THU.CST) os is loading ..."; cprintf("%s\n\n", message); print_kerninfo(); pmm_init(); // init physical memory management pic_init(); // init interrupt controller idt_init(); // init interrupt descriptor table vmm_init(); // init virtual memory management sched_init(); // init scheduler proc_init(); // init process table sync_init(); // init sync struct ide_init(); // init ide devices swap_init(); // init swap fs_init(); // init fs clock_init(); // init clock interrupt intr_enable(); // enable irq interrupt cpu_idle(); // run idle process }
void storage_switch_sd_ide(UINT8 sd_active, BOOL first) { if (sd_active) { if (!first) { #ifdef IDE_SUPPORT ide_disable(); #endif } #ifdef SDIO_SUPPORT sd_enable(SDIO_GPIO_CS, SDIO_GPIO_CS_POLOR, SDIO_GPIO_DETECT, SDIO_GPIO_LOCK); sd_init(); #endif DM_DEBUG("storage device : sdio active\n"); } else { if (!first) { #ifdef SDIO_SUPPORT sd_disable(); #endif } #ifdef IDE_SUPPORT ide_enable(25, 1); ide_init(); #endif DM_DEBUG("storage device : hdd(ide) active\n"); } }
int ide_init_r(void) { puts("IDE: "); ide_init(); return 0; }
int kern_init(void) { extern char edata[], end[]; memset(edata, 0, end - edata); cons_init(); // init the console const char *message = "(THU.CST) os is loading ..."; kprintf ("%s\n\n", message); /* Only to initialize lcpu_count. */ mp_init (); pmm_init(); // init physical memory management pmm_init_ap (); pic_init(); // init interrupt controller vmm_init(); // init virtual memory management sched_init(); // init scheduler proc_init(); // init process table sync_init(); // init sync struct ide_init(); // init ide devices swap_init(); // init swap fs_init(); // init fs clock_init(); // init clock interrupt intr_enable(); // enable irq interrupt cpu_idle(); // run idle process }
/* miscellaneous platform dependent initialisations */ int misc_init_r(void) { #if defined(CONFIG_CMD_NET) char nid[32]; unsigned char *pMACaddr = (unsigned char *)0x203F0000; /* The 0xFF check here is to make sure we don't use the address * in flash if it's simply been erased (aka all 0xFF values) */ if (getenv("ethaddr") == NULL && is_valid_ether_addr(pMACaddr)) { sprintf(nid, "%02x:%02x:%02x:%02x:%02x:%02x", pMACaddr[0], pMACaddr[1], pMACaddr[2], pMACaddr[3], pMACaddr[4], pMACaddr[5]); setenv("ethaddr", nid); } #endif #if defined(CONFIG_BFIN_IDE) #if defined(CONFIG_BFIN_TRUE_IDE) /* Enable ATASEL when in True IDE mode */ printf("Using CF True IDE Mode\n"); cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA); udelay(1000); #elif defined(CONFIG_BFIN_CF_IDE) /* Disable ATASEL when we're in Common Memory Mode */ printf("Using CF Common Memory Mode\n"); cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS); udelay(1000); #elif defined(CONFIG_BFIN_HDD_IDE) printf("Using HDD IDE Mode\n"); #endif ide_init(); #endif /* CONFIG_BFIN_IDE */ return 0; }
/** * The entry. */ int main(int argc, char *argv[], char *envp[]) { if (ginfo->status == STATUS_DEBUG) raise(SIGTRAP); cons_init(); const char *message = "(THU.CST) os is loading ..."; kprintf("%s\n\n", message); intr_init(); ide_init(); host_signal_init(); /* Only to initialize lcpu_count. */ mp_init(); pmm_init(); pmm_init_ap(); vmm_init(); sched_init(); proc_init(); swap_init(); fs_init(); sync_init(); umclock_init(); cpu_idle(); host_exit(SIGINT); return 0; }
void at_init() { common_init(); pit_set_out_func(1, pit_refresh_timer_at); dma16_init(); ide_init(); keyboard_at_init(); if (models[model].init == at_init) mouse_serial_init(); nvr_init(); pic2_init(); }
int misc_init_r(void) { #if defined(CONFIG_BFIN_IDE) #if defined(CONFIG_BFIN_CF_IDE) /*Disable ATASEL when we're in Common Memory Mode*/ cf_outb(0, CONFIG_CF_ATASEL_DIS); udelay(1000); #endif ide_init(); #endif return 0; }
void ps1_init() { AT = 1; common_init(); pit_set_out_func(1, pit_refresh_timer_at); dma16_init(); ide_init(); keyboard_at_init(); mouse_ps2_init(); nvr_init(); pic2_init(); ps1mb_init(); fdc_set_dskchg_activelow(); }
void at_init() { AT = 1; common_init(); mem_add_bios(); pit_set_out_func(1, pit_refresh_timer_at); dma16_init(); ide_init(); keyboard_at_init(); if (models[model].init == at_init) mouse_serial_init(); nvr_init(); pic2_init(); device_add(&gameport_device); }
void __noreturn kern_init(void) { //setup_exception_vector(); tlb_invalidate_all(); /* unsigned base = 0xBE000000; int i, j; for (j = 10; j < 24; ++j) { kprintf("\nj=%d\n\n\n", j); for (i = 0; i < 10; ++i) { int *addr = (int*)(base + i * 4 + (1 << j)); kprintf("0x%08x=0x%04x\n", addr, (*addr)&0xFFFF); } } */ pic_init(); // init interrupt controller cons_init(); // init the console clock_init(); // init clock interrupt // panic("init"); check_initrd(); const char *message = "(THU.CST) os is loading ...\n\n"; kprintf(message); print_kerninfo(); #if 0 kprintf("EX\n"); __asm__ volatile("syscall"); kprintf("EX RET\n"); #endif pmm_init(); // init physical memory management vmm_init(); // init virtual memory management sched_init(); proc_init(); // init process table ide_init(); fs_init(); intr_enable(); // enable irq interrupt //*(int*)(0x00124) = 0x432; //asm volatile("divu $1, $1, $1"); cpu_idle(); }
void cf_ide_init(void) { #if defined(CONFIG_BFIN_TRUE_IDE) /* Enable ATASEL when in True IDE mode */ printf("Using CF True IDE Mode\n"); cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA); udelay(1000); #elif defined(CONFIG_BFIN_CF_IDE) /* Disable ATASEL when we're in Common Memory Mode */ printf("Using CF Common Memory Mode\n"); cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS); udelay(1000); #elif defined(CONFIG_BFIN_HDD_IDE) printf("Using HDD IDE Mode\n"); #endif ide_init(); }
void ps1_common_init() { AT = 1; common_init(); mem_add_bios(); pit_set_out_func(1, pit_refresh_timer_at); dma16_init(); ide_init(); keyboard_at_init(); mouse_ps2_init(); nvr_init(); pic2_init(); fdc_set_dskchg_activelow(); device_add(&ps1_audio_device); /*PS/1 audio uses ports 200h and 202-207h, so only initialise gameport on 201h*/ device_add(&gameport_201_device); }
/* miscellaneous platform dependent initialisations */ int misc_init_r(void) { int i; int cf_stat = 0; /* Check whether CF card is inserted */ *pFIO_EDGE = FIO_EDGE_CF_BITS; *pFIO_POLAR = FIO_POLAR_CF_BITS; for (i = 0; i < 0x300; i++) asm("nop;"); if ((*pFIO_FLAG_S) & CF_STAT_BITS) { cf_stat = 0; } else { cf_stat = 1; } *pFIO_EDGE = FIO_EDGE_BITS; *pFIO_POLAR = FIO_POLAR_BITS; if (cf_stat) { printf("Booting from COMPACT flash\n"); for (i = 0; i < 0x1000; i++) asm("nop;"); for (i = 0; i < 0x1000; i++) asm("nop;"); for (i = 0; i < 0x1000; i++) asm("nop;"); serial_setbrg(); ide_init(); setenv("bootargs", ""); setenv("bootcmd", "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000"); } else { printf("Booting from FLASH\n"); } return 0; }
void kmain(ol_mmap_register_t mmr) { textinit(); clearscreen(); println("The openLoader kernel is executing. \n"); print("Current stack pointer: "); ol_registers_t regs = getregs(); printnum(regs->esp, 16, FALSE, FALSE); putc(0xa); char status = inb(0x60); if((status & 2) == 2) { println("The A20 gate is open."); putc(0xa); } pic_init(); setIDT(); outb(OL_KBC_COMMAND, OL_KB_INIT); // enable the keyboard // display mmap init_mmap(mmr); println("Multiboot memory map:\n"); display_mmap(mmr); #if 0 uint8_t active = ide_init(bootdrive); ide_read(0x100, 1<<20, &bootdrive[active], 60); uint8_t eax = ata_identify(); printnum(active, 16, FALSE, FALSE); #endif putc(0xa); println("Waiting for service interrupts.."); while(1) halt(); println("End of program reached!"); endprogram(); }
int kern_init(void) { extern char edata[], end[]; memset(edata, 0, end - edata); cons_init(); // init the console const char *message = "(THU.CST) os is loading ..."; kprintf("%s\n\n", message); print_kerninfo(); /* Only to initialize lcpu_count. */ mp_init(); debug_init(); // init debug registers pmm_init(); // init physical memory management pmm_init_ap(); pic_init(); // init interrupt controller idt_init(); // init interrupt descriptor table vmm_init(); // init virtual memory management sched_init(); // init scheduler proc_init(); // init process table sync_init(); // init sync struct ide_init(); // init ide devices #ifdef UCONFIG_SWAP swap_init(); // init swap #endif fs_init(); // init fs clock_init(); // init clock interrupt mod_init(); intr_enable(); // enable irq interrupt /* do nothing */ cpu_idle(); // run idle process }
VISIBLE void bmain(void) { __asm__ __volatile__(".code16gcc\n\t"); disable_interrupts(); __asm__ __volatile__( ".code16\n\t" "cld\n\t" "xor %%ax, %%ax\n\t" /* ax = 0x00 */ "mov %%ax, %%ds\n\t" "lgdt %0\n\t" "inc %%ax\n\t" /* ax = 0x01 */ "lmsw %%ax\n\t" /* set cr0.PE */ "mov $0x10, %%al\n\t" /* ax = 0x10 */ "mov %%ax, %%ds\n\t" "mov %%ax, %%es\n\t" "mov %%ax, %%ss\n\t" "movzx %%sp, %%esp\n\t" "ljmpl $0x08, $1f\n\t" ".code32\n" "1:\n\t" :: "m" (gdt) : "eax"); idt_init(); pic_init(); int i = 0; for (i = 0; i < 256; i++) set_int_handler(i, default_handler); //set_int_handler(IRQ_BASE + IRQ_TIMER, timer_handler); //set_int_handler(IRQ_BASE + IRQ_KEYBOARD, keyboard_handler); ide_init(); enable_interrupts(); //char buffer[512]; ide_read(0, 0xb8200); while(1); }
/** * Bootstrap processor starts running C code here. */ int main(void) { /** * ld会生成如下几个变量用来标识程序的段 * * _etext(etext) 正文段结束后第一个地址 * _edata(edata) 数据段结束后第一个地址 * _end(end) bss段结束后第一个地址 */ extern char edata[], end[]; // clear BSS memset(edata, 0, end - edata); // collect info about this machine mp_init(); lapic_init(mp_bcpu()); cprintf("\ncpu%d: starting myos\n\n", cpu()); cprintf("Welcome to myos !\n"); pinit(); // process table binit(); // buffer cache pic_init(); // interrupt controller ioapic_init(); // another interrupt controller kinit(); // physical memory allocator tvinit(); // trap vectors fileinit(); // file table iinit(); // inode cache console_init(); // I/O devices & their interrupts ide_init(); // disk if(!ismp) timer_init(); // uniprocessor timer userinit(); // first user process bootothers(); // start other processors // Finish setting up this processor in mpmain. mpmain(); }
// Starts system void init_system(multiboot_info_t* bi) { // Start display vga_init(); printk(" KiteOS V1.0 --- Initializing \n"); // PIT-less wait to show user boot for(int i=0;i<64821125;i++); vga_color(0x3, 0x0); printk("-- STARTING LOWLEVEL KERNEL --\n"); vga_color(0x5, 0x0); printk("!* Initiating GDT\n"); gdt_init(); printk("!* Initiating IDT\n"); idt_init(); printk("!* Installing Exceptions\n"); isr_init(); vga_color(0x4, 0x0); printk("*** ENTERTED PROTECTED MODE ***\n"); vga_color(0x5, 0x0); printk("!* Initiating IRQ\n"); irq_init(); printk("!* Starting PIT\n"); pit_init(); printk("!* Starting RTC\n"); rtc_init(); printk("!* Restoring Interrupts\n"); __asm__ __volatile__ ("sti"); vga_color(0x3, 0x0); printk("-- STARTING LOWLEVEL DRIVERS --\n"); vga_color(0x5, 0x0); printk("!* Starting physical memory manager\n"); kalloc_init((void*)bi->mmap_addr, (unsigned long)bi->mmap_length); printk("!* Starting keyboard driver\n"); kb_init(); printk("!* Starting IDE driver\n"); ide_init(0x1F0, 0x3F6, 0x170, 0x366); vga_color(0x4, 0x0); printk("*** Initialized system successfully ***\n"); }
extern void swap_init_nios2(void); int alt_main(void) { const char *message = "(THU.CST) os is loading ..."; kprintf("%s\n\n", message); mp_init(); pmm_init(); // init physical memory management pmm_init_ap(); vmm_init(); // init virtual memory management
void __noreturn kern_init(void) { //setup_exception_vector(); tlb_invalidate_all(); pic_init(); // init interrupt controller vga_init(); cons_init(); // init the console clock_init(); // init clock interrupt check_initrd(); const char *message = "(THU.CST) os is loading ...\n\n"; kprintf(message); print_kerninfo(); #if 0 kprintf("EX\n"); __asm__ volatile("syscall"); kprintf("EX RET\n"); #endif pmm_init(); // init physical memory management vmm_init(); // init virtual memory management sched_init(); proc_init(); // init process table ide_init(); fs_init(); intr_enable(); // enable irq interrupt //*(int*)(0x00124) = 0x432; //asm volatile("divu $1, $1, $1"); cpu_idle(); }
int read_partition_map(int device) { ide_init(DISK_PORT); ide_read_sector(DISK_PORT, 0, 0, (uint8_t *)&mbr); if (mbr.signature[0] == 0x55 && mbr.signature[1] == 0xAA) { debug_print(INFO, "Partition table found."); for (int i = 0; i < 4; ++i) { if (mbr.partitions[i].status & 0x80) { debug_print(NOTICE, "Partition #%d: @%d+%d", i+1, mbr.partitions[i].lba_first_sector, mbr.partitions[i].sector_count); } else { debug_print(NOTICE, "Partition #%d: inactive", i+1); } } return 0; } else { debug_print(ERROR, "Did not find partition table."); debug_print(ERROR, "Signature was 0x%x 0x%x instead of 0x55 0xAA", mbr.signature[0], mbr.signature[1]); debug_print(ERROR, "Parsing anyone yields:"); for (int i = 0; i < 4; ++i) { if (mbr.partitions[i].status & 0x80) { debug_print(NOTICE, "Partition #%d: @%d+%d", i+1, mbr.partitions[i].lba_first_sector, mbr.partitions[i].sector_count); } else { debug_print(NOTICE, "Partition #%d: inactive", i+1); } } } return 1; }
void sb700_after_pci_fixup(void) { #ifdef ENABLE_SATA printk_info("sata init\n"); sata_init(_pci_make_tag(0, 0x11, 0)); #endif printk_info("OHCI0-USB1 init\n"); usb_init(_pci_make_tag(0, 0x12, 0)); printk_info("OHCI1-USB1 init\n"); usb_init(_pci_make_tag(0, 0x12, 1)); #if 1 //printk_info("EHCI-USB1 init\n"); //usb_init2(_pci_make_tag(0, 0x12, 2)); printk_info("OHCI0-USB2 init\n"); usb_init(_pci_make_tag(0, 0x13, 0)); printk_info("OHCI1-USB2 init\n"); usb_init(_pci_make_tag(0, 0x13, 1)); //printk_info("EHCI-USB2 init\n"); //usb_init2(_pci_make_tag(0, 0x13, 2)); printk_info("OHCI0-USB3 init\n"); usb_init(_pci_make_tag(0, 0x14, 5)); #endif printk_info("lpc init\n"); lpc_init(_pci_make_tag(0, 0x14, 3)); printk_info("ide init\n"); ide_init(_pci_make_tag(0, 0x14, 1)); //vga test printk_info("pci init\n"); pci_init(_pci_make_tag(0, 0x14, 4)); printk_info("sm init\n"); sm_init(_pci_make_tag(0, 0x14, 0)); #ifdef USE_780E_VGA printk_info("rs780_internal_gfx_init\n"); internal_gfx_pci_dev_init(_pci_make_tag(0,0,0) , _pci_make_tag(1,0x5,0)); #endif }
void board_init_f(ulong bootflag) { cmd_tbl_t *cmdtp; bd_t *bd; unsigned char *s; init_fnc_t **init_fnc_ptr; int j; int i; char *e; #ifndef CONFIG_SYS_NO_FLASH ulong flash_size; #endif gd = (gd_t *) (CONFIG_SYS_GBL_DATA_OFFSET); /* Clear initial global data */ memset((void *)gd, 0, sizeof(gd_t)); gd->bd = (bd_t *) (gd + 1); /* At end of global data */ gd->baudrate = CONFIG_BAUDRATE; gd->cpu_clk = CONFIG_SYS_CLK_FREQ; bd = gd->bd; bd->bi_memstart = CONFIG_SYS_RAM_BASE; bd->bi_memsize = CONFIG_SYS_RAM_SIZE; bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; #if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE) bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; #endif bd->bi_baudrate = CONFIG_BAUDRATE; bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ gd->reloc_off = CONFIG_SYS_RELOC_MONITOR_BASE - CONFIG_SYS_MONITOR_BASE; for (init_fnc_ptr = init_sequence, j = 0; *init_fnc_ptr; ++init_fnc_ptr, j++) { #ifdef DEBUG_INIT_SEQUENCE if (j > 9) str_init_seq[9] = '0' + (j / 10); str_init_seq[10] = '0' + (j - (j / 10) * 10); serial_puts(str_init_seq); #endif if ((*init_fnc_ptr + gd->reloc_off) () != 0) { hang(); } } #ifdef DEBUG_INIT_SEQUENCE serial_puts(str_init_seq_done); #endif /* * Now that we have DRAM mapped and working, we can * relocate the code and continue running from DRAM. * * Reserve memory at end of RAM for (top down in that order): * - kernel log buffer * - protected RAM * - LCD framebuffer * - monitor code * - board info struct */ #ifdef DEBUG_MEM_LAYOUT printf("CONFIG_SYS_MONITOR_BASE: 0x%lx\n", CONFIG_SYS_MONITOR_BASE); printf("CONFIG_ENV_ADDR: 0x%lx\n", CONFIG_ENV_ADDR); printf("CONFIG_SYS_RELOC_MONITOR_BASE: 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE, CONFIG_SYS_MONITOR_LEN); printf("CONFIG_SYS_MALLOC_BASE: 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN); printf("CONFIG_SYS_INIT_SP_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET, CONFIG_SYS_STACK_SIZE); printf("CONFIG_SYS_PROM_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET, CONFIG_SYS_PROM_SIZE); printf("CONFIG_SYS_GBL_DATA_OFFSET: 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET, CONFIG_SYS_GBL_DATA_SIZE); #endif #ifdef CONFIG_POST post_bootmode_init(); post_run(NULL, POST_ROM | post_bootmode_get(0)); #endif /* * We have to relocate the command table manually */ for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { ulong addr; addr = (ulong) (cmdtp->cmd) + gd->reloc_off; #if DEBUG_COMMANDS printf("Command \"%s\": 0x%08lx => 0x%08lx\n", cmdtp->name, (ulong) (cmdtp->cmd), addr); #endif cmdtp->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; addr = (ulong) (cmdtp->name) + gd->reloc_off; cmdtp->name = (char *)addr; if (cmdtp->usage) { addr = (ulong) (cmdtp->usage) + gd->reloc_off; cmdtp->usage = (char *)addr; } #ifdef CONFIG_SYS_LONGHELP if (cmdtp->help) { addr = (ulong) (cmdtp->help) + gd->reloc_off; cmdtp->help = (char *)addr; } #endif } #if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP) puts("AMBA:\n"); do_ambapp_print(NULL, 0, 0, NULL); #endif /* initialize higher level parts of CPU like time base and timers */ cpu_init_r(); /* start timer */ timer_interrupt_init(); /* * Enable Interrupts before any calls to udelay, * the flash driver may use udelay resulting in * a hang if not timer0 IRQ is enabled. */ interrupt_init(); /* The Malloc area is immediately below the monitor copy in RAM */ mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE); malloc_bin_reloc(); #if !defined(CONFIG_SYS_NO_FLASH) puts("FLASH: "); if ((flash_size = flash_init()) > 0) { # ifdef CONFIG_SYS_FLASH_CHECKSUM print_size(flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' * * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX */ s = getenv("flashchecksum"); if (s && (*s == 'y')) { printf(" CRC: %08lX", crc32(0, (const unsigned char *)CONFIG_SYS_FLASH_BASE, flash_size) ); } putc('\n'); # else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size(flash_size, "\n"); # endif /* CONFIG_SYS_FLASH_CHECKSUM */ } else { puts(failed); hang(); } bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */ bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ #if CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */ #else bd->bi_flashoffset = 0; #endif #else /* CONFIG_SYS_NO_FLASH */ bd->bi_flashsize = 0; bd->bi_flashstart = 0; bd->bi_flashoffset = 0; #endif /* !CONFIG_SYS_NO_FLASH */ #ifdef CONFIG_SPI # if !defined(CONFIG_ENV_IS_IN_EEPROM) spi_init_f(); # endif spi_init_r(); #endif /* relocate environment function pointers etc. */ env_relocate(); #if defined(CONFIG_BOARD_LATE_INIT) board_late_init(); #endif #ifdef CONFIG_ID_EEPROM mac_read_from_eeprom(); #endif /* IP Address */ bd->bi_ip_addr = getenv_IPaddr("ipaddr"); #if defined(CONFIG_PCI) /* * Do pci configuration */ pci_init(); #endif /* Initialize stdio devices */ stdio_init(); /* Initialize the jump table for applications */ jumptable_init(); /* Initialize the console (after the relocation and devices init) */ console_init_r(); #ifdef CONFIG_SERIAL_SOFTWARE_FIFO serial_buffered_init(); #endif #ifdef CONFIG_STATUS_LED status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); #endif udelay(20); set_timer(0); /* Initialize from environment */ if ((s = getenv("loadaddr")) != NULL) { load_addr = simple_strtoul(s, NULL, 16); } #if defined(CONFIG_CMD_NET) if ((s = getenv("bootfile")) != NULL) { copy_filename(BootFile, s, sizeof(BootFile)); } #endif /* CONFIG_CMD_NET */ WATCHDOG_RESET(); #if defined(CONFIG_CMD_DOC) WATCHDOG_RESET(); puts("DOC: "); doc_init(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) #if defined(CONFIG_NET_MULTI) WATCHDOG_RESET(); puts("Net: "); #endif eth_initialize(bd); #endif #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) WATCHDOG_RESET(); debug("Reset Ethernet PHY\n"); reset_phy(); #endif #ifdef CONFIG_POST post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif #if defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts("IDE: "); ide_init(); #endif /* CONFIG_CMD_IDE */ #ifdef CONFIG_LAST_STAGE_INIT WATCHDOG_RESET(); /* * Some parts can be only initialized if all others (like * Interrupts) are up and running (i.e. the PC-style ISA * keyboard). */ last_stage_init(); #endif #ifdef CONFIG_PS2KBD puts("PS/2: "); kbd_init(); #endif prom_init(); /* main_loop */ for (;;) { WATCHDOG_RESET(); main_loop(); } }
void board_init_r(gd_t *id, ulong dest_addr) { char *s; ulong size; static bd_t bd_data; static gd_t gd_data; init_fnc_t **init_fnc_ptr; show_boot_progress(0x21); /* Global data pointer is now writable */ gd = &gd_data; memcpy(gd, id, sizeof(gd_t)); /* compiler optimization barrier needed for GCC >= 3.4 */ __asm__ __volatile__("": : :"memory"); gd->bd = &bd_data; memset (gd->bd, 0, sizeof (bd_t)); show_boot_progress(0x22); gd->baudrate = CONFIG_BAUDRATE; mem_malloc_init((((ulong)dest_addr - CONFIG_SYS_MALLOC_LEN)+3)&~3, CONFIG_SYS_MALLOC_LEN); for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) hang (); } show_boot_progress(0x23); #ifdef CONFIG_SERIAL_MULTI serial_initialize(); #endif /* configure available FLASH banks */ size = flash_init(); display_flash_config(size); show_boot_progress(0x24); show_boot_progress(0x25); /* initialize environment */ env_relocate (); show_boot_progress(0x26); #ifdef CONFIG_CMD_NET /* IP Address */ bd_data.bi_ip_addr = getenv_IPaddr ("ipaddr"); #endif #if defined(CONFIG_PCI) /* * Do pci configuration */ pci_init(); #endif show_boot_progress(0x27); stdio_init (); jumptable_init (); /* Initialize the console (after the relocation and devices init) */ console_init_r(); #ifdef CONFIG_MISC_INIT_R /* miscellaneous platform dependent initialisations */ misc_init_r(); #endif #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts ("PCMCIA:"); pcmcia_init(); #endif #if defined(CONFIG_CMD_KGDB) WATCHDOG_RESET(); puts("KGDB: "); kgdb_init(); #endif /* enable exceptions */ enable_interrupts(); show_boot_progress(0x28); #ifdef CONFIG_STATUS_LED status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); #endif udelay(20); /* Initialize from environment */ load_addr = getenv_ulong("loadaddr", 16, load_addr); #if defined(CONFIG_CMD_NET) if ((s = getenv ("bootfile")) != NULL) { copy_filename (BootFile, s, sizeof (BootFile)); } #endif WATCHDOG_RESET(); #if defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts("IDE: "); ide_init(); #endif #if defined(CONFIG_CMD_SCSI) WATCHDOG_RESET(); puts("SCSI: "); scsi_init(); #endif #if defined(CONFIG_CMD_DOC) WATCHDOG_RESET(); puts("DOC: "); doc_init(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) WATCHDOG_RESET(); puts("Net: "); eth_initialize(gd->bd); #endif #if ( defined(CONFIG_CMD_NET)) && (0) WATCHDOG_RESET(); # ifdef DEBUG puts ("Reset Ethernet PHY\n"); # endif reset_phy(); #endif #ifdef CONFIG_LAST_STAGE_INIT WATCHDOG_RESET(); /* * Some parts can be only initialized if all others (like * Interrupts) are up and running (i.e. the PC-style ISA * keyboard). */ last_stage_init(); #endif #ifdef CONFIG_POST post_run (NULL, POST_RAM | post_bootmode_get(0)); #endif show_boot_progress(0x29); /* 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 */ }
/* * This is the next part if the initialization sequence: we are now * running from RAM and have a "normal" C environment, i. e. global * data can be written, BSS has been cleared, the stack size in not * that critical any more, etc. */ void board_init_r(gd_t *id, ulong dest_addr) { bd_t *bd; ulong malloc_start; #ifndef CONFIG_SYS_NO_FLASH ulong flash_size; #endif gd = id; /* initialize RAM version of global data */ bd = gd->bd; gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ /* The Malloc area is immediately below the monitor copy in DRAM */ malloc_start = dest_addr - TOTAL_MALLOC_LEN; #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) /* * The gd->arch.cpu pointer is set to an address in flash before * relocation. We need to update it to point to the same CPU entry * in RAM. */ gd->arch.cpu += dest_addr - CONFIG_SYS_MONITOR_BASE; /* * If we didn't know the cpu mask & # cores, we can save them of * now rather than 'computing' them constantly */ fixup_cpu(); #endif #ifdef CONFIG_SYS_EXTRA_ENV_RELOC /* * Some systems need to relocate the env_addr pointer early because the * location it points to will get invalidated before env_relocate is * called. One example is on systems that might use a L2 or L3 cache * in SRAM mode and initialize that cache from SRAM mode back to being * a cache in cpu_init_r. */ gd->env_addr += dest_addr - CONFIG_SYS_MONITOR_BASE; #endif serial_initialize(); debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); WATCHDOG_RESET(); /* * Setup trap handlers */ trap_init(dest_addr); #ifdef CONFIG_ADDR_MAP init_addr_map(); #endif #if defined(CONFIG_BOARD_EARLY_INIT_R) board_early_init_r(); #endif monitor_flash_len = (ulong)&__init_end - dest_addr; WATCHDOG_RESET(); #ifdef CONFIG_LOGBUFFER logbuff_init_ptrs(); #endif #ifdef CONFIG_POST post_output_backlog(); #endif WATCHDOG_RESET(); #if defined(CONFIG_SYS_DELAYED_ICACHE) icache_enable(); /* it's time to enable the instruction cache */ #endif #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ #endif #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do early PCI configuration _before_ the flash gets initialised, * because PCU ressources are crucial for flash access on some boards. */ pci_init(); #endif #if defined(CONFIG_WINBOND_83C553) /* * Initialise the ISA bridge */ initialise_w83c553f(); #endif asm("sync ; isync"); mem_malloc_init(malloc_start, TOTAL_MALLOC_LEN); #if !defined(CONFIG_SYS_NO_FLASH) puts("Flash: "); if (board_flash_wp_on()) { printf("Uninitialized - Write Protect On\n"); /* Since WP is on, we can't find real size. Set to 0 */ flash_size = 0; } else if ((flash_size = flash_init()) > 0) { #ifdef CONFIG_SYS_FLASH_CHECKSUM print_size(flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' * * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX */ if (getenv_yesno("flashchecksum") == 1) { printf(" CRC: %08X", crc32(0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size) ); } putc('\n'); #else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size(flash_size, "\n"); #endif /* CONFIG_SYS_FLASH_CHECKSUM */ } else { puts(failed); hang(); } /* update start of FLASH memory */ bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* size of FLASH memory (final value) */ bd->bi_flashsize = flash_size; #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE) /* Make a update of the Memctrl. */ update_flash_size(flash_size); #endif #if defined(CONFIG_OXC) || defined(CONFIG_RMU) /* flash mapped at end of memory map */ bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size; #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */ #endif #endif /* !CONFIG_SYS_NO_FLASH */ WATCHDOG_RESET(); /* initialize higher level parts of CPU like time base and timers */ cpu_init_r(); WATCHDOG_RESET(); #ifdef CONFIG_SPI #if !defined(CONFIG_ENV_IS_IN_EEPROM) spi_init_f(); #endif spi_init_r(); #endif #if defined(CONFIG_CMD_NAND) WATCHDOG_RESET(); puts("NAND: "); nand_init(); /* go init the NAND */ #endif #ifdef CONFIG_GENERIC_MMC /* * MMC initialization is called before relocating env. * Thus It is required that operations like pin multiplexer * be put in board_init. */ WATCHDOG_RESET(); puts("MMC: "); mmc_initialize(bd); #endif /* relocate environment function pointers etc. */ env_relocate(); /* * after non-volatile devices & environment is setup and cpu code have * another round to deal with any initialization that might require * full access to the environment or loading of some image (firmware) * from a non-volatile device */ cpu_secondary_init_r(); /* * Fill in missing fields of bd_info. * We do this here, where we have "normal" access to the * environment; we used to do this still running from ROM, * where had to use getenv_f(), which can be pretty slow when * the environment is in EEPROM. */ #if defined(CONFIG_SYS_EXTBDINFO) #if defined(CONFIG_405GP) || defined(CONFIG_405EP) #if defined(CONFIG_I2CFAST) /* * set bi_iic_fast for linux taking environment variable * "i2cfast" into account */ { if (getenv_yesno("i2cfast") == 1) { bd->bi_iic_fast[0] = 1; bd->bi_iic_fast[1] = 1; } } #endif /* CONFIG_I2CFAST */ #endif /* CONFIG_405GP, CONFIG_405EP */ #endif /* CONFIG_SYS_EXTBDINFO */ #if defined(CONFIG_SC3) sc3_read_eeprom(); #endif #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET) mac_read_from_eeprom(); #endif #ifdef CONFIG_CMD_NET /* kept around for legacy kernels only ... ignore the next section */ eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr); #ifdef CONFIG_HAS_ETH1 eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr); #endif #ifdef CONFIG_HAS_ETH2 eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr); #endif #ifdef CONFIG_HAS_ETH3 eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr); #endif #ifdef CONFIG_HAS_ETH4 eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr); #endif #ifdef CONFIG_HAS_ETH5 eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr); #endif #endif /* CONFIG_CMD_NET */ WATCHDOG_RESET(); #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT) /* * Do pci configuration */ pci_init(); #endif /** leave this here (after malloc(), environment and PCI are working) **/ /* Initialize stdio devices */ stdio_init(); /* Initialize the jump table for applications */ jumptable_init(); #if defined(CONFIG_API) /* Initialize API */ api_init(); #endif /* Initialize the console (after the relocation and devices init) */ console_init_r(); #if defined(CONFIG_MISC_INIT_R) /* miscellaneous platform dependent initialisations */ misc_init_r(); #endif #if defined(CONFIG_CMD_KGDB) WATCHDOG_RESET(); puts("KGDB: "); kgdb_init(); #endif debug("U-Boot relocated to %08lx\n", dest_addr); /* * Enable Interrupts */ interrupt_init(); #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); #endif udelay(20); /* Initialize from environment */ load_addr = getenv_ulong("loadaddr", 16, load_addr); WATCHDOG_RESET(); #if defined(CONFIG_CMD_SCSI) WATCHDOG_RESET(); puts("SCSI: "); scsi_init(); #endif #if defined(CONFIG_CMD_DOC) WATCHDOG_RESET(); puts("DOC: "); doc_init(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) WATCHDOG_RESET(); puts("Net: "); eth_initialize(bd); #endif #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) WATCHDOG_RESET(); debug("Reset Ethernet PHY\n"); reset_phy(); #endif #ifdef CONFIG_POST post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif #if defined(CONFIG_CMD_PCMCIA) \ && !defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); puts("PCMCIA:"); pcmcia_init(); #endif #if defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); #ifdef CONFIG_IDE_8xx_PCCARD puts("PCMCIA:"); #else puts("IDE: "); #endif #if defined(CONFIG_START_IDE) if (board_start_ide()) ide_init(); #else ide_init(); #endif #endif #ifdef CONFIG_LAST_STAGE_INIT WATCHDOG_RESET(); /* * Some parts can be only initialized if all others (like * Interrupts) are up and running (i.e. the PC-style ISA * keyboard). */ last_stage_init(); #endif #if defined(CONFIG_CMD_BEDBUG) WATCHDOG_RESET(); bedbug_init(); #endif #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) /* * Export available size of memory for Linux, * taking into account the protected RAM at top of memory */ { ulong pram = 0; char memsz[32]; #ifdef CONFIG_PRAM pram = getenv_ulong("pram", 10, CONFIG_PRAM); #endif #ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR /* Also take the logbuffer into account (pram is in kB) */ pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024; #endif #endif sprintf(memsz, "%ldk", (ulong) (bd->bi_memsize / 1024) - pram); setenv("mem", memsz); } #endif #ifdef CONFIG_PS2KBD puts("PS/2: "); kbd_init(); #endif /* Initialization complete - start the monitor */ /* main_loop() can return to retry autoboot, if so just run it again. */ for (;;) { WATCHDOG_RESET(); main_loop(); } /* NOTREACHED - no way out of command loop except booting */ }