void start_cmd(void *dummy) { #ifndef V7_NO_FS #ifndef DISABLE_OTA fs_init(get_fs_addr(), FS_SIZE); #else fs_init(FS_ADDR, FS_SIZE); #endif #endif init_v7(&dummy); #if !defined(NO_PROMPT) uart_main_init(0); #endif #ifndef V7_NO_FS init_smartjs(); #endif #ifndef DISABLE_OTA finish_update(); #endif #if !defined(NO_PROMPT) sj_prompt_init(v7); #endif }
/* * SmartJS initialization; for non-RTOS env, called as an SDK timer callback * (`os_timer_...()`). For RTOS env, called by the dispatcher task. */ void sjs_init(void *dummy) { /* * In order to see debug output (at least errors) during boot we have to * initialize debug in this point. But default we put debug to UART0 with * level=LL_ERROR, then configuration is loaded this settings are overridden */ uart_debug_init(0, 0); uart_redirect_debug(1); cs_log_set_level(LL_ERROR); #ifndef V7_NO_FS #ifndef DISABLE_OTA fs_init(get_fs_addr(get_current_rom()), get_fs_size(get_current_rom())); finish_update(); #else fs_init(FS_ADDR, FS_SIZE); #endif #endif init_v7(&dummy); /* disable GC during further initialization */ v7_set_gc_enabled(v7, 0); #if !defined(NO_PROMPT) uart_main_init(0); #endif #ifndef V7_NO_FS init_smartjs(); #endif #if !defined(NO_PROMPT) sj_prompt_init(v7); #endif #ifdef ESP_UMM_ENABLE /* * We want to use our own heap functions instead of the ones provided by the * SDK. * * We have marked `pvPortMalloc` and friends weak, so that we can override * them with our own implementations, but to actually make it work, we have * to reference any function from the file with our implementation, so that * linker will not garbage-collect the whole compilation unit. * * So, we have a call to the no-op `esp_umm_init()` here. */ esp_umm_init(); #endif /* SJS initialized, enable GC back, and trigger it */ v7_set_gc_enabled(v7, 1); v7_gc(v7, 1); }
int main() { init_rs232(); enable_rs232_interrupts(); enable_rs232(); fs_init(); fio_init(); register_romfs("romfs", &_sromfs); /* Create the queue used by the serial task. Messages for write to * the RS232. */ vSemaphoreCreateBinary(serial_tx_wait_sem); serial_rx_queue = xQueueCreate(1, sizeof(ch)); /*Create a task handle reference to http://www.freertos.org/a00128.html */ xTaskHandle xHandle; xTaskCreate(shell_task, (signed portCHAR *) "Implement shell", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 2, NULL); /* Start running the tasks. */ vTaskStartScheduler(); return 0; }
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 }
int main(void) { TASK *cdc_demo_task_cb; /* Initialize scheduler. */ scheduler_init(); /* Initialize memory. */ mem_init(); /* Initialize file system. */ fs_init(); /* Initialize USB stack. */ usb_init(); /* Create a task for CDC demo. */ cdc_demo_task_cb = (TASK *)mem_static_alloc(sizeof(TASK) + 4096); task_create(cdc_demo_task_cb, "CDCDEMO", (uint8_t *)(cdc_demo_task_cb + 1), 4096, &cdc_demo_task, (void *)(NULL)); scheduler_task_add(cdc_demo_task_cb, TASK_APERIODIC, 5, 0); /* Run scheduler. */ os_run(); return (0); }
int main(int argc, char** argv) { TOS_FAT_Device device; if (argc != 4) { printf("USAGE: fatmd <imagefile> <parentdirectory> <directory>\n"); return (-1); } if (!(fp = fopen(argv[1], "r+"))) { printf("EXCEPTION: Image file could not be opened!\n"); return (-1); } fs_init(&device); if (!fs_create_directory(&device, argv[2], argv[3])) { printf("EXCEPTION: Directory could not be created!\n"); return (-1); } if (fclose(fp) == EOF) { printf("EXCEPTION: Image file could not be closed!\n"); return (-1); } return (0); }
// **************************************************************************** // Program entry point int main (void) { // Initialize platform first if( platform_init() != PLATFORM_OK ) { // This should never happen while( 1 ); } // Initialize device manager dm_init(); // And register the ROM filesystem dm_register( fs_init() ); // Initialize XMODEM xmodem_init( xmodem_send, xmodem_recv ); printf( ".text ends at %p, first free RAM is at %p, last free ram is at %p\r\n", etext, platform_get_first_free_ram(), platform_get_last_free_ram() ); // Run the shell if( shell_init( XMODEM_MAX_FILE_SIZE ) == 0 ) printf( "Unable to initialize shell!\n" ); else shell_start(); while( 1 ); }
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 }
static int fs_sis_queue_init(struct fs *_fs, const char *args, const struct fs_settings *set) { struct sis_queue_fs *fs = (struct sis_queue_fs *)_fs; const char *p, *parent_name, *parent_args, *error; /* <queue_dir>:<parent fs>[:<args>] */ p = strchr(args, ':'); if (p == NULL || p[1] == '\0') { fs_set_error(_fs, "Parent filesystem not given as parameter"); return -1; } fs->queue_dir = i_strdup_until(args, p); parent_name = p + 1; parent_args = strchr(parent_name, ':'); if (parent_args == NULL) parent_args = ""; else parent_name = t_strdup_until(parent_name, parent_args++); if (fs_init(parent_name, parent_args, set, &fs->super, &error) < 0) { fs_set_error(_fs, "%s: %s", parent_name, error); return -1; } 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 __noprof kernel_main_thread(void *data) { struct thread *me = CURRENT(); struct thread_queue tmp_q; tq_init(&tmp_q); tq_insert_head(me, &tmp_q); bug_on(!scheduler_enqueue(&tmp_q)); mach_running(); kprintf("Initializing vfs core... "); fs_init(); kprintf("Done.\n"); call_late_init(); run_tests(); load_init(); for (;;) { scheduler_yield(); arch_idle(); } bug(); }
int main() { init_rs232(); enable_rs232_interrupts(); enable_rs232(); fs_init(); fio_init(); register_romfs("romfs", &_sromfs); /* Create the queue used by the serial task. Messages for write to * the RS232. */ vSemaphoreCreateBinary(serial_tx_wait_sem); /* Add for serial input * Reference: www.freertos.org/a00116.html */ serial_rx_queue = xQueueCreate(1, sizeof(char)); /* Create a task to output text read from romfs. */ xTaskCreate(command_prompt, (signed portCHAR *) "Command Prompt", 512 /* stack size */, NULL, configMAX_PRIORITIES, NULL); xTaskCreate(semihost_sysinfo, (signed portCHAR *) "Semihost Sysinfo", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 2, NULL); /* Start running the tasks. */ vTaskStartScheduler(); return 0; }
static int bootstrap2(void *arg) { dprintf(SPEW, "top of bootstrap2()\n"); arch_init(); // initialize the dpc system #if WITH_LIB_DPC dpc_init(); #endif // XXX put this somewhere else #if WITH_LIB_BIO bio_init(); #endif #if WITH_LIB_FS fs_init(); #endif // initialize the rest of the platform dprintf(SPEW, "initializing platform\n"); platform_init(); // initialize the target dprintf(SPEW, "initializing target\n"); target_init(); dprintf(SPEW, "calling apps_init()\n"); apps_init(); return 0; }
int main() { init_rs232(); enable_rs232_interrupts(); enable_rs232(); fs_init(); fio_init(); register_romfs("romfs", &_sromfs); pwd_hash=hash_djb2((const uint8_t *)&"",-1); // init pwd to /romfs/ /* Create the queue used by the serial task. Messages for write to * the RS232. */ vSemaphoreCreateBinary(serial_tx_wait_sem); /* Add for serial input * Reference: www.freertos.org/a00116.html */ serial_rx_queue = xQueueCreate(1, sizeof(char)); /* Create a task to output text read from romfs. */ xTaskCreate(command_prompt, (signed portCHAR *) "CLI", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 2, NULL); #if 0 /* Create a task to record system log. */ xTaskCreate(system_logger, (signed portCHAR *) "Logger", 1024 /* stack size */, NULL, tskIDLE_PRIORITY + 1, NULL); #endif /* Start running the tasks. */ vTaskStartScheduler(); return 0; }
// TODO: Kernel init functions, kernel_early_init stub is here, kernel_init is just a declaration to shut the linker up. void kernel_early_init(struct multiboot *mboot_header, addr_t initial_stack) { // This is fun, but as long as grub is a bitch, i have a problem. // Make sure interrupts are disabled. //asm volatile("cli"); // Store passed values, and set up the early system. kernel_state_flags = 0; set_ksf(KSF_BOOTING); mtboot = mboot_header; initial_boot_stack = initial_stack; loader_parse_kernel_elf(mboot_header, &kernel_sections); #if _DBOS_KERNEL_LOADER_MODULES loader_init_kernel_symbols(); #endif serial_init(); cpu_early_init(); #if _DBOS_KERNEL_LOADER_MODULES loader_init_modules(); #endif syscall_init(); cpu_timer_install(1000); cpu_processor_init_1(); printk(8, "[KERNEL]: Parsed kernel elf, end of stub function. If you see this, then it is working.\n"); printk(1, "[KERNEL]: Starting system management.\n"); mm_init(mtboot); tm_init_multitasking(); dm_init(); fs_init(); }
void kloader_cmain(struct mem_map_entry mem_map[], uint32_t mem_entry_count) { screen_init(); screen_cursor_hide(); terminal_init(); KINFO("Welcome to Nox (Bootloader mode)"); mem_mgr_init(mem_map, mem_entry_count); ata_init(); fs_init(); struct fat_part_info* part_info = fs_get_system_part(); struct fat_dir_entry kernel; if(!fat_get_dir_entry(part_info, "KERNEL ELF", &kernel)) { KPANIC("Failed to locate KERNEL.ELF"); while(1); } intptr_t kernel_entry_point; if(!elf_load_trusted("KERNEL ELF", &kernel_entry_point)) { KWARN("Failed to load elf!"); } kernel_entry cmain = (kernel_entry)(kernel_entry_point); cmain(mem_map, mem_entry_count); KINFO("Bootloader done"); while(1); }
/*-----------------------------------------------------------------------------------*/ void httpd_init(void) { fs_init(); /* Listen to port 80. */ uip_listen(HTONS(80)); }
static int fs_sis_init(struct fs *_fs, const char *args, const struct fs_settings *set) { enum fs_properties props; const char *parent_name, *parent_args, *error; if (*args == '\0') { fs_set_error(_fs, "Parent filesystem not given as parameter"); return -1; } parent_args = strchr(args, ':'); if (parent_args == NULL) { parent_name = args; parent_args = ""; } else { parent_name = t_strdup_until(args, parent_args); parent_args++; } if (fs_init(parent_name, parent_args, set, &_fs->parent, &error) < 0) { fs_set_error(_fs, "%s", error); return -1; } props = fs_get_properties(_fs->parent); if ((props & FS_SIS_REQUIRED_PROPS) != FS_SIS_REQUIRED_PROPS) { fs_set_error(_fs, "%s backend can't be used with SIS", parent_name); return -1; } return 0; }
FileSystem* fs_new() { FileSystem *fs = NULL; fs = (FileSystem *) malloc(sizeof(FileSystem)); fs_init(fs); return fs; }
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 ..."; cprintf("%s\n\n", message); print_kerninfo(); grade_backtrace(); pic_init(); // init interrupt controller idt_init(); // init interrupt descriptor table pmm_init(); // init physical memory management vmm_init(); // init virtual memory management sched_init(); // init scheduler proc_init(); // init process table swap_init(); // init swap fs_init(); // init fs clock_init(); // init clock interrupt intr_enable(); // enable irq interrupt //LAB1: CAHLLENGE 1 If you try to do it, uncomment lab1_switch_test() // user/kernel mode switch test //lab1_switch_test(); cpu_idle(); // run idle process }
inline void init_dev_modules() { proc_init(); con_init("/disk/bin/screen_saver.pso"); serial_init(); hdd_init(); fs_init(); pipe_init(); }
void init() { map_init(); mgr_init(); fs_init(); pthread_create(&thread, NULL, server_mgr, NULL); thread_init(); }
int fs_close() //{{{ { fs_file_startblock* file = NULL; if (file_startblock_idx < 0) return FS_ERROR_FILE_NOT_OPEN; // finish updating the file while(fs_busy()) fs_update(); // there is one more partial block that remains to be written uint32_t last_block_idx = file_startblock_idx + BYTES_TO_BLOCKS(file_byte_idx); if (last_block_idx != block_idx) { if (last_block_idx >= fs_capacity) return FS_ERROR_FILE_TOO_LONG; sd_write_block_start(block, last_block_idx); while (sd_write_block_update() < 0); } file = (fs_file_startblock*)block; memset(block, 0, sizeof(block)); file->seq = file_seq; file->byte_len = file_byte_idx; file->fmt_iter = fs_fmt_iter; // write file block if (file_startblock_idx >= fs_capacity) return FS_ERROR_FILE_TOO_LONG; if (!sd_write_block_start(block, file_startblock_idx)) return FS_ERROR_SD_WRITE; while (sd_write_block_update() < 0); // this is a skip file, point to it from the previous skip file if ((file_seq % FS_FILE_SKIP_LEN) == 0 && file_prev_skip_startblock_idx > 0) { // read the prev skip file startblock fs_file_startblock* skip_file = (fs_file_startblock*)block; memset(block, 0, sizeof(block)); if (!sd_read_block(block, file_prev_skip_startblock_idx)) return FS_ERROR_SD_READ; // write prev skip file startblock with the new skip pointer skip_file->next_skip_file_startblock_idx = file_startblock_idx; if (!sd_write_block_start(block, file_prev_skip_startblock_idx)) return FS_ERROR_SD_WRITE; while (sd_write_block_update() < 0); } // reset filesystem state fs_init(); return FS_ERROR_NONE; } //}}}
int main(int argc, char** argv) { TOS_FAT_Device device; FAT_DIR_ENTRY dir_entry; unsigned int current_cluster, next_cluster; if (argc != 3) { printf("USAGE: fatdel <image file> <file>\n"); return -1; } if (!(fp = fopen(argv[1], "r+"))) { printf("EXCEPTION: Image file could not be opened!\n"); return -1; } fs_init(&device); if (fs_get_directory_entry(&device, argv[2], &dir_entry) == 0) { printf("EXCEPTION: File could not be found!\n"); return -1; } dir_entry.dir_name[0] = 0xE5; // mark directory entry as deleted if (fs_update_directory_entry(&device, argv[2], dir_entry) == 0) { printf("EXCEPTION: File could not be deleted!\n"); return -1; } current_cluster = dir_entry.dir_fst_clus_hi; current_cluster = (current_cluster << 8) + dir_entry.dir_fst_clus_lo; // free clusters while (!fs_is_eoc(&device, next_cluster = fs_get_fat_cluster_entry(&device, current_cluster))) { fs_set_fat_cluster_entry(&device, current_cluster, 0); current_cluster = next_cluster; } fs_set_fat_cluster_entry(&device, current_cluster, 0); if (fclose(fp) == EOF) { printf("EXCEPTION: Image file could not be closed!\n"); return -1; } return 0; }
static struct fs * fs_sis_init(const char *args, const struct fs_settings *set) { struct sis_fs *fs; const char *p; fs = i_new(struct sis_fs, 1); fs->fs = fs_class_sis; if (*args == '\0') i_fatal("fs-sis: Parent filesystem not given as parameter"); p = strchr(args, ':'); if (p == NULL) fs->super = fs_init(args, "", set); else fs->super = fs_init(t_strdup_until(args, p), p+1, set); return &fs->fs; }
/**@brief Function for application main entry. */ int main(void) { #ifdef OSSW_DEBUG init_uart(); #endif spi_init(); ext_ram_init(); init_lcd_with_splash_screen(); accel_init(); // Initialize. timers_init(); rtc_timer_init(); buttons_init(); battery_init(); // Initialize the SoftDevice handler module. SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL); // splash screen nrf_delay_ms(500); fs_init(); config_init(); scr_mngr_init(); vibration_init(); notifications_init(); stopwatch_init(); timer_feature_init(); mlcd_timers_init(); // Enter main loop. for (;;) { if (rtc_should_store_current_time()) { rtc_store_current_time(); } app_sched_execute(); stopwatch_process(); command_process(); watchset_process_async_operation(); scr_mngr_draw_screen(); power_manage(); } }
static int cfe_elfload(cfe_loadargs_t *la) { fileio_ctx_t *fsctx; void *ref; int res; /* * Look up the file system type and get a context */ res = fs_init(la->la_filesys,&fsctx,la->la_device); if (res != 0) { return res; } /* * Turn on compression if we're doing that. */ if (la->la_flags & LOADFLG_COMPRESSED) { res = fs_hook(fsctx,"z"); if (res != 0) { return res; } } /* * Open the remote file */ res = fs_open(fsctx,&ref,la->la_filename,FILE_MODE_READ); if (res != 0) { fs_uninit(fsctx); return CFE_ERR_FILENOTFOUND; } /* * Load the image. */ la->la_entrypt = 0; res = elfload_internal(fsctx,ref,(unsigned long *)&(la->la_entrypt),la->la_flags); /* * All done, release resources */ fs_close(fsctx,ref); fs_uninit(fsctx); return res; }
/* Auto-init stuff: comment out here if you don't like this stuff to be running in your build, and also below in arch_main() */ int arch_auto_init() { fs_init(); /* VFS */ // fs_ramdisk_init(); /* Ramdisk */ fs_romdisk_init(); /* Romdisk */ if (__kos_romdisk != NULL) { fs_romdisk_mount("/rd", __kos_romdisk, 0); } return 0; }
static int fs_compress_init(struct fs *_fs, const char *args, const struct fs_settings *set) { struct compress_fs *fs = (struct compress_fs *)_fs; const char *p, *compression_name, *level_str, *error; const char *parent_name, *parent_args; /* get compression handler name */ p = strchr(args, ':'); if (p == NULL) { fs_set_error(_fs, "Compression method not given as parameter"); return -1; } compression_name = t_strdup_until(args, p++); args = p; /* get compression level */ p = strchr(args, ':'); if (p == NULL || p[1] == '\0') { fs_set_error(_fs, "Parent filesystem not given as parameter"); return -1; } level_str = t_strdup_until(args, p++); if (str_to_uint(level_str, &fs->compress_level) < 0 || fs->compress_level < 1 || fs->compress_level > 9) { fs_set_error(_fs, "Invalid compression level parameter '%s'", level_str); return -1; } args = p; fs->handler = compression_lookup_handler(compression_name); if (fs->handler == NULL) { fs_set_error(_fs, "Compression method '%s' not support", compression_name); return -1; } parent_args = strchr(args, ':'); if (parent_args == NULL) { parent_name = args; parent_args = ""; } else { parent_name = t_strdup_until(args, parent_args); parent_args++; } if (fs_init(parent_name, parent_args, set, &_fs->parent, &error) < 0) { fs_set_error(_fs, "%s: %s", parent_name, error); return -1; } return 0; }
int gp_init() { if(common_init()) return -1; //armv6 works. if(cmd_init()) return -1; if(memory_init()) return -1; if(task_init()) return -1; if(bdev_init()) return -1; if(image_init()) return -1; if(nvram_init()) return -1; if(fs_init()) return -1; if(fb_init()) return -1; gGpHasInit = TRUE; return 0; }