Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

616 lines
14 KiB

  1. page,132
  2. ;---------------------------Module-Header-------------------------------;
  3. ; Module Name: CCOM.ASM
  4. ;
  5. ; Copyright (c) Microsoft Corporation 1985-1990. All Rights Reserved.
  6. ;
  7. ; History
  8. ;
  9. ; 041786 Fixed RECCOM to return be able to return nulls
  10. .xlist
  11. include cmacros.inc
  12. include comdev.inc
  13. include ibmcom.inc
  14. .list
  15. sBegin Code
  16. assumes cs,Code
  17. assumes ds,Data
  18. ;=========================================================================
  19. ;
  20. ; Communications Device Driver - C language interface module.
  21. ; This module provides an interface layer between programs written
  22. ; in C, and the low-level OEM specific communications drivers.
  23. ;
  24. ;=========================================================================
  25. externNP $CLRBRK
  26. externNP $DCBPTR
  27. externNP $EVT
  28. externNP $EVTGET
  29. externNP $EXTCOM
  30. externNP $FLUSH
  31. externNP $INICOM
  32. externNP $RECCOM
  33. externNP $RECSTR
  34. externNP $SETBRK
  35. externNP $SETCOM
  36. externNP $SETQUE
  37. externNP $SNDCOM
  38. externNP $SNDIMM
  39. externNP $STACOM
  40. externNP $TRMCOM
  41. externNP $SNDCOMSTR
  42. externNP $ENANOTIFY
  43. externNP GetDEB
  44. ;=========================================================================
  45. ;
  46. ; ushort inicom(pdcb)
  47. ; dcb far *pdcb;
  48. ;
  49. ; returns - 0 if no errors occured
  50. ; - Error Code (which is reset)
  51. ;
  52. ; Inicom is a one-time called routine to initialize. This is meant
  53. ; to be called when a process starts, or determines that it will use
  54. ; communications. Operating parameters are also passed on to setcom(),
  55. ; below.
  56. ;
  57. ; Fields within the dcb (including device id) should be set up prior to
  58. ; calling inicom.
  59. ;
  60. ; As a true device driver, this routine is to be called when the device
  61. ; driver is loaded at system start-up time. The dcb reflects the
  62. ; default operating parameters.
  63. ;
  64. ;=========================================================================
  65. assumes ds,Data
  66. assumes es,nothing
  67. cProc inicom,<PUBLIC,FAR>
  68. parmD pdcb
  69. cBegin
  70. les bx,pdcb
  71. assumes es,nothing
  72. call $INICOM
  73. cEnd
  74. page
  75. ;=========================================================================
  76. ;
  77. ; ushort setcom(pdcb)
  78. ; dcb far *pdcb;
  79. ;
  80. ; returns - 0 if no errors occured
  81. ; - Error Code (reset)
  82. ;
  83. ; Set/alter communications operating parameters. This is a non-destructive
  84. ; alteration of operating mode. Queues and interrupts are not affected.
  85. ;
  86. ;=========================================================================
  87. assumes ds,Data
  88. assumes es,nothing
  89. cProc setcom,<PUBLIC,FAR>
  90. parmD pdcb
  91. cBegin
  92. les bx,pdcb ;get pointer to dcb
  93. assumes es,nothing
  94. call $SETCOM
  95. cEnd
  96. page
  97. ;=========================================================================
  98. ;
  99. ; void setque(cid,pqdb)
  100. ; char cid;
  101. ; qdb far *pqdb;
  102. ;
  103. ; Init the locations of the receive and transmit queues that are to be
  104. ; used to buffer incomming and outgoing characters.
  105. ;
  106. ; This may be called at any time by a process to use a different set
  107. ; of queues. Characters (transmit and/or receive) may be lost if the
  108. ; queues are changed when not empty. This allows dynamic allocation
  109. ; of variable sized queues. Under DOS 4.0, the queues must be locked in
  110. ; memory.
  111. ;
  112. ; As a true device driver, the queues would be allocated at boot time,
  113. ; and must also be locked under DOS 4.0.
  114. ;
  115. ;=========================================================================
  116. assumes ds,Data
  117. assumes es,nothing
  118. cProc setque,<PUBLIC,FAR>
  119. parmB cid
  120. parmD pqdb
  121. cBegin
  122. mov ah,cid
  123. les bx,pqdb ;pointer to qdb
  124. assumes es,nothing
  125. call $SETQUE
  126. cEnd
  127. page
  128. ;=========================================================================
  129. ;
  130. ; short reccom(cid)
  131. ; char cid;
  132. ;
  133. ; Returns - character.
  134. ; - -1 if error
  135. ; - -2 if no character available
  136. ;
  137. ; Read a byte. Extracts a byte from the receive data queue. Returns
  138. ; immediately.
  139. ;=========================================================================
  140. assumes ds,Data
  141. assumes es,nothing
  142. cProc reccom,<PUBLIC,FAR>
  143. parmB cid
  144. cBegin
  145. mov ah,cid ;Id Into AH
  146. call $RECCOM ;Get char, error, or no data
  147. mov cx,ax ;Save data
  148. mov ah,0 ;Assume valid data
  149. jnz reccom5 ;Data is valid
  150. mov ax,-2 ;Assume no data available
  151. jcxz reccom5 ;No data available
  152. inc ax ;Show error (-1)
  153. reccom5:
  154. cEnd
  155. page
  156. ;=========================================================================
  157. ;
  158. ; short ReadCommString(cid, buf, cnt)
  159. ; char cid;
  160. ; LPSTR buf;
  161. ; int cnt;
  162. ;
  163. ; Returns - ax = # of bytes read
  164. ; - 0 if no character available or error
  165. ;
  166. ; Read string. Extracts bytes from the receive data queue. Returns
  167. ; immediately.
  168. ;=========================================================================
  169. assumes ds,Data
  170. assumes es,nothing
  171. cProc ReadCommString,<PUBLIC,FAR>
  172. parmB cid
  173. parmD buf
  174. parmW cnt
  175. cBegin
  176. mov ah,cid ;Id Into AH
  177. les di, buf
  178. mov cx, cnt
  179. call $RECSTR ;Get char, error, or no data
  180. jnz short recstr5 ; jmp if no error
  181. xor ax, ax
  182. recstr5:
  183. cEnd
  184. page
  185. ;=========================================================================
  186. ;
  187. ; ushort sndcom(cid,ch)
  188. ; char cid;
  189. ; char ch;
  190. ;
  191. ; Returns - 0 if no errors
  192. ; - Error Code (Not removed, i.e. stacom will return this error
  193. ; unless another occurs before the next call to stacom.)
  194. ;
  195. ; Transmit a byte. Places a byte into the transmit queue. Negative return
  196. ; indicates error.
  197. ;
  198. ;=========================================================================
  199. assumes ds,Data
  200. assumes es,nothing
  201. cProc sndcom,<PUBLIC,FAR>
  202. parmB cid
  203. parmB chr
  204. cBegin
  205. mov ah,cid
  206. mov al,chr
  207. call $SNDCOM
  208. cEnd
  209. page
  210. ;=========================================================================
  211. ;
  212. ; ushort ctx(cid,ch)
  213. ; char cid;
  214. ; char ch;
  215. ;
  216. ; Returns - 0 if no errors
  217. ; - -1 if character could not be sent.
  218. ;
  219. ; Transmit a byte "immediately". Places a byte into the transmit queue.
  220. ; or other buffer such that it is the next character picked up for
  221. ; transmission. Negative return indicates error.
  222. ;
  223. ;=========================================================================
  224. assumes ds,Data
  225. assumes es,nothing
  226. cProc ctx,<PUBLIC,FAR>
  227. parmB cid
  228. parmB chr
  229. cBegin
  230. mov ah,cid
  231. mov al,chr
  232. call $SNDIMM
  233. cEnd
  234. page
  235. ;=========================================================================
  236. ;
  237. ; void trmcom(cid)
  238. ; char cid;
  239. ;
  240. ; Terminate communications on a particular channel. Flushes the
  241. ; buffers (waits for completion), and shuts down the comm device.
  242. ;
  243. ;=========================================================================
  244. assumes ds,Data
  245. assumes es,nothing
  246. cProc trmcom,<PUBLIC,FAR>
  247. parmB cid
  248. cBegin
  249. mov ah,cid
  250. call $TRMCOM ;and go for it
  251. cEnd
  252. page
  253. ;=========================================================================
  254. ;
  255. ; ushort stacom(cid,pstat)
  256. ; char cid;
  257. ; stat far *pstat;
  258. ;
  259. ; Returns - 0 if no errors
  260. ; - Error Code
  261. ; - status structure updated.
  262. ;
  263. ; Get device status. Returns device status and input queue status.
  264. ;
  265. ;=========================================================================
  266. assumes ds,Data
  267. assumes es,nothing
  268. cProc stacom,<PUBLIC,FAR>,<si,di>
  269. parmB cid
  270. parmD pstat
  271. cBegin
  272. mov ah,cid
  273. les bx,pstat
  274. assumes es,nothing
  275. call $STACOM
  276. cEnd
  277. page
  278. ;=========================================================================
  279. ;
  280. ; dword cextfcn(cid,fcn)
  281. ; char cid;
  282. ; short fcn;
  283. ;
  284. ; Perform extended functions.
  285. ;
  286. ;=========================================================================
  287. assumes ds,Data
  288. assumes es,nothing
  289. cProc cextfcn,<PUBLIC,FAR>
  290. parmB cid
  291. parmW fcn
  292. cBegin
  293. mov ah,cid
  294. mov bx,fcn
  295. call $EXTCOM
  296. cEnd
  297. page
  298. ;=========================================================================
  299. ;
  300. ; ushort cflush(cid,q)
  301. ; ushort cid;
  302. ; ushort q;
  303. ;
  304. ; Queue flush. empties the specified queue. q=0 means transmit queue,
  305. ; 1 indicates receive queue.
  306. ;
  307. ; Returns - 0 or -1.
  308. ;
  309. ;=========================================================================
  310. assumes ds,Data
  311. assumes es,nothing
  312. cProc cflush,<PUBLIC,FAR>,<si,di>
  313. parmB cid
  314. parmB q
  315. cBegin
  316. mov ah,cid
  317. mov bh,q
  318. call $FLUSH
  319. cEnd
  320. page
  321. ;=========================================================================
  322. ;
  323. ; ushort far *cevt(cid,evtmask)
  324. ; ushort cid;
  325. ; ushort evtmask;
  326. ;
  327. ; Returns the location of a word which in which certain bits will be set
  328. ; when particular events occur. The event mask passed defines which bits
  329. ; are to be enabled. The event byte is used primarily for speed in
  330. ; determining if certain events have occurred. Returns 0 on success, -1
  331. ; for an illegal handle.
  332. ;
  333. ;=========================================================================
  334. assumes ds,Data
  335. assumes es,nothing
  336. cProc cevt,<PUBLIC,FAR>
  337. parmB cid
  338. parmW evt_mask
  339. cBegin
  340. mov ah,cid
  341. mov bx,evt_mask
  342. call $EVT ;Set the event
  343. cEnd
  344. page
  345. ;=========================================================================
  346. ;
  347. ; short cevtGet(cid, evtmask)
  348. ; ushort cid;
  349. ; ushort evtmask;
  350. ;
  351. ; The event byte set up by cevt, above, is returned. This routine must be
  352. ; used to read the event byte in order to prevent loss of an event
  353. ; occurance. Those bits set in the event mask passed are then cleared in
  354. ; the event byte.
  355. ;
  356. ;=========================================================================
  357. assumes ds,Data
  358. assumes es,nothing
  359. cProc cevtGet,<PUBLIC,FAR>
  360. parmB cid
  361. parmW evt_mask
  362. cBegin
  363. mov ah,cid
  364. mov bx,evt_mask
  365. call $EVTGET
  366. cEnd
  367. page
  368. ;=========================================================================
  369. ;
  370. ; short csetbrk(cid)
  371. ; ushort cid;
  372. ;
  373. ; Suspends character transmission, and places the transmission line in
  374. ; a break state until cclrbrk is called. Returns 0 on success, -1 if
  375. ; illegal handle.
  376. ;
  377. ;=========================================================================
  378. assumes ds,Data
  379. assumes es,nothing
  380. cProc csetbrk,<PUBLIC,FAR>,<si,di>
  381. parmB cid
  382. cBegin
  383. mov ah,cid
  384. call $SETBRK
  385. cEnd
  386. page
  387. ;=========================================================================
  388. ;
  389. ; short cclrbrk(cid)
  390. ; ushort cid;
  391. ;
  392. ; Restores the line to a non-breaking state, and restarts character
  393. ; transmission. Returns 0 on success, -1 if illegal handle.
  394. ;=========================================================================
  395. assumes ds,Data
  396. assumes es,nothing
  397. cProc cclrbrk,<PUBLIC,FAR>,<si,di>
  398. parmB cid
  399. cBegin
  400. mov ah,cid
  401. call $CLRBRK
  402. cEnd
  403. page
  404. ;=========================================================================
  405. ;
  406. ; dcb far *getdcb(cid)
  407. ; ushort cid;
  408. ;
  409. ; Returns a pointer to the dcb associated with the given id.
  410. ;
  411. ;=========================================================================
  412. assumes ds,Data
  413. assumes es,nothing
  414. cProc getdcb,<PUBLIC,FAR>,<si,di>
  415. parmB cid
  416. cBegin
  417. mov ah,cid
  418. call $DCBPTR
  419. cEnd
  420. ;=========================================================================
  421. ;
  422. ; int CommWriteString(cid, lpstring, count)
  423. ; ushort cid;
  424. ; LPSTR lpstring;
  425. ; int count;
  426. ;
  427. ; Returns # of bytes sent
  428. ;
  429. ;=========================================================================
  430. assumes ds,Data
  431. assumes es,nothing
  432. cProc CommWriteString, <FAR, PUBLIC>, <si, di>
  433. parmB cid
  434. parmD lpstring
  435. parmW count
  436. cBegin
  437. xor ax, ax
  438. mov cx, count
  439. jcxz short cws_exit
  440. mov ah, cid
  441. les di, lpstring
  442. call $SNDCOMSTR
  443. cws_exit:
  444. cEnd
  445. page
  446. ;=========================================================================
  447. ;
  448. ; bool EnableNotification(cid, hWnd, recv_trigger, send_trigger)
  449. ; ushort cid;
  450. ; WORD hWnd; /* 0, to disable notification */
  451. ; int recv_trigger;
  452. ; int send_trigger;
  453. ;
  454. ; Returns # of bytes sent
  455. ;
  456. ;=========================================================================
  457. assumes ds,Data
  458. assumes es,nothing
  459. cProc EnableNotification, <FAR, PUBLIC>, <si, di>
  460. parmB cid
  461. parmW _hWnd
  462. parmW recvT
  463. parmW sendT
  464. cBegin
  465. mov ah, [cid]
  466. mov bx, [_hWnd]
  467. mov cx, [recvT]
  468. mov dx, [sendT]
  469. call $ENANOTIFY
  470. cEnd
  471. page
  472. ;-----------------------------------------------------------------------;
  473. ; WEP
  474. ;
  475. ;
  476. ; Entry:
  477. ;
  478. ; Returns:
  479. ;
  480. ; Registers Destroyed:
  481. ;
  482. ; History:
  483. ; Sat 13-Jan-1990 18:33:48 -by- David N. Weise [davidw]
  484. ; Wrote it!
  485. ;-----------------------------------------------------------------------;
  486. assumes ds,nothing
  487. assumes es,nothing
  488. cProc WEP,<PUBLIC,FAR>
  489. cBegin nogen
  490. nop ; You don't want to know why.
  491. mov ax,1
  492. ret 2
  493. cEnd nogen
  494. sEnd Code
  495. end