source: trunk/src/win32k/misc/buffer.asm@ 2819

Last change on this file since 2819 was 2819, checked in by bird, 26 years ago

Simple (but scalable) bufferingsystem for use when overloading tkExecPgm.
Initial coding.

File size: 3.6 KB
Line 
1; $Id: buffer.asm,v 1.1 2000-02-18 14:55:08 bird Exp $
2;
3; Simple resident buffer for use when overloading tkExecPgm.
4;
5; Copyright (c) 2000 knut st. osmundsen
6;
7; Project Odin Software License can be found in LICENSE.TXT
8;
9 .486p
10
11;
12; Include files
13;
14 include devsegdf.inc
15
16;
17; Exported symbols
18;
19 public AcquireBuffer
20 public ReleaseBuffer
21 public cbBuffer
22
23
24;
25; Global Variables
26;
27DATA32 segment
28fBuffer db 0 ;Access "semaphore"
29cbBuffer db 4096
30achBuffer db 4096 dup(?)
31DATA32 ends
32
33
34CODE32 segment
35 assume CS:CODE32, DS:NOTHING, SS:NOTHING
36
37;;
38; Aquires a resident buffer. (intended use for tkExecPgm)
39; @cproto assembly only for time being.
40; @returns Pointer to buffer
41; @uses eax
42; @sketch if fBuffer == 0 then
43; ok!
44; fBuffer <- 1
45; return pointer to buffer
46; else
47; fail
48; return NULL
49; endif
50; @status completely implemented.
51; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
52; @remark cbBuffer holds the size of the buffer.
53AcquireBuffer PROC NEAR
54 push ds
55 mov ax, FLAT
56 mov ds, ax
57 ASSUME DS:FLAT
58 mov al, 0
59 mov ah, 1
60 lock cmpxchg fBuffer, ah
61 jnz AcquireBuffer_nok
62AcquireBuffer_ok:
63 mov eax, offset achBuffer
64 pop ds
65 ret
66AcquireBuffer_nok:
67 xor eax,eax
68 pop ds
69 ret
70AcquireBuffer ENDP
71
72;;
73; Release the resident buffer pointed to by eax from use.
74; @cproto assembly only for time being.
75; @returns 0 on success, 87 on error.
76; @param eax Pointer to buffer.
77; @uses eax
78; @equiv
79; @sketch if eax == achBuffer then
80; set fBuffer to 0 if 1.
81; if fBuffer was not 1 then fail with rc = 87!
82; else
83; fail with rc = 87
84; endif
85; @status
86; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
87; @remark
88ReleaseBuffer PROC NEAR
89 ASSUME DS:NOTHING
90 push ds
91 mov ax, FLAT
92 mov ds, ax
93 ASSUME DS:FLAT
94 cmp eax, offset achBuffer
95 jne ReleaseBuffer_nok
96 mov al, 1
97 mov ah, 0
98 lock cmpxchg fBuffer, ah
99 jnz ReleaseBuffer_nok
100ReleaseBuffer_ok:
101 xor eax, eax
102 pop ds
103 ret
104ReleaseBuffer_nok:
105 mov eax, 87 ;some error
106 pop ds
107 ret
108ReleaseBuffer ENDP
109
110
111;;
112; Gets the 16-bit segment and offset for this buffer.
113; @cproto assembly only for time being.
114; @returns segment in es and offset in eax
115; On error high word of eax is 87.
116; @param eax Buffer pointer.
117; @uses eax, es
118; @status completely implemented.
119; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
120; @remark cbBuffer holds the size of the buffer.
121QueryBufferSegmentOffset PROC NEAR
122 ASSUME DS:NOTHING
123 push ds
124 mov ax, FLAT
125 mov ds, ax
126 ASSUME DS:FLAT
127 cmp eax, offset achBuffer
128 jne QueryBufferSegmentOffset_nok
129 cmp fBuffer, 1
130 jne QueryBufferSegmentOffset_nok
131
132QueryBufferSegmentOffset_ok:
133 xor eax, eax
134 jmp far ptr CODE16:GetBufferSegmentOffset16
135QueryBufferSegmentOffset_Back::
136 pop ds
137 ret
138
139QueryBufferSegmentOffset_nok:
140 mov eax, 00570000h
141 pop ds
142 ret
143QueryBufferSegmentOffset ENDP
144
145
146CODE32 ENDS
147
148CODE16 SEGMENT
149
150;;
151; Gets the segment(->es) and offset(->ax) of the achBuffer.
152; Jumps back to GetBufferOffset32
153GetBufferSegmentOffset16:
154 ASSUME CS:CODE16, DS:FLAT
155 mov ax, seg achBuffer
156 mov es, ax
157 mov ax, offset achBuffer
158 jmp far ptr FLAT:QueryBufferSegmentOffset_Back
159CODE16 ENDS
160
161END
162
Note: See TracBrowser for help on using the repository browser.