Exemple #1
0
void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
	uchar *env, *nxt;
	int i;

#if defined(CFG_FLASH_ENV_ADDR)
	uchar *environment = env_init();
#else
	env_init();
#endif	/* CFG_FLASH_ENV_ADDR */

	if (argc == 1) {		/* Print all env variables	*/
		uchar *start = environment;
		for (env=environment; *env; env=nxt+1) {
			for (nxt=env; *nxt; ++nxt)
				;
			puts (env);
			putc  ('\n');

			if (tstc()) {
				getc ();
				printf ("\n ** Abort\n");
				return;
			}
		}

		printf("\nEnvironment size: %d bytes\n", env-start);

		return;
	}

	for (i=1; i<argc; ++i) {	/* print single env variables	*/
		char *name = argv[i];
		char *val = NULL;

		for (env=environment; *env; env=nxt+1) {

			for (nxt=env; *nxt; ++nxt)
				;
			val=envmatch(name, env);
			if (val) {
				puts (name);
				putc ('=');
				puts (val);
				putc ('\n');
				break;
			}
		}
		if (!val)
			printf ("## Error: \"%s\" not defined\n", name);
	}
}
Exemple #2
0
void mips_init()
{
	printf("init.c:\tmips_init() is called\n");
	mips_detect_memory();

	mips_vm_init();
	page_init();
	//page_check();

	env_init();

	//ENV_CREATE(user_fktest);
	//ENV_CREATE(user_pt1);
	ENV_CREATE(user_idle);
	ENV_CREATE(fs_serv);
	//ENV_CREATE(user_fktest);
	//ENV_CREATE(user_pingpong);
	//ENV_CREATE(user_testfdsharing);
	//ENV_CREATE(user_testspawn);
	//ENV_CREATE(user_testpipe);
	//ENV_CREATE(user_testpiperace);
	ENV_CREATE(user_icode);
	trap_init();
	kclock_init();
	//env_run(&envs[0]);

	//env_run(&envs[1]);

	panic("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");

	while (1);

	panic("init.c:\tend of mips_init() reached!");
}
Exemple #3
0
int rpmsg_init(int dev_id, struct remote_device **rdev,
                rpmsg_chnl_cb_t channel_created,
                rpmsg_chnl_cb_t channel_destroyed,
                rpmsg_rx_cb_t default_cb, int role) {
    int status;

    /* Initialize IPC environment */
    status = env_init();
    if (status == RPMSG_SUCCESS) {
        /* Initialize the remote device for given cpu id */
        status = rpmsg_rdev_init(rdev, dev_id, role, channel_created,
                        channel_destroyed, default_cb);
        if (status == RPMSG_SUCCESS) {
            /* Kick off IPC with the remote device */
            status = rpmsg_start_ipc(*rdev);
        }
    }

    /* Deinit system in case of error */
    if (status != RPMSG_SUCCESS) {
        rpmsg_deinit(*rdev);
    }

    return status;
}
Exemple #4
0
static ssize_t env_proc_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
{
	char p[32];
	char *page = (char *)p;
	int err = 0;
	ssize_t len = 0;
	int env_valid_length = 0;

	env_init();

	if (!env_valid) {
		pr_err("[%s]read no env valid\n", MODULE_NAME);
		page += sprintf(page, "\nno env valid\n");
		len = page - &p[0];

		if (*ppos >= len)
			return 0;
		err = copy_to_user(buf, (char *)p, len);
		*ppos += len;
		if (err)
			return err;
		return len;
	} else {
		env_valid_length = get_env_valid_length();
		if (*ppos >= env_valid_length)
			return 0;
		if ((size + *ppos) > env_valid_length)
			size = env_valid_length - *ppos;
		err = copy_to_user(buf, g_env.env_data + *ppos, size);
		if (err)
			return err;
		*ppos += size;
		return size;
	}
}
Exemple #5
0
void
i386_init(void)
{
	extern char edata[], end[];

	// Before doing anything else, complete the ELF loading process.
	// Clear the uninitialized global data (BSS) section of our program.
	// This ensures that all static/global variables start out zero.
	memset(edata, 0, end - edata);

	// Initialize the console.
	// Can't call cprintf until after we do this!
	cons_init();

	cprintf("6828 decimal is %o octal!\n", 6828);

	// Lab 2 memory management initialization functions
	i386_detect_memory();
	i386_vm_init();
	page_init();
	page_check();

	// Lab 3 user environment initialization functions
	env_init();
	idt_init();

	// Lab 4 multitasking initialization functions
	pic_init();
	kclock_init();

	// Should always have an idle process as first one.
	ENV_CREATE(user_idle);

	// Start fs.
	ENV_CREATE(fs_fs);
	ENV_CREATE(user_icode);

#if defined(TEST)
	// Don't touch -- used by grading script!
	ENV_CREATE2(TEST, TESTSIZE)
#else
	// Touch all you want.
	// ENV_CREATE(user_icode);
	// ENV_CREATE(user_pipereadeof);
	// ENV_CREATE(user_pipewriteeof);
	// ENV_CREATE(user_testpipe);
	// ENV_CREATE(user_primespipe);
	// ENV_CREATE(user_testpiperace);
	// ENV_CREATE(user_testpiperace2);
	// ENV_CREATE(user_testfdsharing);
#endif // TEST*

	// Should not be necessary - drain keyboard because interrupt has given up.
	kbd_intr();

	// Schedule and run the first user environment!
	sched_yield();


}
Exemple #6
0
void __attribute__((noreturn)) mainloop (void)
{
  prvSetupHardware ();
  vLedInit ();

  /* If no previous environment exists - create a new, but don't store it */
  env_init ();
  if(!env_load ()) {
    debug_printf ("unable to load environment, resetting to defaults\n");
    bzero (&env, sizeof (env));
  }

  if (env.e.n_lamps > MAX_LAMPS)
    env.e.n_lamps = 0;

  vRndInit ((((u_int32_t) env.e.mac_h) << 8) | env.e.mac_l);
  vNetworkInit ();

  xTaskCreate (vUSBCDCTask, (signed portCHAR *) "USB", TASK_USB_STACK,
	       NULL, TASK_USB_PRIORITY, NULL);

  PtInitProtocol ();
  vUSBShellInit ();
  vTaskStartScheduler ();

  while(1);
}
Exemple #7
0
void fih_hwid_get(void)
{
  pr_info("======FIH HWID init start======\r\n");

  if (fih_get_s1_boot())
  {
    pr_info("This is s1 boot\r\n");
  }
  else
  {
    pr_info("This is qcom boot\r\n");
  }

  if(env_init())
  {
    pr_info("FIH HWID init fail\r\n");
    pr_info("================================\r\n");
  }

  if(hwid_map())
  {
    pr_info("******map fail use default HWID******\r\n");
  }

  hwid_info();

  pr_info("================================\r\n");

}
Exemple #8
0
void board_init_f(ulong dummy)
{
	/* Set global data pointer */
	gd = &gdata;
	/* Clear global data */
	memset((void *)gd, 0, sizeof(gd_t));
#ifdef CONFIG_LS2085A
	arch_cpu_init();
#endif
#ifdef CONFIG_FSL_IFC
	init_early_memctl_regs();
#endif
	board_early_init_f();
	timer_init();
#ifdef CONFIG_LS2085A
	env_init();
#endif
	get_clocks();

	preloader_console_init();

#ifdef CONFIG_SPL_I2C_SUPPORT
	i2c_init_all();
#endif
	dram_init();

	/* Clear the BSS */
	memset(__bss_start, 0, __bss_end - __bss_start);

#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
	enable_layerscape_ns_access();
#endif
	board_init_r(NULL, 0);
}
Exemple #9
0
void
i386_init(void)
{
    extern char edata[], end[];

    // Before doing anything else, complete the ELF loading process.
    // Clear the uninitialized global data (BSS) section of our program.
    // This ensures that all static/global variables start out zero.
    memset(edata, 0, end - edata);

    // Initialize the console.
    // Can't call cprintf until after we do this!
    cons_init();

    cprintf("6828 decimal is %o octal!\n", 6828);

    // Lab 2 memory management initialization functions
    mem_init();

    // Lab 3 user environment initialization functions
    env_init();
    trap_init();

#if defined(TEST)
    // Don't touch -- used by grading script!
    ENV_CREATE(TEST, ENV_TYPE_USER);
#else
    // Touch all you want.
    ENV_CREATE(user_hello, ENV_TYPE_USER);
#endif // TEST*

    // We only have one user environment for now, so just run it.
    env_run(&envs[0]);
}
/// Setup our environment (e.g., tty modes), process key strokes, then reset the environment.
void setup_and_process_keys(bool continuous_mode) {
    is_interactive_session = 1;  // by definition this is interactive
    set_main_thread();
    setup_fork_guards();
    wsetlocale(LC_ALL, L"POSIX");
    program_name = L"fish_key_reader";
    env_init();
    reader_init();
    input_init();

    // Installing our handler for every signal (e.g., SIGSEGV) is dubious because it means that
    // signals that might generate a core dump will not do so. On the other hand this allows us
    // to restore the tty modes so the terminal is still usable when we die.
    for (int signo = 1; signo < 32; signo++) {
        signal(signo, signal_handler);
    }

    if (continuous_mode) {
        printf("\n");
        printf("Type 'exit' or 'quit' to terminate this program.\n");
        printf("\n");
        printf("Characters such as [ctrl-D] (EOF) and [ctrl-C] (interrupt)\n");
        printf("have no special meaning and will not terminate this program.\n");
        printf("\n");
    } else {
        set_wait_on_escape_ms(500);
    }

    // TODO: We really should enable keypad mode but see issue #838.
    process_input(continuous_mode);
    restore_term_mode();
}
Exemple #11
0
///仅使用私钥初始化信封函数库
ENVELOP_API int env_init_only_key(IN const char * key)
{
	g_pub_key_list = (LinkList)malloc(sizeof(LNode));	
	memset(g_pub_key_list,0,sizeof(LNode));

	return env_init(NULL,key);
}
Exemple #12
0
void
init_telnet(void)
{
    env_init();

    SB_CLEAR();
    ClearArray(options);

    connected = ISend = localflow = donebinarytoggle = 0;
#ifdef	AUTHENTICATION
#ifdef	ENCRYPTION
    auth_encrypt_connect(connected);
#endif
#endif
    restartany = -1;

    SYNCHing = 0;

    /* Don't change NetTrace */

    escape = CONTROL(']');
    rlogin = _POSIX_VDISABLE;
#ifdef	KLUDGELINEMODE
    echoc = CONTROL('E');
#endif

    flushline = 1;
    telrcv_state = TS_DATA;
}
Exemple #13
0
int allocate(wam_t *wam)
{
	environ_t *env = env_init(wam->ctnptr, wam->env);
	wam->env = env;
	wam->pc += 1;
	return 0;
}
Exemple #14
0
void kernel_init()
{

  //TODO: init all kernel modules

#ifdef __KERN_DEBUG__

#ifdef USE_KERN_SHELL
  mimosa_kshell_run(NULL);
#endif // End of USE_KERN_SHELL;

#endif

#ifdef __MIMOSA_APP__
  mimosa_app_run();
#endif
  
  /*
  mimosa_memory_init();
  mimosa_fs_init();
  mimosa_interrupt_init();
  */
  
  // Call env_init at the end

  env_init();
}
/// Setup our environment (e.g., tty modes), process key strokes, then reset the environment.
static void setup_and_process_keys(bool continuous_mode) {
    is_interactive_session = 1;    // by definition this program is interactive
    setenv("LC_ALL", "POSIX", 1);  // ensure we're in a single-byte locale
    set_main_thread();
    setup_fork_guards();
    env_init();
    reader_init();
    input_init();
    proc_push_interactive(1);
    signal_set_handlers();
    install_our_signal_handlers();

    if (continuous_mode) {
        printf("\n");
        printf("To terminate this program type \"exit\" or \"quit\" in this window,\n");
        printf("or press [ctrl-C] or [ctrl-D] twice in a row.\n");
        printf("\n");
    }

    process_input(continuous_mode);
    restore_term_mode();
    restore_term_foreground_process_group();
    input_destroy();
    reader_destroy();
}
Exemple #16
0
void _benmain(void)
{
	struct FIFO32 fifo;
	int keybuf[128]={0};
	fifo32_init(&fifo, 128, keybuf);
	struct TSS32 tss_a = {0};
	cons_init();
	env_init();

	/* keyboard setting */
	init_kb(&fifo, 256);

	tss_a.ldtr = 0;
	tss_a.iomap = 0x40000000;
	set_segmdesc(gdt + 0, 103, (int) &tss_a, AR_TSS32);

	task_init(memman);
	/* Unfortunate try the switch back to 0*8 (_benmain) with farjmp but not working.
	* And the reason still unknown.
	* So that I use another thread_kb_io() to catch the keyboard interrupt.
	*/
	load_tr(0 * 8); // record current working task to tss_a
	task_create((int) &thread_kb_io, memman, "bshell", 1);
	task_create((int) &thread_events, memman, "events", 0);

	/* strange issue encountered if run pci_init at the setup_hw() */
	puts("pci scan bus\n");
	pci_init();
	farjmp(0, 4*8);

	puts("\nSystem Halted                                    \n");
	_syshalt();
}
/// Setup our environment (e.g., tty modes), process key strokes, then reset the environment.
static void setup_and_process_keys(bool continuous_mode) {
    is_interactive_session = 1;  // by definition this program is interactive
    set_main_thread();
    setup_fork_guards();
    proc_push_interactive(1);
    env_init();
    reader_init();
    // We need to set the shell-modes for ICRNL,
    // in fish-proper this is done once a command is run.
    tcsetattr(STDIN_FILENO, TCSANOW, &shell_modes);
    install_our_signal_handlers();

    if (continuous_mode) {
        std::fwprintf(stderr, L"\n");
        std::fwprintf(stderr,
                      L"To terminate this program type \"exit\" or \"quit\" in this window,\n");
        std::fwprintf(stderr, L"or press [ctrl-%c] or [ctrl-%c] twice in a row.\n",
                      shell_modes.c_cc[VINTR] + 0x40, shell_modes.c_cc[VEOF] + 0x40);
        std::fwprintf(stderr, L"\n");
    }

    process_input(continuous_mode);
    restore_term_mode();
    restore_term_foreground_process_group();
}
Exemple #18
0
void board_boot_order(u32 *spl_boot_list)
{
	/* Default boot sequence SPI -> MMC */
	spl_boot_list[0] = spl_boot_device();
	spl_boot_list[1] = BOOT_DEVICE_MMC1;
	spl_boot_list[2] = BOOT_DEVICE_UART;
	spl_boot_list[3] = BOOT_DEVICE_NONE;

	/*
	 * In case of emergency PAD pressed, we always boot
	 * to proper u-boot and perform recovery tasks there.
	 */
	if (board_check_emergency_pad())
		return;

#ifdef CONFIG_SPL_ENV_SUPPORT
	/* 'fastboot' */
	const char *s;

	if (env_init() || env_load())
		return;

	s = env_get("BOOT_FROM");
	if (s && !bootcount_error() && strcmp(s, "ACTIVE") == 0) {
		spl_boot_list[0] = BOOT_DEVICE_MMC1;
		spl_boot_list[1] = spl_boot_device();
	}
#endif
}
Exemple #19
0
int			main(int ac, char **av)
{
	GLFWwindow	*win;
	t_env		env;

	if (ac != 2)
		return (0);
	get_level(&env, av[1]);
	if (!glfwInit())
		exit(EXIT_FAILURE);
	win = glfwCreateWindow(2560, 1440, "Arkanoid",
			glfwGetPrimaryMonitor(), NULL);
	if (!win)
	{
		glfwTerminate();
		return (-1);
	}
	env_init(&env);
	glfwMakeContextCurrent(win);
	glfwSetKeyCallback(win, key_callback);
	do_window(win, &env);
	glfwDestroyWindow(win);
	glfwTerminate();
	return (0);
}
Exemple #20
0
void
i386_init(void)
{
	extern char edata[], end[];

	// Before doing anything else, complete the ELF loading process.
	// Clear the uninitialized global data (BSS) section of our program.
	// This ensures that all static/global variables start out zero.
	memset(edata, 0, end - edata);

	// Initialize the console.
	// Can't call cprintf until after we do this!
	cons_init();

	cprintf("6828 decimal is %o octal!\n", 6828);

	// Lab 2 memory management initialization functions
	i386_detect_memory();
	i386_vm_init();

	// Lab 3 user environment initialization functions
	env_init();
	idt_init();

	// Lab 4 multitasking initialization functions
	pic_init();
	kclock_init();

	time_init();
	pci_init();

	// Should always have an idle process as first one.
	ENV_CREATE(user_idle);

	// Start fs.
	ENV_CREATE(fs_fs);

#if !defined(TEST_NO_NS)
	// Start ns.
	ENV_CREATE(net_ns);
#endif

#if defined(TEST)
	// Don't touch -- used by grading script!
	ENV_CREATE2(TEST, TESTSIZE);
#else
	// Touch all you want.
	// ENV_CREATE(net_testoutput);
	// ENV_CREATE(user_echosrv);
	// ENV_CREATE(user_httpd);
  // ENV_CREATE(user_writemotd);
	// ENV_CREATE(user_testfile);
	ENV_CREATE(user_icode);
	// ENV_CREATE(user_primes);
#endif // TEST*

	// Schedule and run the first user environment!
	sched_yield();
}
void
i386_init(void)
{
	extern char edata[], end[];

	// Before doing anything else, complete the ELF loading process.
	// Clear the uninitialized global data (BSS) section of our program.
	// This ensures that all static/global variables start out zero.
	memset(edata, 0, end - edata);

	// Initialize the console.
	// Can't call cprintf until after we do this!
	cons_init();

	cprintf("6828 decimal is %o octal!\n", 6828);

	// Lab 2 memory management initialization functions
	mem_init();

	// Lab 3 user environment initialization functions
	env_init();
	trap_init();

	// Lab 4 multiprocessor initialization functions
	mp_init();
	lapic_init();

	// Lab 4 multitasking initialization functions
	pic_init();

	// Acquire the big kernel lock before waking up APs
	// Your code here:
        lock_kernel();
	// Starting non-boot CPUs
	boot_aps();

	// Start fs.
	ENV_CREATE(fs_fs, ENV_TYPE_FS);

#if defined(TEST)
	// Don't touch -- used by grading script!
	ENV_CREATE(TEST, ENV_TYPE_USER);
#else
	// Touch all you want.
//<<<<<<< HEAD
	ENV_CREATE(user_icode, ENV_TYPE_USER);
//=======
//	ENV_CREATE(user_dumbfork, ENV_TYPE_USER);
         
        
//>>>>>>> lab4
#endif // TEST*

	// Should not be necessary - drains keyboard because interrupt has given up.
	kbd_intr();

	// Schedule and run the first user environment!
	sched_yield();
}
Exemple #22
0
int nvm_set_parameter(const char *key, const char *value)
{
	int env_valid = 0;
	int isEnv1Bad = -1;
	int isEnv2Bad = -1;
	int opt_sts = CMM_SUCCESS;
	
	env_t *env_ptr = NULL;	

	isEnv1Bad = check_block("/dev/mtd2", 0);
	isEnv2Bad = check_block("/dev/mtd2", CFG_ENV_SIZE);

	if( -1 == isEnv1Bad )
	{
		printf("	ERROR: check env block 1 failed\n");
		return CMM_FAILED;
	}
	if( -1 == isEnv2Bad )
	{
		printf("	ERROR: check env block 2 failed\n");
		return CMM_FAILED;
	}

	/* either env1 or env2 is bad block, we do not permit set operation */
	if( ( isEnv1Bad != 0 ) || ( isEnv2Bad != 0 ) )
	{
		printf("	ERROR: env is broken\n");
		return CMM_FAILED;
	}

	/* Get NVM */
	env_ptr = env_init(&env_valid);
	if( NULL == env_ptr )
	{
		printf("	ERROR: read env failed\n");
		return CMM_FAILED;
	}

	/* modify ethaddr */
	__do_env_set_parameter(env_ptr, key, value);

	/* update env crc */
	__env_crc_update(env_ptr);
	
	/* save env to flash */
	if( CMM_SUCCESS != __save_env(env_ptr, env_valid) )
	{
		printf("	ERROR: save env failed\n\n");
		opt_sts = CMM_FAILED;
	}
	else
	{		
		opt_sts = CMM_SUCCESS;
	}

	/* free env_ptr malloced by function env_init() */
	env_destroy(env_ptr);	
	return opt_sts;
}
Exemple #23
0
/*
 * Return
 * 0 if booting into OS is selected
 * 1 if booting into U-Boot is selected
 */
int spl_start_uboot(void)
{
	env_init();
	if (env_get_yesno("boot_os") != 0)
		return 0;

	return 1;
}
Exemple #24
0
int main()
{
    envp = env_init(".", "xx", 1024);
    db_init(envp, &dbp, 100, 1024);
    run_bulk_insert();

    return 0;
}
Exemple #25
0
void
i386_init(void)
{
	extern char edata[], end[];

	// Before doing anything else, complete the ELF loading process.
	// Clear the uninitialized global data (BSS) section of our program.
	// This ensures that all static/global variables start out zero.
	memset(edata, 0, end - edata);
	// Initialize the console.
	// Can't call cprintf until after we do this!
	cons_init();

	//bluesea
	//经测试,下面的语句会输出:edata f0114300, end f0114970
	//因此,edata < end, [edata, end)之间是bss段, kernel需要用的global variable.
	// > end之后的内存可以用于boot_alloc
	//cprintf("edata %x, end %x\n", edata, end);
	

	cprintf("6828 decimal is %o octal!\n", 6828);

	// Lab 2 memory management initialization functions
	mem_init();

	// Lab 3 user environment initialization functions
	env_init();
	trap_init();

	// Lab 4 multiprocessor initialization functions
	mp_init();
	lapic_init();

	// Lab 4 multitasking initialization functions
	pic_init();

	// Acquire the big kernel lock before waking up APs
	// Your code here:
	lock_kernel();

	// Starting non-boot CPUs
	boot_aps();

#if defined(TEST)
	// Don't touch -- used by grading script!
	ENV_CREATE(TEST, ENV_TYPE_USER);
#else
	// Touch all you want.
	//ENV_CREATE(user_primes, ENV_TYPE_USER);
	//ENV_CREATE(user_yield, ENV_TYPE_USER);
	//ENV_CREATE(user_yield, ENV_TYPE_USER);
	//ENV_CREATE(user_yield, ENV_TYPE_USER);
	ENV_CREATE(user_dumbfork, ENV_TYPE_USER);
#endif // TEST*

	// Schedule and run the first user environment!
	sched_yield();
}
Exemple #26
0
void nvm_dump(void)
{
	int env_valid = 0;
	int isEnv1Bad = -1;
	int isEnv2Bad = -1;
	
	struct mtd_info_user info;

	env_t *env_ptr = NULL;

	if( CMM_SUCCESS != get_mtd_info("/dev/mtd2", &info) )
	{
		printf("	ERROR: can not get mtd info\n");
		return;
	}
	
	isEnv1Bad = check_block("/dev/mtd2", 0);
	isEnv2Bad = check_block("/dev/mtd2", CFG_ENV_SIZE);

	if( -1 == isEnv1Bad )
	{
		printf("	ERROR: check env block 1 failed\n");
		return;
	}
	if( -1 == isEnv2Bad )
	{
		printf("	ERROR: check env block 2 failed\n");
		return;
	}

	if( ( isEnv1Bad != 0 ) || ( isEnv2Bad != 0 ) )
	{
		printf("	ERROR: env is broken\n");
		return;
	}

	env_ptr = env_init(&env_valid);
	if( NULL == env_ptr )
	{
		printf("	ERROR: read env failed\n");
		return;
	}

	printf("nvm device name:	mtd2\n");
	printf("device type:		%d\n", info.type);
	printf("nvm total size:		%d KiB\n", info.size/1024);
	printf("block size:		%d KiB\n", info.erasesize/1024);
	printf("page size:		%d KiB\n", info.writesize/1024);
	printf("oob size:		%d bytes\n", info.oobsize);
	printf("bad blocks:		0\n");
	printf("env config size:	%d KiB\n", CFG_ENV_SIZE/1024);
	printf("env valid:		%d\n", env_valid);

	__debug_printf_env(env_ptr);
	
	env_destroy(env_ptr);
}
Exemple #27
0
int main(int argc, char ** argv)
{
	usb_cdc_class_t * cdc;

	DCC_LOG_INIT();
	DCC_LOG_CONNECT();

	DCC_LOG(LOG_TRACE, "1. cm3_udelay_calibrate()");
	cm3_udelay_calibrate();

	DCC_LOG(LOG_TRACE, "2. thinkos_init()");
	thinkos_init(THINKOS_OPT_PRIORITY(8) | THINKOS_OPT_ID(7));

	DCC_LOG(LOG_TRACE, "3. io_init()");
	io_init();

	DCC_LOG(LOG_TRACE, "4. external_bus_init()");
	external_bus_init();

	DCC_LOG(LOG_TRACE, "5. stdio_init()");
	stdio_init();
	printf("\n---\n");

	DCC_LOG(LOG_TRACE, "6. trace_init()");
	trace_init();

	DCC_LOG(LOG_TRACE, "7. env_init()");
	env_init();

	/* create some threads */
	DCC_LOG(LOG_TRACE, "8. monitor_init()");
	monitor_init();

	DCC_LOG(LOG_TRACE, "9. watchdog_init()");
	watchdog_init();

	DCC_LOG(LOG_TRACE, "10. net_init()");
	net_init();

	DCC_LOG(LOG_TRACE, "11. pkt_xmt_init()");
	pkt_xmt_init();
	net_pkt_mode(true);

	DCC_LOG(LOG_TRACE, "12. console_shell_init()");
	console_shell_init();

	DCC_LOG(LOG_TRACE, "13. usb_cdc_init()");
	usb_cdc_sn_set(*((uint64_t *)STM32F_UID));
	cdc = usb_cdc_init(&stm32f_otg_fs_dev, 
					   cdc_acm_def_str, 
					   cdc_acm_def_strcnt);

	DCC_LOG(LOG_TRACE, "14. usb_shell()");
	for (;;) {
		usb_shell(cdc);
	}
}
Exemple #28
0
void _benmain(void)
{
	int i;
	int c = 0;
	int keybuf[128]={0};
	struct FIFO32 fifo;
	struct TIMER *timer;
	fifo32_init(&fifo, 128, keybuf);
	struct TSS32 tss_a, tss_c;
	env_init();

	/* keyboard setting */
	init_kb(&fifo, 256);

	i=0;	

	timer = timer_alloc();
	timer_init(timer, &fifo, 1);
	timer_settime(timer, 50);

	tss_a.ldtr = 0;
	tss_a.iomap = 0x40000000;
	tss_c.ldtr = 0;
	tss_c.iomap = 0x40000000;
	set_segmdesc(gdt + 3, 103, (int) &tss_a, AR_TSS32);

	task_init(memman);

	/* Unfortunate try the switch back to 3*8 (_benmain) with farjmp but not working.
	* And the reason still unknown.
	* So that I use another thread_kb_io() to catch the keyboard interrupt.
	*/

	load_tr(3 * 8); // record current working task to tss_a
	task_create((int) &thread_kb_io, memman, "bshell");

	/* strange issue encountered if run pci_init at the setup_hw() */
	puts("pci scan bus\n");
	pci_init();
	for (;;) {
		asm_cli();
		if (fifo32_status(&fifo) == 0) {
			asm_stihlt(); // wake while keyboard input 
			// got a interrupt
		} else { /* scan_code input */
			c=fifo32_get(&fifo);
			asm_sti();
			if (c == 1) { 
				farjmp(0, 4*8);
			} else {
				puts("disabled boot options.\n");
			}
		}
	}
	puts("\nSystem Halted                                    \n");
	_syshalt();
}
Exemple #29
0
void
i386_init(void)
{
	extern char edata[], end[];

	// Before doing anything else, complete the ELF loading process.
	// Clear the uninitialized global data (BSS) section of our program.
	// This ensures that all static/global variables start out zero.
	memset(edata, 0, end - edata);

	// Initialize the console.
	// Can't call cprintf until after we do this!
	cons_init();

	cprintf("372 decimal is %o octal!\n", 372);


	// Lab 2 memory management initialization functions
	mem_init();

	// Lab 3 user environment initialization functions
	env_init();
	trap_init();

	// Lab 4 multiprocessor initialization functions
	mp_init();
	lapic_init();

	// Lab 4 multitasking initialization functions
	pic_init();

	// Acquire the big kernel lock before waking up APs
	// Your code here:
    lock_kernel();
	// Starting non-boot CPUs
	boot_aps();

	// Should always have idle processes at first.
	int i;
	for (i = 0; i < NCPU; i++)
		ENV_CREATE(user_idle, ENV_TYPE_IDLE);
    
   // ENV_CREATE(user_yield, ENV_TYPE_USER);
   // ENV_CREATE(user_yield, ENV_TYPE_USER);
   // ENV_CREATE(user_yield, ENV_TYPE_USER);
    
#if defined(TEST)
	// Don't touch -- used by grading script!
	ENV_CREATE(TEST, ENV_TYPE_USER);
#else
	// Touch all you want.
	ENV_CREATE(user_primes, ENV_TYPE_USER);
#endif // TEST*

	// Schedule and run the first user environment!
	sched_yield();
}
Exemple #30
0
JScript* script_create(void)
{
	JScript* s = (JScript*)NBK_malloc0(sizeof(JScript));
	s->scanner = scanner_create();
	s->scanner->script = s;
    s->scanner->handleToken = script_handleToken;
	env_init();
	return s;
}