Changeset 4164 for trunk/src/win32k/misc


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

Merged in the Grace branch. New Win32k!

Location:
trunk/src/win32k/misc
Files:
13 edited

Legend:

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

    r3829 r4164  
    1 /* $Id: OS2KPTDA.c,v 1.1 2000-07-16 22:21:17 bird Exp $
     1/* $Id: OS2KPTDA.c,v 1.2 2000-09-02 21:08:12 bird Exp $
    22 *
    33 * PTDA access functions.
     
    99 */
    1010
     11/*******************************************************************************
     12*   Defined Constants And Macros                                               *
     13*******************************************************************************/
     14#define INCL_OS2KRNL_SEM
     15#define INCL_OS2KRNL_PTDA
    1116
    1217/*******************************************************************************
     
    1419*******************************************************************************/
    1520#include <os2.h>
    16 #include <OS2KPTDA.h>
     21#include <OS2Krnl.h>
    1722
    1823
     
    2833extern ULONG    pptda_start;
    2934extern ULONG    pptda_environ;
     35extern ULONG    pptda_ptdasem;
     36extern ULONG    pptda_module;
    3037
    3138
     
    3542 * @returns     Content of the pPTDA->ptda_environ member.
    3643 * @param       pPTDA   PTDA Pointer. (NULL is not allowed!)
    37  * @sketch
    3844 */
    3945USHORT  ptdaGet_ptda_environ(PPTDA pPTDA)
     
    4248}
    4349
     50
     51/**
     52 * Gets the ptda_module PTDA member. This member holds the MTE handle of the process's
     53 * executable image.
     54 * @returns     Content of the pPTDA->ptda_module member.
     55 * @param       pPTDA   PTDA Pointer. (NULL is not allowed!)
     56 */
     57USHORT  ptdaGet_ptda_module(PPTDA pPTDA)
     58{
     59    return *(PUSHORT)(void*)(((char*)(void*)pPTDA) + (pptda_module - pptda_start));
     60}
     61
     62
     63/**
     64 * Gets the ptda_ptdasem PTDA member. This member holds the intra-process semaphore which
     65 * for example is used to serialize _LDRQAppType.
     66 * @returns     Content of the pPTDA->ptda_ptdasem member.
     67 * @param       pPTDA   PTDA Pointer. (NULL is not allowed!)
     68 */
     69HKSEMMTX    ptda_ptda_ptdasem(PPTDA pPTDA)
     70{
     71    return (HKSEMMTX)(void*)(((char*)(void*)pPTDA) + (pptda_ptdasem - pptda_start));
     72}
     73
     74
     75
  • trunk/src/win32k/misc/OS2KTCB.c

    r3829 r4164  
    1 /* $Id: OS2KTCB.c,v 1.1 2000-07-16 22:21:17 bird Exp $
     1/* $Id: OS2KTCB.c,v 1.2 2000-09-02 21:08:13 bird Exp $
    22 *
    33 * TCB - Thread Control Block access methods.
     
    1515#include <os2.h>
    1616#include <OS2KTCB.h>
     17#include "devSegDf.h"                   /* Win32k segment definitions. */
    1718#include "options.h"
    1819
  • trunk/src/win32k/misc/avl.c

    r3168 r4164  
    1 /* $Id: avl.c,v 1.4 2000-03-19 16:00:11 bird Exp $
     1/* $Id: avl.c,v 1.5 2000-09-02 21:08:13 bird Exp $
    22 *
    33 * AVL-Tree (lookalike) implementation.
     
    2424*******************************************************************************/
    2525#include <os2.h>
     26#include "devSegDf.h"                   /* Win32k segment definitions. */
    2627#include "avl.h"
    2728#if defined(RING0) || defined(RING3)
  • trunk/src/win32k/misc/buffer.asm

    r2838 r4164  
    1 ; $Id: buffer.asm,v 1.5 2000-02-21 09:24:02 bird Exp $
    2 ;
    3 ; Simple resident buffer for use when overloading tkExecPgm.
     1; $Id: buffer.asm,v 1.6 2000-09-02 21:08:13 bird Exp $
     2;
     3; Simple resident buffer for use when overloading tkExecPgm - obsolete!
    44;
    55; Copyright (c) 2000 knut st. osmundsen
     
    1313;   Defined Constants And Macros
    1414;
    15 NBR_BUFFERS     EQU 20
     15NBR_BUFFERS     EQU 2
    1616BUFFER_SIZE     EQU 1536
    1717
  • trunk/src/win32k/misc/cout.cpp

    r1467 r4164  
    1 /* $Id: cout.cpp,v 1.2 1999-10-27 02:02:59 bird Exp $
     1/* $Id: cout.cpp,v 1.3 2000-09-02 21:08:13 bird Exp $
    22 *
    33 * cout - cout replacement.
     
    2525#include <stdarg.h>
    2626
     27#include "devSegDf.h"                   /* Win32k segment definitions. */
    2728#include "cout.h"
    2829#include "options.h"
  • trunk/src/win32k/misc/env.c

    r3412 r4164  
    1 /* $Id: env.c,v 1.2 2000-04-17 02:26:04 bird Exp $
     1/* $Id: env.c,v 1.3 2000-09-02 21:08:13 bird Exp $
    22 *
    33 * Environment access functions
     
    1414#define INCL_DOSERRORS                  /* Error codes */
    1515#define INCL_OS2KRNL_VM                 /* OS2KRNL: Virtual Memory Management */
    16 
     16#define INCL_OS2KRNL_PTDA               /* OS2KNRL: (per)ProcessTaskDataArea */
    1717
    1818/*******************************************************************************
     
    2121#include <os2.h>
    2222
     23#include "devSegDf.h"                   /* Win32k segment definitions. */
    2324#include "dev32.h"
    2425#include "dev32hlp.h"
    2526#include "log.h"
    26 #include "ptda.h"
    2727#include "OS2Krnl.h"
    2828#include <string.h>
    29 
     29#include "macros.h"
    3030#include "env.h"
    3131
     
    3939 * @param     paszEnv   Pointer to the environment data to search.
    4040 *                      The environment data is a list of zero-strings terminated
    41  *                      by an empty string. The strings are paired, that means
    42  *                      that the first string is the variable name and the
    43  *                      following string is the value of the variable.
    44  *                      AFAIK a variable can't have an empty value string!
    45  * @param     pszVar    Name of the environment variable to find.
     41 *                      by an empty string. The strings consists of two parts which
     42 *                      are separated by a euqal char ('='). The first part is the
     43 *                      variable name. The second part is the value of the variable.
     44 *
     45 *                      IF this is NULL we'll simply return NULL.
     46 * @param     pszVar    Name of the environment variable to find. (NULL not allowed.)
    4647 */
    4748const char *ScanEnv(const char *paszEnv, const char *pszVar)
    4849{
     50    int     cchVar;
     51    /*
     52     * Return if environment not found.
     53     */
     54    #ifdef DEBUG
     55    if (pszVar < (const char *)0x10000 || *pszVar == '\0')
     56        kprintf(("ScanEnv: Invalid parameter pszVar (%p)\n", pszVar));
     57    #endif
     58    if (paszEnv == NULL)
     59        return NULL;
     60    #ifdef DEBUG
     61    if (paszEnv < (const char *)0x10000)
     62        kprintf(("ScanEnv: Invalid parameter paszEnv (%p)\n", paszEnv));
     63    #endif
     64
    4965    /*
    5066     * Loop thru the environment data until an empty string is reached.
    5167     */
     68    cchVar = strlen(pszVar);
    5269    while (*paszEnv != '\0')
    5370    {
    54         register int i;                 /* Variable use to store the compare result. */
    55 
    5671        /*
    57          * Variable name.
    58          * Check if it's matching the name we're searching for and skip the variable name.
     72         * Check if the variable name is it's matching the one we're searching for.
    5973         */
    60         i = stricmp(paszEnv, pszVar);
    61         paszEnv += strlen(paszEnv) + 1;
    62         if (i == 0)
    63         {   /* Variable was found. Return pointer to the value. */
    64             return paszEnv;
     74        const char *pszEqual = strchr(paszEnv, '=');
     75        if (pszEqual != NULL && (pszEqual - paszEnv) == cchVar
     76            && memcmp(paszEnv, pszVar, cchVar) == 0
     77            )
     78        {
     79            /*
     80             * Variable was found. Return pointer to the value.
     81             */
     82            return pszEqual + 1;
    6583        }
    6684
    6785        /*
    68          * !Paranoia!
    69          * If no value string we'll quit. This may be an IPE, if not it might
    70          * cause one if we continue processing the environment data.
     86         * Skip this variable. (Don't use pszEqual since it might be NULL)
    7187         */
    72         if (*paszEnv == '\0')
    73             break;
    74 
    75         /* Skip value */
    7688        paszEnv += strlen(paszEnv) + 1;
    7789    }
     
    8294
    8395/**
    84  * Get the linear pointer to the environment data.
     96 * Get the linear pointer to the environment data for the current
     97 * process or the process being started (EXECed).
    8598 *
    86  * @returns   Pointer to environment data.
    87  *            NULL on failure.
     99 * @param       fExecChild      TRUE:  Get exec child environment.
     100 *                                     (Not supported by method 2)
     101 *                              FALSE: Get current process environment.
     102 * @returns     Pointer to environment data.
     103 *              NULL on failure.
    88104 */
    89 const char *GetEnv(void)
     105const char *GetEnv(BOOL fExecChild)
    90106{
    91     /*  There is probably two ways of getting the environment data for a the
     107    /*  There are probably two ways of getting the environment data for the
    92108     *  current process: 1) get it from the PTDA->ptda_environ
    93109     *                   2) Local infosegment (LIS from GetDosVar devhlp)
    94      *  I am not sure which one of these works best. What I know is that
     110     *  I am not sure which one of these which works best. What I know is that
    95111     *  method 1) is used by the w_GetEnv API worker. This API is called at
    96112     *  Ring-0 from some delete file operation. (Which uses it to get the
     
    98114     *  I don't want to thunk around using that. There for I'll implement
    99115     *  my own GetEnv. So, currently I'll write the code for both 1) and
    100      *  2), testing will show which one of them are most handy.
     116     *  2), testing will show which one of them are the better.
    101117     */
    102118
     
    116132     */
    117133    pPTDACur = ptdaGetCur();
    118     if (pPTDA != NULL)
     134    if (pPTDACur != NULL)
    119135    {
    120         pPTDA = ptdaGet_pPTDAExecChild(pPTDA);
    121         if (pPTDA != NULL)
     136        pPTDA = ptdaGet_pPTDAExecChild(pPTDACur);
     137        if (pPTDA != NULL && fExecChild)
    122138        {
    123139            hobEnviron = ptdaGet_ptda_environ(pPTDA);
     
    127143                if (rc == NO_ERROR)
    128144                    return (const char *)ulAddr;
    129                 kprintf(("GetEnv: VMObjHandleInfo failed with rc=%d for hob=0x%04x\n", rc, hobEnviron));
     145                kprintf(("GetEnv: (1) VMObjHandleInfo failed with rc=%d for hob=0x%04x \n", rc, hobEnviron));
    130146            }
    131147        }
     
    135151        {
    136152            rc = VMObjHandleInfo(hobEnviron, SSToDS(&ulAddr), SSToDS(&ushPTDA));
    137             if (rc != NO_ERROR)
    138             {
    139                 kprintf(("GetEnv: VMObjHandleInfo failed with rc=%d for hob=0x%04x\n", rc, hobEnviron));
    140             }
     153            if (rc == NO_ERROR)
     154                return (const char *)ulAddr;
     155            kprintf(("GetEnv: (2) VMObjHandleInfo failed with rc=%d for hob=0x%04x\n", rc, hobEnviron));
    141156        }
    142157    }
    143158    else
    144     {
     159    {   /* Not called at task time? No current task! */
    145160        kprintf(("GetEnv: Failed to get current PTDA.\n"));
    146161    }
    147162
    148     return (const char *)ulAddr;
     163    return NULL;
     164
    149165
    150166    #else
     167
    151168
    152169    struct InfoSegLDT * pLIS;           /* Pointer to local infosegment. */
     
    162179    {
    163180        kprintf(("GetEnv: Failed to get local info segment\n"));
     181        NOREF(fExecChild);
    164182        return NULL;
    165183    }
  • trunk/src/win32k/misc/log.c

    r847 r4164  
    1 /* $Id: log.c,v 1.1 1999-09-06 02:20:02 bird Exp $
     1/* $Id: log.c,v 1.2 2000-09-02 21:08:13 bird Exp $
    22 *
    33 * log - C-style logging - kprintf.
     
    2323#include <builtin.h>
    2424
     25#include "devSegDf.h"                   /* Win32k segment definitions. */
    2526#include "dev32.h"
    2627#include "options.h"
  • trunk/src/win32k/misc/malloc.c

    r2511 r4164  
    1 /* $Id: malloc.c,v 1.6 2000-01-24 18:19:00 bird Exp $
     1/* $Id: malloc.c,v 1.7 2000-09-02 21:08:14 bird Exp $
    22 *
    33 * Common Heap - this forwards to the swappable heap!
     
    2020******************************************************************************/
    2121#include <os2.h>
     22#include "devSegDf.h"                   /* Win32k segment definitions. */
    2223#include "smalloc.h"
    2324#include "rmalloc.h"
     
    2829*  Global data
    2930******************************************************************************/
    30 #ifndef RING0
     31#if !defined(RING0) || defined(R3TST)
    3132    char           fInited;       /* init flag */
    3233#endif
     
    5354    if (rc != 0)
    5455        return rc;
    55     #ifdef RING3
     56    #if !defined(RING0) || defined(R3TST)
    5657        fInited = TRUE;
    5758    #endif
     
    6970void * malloc(unsigned cbSize)
    7071{
     72    #ifdef R3TST
     73    if (!fInited)
     74    {
     75        PVOID pv;
     76        if (!DosAllocMem(&pv, cbSize, PAG_WRITE | PAG_READ | PAG_COMMIT)) /* no SSToDS! */
     77            return pv;
     78        else
     79            return NULL;
     80    }
     81    #endif
    7182    return smalloc(cbSize);
    7283}
     
    8192void *realloc(void *pv, unsigned cbNew)
    8293{
     94    #ifdef R3TST
     95    if (!fInited)
     96        Int3();
     97    #endif
    8398    return srealloc(pv, cbNew);
    8499}
     
    91106void free(void *pv)
    92107{
     108    #ifdef R3TST
     109    if (!fInited) /* controlled leak! */
     110       return;
     111    #endif
    93112    sfree(pv);
    94113}
     
    154173
    155174
     175
    156176#if !defined(RING0) && defined(__IBMC__)
    157177
     
    162182int _rmem_init(void)
    163183{
    164     int rc = heapInit(CB_RES_INIT, CB_RES_MAX, CB_SWP_INIT, CB_SWP_MAX);
     184    int rc;
     185    rc = heapInit(CB_RES_INIT, CB_RES_MAX, CB_SWP_INIT, CB_SWP_MAX);
    165186    return rc;
    166187}
  • trunk/src/win32k/misc/new.cpp

    r2540 r4164  
    1 /* $Id: new.cpp,v 1.4 2000-01-27 23:46:57 bird Exp $
     1/* $Id: new.cpp,v 1.5 2000-09-02 21:08:14 bird Exp $
    22 *
    33 * new - new and delete operators.
     
    2121#include <os2.h>
    2222
     23#include "devSegDf.h"                   /* Win32k segment definitions. */
    2324#include "new.h"
    2425#include "rmalloc.h"
  • trunk/src/win32k/misc/rmalloc.c

    r2507 r4164  
    1 /* $Id: rmalloc.c,v 1.3 2000-01-24 01:45:20 bird Exp $
     1/* $Id: rmalloc.c,v 1.4 2000-09-02 21:08:14 bird Exp $
    22 *
    33 * Resident Heap.
     
    5050******************************************************************************/
    5151#include <os2.h>
     52#include "devSegDf.h"                   /* Win32k segment definitions. */
    5253#ifdef RING0
    5354    #include "dev32hlp.h"
  • trunk/src/win32k/misc/rmalloc_avl.c

    r2511 r4164  
    1 /* $Id: rmalloc_avl.c,v 1.5 2000-01-24 18:19:00 bird Exp $
     1/* $Id: rmalloc_avl.c,v 1.6 2000-09-02 21:08:14 bird Exp $
    22 *
    33 * Resident Heap - AVL.
     
    4747******************************************************************************/
    4848#include <os2.h>
     49#include "devSegDf.h"                   /* Win32k segment definitions. */
    4950#ifdef RING0
    5051    #include "dev32hlp.h"
     
    120121static PHEAPANCHOR  phaFirst;           /* Pointer to the first anchor block.*/
    121122static PHEAPANCHOR  phaLast;            /* Pointer to the last anchor block.*/
    122 static unsigned     cbResHeapMax;       /* Maximum amount of memory used by the heap. */
     123unsigned            cbResHeapMax;       /* Maximum amount of memory used by the heap. */
    123124
    124125#ifndef RING0
     
    898899
    899900/**
     901 * Get amount of used memory (in bytes)
     902 * @returns  Amount of used memory (in bytes).
     903 */
     904unsigned    _res_memused(void)
     905{
     906    PHEAPANCHOR pha = phaFirst;
     907    unsigned    cb;
     908
     909    #ifdef ALLWAYS_HEAPCHECK
     910    if (!_res_heap_check())
     911        kprintf(("_res_memused: _res_heap_check failed!\n"));
     912    #endif
     913
     914    for (cb = 0; pha != NULL; pha = pha->pNext)
     915        cb += pha->cbUsed;
     916
     917    return cb;
     918}
     919
     920
     921/**
     922 * Collects the heap state.
     923 * @returns     0 on success.
     924 *              -1 on error.
     925 * @param       pState  Pointer to a RES_HEAPSTATE structure which is
     926 *                      filled upon successful return.
     927 */
     928int         _res_state(PHEAPSTATE pState)
     929{
     930    PHEAPANCHOR pha;
     931
     932    #ifdef ALLWAYS_HEAPCHECK
     933    if (!_res_heap_check())
     934    {
     935        kprintf(("_res_state: _res_heap_check failed!\n"));
     936        return -1;
     937    }
     938    #endif
     939
     940    if (pState == NULL)
     941        return -1;
     942
     943    /*
     944     * Loop thru all the anchor blocks and all memory blocks
     945     * building the stats.
     946     */
     947    memset(pState, 0, sizeof(HEAPSTATE));
     948    for (pha = phaFirst; pha != NULL; pha = pha->pNext)
     949    {
     950        AVLENUMDATA     EnumData;
     951        PAVLENUMDATA    pEnumData = SSToDS(&EnumData);
     952        PMEMBLOCK       pmb;
     953
     954        /* count of free blocks */
     955        pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbFree, pEnumData, TRUE);
     956        while (pmb)
     957        {
     958            pState->cBlocksFree++;
     959            pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData);
     960        }
     961
     962        /* count of used blocks */
     963        pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbUsed, pEnumData, TRUE);
     964        while (pmb)
     965        {
     966            pState->cBlocksUsed++;
     967            pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData);
     968        }
     969
     970        /* sizes */
     971        pState->cbHeapSize  += pha->cbSize;
     972        pState->cbHeapFree  += pha->cbFree;
     973        pState->cbHeapUsed  += pha->cbUsed;
     974    }
     975
     976    return 0;
     977}
     978
     979
     980/**
    900981 * Checks heap integrety.
    901982 * @returns  TRUE  when ok.
  • trunk/src/win32k/misc/smalloc_avl.c

    r2511 r4164  
    1 /* $Id: smalloc_avl.c,v 1.3 2000-01-24 18:19:00 bird Exp $
     1/* $Id: smalloc_avl.c,v 1.4 2000-09-02 21:08:15 bird Exp $
    22 *
    33 * Swappable Heap - AVL.
     
    5959******************************************************************************/
    6060#include <os2.h>
     61#include "devSegDf.h"                   /* Win32k segment definitions. */
    6162#ifdef RING0
    6263    #include "dev32hlp.h"
     
    140141static PHEAPANCHOR  phaFirst;           /* Pointer to the first anchor block.*/
    141142static PHEAPANCHOR  phaLast;            /* Pointer to the last anchor block.*/
    142 static unsigned     cbSwpHeapMax;       /* Maximum amount of memory used by the heap. */
    143 static PMEMBLOCKCHUNK pmcFirst;          /* Pointer to the first memblock chunk. */
     143unsigned            cbSwpHeapMax;       /* Maximum amount of memory used by the heap. */
     144static PMEMBLOCKCHUNK pmcFirst;         /* Pointer to the first memblock chunk. */
    144145
    145146#ifndef RING0
     
    10661067
    10671068    return cb;
     1069}
     1070
     1071
     1072/**
     1073 * Get amount of used memory (in bytes)
     1074 * @returns  Amount of used memory (in bytes).
     1075 */
     1076unsigned    _swp_memused(void)
     1077{
     1078    PHEAPANCHOR pha = phaFirst;
     1079    unsigned    cb;
     1080
     1081    #ifdef ALLWAYS_HEAPCHECK
     1082    if (!_swp_heap_check())
     1083        kprintf(("_swp_memused: _swp_heap_check failed!\n"));
     1084    #endif
     1085
     1086    for (cb = 0; pha != NULL; pha = pha->pNext)
     1087        cb += pha->cbUsed;
     1088
     1089    return cb;
     1090}
     1091
     1092
     1093/**
     1094 * Collects the heap state.
     1095 * @returns     0 on success.
     1096 *              -1 on error.
     1097 * @param       pState  Pointer to a HEAPSTATE structure which is
     1098 *                      filled upon successful return.
     1099 */
     1100int         _swp_state(PHEAPSTATE pState)
     1101{
     1102    PHEAPANCHOR pha;
     1103
     1104    #ifdef ALLWAYS_HEAPCHECK
     1105    if (!_res_heap_check())
     1106    {
     1107        kprintf(("_res_state: _res_heap_check failed!\n"));
     1108        return -1;
     1109    }
     1110    #endif
     1111
     1112    if (pState == NULL)
     1113        return -1;
     1114
     1115    /*
     1116     * Loop thru all the anchor blocks and all memory blocks
     1117     * building the stats.
     1118     */
     1119    memset(pState, 0, sizeof(HEAPSTATE));
     1120    for (pha = phaFirst; pha != NULL; pha = pha->pNext)
     1121    {
     1122        AVLENUMDATA     EnumData;
     1123        PAVLENUMDATA    pEnumData = SSToDS(&EnumData);
     1124        PMEMBLOCK       pmb;
     1125
     1126        /* count of free blocks */
     1127        pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pcoreFree, pEnumData, TRUE);
     1128        while (pmb)
     1129        {
     1130            pState->cBlocksFree++;
     1131            pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData);
     1132        }
     1133
     1134        /* count of used blocks */
     1135        pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pcoreUsed, pEnumData, TRUE);
     1136        while (pmb)
     1137        {
     1138            pState->cBlocksUsed++;
     1139            pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData);
     1140        }
     1141
     1142        /* sizes */
     1143        pState->cbHeapSize  += pha->cbSize;
     1144        pState->cbHeapFree  += pha->cbFree;
     1145        pState->cbHeapUsed  += pha->cbUsed;
     1146    }
     1147
     1148    return 0;
    10681149}
    10691150
  • 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.