Example #1
0
File: zexit.c Project: E-LLP/VICAR
FUNCTION  VOID  z_exit
(
    FUNINT		sfi,			/* in: value for $sfi	*/
    TEXT		*skey			/* in: value for $sky	*/

 )
    {
#define ALDIM(bytes) 	1+((bytes-1)/sizeof (ALIGN)) 
#define HEAD_SIZ (sizeof(struct PARBLK) - P_BYTES + 8)  /* 8 for align safety*/
#define ZBLKDIM		(3*sizeof(struct VARIABLE) + 2*STRINGSIZ + HEAD_SIZ)
    						/* block dimension	*/

    IMPORT TEXT		savekey[];		/* key for last message	*/
    TEXT		*keyptr[1];		/* pointer to key string */
    TAEINT		sfival[1];
    ALIGN		block[ALDIM(ZBLKDIM)];	/* parameter block to send */
    struct	PARBLK  *termblk;		/* pointer to parameter block*/
    CODE		code;

    keyptr[0] = skey;				/* assume key present	*/
    if (NULLSTR(skey))
	keyptr[0] = savekey;			/* else, give old key	*/
    sfival[0] = sfi;
    termblk = (struct PARBLK *)block;		/* cast pointer		*/
    q_init(termblk, ZBLKDIM - HEAD_SIZ, P_ABORT); /* initialize the block*/
    q_intg(termblk, "$SFI", 1, sfival, P_ADD);	/* put sfi in block	*/
    q_string(termblk, "$SKEY", 1, keyptr, P_ADD);  /* put skey in block */
    code = q_out(termblk);			/* send block to tm	*/
    procexit(code);
    return;
    }
Example #2
0
File: mmsg.c Project: E-LLP/VICAR
FUNCTION  CODE  m_msg
(
 TEXT	message[],			/* In: message to be logged */
 TEXT	key[]				/* In: message key */
 )
    {
    CODE 	code;

/* the following avoids declaring a full PARBLK just to send a message	*/
#define ALDIM(bytes) 	1+((bytes-1)/sizeof (ALIGN)) 
#define HEAD_SIZ (sizeof(struct PARBLK) - P_BYTES + 8)  /* 8 for align safety*/
#define MBLKDIM (3*sizeof(struct VARIABLE) + 3*OUTMSGSIZ + HEAD_SIZ)
						/* block size in bytes	*/
    ALIGN	block[ALDIM(MBLKDIM)];		/* parameter block to send */
    struct	PARBLK  *parblk;		/* pointer to parameter block*/

    TEXT	*vector[1];			/* pointer to value */
    TEXT	msgbuf[OUTMSGSIZ+1];
    TEXT	msgkey[KEYSIZ+1];

    
    parblk = (struct PARBLK *) block;
    q_init (parblk, MBLKDIM - HEAD_SIZ, P_ABORT);	/* initialize block */
    s_bcopy((GENPTR)message, (GENPTR)msgbuf, OUTMSGSIZ); /* copy locally */
    if (s_length(message) > OUTMSGSIZ)			/* if too long-	*/
	msgbuf[OUTMSGSIZ] = EOS;			/* truncate	*/
    vector[0] = (TEXT *) msgbuf;
    code = q_string(parblk, "MESSAGE", 1, vector, P_ADD); /* add message */
    if (code == SUCCESS)
	{
	s_bcopy(key, msgkey, KEYSIZ);			/* copy key locally */
	if (s_length(key) > KEYSIZ)
	    msgkey[KEYSIZ] = EOS;			/* police length */
        vector[0] = (TEXT *) msgkey;			/* pointer to key   */
	code = q_string(parblk, "KEY", 1, vector, P_ADD); /* add key 	    */
	}
    if (code == SUCCESS)
	{
	code = q_sndp(parblk, M_HLOGMSG);		/* send message     */
	if (code == SUCCESS)
	    {
	    code = c_rcvp((GENPTR)parblk, sizeof(block)); /* rcv handsh blk */
	    (*parblk).hostcode = code;			/* save host code   */
	    if (code != SUCCESS)
		{
		t_write(
	"[TAE-MSGHANDS] Unable to confirm message reception by TM", T_STDCC);
		procexit(code);
		}
	    }
	}
    s_copy(msgkey, savekey);				/* save the key     */
    m_msgout(msgbuf, msgkey);				/* write to output  */
    return(code);
    }
Example #3
0
static void
f(void *arg)
{
	int n;
	
	n = *(int*)arg;
	if(chansend(ch, &n) != 1)
		fail = 1;
	procexit();
	fail = 1;
	printf("proc %d still alive after procexit\n", n);
}
Example #4
0
File: trap.c Project: mytchel/bom
void
trap(void *pc, int type)
{
  uint32_t fsr;
  void *addr;

  if (up == nil) {
    printf("Trapped with an unknown process!\n");
    panic("Probably an in kernel problem.\n");
  }

  switch(type) {
  case ABORT_INTERRUPT:
    irqhandler();

    return; /* Note the return. */

  case ABORT_INSTRUCTION:
    printf("%i bad instruction at 0x%h\n",
	   up->pid, pc);
    break;

  case ABORT_PREFETCH:
    if (fixfault((void *) pc)) {
      return;
    }

    printf("%i prefetch abort 0x%h\n",
	   up->pid, pc);

    break;

  case ABORT_DATA:
    addr = faultaddr();
    fsr = fsrstatus() & 0xf;

    switch (fsr) {
    case 0x5: /* section translation */
    case 0x7: /* page translation */
      /* Try add page */
      if (fixfault(addr)) {
	return;
      }
      
      break;
    case 0x0: /* vector */
    case 0x1: /* alignment */
    case 0x3: /* also alignment */
    case 0x2: /* terminal */
    case 0x4: /* external linefetch section */
    case 0x6: /* external linefetch page */
    case 0x8: /* external non linefetch section */
    case 0xa: /* external non linefetch page */
    case 0x9: /* domain section */
    case 0xb: /* domain page */
    case 0xc: /* external translation l1 */
    case 0xe: /* external translation l2 */
    case 0xd: /* section permission */
    case 0xf: /* page permission */
    default:
      break;
    }

    printf("%i data abort 0x%h (type 0x%h)\n",
	   up->pid, addr, fsr);
		
    break;
  }
	
  printf("kill proc %i (trap %i, at 0x%h)\n", up->pid, type, pc);
  procexit(up, -1);
  schedule();
  /* Never reached */
}
Example #5
0
File: heap.c Project: mytchel/bom
void *
malloc(size_t size)
{
  struct block *b, *n, *p;
  void *ptr;

  if (size == 0)
    return nil;

  size = roundptr(size);

  if (size > PAGE_SIZE - sizeof(struct pagel) - sizeof(size_t)) {
    printf("%i trying to malloc something too large %i\n",
	   up->pid, size);

    setintr(INTR_off);
    procexit(up, ENOMEM);
    schedule();

    return nil;
  }

  lock(&heaplock);
  
  p = nil;
  for (b = heap; b != nil; p = b, b = b->next) {
    if (b->size >= size) {
      break;
    }
  }

  if (b == nil) {
    b = growheap(p);
    if (b == nil) {
      panic("KERNEL OUT OF MEMORY!\n");
      return nil;
    }
  }

  ptr = (void *) ((uint8_t *) b + sizeof(size_t));
	
  if (b->size > size + sizeof(size_t) + sizeof(struct block)) {
    n = (struct block *) ((uint8_t *) b + sizeof(size_t) + size);
		
    n->size = b->size - size - sizeof(size_t);
    n->next = b->next;
		
    /* Set size of allocated block (so free can find it) */
    b->size = size;
  } else {
    n = b->next;
  }
	
  if (p == nil) {
    heap = n;
  } else {
    p->next = n;
  }

  unlock(&heaplock);

  memset(ptr, 0, size);

  return ptr;
}