Ignore:
Timestamp:
Sep 2, 2000, 11:08:23 PM (25 years ago)
Author:
bird
Message:

Merged in the Grace branch. New Win32k!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/misc/vprintf.c

    r2501 r4164  
    1 /* $Id: vprintf.c,v 1.7 2000-01-22 18:21:03 bird Exp $
     1/* $Id: vprintf.c,v 1.8 2000-09-02 21:08:15 bird Exp $
    22 *
    33 * vprintf and printf
     
    2525
    2626
    27 #ifdef RING0
     27
     28#if defined(RING0) && !defined(R3TST)
     29    #define COMOUTPUT
     30#endif
     31#if !defined(RING0) || defined(R3TST)
     32    #define DOSWRITEOUTPUT
     33#endif
     34
     35#ifndef DOSWRITEOUTPUT
    2836    #define INCL_NOAPI
    2937#else
     
    3947#include <stdarg.h>
    4048
     49#include "devSegDf.h"                   /* Win32k segment definitions. */
    4150#include "dev32.h"
    4251#include "vprintf.h"
     52#ifdef COMOUTPUT
     53    #include <builtin.h>
     54#endif
    4355#ifdef RING0
    44     #include <builtin.h>
    4556    #include "options.h"
    4657#endif
     
    222233int vprintf(const char *pszFormat, va_list args)
    223234{
    224     #ifdef RING0
     235    #if defined(RING0) && !defined(R3TST)
    225236    if (!options.fLogging)
    226237        return 0;
     
    239250int vprintf2(const char *pszFormat, va_list args)
    240251{
    241     #ifndef RING0
    242         int cch = 0;
    243     #endif
     252    int cch = 0;
    244253
    245254    while (*pszFormat != '\0')
     
    247256        if (*pszFormat == '%')
    248257        {
    249             #ifndef RING0
    250                 if (cch > 0)
    251                 {
    252                     strout((char*)(pszFormat - cch), cch);
    253                     cch = 0;
    254                 }
    255             #endif
     258            if (cch > 0)
     259            {
     260                strout((char*)(pszFormat - cch), cch);
     261                cch = 0;
     262            }
    256263
    257264            pszFormat++;  /* skip '%' */
     
    396403        else
    397404        {
    398             #ifdef RING0
    399                 chout(*pszFormat++);
    400             #else
    401                 cch++;
    402                 pszFormat++;
    403             #endif
    404         }
    405     }
    406 
    407     #ifndef RING0
    408         if (cch > 0)
    409         {
    410             strout((char*)(pszFormat - cch), cch);
    411             cch = 0;
    412         }
    413     #endif
     405            cch++;
     406            pszFormat++;
     407        }
     408    }
     409
     410    if (cch > 0)
     411    {
     412        strout((char*)(pszFormat - cch), cch);
     413        cch = 0;
     414    }
    414415
    415416    return 0UL;
     
    479480static void chout(int ch)
    480481{
    481     #ifndef RING0
    482         ULONG ulWrote;
    483     #endif
     482#ifdef DOSWRITEOUTPUT
     483    ULONG ulWrote;
     484#endif
    484485
    485486    if (ch != '\r')
     
    487488        if (ch == '\n')
    488489        {
    489             #ifdef RING0
    490                 #pragma info(noeff)
    491                 while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    492                 _outp(options.usCom, chReturn);             /* Put the char. */
    493                 #pragma info(restore)
    494             #else
    495                 DosWrite(1, (void*)&chReturn, 1, &ulWrote);
    496             #endif
    497         }
    498         #ifdef RING0
     490        #ifdef COMOUTPUT
    499491            #pragma info(noeff)
    500492            while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    501             _outp(options.usCom, ch);                   /* Put the char. */
     493            _outp(options.usCom, chReturn);             /* Put the char. */
    502494            #pragma info(restore)
    503             Yield();
    504         #else
    505             DosWrite(1, (void*)&ch, 1, &ulWrote);
    506495        #endif
     496        #ifdef DOSWRITEOUTPUT
     497            DosWrite(1, (void*)&chReturn, 1, SSToDS(&ulWrote));
     498        #endif
     499        }
     500    #ifdef COMOUTPUT
     501        #pragma info(noeff)
     502        while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     503        _outp(options.usCom, ch);                   /* Put the char. */
     504        #pragma info(restore)
     505        Yield();
     506    #endif
     507    #ifdef DOSWRITEOUTPUT
     508        DosWrite(1, SSToDS(&ch), 1, SSToDS(&ulWrote));
     509    #endif
    507510    }
    508511}
     
    529532
    530533        /* write string part */
    531         #ifdef RING0
    532             for (ul = 0; ul < cch; ul++)
    533             {
    534                 #pragma info(noeff)
    535                 while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    536                 _outp(options.usCom, psz[ul]);              /* Put the char. */
    537                 #pragma info(restore)
    538             }
    539         #else
    540             DosWrite(1, (void*)psz, cch, &ul);
    541         #endif
     534    #ifdef COMOUTPUT
     535        for (ul = 0; ul < cch; ul++)
     536        {
     537            #pragma info(noeff)
     538            while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     539            _outp(options.usCom, psz[ul]);              /* Put the char. */
     540            #pragma info(restore)
     541        }
     542    #endif
     543    #ifdef DOSWRITEOUTPUT
     544        DosWrite(1, psz, cch, SSToDS(&ul));
     545    #endif
    542546
    543547        /* cr and lf check + skip */
    544         if (psz[cch] == '\n' || psz[cch] == '\r')
     548        if (cch < cchMax && (psz[cch] == '\n' || psz[cch] == '\r'))
    545549        {
    546550            if (psz[cch] == '\n')
    547551            {
    548             #ifdef RING0
     552            #ifdef COMOUTPUT
    549553                #pragma info(noeff)
    550554                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     
    552556                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    553557                _outp(options.usCom, chNewLine);            /* Put the char. */
    554                 cchYield ++;
     558                cchYield++;
    555559                #pragma info(restore)
    556             #else
    557                 DosWrite(1, (void*)&chReturn, 1, &ul);
    558                 DosWrite(1, (void*)&chNewLine, 1, &ul);
     560            #endif
     561            #ifdef DOSWRITEOUTPUT
     562                DosWrite(1, (void*)&chReturn, 1, SSToDS(&ul));
     563                DosWrite(1, (void*)&chNewLine, 1, SSToDS(&ul));
    559564            #endif
    560565
Note: See TracChangeset for help on using the changeset viewer.