int bootcode_load(ihandle_t dev) { int retval = -1, count = 0, fd; unsigned long bootcode, loadbase, offset; /* Mark the saved-program-state as invalid */ feval("0 state-valid !"); fd = open_ih(dev); if (fd == -1) { goto out; } /* Default to loading at load-base */ fword("load-base"); loadbase = POP(); #ifdef CONFIG_PPC /* However Old World Macs need to load to a different address */ if (is_oldworld()) { loadbase = OLDWORLD_BOOTCODE_BASEADDR; } #endif bootcode = loadbase; offset = 0; while(1) { if (seek_io(fd, offset) == -1) break; count = read_io(fd, (void *)bootcode, 512); offset += count; bootcode += count; } /* If we didn't read anything then exit */ if (!count) { goto out; } /* Initialise saved-program-state */ PUSH(loadbase); feval("saved-program-state >sps.entry !"); PUSH(offset); feval("saved-program-state >sps.file-size !"); feval("bootcode saved-program-state >sps.file-type !"); feval("-1 state-valid !"); out: close_io(fd); return retval; }
void fcode_init_program(void) { /* Use trampoline context to execute FCode */ PUSH((ucell)&init_fcode_context); feval("load-state >ls.entry !"); arch_init_program(); feval("-1 state-valid !"); }
void go(void) { ucell address, type, size; int image_retval = 0; /* Get the entry point and the type (see forth/debugging/client.fs) */ feval("saved-program-state >sps.entry @"); address = POP(); feval("saved-program-state >sps.file-type @"); type = POP(); feval("saved-program-state >sps.file-size @"); size = POP(); printk("\nJumping to entry point " FMT_ucellx " for type " FMT_ucellx "...\n", address, type); switch (type) { case 0x0: /* Start ELF boot image */ image_retval = start_elf(address, (uint32_t)&elf_boot_notes); break; case 0x1: /* Start ELF image */ image_retval = start_elf(address, (uint32_t)NULL); break; case 0x5: /* Start a.out image */ image_retval = start_elf(address, (uint32_t)NULL); break; case 0x10: /* Start Fcode image */ printk("Evaluating FCode...\n"); PUSH(address); PUSH(1); fword("byte-load"); image_retval = 0; break; case 0x11: /* Start Forth image */ PUSH(address); PUSH(size); fword("eval2"); image_retval = 0; break; } printk("Image returned with return value %#x\n", image_retval); }
void init_program(void) { /* Get the value of load-base and use it to determine the correct loader to use */ ucell addr; feval("load-base"); addr = POP(); #ifdef CONFIG_LOADER_AOUT if (is_aout((struct exec *)cell2pointer(addr))) { aout_init_program(); return; } #endif #ifdef CONFIG_LOADER_BOOTCODE if (is_bootcode((char *)cell2pointer(addr))) { bootcode_init_program(); return; } #endif #ifdef CONFIG_LOADER_BOOTINFO if (is_bootinfo((char *)cell2pointer(addr))) { bootinfo_init_program(); return; } #endif #ifdef CONFIG_LOADER_ELF if (is_elf((Elf_ehdr *)cell2pointer(addr))) { elf_init_program(); return; } #endif #ifdef CONFIG_LOADER_FCODE if (is_fcode((unsigned char *)cell2pointer(addr))) { fcode_init_program(); return; } #endif #ifdef CONFIG_LOADER_FORTH if (is_forth((char *)cell2pointer(addr))) { forth_init_program(); return; } #endif #ifdef CONFIG_LOADER_XCOFF if (is_xcoff((COFF_filehdr_t *)cell2pointer(addr))) { xcoff_init_program(); return; } #endif }
void init_forth_context(void) { /* Execute Forth payload */ printk("Evaluating Forth...\n"); fword("load-base"); feval("load-state >ls.file-size @"); fword("eval2"); }
void warning(const emlrtStack *sp) { int32_T i1; static const char_T cv1[7] = { 'w', 'a', 'r', 'n', 'i', 'n', 'g' }; char_T u[7]; const mxArray *y; static const int32_T iv0[2] = { 1, 7 }; const mxArray *m0; static const char_T cv2[7] = { 'm', 'e', 's', 's', 'a', 'g', 'e' }; char_T b_u[7]; const mxArray *b_y; static const int32_T iv1[2] = { 1, 7 }; static const char_T msgID[43] = { 's', 'd', 'r', 'u', ':', 'S', 'D', 'R', 'u', 'T', 'r', 'a', 'n', 's', 'm', 'i', 't', 't', 'e', 'r', ':', 'O', 'u', 't', 'O', 'f', 'R', 'a', 'n', 'g', 'e', 'I', 'n', 't', 'e', 'r', 'p', 'F', 'a', 'c', 't', 'o', 'r' }; char_T c_u[43]; const mxArray *c_y; static const int32_T iv2[2] = { 1, 43 }; emlrtStack st; st.prev = sp; st.tls = sp->tls; for (i1 = 0; i1 < 7; i1++) { u[i1] = cv1[i1]; } y = NULL; m0 = emlrtCreateCharArray(2, iv0); emlrtInitCharArrayR2013a(sp, 7, m0, &u[0]); emlrtAssign(&y, m0); for (i1 = 0; i1 < 7; i1++) { b_u[i1] = cv2[i1]; } b_y = NULL; m0 = emlrtCreateCharArray(2, iv1); emlrtInitCharArrayR2013a(sp, 7, m0, &b_u[0]); emlrtAssign(&b_y, m0); for (i1 = 0; i1 < 43; i1++) { c_u[i1] = msgID[i1]; } c_y = NULL; m0 = emlrtCreateCharArray(2, iv2); emlrtInitCharArrayR2013a(sp, 43, m0, &c_u[0]); emlrtAssign(&c_y, m0); st.site = &fb_emlrtRSI; b_feval(&st, y, feval(&st, b_y, c_y, &emlrtMCI), &b_emlrtMCI); }
octave_caller_t::octave_caller_t() { wordexp_t p; std::string test_path = "$PRACSYS_PATH/prx_utilities/prx/utilities/octave_interface/functions/"; wordexp(test_path.c_str(), &p, 0); std::string dir(p.we_wordv[0]); f_arg(0) = dir; const char * argvv[] = {"", "-q"}; octave_main(2, (char**)argvv, true); feval("cd", f_arg); }
void b_warning(const emlrtStack *sp) { int32_T i11; static const char_T cv7[7] = { 'w', 'a', 'r', 'n', 'i', 'n', 'g' }; char_T u[7]; const mxArray *y; static const int32_T iv5[2] = { 1, 7 }; const mxArray *m1; static const char_T cv8[7] = { 'm', 'e', 's', 's', 'a', 'g', 'e' }; char_T b_u[7]; const mxArray *b_y; static const int32_T iv6[2] = { 1, 7 }; static const char_T msgID[39] = { 's', 'd', 'r', 'u', ':', 'S', 'D', 'R', 'u', 'R', 'e', 'c', 'e', 'i', 'v', 'e', 'r', ':', 'O', 'u', 't', 'O', 'f', 'R', 'a', 'n', 'g', 'e', 'D', 'e', 'c', 'i', 'm', 'F', 'a', 'c', 't', 'o', 'r' }; char_T c_u[39]; const mxArray *c_y; static const int32_T iv7[2] = { 1, 39 }; emlrtStack st; st.prev = sp; st.tls = sp->tls; for (i11 = 0; i11 < 7; i11++) { u[i11] = cv7[i11]; } y = NULL; m1 = emlrtCreateCharArray(2, iv5); emlrtInitCharArrayR2013a(sp, 7, m1, &u[0]); emlrtAssign(&y, m1); for (i11 = 0; i11 < 7; i11++) { b_u[i11] = cv8[i11]; } b_y = NULL; m1 = emlrtCreateCharArray(2, iv6); emlrtInitCharArrayR2013a(sp, 7, m1, &b_u[0]); emlrtAssign(&b_y, m1); for (i11 = 0; i11 < 39; i11++) { c_u[i11] = msgID[i11]; } c_y = NULL; m1 = emlrtCreateCharArray(2, iv7); emlrtInitCharArrayR2013a(sp, 39, m1, &c_u[0]); emlrtAssign(&c_y, m1); st.site = &fb_emlrtRSI; b_feval(&st, y, feval(&st, b_y, c_y, &emlrtMCI), &b_emlrtMCI); }
void aout_init_program(void) { ucell start, size; // Relocate a.out text down from load-base to load-base - header. This // is similar to what OBP does and is needed for NextStep. fword("load-base"); start = POP(); feval("load-state >ls.file-size @"); size = POP(); memmove((char *)start - sizeof(struct exec), (char *)start, size); PUSH(start); feval("load-state >ls.entry !"); arch_init_program(); feval("-1 state-valid !"); }
void boot(void) { /* Boot preloaded kernel */ if (kernel_size) { printk("[sparc] Kernel already loaded\n"); PUSH(kernel_image); feval("load-state >ls.entry !"); arch_init_program(); start_elf(); } }
SEXP zero(SEXP f, SEXP guesses, SEXP stol, SEXP rho) { double x0 = REAL(guesses)[0], x1 = REAL(guesses)[1], tol = REAL(stol)[0]; double f0, f1, fc, xc; if(tol <= 0.0) error("non-positive tol value"); f0 = feval(x0, f, rho); f1 = feval(x1, f, rho); if(f0 == 0.0) return mkans(x0); if(f1 == 0.0) return mkans(x1); if(f0*f1 > 0.0) error("x[0] and x[1] have the same sign"); for(;;) { xc = 0.5*(x0+x1); if(fabs(x0-x1) < tol) return mkans(xc); fc = feval(xc, f, rho); if(fc == 0) return mkans(xc); if(f0*fc > 0.0) { x0 = xc; f0 = fc; } else { x1 = xc; f1 = fc; } } }
void evaluate(const char* code, char** out, char** err) { size_t out_size, err_size; FILE* fin = fmemopen((char*)code, strlen(code), "r"); FILE* fout = open_memstream(out, &out_size); FILE* ferr = open_memstream(err, &err_size); osSetStreams(osStdin, fout, ferr); feval(fin, fout, finfo); osSetStreams(osStdin, osStdout, osStderr); fclose(fin); fclose(fout); fclose(ferr); }
/* Function Definitions */ static real_T c_fprintf(const emlrtStack *sp) { const mxArray *y; static const int32_T iv8[2] = { 1, 7 }; const mxArray *m1; char_T cv14[7]; int32_T i; static const char_T cv15[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; const mxArray *c_y; static const int32_T iv9[2] = { 1, 50 }; char_T cv16[50]; static const char_T cv17[50] = { 'R', 'e', 'm', 'e', 'm', 'b', 'e', 'r', ' ', 't', 'o', ' ', 'c', 'o', 'm', 'p', 'a', 'r', 'e', ' ', 'o', 'u', 't', 'p', 'u', 't', ' ', 'f', 'i', 'l', 'e', 's', ' ', 'w', 'i', 't', 'h', ' ', 'm', 'd', '5', ' ', 'o', 'r', ' ', 'S', 'H', 'A', '\\', 'n' }; emlrtStack st; st.prev = sp; st.tls = sp->tls; y = NULL; m1 = mxCreateCharArray(2, iv8); for (i = 0; i < 7; i++) { cv14[i] = cv15[i]; } emlrtInitCharArrayR2013a(sp, 7, m1, cv14); emlrtAssign(&y, m1); b_y = NULL; m1 = mxCreateDoubleScalar(1.0); emlrtAssign(&b_y, m1); c_y = NULL; m1 = mxCreateCharArray(2, iv9); for (i = 0; i < 50; i++) { cv16[i] = cv17[i]; } emlrtInitCharArrayR2013a(sp, 50, m1, cv16); emlrtAssign(&c_y, m1); st.site = &cb_emlrtRSI; return e_emlrt_marshallIn(&st, feval(&st, y, b_y, c_y, &r_emlrtMCI), "feval"); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); // crear la aplicacion de Qt MainWindow w; // Crear un objeto MainWidnow w.show(); // mostrar el objeto // Argumentos para octave argv[0] = "GUI_NS"; argv[1] = "-q"; // Iniciar en modo silencioso (no muestra informacion de la version o la licencia argc = 2; // Numero de argumentos setlocale(LC_ALL, "en_US.UTF-8"); // Indicar a octave que se trabajara en English, o si no, no funciona octave_main (argc, argv, true); // Llamar al main de octave feval("inicializar"); return a.exec(); // Ejecutar la aplicacion Qt }
static real_T e_fprintf(const emlrtStack *sp) { const mxArray *y; static const int32_T iv10[2] = { 1, 7 }; const mxArray *m2; char_T cv18[7]; int32_T i; static const char_T cv19[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; const mxArray *c_y; static const int32_T iv11[2] = { 1, 31 }; char_T cv20[31]; static const char_T cv21[31] = { 'f', 'i', 'l', 'e', 'S', 'o', 'u', 'r', 'c', 'e', 'S', 'i', 'n', 'k', ' ', 'T', 'e', 's', 't', ' ', 'C', 'o', 'm', 'p', 'l', 'e', 't', 'e', 'd', '\\', 'n' }; emlrtStack st; st.prev = sp; st.tls = sp->tls; y = NULL; m2 = mxCreateCharArray(2, iv10); for (i = 0; i < 7; i++) { cv18[i] = cv19[i]; } emlrtInitCharArrayR2013a(sp, 7, m2, cv18); emlrtAssign(&y, m2); b_y = NULL; m2 = mxCreateDoubleScalar(1.0); emlrtAssign(&b_y, m2); c_y = NULL; m2 = mxCreateCharArray(2, iv11); for (i = 0; i < 31; i++) { cv20[i] = cv21[i]; } emlrtInitCharArrayR2013a(sp, 31, m2, cv20); emlrtAssign(&c_y, m2); st.site = &cb_emlrtRSI; return e_emlrt_marshallIn(&st, feval(&st, y, b_y, c_y, &r_emlrtMCI), "feval"); }
/* Function Definitions */ static real_T c_fprintf(real_T varargin_1) { real_T nbytes; const mxArray *y; static const int32_T iv46[2] = { 1, 7 }; const mxArray *m6; char_T cv22[7]; int32_T i; static const char_T cv23[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; static const int32_T iv47[2] = { 1, 48 }; char_T cv24[48]; static const char_T cv25[48] = { 'E', 'r', 'r', 'o', 'r', ':', ' ', 'm', 'a', 't', 'r', 'i', 'x', ' ', 's', 'q', 'u', 'a', 'r', 'e', ' ', 'r', 'o', 'o', 't', ' ', 'r', 'e', 's', 'i', 'd', 'u', 'a', 'l', ' ', 'n', 'o', 'r', 'm', ' ', 'i', 's', ' ', '%', 'g', '.', '\\', 'n' }; emlrtPushRtStackR2012b(&mi_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); y = NULL; m6 = mxCreateCharArray(2, iv46); for (i = 0; i < 7; i++) { cv22[i] = cv23[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 7, m6, cv22); emlrtAssign(&y, m6); b_y = NULL; m6 = mxCreateCharArray(2, iv47); for (i = 0; i < 48; i++) { cv24[i] = cv25[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 48, m6, cv24); emlrtAssign(&b_y, m6); nbytes = emlrt_marshallIn(feval(y, emlrt_marshallOut(1.0), b_y, emlrt_marshallOut(varargin_1), &p_emlrtMCI), "feval"); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&mi_emlrtRSI, emlrtRootTLSGlobal); return nbytes; }
static real_T u_fprintf(const emlrtStack *sp) { const mxArray *y; static const int32_T iv201[2] = { 1, 7 }; const mxArray *m43; char_T cv249[7]; int32_T i; static const char_T cv250[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; const mxArray *c_y; static const int32_T iv202[2] = { 1, 32 }; char_T cv251[32]; static const char_T cv252[32] = { 'M', 'A', 'C', '|', ' ', 'T', 'r', 'a', 'n', 's', 'm', 'i', 't', 't', 'i', 'n', 'g', ' ', 'A', 'C', 'K', ' ', 'f', 'o', 'r', ' ', 'd', 'u', 'p', 'e', '\\', 'n' }; emlrtStack st; st.prev = sp; st.tls = sp->tls; y = NULL; m43 = mxCreateCharArray(2, iv201); for (i = 0; i < 7; i++) { cv249[i] = cv250[i]; } emlrtInitCharArrayR2013a(sp, 7, m43, cv249); emlrtAssign(&y, m43); b_y = NULL; m43 = mxCreateDoubleScalar(1.0); emlrtAssign(&b_y, m43); c_y = NULL; m43 = mxCreateCharArray(2, iv202); for (i = 0; i < 32; i++) { cv251[i] = cv252[i]; } emlrtInitCharArrayR2013a(sp, 32, m43, cv251); emlrtAssign(&c_y, m43); st.site = &ew_emlrtRSI; return c_emlrt_marshallIn(&st, feval(&st, y, b_y, c_y, &n_emlrtMCI), "feval"); }
static real_T i_fprintf(const emlrtStack *sp) { const mxArray *y; static const int32_T iv84[2] = { 1, 7 }; const mxArray *m17; char_T cv98[7]; int32_T i; static const char_T cv99[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; const mxArray *c_y; static const int32_T iv85[2] = { 1, 26 }; char_T cv100[26]; static const char_T cv101[26] = { 'D', 'L', '|', ' ', 'M', 'a', 'x', ' ', 't', 'i', 'm', 'e', 'o', 'u', 't', 's', ' ', 'r', 'e', 'a', 'c', 'h', 'e', 'd', '\\', 'n' }; emlrtStack st; st.prev = sp; st.tls = sp->tls; y = NULL; m17 = mxCreateCharArray(2, iv84); for (i = 0; i < 7; i++) { cv98[i] = cv99[i]; } emlrtInitCharArrayR2013a(sp, 7, m17, cv98); emlrtAssign(&y, m17); b_y = NULL; m17 = mxCreateDoubleScalar(1.0); emlrtAssign(&b_y, m17); c_y = NULL; m17 = mxCreateCharArray(2, iv85); for (i = 0; i < 26; i++) { cv100[i] = cv101[i]; } emlrtInitCharArrayR2013a(sp, 26, m17, cv100); emlrtAssign(&c_y, m17); st.site = &ew_emlrtRSI; return c_emlrt_marshallIn(&st, feval(&st, y, b_y, c_y, &n_emlrtMCI), "feval"); }
extern "C" const char * stage16_5_blep (const char *foo) { string_vector argv(2); argv(0) = "embedded"; argv(1) = "-q"; octave_main(2, argv.c_str_vec(), 1); octave_exit = much_improved_octave_exit_func; int st=0; eval_string("source(\"stage17.m\")", true, st); octave_value_list args(1); args(octave_idx_type(0)) = octave_value(foo); octave_value_list out = feval("blep", args, 1); std::string orv = out(0).string_value(); const char *rv = strdup(orv.c_str()); clean_up_and_exit(0); return rv; }
static real_T c_fprintf(const emlrtStack *sp) { const mxArray *y; static const int32_T iv78[2] = { 1, 7 }; const mxArray *m14; char_T cv86[7]; int32_T i; static const char_T cv87[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; const mxArray *c_y; static const int32_T iv79[2] = { 1, 23 }; char_T cv88[23]; static const char_T cv89[23] = { 'D', 'L', '|', ' ', 'D', 'u', 'p', 'l', 'i', 'c', 'a', 't', 'e', ' ', 'M', 'e', 's', 's', 'a', 'g', 'e', '\\', 'n' }; emlrtStack st; st.prev = sp; st.tls = sp->tls; y = NULL; m14 = mxCreateCharArray(2, iv78); for (i = 0; i < 7; i++) { cv86[i] = cv87[i]; } emlrtInitCharArrayR2013a(sp, 7, m14, cv86); emlrtAssign(&y, m14); b_y = NULL; m14 = mxCreateDoubleScalar(1.0); emlrtAssign(&b_y, m14); c_y = NULL; m14 = mxCreateCharArray(2, iv79); for (i = 0; i < 23; i++) { cv88[i] = cv89[i]; } emlrtInitCharArrayR2013a(sp, 23, m14, cv88); emlrtAssign(&c_y, m14); st.site = &ew_emlrtRSI; return c_emlrt_marshallIn(&st, feval(&st, y, b_y, c_y, &n_emlrtMCI), "feval"); }
VALUE or_feval(VALUE function_name, VALUE arguments) { VALUE ruby_val = Qnil; int i, n; octave_value_list argList; n = RARRAY_LEN(arguments); bool is_function_definition = (n == 1 && FIXNUM_P(RARRAY_PTR(arguments)[0]) == 0 && strncmp(RSTRING_PTR(StringValue(RARRAY_PTR(arguments)[0])), "function ", 9) == 0); for (i = 0; i < n; i++) { argList(i) = OR_Variable(RARRAY_PTR(arguments)[i]).to_octave(); } if (octave_set_current_context) { // unwind_protect::run_all(); raw_mode(0); } can_interrupt = true; octave_initialized = true; try { symbol_table::set_scope(symbol_table::top_scope()); reset_error_handler(); int nargout = (is_function_definition ? 0 : 1); octave_value_list val = feval(std::string(RSTRING_PTR(function_name)), argList, nargout); if(val.length() > 0 && val(0).is_defined()) { ruby_val = OR_Variable(val(0)).to_ruby(); } } catch (octave_interrupt_exception) { recover_from_exception(); error_state = -2; } catch (std::bad_alloc) { recover_from_exception(); error_state = -3; } octave_initialized = false; return(ruby_val); }
static real_T g_fprintf(const emlrtStack *sp) { const mxArray *y; static const int32_T iv82[2] = { 1, 7 }; const mxArray *m16; char_T cv94[7]; int32_T i; static const char_T cv95[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; const mxArray *c_y; static const int32_T iv83[2] = { 1, 21 }; char_T cv96[21]; static const char_T cv97[21] = { 'D', 'L', '|', ' ', 'T', 'i', 'm', 'e', 'o', 'u', 't', ' ', 'o', 'c', 'c', 'u', 'r', 'e', 'd', '\\', 'n' }; emlrtStack st; st.prev = sp; st.tls = sp->tls; y = NULL; m16 = mxCreateCharArray(2, iv82); for (i = 0; i < 7; i++) { cv94[i] = cv95[i]; } emlrtInitCharArrayR2013a(sp, 7, m16, cv94); emlrtAssign(&y, m16); b_y = NULL; m16 = mxCreateDoubleScalar(1.0); emlrtAssign(&b_y, m16); c_y = NULL; m16 = mxCreateCharArray(2, iv83); for (i = 0; i < 21; i++) { cv96[i] = cv97[i]; } emlrtInitCharArrayR2013a(sp, 21, m16, cv96); emlrtAssign(&c_y, m16); st.site = &ew_emlrtRSI; return c_emlrt_marshallIn(&st, feval(&st, y, b_y, c_y, &n_emlrtMCI), "feval"); }
static real_T e_fprintf(real_T varargin_1) { real_T nbytes; const mxArray *y; static const int32_T iv2[2] = { 1, 7 }; const mxArray *m1; char_T cv4[7]; int32_T i; static const char_T cv5[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; static const int32_T iv3[2] = { 1, 25 }; char_T cv6[25]; static const char_T cv7[25] = { 'B', 'E', 'R', ' ', 'f', 'o', 'r', ' ', 'p', 'r', 'e', 'a', 'm', 'b', 'l', 'e', ':', ' ', '%', '.', '1', '0', 'f', '\\', 'n' }; emlrtPushRtStackR2012b(&d_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); y = NULL; m1 = mxCreateCharArray(2, iv2); for (i = 0; i < 7; i++) { cv4[i] = cv5[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 7, m1, cv4); emlrtAssign(&y, m1); b_y = NULL; m1 = mxCreateCharArray(2, iv3); for (i = 0; i < 25; i++) { cv6[i] = cv7[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 25, m1, cv6); emlrtAssign(&b_y, m1); nbytes = emlrt_marshallIn(feval(y, emlrt_marshallOut(1.0), b_y, emlrt_marshallOut(varargin_1), &emlrtMCI), "feval"); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&d_emlrtRSI, emlrtRootTLSGlobal); return nbytes; }
/* Function Definitions */ static real_T c_fprintf(real_T varargin_1) { real_T nbytes; const mxArray *y; static const int32_T iv0[2] = { 1, 7 }; const mxArray *m0; char_T cv0[7]; int32_T i; static const char_T cv1[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' }; const mxArray *b_y; static const int32_T iv1[2] = { 1, 21 }; char_T cv2[21]; static const char_T cv3[21] = { 'B', 'E', 'R', ' ', 'f', 'o', 'r', ' ', 'd', 'a', 't', 'a', ':', ' ', '%', '.', '1', '0', 'f', '\\', 'n' }; emlrtPushRtStackR2012b(&d_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); y = NULL; m0 = mxCreateCharArray(2, iv0); for (i = 0; i < 7; i++) { cv0[i] = cv1[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 7, m0, cv0); emlrtAssign(&y, m0); b_y = NULL; m0 = mxCreateCharArray(2, iv1); for (i = 0; i < 21; i++) { cv2[i] = cv3[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m0, cv2); emlrtAssign(&b_y, m0); nbytes = emlrt_marshallIn(feval(y, emlrt_marshallOut(1.0), b_y, emlrt_marshallOut(varargin_1), &emlrtMCI), "feval"); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&d_emlrtRSI, emlrtRootTLSGlobal); return nbytes; }
void evangelionbios_init( void ) { // Bind the saved program state context into Forth PUSH(pointer2cell((void *)&__context)); feval("['] __context cell+ !"); #if defined(CONFIG_DRIVER_FW_CFG) // Bind the Forth fw_cfg file interface bind_func("fw-cfg-read-file", forth_fw_cfg_read_file); #endif // Bind the C implementation of (init-program) into Forth bind_func("(init-program)", init_program); // Bind the C implementation of (go) into Forth bind_func("(go)", go); // Bind the LE access words bind_func("le-w!", lewstore); bind_func("le-l!", lelstore); bind_func("le-w@", lewfetch); bind_func("le-l@", lelfetch); }
void setup_romvec(void) { /* SPARC32 is slightly unusual in that before invoking any loaders, a romvec array needs to be set up to pass certain parameters using a C struct. Hence this function extracts the relevant boot information and places it in obp_arg. */ int intprop, proplen, target, device, i; unsigned int *intprop_ptr; phandle_t chosen; char *prop, *id, *name; static char bootpathbuf[128], bootargsbuf[128], buf[128]; struct linux_mlist_v0 **pp; /* Get the stdin and stdout paths */ chosen = find_dev("/chosen"); intprop = get_int_property(chosen, "stdin", &proplen); PUSH(intprop); fword("get-instance-path"); ((struct linux_romvec *)romvec)->pv_stdin = pop_fstr_copy(); intprop = get_int_property(chosen, "stdout", &proplen); PUSH(intprop); fword("get-instance-path"); ((struct linux_romvec *)romvec)->pv_stdout = pop_fstr_copy(); /* Get the name of the selected boot device, along with the device and unit number */ prop = get_property(chosen, "bootpath", &proplen); strncpy(bootpathbuf, prop, proplen); prop = get_property(chosen, "bootargs", &proplen); strncpy(bootargsbuf, prop, proplen); /* Set bootpath pointer used in romvec table to the bootpath */ push_str(bootpathbuf); fword("pathres-resolve-aliases"); bootpath = pop_fstr_copy(); printk("bootpath: %s\n", bootpath); /* Now do some work to get hold of the target, partition etc. */ push_str(bootpathbuf); feval("open-dev"); feval("ihandle>boot-device-handle drop to my-self"); push_str("name"); fword("get-my-property"); POP(); name = pop_fstr_copy(); if (!strncmp(name, "sd", 2)) { /* Old-style SunOS disk paths are given in the form: sd(c,t,d):s where: c = controller (Nth controller in system, usually 0) t = target (my-unit phys.hi) d = device/LUN (my-unit phys.lo) s = slice/partition (my-args) */ /* Controller currently always 0 */ obp_arg.boot_dev_ctrl = 0; /* Get the target, device and slice */ fword("my-unit"); target = POP(); device = POP(); fword("my-args"); id = pop_fstr_copy(); if (id != NULL) { snprintf(buf, sizeof(buf), "sd(0,%d,%d):%c", target, device, id[0]); obp_arg.dev_partition = id[0] - 'a'; } else { snprintf(buf, sizeof(buf), "sd(0,%d,%d)", target, device); obp_arg.dev_partition = 0; } obp_arg.boot_dev_unit = target; obp_arg.boot_dev[0] = buf[0]; obp_arg.boot_dev[1] = buf[1]; obp_arg.argv[0] = buf; obp_arg.argv[1] = bootargsbuf; } else if (!strncmp(name, "SUNW,fdtwo", 10)) { obp_arg.boot_dev_ctrl = 0; obp_arg.boot_dev_unit = 0; obp_arg.dev_partition = 0; strcpy(buf, "fd()"); obp_arg.boot_dev[0] = buf[0]; obp_arg.boot_dev[1] = buf[1]; obp_arg.argv[0] = buf; obp_arg.argv[1] = bootargsbuf; } else if (!strncmp(name, "le", 2)) { obp_arg.boot_dev_ctrl = 0; obp_arg.boot_dev_unit = 0; obp_arg.dev_partition = 0; strcpy(buf, "le()"); obp_arg.boot_dev[0] = buf[0]; obp_arg.boot_dev[1] = buf[1]; obp_arg.argv[0] = buf; obp_arg.argv[1] = bootargsbuf; } /* Generate the totphys (total memory available) list */ prop = get_property(s_phandle_memory, "reg", &proplen); intprop_ptr = (unsigned int *)prop; for (pp = &totphyslist, i = 0; i < (proplen / sizeof(int)); pp = &(**pp).theres_more, i+=3) { *pp = (struct linux_mlist_v0 *)malloc(sizeof(struct linux_mlist_v0)); (**pp).theres_more = NULL; (**pp).start_adr = (char *)intprop_ptr[1]; (**pp).num_bytes = intprop_ptr[2]; intprop_ptr += 3; } /* Generate the avail (physical memory available) list */ prop = get_property(s_phandle_memory, "available", &proplen); intprop_ptr = (unsigned int *)prop; for (pp = &availlist, i = 0; i < (proplen / sizeof(int)); pp = &(**pp).theres_more, i+=3) { *pp = (struct linux_mlist_v0 *)malloc(sizeof(struct linux_mlist_v0)); (**pp).theres_more = NULL; (**pp).start_adr = (char *)intprop_ptr[1]; (**pp).num_bytes = intprop_ptr[2]; intprop_ptr += 3; } /* Generate the prommap (taken virtual memory) list from inverse of available */ prop = get_property(s_phandle_mmu, "available", &proplen); intprop_ptr = (unsigned int *)prop; for (pp = &prommaplist, i = 0; i < (proplen / sizeof(int)); pp = &(**pp).theres_more, i+=3) { *pp = (struct linux_mlist_v0 *)malloc(sizeof(struct linux_mlist_v0)); (**pp).theres_more = NULL; (**pp).start_adr = (char *)(intprop_ptr[1] + intprop_ptr[2]); if (i + 3 < (proplen / sizeof(int))) { /* Size from next entry */ (**pp).num_bytes = (intprop_ptr[4] + intprop_ptr[5]) - (intprop_ptr[1] + intprop_ptr[2]); } else { /* Tail (size from top of virtual memory) */ (**pp).num_bytes = ofmem_arch_get_virt_top() - 1 - (intprop_ptr[1] + intprop_ptr[2]) + 1; } intprop_ptr += 3; } /* Finally set the memory properties */ ((struct linux_romvec *)romvec)->pv_v0mem.v0_totphys = &totphyslist; ((struct linux_romvec *)romvec)->pv_v0mem.v0_available = &availlist; ((struct linux_romvec *)romvec)->pv_v0mem.v0_prommap = &prommaplist; }
int fcode_load(ihandle_t dev) { int retval = -1; uint8_t fcode_header[8]; unsigned long start, size; unsigned int offset; /* Mark the saved-program-state as invalid */ feval("0 state-valid !"); fd = open_ih(dev); if (fd == -1) { goto out; } for (offset = 0; offset < 16 * 512; offset += 512) { seek_io(fd, offset); if (read_io(fd, &fcode_header, sizeof(fcode_header)) != sizeof(fcode_header)) { debug("Can't read FCode header from ihandle " FMT_ucellx "\n", dev); retval = LOADER_NOT_SUPPORT; goto out; } if (is_fcode(fcode_header)) goto found; } debug("Not a bootable FCode image\n"); retval = LOADER_NOT_SUPPORT; goto out; found: size = (fcode_header[4] << 24) | (fcode_header[5] << 16) | (fcode_header[6] << 8) | fcode_header[7]; fword("load-base"); start = POP(); printf("\nLoading FCode image...\n"); seek_io(fd, offset); if ((size_t)read_io(fd, (void *)start, size) != size) { printf("Can't read file (size 0x%lx)\n", size); goto out; } debug("Loaded %lu bytes\n", size); debug("entry point is %#lx\n", start); // Initialise load-state PUSH(size); feval("load-state >ls.file-size !"); feval("fcode load-state >ls.file-type !"); out: close_io(fd); return retval; }
int asy1(double *nodes, double*weights, unsigned long int n, double a, double b) { int j, k, iter, oldk; double x, w, t, dt, C, C2, K, tK, tmp, f, fp, dn = (double)n, pn, jk, phik, phi; double dS, S, nak, nk, fna, fn, fnab, ff, Cw; double rho = dn + .5*(a+b+1.), rho2 = dn + .5*(a+b-1.); double tB1[NN], A2[NN], xcheb[NN]; // The constant out the front of the sum in evaluation (compute only once) dS = .5*a*a/dn; S = dS; k = 1; while (fabs(dS/S) > EPSILON/10) { k += 1; dS *= -(k-1.)/(k+1.)/dn*a; S += dS; } double stirling[10] = {1., 1./12., 1./288., -139./51840., -571./2488320., 163879./209018880, 5246819./75246796800., -534703531./902961561600., -4483131259./86684309913600., 432261921612371./514904800886784000.}; fn = 1.; nk = n; fna = 1.; nak = n+a; for ( k = 1 ; k < 10 ; k++ ) { fn += stirling[k]/nk; fna += stirling[k]/nak; nk *= n; nak *= n+a; } ff = fna/fn; C = exp(S)*sqrtl(.5*(dn+a)/dn)*pow(dn/rho,a)*ff; C2 = exp(S)*sqrtl(.5*dn/(dn+a))*pow(dn/rho2,a)*ff; // C2 = C*n/(n+1.0)*pow(rho/rho2,a); // Constant for the weights Cw = 1; phi = -a*b/(double)n; for (k = 1; k <= 20; k++) { Cw = Cw + phi; phi = -(k+a)*(k+b)/(k+1.)/(n-k)*phi; if (fabs(phi) < EPSILON/10) break; if (k == n-1) break; } Cw *= pow(2,a+b+1); // Chebyshev points for ( k=0; k<NN; k++ ) { xcheb[NN-k-1] = .5*CC*(1+cos(PI*k/(NN-1.))); } // Loop over each root (first half, theta <= PI/2) for ( k = 1; k <= n; k++ ) { // Asymptotic approximation of roots (in theta-space) K = PI*(4.0*k-1.+2.*a)/(4.0*n+2.0*(a+b+1)); tK = tan(.5*K); tmp = 2*n+a+b+1; t = K + ((.25-a*a)/tK-(.25-b*b)*tK)/(tmp*tmp); x = cos(t); if ( t > PI/2 ) break; // Initialise dt = 1.0; iter = 1; // Newton iteration for roots while (fabs(dt) > EPSILON) { feval(n, t, C, C2, &f, &fp, a, b, tB1, A2, xcheb); // Evaluate at current approximation dt = f/fp; // Newton update t += dt; // Update t if (iter++ > ITER_MAX) break; } // Convert back to x-space x = cos(t); w = Cw / (fp*fp); // Store nodes and weights nodes[n-k] = x; weights[n-k] = w; } // Use symmetry and flip for theta > PI/2 tmp = a; a = b; b = tmp; // The constant out the front of the sum in evaluation (compute only once) dS = .5*a*a/dn; S = dS; j = 1; while (fabs(dS/S) > EPSILON/10) { j += 1; dS *= -(j-1.)/(j+1.)/dn*a; S += dS; } fn = 1.; nk = n; fna = 1.; nak = n+a; for ( j = 1 ; j < 10 ; j++ ) { fn += stirling[j]/nk; fna += stirling[j]/nak; nk *= n; nak *= n+a; } ff = fna/fn; C = exp(S)*sqrtl(.5*(dn+a)/dn)*pow(dn/rho,a)*ff; C2 = exp(S)*sqrtl(.5*dn/(dn+a))*pow(dn/rho2,a)*ff; // Loop over each root (second half, theta > PI/2) for ( k = k-1; k < n; k++ ) { // Asymptotic approximation of roots (in theta-space) K = PI*(4.0*(n-k)-1.+2.*a)/(4.0*n+2.0*(a+b+1)); tK = tan(.5*K); tmp = 2*n+a+b+1; t = K + ((.25-a*a)/tK-(.25-b*b)*tK)/(tmp*tmp); x = cos(t); // Initialise dt = 1.0; iter = 1; // Newton iteration for roots while (fabs(dt) > EPSILON) { feval(n, t, C, C2, &f, &fp, a, b, tB1, A2, xcheb); // Evaluate at current approximation dt = f/fp; // Newton update t += dt; // Update t if (iter++ > ITER_MAX) break; } // Convert back to x-space x = -cos(t); w = Cw/(fp*fp); // Store nodes and weights nodes[n-1-k] = x; weights[n-1-k] = w; } return 0; }
octave_value_list octave_caller_t::call_function(std::string function_name,const octave_value_list& args) { octave_value_list result = feval(function_name.c_str(), args); return result; }
void load(ihandle_t dev) { /* Invoke the loaders on the specified device */ char *param; ucell valid; #ifdef CONFIG_LOADER_ELF /* Grab the boot arguments */ push_str("bootargs"); push_str("/chosen"); fword("(find-dev)"); POP(); fword("get-package-property"); POP(); param = pop_fstr_copy(); elf_load(&sys_info, dev, param, &elf_boot_notes); feval("state-valid @"); valid = POP(); if (valid) { return; } #endif #ifdef CONFIG_LOADER_AOUT aout_load(&sys_info, dev); feval("state-valid @"); valid = POP(); if (valid) { return; } #endif #ifdef CONFIG_LOADER_FCODE fcode_load(dev); feval("state-valid @"); valid = POP(); if (valid) { return; } #endif #ifdef CONFIG_LOADER_FORTH forth_load(dev); feval("state-valid @"); valid = POP(); if (valid) { return; } #endif #ifdef CONFIG_LOADER_BOOTCODE /* Check for a "raw" %BOOT bootcode payload */ feval("want-bootcode @"); valid = POP(); if (valid) { bootcode_load(dev); } #endif }