static void initialize_devices(void) { init_timer(); init_serial(); init_stdio(); sei(); }
FILE *__getstdfile(int n) { struct process *proc = gettib()->proc; struct crtbase *crtbase = (struct crtbase *) proc->crtbase; if (!crtbase->stdio_initialized) init_stdio(); return &crtbase->iob[n]; }
void token_linker(t_shell *sh, t_job **job, t_process **p, t_token *token) { create_process(p, token, sh); create_job(job, p, token); init_stdio(sh); *p = NULL; }
inline static void init_logfile(const char *logfile) { if (NULL != logfile) { if (logfile[0] == '|') { // popen ++logfile; FILE *fp = popen(logfile, "w"); if (NULL != fp) init_stdio(fileno(fp)); ::close(fileno(fp)); } else { // open int fd = open(logfile, O_CREAT | O_WRONLY | O_APPEND, 0644); init_stdio(fd); ::close(fd); } } }
kmain() { /* Inicializa */ init_interrupts(); init_video(); init_stdio(); keyboard_queue_initialize(); set_language(ENGLISH); set_terminal(0); loop(); }
int main() { init_timer(); init_ATX_power(); init_serial(); init_stdio(); init_safety_switches(); init_i2c(); init_laser_power(); init_heaters(); init_main_laser(); sei(); enable_ATX_power(); uint32_t b = millisecond_time(); while (!ATX_power_state()) { enable_ATX_power(); continue; } uint32_t a = millisecond_time(); printf("ATX power: %ld msec\n", a - b); enable_heater_1(); // aka water pump delay_milliseconds(2000); enable_heater_0(); // aka high voltage supply set_laser_power(4095 / 3); // 1/3rd power printf("Main Laser! Danger!\n"); while (true) { if (getchar() == '\r') { if (e_is_stopped()) printf("Emergency Stop. No fire.\n"); else if (lid_is_open()) printf("Lid is open. No fire.\n"); else { printf("Fire!\n"); enable_main_laser(); delay_milliseconds(PULSE_MS); disable_main_laser(); } } } }
void nt_init(void) { #ifdef SECURE_CD { char temp[512]; extern char gcurr_drive; if(!GetCurrentDirectory(512,temp)) ExitProcess((DWORD)-1); gcurr_drive=temp[0]; } #endif SECURE_CD init_stdio(); nt_init_signals(); nt_term_init(); init_hb_subst(); setlocale(LC_ALL,""); init_shell_dll(); init_plister(); fork_init(); init_clipboard(); return; }
/*! \brief Initializes STDIO. */ static void init_stdio(void) { #if (defined __GNUC__) && (defined __AVR32__) static const gpio_map_t STDIO_USART_GPIO_MAP = { {STDIO_USART_RX_PIN, STDIO_USART_RX_FUNCTION}, {STDIO_USART_TX_PIN, STDIO_USART_TX_FUNCTION} }; // Initialize the USART used for STDIO. set_usart_base((void *)STDIO_USART); gpio_enable_module(STDIO_USART_GPIO_MAP, sizeof(STDIO_USART_GPIO_MAP) / sizeof(STDIO_USART_GPIO_MAP[0])); usart_init(STDIO_USART_BAUDRATE); #elif (defined __ICCAVR32__) static const gpio_map_t STDIO_USART_GPIO_MAP = { {STDIO_USART_RX_PIN, STDIO_USART_RX_FUNCTION}, {STDIO_USART_TX_PIN, STDIO_USART_TX_FUNCTION} }; static const usart_options_t STDIO_USART_OPTIONS = { .baudrate = STDIO_USART_BAUDRATE, .charlength = 8, .paritytype = USART_NO_PARITY, .stopbits = USART_1_STOPBIT, .channelmode = USART_NORMAL_CHMODE }; // Initialize the USART used for STDIO. extern volatile avr32_usart_t *volatile stdio_usart_base; stdio_usart_base = STDIO_USART; gpio_enable_module(STDIO_USART_GPIO_MAP, sizeof(STDIO_USART_GPIO_MAP) / sizeof(STDIO_USART_GPIO_MAP[0])); usart_init_rs232(STDIO_USART, &STDIO_USART_OPTIONS, FPBA_HZ); #endif } #if (defined __GNUC__) /*! \brief Low-level initialization routine called during startup, before the * main function. * * This version comes in replacement to the default one provided by the Newlib * add-ons library. * Newlib add-ons' _init_startup only calls init_exceptions, but Newlib add-ons' * exception and interrupt vectors are defined in the same section and Newlib * add-ons' interrupt vectors are not compatible with the interrupt management * of the INTC module. * More low-level initializations are besides added here. */ int _init_startup(void) { // Import the Exception Vector Base Address. extern void _evba; // Load the Exception Vector Base Address in the corresponding system register. Set_system_register(AVR32_EVBA, (int)&_evba); // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. irq_initialize_vectors(); cpu_irq_enable(); init_stdio(); // Don't-care value for GCC. return 1; } #elif (defined __ICCAVR32__) /*! \brief Low-level initialization routine called during startup, before the * main function. */ int __low_level_init(void) { // Enable exceptions. Enable_global_exception(); // Initialize interrupt handling. irq_initialize_vectors(); cpu_irq_enable(); init_stdio(); // Request initialization of data segments. return 1; }
void julia_init(char *imageFile) { jl_page_size = jl_getpagesize(); jl_find_stack_bottom(); jl_dl_handle = jl_load_dynamic_library(NULL, JL_RTLD_DEFAULT); #ifdef __WIN32__ uv_dlopen("ntdll.dll",jl_ntdll_handle); //bypass julia's pathchecking for system dlls uv_dlopen("Kernel32.dll",jl_kernel32_handle); uv_dlopen("msvcrt.dll",jl_crtdll_handle); uv_dlopen("Ws2_32.dll",jl_winsock_handle); _jl_exe_handle.handle = GetModuleHandleA(NULL); #endif jl_io_loop = uv_default_loop(); //this loop will internal events (spawining process etc.) init_stdio(); #if defined(__linux__) int ncores = jl_cpu_cores(); if (ncores > 1) { cpu_set_t cpumask; CPU_ZERO(&cpumask); for(int i=0; i < ncores; i++) { CPU_SET(i, &cpumask); } sched_setaffinity(0, sizeof(cpu_set_t), &cpumask); } #endif #ifdef JL_GC_MARKSWEEP jl_gc_init(); jl_gc_disable(); #endif jl_init_frontend(); jl_init_types(); jl_init_tasks(jl_stack_lo, jl_stack_hi-jl_stack_lo); jl_init_codegen(); jl_an_empty_cell = (jl_value_t*)jl_alloc_cell_1d(0); jl_init_serializer(); if (!imageFile) { jl_main_module = jl_new_module(jl_symbol("Main")); jl_main_module->parent = jl_main_module; jl_core_module = jl_new_module(jl_symbol("Core")); jl_core_module->parent = jl_main_module; jl_set_const(jl_main_module, jl_symbol("Core"), (jl_value_t*)jl_core_module); jl_module_using(jl_main_module, jl_core_module); jl_current_module = jl_core_module; jl_init_intrinsic_functions(); jl_init_primitives(); jl_load("boot.jl"); jl_get_builtin_hooks(); jl_boot_file_loaded = 1; jl_init_box_caches(); } if (imageFile) { JL_TRY { jl_restore_system_image(imageFile); } JL_CATCH { JL_PRINTF(JL_STDERR, "error during init:\n"); jl_show(jl_stderr_obj(), jl_exception_in_transit); JL_PRINTF(JL_STDOUT, "\n"); jl_exit(1); } } // set module field of primitive types int i; void **table = jl_core_module->bindings.table; for(i=1; i < jl_core_module->bindings.size; i+=2) { if (table[i] != HT_NOTFOUND) { jl_binding_t *b = (jl_binding_t*)table[i]; if (b->value && jl_is_datatype(b->value)) { jl_datatype_t *tt = (jl_datatype_t*)b->value; tt->name->module = jl_core_module; } } } // the Main module is the one which is always open, and set as the // current module for bare (non-module-wrapped) toplevel expressions. // it does "using Base" if Base is available. if (jl_base_module != NULL) { jl_add_standard_imports(jl_main_module); } // eval() uses Main by default, so Main.eval === Core.eval jl_module_import(jl_main_module, jl_core_module, jl_symbol("eval")); jl_current_module = jl_main_module; #ifndef __WIN32__ struct sigaction actf; memset(&actf, 0, sizeof(struct sigaction)); sigemptyset(&actf.sa_mask); actf.sa_handler = fpe_handler; actf.sa_flags = 0; if (sigaction(SIGFPE, &actf, NULL) < 0) { JL_PRINTF(JL_STDERR, "sigaction: %s\n", strerror(errno)); jl_exit(1); } stack_t ss; ss.ss_flags = 0; ss.ss_size = SIGSTKSZ; ss.ss_sp = malloc(ss.ss_size); if (sigaltstack(&ss, NULL) < 0) { JL_PRINTF(JL_STDERR, "sigaltstack: %s\n", strerror(errno)); jl_exit(1); } struct sigaction act; memset(&act, 0, sizeof(struct sigaction)); sigemptyset(&act.sa_mask); act.sa_sigaction = segv_handler; act.sa_flags = SA_ONSTACK | SA_SIGINFO; if (sigaction(SIGSEGV, &act, NULL) < 0) { JL_PRINTF(JL_STDERR, "sigaction: %s\n", strerror(errno)); jl_exit(1); } #else if (signal(SIGFPE, (void (__cdecl *)(int))fpe_handler) == SIG_ERR) { JL_PRINTF(JL_STDERR, "Couldn't set SIGFPE\n"); jl_exit(1); } #endif #ifdef JL_GC_MARKSWEEP jl_gc_enable(); #endif }
int main_fox(int argc, const char **argv) { ArgumentInfo ai; RefNode *mod; RefStr *name_startup; int ret = FALSE; memset(&ai, 0, sizeof(ai)); init_stdio(); // デフォルト値 fs->max_alloc = 64 * 1024 * 1024; // 64MB fs->max_stack = 32768; fv->err_dst = "alert"; if (!parse_args(&ai, argc, argv)) { goto ERROR_END; } fox_init_compile(FALSE); if (ai.srcfile != NULL) { mod = get_module_by_file(ai.srcfile); if (mod != NULL) { mod->u.m.src_path = ai.srcfile; } } else { throw_errorf(fs->mod_lang, "ArgumentError", "Missing filename"); goto ERROR_END; } // ソースを読み込んだ後で実行 if (fs->running_mode == RUNNING_MODE_CGI) { throw_errorf(fs->mod_lang, "CompileError", "CGI mode is not supported"); goto ERROR_END; } init_fox_stack(); if (mod == NULL) { throw_error_select(THROW_CANNOT_OPEN_FILE__STR, Str_new(ai.srcfile, -1)); goto ERROR_END; } if (fg->error != VALUE_NULL) { goto ERROR_END; } // 参照できない名前で登録 name_startup = intern("[startup]", 9); mod->name = name_startup; Hash_add_p(&fg->mod_root, &fg->st_mem, name_startup, mod); if (!fox_link()) { goto ERROR_END; } if (!fox_run(mod)) { goto ERROR_END; } ret = TRUE; ERROR_END: print_last_error(); fox_close(); return ret; }
void julia_init(char *imageFile) { jl_page_size = jl_getpagesize(); jl_find_stack_bottom(); jl_dl_handle = jl_load_dynamic_library(NULL, JL_RTLD_DEFAULT); #ifdef _OS_WINDOWS_ uv_dlopen("ntdll.dll",jl_ntdll_handle); //bypass julia's pathchecking for system dlls uv_dlopen("Kernel32.dll",jl_kernel32_handle); uv_dlopen("msvcrt.dll",jl_crtdll_handle); uv_dlopen("Ws2_32.dll",jl_winsock_handle); _jl_exe_handle.handle = GetModuleHandleA(NULL); if (!DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), (PHANDLE)&hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS )) { JL_PRINTF(JL_STDERR, "Couldn't access handle to main thread\n"); } #if defined(_CPU_X86_64_) SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); SymInitialize(GetCurrentProcess(), NULL, 1); needsSymRefreshModuleList = 0; #endif #endif jl_io_loop = uv_default_loop(); //this loop will internal events (spawining process etc.) init_stdio(); #if defined(__linux__) int ncores = jl_cpu_cores(); if (ncores > 1) { cpu_set_t cpumask; CPU_ZERO(&cpumask); for(int i=0; i < ncores; i++) { CPU_SET(i, &cpumask); } sched_setaffinity(0, sizeof(cpu_set_t), &cpumask); } #endif #ifdef JL_GC_MARKSWEEP jl_gc_init(); jl_gc_disable(); #endif jl_init_frontend(); jl_init_types(); jl_init_tasks(jl_stack_lo, jl_stack_hi-jl_stack_lo); jl_init_codegen(); jl_an_empty_cell = (jl_value_t*)jl_alloc_cell_1d(0); jl_init_serializer(); if (!imageFile) { jl_main_module = jl_new_module(jl_symbol("Main")); jl_main_module->parent = jl_main_module; jl_core_module = jl_new_module(jl_symbol("Core")); jl_core_module->parent = jl_main_module; jl_set_const(jl_main_module, jl_symbol("Core"), (jl_value_t*)jl_core_module); jl_module_using(jl_main_module, jl_core_module); jl_current_module = jl_core_module; jl_init_intrinsic_functions(); jl_init_primitives(); jl_load("boot.jl"); jl_get_builtin_hooks(); jl_boot_file_loaded = 1; jl_init_box_caches(); } if (imageFile) { JL_TRY { jl_restore_system_image(imageFile); } JL_CATCH { JL_PRINTF(JL_STDERR, "error during init:\n"); jl_show(jl_stderr_obj(), jl_exception_in_transit); JL_PRINTF(JL_STDERR, "\n"); jl_exit(1); } } // set module field of primitive types int i; void **table = jl_core_module->bindings.table; for(i=1; i < jl_core_module->bindings.size; i+=2) { if (table[i] != HT_NOTFOUND) { jl_binding_t *b = (jl_binding_t*)table[i]; if (b->value && jl_is_datatype(b->value)) { jl_datatype_t *tt = (jl_datatype_t*)b->value; tt->name->module = jl_core_module; } } } // the Main module is the one which is always open, and set as the // current module for bare (non-module-wrapped) toplevel expressions. // it does "using Base" if Base is available. if (jl_base_module != NULL) { jl_add_standard_imports(jl_main_module); } // eval() uses Main by default, so Main.eval === Core.eval jl_module_import(jl_main_module, jl_core_module, jl_symbol("eval")); jl_current_module = jl_main_module; #ifndef _OS_WINDOWS_ signal_stack = malloc(SIGSTKSZ); struct sigaction actf; memset(&actf, 0, sizeof(struct sigaction)); sigemptyset(&actf.sa_mask); actf.sa_handler = fpe_handler; actf.sa_flags = 0; if (sigaction(SIGFPE, &actf, NULL) < 0) { JL_PRINTF(JL_STDERR, "sigaction: %s\n", strerror(errno)); jl_exit(1); } #if defined(_OS_LINUX_) stack_t ss; ss.ss_flags = 0; ss.ss_size = SIGSTKSZ; ss.ss_sp = signal_stack; if (sigaltstack(&ss, NULL) < 0) { JL_PRINTF(JL_STDERR, "sigaltstack: %s\n", strerror(errno)); jl_exit(1); } struct sigaction act; memset(&act, 0, sizeof(struct sigaction)); sigemptyset(&act.sa_mask); act.sa_sigaction = segv_handler; act.sa_flags = SA_ONSTACK | SA_SIGINFO; if (sigaction(SIGSEGV, &act, NULL) < 0) { JL_PRINTF(JL_STDERR, "sigaction: %s\n", strerror(errno)); jl_exit(1); } if (signal(SIGPIPE,SIG_IGN) == SIG_ERR) { JL_PRINTF(JL_STDERR, "Couldn't set SIGPIPE\n"); jl_exit(1); } #elif defined (_OS_DARWIN_) kern_return_t ret; mach_port_t self = mach_task_self(); ret = mach_port_allocate(self,MACH_PORT_RIGHT_RECEIVE,&segv_port); HANDLE_MACH_ERROR("mach_port_allocate",ret); ret = mach_port_insert_right(self,segv_port,segv_port,MACH_MSG_TYPE_MAKE_SEND); HANDLE_MACH_ERROR("mach_port_insert_right",ret); // Alright, create a thread to serve as the listener for exceptions pthread_t thread; pthread_attr_t attr; if (pthread_attr_init(&attr) != 0) { JL_PRINTF(JL_STDERR, "pthread_attr_init failed"); jl_exit(1); } pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); if (pthread_create(&thread,&attr,mach_segv_listener,NULL) != 0) { JL_PRINTF(JL_STDERR, "pthread_create failed"); jl_exit(1); } pthread_attr_destroy(&attr); ret = task_set_exception_ports(self,EXC_MASK_BAD_ACCESS,segv_port,EXCEPTION_DEFAULT,MACHINE_THREAD_STATE); HANDLE_MACH_ERROR("task_set_exception_ports",ret); #endif #else if (signal(SIGFPE, (void (__cdecl *)(int))fpe_handler) == SIG_ERR) { JL_PRINTF(JL_STDERR, "Couldn't set SIGFPE\n"); jl_exit(1); } #endif #ifdef JL_GC_MARKSWEEP jl_gc_enable(); #endif }
/** process start callback. function is not covered by MT lock, nor by ldr_mutex! note, that callbacks are called in CALLER context! */ int _std mod_startcb(process_context *pq) { init_stdio(pq); return 0; }
void nt_init(void) { int rc; char ptr[MAX_PATH]; char hdrive[MAX_PATH],hpath[MAX_PATH]; char *s; char *temp=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,MAX_PATH); char *pathtemp= NULL; gosver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx(&gosver)) { MessageBox(NULL,"GetVersionEx failed","zsh",MB_ICONHAND); ExitProcess(0xFF); } if (__forked) goto skippy; if (GetEnvironmentVariable("HOME",ptr,MAX_PATH) != 0) { s = ptr; while(*s) { if (*s == '\\') *s = '/'; s++; } SetEnvironmentVariable("HOME",ptr); goto skippy; } if( GetEnvironmentVariable("ZDOTDIR",ptr,MAX_PATH) != 0) goto skippy; if(gosver.dwPlatformId == VER_PLATFORM_WIN32_NT) { if (gosver.dwMajorVersion <4) { GetEnvironmentVariable("HOMEDRIVE",hdrive,MAX_PATH); GetEnvironmentVariable("HOMEPATH",hpath,MAX_PATH); wsprintf(temp,"%s%s",hdrive,hpath ); } else if (gosver.dwMajorVersion >= 4) { GetEnvironmentVariable("USERPROFILE",temp,MAX_PATH); } } else if (gosver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { rc = GetWindowsDirectory(temp,MAX_PATH); if (rc > MAX_PATH) { MessageBox(NULL,"This should never happen","zsh",MB_ICONHAND); ExitProcess(0xFF); } } else { MessageBox(NULL,"Unknown platform","zsh",MB_ICONHAND); } s = temp; while(*s) { if(*s == '\\') *s ='/'; *s++; } SetEnvironmentVariable("HOME",temp); skippy: rc = GetEnvironmentVariable("PATH",NULL,0); pathtemp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,rc+1); rc = GetEnvironmentVariable("PATH",pathtemp,rc+1); s = pathtemp; while(*s) { if(*s == '\\') *s ='/'; *s++; } SetEnvironmentVariable("PATH",pathtemp); gdwPlatform = gosver.dwPlatformId; HeapFree(GetProcessHeap(),0,temp); HeapFree(GetProcessHeap(),0,pathtemp); init_stdio(); nt_term_init(); nt_init_signals(); init_shell_dll(); }
/*! \brief Main function. */ int main(void) { bool valid_block_found[NF_N_DEVICES]; U32 u32_nf_ids, i_dev, i_block; U8 maker_id, device_id, byte3; U32 i, time_s, time_e; U8 data; // start init sysclk_init(); // Enable clock for require module sysclk_enable_hsb_module(SYSCLK_EBI); sysclk_enable_pbb_module(SYSCLK_SMC_REGS); sysclk_enable_pbb_module(SYSCLK_HMATRIX); // Initialize the board. // The board-specific conf_board.h file contains the configuration of the board // initialization. board_init(); init_stdio(); #ifdef NF_ADDON // addon nandflash board for EVK1104 (not mounted by default) // Unselect NF on board gpio_set_gpio_pin(AVR32_PIN_PX53); gpio_set_gpio_pin(AVR32_PIN_PX52); #endif nf_init(sysclk_get_cpu_hz()); nf_unprotect(); printf("\x0C"); printf("Nand Flash example.\r\n===================\r\n\r\n"); // - Simple test of the NF communication through the SMC. // - Find all bad blocks. // - Find a valid block for the remaining tests. nf_reset_nands(NF_N_DEVICES); printf("\tDetecting Nand Flash device(s).\r\n"); for( i_dev=0 ; i_dev<NF_N_DEVICES ; i_dev++ ) { // Performs some init here... valid_block_found[i_dev] = false; // Test Maker and Device ids u32_nf_ids = nf_read_id( NF_READ_ID_CMD, i_dev ); maker_id = MSB0(u32_nf_ids); device_id = MSB1(u32_nf_ids); byte3 = MSB3(u32_nf_ids); printf("\t\tNF %ld: [Maker=0x%02x] [Device=0x%02x] [byte3=0x%02x]\r\n", i_dev, maker_id, device_id, byte3); if( maker_id==M_ID_MICRON ) { printf("\t\t Micron chip"); if( (device_id==0xDA) && (byte3==0x15) ) printf("- MT29F2G08AACWP device\r\n"); else if( (device_id==0xDA) && (byte3==0x95) ) printf("- MT29F2G08AADWP device\r\n"); else { printf("- *** Error: unexpected chip detected. Please check the board settings and hardware.\r\n"); return -1; } } else { printf("\t\t *** Error: unexpected chip detected. Please check the board settings and hardware.\r\n"); return -1; } } printf("\r\n\tTesting bad blocks.\r\n"); for( i_dev=0 ; i_dev<NF_N_DEVICES ; i_dev++ ) { printf("\t\tNF %ld:\r\n", i_dev); nf_select(i_dev); for( i_block=0 ; i_block<G_N_BLOCKS ; i_block++ ) { nf_open_page_read( nf_block_2_page(i_block), NF_SPARE_POS + G_OFST_BLK_STATUS ); if( (nf_rd_data()!=0xFF) ) { // The block is bad. printf("\t\t\tBlock %ld (0x%lx) is bad.\r\n", i_block, i_block); } else { if( !valid_block_found[i_dev] ) { valid_block_found[i_dev]= true; valid_block_addr[i_dev] = i_block; printf("\t\t\tFirst valid block is at address %ld (0x%lx).\r\n", i_block, i_block); } } } } for( i_dev=0 ; i_dev<NF_N_DEVICES ; i_dev++ ) if( !valid_block_found[i_dev] ) { printf("Error %d\r\n", __LINE__); return 0; } // - Ensure good NF behaviour through simple commands. // Erase, Program, Read // - Measures NF timings. printf("\r\n\tMeasuring NF timings.\r\n"); for( i_dev=0 ; i_dev<NF_N_DEVICES ; i_dev++ ) { printf("\t\tNF %ld:\r\n", i_dev); nf_select(i_dev); nf_erase_block( nf_block_2_page(valid_block_addr[0]), false); time_s = Get_sys_count(); nf_wait_busy(); time_e = Get_sys_count(); // Verify that the block is erased. nf_open_page_read( nf_block_2_page(valid_block_addr[0]), 0); for( i= 0; i<2048 ; i++ ) { data = nf_rd_data(); if( data!=0xFF ) { printf("\tError: offset %d is not erased (read %d).\r\n", (U8)i, data); return 0; } } printf("\t\t\tTime to erase a page:%ld cy (%ld us)\r\n", time_e-time_s, cpu_cy_2_us(time_e-time_s, sysclk_get_cpu_hz())); nf_open_page_write( nf_block_2_page(valid_block_addr[0]), 0); for( i=0 ; i<2048 ; i++ ) nf_wr_data(i%256); nf_wr_cmd(NF_PAGE_PROGRAM_CMD); time_s = Get_sys_count(); nf_wait_busy(); time_e = Get_sys_count(); printf("\t\t\tTime to program a page:%ld cy (%ld us)\r\n", time_e-time_s, cpu_cy_2_us(time_e-time_s, sysclk_get_cpu_hz())); time_s = Get_sys_count(); nf_open_page_read( nf_block_2_page(valid_block_addr[0]), 0); time_e = Get_sys_count(); printf("\t\t\tTime to access to a page:%ld cy (%ld us)\r\n", time_e-time_s, cpu_cy_2_us(time_e-time_s, sysclk_get_cpu_hz())); for( i= 0; i<2048 ; i++ ) { data = nf_rd_data(); if( data!= i%256) { printf("\tError: expect %d, read %d\r\n", (U8)i, data); return 0; } } } printf("Example DONE\r\n"); return 0; }
void init(multiboot *mboot_ptr, uint32_t init_stack) { init_esp = init_stack; init_gdt(); init_idt(); init_paging(mboot_ptr); init_stdio(); init_timer(FREQ); install_keyboard(); init_video(); ttys = (tty_t**) kmalloc(sizeof(tty_t) * 3); ttys[0] = main_tty; ttys[1] = tty_init(ttys[1]); ttys[2] = tty_init(ttys[2]); tty_index = 0; current_tty = main_tty; printk("%s %s (%s) by %s. Copyright C 2015 %s. All rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); detect_cpu(); printk("\n-------------------------------------------------------------------\n"); printk("VGA driver was installed!\n"); printk("Initialize tty. "); wstr_color("[OK]\n", COLOR_GREEN); printk("Initialize paging. "); wstr_color("[OK]\n", COLOR_GREEN); printk("Memory info:\n"); printk("\tKernel starts at: %x\n", (size_t)&kernel_start); printk("\tKernel ends at: %x\n", (size_t)&kernel_end); printk("\tRAM: %d MB\n", mem_size_mb); printk("Initialize stdio (allow using of stdio header). "); wstr_color("[OK]\n", COLOR_GREEN); printk("Initialize GDT. "); wstr_color("[OK]\n", COLOR_GREEN); printk("Initialize IDT and interrupts. "); wstr_color("[OK]\n", COLOR_GREEN); printk("Install timer and clock. "); wstr_color("[OK]\n", COLOR_GREEN); printk("Install keyboard support. "); wstr_color("[OK]\n", COLOR_GREEN); /* tasking is useless, because switcher crashes every time init_tasking(); uint32_t cr3, eflags; asm volatile("movl %%cr3, %%eax; movl %%eax, %0;":"=r"(cr3)::"%eax"); asm volatile("pushfl; movl (%%esp), %%eax; movl %%eax, %0; popfl;":"=r"(eflags)::"%eax"); task_t *clock_task = create_task(clock_task, &update_time, eflags, cr3); */ wstr_color("\nDONE!\n", COLOR_GREEN); sti(); getch(); }
void token_pipe(t_shell *sh, t_process **process, t_token *token) { create_process(process, token, sh); init_stdio(sh); }