void kmain(struct multiboot* b, uint32_t magic) { hide_cursor(); cls(); setup_gdt(); setup_idt(); if(b->mods_count == 1) { uint32_t mods_start_addr=*(uint32_t*)(b->mods_addr); uint32_t mods_end_addr=*(uint32_t*)(b->mods_addr + 4); if(((uint32_t)&__kernel_end - KERNEL_VMA) < mods_end_addr) kernel_end_addr=(mods_end_addr & 0xFFFFF000) + 0x1000; } setup_bitmap(); setup_vmm(); setup_pic(); setup_tasking(); setup_process_tree(); set_timer_freq(100); pci_init(); setup_network(); b=(struct multiboot*)((uint8_t*)b+KERNEL_VMA); uint32_t mods_addr=*(uint32_t*)(b->mods_addr + KERNEL_VMA) + KERNEL_VMA; root_fs=ext2_fs_init((uint8_t*)mods_addr); struct inode *devfs=devfs_init(); struct inode *devfs_root=vfs_search((struct inode*)root_fs, "/dev"); if(devfs_root) { vfs_mount(devfs, devfs_root); register_tty_driver(); register_kbd_driver(); register_rtl8139_driver(); } else kprintf("Could not mount /dev, no such directory\n"); kprintf("\n%@Welcome to tapiOS!%@\n\n", 0x05, 0x07, b->mods_count, 0x03); struct inode *node=vfs_search((struct inode*)root_fs, "/bin/init"); if(node) { struct file *init=vfs_open(node, NULL, O_RDONLY); uint8_t *init_mem=kmalloc(node->size); int read=vfs_read(init, init_mem, node->size); vaddr_t entrypoint=init_elf_get_entry_point(init_mem); setup_initial_process(entrypoint); } else kprintf("Init not found\n"); __asm__ volatile("hltloop: hlt; jmp hltloop"); PANIC(); }
static int cdrom_init() { if (cdrom_buf_init()==-1) return -1; devfs_init(); cdrom_devices = llist_create(); llist_t list = rpc_list(); char *name; while ((name = llist_pop(list))) { if (strncmp(name,"scsi_request_atapi",18)==0) { char *dev = name+13; // dev = "atapiXX" if (cdrom_device_init(dev)==-1) fprintf(stderr,"Could not initialize ATAPI device %s\n",dev); } free(name); } llist_destroy(list); return 0; }
void fs_init(void) #endif { char *rnn; kprintf("FS initialization...\n"); vfs_node_t *main; #ifdef __HOSTED__ main = initrd_init(p, len); rnn = "initrd0"; #else main = ata_init(); rnn = "ata0"; #endif dfs = devfs_init(); devfs_add(main); root = vfs_alloc_node(); root->name[0] = '/'; root->name[1] = 0; root->flags = VFS_DIRECTORY; vfs_node_t *t = vfs_finddir(dfs, rnn); vfs_mount(t, root); if (root->ptr != NULL) { kprintf("Root mounted successfully\n"); } tty_node = tty_init(NULL); devfs_add(tty_node); fs_print_dir(dfs); }
int main(int argc,char *argv[]) { unsigned int bus,slot,func; ioport_reg(PCI_CONFIG_DATA); ioport_reg(PCI_CONFIG_ADDRESS); devfs_init(); for (bus=0;bus<PCI_MAXBUSSES;bus++) { for (slot=0;slot<PCI_MAXSLOTS;slot++) { for (func=0;func<PCI_MAXFUNCS;func++) { int vendor = pci_config_readd(bus,slot,func,0)&0x0000FFFF; if (vendor!=0x0000 && vendor!=0xFFFF) { if (pci_dev_init(bus,slot,func)==-1) fprintf(stderr,"pci: Could not create device for: pci%d.%d.%d\n",bus,slot,func); } } } } devfs_mainloop(); return 0; }
/** * RT-Thread Components Initialization */ void rt_components_init(void) { #ifndef _MSC_VER #ifdef RT_DEBUG_INIT int result; const struct rt_init_desc *desc; rt_kprintf("do components intialization.\n"); for (desc = &__rt_init_desc_rti_board_end; desc < &__rt_init_desc_rti_end; desc ++) { rt_kprintf("initialize %s", desc->fn_name); result = desc->fn(); rt_kprintf(":%d done\n", result); } #else const init_fn_t *fn_ptr; for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; fn_ptr ++) { (*fn_ptr)(); } #endif #else #ifdef RT_USING_MODULE rt_system_module_init(); #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_LWIP /* initialize lwip stack */ /* register ethernetif device */ eth_system_device_init(); /* initialize lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); #endif #ifdef RT_USING_DFS /* initialize the device file system */ dfs_init(); #ifdef RT_USING_DFS_ELMFAT /* initialize the elm chan FatFS file system*/ elm_init(); #endif #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) /* initialize NFSv3 client file system */ nfs_init(); #endif #ifdef RT_USING_DFS_YAFFS2 dfs_yaffs2_init(); #endif #ifdef RT_USING_DFS_UFFS dfs_uffs_init(); #endif #ifdef RT_USING_DFS_JFFS2 dfs_jffs2_init(); #endif #ifdef RT_USING_DFS_ROMFS dfs_romfs_init(); #endif #ifdef RT_USING_DFS_RAMFS dfs_ramfs_init(); #endif #ifdef RT_USING_DFS_DEVFS devfs_init(); #endif #endif /* end of RT_USING_DFS */ #ifdef RT_USING_NEWLIB libc_system_init(RT_CONSOLE_DEVICE_NAME); #else /* the pthread system initialization will be initiallized in libc */ #ifdef RT_USING_PTHREADS pthread_system_init(); #endif #endif #ifdef RT_USING_RTGUI rtgui_system_server_init(); #endif #ifdef RT_USING_USB_HOST rt_usb_host_init(); #endif #endif }
int main(int argc, char* argv[]) { (void)argc; (void)argv; struct coresrv_init *data = (struct coresrv_init *)_libc_init_get()->data; syscall_log("coresrv", "main", "initializing.."); struct timeval time; gettimeofday(&time, 0); char msg[128]; sprintf(msg, "Current UNIX time is %llu", (unsigned long long)time.tv_sec); syscall_log("coresrc", "main", msg); broker_init(); vfs_init(); vfs_t vfs; VFS_BIND(&vfs); syscall_log("coresrv", "main", "created VFS"); // devfs needs to be bound first so that we can allocate device numbers. devfs_init(); devfs_op_t devfs_op; DEVFS_BIND(&devfs_op); initfs_init(); initfs_op_t initfs_op; INITFS_BIND(&initfs_op); vfs_fs_t initfs; dev_t init_dev = devfs_op.alloc_dev(); if (initfs_op.create(data->initrd_base, data->initrd_size, init_dev, &initfs)) exit(-1); if (vfs.mount("/", &initfs)) exit(-1); syscall_log("coresrv", "main", "mounted initfs at /"); vfs_fs_t devfs; if (devfs_op.create(&devfs)) exit(-1); if (vfs.mount("/dev", &devfs)) exit(-1); syscall_log("coresrv", "main", "mounted devfs at /dev"); pci_init(); pci_op_t pci_op; PCI_BIND(&pci_op); vfs_node_t pci; if (pci_op.create(&pci)) exit(-1); if (devfs_op.add_dev(&devfs, "pci", &pci, &pci.stat.st_rdev)) exit(-1); syscall_log("coresrv", "main", "added /dev/pci"); console_init(); console_op_t console_op; CONSOLE_BIND(&console_op); vfs_node_t console; if (console_op.create(&console)) exit(-1); if (devfs_op.add_dev(&devfs, "console", &console, &console.stat.st_rdev)) exit(-1); syscall_log("coresrv", "main", "added /dev/console"); ramdisk_init(); ramdisk_op_t ramdisk_op; RAMDISK_BIND(&ramdisk_op); vfs_node_t ramdisk; if (ramdisk_op.create(0x200000, &ramdisk)) exit(-1); if (devfs_op.add_dev(&devfs, "ramdisk$", &ramdisk, &ramdisk.stat.st_rdev)) exit(-1); syscall_log("coresrv", "main", "added /dev/ramdisk"); tmpfs_init(); tmpfs_op_t tmpfs_op; TMPFS_BIND(&tmpfs_op); vfs_fs_t tmpfs; dev_t tmp_dev = devfs_op.alloc_dev(); if (tmpfs_op.create(0x200000, tmp_dev, &tmpfs)) exit(-1); if (vfs.mount("/tmp", &tmpfs)) exit(-1); syscall_log("coresrv", "main", "mounted tmpfs at /tmp"); fat16_init(); fat16_op_t fat16_op; FAT16_BIND(&fat16_op); vfs_fs_t fatfs; if (fat16_op.create(&ramdisk, &fatfs)) exit(-1); if (vfs.mount("/home", &fatfs)) exit(-1); syscall_log("coresrv", "main", "mounted fat16 at /home"); /* pid_t init = fork(); if (!init) { execl(argv[1], argv[1], (void*)0); } else while (wait(0) == -1); */ ps2_init(); // TODO: funny way to just sleep syscall_log("corsrv", "main", "sleeping for good."); syscall_set_signal_mask(~0ull); syscall_wait_signal(1<<SIGINT); }
void rt_init_thread_entry(void* parameter) { platform_init(); /* Filesystem Initialization */ #ifdef RT_USING_DFS { /* init the device filesystem */ dfs_init(); #if defined(RT_USING_DFS_ELMFAT) /* init the elm chan FatFs filesystam*/ elm_init(); #endif #if defined(RT_USING_DFS_ROMFS) dfs_romfs_init(); if (dfs_mount(RT_NULL, "/rom", "rom", 0, &romfs_root) == 0) { rt_kprintf("ROM File System initialized!\n"); } else rt_kprintf("ROM File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_DEVFS) devfs_init(); if (dfs_mount(RT_NULL, "/dev", "devfs", 0, 0) == 0) rt_kprintf("Device File System initialized!\n"); else rt_kprintf("Device File System initialzation failed!\n"); #ifdef RT_USING_NEWLIB /* init libc */ libc_system_init(RT_CONSOLE_DEVICE_NAME); #endif #endif #if defined(RT_USING_DFS_UFFS) { /* init the uffs filesystem */ dfs_uffs_init(); /* mount flash device as flash directory */ if(dfs_mount("nand0", "/nand0", "uffs", 0, 0) == 0) rt_kprintf("UFFS File System initialized!\n"); else rt_kprintf("UFFS File System initialzation failed!\n"); } #endif #ifdef RT_USING_I2C { rt_i2c_core_init(); davinci_i2c_init("I2C1"); } #endif #ifdef RT_USING_SPI { rt_hw_spi_init(); } #endif #ifdef RT_USING_SDIO rt_mmcsd_core_init(); rt_mmcsd_blk_init(); rt_hw_mmcsd_init(); rt_thread_delay(RT_TICK_PER_SECOND*2); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) { rt_kprintf("File System initialized!\n"); } else rt_kprintf("File System initialzation failed!%d\n", rt_get_errno()); #endif } #endif #ifdef RT_USING_LWIP { /* register ethernetif device */ eth_system_device_init(); rt_hw_davinci_emac_init(); /* init lwip system */ lwip_system_init(); } #endif }
/** * RT-Thread Components Initialization */ void rt_components_init(void) { #ifdef RT_USING_MODULE rt_system_module_init(); #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_LWIP /* initialize lwip stack */ /* register ethernetif device */ eth_system_device_init(); /* initialize lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); #endif #ifdef RT_USING_DFS /* initialize the device file system */ dfs_init(); #ifdef RT_USING_DFS_ELMFAT /* initialize the elm chan FatFS file system*/ elm_init(); #endif #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) /* initialize NFSv3 client file system */ nfs_init(); #endif #ifdef RT_USING_DFS_YAFFS2 dfs_yaffs2_init(); #endif #ifdef RT_USING_DFS_UFFS dfs_uffs_init(); #endif #ifdef RT_USING_DFS_JFFS2 dfs_jffs2_init(); #endif #ifdef RT_USING_DFS_ROMFS dfs_romfs_init(); #endif #ifdef RT_USING_DFS_DEVFS devfs_init(); #endif #endif /* end of RT_USING_DFS */ #ifdef RT_USING_NEWLIB libc_system_init(RT_CONSOLE_DEVICE_NAME); #else /* the pthread system initialization will be initiallized in libc */ #ifdef RT_USING_PTHREADS pthread_system_init(); #endif #endif #ifdef RT_USING_RTGUI rtgui_system_server_init(); #endif #ifdef RT_USING_USB_HOST rt_usb_host_init(); #endif return; }
void rt_init_thread_entry(void *parameter) { /* Filesystem Initialization */ #ifdef RT_USING_DFS { /* init the device filesystem */ dfs_init(); #if defined(RT_USING_DFS_ELMFAT) /* init the elm chan FatFs filesystam*/ elm_init(); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) { rt_kprintf("File System initialized!\n"); } else rt_kprintf("File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_ROMFS) dfs_romfs_init(); if (dfs_mount(RT_NULL, "/rom", "rom", 0, &romfs_root) == 0) { rt_kprintf("ROM File System initialized!\n"); } else rt_kprintf("ROM File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_DEVFS) devfs_init(); if (dfs_mount(RT_NULL, "/dev", "devfs", 0, 0) == 0) rt_kprintf("Device File System initialized!\n"); else rt_kprintf("Device File System initialzation failed!\n"); #ifdef RT_USING_NEWLIB /* init libc */ libc_system_init("uart0"); #endif #endif #if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) /* NFSv3 Initialization */ nfs_init(); if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0) rt_kprintf("NFSv3 File System initialized!\n"); else rt_kprintf("NFSv3 File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_UFFS) /* init the uffs filesystem */ dfs_uffs_init(); /* mount flash device as flash directory */ if (dfs_mount("nand0", "/nand0", "uffs", 0, 0) == 0) rt_kprintf("UFFS File System initialized!\n"); else rt_kprintf("UFFS File System initialzation failed!\n"); #endif } #endif #ifdef RT_USING_RTGUI { extern void rtgui_system_server_init(void); rt_device_t lcd; /* init lcd */ rt_hw_lcd_init(); /* init touch panel */ rtgui_touch_hw_init(); /* init keypad */ rt_hw_key_init(); /* find lcd device */ lcd = rt_device_find("lcd"); /* set lcd device as rtgui graphic driver */ rtgui_graphic_set_device(lcd); /* initalize rtgui system server */ rtgui_system_server_init(); } #endif /* LwIP Initialization */ #ifdef RT_USING_LWIP { extern void lwip_sys_init(void); eth_system_device_init(); /* register ethernetif device */ rt_hw_dm9000_init(); /* init lwip system */ lwip_sys_init(); rt_kprintf("TCP/IP initialized!\n"); } #endif #ifdef RT_USING_FTK { rt_thread_t ftk_thread; /* init lcd */ rt_hw_lcd_init(); /* init touch panel */ rtgui_touch_hw_init(); /* init keypad */ rt_hw_key_init(); /* create ftk thread */ ftk_thread = rt_thread_create("ftk", rt_ftk_thread_entry, RT_NULL, 10 * 1024, 8, 20); /* startup ftk thread */ if (ftk_thread != RT_NULL) rt_thread_startup(ftk_thread); } #endif }
/** * RT-Thread Components Initialization */ void rt_components_init(void) { #ifdef RT_USING_MODULE rt_system_module_init(); #endif #ifdef RT_USING_FINSH /* initialize finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_LWIP /* initialize lwip stack */ /* register ethernetif device */ eth_system_device_init(); /* initialize lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); #endif #ifdef RT_USING_DFS /* initialize the device file system */ dfs_init(); #ifdef RT_USING_DFS_ELMFAT /* initialize the elm chan FatFS file systam*/ elm_init(); #endif #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP) extern void nfs_init(void); /* initialize NFSv3 client file system */ nfs_init(); #endif #ifdef RT_USING_DFS_YAFFS2 yaffs2_init(); #endif #ifdef RT_USING_DFS_UFFS uffs_init(); #endif #ifdef RT_USING_DFS_JFFS2 jffs2_init(); #endif #ifdef RT_USING_DFS_ROMFS romfs_init(); #endif #ifdef RT_USING_DFS_DEVFS devfs_init(); #endif #endif #ifdef RT_USING_NEWLIB libc_system_init(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_PTHREADS pthread_system_init(); #endif #ifdef RT_USING_RTGUI rtgui_system_server_init(); #endif return; }
void rt_init_thread_entry(void* parameter) { rt_hw_sdcard_init(); /* Filesystem Initialization */ #ifdef RT_USING_DFS { /* init the device filesystem */ dfs_init(); #if defined(RT_USING_DFS_ELMFAT) /* init the elm chan FatFs filesystam*/ elm_init(); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) { rt_kprintf("File System initialized!\n"); } else rt_kprintf("File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_ROMFS) dfs_romfs_init(); if (dfs_mount(RT_NULL, "/rom", "rom", 0, &romfs_root) == 0) { rt_kprintf("ROM File System initialized!\n"); } else rt_kprintf("ROM File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_DEVFS) devfs_init(); if (dfs_mount(RT_NULL, "/dev", "devfs", 0, 0) == 0) rt_kprintf("Device File System initialized!\n"); else rt_kprintf("Device File System initialzation failed!\n"); #ifdef RT_USING_NEWLIB /* init libc */ libc_system_init("uart0"); #endif #endif #if defined(RT_USING_DFS_UFFS) { /* init the uffs filesystem */ dfs_uffs_init(); /* mount flash device as flash directory */ if(dfs_mount("nand0", "/nand0", "uffs", 0, 0) == 0) rt_kprintf("UFFS File System initialized!\n"); else rt_kprintf("UFFS File System initialzation failed!\n"); } #endif } #endif #ifdef RT_USING_RTGUI { /* init lcd */ rt_hw_lcd_init(); /* init touch panel */ rtgui_touch_hw_init(); /* init keypad */ rt_hw_key_init(); /* re-init device driver */ rt_device_init_all(); /* startup rtgui */ //rtgui_startup(); } #endif /* LwIP Initialization */ #ifdef RT_USING_LWIP { extern void lwip_sys_init(void); eth_system_device_init(); /* register ethernetif device */ rt_hw_dm9000_init(); /* re-init device driver */ rt_device_init_all(); /* init lwip system */ lwip_sys_init(); rt_kprintf("TCP/IP initialized!\n"); } #endif #ifdef RT_USING_FTK { rt_thread_t ftk_thread; int FTK_MAIN(int argc, char* argv[]); /* init lcd */ rt_hw_lcd_init(); /* init touch panel */ rtgui_touch_hw_init(); /* init keypad */ rt_hw_key_init(); /* re-init device driver */ rt_device_init_all(); /* create ftk thread */ ftk_thread = rt_thread_create("ftk", FTK_MAIN, RT_NULL, 10 * 1024, 8, 20); /* startup ftk thread */ if(ftk_thread != RT_NULL) rt_thread_startup(ftk_thread); } #endif }
void kernel_init(multiboot_info_t *mboot_info) { extern char __start_bss[], __stop_bss[]; memset(__start_bss, 0, __stop_bss - __start_bss); /* mboot_info is a physical address. while some arches currently have the * lower memory mapped, everyone should have it mapped at kernbase by now. * also, it might be in 'free' memory, so once we start dynamically using * memory, we may clobber it. */ multiboot_kaddr = (struct multiboot_info*)((physaddr_t)mboot_info + KERNBASE); extract_multiboot_cmdline(multiboot_kaddr); cons_init(); print_cpuinfo(); printk("Boot Command Line: '%s'\n", boot_cmdline); exception_table_init(); cache_init(); // Determine systems's cache properties pmem_init(multiboot_kaddr); kmem_cache_init(); // Sets up slab allocator kmalloc_init(); hashtable_init(); radix_init(); cache_color_alloc_init(); // Inits data structs colored_page_alloc_init(); // Allocates colors for agnostic processes acpiinit(); topology_init(); kthread_init(); /* might need to tweak when this happens */ vmr_init(); file_init(); page_check(); idt_init(); kernel_msg_init(); timer_init(); vfs_init(); devfs_init(); train_timing(); kb_buf_init(&cons_buf); arch_init(); block_init(); enable_irq(); run_linker_funcs(); /* reset/init devtab after linker funcs 3 and 4. these run NIC and medium * pre-inits, which need to happen before devether. */ devtabreset(); devtabinit(); #ifdef CONFIG_EXT2FS mount_fs(&ext2_fs_type, "/dev/ramdisk", "/mnt", 0); #endif /* CONFIG_EXT2FS */ #ifdef CONFIG_ETH_AUDIO eth_audio_init(); #endif /* CONFIG_ETH_AUDIO */ get_coreboot_info(&sysinfo); booting = 0; #ifdef CONFIG_RUN_INIT_SCRIPT if (run_init_script()) { printk("Configured to run init script, but no script specified!\n"); manager(); } #else manager(); #endif }
void rt_init_thread_entry(void* parameter) { /* Filesystem Initialization */ #ifdef RT_USING_DFS { /* init the device filesystem */ dfs_init(); #if defined(RT_USING_DFS_ROMFS) dfs_romfs_init(); if (dfs_mount(RT_NULL, "/", "rom", 0, &romfs_root) == 0) { rt_kprintf("ROM File System initialized!\n"); } else rt_kprintf("ROM File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_ELMFAT) /* init the elm chan FatFs filesystam*/ elm_init(); /* mount sd card fat partition 1 as root directory */ if (dfs_mount("sd0", "/sd", "elm", 0, 0) == 0) { rt_kprintf("File System initialized!\n"); } else rt_kprintf("File System initialzation failed!\n"); #endif #if defined(RT_USING_DFS_DEVFS) devfs_init(); if (dfs_mount(RT_NULL, "/dev", "devfs", 0, 0) == 0) rt_kprintf("Device File System initialized!\n"); else rt_kprintf("Device File System initialzation failed!\n"); #ifdef RT_USING_NEWLIB /* init libc */ libc_system_init("uart"); rt_kprintf("libc init done\n"); #endif #endif } #endif #ifdef RT_USING_RTGUI { rtgui_rect_t rect; rtgui_system_server_init(); /* register dock panel */ rect.x1 = 0; rect.y1 = 0; rect.x2 = 400; rect.y2 = 480; rtgui_panel_register("panel", &rect); /* register main panel */ rect.x1 = 400; rect.y1 = 0; rect.x2 = 800; rect.y2 = 480; rtgui_panel_register("main", &rect); rtgui_panel_set_default_focused("main"); rt_hw_lcd_init(); } #endif }