wok-tiny view linux/stuff/bundle.S @ rev 142

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Feb 27 17:43:23 2019 +0100 (2019-02-27)
parents cda63f13344c
children f93fa966f210
line source
1 #define TIMEOUT autostart after 5 seconds
2 #define CHECK_FILES add 'Check media' entry
4 .arch i8086
5 .code16
6 .org 0
7 start:
8 // stack segment setup
9 cld
10 movw $0x9000, %di
11 pushw %di
12 popw %ss
13 movw %di, %sp
15 // patch disk parameter table
16 xorw %cx, %cx
17 pushw %cx // bootloader may want to pull 0
18 movw $0x78, %bx
19 movw %cx, %ds
20 ldsw (%bx), %si
21 pushw %ss
22 popw %es
23 movb $6, %cl
24 pushw %di
25 rep
26 movsw
27 movb $63, %es:4-12(%di)
28 movw %cx, %ds
29 popw (%bx)
30 movw %es, 2(%bx)
32 // data segments setup
33 movw $0x7C0, %ax
34 pushw %ax
35 popw %ds
36 pushw %ds
37 popw %es
39 // main loop
40 menustart:
41 xorw %bp, %bp
42 menudown:
43 incw %bp
44 menustartlp:
45 movw $3, %ax
46 int $0x10 // clear screen
47 movb $1, %ah
48 movw $0x1000, %cx
49 int $0x10 // clear cursor
50 movw $menu, %si
51 call puts
52 call putcr
53 movw %bp, %cx
54 menulp:
55 movb $' ', %bh
56 lodsw
57 loop notcur
58 xchgw %ax, %di
59 movb $'>', %bh
60 notcur:
61 movb %bh, %al
62 call putcs
63 #ifdef CHECK_FILES
64 lodsw // CRC16
65 lodsw // sector count
66 #endif
67 cmpw $0, (%si)
68 jne menulp
69 #ifdef CHECK_FILES
70 movw $msgcrc, %si
71 movb $' ', %al
72 loop notcrc
73 movb $'>', %al
74 notcrc:
75 call putcs
76 #endif
77 menustartz:
78 #ifdef TIMEOUT
79 clock = 0x46C
80 wait:
81 wait4key:
82 pushw %ds
83 xorw %ax, %ax
84 movw %ax, %ds
85 movw $clock, %si
86 #define DELAY 5
87 movb $257-(DELAY*182)/10, (%si)
88 waitkbd:
89 movw $0x10D, %ax // test keyboard, timeout => CR
90 cmpb (%si), %ah
91 je waitdone
92 int $0x16
93 jz waitkbd
94 cbw
95 int $0x16 // eat char
96 movw %si, wait4key+0x7C02 // disable timeout
97 waitdone:
98 popw %ds
99 #else
100 xorb %ax, %ax
101 int $0x16
102 #endif
103 cmpb $0x0D, %al // CR ?
104 je doit
105 cmpb $0x48, %ah // UP ?
106 jne isitdn
107 decw %bp
108 jz menudown
109 isitdn:
110 incw %cx
111 cmpb $0x50, %ah // DN ?
112 loope menudown
113 jmp menustartlp
115 .macro tochs // %di -> %cx, %dx & %bp=sector max
116 movw $64, %cx
117 movw $0x200, %bx
118 sectlp:
119 movw $0x201, %ax
120 movb %ch, %dh
121 decw %cx
122 int $0x13
123 jc sectlp
124 movw %cx, %bp
125 movw %di, %ax
126 div %cl // 32 Mb & 255 tracks max
127 movb %ah, %cl // sector
128 incb %cl
129 shrb $1, %al // C = head, AL = cylinder
130 adcb %dh, %dh
131 movb %al, %ch
132 .endm
134 doit:
135 #ifdef CHECK_FILES
136 jcxz docrc
137 call getsectors
138 #else
139 tochs // %di -> %cx, %dx & %bp=sector max
140 #endif
141 pushw %cx
142 movw $0x201, %ax
143 int $0x13
144 popw %cx
145 jc menustart
147 // scan boot code
148 movw %bx, %di // =0x200
149 scanboot:
150 incw %di
151 je found
152 cmpw $0x5897, -3(%di) // xchgw %ax, %di; popw %ax
153 jne scanboot
154 cmpw $0xE841, -1(%di) // incw %cx ; call ...
155 jne scanboot
156 found:
157 pushw %ds
158 pushw %di
159 cli
160 movb 0x1F1(%bx), %al // setup size
161 pushw %ss
162 popw %ds
163 pushw %ss
164 popw %es
165 xorw %di, %di
166 xchgw %ax, %di // ax = limits = 0
167 xorw %bx, %bx // to %es:%bx = 9000:0000
168 incw %di // Add bootsector, Clear Z
169 lret // Read from %dx, %cx
171 #ifdef CHECK_FILES
172 docrc:
173 movw $menu, %si
174 skiptitle:
175 lodsb
176 orb %al, %al
177 jnz skiptitle
178 nextchk:
179 lodsw // sector offset
180 xchgw %ax, %di
181 movw %di, %cx
182 movw $1, %bp
183 jcxz menustartz
184 call puts // menu entry
185 call getsectors
186 lodsw
187 xchgw %ax, %di // crc
188 movw $0x201, %ax
189 int $0x13
190 lodsw // sector count
191 pushw %si
192 jc chkfail
193 xchgw %ax, %si
194 chksector:
195 subw (%bx), %di
196 incw %bx
197 incw %bx
198 cmpb $4, %bh
199 jne chksector
200 movb $2, %bh
201 decw %si
202 je chkend
203 movw %bp, %ax
204 incw %cx
205 cmpb %al, %cl
206 jle rdit
207 movb $1, %cl
208 xorb %cl, %dh
209 jne rdit
210 incb %ch
211 rdit:
212 movw $0x201, %ax
213 int $0x13
214 jnc chksector
215 chkend:
216 movw $msgok, %si
217 orw %di, %di
218 je chkok
219 chkfail:
220 movw $msgko, %si
221 chkok:
222 call puts
223 popw %si
224 jmp nextchk
226 getsectors:
227 tochs // %di -> %cx, %dx & %bp=sector max
228 ret
229 #endif
231 puts:
232 lodsb
233 orb %al, %al
234 jnz putcs
235 putcr:
236 movb $10, %al
237 putlf:
238 xorb $10^13, %al
239 putcs:
240 movw $7, %bx
241 movb $0xE, %ah
242 int $0x10
243 cmpb $13, %al
244 jz putlf
245 jnc puts
246 ret
248 #ifdef CHECK_FILES
249 msgok:
250 .asciz " OK"
251 msgko:
252 .asciz " Broken"
253 msgcrc:
254 .asciz "Check media" // used to detect CHECK_FILES
255 #endif
256 menu:
258 .org 0x1F1
259 setupsz:
260 .byte 0
261 rootflags:
262 .word menu
263 syssz:
264 .long 0 // updated by bundle
265 ramsize:
266 .ascii "SliTaz"
267 // .word 0
268 //vidmode:
269 // .word 0
270 //rootdev:
271 // .word 0
272 bootflag:
273 .word 0xAA55