wok view linld/stuff/src/XMM.ASM @ rev 20142

linld: tiny shrink
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 11 10:57:19 2017 +0100 (2017-11-11)
parents a7fbb1c5c71a
children c0625ff5d49b
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 ifdef NO386
9 p8086
10 else
11 p386
12 endif
14 group DGROUP _TEXT,_BSS
15 assume cs:DGROUP,ds:DGROUP
17 segment _BSS byte public use16 'BSS'
19 global xmm_handler:dword
20 xmm_handler dd ?
22 ends _BSS
24 segment _TEXT byte public use16 'CODE'
26 ;***************************************************************
27 ;void enable_a20_xmm();
28 ;***************************************************************
29 global _enable_a20_xmm:near
30 proc _enable_a20_xmm near
32 mov ah,03h ;global enable a20
33 call xmm_driver ;
34 mov ah,05h ;local enable a20
35 ;jmp xmm_driver ;
37 endp _enable_a20_xmm
39 ;***************************************************************
40 ;Call xmm driver addr or 0 if no xmm
41 ;void xmm_driver(ah)
42 ;***************************************************************
43 global xmm_driver:near
44 proc xmm_driver near
46 push si
47 mov si,offset xmm_handler
48 ifndef NO386
49 cmp [dword si],0
50 else
51 mov ax,[word si]
52 or ax,[word si+2]
53 endif
54 jne @@gotit
56 xchg ax,cx ; save cmd
57 mov ax,4300h ; installation check in al
58 int 2fh
59 mov bx,offset xmm_fail
60 push cs
61 pop es
62 cmp al,80h
63 jne @@err
64 mov ax,4310h ; get driver address in es:bx
65 int 2fh
66 @@err:
67 xchg ax,cx ; restore cmd
68 push es
69 push bx
70 pop [dword si]
71 @@gotit:
72 call [dword si]
73 dec ax ; Z=1=OK
74 pop si
75 ret
76 xmm_fail:
77 xor ax,ax
78 cwd
79 retf
81 endp xmm_driver
84 struc image_himem ;struct image_himem {
85 fd dw ? ; 0 int fd;
86 fallback dd ? ; 2 u32 fallback;
87 size dd ? ; 6 u32 size;
88 remaining dd ? ;10 u32 remaining;
89 buf dd ? ;14 u32 buf;
90 bufv dw ? ;18 u32 *bufv;
91 errmsg dw ? ;20 char *errmsg;
92 chunk_size dd ? ;22 u32 chunk_size;
93 next_chunk dw ? ;26 void (*next_chunk)(struct image_himem *);
94 state dw ? ;28 u16 state;
95 fd2close dw ? ;30 u16 fd2close;
96 ends ;};
98 ;***************************************************************
99 ;void xmm_alloc(struct image_himem *m)
100 ;***************************************************************
101 global _xmm_alloc:near
102 proc _xmm_alloc near
104 pop ax
105 pop bx
106 push bx
107 push ax
108 ifndef NO386
109 mov edx,[(image_himem bx).size] ; m->size
110 ;dec edx
111 shr edx,10 ; to Kb
112 else
113 ;mov ax,-1
114 ;cwd
115 ;add ax,[word (image_himem bx).size] ; lo m->size
116 ;adc dx,[word (image_himem bx+2).size] ; hi m->size
117 mov ax,[word (image_himem bx).size] ; lo m->size
118 mov dx,[word (image_himem bx+2).size] ; hi m->size
119 mov cl,16-10
120 extrn N_LXLSH@:near
121 call N_LXLSH@
122 endif
123 inc dx
124 push bx
125 mov ah,09h ;allocate blk of DX kilobytes
126 call xmm_driver ;
127 jnz @@goerr
128 ;now: dx=handle of the blk
129 mov ah,0Ch ;lock blk
130 call xmm_driver ;
131 ;now: dx:bx=addr of blk
132 xchg ax,bx
133 @@goerr:
134 pop bx
135 jnz @@err
136 mov [word (image_himem bx).buf],ax ; lo m->buf
137 mov [word (image_himem bx+2).buf],dx ; hi m->buf
138 @@err:
139 ret
141 endp _xmm_alloc
143 ends _TEXT
145 end
147 ;###### END OF FILE ############################################