main(int argc, char *argv[])
{
    int TestcaseId=0;
    switch(argc)
    {
      case 2:
           TestcaseId=dstrtol(argv[1],NULL,10);
           Printf("\nTesting case %d\n",TestcaseId);
           break;
      default:
           Printf("\nUsage: ");
           Printf(argv[0]);
           Printf(" [case id]\n\n");
           exit();
    }

    switch(TestcaseId)
    {
        case 1: process_create("userprog1.dlx.obj",NULL);
                break;
        case 2: process_create("userprog2.dlx.obj",NULL);
                break;
        default:
                Printf("Test case %d not supported\n", TestcaseId);
                break;
    }
}
Example #2
0
int main (void) {
    WDTCTL = WDTPW + WDTHOLD;
    P1DIR = 0x03;
    P1OUT = 0x00;

    realtime_t_init();
    time_init();

    if (process_create (p1,10) < 0) {
        return -1;
    }
    if (process_create (p2,10) < 0) {
        return -1;
    }

    //rt processes
    start.sec = 0;
    work.sec=1;
    deadline.msec=100;
    if (process_rt_create (rt_p1,10, start, work, deadline) < 0) {
        return -1;
    }
    start.sec = 0;
    work.sec=1;
    deadline.msec=90;
    if (process_rt_create (rt_p2,10, start, work, deadline) < 0) {
        return -1;
    }

    process_start();
    P1OUT= 0x02;
    while(1);
    return 0;
}
Example #3
0
void user_process_init(void){
	//unsigned char err=0;
	UINT32 *stkA, *stkB;
	process_control_block_t *ret;

	stkA=(unsigned long *)os_mem_alloc(PROC_STACK_SIZE);
	stkB=(unsigned long *)os_mem_alloc(PROC_STACK_SIZE);

	

	process_create(procIdA, 1, ret, user_process_a, stkA);
	process_create(procIdB, 2, ret, user_process_b, stkB);
	//current=idle->next;
}
Example #4
0
int main(int argc, char *argv[]) {
	int id = my_id();
	char buf[8];

	sprintf(buf, "+%d\n", id);
	kprint(buf);

	process_create(PROGRAM);
	process_create(PROGRAM);

	sprintf(buf, "-%d\n", id);
	kprint(buf);

	return 0;
}
Example #5
0
File: ottos.c Project: ottos/ottos
void process_exit_test() {

  process_table_init();
  process_create(1, (int) serial_test_write_exit_1);
  process_create(1, (int) serial_test_write_exit_2);
  process_create(1, (int) toggle_led1);

  devices_init();

  irq_init();
  timer_init();
  irq_register_context_switch();
  irq_enable();

  kernel_to_user_mode();
}
Example #6
0
File: kthread.c Project: Nakrez/zOS
void kthread_initialize(void)
{
    kproc = process_create(PROCESS_TYPE_KERNEL, 0, 0, NULL);

    if (!kproc)
        kernel_panic("Fail to initialize kthreads");
}
Example #7
0
File: sosh.c Project: gz/aos10
static int exec(int argc, char **argv) {
	pid_t pid;
	int r;
	int bg = 0;

	if (argc < 2 || (argc > 2 && argv[2][0] != '&')) {
		printf("Usage: exec filename [&]\n");
		return 1;
	}

	if ((argc > 2) && (argv[2][0] == '&')) {
		bg = 1;
	}

	if (bg == 0) {
		r = close(in);
		assert(r == 0);
	}

	pid = process_create(argv[1]);
	if (pid >= 0) {
		printf("Child pid=%d\n", pid);
		if (bg == 0) {
			process_wait(pid);
		}
	} else {
		printf("Failed!\n");
	}
	if (bg == 0) {
		in = open("console", FM_READ);
		assert(in>=0);
	}
	return 0;
}
Example #8
0
int main(void){
	WDTCTL = WDTPW + WDTHOLD;
	P1DIR = 0x03;
	P1OUT = 0x00;

	
	if (process_rt_create(rtp1,20,50,10,10000) < 0) 
	{
	 	return -1;
	}
	if (process_rt_create(rtp2,20,2000,10,1000) < 0) 
	{
	 	return -1;
	}


	if (process_create (p1,10) < 0) {
	 	return -1;
	}
	
	process_start();
	//P1OUT= 0x02;
	while(1){};
	return 0;	
}
Example #9
0
void process_init()
{
	init_process_pid = process_create((int)(init_process),0,8,1);

	vid_puts("Initial process created: pid ");
	vid_putd(init_process_pid);
	vid_putc('\n');
}
Example #10
0
File: ottos.c Project: ottos/ottos
void serial_test_calc() {

  process_table_init();
  process_create(1, (int) toggle_led1);
  process_create(1, (int) serial_test_calculator);

  devices_init();

  irq_init();

  timer_init();

  irq_register_context_switch();

  irq_enable();
  kernel_to_user_mode();
}
Example #11
0
static void run_boot_hooks(struct boot_task *task)
{
	struct dirent **hooks;
	int i, n;

	n = scandir(boot_hook_dir, &hooks, hook_filter, hook_cmp);
	if (n < 1)
		return;

	update_status(task->status_fn, task->status_arg, BOOT_STATUS_INFO,
			_("running boot hooks"));

	boot_hook_setenv(task);

	for (i = 0; i < n; i++) {
		const char *argv[2] = { NULL, NULL };
		struct process *process;
		char *path;
		int rc;

		path = join_paths(task, boot_hook_dir, hooks[i]->d_name);

		if (access(path, X_OK)) {
			talloc_free(path);
			continue;
		}

		process = process_create(task);

		argv[0] = path;
		process->path = path;
		process->argv = argv;
		process->keep_stdout = true;

		pb_log("running boot hook %s\n", hooks[i]->d_name);

		rc = process_run_sync(process);
		if (rc) {
			pb_log("boot hook exec failed!\n");

		} else if (WIFEXITED(process->exit_status) &&
			   WEXITSTATUS(process->exit_status)
				== BOOT_HOOK_EXIT_UPDATE) {
			/* if the hook returned with BOOT_HOOK_EXIT_UPDATE,
			 * then we process stdout to look for updated params
			 */
			boot_hook_update(task, hooks[i]->d_name,
					process->stdout_buf);
			boot_hook_setenv(task);
		}

		process_release(process);
		talloc_free(path);
	}

	free(hooks);
}
Example #12
0
// The kernel main function. Initialize everything and start the kernel
// debugger. The two arguments are the physical address of the Multiboot info
// structure and the bootloader magic number respectively.
void
init()
{
    int r;

    // Initialize the console first to print messages during the initialization
    cons_init();

    kprintf("Argentum Operating System\n");

    arch_init();

    kmem_cache_init();
    kmem_cache_sizes_init();

    vm_init();
    process_init();
    thread_init();
    ipc_init();
    scheduler_init();
    sync_init();
    clock_init();

    if ((r = process_create_system(system_main, NULL)) < 0)
        kprintf("Cannot create system process: %s\n", strerror(-r));

    if (module_start) {
        Boot_image *image = (Boot_image *) module_start;
    
        if(image->magic != 0x12345678)
            panic("invalid bootimage");

        for (unsigned i = 0; i < image->length; i++) {
            uint8_t *binary = (uint8_t *) image + image->headers[i].offset;
            size_t size = image->headers[i].length;

            if (binary < module_start || binary >= module_end)
                panic("invalid bootimage");
            if ((binary + size) <= module_start || (binary + size) > module_end)
                panic("invalid bootimage");

            r = process_create((uint8_t *) image + image->headers[i].offset,
                    image->headers[i].length, PROCESS_TYPE_USER, NULL);
            if (r < 0)
                panic("Cannot create process: %s", strerror(-r));
        }

    }

    scheduler_start();

    for (;;) {
        kdb_main(NULL);
    }
}
Example #13
0
static result_t start_child(pid_t * const pid, const int master_fd, const int slave_fd, const options_t * const options)
{
    if (!process_create(pid))
        fail();

    if (*pid == 0) {
        close(master_fd);
        run_child(slave_fd, options);
    }

    succeed();
}
Example #14
0
static result_t start_relay(pid_t * const pid, const int master_fd, const int slave_fd)
{
    if (!process_create(pid))
        fail();

    if (*pid == 0) {
        close(slave_fd);
        run_relay(master_fd);
    }

    succeed();
}
Example #15
0
static inline void app_init(APP* app)
{
    process_create(&__STM32_CORE);

    app_disable_JTAG();

    gpio_enable_pin(C8, GPIO_MODE_OUT);
    gpio_set_pin(C8);

    app_setup_dbg();
//    printf("App init\n");
}
Example #16
0
File: ottos.c Project: ottos/ottos
void timer_test() {


  process_table_init();

  process_create(1, (int)toggle_led1);
  process_create(1, (int)toggle_led2);

  devices_init();

  irq_init();

  timer_init();
  //timer_add_handler(toggle_led_1, 5000);
  //timer_add_handler(toggle_led_2, 10000);

  irq_register_context_switch();

  irq_enable();
  kernel_to_user_mode();
}
Example #17
0
HANDLE tcpip_create(unsigned int process_size, unsigned int priority, unsigned int eth_handle)
{
    char name[24];
    REX rex;
    sprintf(name, "TCP/IP %#x stack", eth_handle);
    rex.name = name;
    rex.size = process_size;
    rex.priority = priority;
    rex.flags = PROCESS_FLAGS_ACTIVE;
    rex.fn = tcpips_main;
    return process_create(&rex);
}
Example #18
0
static result_t start_timer(pid_t * const pid, const int master_fd, const int slave_fd, const unsigned int n)
{
    if (!process_create(pid))
        fail();

    if (*pid == 0) {
        close(master_fd);
        close(slave_fd);
        run_timer(n);
    }

    succeed();
}
Example #19
0
void proc_pong_init(os_uint8 priority)
{
    struct process *proc_pong = process_create(proc_pong_entry, priority);
    gl_proc_pong_pid = proc_pong->_pid;

    proc_pong->wakeup_init_callback = pong_wakup_callback;
    proc_pong->sleep_cleanup_callback = pong_sleep_callback;

    gl_timeout_timer = os_timer_alloc();
    haddock_assert(gl_timeout_timer);

    os_ipc_set_signal(this->_pid, SIGNAL_PONG_INITED);
}
Example #20
0
File: ottos.c Project: ottos/ottos
void serial_test() {



   process_table_init();

//    process_create(1, (int)serial_test_test_yield);
//    process_create(1, (int)toggle_led1_yield);
//    process_create(1, (int)toggle_led2_yield);


   //process_create(1, (int) led1_on);
   //process_create(1, (int) led1_off);
   process_create(1, (int) toggle_led1);
   process_create(1, (int) toggle_led2);
   //process_create(1, (int) serial_test_write_1);
   //process_create(1, (int) serial_test_write_2);
   //process_create(1, (int) serial_test_write_3);
   //process_create(1, (int) serial_test_write_4);
   //process_create(1, (int) serial_test_write_5);
   process_create(1, (int) serial_test_calculator);

    devices_init();
    serial_test_create();

    irq_init();

    timer_init();

    irq_register_context_switch();

    irq_enable();
    kernel_to_user_mode();
//    sys_yield();

//    serial_test_test();
}
Example #21
0
File: main.c Project: nielh/dragon
void init_thread(void* param1, void* param2)
{
    ahci_init();
    //ahci_test();
    fat_init();
    pe_init();

    //LoadSysModule("sys/test.sys");
    //for(int i=0; i <16; i++)
	process_create("sys/init.exe");

    while(1)
    {
        mdelay(2000);
        printk("1");
    }
}
Example #22
0
File: main.c Project: cfallin/speck
int kernel_main()
{
    arch_init();
    mm_init();
    process_init();
    kmod_init();

    vid_puts("\nspeck/" SPECK_ARCH " version " SPECK_VERSION "\n");
    vid_puts("  Built " SPECK_BUILD_DATE " by " SPECK_BUILD_USER "@"
             SPECK_BUILD_HOST "\n");

    vid_puts("\nDone initializing.\n");

    // TODO: one idle process per processor
    process_create((int)idle_process,0,0,1);

    // enable interrupts
    int_enable(INT_ENABLE_FLAGS_INIT);

    while(1);
}
int main(int argc, char **argv)
{
	struct waitset *waitset;
	struct process *process;
	const char *child_argv[3];
	void *ctx;

	if (argc == 2 && !strcmp(argv[1], "child"))
		return do_child();

	ctx = talloc_new(NULL);

	waitset = waitset_create(ctx);

	process_init(ctx, waitset, false);

	child_argv[0] = argv[0];
	child_argv[1] = "child";
	child_argv[2] = NULL;

	process = process_create(ctx);
	process->path = child_argv[0];
	process->argv = child_argv;
	process->keep_stdout = true;
	process->add_stderr = true;

	process_run_sync(process);

	assert(WIFEXITED(process->exit_status));
	assert(WEXITSTATUS(process->exit_status) == 42);

	assert(process->stdout_len == strlen("forty two\n"));
	assert(!memcmp(process->stdout_buf, "forty two\n",
				process->stdout_len));

	talloc_free(ctx);

	return EXIT_SUCCESS;
}
Example #24
0
int page_replacement_init( FILE *fp, int mech )
{
  int i;
  int err;
  int pid;
  unsigned int vaddr;

  fseek( fp, 0, SEEK_SET );  /* start at beginning */

  /* initialize process table, frame table, and TLB */
  memset( processes, 0, sizeof(task_t) * MAX_PROCESSES );
  memset( physical_mem, 0, sizeof(frame_t) * PHYSICAL_FRAMES );
  tlb_flush( );
  current_pt = 0;

  /* initialize frames with numbers */
  for ( i = 0; i < PHYSICAL_FRAMES ; i++ ) {
    physical_mem[i].number = i;
  }

  /* create processes, including initial page table */
  while ( fscanf( fp, "%d %x\n", &pid, &vaddr ) == 2 ) {

    if ( processes[pid].pagetable == NULL ) {
      err = process_create( pid );

      if ( err )
	return -1;
    }
  }

  fseek( fp, 0, SEEK_SET );  /* reset at beginning */

  /* init replacement specific data */
  pt_replace_init[mech]( fp );

  return 0;
}
Example #25
0
/*--------------------------------------------*/
int main(void) {	
	 
	LED_Initialize();

    /* Create processes */ 
    if (process_create(pNRT, NRT_STACK) < 0) { return -1; }
    if (process_rt_create(pRT1, RT_STACK, &t_pRT1, &t_10sec, &t_1msec) < 0) { return -1; } 
   
    /* Launch concurrent execution */
	process_start();

  LED_Off();
  while(process_deadline_miss>0) {
		LEDGreen_On();
		shortDelay();
		LED_Off();
		shortDelay();
		process_deadline_miss--;
	}
	
	/* Hang out in infinite loop (so we can inspect variables if we want) */ 
	while (1);
	return 0;
}
main (int argc, char *argv[])
{
  int number, i, j, offset;
  uint32 handle;
  sem_t spage; sem_t ipc_sem;
  char num_str[10], spage_str[10], handle_str[10], ipc_str[10];
  DB * db;

  switch(argc)
  {
    case 2:  
      handle = shmget();
      db = (DB *)shmat(handle);
      if(db == NULL)
        {
          Printf("Could not map the shared page to virtual address, exiting..\n");
          exit();
        }
      db->end = 0;              // Initially the end flag is 0

      spage = sem_create(0);
      ipc_sem = cond_create(0);
      ditoa(handle, handle_str);
      ditoa(spage, spage_str);

      number = dstrtol(argv[1], NULL, 10);
      Printf("Setting number = %d\n", number);
  
      for(i = 0; i < number; i++)
      {
        //Printf("Current process : %d\n", i);
        ditoa(i, num_str);
        process_create("userprog4.dlx.obj", 1 + i, 0, num_str, 
                       spage_str, handle_str,
                       NULL);     // different p_nice for child process
      }

      sem_wait(spage);            // wait for the children to reach 200
      db->end = 1;                // terminate children processes

      break;
    case 4:
      offset = dstrtol(argv[1], NULL, 10);
      spage = dstrtol(argv[2], NULL, 10);
      //ipc_sem = dstrtol(argv[3], NULL, 10);
      handle = dstrtol(argv[3], NULL, 10);
      db = (DB *)shmat(handle);
      if(db == NULL)
        {
          Printf("Could not map the virtual address to the memory, exiting...\n");
          exit();
        }
        sleep(100);

      for(i = 0; !db->end; i ++)
      {
        for(j = 0; j < 50000; j++)
        {
        //#ifdef sleep
          if(offset == 1 && j % 1000 == 0 && j <= 30000)
            sleep(1);
      
          //# endif

          #ifdef dynamic
            if(offset == 0 && j % 500 == 0 && j <= 3000)
              cond_wait(ipc_sem);

            if(offset == 1 && j % 600 == 0)
              cond_signal(ipc_sem);
          # endif
        }     //waste some time
        Printf("%c%d\n",'A'+offset, i);
        if(i > 200) sem_signal(spage);  //signal end
      }

      Printf("***** Process %d reached %d *****\n", getpid(), i);

      /*
        The expected output for the following run

        dlxsim -x os.dlx.obj -a -u userprog4.dlx.obj 2

        is that the first process reaches an "i" which is roughly half
        of the "i" reached by the second process. This implies the
        second process gets scheduled for twice the time of the first
        process.

        Our output is
        ***** Process 29 reached 203 *****
        ***** Process 30 reached 101 *****
        
        Your output may differ a little bit due to randomness.
      */

      break;
    default:
      Printf("Usage: ");
      Printf(argv[0]);
      Printf(" number\n");
      Printf("argc = %d\n", argc);
      exit();
  }
}
void main (int argc, char *argv[])
{
  int numprocs = 5;               // Used to store number of processes to create
  int i;                          // Loop index variable
  phil *p;               // Used to get address of shared memory page
  uint32 h_mem;                   // Used to hold handle to shared memory page
  sem_t s_procs_completed;        // Semaphore used to wait until all spawned processes have completed
  char h_mem_str[10];             // Used as command-line argument to pass mem_handle to new processes
  char s_procs_completed_str[10]; // Used as command-line argument to pass page_mapped handle to new processes
  char i_str[2];
  if (argc != 1) {
    Printf("Usage: ");
    Printf(argv[0]);
    Printf("\n");
    Exit();
  }

  Printf("Creating %d processes\n", numprocs);

  // Allocate space for a shared memory page, which is exactly 64KB
  // Note that it doesn't matter how much memory we actually need: we 
  // always get 64KB
  if ((h_mem = shmget()) == 0) {
    Printf("ERROR: could not allocate shared memory page in "); Printf(argv[0]); Printf(", exiting...\n");
    Exit();
  }

  // Map shared memory page into this process's memory space
  if ((p = (phil *)shmat(h_mem)) == NULL) {
    Printf("Could not map the shared page to virtual address in "); Printf(argv[0]); Printf(", exiting..\n");
    Exit();
  }

  // Put some values in the shared memory, to be read by other processes
  for (i = 0; i < 5; i++){
	  p->state[i] = THINKING;
	  p->wait_locks[i] = lock_create();
	  p->self[i] = cond_create(p->wait_locks[i]);
	  p->eaten[i] = 0;

  }



  // Create semaphore to not exit this process until all other processes 
  // have signalled that they are complete.  To do this, we will initialize
  // the semaphore to (-1) * (number of signals), where "number of signals"
  // should be equal to the number of processes we're spawning - 1.  Once 
  // each of the processes has signaled, the semaphore should be back to
  // zero and the final sem_wait below will return.
  if ((s_procs_completed = sem_create(-(numprocs-1))) == SYNC_FAIL) {
    Printf("Bad sem_create in "); Printf(argv[0]); Printf("\n");
    Exit();
  }

  // Setup the command-line arguments for the new process.  We're going to
  // pass the handles to the shared memory page and the semaphore as strings
  // on the command line, so we must first convert them from ints to strings.
  ditoa(h_mem, h_mem_str);
  ditoa(s_procs_completed, s_procs_completed_str);

  // Now we can create the processes.  Note that you MUST end your call to
  // process_create with a NULL argument so that the operating system
  // knows how many arguments you are sending.
  for(i=0; i<numprocs; i++) {
	  ditoa(i, i_str);
    process_create(FILENAME_TO_RUN, h_mem_str, s_procs_completed_str, i_str , NULL);
    Printf("Process %d created\n", i);
  }


  // And finally, wait until all spawned processes have finished.
  if (sem_wait(s_procs_completed) != SYNC_SUCCESS) {
    Printf("Bad semaphore s_procs_completed (%d) in ", s_procs_completed); Printf(argv[0]); Printf("\n");
    Exit();
  }
  for (i = 0; i < numprocs; i++){
	  if (p->eaten[i] == 1){
		  Printf("Philosopher %d has eaten\n", i);
	  }else{
		  Printf("Philosopher %d DID NOT eat\n", i);
	  }
  }

  Printf("All other processes completed, exiting main process.\n");
}
Example #28
0
void kernel_start_core() {
  // create the core service.
  if (multiboot_data.coresrv_module == -1) {
    log_error("kernel", "start_core", "Coresrv module not found");
  }
  module_t *core_mod = multiboot_data.modules + multiboot_data.coresrv_module;
  Elf32_Ehdr *elf = (Elf32_Ehdr*)kernel_p2v(core_mod->mod_start);
  // each ELF header may end up as a memory block.
  // we also need one for initrd, stack, and VGA each.
  struct process_descriptor* pd = process_alloc_descriptor(elf->e_phnum + 3);
  pd->vmem_base = 0;
  pd->vmem_size = USERMODE_SIZE;
  service_relocate(pd);
  pd->entry_point = pd->vmem_base + (uintptr_t)elf->e_entry;

  // create memory map description of the binary.
  uintptr_t vmem_top = 0;
  struct process_memory *pm_local = 0; // thread local section.
  for (unsigned i = 0; i < elf->e_phnum; ++i) {
    Elf32_Phdr *prog_header = (Elf32_Phdr*)
      ((uintptr_t)elf + elf->e_phoff + i * elf->e_phentsize);
    if (prog_header->p_type != PT_LOAD) continue;
    struct process_memory *pm = pd->memory_maps + (pd->n_maps++);

    // check flags:
    pm->flags = 0;
    if ((prog_header->p_flags & PF_X) == 0) pm->flags |= PAGE_NOEXECUTE;
    if ((prog_header->p_flags & PF_W) != 0) pm->flags |= PAGE_WRITEABLE;

    // virtual address range where pages will be moved into:
    pm->v_base = pd->vmem_base + (uintptr_t)prog_header->p_vaddr;
    pm->v_size = (size_t)prog_header->p_memsz;
    if (pm->v_base % TABLE_SIZE) { // each block must be at table boundary!
      log_error("kernel", "start_core", "Unaligned ELF segment");
    }

    // actual memory address range to move:
    pm->m_base = kernel_p2v(core_mod->mod_start + prog_header->p_offset);
    pm->m_size = (size_t)prog_header->p_filesz;

    // thread local section requires special care:
    if (pm->v_base == pd->vmem_base + THREAD_LOCAL_BASE) {
      pm->flags = 0;
      pm_local = pm;
    } else {
      uintptr_t v_top = pm->v_base + pm->v_size;
      if (v_top > vmem_top) vmem_top = v_top;
    }
  }

  // add a stack.
  uintptr_t stack = page_clear(lomem_alloc_4k());
  size_t stack_size = PAGE_SIZE;
  uintptr_t stack_top = stack + stack_size;
  if (!stack) log_error("kernel", "start_core", "Out of memory");
  {
    struct process_memory *pm = pd->memory_maps + (pd->n_maps++);
    pm->flags = PAGE_WRITEABLE | PAGE_NOEXECUTE;
    pm->m_base = kernel_p2v(stack);
    pm->m_size = -(intptr_t)stack_size;
    pm->v_base = page_table_round_up(vmem_top);
    pm->v_size = USER_STACK_SIZE;
    uintptr_t v_top = pm->v_base + pm->v_size;
    if (v_top > vmem_top) vmem_top = v_top;
    pd->stack_bottom = pm->v_base;
    pd->stack_top = pm->v_base + pm->v_size;
  }

  // top of stack is used for libc & coresrv initialization data.
  pd->stack_reserved = sizeof(struct libc_init) + sizeof(struct coresrv_init);
  if (pd->stack_reserved > stack_size) {
    log_error("kernel", "start_core", "Stack too small");
  }
  struct coresrv_init *coresrv = 
    (struct coresrv_init *)kernel_p2v(stack_top - sizeof(struct coresrv_init));
  struct libc_init *libc = (struct libc_init *)kernel_p2v(stack_top - pd->stack_reserved);
  libc->data = (void*)(pd->stack_top - sizeof(struct coresrv_init));
  pd->libc = libc;

  // special thread locals init memory.
  if (pm_local) {
    pm_local->v_base = page_table_round_up(vmem_top);
    uintptr_t v_top = pm_local->v_base + pm_local->v_size;
    if (v_top > vmem_top) vmem_top = v_top;
    libc->threadlocal_init = (void*)pm_local->v_base;
    libc->threadlocal_size = pm_local->v_size;
  }

  // add VGA.
  {
    struct process_memory *pm = pd->memory_maps + (pd->n_maps++);
    pm->flags = PAGE_WRITETHROUGH | PAGE_WRITEABLE | PAGE_NOEXECUTE;
    pm->m_base = vga.fb;
    pm->m_size = vga.fb_size;
    pm->v_base = page_table_round_up(vmem_top);
    pm->v_size = pm->m_size;
    uintptr_t v_top = pm->v_base + pm->v_size;
    if (v_top > vmem_top) vmem_top = v_top;
    coresrv->vga_base = (void*)pm->v_base;
    coresrv->vga_size = pm->v_size;
  }

  // add the initrd, if available.
  if (multiboot_data.initrd_module != -1) {
    module_t *initrd_mod = multiboot_data.modules + multiboot_data.initrd_module;
    struct process_memory *pm = pd->memory_maps + (pd->n_maps++);
    pm->flags = PAGE_WRITEABLE | PAGE_NOEXECUTE;
    pm->m_base = kernel_p2v(initrd_mod->mod_start);
    pm->m_size = initrd_mod->mod_end - initrd_mod->mod_start;
    pm->v_base = page_table_round_up(vmem_top);
    pm->v_size = pm->m_size;
    uintptr_t v_top = pm->v_base + pm->v_size;
    if (v_top > vmem_top) vmem_top = v_top;
    coresrv->initrd_base = (void*)pm->v_base;
    coresrv->initrd_size = pm->v_size;
  }

  // make it happen!
  struct process *core = process_create(pd);
  (void)core;
}
Example #29
0
void
rtp_callback_proc(struct rtp *s, rtp_event *e)
{
        struct s_session *sp;
	int		  i;

	assert(s != NULL);
	assert(e != NULL);

        sp = get_session(s);
        if (sp == NULL) {
                /* Should only happen when SOURCE_CREATED is generated in */
                /* rtp_init.                                              */
                debug_msg("Could not find session (0x%08lx)\n", (unsigned long)s);
                return;
        }

	if (sp->logger != NULL) {
		rtpdump_callback(sp->logger, e);
	}

	/* If we're a transcoder, add this source as a CSRC on the other session */
	if (sp->other_session != NULL) {
		for (i = 0; i < sp->other_session->rtp_session_count; i++) {
			rtp_add_csrc(sp->other_session->rtp_session[i], e->ssrc);
		}
	}

	switch (e->type) {
	case RX_RTP:
                process_rtp_data(sp, e->ssrc, (rtp_packet*)e->data);
                break;
	case RX_RTCP_START:
		break;
	case RX_RTCP_FINISH:
		break;
	case RX_SR:
		break;
	case RX_RR:
                process_rr(sp, e);
		break;
	case RX_RR_EMPTY:
		break;
	case RX_SDES:
                process_sdes(sp, e->ssrc, (rtcp_sdes_item*)e->data);
		break;
        case RX_APP:
                debug_msg("Received application specific report from %08x - and processing it - possible siteid packet\n", e->ssrc);
	        process_app(sp, e->ssrc, (rtcp_app*)e->data);
		xfree(e->data);
                break;
	case RX_BYE:
	case SOURCE_DELETED:
                process_delete(sp, e);
		if (sp->other_session != NULL) {
			for (i = 0; i < sp->other_session->rtp_session_count; i++) {
				rtp_del_csrc(sp->other_session->rtp_session[i], e->ssrc);
			}
		}
		break;
	case SOURCE_CREATED:
		process_create(sp, e->ssrc);
		break;
	case RR_TIMEOUT:
                process_rr_timeout(sp, e->ssrc, (rtcp_rr*)e->data);
		break;
	default:
		debug_msg("Unknown RTP event (type=%d)\n", e->type);
		abort();
	}
}
Example #30
0
//----------------------------------------------------------------------
//
//	main
//
//	This routine is called when the OS starts up.  It allocates a
//	PCB for the first process - the one corresponding to the initial
//	thread of execution.  Note that the stack pointer is already
//	set correctly by _osinit (assembly language code) to point
//	to the stack for the 0th process.  This stack isn't very big,
//	though, so it should be replaced by the system stack of the
//	currently running process.
//
//----------------------------------------------------------------------
main (int argc, char *argv[])
{
  int		i, j;
  int		n;
  char	buf[120];
  char		*userprog = (char *)0;
  static PCB	temppcb;
  uint32	addr;
  extern void	SysprocCreateProcesses ();
  char *param[12]={NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  	 	   NULL, NULL, NULL, NULL};
  int base;

  debugstr[0] = '\0';
  MyFuncRetZero();
  printf ("Got %d arguments.\n", argc);
  printf ("Available memory: 0x%x -> 0x%x.\n", lastosaddress,
	  MemoryGetSize ());
  printf ("Argument count is %d.\n", argc);
  for (i = 0; i < argc; i++) {
    printf ("Argument %d is %s.\n", i, argv[i]);
  }
//  *((int *)0xfff00100) = 't';
  FsModuleInit ();
  for (i = 0; i < argc; i++)
  {
    if (argv[i][0] == '-')
    {
      switch (argv[i][1])
      {
      case 'D':
	dstrcpy (debugstr, argv[++i]);
	break;
      case 'i':
	n = dstrtol (argv[++i], (void *)0, 0);
	ditoa (n, buf);
	printf ("Converted %s to %d=%s\n", argv[i], n, buf);
	break;
      case 'f':
      {
	int	start, codeS, codeL, dataS, dataL, fd, j;
	int	addr = 0;
	static unsigned char buf[200];
	fd = ProcessGetCodeInfo (argv[++i], &start, &codeS, &codeL, &dataS,
				 &dataL);
	printf ("File %s -> start=0x%08x\n", argv[i], start);
	printf ("File %s -> code @ 0x%08x (size=0x%08x)\n", argv[i], codeS,
		codeL);
	printf ("File %s -> data @ 0x%08x (size=0x%08x)\n", argv[i], dataS,
		dataL);
	while ((n = ProcessGetFromFile (fd, buf, &addr, sizeof (buf))) > 0)
	{
	  for (j = 0; j < n; j += 4)
	  {
	    printf ("%08x: %02x%02x%02x%02x\n", addr + j - n, buf[j], buf[j+1],
		    buf[j+2], buf[j+3]);
	  }
	}
	close (fd);
	break;
      }
      case 'u':
	userprog = argv[++i];
        base = i;
	break;
      default:
	printf ("Option %s not recognized.\n", argv[i]);
	break;
      }
      if(userprog)
        break;
    }
  }
  dbprintf ('i', "About to initialize queues.\n");
  QueueModuleInit ();
  dbprintf ('i', "After initializing queues.\n");
  MemoryModuleInit ();
  dbprintf ('i', "After initializing memory.\n");

  ProcessModuleInit ();
  dbprintf ('i', "After initializing processes.\n");
  ShareModuleInit ();
  dbprintf ('i', "After initializing shared memory.\n");
  SynchModuleInit ();
  dbprintf ('i', "After initializing synchronization tools.\n");
  KbdModuleInit ();
  dbprintf ('i', "After initializing keyboard.\n");
  for (i = 0; i < 100; i++) {
    buf[i] = 'a';
  }
  i = FsOpen ("vm", FS_MODE_WRITE);
  dbprintf ('i', "VM Descriptor is %d\n", i);
  FsSeek (i, 0, FS_SEEK_SET);
  FsWrite (i, buf, 80);
  FsClose (i);
  if (userprog != (char *)0) {
      for(i=base;i<argc&&i-base<11; i++)
      {
        param[i-base] = argv[i];
      }
      process_create(0,0,param[0], param[1], param[2], param[3], param[4],
      		     param[5], param[6], param[7], param[8], param[9],
		     param[10], param[11]);
//    ProcessFork (0, (uint32)"Help Me man!", userprog, 1);
  }
  SysprocCreateProcesses ();
  dbprintf ('i', "Created processes - about to set timer quantum.\n");
  TimerSet (processQuantum);
  dbprintf ('i', "Set timer quantum to %d, about to run first process.\n",
	    processQuantum);
  intrreturn ();
  // Should never be called because the scheduler exits when there
  // are no runnable processes left.
  exitsim();	// NEVER RETURNS!
}