Exemple #1
0
// **********************************************************************
// keyboard interrupt service routine
//
static void keyboard_isr()
{
	// assert system mode
	assert("keyboard_isr Error" && superMode);

	semSignal(charReady);					// SIGNAL(charReady) (No Swap)
	if (charFlag == 0)
	{
		switch (inChar)
		{
			case '\r':
			case '\n':
			{
				inBufIndx = 0;				// EOL, signal line ready
				semSignal(inBufferReady);	// SIGNAL(inBufferReady)
				break;
			}

			case 0x18:						// ^x
			{
				inBufIndx = 0;
				inBuffer[0] = 0;
				sigSignal(0, mySIGINT);		// interrupt task 0
				semSignal(inBufferReady);	// SEM_SIGNAL(inBufferReady)
				break;
			}

			case 0x17: 						// ^w
			{
				sigSignal(-1, mySIGTSTP);
				break;
			}

			case 0x12:						// ^r
			{
				sigSignal (-1, mySIGCONT);

				break;
			}


			default:
			{
				inBuffer[inBufIndx++] = inChar;
				inBuffer[inBufIndx] = 0;
				printf("%c", inChar);		// echo character
			}
		}
	}
	else
	{
		// single character mode
		inBufIndx = 0;
		inBuffer[inBufIndx] = 0;
	}
	return;
} // end keyboard_isr
Exemple #2
0
// **********************************************************************
//	sigSignal - send signal to task(s)
//
//	taskId = task (-1 = all tasks)
//	sig = signal
//
int sigSignal(int taskId, int sig)
{
	// check for task
	if ((taskId >= 0) && tcb[taskId].name)
	{
		tcb[taskId].signal |= sig;
		return 0;
	}
	else if (taskId == -1)
	{
		for (taskId=0; taskId<MAX_TASKS; taskId++)
		{
			sigSignal(taskId, sig);
		}
		return 0;
	}
	// error
	return 1;
}
Exemple #3
0
int defaultSigTstpHandler(void)			// task mySIGINT handler
{
	sigSignal(-1, mySIGSTOP);
	return 1;
}
Exemple #4
0
// **********************************************************************
// **********************************************************************
//	Default signal handlers
//
void defaultSigIntHandler(void)			// task mySIGINT handler
{
	sigSignal(-1, mySIGTERM);
	return;
}
Exemple #5
0
void mySIGINTHandler(void)
{
	sigSignal(-1, mySIGTERM);
	return;
}
Exemple #6
0
void mySIGTSTPHandler(void)
{
	sigSignal(-1, mySIGSTOP);
	return;
}
Exemple #7
0
void defaultSigTstpHandler(void)
{
	printf("\nTstp handler\n");
	sigSignal(-1, mySIGSTOP);
}
Exemple #8
0
// **********************************************************************
// **********************************************************************
//	Default signal handlers
//
void defaultSigIntHandler(void)			// task mySIGINT handler
{
	printf("\nInt handler\n");
	sigSignal(-1, mySIGTERM);
}
Exemple #9
0
void defaultSigTstpHandler(void)			// task mySIGTSTP handler
{
//	printf("\ndefaultSigTstpHandler");
    sigSignal(-1, mySIGSTOP);
	return;
}
Exemple #10
0
void defaultSigIntHandler(void)			// task mySIGINT handler
{
	//	printf("\ndefaultSigIntHandler");
	sigSignal(-1, mySIGTERM);
	return;
}
Exemple #11
0
// **********************************************************************
// keyboard interrupt service routine
//
static void keyboard_isr()
{
	// assert system mode
	assert("keyboard_isr Error" && superMode);

	semSignal(charReady);					// SIGNAL(charReady) (No Swap)

	if (charFlag == 0)
	{
		switch (inChar)
		{
		case '\r':
		case '\n':
		{

			if(strlen(inBuffer) > 1){
				strcpy(hist[histSize], inBuffer);
				histSize++;
			}
			histIndx = histSize;
			//for(i = histIndx - 1; i >= 0; i--)
			//	printf("\n %2d: %s", i, hist[i]);
			inBufIndx = 0;				// EOL, signal line ready
			semSignal(inBufferReady);	// SIGNAL(inBufferReady)
			break;
		}
		case '\b':
		{
			inBuffer[--inBufIndx] = 0; // backspace
			printf("\b \b");		   // backspace, write empty space and backspace again
			break;
		}
		case 0x12:						// ^r (18)
		{
			printf("^R");
			int i = 0;
			inBufIndx = 0;
			inBuffer[0] = 0;
			sigSignal(-1, mySIGCONT); //resumes all tasks (except shell)
			for(i = 0; i < MAX_TASKS; i++)
			{
				if (tcb[i].signal & mySIGTSTP) tcb[i].signal &= ~mySIGTSTP;
				if (tcb[i].signal & mySIGSTOP) tcb[i].signal &= ~mySIGSTOP;
			}
			semSignal(inBufferReady);	// SIGNAL(inBufferReady)
			break;
		}
		case 0x17:						// ^w (23)
		{
			printf("^W");
			inBufIndx = 0;
			inBuffer[0] = 0;
			sigSignal(0, mySIGTSTP); //pauses all tasks (except shell)
			semSignal(inBufferReady);	// SEM_SIGNAL(inBufferReady)
			break;
		}
		case 0x18:						// ^x (24)
		{
			printf("^X");
			inBufIndx = 0;
			inBuffer[0] = 0;
			sigSignal(-1, mySIGINT); //kills all tasks (except shell)
			semSignal(inBufferReady);	// SEM_SIGNAL(inBufferReady)
			break;
		}
		case 0x48: // key-up, same as "H" (78)
			if(arrowKey)
			{
				if(histIndx == 0)
					return;
				while(inBufIndx >= 1)
				{
					inBuffer[--inBufIndx] = 0; // backspace
					printf("\b \b");
				}
				histIndx--;
				printf("%s", hist[histIndx]);
				strcpy(inBuffer, hist[histIndx]);
				inBufIndx = strlen(hist[histIndx]);
				arrowKey = FALSE;
			}
			else
			{
				inBuffer[inBufIndx++] = inChar;
				inBuffer[inBufIndx] = 0;
				printf("%c", inChar);		// echo character
			}
			break;
		case 0x50: // key-up, same as "P" (80)
			if(arrowKey)
			{
				if(histIndx == histSize)
					return;
				while(inBufIndx >= 1)
				{
					inBuffer[--inBufIndx] = 0; // backspace
					printf("\b \b");
				}
				histIndx++;
				printf("%s", hist[histIndx]);
				strcpy(inBuffer, hist[histIndx]);
				inBufIndx = strlen(hist[histIndx]);
				arrowKey = FALSE;
			}
			else
			{
				inBuffer[inBufIndx++] = inChar;
				inBuffer[inBufIndx] = 0;
				printf("%c", inChar);		// echo character
			}
			break;
		default:
		{
			if(arrowKey){
				arrowKey = FALSE;
			}
			else
			{
				inBuffer[inBufIndx++] = inChar;
				inBuffer[inBufIndx] = 0;
				printf("%c", inChar);		// echo character
			}
		}
		}
	}
	else
	{
		// single character mode
		inBufIndx = 0;
		inBuffer[inBufIndx] = 0;
	}
	return;
} // end keyboard_isr