コード例 #1
0
ファイル: getty.c プロジェクト: troglobit/finit
/*
 * Handle the process of a GETTY.
 */
static void do_getty(char *tty, char *name, size_t len)
{
	int ch;
	char *np;

	/*
	 * Clean up tty name.
	 */
	if (!strncmp(tty, _PATH_DEV, strlen(_PATH_DEV)))
		tty += 5;

	/*
	 * Display prompt.
	 */
	ch = ' ';
	*name = '\0';
	while (ch != '\n') {
		do_issue(tty);

		np = name;
		while ((ch = readch(tty)) != '\n') {
			if (ch == CTL('U')) {
				while (np > name) {
					(void)write(1, "\b \b", 3);
					np--;
				}
				continue;
			}

			if (np < name + len)
				*np++ = ch;
		}

		*np = '\0';
		if (*name == '\0')
			ch = ' ';	/* blank line typed! */
	}

	name[len - 1] = 0;
}
コード例 #2
0
ファイル: dpath.c プロジェクト: palmerc/lab
int Data_path (void)
{
	register struct mem_wrd *memaddr;
	register struct IR_FIELDS   *ir;
	register struct SIM_FLAGS   *f;
	int     retval,retval_cmmu;				/* return value */
	unsigned int	issue_latency = 0;	/* max time to issue instr(s) */


	if (ckbrkpts(IP, BRK_EXEC))		/* Check for breakpoint */
	{
		retval = -1;
		return(retval);
	}

	retval_cmmu = 0;
	if(usecmmu && (retval = cmmu_function1()))
		return(retval);

	if ((memaddr = getmemptr (IP, M_INSTR)) == 0)
		return (exception(E_TCACC, "Code Access Bus Error"));

	ir = &memaddr -> opcode;
	f = ((ir->p) ? &ir->p->flgs: &simdata.flgs);


	/* see if we can issue the instruction in this clock */

	if ( (retval = test_issue( ir, f )) == -1 )
	{
		return ( retval );
	}
	else
	{

		Statistics (ir);

		/* Issue the instruction to the appropriate FU */

		do_issue();
		issue_latency = f->is_latency;
		issue_latency += retval;
		prev_extime = issue_latency;

		if(debugflag)
			PPrintf(" after chk_SB : Dcmmutime = %d \n", Dcmmutime);

		if (usecmmu)
			cmmu_function2(ir);

		/*
		 * The data from the source 1 register is put onto the 
		 * source 1 bus, as an input to the ALU.
		 */

		m88000.S1bus = m88000.Regs[ir -> src1];

		/*
		 * The data from the source 2 register, or an immediate 
		 * value, is put on the source 2 bus, which is also an 
		 * input to the ALU.
		 */

		if (!f -> imm_flags)	/* if not immediate */
			m88000.S2bus = m88000.Regs[ir -> src2];
		else if (f -> imm_flags == i26bit)
			m88000.S2bus = sext (opword (IP), 0, 26);
		else if ((f -> imm_flags == i16bit) &&
				((ir -> op < (unsigned)JSR) || (ir -> op > (unsigned)BCND)))
			m88000.S2bus = uext (opword (IP), 0, 16);
		else if ((f -> imm_flags == i16bit) &&
				((ir -> op >= (unsigned)JSR) && (ir -> op <= (unsigned)BCND)))
			m88000.S2bus = sext (opword (IP), 0, 16);
		else if (f -> imm_flags == i10bit)
			m88000.S2bus = uext (opword (IP), 0, 10);
		else
		{
			Eprintf ("SYSTEM ERROR in dpath, funky sized immediate\n");
			return(-1);
		}

		/*
		 * The instruction has been issued and the busses have 
		 * been driven.  Now execute the instruction.
		 */

		if( retval = execute(ir, f, memaddr) ) return(retval);

   		if (usecmmu && debugflag)
			PPrintf(" Dcmmutime (total after store) = %d \n",Dcmmutime);

		/*
		 *	Adjust the program counter
		 */

		killtime ( issue_latency );
		if ( retval = Pc(memaddr, ir, f) )
			return ( retval );

	}


	return ( retval );
}