wok view linld/stuff/src/_ISOBEG.ASM @ rev 23811

linld/isoboot: canonicalize filename
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 25 16:38:34 2020 +0000 (2020-05-25)
parents d70f7cc6e3ac
children 31a47c12da10
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %PAGESIZE 1000
6 %crefref
7 %noincl
8 %nomacs
9 p8086
11 group DGROUP _TEXT,_DATA,_BSS
12 assume cs:DGROUP,ds:DGROUP
14 segment _TEXT byte public use16 'CODE'
15 ends _TEXT
17 segment _DATA byte public use16 'DATA'
18 global _data_start:byte
19 label _data_start byte
20 ends _DATA
22 segment _BSS byte public use16 'BSS'
24 global _bss_start:byte
25 label _bss_start byte
26 utoabuf db 6 dup(?)
28 include "isostate.inc"
30 extrn _isostate:isostate
32 ends _BSS
34 segment _TEXT byte public use16 'CODE'
36 org 100h
37 global _text_start:byte
38 label _text_start byte
40 extrn fold
41 extrn unfold
42 mov si,offset fold
43 mov di,offset unfold
44 mov ch,4
45 cld
46 rep
47 movsw
49 ;***************************************************************
50 ; clear bss
51 ;***************************************************************
53 mov si,offset _bss_start
54 clearbss:
55 mov [byte si],cl ; clear bss + heap
56 inc si
57 jne clearbss
59 ;***************************************************************
60 ; build arg
61 ;***************************************************************
63 mov si,80h
64 lodsb
65 cbw
66 xchg ax,bx
67 mov [bx+si],bh ; set EOS
68 searchStart:
69 lodsb
70 cmp al,0
71 je _abort
72 cmp al,' '
73 je searchStart
74 dec si
75 mov di,offset filename
76 push di
77 mov ah,60h ; canonicalize filename
78 int 21h
79 jc _abort
80 ifdef WITH_LONG_FILENAME
81 pop si
82 mov ax,716Ch
83 xor bx,bx ; R/O
84 ;xor cx,cx ; attributes
85 cwd ; action = open
86 stc
87 int 21h
88 jnc opened
89 mov dx,si
90 else
91 pop dx
92 endif
93 mov ax,3d00h ; read-only+compatibility
94 ;mov cl,0 ; attribute mask
95 int 21h
96 jnc opened
98 _abort:
99 mov dx,offset stopmsg
100 mov ah,9
101 int 21h
102 int 20h
103 opened:
104 mov [_isostate.fd],ax
105 mov ax,offset bootdir
106 extrn iso_open:near
107 call iso_open
108 jc_abort:
109 jc _abort
111 ; patch magic
112 ;***************************************************************
114 extrn @readmenu$qv:near
115 call @readmenu$qv
116 mov ax,[_isostate.filemod]
117 mov bx,10
118 xor cx,cx
119 @@loop1:
120 xor dx,dx
121 div bx ; DX:AX = n%10:n/10
122 push dx ; DL = n%10
123 inc cx
124 or ax,ax
125 jnz @@loop1
126 push ds
127 pop es
128 mov di,offset magic
129 @@loop2:
130 pop ax
131 add al,'0'
132 stosb
133 loop @@loop2
135 ; patch initrd
136 ;***************************************************************
137 cwd
138 or [_isostate.curdirsize],-1
139 jmp patchtest
140 found:
141 inc dh
142 patchtest:
143 push dx
144 extrn @isoreaddir$qv:near
145 call @isoreaddir$qv
146 pop dx
147 push ds
148 pop es
149 inc ax
150 jne patchlp
151 cmp dx,100h
152 je initrddone
153 mov di,offset dotgz
154 or dh,dh
155 je modify
156 add di,4
157 mov si,offset rootfs
158 mov cx,3
159 rep
160 movsw
161 modify:
162 xchg ax,dx
163 mov ah,'.'
164 stosw
165 mov ax,'zg'
166 stosw
167 mov ax,'!,'
168 stosw
169 initrddone:
171 ;***************************************************************
173 mov si, offset cmdline
174 mov di, 82h
175 copy:
176 mov ah,al
177 lodsb
178 cmp al,' '
179 jne docopy
180 cmp al,ah
181 je copy
182 docopy:
183 stosb
184 cmp al,0
185 jnz copy
186 xchg di,ax
187 sub al, 82h
188 mov [80h],al
190 mov ax,offset linld
191 call iso_open
192 jc jc_abort
193 mov cx,[word _isostate.filesize]
194 mov dx,100h
195 jmp near unfold
197 patchlp:
198 mov si,[_isostate.filename]
199 mov di,offset rootfs
200 mov cx,9
201 rep
202 cmpsb
203 jcxz found
204 cmp cl,3
205 ja patchtest
206 dec si
207 cmp dl,[si]
208 ja patchtest
209 mov dl,[si]
210 jmp patchtest
212 stopmsg:
213 db "This program cannot be run in DOS mode$"
214 bootdir:
215 db "/boot",0
216 linld:
217 db "linld.com",0
218 cmdline:
219 db "-f "
220 ;db "image=boot\"
221 ;db "bzImage "
222 db "initrd="
223 rootfs:
224 db "rootfs"
225 dotgz:
226 db ".gz,! "
227 ; ".gz,rootfs4.gz,! "
228 ;db "rw "
229 db "autologin rdinit=/init.exe mode=menu magic="
230 magic:
231 db "0 bootfrom="
232 ; "65535 bootfrom="
233 filename:
236 ;***************************************************************
238 ends _TEXT
241 end _text_start
243 ;###### END OF FILE ############################################