Exemple #1
0
/*
 * ScreenInit - get screen info
 */
void ScreenInit( void )
{
    unsigned short              solvb;
    struct _VIOCONFIGINFO       config;
    struct _VIOMODEINFO         vioMode;
    void * SEG16                ptr;

    vioMode.cb = sizeof( vioMode );
    if( VioGetMode( &vioMode, 0 ) != 0 ) {
        FatalError( ERR_WIND_INVALID );
    }
    EditVars.WindMaxWidth = vioMode.col;
    EditVars.WindMaxHeight = vioMode.row;

    config.cb = sizeof( config );
    if( VioGetConfig( 0, &config, 0 ) != 0 ) {
        FatalError( ERR_WIND_INVALID );
    }
    if( config.display == 3 ) {
        EditFlags.BlackAndWhite = TRUE;
    } else {
        if( config.adapter == 0 ) {
            EditFlags.Monocolor = TRUE;
        } else {
            EditFlags.Color = TRUE;
        }
    }

    VioGetBuf( (PULONG) &ptr, (PUSHORT) &solvb, 0);
    Scrn = ptr;
    ScreenPage( 0 );

} /* ScreenInit */
Exemple #2
0
int intern initbios( void )
/*************************/
{
    int                 initialized;
    // unsigned            offset;
    #ifdef __386__
        void        __far16 *ptrLVB;
        void                *ptr;
    #else
        unsigned    long    ptrLVB;
    #endif
    unsigned    short   SizeOfLVB;

    initialized = FALSE;
    if( initmonitor() ) {
        VioGetBuf( (PULONG) &ptrLVB, (PUSHORT) &SizeOfLVB, 0);
        // offset = SCREEN_OFFSET; AFS 08-feb-91
        #ifdef __386__
            ptr = ptrLVB;
            UIData->screen.origin = ptr;
        #else
            UIData->screen.origin = (LP_PIXEL)ptrLVB;
        #endif
        UIData->screen.increment = UIData->width;
        uiinitcursor();
        initkeyboard();
        if( _osmode == DOS_MODE ) {
            UIData->mouse_acc_delay = 5;   /* ticks */
            UIData->mouse_rpt_delay = 1;   /* ticks */
            UIData->mouse_clk_delay = 5;   /* ticks */
            UIData->tick_delay = 9;        /* ticks */
            UIData->mouse_speed = 8;       /* mickeys to ticks ratio */
        } else {
            UIData->mouse_acc_delay = 250;
            UIData->mouse_rpt_delay = 100;
            UIData->mouse_clk_delay = 250;
            UIData->tick_delay = 500;
            UIData->mouse_speed = 8;       /* mickeys to ticks ratio */
        }
        initialized = TRUE;
    }
    return( initialized );
}
Exemple #3
0
/*
 * ScreenInit - get screen info
 */
void ScreenInit( void )
{
    unsigned short              solvb;
    struct _VIOCONFIGINFO       config;
    struct _VIOMODEINFO         vioMode;
    void * SEG16                ptr;

    /* Set the cb member of VIOMODEINFO/VIOCONFIGINFO to smaller values
     * in order to be backward compatible with old OS/2 versions.
     */
    vioMode.cb = offsetof( VIOMODEINFO, buf_addr );
    if( VioGetMode( &vioMode, 0 ) != 0 ) {
        StartupError( ERR_WIND_INVALID );
    }
    WindMaxWidth = vioMode.col;
    WindMaxHeight = vioMode.row;

    config.cb = offsetof( VIOCONFIGINFO, Configuration );
    if( VioGetConfig( 0, &config, 0 ) != 0 ) {
        StartupError( ERR_WIND_INVALID );
    }
    if( config.display == 3 ) {
        EditFlags.BlackAndWhite = TRUE;
    } else {
        if( config.adapter == 0 ) {
            EditFlags.Monocolor = TRUE;
        } else {
            EditFlags.Color = TRUE;
        }
    }

    VioGetBuf( (PULONG) &ptr, (PUSHORT) &solvb, 0);
    Scrn = ptr;
    ScreenPage( 0 );

} /* ScreenInit */
Exemple #4
0
USHORT __pascal VIOGETBUF (PULONG pLVB,
                          PUSHORT pcbLVB,
                          HVIO hvio)
{
  return VioGetBuf(pLVB, pcbLVB, hvio);
}
void VioInit( )
{
 APIRET      rc;
 UCHAR     **cpp;
 UINT        vlen;
 UINT        row;
 VIOMODEINFO md;

 memset(&md, 0, sizeof(md) );
 md.cb = sizeof(md);

 if( VioGetMode(&md, 0) )
 {
  printf( "Vio error" );
  exit(0);
 }

 VideoRows = md.row;
 VideoCols = md.col;
 MaxPer    = VideoRows - 2 ;            /* max # of lines of Code            */
 MaxData   = VideoRows * 2 / 3;         /* max # of rows for data window     */
 MinPer    = MaxPer - MaxData;          /* min # of lines of Code            */
 ProRow    = VideoRows - 3;             /* screen row for prompt (0..N)      */
 MenuRow   = VideoRows - 3;             /* screen row for menu bar (0..N)    */
 FnameRow  = VideoRows - 2;             /* screen row for file name (0..N)   */
 HelpRow   = VideoRows - 1;             /* screen row for menu help (0..N)   */
 MsgRow    = VideoRows - 1;             /* screen row for messages (0..N)    */
 LinesPer  = MaxPer - TopLine;          /* current # of lines per screen     */
                                        /* for source                        */
 VideoMap  = vaColor;

 if( md.color == 1 )
  VideoMap = vaMono;


    rc = VioGetBuf((PULONG)&VideoPtr, (PUSHORT)&vlen, 0);
    if( rc != 0 ){
        printf( "VioGetBuf() returned %d\n", rc );
        panic(OOquit);
    }
    if( ! HiddenCursor.attr ){
        rc = VioGetCurType(&NormalCursor,0);
        if( rc != 0 ){
            printf( "VioGetCurType() returned %d\n", rc );
            panic(OOquit);  }

        /*********************************************************************/
        /* If the cursor is in insert mode when we enter here then convert   */
        /* the parms of cursorinfo into a normal mode cursor.                */
        /*********************************************************************/
        if ((NormalCursor.cEnd - NormalCursor.yStart) > 2)
          NormalCursor.yStart = NormalCursor.cEnd -
                           ((NormalCursor.cEnd - NormalCursor.yStart - 1) / 4);
        NormalCursor.yStart -= 1;                                       /*112*/
        memcpy( &InsertCursor, &NormalCursor, sizeof(InsertCursor) );   /*100*/
        InsertCursor.yStart = 0;
        memcpy( &HiddenCursor, &NormalCursor, sizeof(HiddenCursor) );   /*100*/
        HiddenCursor.attr = -1;
    }

    /*************************************************************************/
    /* - Allocate memory for screen bounds                                400*/
    /* - set the bounds to the video cols                                 400*/
    /*************************************************************************/
    BoundPtr = Talloc(VideoRows);                                   /*521 518*/
    if (BoundPtr)                                                       /*518*/
       memset(BoundPtr,VideoCols,VideoRows);                            /*518*/
    else                                                                /*518*/
    {                                                                   /*518*/
        printf( "malloc failed\n");                                     /*518*/
        panic(OOquit);                                                  /*518*/
    }                                                                   /*518*/

    VioStartOffSet = 1;
    TopLine = 1;
    MenuRow  = 0;
    LinesPer = MaxPer - TopLine;
    InitDataWinCsr();
    AccessMouse();

    HideCursor();
    ClrScr( 0, VideoRows-1, vaBptOk );
    cpp = banner;
    for( row = BANNER_ROW; *cpp; cpp++,row++ )
    {
     putrc( row, (VideoCols-strlen(*cpp)) / 2, *cpp );
    }
}
Exemple #6
0
VOID InitProg(INT iArgc, PSZ rgArgv[])
{
APIRET    rc;
BYTE      szTranslate[256];
INT       iArg;
ULONG     ulLVB;
USHORT    uscbLVB;
ULONG     ulDataSize;
ULONG     ulParmSize;
BOOL      fSetParms = FALSE;
ULONG     ulParm;


   memset(szTranslate, 0, sizeof szTranslate);

   /*
      Determine if we run in the foreground
   */
   rc = VioGetBuf(&ulLVB, &uscbLVB, (HVIO)0);
   if (rc)
      fForeGround = FALSE;
   else
      fForeGround = TRUE;

   if (fForeGround)
      printf("FAT32 cache helper version %s.\n", FAT32_VERSION);
   else
      WriteLogMessage("FAT32 task detached");

   rc = DosGetNamedSharedMem((PVOID *)&pOptions, SHAREMEM, PAG_READ|PAG_WRITE);
   if (!rc)
      {
      fActive = TRUE;
      WriteLogMessage("Shared memory found!");
      }
   else
      {
      rc = DosAllocSharedMem((PVOID *)&pOptions, SHAREMEM, sizeof (LWOPTS), PAG_COMMIT|PAG_READ|PAG_WRITE);
      if (rc)
         DosExit(EXIT_PROCESS, 1);
      memset(pOptions, 0, sizeof pOptions);
      pOptions->bLWPrio = PRTYC_IDLETIME;
      WriteLogMessage("Shared memory allocated!");
      }

   ulDataSize = sizeof f32Parms;
   rc = DosFSCtl(
      (PVOID)&f32Parms, ulDataSize, &ulDataSize,
      NULL, 0, &ulParmSize,
      FAT32_GETPARMS, "FAT32", -1, FSCTL_FSDNAME);
   if (rc)
      {
      printf("DosFSCtl, FAT32_GETPARMS failed, rc = %d\n", rc);
      DosExit(EXIT_PROCESS, 1);
      }
   if (strcmp(f32Parms.szVersion, FAT32_VERSION))
      {
      printf("ERROR: FAT32 version (%s) differs from CACHEF32 version (%s)\n", f32Parms.szVersion, FAT32_VERSION);
      DosExit(EXIT_PROCESS, 1);
      }

   for (iArg = 1; iArg < iArgc; iArg++)
      {
      strupr(rgArgv[iArg]);
      if (rgArgv[iArg][0] == '/' || rgArgv[iArg][0] == '-')
         {
         switch (rgArgv[iArg][1])
            {
            case '?' :
               printf("USAGE: CACHEF32 [options]\n");
               printf("/Q (Quit)\n");
               printf("/N do NOT load lazy write deamon.\n");
               printf("/D:diskidle in millisecs.\n");
               printf("/B:bufferidle in millisecs.\n");
               printf("/M:maxage in millisecs.\n");
               printf("/R:d:,n sets read ahead sector count for drive d: to n.\n");
               printf("/FS use short file names internally.\n");
               printf("/FL use long file names internally.\n");
               printf("/L:on|off set lazy writing on or off.\n");
               printf("/P:1|2|3|4 Set priority of Lazy writer\n");
               DosExit(EXIT_PROCESS, 0);
               break;

            case 'P':
               if (rgArgv[iArg][2] != ':')
                  {
                  printf("Missing : after /P\n");
                  DosExit(EXIT_PROCESS, 1);
                  }
               if (rgArgv[iArg][3] < '1' ||
                   rgArgv[iArg][3] > '4')
                  {
                  printf("Lazy write priority should be from 1 to 4!\n");
                  DosExit(EXIT_PROCESS, 1);
                  }
               pOptions->bLWPrio = rgArgv[iArg][3] - '0';
               break;


            case 'N':
               fLoadDeamon = FALSE;
               break;

            case 'T':
               printf("The /T option is no longer supported.\n");
               printf("Please read the documentation.\n");
               break;

            case 'Q' :
               if (fActive)
                  {
                  if (pOptions->fTerminate)
                     printf("Terminate request already set!\n");
                  pOptions->fTerminate = TRUE;
                  printf("Terminating CACHEF32.EXE...\n");
                  DosExit(EXIT_PROCESS, 0);
                  }
               printf("/Q is invalid, CACHEF32 is not running!\n");
               DosExit(EXIT_PROCESS, 1);
               break;
            case 'D':
               if (rgArgv[iArg][2] != ':')
                  {
                  printf("ERROR: missing : in %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               ulParm = atol(&rgArgv[iArg][3]);
               if (!ulParm)
                  {
                  printf("ERROR: Invalid value in %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               f32Parms.ulDiskIdle = ulParm / TIME_FACTOR;
               fSetParms = TRUE;
               break;

            case 'B':
               if (rgArgv[iArg][2] != ':')
                  {
                  printf("ERROR: missing : in %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               ulParm = atol(&rgArgv[iArg][3]);
               if (!ulParm)
                  {
                  printf("ERROR: Invalid value in %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               f32Parms.ulBufferIdle = ulParm / TIME_FACTOR;
               fSetParms = TRUE;
               break;

            case 'M':
               if (rgArgv[iArg][2] != ':')
                  {
                  printf("ERROR: missing : in %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               ulParm = atol(&rgArgv[iArg][3]);
               if (!ulParm)
                  {
                  printf("ERROR: Invalid value in %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               f32Parms.ulMaxAge = ulParm / TIME_FACTOR;
               fSetParms = TRUE;
               break;

            case 'R':
               if (rgArgv[iArg][2] != ':')
                  {
                  printf("ERROR: missing : in %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               SetRASectors(&rgArgv[iArg][3]);
               break;
            case 'F':
               if (rgArgv[iArg][2] == 'S')
                  f32Parms.fUseShortNames = TRUE;
               else if (rgArgv[iArg][2] == 'L')
                  f32Parms.fUseShortNames = FALSE;
               else
                  {
                  printf("ERROR: Unknown option %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               fSetParms = TRUE;
               break;

            case 'L':
               if (!stricmp(&rgArgv[iArg][2], ":ON"))
                  {
                  rc = DosFSCtl(NULL, 0, NULL,
                              NULL, 0, NULL,
                     FAT32_STARTLW, "FAT32", -1, FSCTL_FSDNAME);
                  if (rc)
                     printf("Warning: Lazy writing is already active or cachesize is 0!\n");
                  }
               else if (!stricmp(&rgArgv[iArg][2], ":OFF"))
                  {
                  rc = DosFSCtl(NULL, 0, NULL,
                              NULL, 0, NULL,
                     FAT32_STOPLW, "FAT32", -1, FSCTL_FSDNAME);
                  if (rc)
                     printf("Warning: Lazy writing is not active!\n");
                  }
               else
                  {
                  printf("ERROR: Unknown option %s\n", rgArgv[iArg]);
                  DosExit(EXIT_PROCESS, 1);
                  }
               break;

            default :
               printf("ERROR: Unknown option %s\n", rgArgv[iArg]);
               DosExit(EXIT_PROCESS, 1);
               break;
            }

         }
      }

   if (LoadTranslateTable())
      fSetParms = TRUE;

   if (fSetParms)
      {
      if (f32Parms.ulDiskIdle < f32Parms.ulBufferIdle)
         {
         printf("DISKIDLE must be greater than BUFFERIDLE\n");
         DosExit(EXIT_PROCESS, 1);
         }

      ulParmSize = sizeof f32Parms;
      rc = DosFSCtl(
         NULL, 0, &ulDataSize,
         (PVOID)&f32Parms, ulParmSize, &ulParmSize,
         FAT32_SETPARMS, "FAT32", -1, FSCTL_FSDNAME);
      if (rc)
         {
         printf("DosFSCtl FAT32_SETPARMS, failed, rc = %d\n", rc);
         DosExit(EXIT_PROCESS, 1);
         }
      }

   ulDriveMap = GetFAT32Drives();
   if (!fActive)
      {
      if (!ulDriveMap)
         {
         printf("FAT32: No FAT32 partitions found, aborting...\n");
         DosExit(EXIT_PROCESS, 1);
         }
      }



   /*
      Query parms
   */

   if (fActive || !f32Parms.usCacheSize)
      {
      if (fActive)
         {
         printf("CACHEF32 is already running.\n");
         printf("Current priority is %s.\n", rgPriority[pOptions->bLWPrio]);
         }

      if (!f32Parms.fLW)
         printf("LAZY WRITING is NOT active!\n\n");
      else
         {
         printf("\n");
         printf("DISKIDLE  : %lu milliseconds.\n", f32Parms.ulDiskIdle * TIME_FACTOR);
         printf("BUFFERIDLE: %lu milliseconds.\n", f32Parms.ulBufferIdle * TIME_FACTOR);
         printf("MAXAGE    : %lu milliseconds.\n", f32Parms.ulMaxAge * TIME_FACTOR);
         }

      printf("\n");
      ShowRASectors();
      printf("\n");
      printf("CACHE has space for %u sectors\n", f32Parms.usCacheSize);
      printf("CACHE contains %u sectors\n", f32Parms.usCacheUsed);
      printf("There are %u dirty sectors in cache.\n", f32Parms.usDirtySectors);
      if (f32Parms.usPendingFlush > 0)
         printf("%u sectors are in pending flush state.\n", f32Parms.usPendingFlush);
      printf("The cache hits ratio is %3d%%.\n",
         f32Parms.ulTotalHits * 100 / f32Parms.ulTotalReads);
      if (f32Parms.fUseShortNames)
         {
         printf("Internally, short names are used.\n");
         printf("All files are visible in DOS sessions.\n");
         }
      else
         {
         printf("Internally, long names are used.\n");
         printf("Files and directories with long names are hidden for DOS.\n");
         }
      printf("FAT32.IFS has currently %u GDT segments allocated.\n",
         f32Parms.usSegmentsAllocated);
      }

   return;
}