Ejemplo n.º 1
0
void 
init_handoff(void) {
  int status;
  int i;
  printf("INIT_HANDOFF pid %d\n",getpid());

  status = fd_shm_alloc(FD_SHM_OFFSET + TCP_SOCKET_TYPE + 125 ,
			(sizeof(struct tcb_handoff)),
			(char *)TCB_SHARED_REGION);
  
  if (status == -1) assert(0);
  tcb_handoff = (struct tcb_handoff *) TCB_SHARED_REGION;
  printf("TCB_HANDOFF ADDR: %p size: %d\n",tcb_handoff, (sizeof(struct tcb_handoff)));
  if (status) {
    printf("clearing handoff region\n");
    /* not used before */
    for(i=0;i<MAXHANDOFF;i++) tcb_handoff->inuse[i] = 0;
  } else {
    printf("mapped handoff region\n");
  }
  
  OnExec(handoff_exec_handler);
  search_n_handoff(0);
  for(i=0;i<MAXHANDOFF;i++) tcb_handoff->inuse[i] = 0;
}
Ejemplo n.º 2
0
Archivo: pty.c Proyecto: aunali1/exopc
int
pty_init(void) {
    int i;
    int status;
    struct pty *ptyp;
#ifdef AEGIS
    tmp_putchr = putchr;
    putchr = ae_putc;
#endif /* AEGIS */

    DPRINTF(CLUHELP_LEVEL,("pty_init"));

    status = fd_shm_alloc(FD_SHM_OFFSET + PTY_TYPE,
			   (sizeof(struct pty_shared_data)),
			   (char *)PTY_SHARED_REGION);

    StaticAssert((sizeof(struct pty_shared_data)) <= PTY_SHARED_REGION_SZ);
    pty_shared_data = (struct pty_shared_data *) PTY_SHARED_REGION;


    demand(pty_shared_data, pty_shared_data getting bad pointer);

    if (status == -1) {
	demand(0, problems attaching shm);
	return -1;
    }

    if (status) {
#ifdef AEGIS
	ae_putc('P');
	ae_putc('I');
#endif /* AEGIS */
	init_pty_shared_lock();
	for (i = 0; i < NR_PTY; i++) {
	    ptyp = MAKEPTYP(i);
	    init_lock_pty(ptyp);
	    CLR_PTY_INUSE(0,ptyp);
	    CLR_PTY_INUSE(1,ptyp);
	}
    } else {
	/*printf("This is not first process, just attaching memory\n");  */
    }
    register_file_ops((struct file_ops *)&pty_file_ops, PTY_TYPE);
#ifdef AEGIS
    putchr = tmp_putchr;
#endif /* AEGIS */


    
    return 0;
}
Ejemplo n.º 3
0
int synch_init(void) {
  int status;
  int i;
  hz = 1000000 / __sysinfo.si_rate;

  status = fd_shm_alloc(SYNCH_SHM_OFFSET,
			sizeof(struct synch_table),
			(char *)SYNCH_SHARED_REGION);
  StaticAssert((sizeof(struct synch_table)) <= SYNCH_SHARED_REGION_SZ);
  if (status == -1) demand(0, problems attaching shm);

  synch_table = (struct synch_table *)SYNCH_SHARED_REGION;
  if (status) {
    /* first process */
    for (i = 0; i < NENV; i++) 
      synch_table->wchan[i] = NULL;
  }
  return 0;
}
Ejemplo n.º 4
0
Archivo: npty.c Proyecto: aunali1/exopc
int
npty_init(void) {

    int status,i;

    DPRINTF(CLUHELP_LEVEL,("pty_init"));

    status = fd_shm_alloc(FD_SHM_OFFSET + NPTY_TYPE + 990,
			  (sizeof(struct npty_shared_data)),
			  (char *)NPTY_SHARED_REGION);
    demand(npty_shared_data != 0, pty_shared_data getting bad pointer);
    
    StaticAssert((sizeof(struct npty_shared_data)) <= NPTY_SHARED_REGION_SZ);


    if (status == -1) {
	demand(0, problems attaching shm);
	return -1;
    }
    if (status) {
k1printf("npty_init first %d\n",NPTY_TYPE);
      bzero(npty_shared_data,(sizeof(struct npty_shared_data)));
      npty_tty_init();			/* initialize tty, clists */
      pt_softc_init(1);
      init_npty_shared_lock();
      for (i = 0; i < NPTY; i++) {
	init_lock_pty(i);
	npty_shared_data->refcount[0][i] = 0;
	npty_shared_data->refcount[1][i] = 0;

      }
      //npty_sched_init(1);
    } else {
k1printf("npty_init second+ %d\n",NPTY_TYPE);
      //npty_sched_init(0);
      pt_softc_init(0);
    }
    k1printf("pty_init: envid: %d\n",__envid);
    register_file_ops((struct file_ops *)&pty_file_ops, NPTY_TYPE);

    return 0;
}
Ejemplo n.º 5
0
int
arp_init(void) {
  int status;
  

  status = fd_shm_alloc(ARP_SHM_OFFSET,
			sizeof(arp_table_t),
			(char *)ARP_SHARED_REGION);
  arp_table = (arp_table_p)ARP_SHARED_REGION;

  StaticAssert((sizeof(arp_table_t)) <= ARP_SHARED_REGION_SZ);

  if (status == -1) {
    demand(0, problems attaching shm);
    return -1;
  }

  if (status) {
    arp_init_table();
  } 
  protect_arp_table();
  return 0;
}
Ejemplo n.º 6
0
int
ip_init() {
  int status;

  status = fd_shm_alloc(IP_SHM_OFFSET,
			sizeof(ip_table_t),
			(char *)IP_SHARED_REGION);
  ip_table = (ip_table_p)IP_SHARED_REGION;

  StaticAssert((sizeof(ip_table_t)) <= IP_SHARED_REGION_SZ);

  if (status == -1) {
    demand(0, problems attaching shm);
    return -1;
  }

  if (status) {
    ip_init_table();
  } 
  mk_ip_table_ro();
  return 0;

}
Ejemplo n.º 7
0
int
fd_fast_tcp_init(void) {
    int i;
    int status;
    START(fd_op[TCP_SOCKET_TYPE],init);
    DPRINTF(CLUHELP_LEVEL,("tcp_socket_init\n"));
    
#if 0
    printf("tcpsocket_init: just to test the memory, but tcp\n"
	   "uses its own static structures\n");
#endif
#ifdef AEGIS

    status = fd_shm_alloc(FD_SHM_OFFSET + TCP_SOCKET_TYPE,
			   (sizeof(struct tcp_shared_data)),
			   (char *)TCP_SHARED_REGION);

    StaticAssert((sizeof(struct tcp_shared_data)) <= TCP_SHARED_REGION_SZ);
    tcp_shared_data = (struct tcp_shared_data *) TCP_SHARED_REGION;
#endif /* AEGIS */
#ifdef EXOPC

    status = 1;
    tcp_shared_data = (struct tcp_shared_data *) 
      malloc(sizeof(struct tcp_shared_data));
    assert(tcp_shared_data);

#endif /* EXOPC */



    if (status == -1) {
	demand(0, problems attaching shm);
	STOP(fd_op[TCP_SOCKET_TYPE],init);
	return -1;
    }

    if (status) {
	/* 	printf("Initializing tcp shared data structture\n"); */
      assert(sizeof(struct tcp_socket_data) <= FILE_DATA_SIZE);

	for (i = 0; i < NR_SOCKETS; i++)
	    tcp_shared_data->used_ports[i] = 0;
#if 0				
	/* Using local structures */
	for (i = 0; i < MAX_CONNECTION; i++)
	    tcb_release(&(tcp_shared_data->connection[i]));
#endif
	tcp_shared_data->next_port = (getpid() << 9) | random();

    } else {
	/* printf("This is not first process, just attaching memory\n"); */
    }
    /* AF_UNIX, SOCK_STREAM, TCP */
    register_family_type_protocol(2,1,6,tcp_socket);
    /* AF_UNIX, SOCK_STREAM, IP */
    register_family_type_protocol(2,1,0,tcp_socket);
    register_file_ops(&tcp_file_ops, TCP_SOCKET_TYPE);
#if 0 /* commented out for now */
    init_handoff();
#endif
    STOP(fd_op[TCP_SOCKET_TYPE],init);
    return 0;
}