source: GPL/branches/uniaud32-2.1.x/drv32/read.cpp@ 504

Last change on this file since 504 was 504, checked in by David Azarewicz, 15 years ago

Bring branch up-to-date with trunk

File size: 1.5 KB
Line 
1#define INCL_NOPMAPI
2#include <os2.h>
3#include <devhelp.h>
4#include <devrp.h>
5#include <dbgos2.h>
6#include <string.h> // memcpy
7
8extern "C" {
9
10int rdOffset= 0;
11int wrOffset= 0;
12char *szprintBuf= 0;
13
14void * __ioremap(unsigned long physaddr, unsigned long size, unsigned long flags);
15void iounmap(void *addr);
16
17}
18
19ULONG StratRead(RP __far* _rp)
20{
21 RPRWV __far* rp = (RPRWV __far*)_rp;
22
23 char *lin;
24 int transferCount= rp->Count;
25
26 if( szprintBuf )
27 {
28 lin= (char *)__ioremap( rp->Transfer, transferCount, 0 );
29 if( lin )
30 {
31 int diffCount;
32
33 if( rdOffset > wrOffset )
34 {
35 diffCount= DBG_MAX_BUF_SIZE - rdOffset + wrOffset;
36 } else
37 {
38 diffCount= wrOffset - rdOffset;
39 }
40 if( transferCount > diffCount )
41 transferCount= diffCount;
42
43 rp->Count= transferCount;
44 if( (rdOffset + transferCount) > DBG_MAX_BUF_SIZE )
45 {
46 diffCount= DBG_MAX_BUF_SIZE - rdOffset;
47 memcpy( lin, szprintBuf + rdOffset, diffCount );
48 transferCount= transferCount - diffCount;
49 rdOffset= 0;
50 } else
51 diffCount= 0;
52
53 if( transferCount )
54 {
55 memcpy( lin + diffCount, szprintBuf + rdOffset, transferCount );
56 rdOffset= rdOffset + transferCount;
57 }
58 iounmap( (void *)lin );
59 return RPDONE;
60 } else
61 return RPDONE | RPERR;
62 } else
63 {
64 rp->Count= 0;
65 return RPDONE;
66 }
67}
Note: See TracBrowser for help on using the repository browser.