Example #1
0
// Attention! PID has a HANDLE type. But it still is PID.
VOID DDKAPI
load_image_watcher(PUNICODE_STRING  uszFullImageName, HANDLE dwProcessId,
                   PIMAGE_INFO pImageInfo)
{
  //DbgPrint("LI callback runned PID: %d, Name: %wZ\r\n",
  //         dwProcessId, uszFullImageName);
  int j;
  for (j = 0;
       j < g_used_progs &&
         !RtlEqualUnicodeString(&g_usz_hprogs[j], uszFullImageName, TRUE);
       ++j)
    //DbgPrint("%wZ\r\nvs\r\n%wZ\r\n", &g_usz_hprogs[j], uszFullImageName);
    ;
  if (j == g_used_progs)
    return;

  int i;
  // Let us find a free entry
  for (i = 0; i < ENT_CNT && g_proc_table[i].pid; ++i);
  if (g_proc_table[i].pid) {
    // No more free entries
    DbgPrint("Sorry, can not handle this process\r\n");
    return;
  }
  g_proc_table[i].pid = dwProcessId;
  run_process(i, g_pwc_rprogs[j]);

  return;
}
Example #2
0
void prempt(int swap) {
    volatile process* p = get_ready_process();
    //	//print("Trying to execute process = %s with id = %d",p->p_name,p->pid);
    if(p==NULL)
        return;

    if(current_running_process->state == TASK_UNINTERRUPTIBLE) {
        return;
    }

    if(current_running_process->state == TASK_ZOMBIE) {
        add_to_zombie_queue(current_running_process);
    }

    if(current_running_process->state != TASK_WAITING && current_running_process->state != TASK_ZOMBIE) {
        current_running_process->state = TASK_SWAPPING;
        add_to_readyQ(current_running_process);
    }
    //disp_queue();
    //	disp_queue();
    if(p == NULL) {
        //print("Process returned null value");
        return;
        //	switch_to(init_process);
    } else {
        if(p->reg.rsi != 0) {
            switch_to(p);
        } else {
            run_process(p);
        }
    }

}
Example #3
0
File: myfork.c Project: 0x7678/zzuf
/*
 * Run a process, either by forking (Unix) or using the Windows API. The
 * child PID is stored in the child structure, and a communication channel
 * is set up using pipes.
 */
int myfork(zzuf_child_t *child, zzuf_opts_t *opts)
{
    /* Prepare communication pipes */
    int pipefds[3][2];
    for (int i = 0; i < 3; ++i)
    {
        if (mypipe(pipefds[i]) < 0)
        {
            perror("pipe");
            return -1;
        }
    }

    pid_t pid = run_process(child, opts, pipefds);
    if (pid < 0)
    {
        /* FIXME: close pipes */
        fprintf(stderr, "error launching `%s'\n", child->newargv[0]);
        return -1;
    }

    child->pid = pid;
    for (int i = 0; i < 3; ++i)
    {
        close(pipefds[i][1]);
        child->fd[i] = pipefds[i][0];
    }

    return 0;
}
Example #4
0
/* run loop for given queue type and msgid[.del]; msgid is a volatile string */
static void run_loop(const char *qtype, const char *msgid, const char *looppath) {
    const char *args[] = { looppath, qtype, msgid, NULL };

    if (run_process(MAX_PROC, WAIT_PROC, args))
        flog(LOG_INFO, "processing: %s %s", qtype, msgid);
    else
        flog(LOG_WARNING, "failed to launch: %s %s", qtype, msgid);
}
Example #5
0
 windows_process(const std::filesystem::path& filename, const std::vector<std::string>& argv = {},
                 const std::vector<std::string>& envp = {})
 {
    std::system_error ec = run_process(filename, argv, envp);
    if (ec.code().value() != 0)
    {
       throw ec;
    }
 }
Example #6
0
int main(void)
{
	status c_program;
	
	init_processes();
	ipc_open(endif_process->params, O_RDONLY);
	
	while(1)
		if (ipc_receive(endif_process->params, &c_program, sizeof(struct status)) > 0)
			run_process(&c_program, &execute_endif);
	return 0;
}
Example #7
0
void parseCommandLine ( char *command )
{
    char *args[100];
    parse(command , args);
    if(strncmp("cd",command,strlen(command)) == 0){
    	DIR* dir = opendir(args[1]);
    	if(dir){
    		closedir(dir);
    	}
    	else{
    		printf("Cannot open the directory\n");
    		return;
    	}
    	chdir(args[1]);
    	return;
    }
    char * inputFile = NULL;
    char * outputFile = NULL;
    int flags = 0;
    int len;
    for (len = 0 ; args[len] ; len++)
        ;
    int i;
    for (i = 0 ; args[i] ; i++)
    {
        if (args[i][0] == '<')
        {
            if (i + 1 < len)
                inputFile = args[i + 1];
            else
                inputFile = NULL;
            flags |= 1;
            args[i] = NULL;
            i++;
        }
        if (args[i][0] == '>')
        {
            flags |= 2;
            if (strlen(args[i]) == 2 && args[i][1] == '>')
            {
                flags |= 4;
                flags &= ~2;
            }
            if (i + 1 < len)
                outputFile = args[i + 1];
            else
                outputFile = NULL;
            args[i] = NULL;
            i++;
        }
    }
    run_process ( command , args , flags , inputFile , outputFile );
}
Example #8
0
/* timer callback */
static void timer_cb(evutil_socket_t fd, short what, void *arg)
{
    if (in_shutdown)
        return;

    if (afpd_pid == -1) {
        afpd_restarts++;
        LOG(log_note, logtype_afpd, "Restarting 'afpd' (restarts: %u)", afpd_restarts);
        if ((afpd_pid = run_process(_PATH_AFPD, "-d", "-F", obj.options.configfile, NULL)) == -1) {
            LOG(log_error, logtype_afpd, "Error starting 'afpd'");
        }
    }

    if (cnid_metad_pid == -1) {
        cnid_metad_restarts++;
        LOG(log_note, logtype_afpd, "Restarting 'cnid_metad' (restarts: %u)", cnid_metad_restarts);
        if ((cnid_metad_pid = run_process(_PATH_CNID_METAD, "-d", "-F", obj.options.configfile, NULL)) == -1) {
            LOG(log_error, logtype_afpd, "Error starting 'cnid_metad'");
        }
    }
}
Example #9
0
int main(int argc, char *argv[])
{
	puts("Mounting...");

	do_mounts();

	run_process("/virt/init_stage2");

	printf("Init failed: %s\n", strerror(errno));

	return 0;
}
/* Run the next process in the queue */
void run_next_process(){
  PID_type prev_pid = current_pid;
  current_pid = dequeue_ready_process();
  if (current_pid == IDLE_PROCESS){
    if (prev_pid != IDLE_PROCESS){
      printf("Time %d: Processor is idle\n",clock);fflush(stdout);
    }
  }
  else {
    run_process(current_pid);
  }
}
Example #11
0
File: shell.c Project: kjk/qemacs
EditBuffer *new_shell_buffer(const char *name, const char *path,
                             const char **argv, int is_shell)
{
    ShellState *s;
    EditBuffer *b, *b_color;

    b = eb_new("", BF_SAVELOG);
    if (!b)
        return NULL;
    set_buffer_name(b, name); /* ensure that the name is unique */
    eb_set_charset(b, &charset_vt100);

    s = malloc(sizeof(ShellState));
    if (!s) {
        eb_free(b);
        return NULL;
    }
    memset(s, 0, sizeof(ShellState));
    b->priv_data = s;
    b->close = shell_close;
    eb_add_callback(b, eb_offset_callback, &s->cur_offset);
    s->b = b;
    s->pty_fd = -1;
    s->pid = -1;
    s->is_shell = is_shell;
    s->qe_state = &qe_state;
    tty_init(s);

    /* add color buffer */
    if (is_shell) {
        b_color = eb_new("*color*", BF_SYSTEM);
        if (!b_color) {
            eb_free(b);
            free(s);
            return NULL;
        }
        /* no undo info in this color buffer */
        b_color->save_log = 0;
        eb_add_callback(b, shell_color_callback, s);
        s->b_color = b_color;
    }

    /* launch shell */
    if (run_process(path, argv, &s->pty_fd, &s->pid) < 0) {
        eb_free(b);
        return NULL;
    }

    set_read_handler(s->pty_fd, shell_read_cb, s);
    set_pid_handler(s->pid, shell_pid_cb, s);
    return b;
}
Example #12
0
void run_task(TASK_P tsk){
    
    switch(tsk->type){
        case PROCESS:
            printf("Process Start\n");
            run_process(tsk);
            break;
        case THREAD:
            break;
        default:
            printf("No TASK started\n");
    }
}
Example #13
0
int main(int argc, char *argv[])
{
	puts("Mounting...");

	do_mounts();

	puts("Starting '/bin/sh'...");

	run_process("/bin/sh");

	printf("Init failed: %s\n", strerror(errno));

	return 0;
}
Example #14
0
void out_of_memory() {
    for(int i=0; i<20; i++) {
        volatile process *p = get_ready_process();
        invalidate_r_queue(p->pid);
        invalidate_w_queue(p->pid);
        child_update(p->pid);
        free_process_memory(p);
    }
    volatile process *p = get_ready_process();
    if(p->reg.rsi != 0) {
        switch_to(p);
    } else {
        run_process(p);
    }
}
Example #15
0
int main(void)
{
	status c_program;
	
	init_processes(FALSE);
	
	signal(SIGINT, end_process);
	
	ipc_open(if_process->params, O_RDONLY);
	
	while(1)
		if (ipc_receive(if_process->params, &c_program, sizeof(struct status)) > 0)
			run_process(&c_program, &execute_if);
	return 0;
}
Example #16
0
/*
 * run_check_subtest --
 *	Run the subtest with the given parameters and check the results.
 */
static void
run_check_subtest(TEST_OPTS *opts, const char *debugger, uint64_t nops,
    bool close_test, uint64_t *nresultsp)
{
	int estatus, narg;
	char rarg[20], sarg[20], *subtest_args[MAX_ARGS];

	narg = 0;
	if (debugger != NULL) {
		subtest_args[narg++] = (char *)debugger;
		subtest_args[narg++] = (char *)"--";
	}

	subtest_args[narg++] = (char *)opts->progname;
	/* "subtest" must appear before arguments */
	if (close_test)
		subtest_args[narg++] = (char *)"subtest_close";
	else
		subtest_args[narg++] = (char *)"subtest";
	subtest_args[narg++] = (char *)"-h";
	subtest_args[narg++] = opts->home;
	subtest_args[narg++] = (char *)"-v";	/* subtest is always verbose */
	subtest_args[narg++] = (char *)"-p";
	subtest_args[narg++] = (char *)"-o";
	testutil_check(__wt_snprintf(sarg, sizeof(sarg), "%" PRIu64, nops));
	subtest_args[narg++] = sarg;		/* number of operations */
	subtest_args[narg++] = (char *)"-n";
	testutil_check(__wt_snprintf(
	    rarg, sizeof(rarg), "%" PRIu64, opts->nrecords));
	subtest_args[narg++] = rarg;		/* number of records */
	subtest_args[narg++] = NULL;
	testutil_assert(narg <= MAX_ARGS);
	if (opts->verbose)
		printf("running a separate process with %" PRIu64
		    " operations until fail...\n", nops);
	testutil_clean_work_dir(opts->home);
	testutil_check(run_process(
	    opts, debugger != NULL ? debugger : opts->progname,
	    subtest_args, &estatus));
	if (opts->verbose)
		printf("process exited %d\n", estatus);

	/*
	 * Verify results in parent process.
	 */
	testutil_check(check_results(opts, nresultsp));
}
Example #17
0
int main(int argc, char *argv[])
{
        int c;

        if (argc < 2)
        {
                fprintf(stderr, "Usage: %s <command>\n", argv[0]);
                exit(EXIT_FAILURE);
        }

        while ((c = getopt(argc, argv, "c:")) != -1);

        argc -= optind;
        argv += optind;

        setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_THROTTLE);
        int err = run_process(argv[0], &argv[0], 0x03);
        exit (err);
}
Example #18
0
void casr::State::run() {

	quit_time = ca::MAX_INT_TIME;
	for (;;) {
		ca::IntTime next_time = ca::MAX_INT_TIME;
		for (int p = 0; p < ca::process_count; p++) {
			ca::IntTime t = run_process(p);
			if (t < next_time) {
				next_time = t;
			}
		}
		if (quit_time <= next_time && quit_time != ca::MAX_INT_TIME) {
			global_time = quit_time;
			return;
		}
		if (next_time == ca::MAX_INT_TIME) {
			fprintf(stderr, "Deadlock detected\n");
			return;
		}
		global_time = next_time;
	}
}
Example #19
0
int main(int argc, char *argv[])
{
	pid_t child;
	int status;

	puts("Mounting...");

	do_mounts();

	/* get session leader */
	setsid();

	/* set controlling terminal */
	ioctl(0, TIOCSCTTY, 1);

	child = fork();
	if (child < 0) {
		printf("Fatal: fork() failed with %d\n", child);
		return 0;
	} else if (child == 0) {
		if (access("/virt/sandbox.sh", R_OK) == 0)
			run_process_sandbox("/bin/sh");
		else
			run_process("/bin/sh");
	} else {
		pid_t corpse;

		do {
			corpse = waitpid(-1, &status, 0);
		} while (corpse != child);
	}

	reboot(LINUX_REBOOT_CMD_RESTART);

	printf("Init failed: %s\n", strerror(errno));

	return 0;
}
Example #20
0
int main(int argc, char** argv)
{
	if (argc != 3)
	{
		printf("Usage: \"./ioprog <number_children> <scheduler_policy>\"");
		exit(EXIT_FAILURE);
	}
	int numChildren = atoi(argv[1]);
	schedinfo policy;
	/* Set the policy */
	if (!schedutil_parse_policy(argv[2], &policy))
	{
		exit(EXIT_FAILURE);
	}
	if (!schedutil_implement_policy(&policy))
	{
		exit(EXIT_FAILURE);
	}

	printf("Spawning %d children, using the scheduler policy %s.\n", numChildren, argv[2]);

	/* Spawn the child processes */
	int i;
        for (i = 0; i < numChildren; ++i)
        {
                pid_t pid = fork();
                if (pid == 0) /* Child */
                {
                        run_process();
                        exit(EXIT_SUCCESS);
                }
		else
		{
			++child_number;
		}
        }

	/* Wait for all children to finish */
        while (1)
        {
                pid_t status;
                pid_t done = wait(&status);
                if (done == -1)
                {
                        if (errno == ECHILD)
                        {
                                break; /* No more child processes */
                        }
                        else
                        {
                                printf("Waiting for child failed.\n");
                                abort();
                        }
                }
                else
                {
                        if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
                        {
                                printf("Waiting for pid %d failed.\n", done);
                                abort();
                        }
                }
        }

        return 0;
}
Example #21
0
void kernel_main(uint32_t r0, uint32_t r1, uint32_t *atags,
		uint32_t memory_kernel) {

	unsigned int memory_total;
	int init_process,idle_process;
	struct atag_info_t atag_info;
	uint32_t framebuffer_width=800,framebuffer_height=600;

	(void) r0;	/* Ignore boot method */

	/* Initialize Software Structures */
	processes_init();

	/* Detect Hardware */
	atags_detect(atags,&atag_info);
	hardware_type=atag_info.hardware_type;

	/* Initialize Hardware */

	/* Serial console is most important so do that first */
	uart_init();

	/* Enable Interrupts */
	enable_interrupts();

	/************************/
	/* Boot message!	*/
	/************************/

	printk("\r\nBooting VMWos...\r\n");

	/**************************/
	/* Device Drivers	  */
	/**************************/

	/* Set up ACT LED */
	led_init();

	/* Set up timer */
	timer_init();

	/* Set up keyboard */
	ps2_keyboard_init();

	/* Enable the Framebuffer */
	if (atag_info.framebuffer_x!=0) {
		framebuffer_width=atag_info.framebuffer_x;
	}
	if (atag_info.framebuffer_y!=0) {
		framebuffer_height=atag_info.framebuffer_y;
	}

	framebuffer_init(framebuffer_width,framebuffer_height,24);
	framebuffer_console_init();

	/* Delay to allow time for serial port to settle */
	/* So we can actually see the output on the terminal */
	delay(0x3f0000);

	printk("\r\nWaiting for serial port to be ready (press any key)\r\n");
	uart_getc();

	uart_enable_interrupts();


	/* Clear screen */
	printk("\n\r\033[2J\n\r\n\r");

	/* Print boot message */
	printk("\033[0;41m   \033[42m \033[44m   \033[42m \033[44m   \033[0m VMW OS\r\n");
	printk(" \033[0;41m \033[42m   \033[44m \033[42m   \033[44m \033[0m  Version 0.%d\r\n\r\n",VERSION);

	/* Print hardware version */
	printk("Hardware version: %x ",r1);
	if (r1==0xc42) printk("(Raspberry Pi)");
	else printk("(Unknown Hardware)");
	printk("\r\n");

	printk("Detected Model ");
	switch(hardware_type) {
		case RPI_MODEL_A:	printk("A"); break;
		case RPI_MODEL_APLUS:	printk("A+"); break;
		case RPI_MODEL_B:	printk("B"); break;
		case RPI_MODEL_BPLUS:	printk("B+"); break;
		case RPI_MODEL_B2:	printk("B2"); break;
		case RPI_COMPUTE_NODE:	printk("Compute Node"); break;
		default:		printk("Unknown %x",hardware_type); break;
	}
	printk("\r\n");

	/* Print ATAGS */
	atags_dump(atags);

	printk("\r\n");

	/* Get amount of RAM from ATAGs */
	memory_total=atag_info.ramsize;

	/* Init memory subsystem */
	memory_init(memory_total,memory_kernel);

	/* Init the MMU */
	printk("Initializing MMU and caches\r\n");
	//enable_mmu(0, memory_total);
	//l1_data_cache_clear();
	//l1_data_cache_enable();
	l1_instruction_cache_enable();




	/* Memory Benchmark */
#if 1
	{
		int i;
		uint32_t before,after;

		before=ticks_since_boot();

		for(i=0;i<16;i++) {
			memset(benchmark,0,BENCH_SIZE);
		}
		after=ticks_since_boot();

		printk("MEMSPEED: %d MB took %d ticks %dkB/s\r\n",
			16, (after-before),
			div32(16*1024,(((after-before)*1000)/64)));
	}
#endif

	/* Load the idle thread */
	idle_process=load_process("idle",PROCESS_FROM_RAM,
				(char *)&idle_task,8,4096);

	init_process=load_process("shell",PROCESS_FROM_DISK,
				NULL,0,8192);

	load_process("printa",PROCESS_FROM_DISK,
				NULL,0,8192);

	load_process("printb",PROCESS_FROM_DISK,
				NULL,0,8192);


	/* Enter our "init" process*/
	printk("\r\nEntering userspace by starting process %d!\r\n",
		init_process);

	process[idle_process].ready=1;
	process[init_process].ready=1;

	userspace_started=1;

	/* run init and restore stack as we won't return */
	run_process(init_process,0x8000);

	/* we should never get here */

	while(1) {

		/* Loop Forever */
		/* Should probably execute a wfi instruction */
	}

}
Example #22
0
//receive the time from QOMET and do actions
//ActionRecord array must be orderred
void do_actions(int accept_sd,ActionRecord *ac,int ac_count, action_mapping *am, id_ip *p)
{
	printf("\n in do action\n");
	float buffer ;
        buffer =0;
	int index_ac =0;
	int i =0;
	int rc;
	char *argv[4];
	argv[0] = "/usr/local/bin/bash";
	for(i=0;i<ac_count;i++)
		PrintAction(&ac[i]);
	while(1)
	{
		/* Receive a message from the client */
		//printf("\nI am waiting client(s) to send message(s) to me...\n");
		rc = recv(accept_sd,&buffer, sizeof(float), 0);
		//printf("\n number byte rec %d\n",rc);
		//printf("\n time %f\n",buffer);
		if(rc <= 0)
		{	
			perror("TCP_QO_ACTION server - recv() error");
			goto bad_do_action;
		}
		else
		{
				//if there is any action in this time, run it
				if(index_ac > ac_count)
					continue;
				while(ac[index_ac].time == buffer)
				{		
					printf("\ncall action\n"); 	
					printf("\n time %f\n",buffer);
	  				PrintAction(&ac[index_ac]);
	    			       //create a process for start an action
					process *pr;
					//printf("\ncreate a process");
					pr = create_process();
					if(pr == NULL)
					{
						printf("\nerror in create a process");
						return;
					}
					pr->expire_time = ac[index_ac].time + ac[index_ac].duration;
					//build argument for action
								
					argv[1] =  look_up_action_file(am,ac[index_ac].id);
					if(argv[1] == NULL)
					{
						printf("\n cannot find action file of action id:%d",ac[index_ac].id);
						//goto bad_do_action;
						index_ac++;	
						continue;
					}
					printf("\naction file:%s",argv[1]);

					if (ac[index_ac].target != -1)
					{
						argv[2] = (char *)look_up_ip(p,ac[index_ac].target);
						if(argv[2] == NULL)
						{
							printf("\n cannot find ip adress of target id:%d",ac[index_ac].target);
							index_ac++;	
						       continue;
						}
						argv[3] =(char*)0;
					}
					else
						argv[2] = (char*)0;
					
					run_process(pr,main_p->pgid,argv);	
					index_ac++;	

					if(index_ac > ac_count)
						break;
					//printf("\nindex :%d and ac[index_ac].time:%f",index_ac,ac[index_ac].time);					     					
					//add the process into process list
					add_process_to_list(pr);
					//print_processes();	
				
				}
				//if there is any processes that needs close because of deadline, close them
				if(main_p->first_child_process != NULL)
					while(find_process(buffer)!=NULL)
					{
						printf("\nkill a process with time:%d\n",buffer);
						kill_a_process(buffer);
					}

		}
		//if the value is -1 , the program will be terminated
		if(buffer == (float)-1)
		{
			index_ac =0;
		}


	}		
	
bad_do_action:
	return ;
}
Example #23
0
void kernel_main(uint32_t r0, uint32_t r1, uint32_t *atags,
		uint32_t memory_kernel) {

	unsigned int memory_total;
	int init_process,idle_process;
	struct atag_info_t atag_info;
	uint32_t framebuffer_width=800,framebuffer_height=600;
	uint32_t temperature;

	(void) r0;	/* Ignore boot method */

	/* Initialize Software Structures */
	processes_init();

	/* Detect Hardware */
	atags_detect(atags,&atag_info);
	hardware_type=atag_info.hardware_type;

	/* Initialize Hardware */

	/* Serial console is most important so do that first */
	uart_init();

	/* Enable HW random number generator */
	bcm2835_rng_init();

	/* Enable Interrupts */
	enable_interrupts();

	/************************/
	/* Boot message!	*/
	/************************/

	printk("\nBooting VMWos...\n");

	/**************************/
	/* Device Drivers	  */
	/**************************/

	/* Set up ACT LED */
	led_init();

	/* Set up timer */
	timer_init();

	/* Set up keyboard */
	ps2_keyboard_init();

	/* Enable the Framebuffer */
	if (atag_info.framebuffer_x!=0) {
		framebuffer_width=atag_info.framebuffer_x;
	}
	if (atag_info.framebuffer_y!=0) {
		framebuffer_height=atag_info.framebuffer_y;
	}

	framebuffer_init(framebuffer_width,framebuffer_height,24);
	framebuffer_console_init();

	/* Delay to allow time for serial port to settle */
	/* So we can actually see the output on the terminal */
	delay(0x3f0000);

	printk("\nWaiting for serial port to be ready (press any key)\n");
	uart_getc();

	uart_enable_interrupts();


	/* Clear screen */
	printk("\n\033[2J\n\n");

	/* Print boot message */
	printk("\033[0;41m   \033[42m \033[44m   \033[42m \033[44m   \033[0m VMW OS\n");
	printk(" \033[0;41m \033[42m   \033[44m \033[42m   \033[44m \033[0m  Version 0.%d\n\n",VERSION);

	/* Print hardware version */
	printk("Hardware version: %x ",r1);
	if (r1==0xc42) printk("(Raspberry Pi)");
	else printk("(Unknown Hardware)");
	printk("\n");

	printk("Detected Model ");
	switch(hardware_type) {
		case RPI_MODEL_A:	printk("A"); break;
		case RPI_MODEL_APLUS:	printk("A+"); break;
		case RPI_MODEL_B:	printk("B"); break;
		case RPI_MODEL_BPLUS:	printk("B+"); break;
		case RPI_MODEL_B2:	printk("B2"); break;
		case RPI_COMPUTE_NODE:	printk("Compute Node"); break;
		default:		printk("Unknown %x",hardware_type); break;
	}
	printk("\n");

	/* Check temperature */
	temperature=thermal_read();
	printk("CPU Temperature: %dC, %dF\n",
		temperature/1000,
		((temperature*9)/5000)+32);

	/* Print ATAGS */
	atags_dump(atags);

	printk("\n");

	/* Get amount of RAM from ATAGs */
	memory_total=atag_info.ramsize;

	/* Init memory subsystem */
	memory_init(memory_total,memory_kernel);

	/* Start HW Perf Counters */
	arm1176_init_pmu();

#if 0
	asm("nop");
	asm("nop");
	asm("nop");
	asm("nop");

	asm("nop");
	asm("nop");
	asm("nop");
	asm("nop");

	asm("nop");
	asm("nop");
	asm("nop");
	asm("nop");

	asm("nop");

//	printk("Heisenbug!\n");
#endif

	/* Setup Memory Hierarchy */
#if 1
	memset_benchmark(memory_total);
#else
	/* Enable L1 i-cache */
	printk("Enabling L1 icache\n");
	enable_l1_dcache();

	/* Enable branch predictor */
	printk("Enabling branch predictor\n");

	/* Enable L1 d-cache */
	printk("Enabling MMU with 1:1 Virt/Phys page mapping\n");
	enable_mmu(0,memory_total);
	printk("Enabling L1 dcache\n");
	enable_l1_dcache();
#endif

	/* Init the file descriptor table */
	fd_table_init();

	/* Initialize the ramdisk */
	ramdisk_init(initrd_image,sizeof(initrd_image));

	/* Mount the ramdisk */
	mount("/dev/ramdisk","/","romfs",0,NULL);

	/* Load the idle thread */
	idle_process=load_process("idle",PROCESS_FROM_RAM,
				(char *)&idle_task,8,4096);

	init_process=load_process("shell",PROCESS_FROM_DISK,
				NULL,0,8192);

	load_process("printa",PROCESS_FROM_DISK,
				NULL,0,8192);

	load_process("printb",PROCESS_FROM_DISK,
				NULL,0,8192);


	/* Enter our "init" process*/
	printk("\nEntering userspace by starting process %d!\n",
		init_process);

	process[idle_process].ready=1;
	process[init_process].ready=1;

	userspace_started=1;

	/* run init and restore stack as we won't return */
	run_process(init_process,0x8000);

	/* we should never get here */

	while(1) {

		/* Loop Forever */
		/* Should probably execute a wfi instruction */
	}

}
Example #24
0
 windows_process(const std::filesystem::path& filename, const std::vector<std::string>& argv,
                 const std::vector<std::string>& envp, std::system_error& ec)
 {
    ec = run_process(filename, argv, envp);
 }