?? monitor.c
字號(hào):
/*
MMURTL Operating System Source Code
Copyright 1991,1992,1993, Richard A. Burgess
ALL RIGHTS RESERVED
Version x0.8
*/
/* This is the MMURTL Monitor program. It is the OS monitor providing
the user with statistics and control of the environment, and a few
basic functions such as starting a CLI.
The monitor has three main functions:
1) Sets up internal device drivers and services.
2) Checks config files and loads any system services specified
in the config file,
3) Loads the first CLI and assigns the video and keyboard to it.
Because the Monitor is part of the OS we do not declare a main
function. The entry point to the monitor is called Monitor and
it has no parameters. After the OS gets done with its low level
initialization, the monitor procedure is "Jumped" to.
*/
#define U32 unsigned long
#define S32 long
#define U16 unsigned int
#define S16 int
#define U8 unsigned char
#define S8 char
#include "MKernel.h"
#include "MMemory.h"
#include "MData.h"
#include "MTimer.h"
#include "MVid.h"
#include "MKbd.h"
#include "MJob.h"
#include "MFiles.h"
#include "MDevDrv.h"
#define ok 0
#define ErcNoDevice 504
char rgStatLine[] =
"mm/dd/yy 00:00:00 MMURTL Monitor Tick:0 ";
char rgMonMenu1[] = "LdCLI\xb3Jobs \xb3Stats \xb3 ";
char rgMonMenu2[] = " \xb3 \xb3 \xb3Reboot";
char rgMonMenu3[] = " \xb3Debug \xb3 \xb3 ";
char rgCPR1[] ="MMURTL (tm) - Message based, MUltitasking, Real-Time kerneL";
char rgCPR2[] ="Copyright (c) R.A. Burgess, 1990-1993, All Rights Reserved";
char *CRLF = "\r\n\r\n";
unsigned long Color = WHITE|BGBLACK; /* Color test for xprintf */
long time, date, tick;
unsigned long KillExch; /* Messaging for stat task KILL proc */
unsigned long KillMsg[2]; /* First DWORD = TSSExch, second is ERROR */
unsigned long KillError;
unsigned long KillJob;
unsigned char fKilled;
unsigned long MngrExch; /* Messaging for stat task */
unsigned long MngrMsg[2];
unsigned long MngrHndl;
unsigned long gcode;
unsigned long GPExch; /* Messaging for main */
unsigned long GPMsg[2];
unsigned long GPHndl;
unsigned long GP1Exch; /* Extra Messaging for main */
unsigned long GP1Msg[2];
unsigned long GP1Hndl;
/* Structure for disk device driver status and setup */
struct {
U32 erc;
U32 blocks_done;
U32 BlocksMax;
U8 fNewMedia;
U8 type_now; /* current disk type for drive selected */
U8 resvd1[2]; /* padding for DWord align */
U32 nCyl; /* total physical cylinders */
U32 nHead; /* total heads on device */
U32 nSectors; /* Sectors per track */
U32 nBPS; /* Number of bytes per sect */
U32 LastRecalErc0;
U32 LastSeekErc0;
U8 LastStatByte0;
U8 LastErcByte0;
U8 fIntOnReset; /* Interrupt was received on HDC_RESET */
U8 filler0;
U32 LastRecalErc1;
U32 LastSeekErc1;
U8 LastStatByte1;
U8 LastErcByte1;
U8 ResetStatByte; /* Status Byte immediately after RESET */
U8 filler1;
U32 resvd1[2]; /* out to 64 bytes */
} DiskStatus;
struct JCBRec *pKillJCB;
long StatStack[256]; /* 1024 byte stack for stat task */
long MngrStack[256]; /* 1024 byte stack for Mngr task */
unsigned char Buffer[512];
unsigned long nMemPages;
extern unsigned long oMemMax;
extern unsigned long nSwitches;
extern unsigned long nRQBLeft;
extern unsigned long nJCBLeft;
extern unsigned long nTSSLeft;
extern unsigned long nLBLeft;
extern unsigned long nEXCHLeft;
/*============ protos (NOT FAR MMURTL) =======================*/
extern long InitKBDService(void); /* From KbdCode.inc */
extern long fdisk_setup(void); /* From FDD.c */
extern long hdisk_setup(void); /* From FDD.c */
extern long coms_setup(void); /* From COMMDRV.c */
extern long InitFS(void); /* From Fsys.c */
/*============ protos (NEAR MMURTL support calls) =======================*/
extern long GetExchOwner(long Exch, char *pJCBRet);
extern long DeAllocJCB(long *pdJobNumRet, char *ppJCBRet);
/*======================================================*/
/*=================== START OF CODE ====================*/
/*======================================================*/
/**************************************************************
Temporary formatted output routines for montitor program until
CM32 library is ported. printf, sprintf.
***************************************************************/
#include <stdarg.h>
#define S_SIZE 100
/*********************************************
* Determine if a character is a numeric digit
**********************************************/
long isdigit(long chr)
{
;
#asm
MOV EAX,[EBP+8]
CMP AL,'0' ;
JL isdigit0 ;No
CMP AL,'9' ;
JLE isdigit1 ;Yes
isdigit0:
XOR EAX,EAX ;No
JMP SHORT isdigit2
isdigit1:
MOV EAX, -1
isdigit2:
#endasm
}
long strlen(char *cs)
{
;
#asm
XOR EAX, EAX
MOV ESI,[EBP+8]
_strlen0:
CMP BYTE PTR [ESI],0
JE _strlen1
INC ESI
INC EAX
JMP SHORT _strlen0
_strlen1:
#endasm
}
/*************************************************************
This does the actual parsing of the format and also moves to
the next arg(s) in the list from the passed in arg pointer.
The number of chars written is returned (not incl \0).
**************************************************************/
long _ffmt(char *outptr, char *fmt, long *argptr)
{
char numstk[33], *ptr, justify, zero, minus, chr;
unsigned long width, value, i, total;
total = 0;
while(chr = *fmt++) {
if(chr == '%') { /* format code */
chr = *fmt++;
ptr = &numstk[32];
*ptr = justify = minus = 0;
width = value = i = 0;
zero = ' ';
if(chr == '-') { /* left justify */
--justify;
chr = *fmt++;
}
if(chr == '0') /* leading zeros */
zero = '0';
while(isdigit(chr)) { /* field width specifier */
width = (width * 10) + (chr - '0');
chr = *fmt++;
}
value = *--argptr; /* get parameter value */
switch(chr) {
case 'd' : /* decimal number */
if(value & 0x80000000) {
value = -value;
++minus; }
case 'u' : /* unsigned number */
i = 10;
break;
case 'x' : /* hexidecimal number */
case 'X' :
i = 16;
break;
case 'o' : /* octal number */
i = 8;
break;
case 'b' : /* binary number */
i = 2;
break;
case 'c' : /* character data */
*--ptr = value;
break;
case 's' : /* string */
ptr = value; /* value is ptr to string */
break;
default: /* all others */
*--ptr = chr;
++argptr; /* backup to last arg */
}
if(i) /* for all numbers, generate the ASCII string */
do {
if((chr = (value % i) + '0') > '9')
chr += 7;
*--ptr = chr; }
while(value /= i);
/* output sign if any */
if(minus) {
*outptr++ = '-';
++total;
if(width)
--width;
}
/* pad with 'zero' value if right justify enabled */
if(width && !justify) {
for(i = strlen(ptr); i < width; ++i)
*outptr++ = zero;
++total;
}
/* move in data */
i = 0;
value = width - 1;
while((*ptr) && (i <= value)) {
*outptr++ = *ptr++;
++total;
++i; }
/* pad with 'zero' value if left justify enabled */
if(width && justify) {
while(i < width) {
*outptr++ = zero;
++total;
++i;
}
}
}
else {
/* not format char, just move into string */
*outptr++ = chr;
++total;
}
}
*outptr = 0;
return total;
}
/************************************
Formatted print to screen
*************************************/
long xprintf(char *fmt, ...)
{
va_list ap;
long total;
char buffer[S_SIZE];
va_start(ap, fmt); /* set up ap pointer */
total = _ffmt(buffer, fmt, ap);
TTYOut(buffer, strlen(buffer), Color);
va_end(ap, fmt);
return total;
}
/************************************
Formatted print to string s
*************************************/
long xsprintf(char *s, char *fmt, ...)
{
va_list ap;
long total;
va_start(ap, fmt); /* set up ap pointer */
total = _ffmt(s, fmt, ap);
va_end(ap, fmt);
return total;
}
/*********************************************************
This is called to initialize the sacreen.
*********************************************************/
void InitScreen(void)
{
ClrScr();
xsprintf(&rgStatLine[70], "%d", tick);
PutVidChars(0,0, rgStatLine, 80, WHITE|BGBLUE);
PutVidChars(0, 24, rgMonMenu1, 26, BLUE|BGWHITE);
PutVidChars(27, 24, rgMonMenu2, 26, BLUE|BGWHITE);
PutVidChars(54, 24, rgMonMenu3, 25, BLUE|BGWHITE);
SetXY(0,1);
return;
}
/******************* END OF TEMPORARY CODE ********************/
/*********************************************************
This is the status task for the Monitor.
*********************************************************/
void StatTask(void)
{
unsigned long erc, i, Exch, Msg[2];
U8 *pPD, *pVid;
for(;;) {
GetCMOSTime(&time);
rgStatLine[10] = '0' + ((time >> 20) & 0x0f);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -