Exemple #1
0
static void _execv(char *cmd, char **argv) {
#ifdef DEBUG
  DumpCommand(argv);
#endif
  if (execv(cmd, argv) < 0) {
    int errsv = errno;
    Error("%s: %s", strerror(errsv), cmd);
  }
}
Exemple #2
0
static void DumpProcess(Process *proc) {
  fprintf(stderr, "pid:%d status:%s\n", (int)proc->pid,
          proc->state == STATE_RUN ? "RUN" : "DOWN");
  DumpCommand(proc->argv);
}
Exemple #3
0
VOID
Monitor(
    IN ULONG CallerSource,
    IN PFW_EXCEPTION_FRAME Frame
    )
/*++

Routine Description:

    This is the main dispatch routine to the various commands
    that can be typed at the monitor prompt.

    
Arguments:

    For Alpha/Jensen:
    
    CallerSource	0 if exception (or bugcheck, on Alpha/Jensen)
    			3 if called from boot menu

    Frame               the machine / exception state.

    
Return Value:

    None.

--*/

{
    CHAR Buffer[2][128];
    ULONG ParityDiag[3];
    PULONG ParDiag;
    ULONG BufferIndex;
    PCHAR Argv[10];
    PCHAR Tmp;
    CHAR  String[128];
    BOOLEAN CommandValid;
    GETSTRING_ACTION Action;

#ifdef ALPHA_FW_KDHOOKS

    //
    // If this is a breakpoint exception which is recognized, process it.
    // Otherwise, continue into the Monitor.
    //

    if ((Frame->ExceptionType == FW_EXC_BPT) &&
	(FwKdProcessBreakpoint(Frame) == TRUE)) {
	
	//
	// This does not return.
	//
	      
        FwRfe(Frame);
    }

#endif
    
    FwPrint(MON_MONITOR_MSG);
    FwPrint(MON_PRESS_H_MSG);

    //
    // Initialize command line to null.
    //
    Argv[0] = (PCHAR)NULL;

    if (CallerSource !=3) {

        //
        // Display Cause of exception.
        //

        if ((Frame->ExceptionType >= FW_EXC_FIRST) &&
            (Frame->ExceptionType <= FW_EXC_LAST)
            )
              { FwPrint(ExceptionNameTable[(Frame->ExceptionType & 0xf)]);}
	else
	      { FwPrint("** !! Unknown Exception"); }

        FwPrint(MON_EXCEPTION_MSG);

	FwPrint("PC = 0x%016Lx, VA = 0x%016Lx\r\n",
		Frame->ExceptionFaultingInstructionAddress,
		Frame->ExceptionVa);

        //
	// If an exception happened before the ARC console was opened,
	// a call to JzGetString will not work since JzGetString calls
	// ArcRead.  So, close the console (nothing bad will happen if these
	// are not already opened) and reopen it.
	//

        FwClose(ARC_CONSOLE_INPUT);
        FwClose(ARC_CONSOLE_OUTPUT);

#ifdef ALPHA_FW_KDHOOKS

	//
        // If we are built with the kernel debugger stubs, and have come
	// here because of an exception, we want to enter the debugger.
	//

        Frame->ExceptionType = FW_EXC_BPT;
        DbgBreakPoint();

#endif

	FwOpenConsole();
    }

    //
    // Initialize Static variables.
    //
    DefaultAddress = KSEG0_BASE;
    DataSize = MON_QUAD;
    BufferIndex = 0;

    //
    // loop forever getting commands and dispatching them
    //

    while(TRUE) {

        //
        // print prompt
        //

        FwPrint(">");

        //
        // read a command.
        //

        do {
            Action = JzGetString(Buffer[BufferIndex], 128, NULL,
				 FwRow+1, FwColumn+1, FALSE);
        } while ((Action != GetStringSuccess) && (Action != GetStringEscape));
        FwPrint(FW_CRLF_MSG);

        //
        // convert string to lower case.
        //

        for (Tmp=Buffer[BufferIndex];*Tmp;*Tmp++) {
            *Tmp=tolower(*Tmp);
        }

        //
        // if escape was pressed, simulate a quit command.
        //

        if (Action == GetStringEscape) {
            Argc = 1;
            Argv[0] = "q";

        //
        // separate command line into tokens delimited by spaces
        // load up Argv with pointers to arguments and put count in Argc
        //

        } else if (*Buffer[BufferIndex] != '\0') {
            Tmp = Buffer[BufferIndex];
            Argc = 0;
            //
            // Skip leading blanks
            //
            while ( *Tmp == ' ') {
                Tmp++;
            }
            while ( *Tmp ) {
                Argv[Argc++] = Tmp;
                while ( *Tmp ) {
                    if (*Tmp == ' ') {
                        *Tmp++ = '\0';
                        while ( *Tmp == ' ') {
                            Tmp++;
                        }
                        break;
                    }
                    Tmp++;
                }
            }

            //
            // Increment index so that next command is read into the other
            // buffer. And we preserve the previous one.
            //
            BufferIndex = (BufferIndex+1) & 0x1;
        } else {
            //
            // repeat the last command already in Argv Argc
            //
        }
        //
        // if first argument is not null, then dispatch to routines.
        //
        if (Argv[0] != (PCHAR) NULL) {
            CurrentArg = 1;
            CurrentCommand = GetCommand(Argv[0]);
            switch(CurrentCommand) {
                case DumpByte:
                case DumpWord:
                case DumpLongword:
                case DumpQuad:
                        DataSizeShift = (CurrentCommand - Dump -1);
                        DataSize = 1 << DataSizeShift;
                        DataSizeMask = DataSize-1;
                case Dump:
                        CommandValid = DumpCommand(Argv,Frame);
                        break;

                case EnterByte:
                case EnterWord:
                case EnterLongword:
		case EnterQuad:
                        DataSizeShift = (CurrentCommand - Enter -1);
                        DataSize = 1 << DataSizeShift;
                        DataSizeMask = DataSize-1;
                case Enter:
                        CommandValid = EnterCommand(Argv,Frame);
                        break;

                case Help:
                case Help2:
			HelpCommand();
			break;

                case DepositByte:
                case DepositWord:
                case DepositLongword:
                case DepositQuad:
                        DataSizeShift = (CurrentCommand - Deposit -1);
                        DataSize = 1 << DataSizeShift;
                        DataSizeMask = DataSize-1;
                case Deposit:
                        CommandValid = DepositCommand(Argv,Frame);
                        break;
                case ExamineByte:
                case ExamineWord:
                case ExamineLongword:
                case ExamineQuad:
                        DataSizeShift = (CurrentCommand - Examine -1);
                        DataSize = 1 << DataSizeShift;
                        DataSizeMask = DataSize-1;
                case Examine:
                        CommandValid = ExamineCommand(Argv,Frame);
                        break;

 		case IOReadByte:
 		case IOReadWord:
 		case IOReadLongword:
                        DataSizeShift = (CurrentCommand - IORead -1);
                        DataSize = 1 << DataSizeShift;
                        DataSizeMask = DataSize-1;
		case IORead:
			CommandValid = IOReadCommand(Argv, Frame);
			break;
			
#if 0

 		case IOWriteByte:
 		case IOWriteWord:
 		case IOWriteLongword:
                        DataSizeShift = (CurrentCommand - IOWrite -1);
                        DataSize = 1 << DataSizeShift;
                        DataSizeMask = DataSize-1;
		case IOWrite:
			CommandValid = IOWriteCommand(Argv, Frame);
			break;
			
#endif

                case Register:
		case IntegerRegisterDump:
		case FloatingRegisterDump:
                        CommandValid = RegisterCommand(Argv, Frame);
                        break;

                case Zero:
                        CommandValid = ZeroCommand(Argv,Frame);
                        break;

                case Fill:
                        CommandValid = FillCommand(Argv,Frame);
                        break;

#if 0
		case AvailableDevices:
			CommandValid = FwDumpLookupTable();
			break;
#endif

                case Quit:
                        if (CallerSource == 3) {
                            return;
                        } else {
                            //
                            // We came because of an exception.
                            // The only way to exit is reseting the system.
                            //
                            FwPrint(MON_NO_RETURN_MSG);
                            FwPrint(MON_RESET_MACHINE_MSG);

                            do {
                                Action = JzGetString(Buffer[BufferIndex],
						     128,
						     NULL,
						     FwRow+1,
						     FwColumn+1,
						     FALSE);
                            } while ((Action != GetStringSuccess) && (Action != GetStringEscape));
                            FwPrint(FW_CRLF_MSG);

                            Buffer[BufferIndex][0]=tolower(Buffer[BufferIndex][0]);
                            if (strcmp(Buffer[BufferIndex],"y") == 0) {
                                ResetSystem();
                            }
                            break;
                        }

                case invalidcommand:

                        FwPrint(MON_UNRECOGNIZED_COMMAND_MSG);

                        //
                        // Clear the argument so that re-do last command
                        // doesn't repeat the erroneous command.
                        //

                        CommandValid = FALSE;
                        break;
            }

            if (!CommandValid) {
                Argv[0] = (PCHAR) NULL;
            }
        }
    }
}