Changeset 4164 for trunk/src/win32k/misc
- Timestamp:
- Sep 2, 2000, 11:08:23 PM (25 years ago)
- 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:17bird Exp $1 /* $Id: OS2KPTDA.c,v 1.2 2000-09-02 21:08:12 bird Exp $ 2 2 * 3 3 * PTDA access functions. … … 9 9 */ 10 10 11 /******************************************************************************* 12 * Defined Constants And Macros * 13 *******************************************************************************/ 14 #define INCL_OS2KRNL_SEM 15 #define INCL_OS2KRNL_PTDA 11 16 12 17 /******************************************************************************* … … 14 19 *******************************************************************************/ 15 20 #include <os2.h> 16 #include <OS2K PTDA.h>21 #include <OS2Krnl.h> 17 22 18 23 … … 28 33 extern ULONG pptda_start; 29 34 extern ULONG pptda_environ; 35 extern ULONG pptda_ptdasem; 36 extern ULONG pptda_module; 30 37 31 38 … … 35 42 * @returns Content of the pPTDA->ptda_environ member. 36 43 * @param pPTDA PTDA Pointer. (NULL is not allowed!) 37 * @sketch38 44 */ 39 45 USHORT ptdaGet_ptda_environ(PPTDA pPTDA) … … 42 48 } 43 49 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 */ 57 USHORT 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 */ 69 HKSEMMTX 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:17bird Exp $1 /* $Id: OS2KTCB.c,v 1.2 2000-09-02 21:08:13 bird Exp $ 2 2 * 3 3 * TCB - Thread Control Block access methods. … … 15 15 #include <os2.h> 16 16 #include <OS2KTCB.h> 17 #include "devSegDf.h" /* Win32k segment definitions. */ 17 18 #include "options.h" 18 19 -
trunk/src/win32k/misc/avl.c
r3168 r4164 1 /* $Id: avl.c,v 1. 4 2000-03-19 16:00:11bird Exp $1 /* $Id: avl.c,v 1.5 2000-09-02 21:08:13 bird Exp $ 2 2 * 3 3 * AVL-Tree (lookalike) implementation. … … 24 24 *******************************************************************************/ 25 25 #include <os2.h> 26 #include "devSegDf.h" /* Win32k segment definitions. */ 26 27 #include "avl.h" 27 28 #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:02bird 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! 4 4 ; 5 5 ; Copyright (c) 2000 knut st. osmundsen … … 13 13 ; Defined Constants And Macros 14 14 ; 15 NBR_BUFFERS EQU 2 015 NBR_BUFFERS EQU 2 16 16 BUFFER_SIZE EQU 1536 17 17 -
trunk/src/win32k/misc/cout.cpp
r1467 r4164 1 /* $Id: cout.cpp,v 1. 2 1999-10-27 02:02:59bird Exp $1 /* $Id: cout.cpp,v 1.3 2000-09-02 21:08:13 bird Exp $ 2 2 * 3 3 * cout - cout replacement. … … 25 25 #include <stdarg.h> 26 26 27 #include "devSegDf.h" /* Win32k segment definitions. */ 27 28 #include "cout.h" 28 29 #include "options.h" -
trunk/src/win32k/misc/env.c
r3412 r4164 1 /* $Id: env.c,v 1. 2 2000-04-17 02:26:04bird Exp $1 /* $Id: env.c,v 1.3 2000-09-02 21:08:13 bird Exp $ 2 2 * 3 3 * Environment access functions … … 14 14 #define INCL_DOSERRORS /* Error codes */ 15 15 #define INCL_OS2KRNL_VM /* OS2KRNL: Virtual Memory Management */ 16 16 #define INCL_OS2KRNL_PTDA /* OS2KNRL: (per)ProcessTaskDataArea */ 17 17 18 18 /******************************************************************************* … … 21 21 #include <os2.h> 22 22 23 #include "devSegDf.h" /* Win32k segment definitions. */ 23 24 #include "dev32.h" 24 25 #include "dev32hlp.h" 25 26 #include "log.h" 26 #include "ptda.h"27 27 #include "OS2Krnl.h" 28 28 #include <string.h> 29 29 #include "macros.h" 30 30 #include "env.h" 31 31 … … 39 39 * @param paszEnv Pointer to the environment data to search. 40 40 * 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.) 46 47 */ 47 48 const char *ScanEnv(const char *paszEnv, const char *pszVar) 48 49 { 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 49 65 /* 50 66 * Loop thru the environment data until an empty string is reached. 51 67 */ 68 cchVar = strlen(pszVar); 52 69 while (*paszEnv != '\0') 53 70 { 54 register int i; /* Variable use to store the compare result. */55 56 71 /* 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. 59 73 */ 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; 65 83 } 66 84 67 85 /* 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) 71 87 */ 72 if (*paszEnv == '\0')73 break;74 75 /* Skip value */76 88 paszEnv += strlen(paszEnv) + 1; 77 89 } … … 82 94 83 95 /** 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). 85 98 * 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. 88 104 */ 89 const char *GetEnv( void)105 const char *GetEnv(BOOL fExecChild) 90 106 { 91 /* There is probably two ways of getting the environment data for athe107 /* There are probably two ways of getting the environment data for the 92 108 * current process: 1) get it from the PTDA->ptda_environ 93 109 * 2) Local infosegment (LIS from GetDosVar devhlp) 94 * I am not sure which one of these w orks best. What I know is that110 * I am not sure which one of these which works best. What I know is that 95 111 * method 1) is used by the w_GetEnv API worker. This API is called at 96 112 * Ring-0 from some delete file operation. (Which uses it to get the … … 98 114 * I don't want to thunk around using that. There for I'll implement 99 115 * 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. 101 117 */ 102 118 … … 116 132 */ 117 133 pPTDACur = ptdaGetCur(); 118 if (pPTDA != NULL)134 if (pPTDACur != NULL) 119 135 { 120 pPTDA = ptdaGet_pPTDAExecChild(pPTDA );121 if (pPTDA != NULL )136 pPTDA = ptdaGet_pPTDAExecChild(pPTDACur); 137 if (pPTDA != NULL && fExecChild) 122 138 { 123 139 hobEnviron = ptdaGet_ptda_environ(pPTDA); … … 127 143 if (rc == NO_ERROR) 128 144 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)); 130 146 } 131 147 } … … 135 151 { 136 152 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)); 141 156 } 142 157 } 143 158 else 144 { 159 { /* Not called at task time? No current task! */ 145 160 kprintf(("GetEnv: Failed to get current PTDA.\n")); 146 161 } 147 162 148 return (const char *)ulAddr; 163 return NULL; 164 149 165 150 166 #else 167 151 168 152 169 struct InfoSegLDT * pLIS; /* Pointer to local infosegment. */ … … 162 179 { 163 180 kprintf(("GetEnv: Failed to get local info segment\n")); 181 NOREF(fExecChild); 164 182 return NULL; 165 183 } -
trunk/src/win32k/misc/log.c
r847 r4164 1 /* $Id: log.c,v 1. 1 1999-09-06 02:20:02bird Exp $1 /* $Id: log.c,v 1.2 2000-09-02 21:08:13 bird Exp $ 2 2 * 3 3 * log - C-style logging - kprintf. … … 23 23 #include <builtin.h> 24 24 25 #include "devSegDf.h" /* Win32k segment definitions. */ 25 26 #include "dev32.h" 26 27 #include "options.h" -
trunk/src/win32k/misc/malloc.c
r2511 r4164 1 /* $Id: malloc.c,v 1. 6 2000-01-24 18:19:00bird Exp $1 /* $Id: malloc.c,v 1.7 2000-09-02 21:08:14 bird Exp $ 2 2 * 3 3 * Common Heap - this forwards to the swappable heap! … … 20 20 ******************************************************************************/ 21 21 #include <os2.h> 22 #include "devSegDf.h" /* Win32k segment definitions. */ 22 23 #include "smalloc.h" 23 24 #include "rmalloc.h" … … 28 29 * Global data 29 30 ******************************************************************************/ 30 #if ndef RING031 #if !defined(RING0) || defined(R3TST) 31 32 char fInited; /* init flag */ 32 33 #endif … … 53 54 if (rc != 0) 54 55 return rc; 55 #if def RING356 #if !defined(RING0) || defined(R3TST) 56 57 fInited = TRUE; 57 58 #endif … … 69 70 void * malloc(unsigned cbSize) 70 71 { 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 71 82 return smalloc(cbSize); 72 83 } … … 81 92 void *realloc(void *pv, unsigned cbNew) 82 93 { 94 #ifdef R3TST 95 if (!fInited) 96 Int3(); 97 #endif 83 98 return srealloc(pv, cbNew); 84 99 } … … 91 106 void free(void *pv) 92 107 { 108 #ifdef R3TST 109 if (!fInited) /* controlled leak! */ 110 return; 111 #endif 93 112 sfree(pv); 94 113 } … … 154 173 155 174 175 156 176 #if !defined(RING0) && defined(__IBMC__) 157 177 … … 162 182 int _rmem_init(void) 163 183 { 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); 165 186 return rc; 166 187 } -
trunk/src/win32k/misc/new.cpp
r2540 r4164 1 /* $Id: new.cpp,v 1. 4 2000-01-27 23:46:57bird Exp $1 /* $Id: new.cpp,v 1.5 2000-09-02 21:08:14 bird Exp $ 2 2 * 3 3 * new - new and delete operators. … … 21 21 #include <os2.h> 22 22 23 #include "devSegDf.h" /* Win32k segment definitions. */ 23 24 #include "new.h" 24 25 #include "rmalloc.h" -
trunk/src/win32k/misc/rmalloc.c
r2507 r4164 1 /* $Id: rmalloc.c,v 1. 3 2000-01-24 01:45:20bird Exp $1 /* $Id: rmalloc.c,v 1.4 2000-09-02 21:08:14 bird Exp $ 2 2 * 3 3 * Resident Heap. … … 50 50 ******************************************************************************/ 51 51 #include <os2.h> 52 #include "devSegDf.h" /* Win32k segment definitions. */ 52 53 #ifdef RING0 53 54 #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:00bird Exp $1 /* $Id: rmalloc_avl.c,v 1.6 2000-09-02 21:08:14 bird Exp $ 2 2 * 3 3 * Resident Heap - AVL. … … 47 47 ******************************************************************************/ 48 48 #include <os2.h> 49 #include "devSegDf.h" /* Win32k segment definitions. */ 49 50 #ifdef RING0 50 51 #include "dev32hlp.h" … … 120 121 static PHEAPANCHOR phaFirst; /* Pointer to the first anchor block.*/ 121 122 static PHEAPANCHOR phaLast; /* Pointer to the last anchor block.*/ 122 static unsignedcbResHeapMax; /* Maximum amount of memory used by the heap. */123 unsigned cbResHeapMax; /* Maximum amount of memory used by the heap. */ 123 124 124 125 #ifndef RING0 … … 898 899 899 900 /** 901 * Get amount of used memory (in bytes) 902 * @returns Amount of used memory (in bytes). 903 */ 904 unsigned _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 */ 928 int _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 /** 900 981 * Checks heap integrety. 901 982 * @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:00bird Exp $1 /* $Id: smalloc_avl.c,v 1.4 2000-09-02 21:08:15 bird Exp $ 2 2 * 3 3 * Swappable Heap - AVL. … … 59 59 ******************************************************************************/ 60 60 #include <os2.h> 61 #include "devSegDf.h" /* Win32k segment definitions. */ 61 62 #ifdef RING0 62 63 #include "dev32hlp.h" … … 140 141 static PHEAPANCHOR phaFirst; /* Pointer to the first anchor block.*/ 141 142 static PHEAPANCHOR phaLast; /* Pointer to the last anchor block.*/ 142 static unsignedcbSwpHeapMax; /* Maximum amount of memory used by the heap. */143 static PMEMBLOCKCHUNK pmcFirst; 143 unsigned cbSwpHeapMax; /* Maximum amount of memory used by the heap. */ 144 static PMEMBLOCKCHUNK pmcFirst; /* Pointer to the first memblock chunk. */ 144 145 145 146 #ifndef RING0 … … 1066 1067 1067 1068 return cb; 1069 } 1070 1071 1072 /** 1073 * Get amount of used memory (in bytes) 1074 * @returns Amount of used memory (in bytes). 1075 */ 1076 unsigned _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 */ 1100 int _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; 1068 1149 } 1069 1150 -
trunk/src/win32k/misc/vprintf.c
r2501 r4164 1 /* $Id: vprintf.c,v 1. 7 2000-01-22 18:21:03bird Exp $1 /* $Id: vprintf.c,v 1.8 2000-09-02 21:08:15 bird Exp $ 2 2 * 3 3 * vprintf and printf … … 25 25 26 26 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 28 36 #define INCL_NOAPI 29 37 #else … … 39 47 #include <stdarg.h> 40 48 49 #include "devSegDf.h" /* Win32k segment definitions. */ 41 50 #include "dev32.h" 42 51 #include "vprintf.h" 52 #ifdef COMOUTPUT 53 #include <builtin.h> 54 #endif 43 55 #ifdef RING0 44 #include <builtin.h>45 56 #include "options.h" 46 57 #endif … … 222 233 int vprintf(const char *pszFormat, va_list args) 223 234 { 224 #if def RING0235 #if defined(RING0) && !defined(R3TST) 225 236 if (!options.fLogging) 226 237 return 0; … … 239 250 int vprintf2(const char *pszFormat, va_list args) 240 251 { 241 #ifndef RING0 242 int cch = 0; 243 #endif 252 int cch = 0; 244 253 245 254 while (*pszFormat != '\0') … … 247 256 if (*pszFormat == '%') 248 257 { 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 } 256 263 257 264 pszFormat++; /* skip '%' */ … … 396 403 else 397 404 { 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 } 414 415 415 416 return 0UL; … … 479 480 static void chout(int ch) 480 481 { 481 #ifndef RING0 482 483 482 #ifdef DOSWRITEOUTPUT 483 ULONG ulWrote; 484 #endif 484 485 485 486 if (ch != '\r') … … 487 488 if (ch == '\n') 488 489 { 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 499 491 #pragma info(noeff) 500 492 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. */ 502 494 #pragma info(restore) 503 Yield();504 #else505 DosWrite(1, (void*)&ch, 1, &ulWrote);506 495 #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 507 510 } 508 511 } … … 529 532 530 533 /* 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 542 546 543 547 /* cr and lf check + skip */ 544 if ( psz[cch] == '\n' || psz[cch] == '\r')548 if (cch < cchMax && (psz[cch] == '\n' || psz[cch] == '\r')) 545 549 { 546 550 if (psz[cch] == '\n') 547 551 { 548 #ifdef RING0552 #ifdef COMOUTPUT 549 553 #pragma info(noeff) 550 554 while (!(_inp(options.usCom + 5) & 0x20)); /* Waits for the port to be ready. */ … … 552 556 while (!(_inp(options.usCom + 5) & 0x20)); /* Waits for the port to be ready. */ 553 557 _outp(options.usCom, chNewLine); /* Put the char. */ 554 cchYield 558 cchYield++; 555 559 #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)); 559 564 #endif 560 565
Note:
See TracChangeset
for help on using the changeset viewer.