wok-6.x view syslinux/stuff/iso2exe/meminfo.S @ rev 19872

linld/tazboot: fix magic (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Mar 30 18:01:42 2017 +0200 (2017-03-30)
parents 45e76a6c05d7
children
line source
1 .text
2 .code16
3 .org 0
4 stacktop = 0xFFFE
6 .globl _start
7 _start:
8 #if 1
9 #define EXEADRS(x) x+0xE0
10 #define CODESZ 0x200
11 decw %bp // Magic number: MZ
12 popw %dx
13 jmp start // Bytes on last page of file
14 .word (CODESZ+511)/512 // Pages in file
15 .word 0 // Relocations
16 .word (end_header-_start)/16 // Size of header in paragraphs
17 .word 4096 // Minimum extra paragraphs needed
18 .word -1 // Maximum extra paragraphs needed
19 .word (CODESZ+15)/16 // Initial (relative) SS value
20 .word stacktop // Initial SP value
21 .word 0 // Checksum
22 .word EXEADRS(comstart) // Initial IP value
23 .word 0xFFF0 // Initial (relative) CS value
24 // .word 0x001C // File address of relocation table
25 // .word 0,0,0 // Overlay number
26 start:
27 pushw %dx
28 cld
29 pushw %cs
30 call comstart2
31 stop:
32 hlt
33 jmp stop
34 end_header:
35 #endif
36 comstart:
37 pushw %cs
38 call comstart2
39 int $0x20
40 comstart2:
41 call here
42 here:
43 popw %ax
44 subw $here-_start, %ax
45 shrw $4, %ax
46 movw %cs, %dx
47 addw %ax, %dx
48 pushw %dx
49 pushw $go
50 retf
51 go:
52 pushw %cs
53 popw %ds
54 pushw %cs
55 popw %es
56 #if 1
57 pushfw // save flags
58 // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
59 // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
60 movb $0x10, %ah
61 pushw %ax
62 popfw // < 286 : flags[12..15] are forced 1
63 pushfw // = 286 : flags[12..15] are forced 0
64 popw %bx // > 286 : only flags[15] is forced 0
65 popfw // restore flags
66 addb %ah, %bh // test F0 and 00 cases
67 cmpb %ah, %bh
68 jbe fail // C=8086/80186, Z=80286
69 #endif
70 xorl %ebx, %ebx
71 e820lp:
72 movl $0xe820, %eax
73 movl $0x534d4150, %edx
74 movl $20, %ecx
75 movw $buffer, %di
76 int $0x15
77 jc fail
78 cmpl $0x534d4150, %eax
79 jne fail
80 cmpl $20, %ecx
81 jc fail
82 pushl %ebx
83 movw $header_e820, %si
84 call puts64
85 movw $usable, %si
86 cmpl $1, (%di)
87 je show_status
88 movw $acpi_reclaim, %si
89 cmpl $3, (%di)
90 je show_status
91 movw $acpi_nvs, %si
92 cmpl $4, (%di)
93 je show_status
94 movw $reserved, %si
95 show_status:
96 call putcs
97 popl %ebx
98 orl %ebx, %ebx
99 jnz e820lp
100 fail:
101 movb $10, %al
102 call putc
103 movw $8*4, %cx
104 movw $buffer, %di
105 pushw %di
106 xorw %ax, %ax
107 rep
108 stosw
109 movw $0xE801, %ax
110 int $0x15
111 popw %di
112 jc fail2
113 movb $0x10, 0+2(%di) // 1M
114 movb $0x10, 32+2(%di) // 1M
115 movb $0x1, 16+3(%di) // 16M
116 movb $0x1, 48+3(%di) // 16M
117 incb %bh
118 movw %bx, 24+2(%di)
119 incb %dh
120 movw %dx, 56+2(%di)
121 movw %cx, %dx
122 movb $6, %cl
123 shrw %cl, %ax // 1K -> 64K
124 jz e801_configured
125 shrw %cl, %dx // 1K -> 64K
126 addw $0x10, %ax
127 addw $0x10, %dx
128 movw %ax, 8+2(%di)
129 movw %dx, 40+2(%di)
130 movw $extended, %si
131 call pute801
132 call pute801
133 e801_configured:
134 movw $buffer+32, %di
135 movw $configured, %si
136 call pute801
137 call pute801
138 movb $10, %al
139 call putc
140 fail2:
141 movw $8, %cx
142 movw $buffer, %di
143 pushw %di
144 xorw %ax, %ax
145 rep
146 stosw
147 movb $0x88, %ah
148 int $0x15
149 popw %di
150 jc fail3
151 movb $0x10, 0+2(%di) // 1M
152 movb $6, %cl
153 shrw %cl, %ax // 1K -> 64K
154 jz fail3
155 addw $0x10, %ax
156 movw %ax, 8+2(%di)
157 movw $header_0088, %si
158 call puts64
159 movb $10, %al
160 call putc
161 fail3:
162 retf
164 puts64:
165 call puts
166 call put64
167 movw $middle, %si
168 call putcs
169 put64:
170 movw $8, %cx
171 addw %cx, %di
172 pushw %di
173 put64lp:
174 decw %di
175 movb (%di), %al
176 shrb $4, %al
177 call putx
178 movb (%di), %al
179 call putx
180 loop put64lp
181 popw %di
182 ret
184 pute801:
185 pushw %si
186 movw $header_e801, %si
187 call puts64
188 popw %si
189 pushw %si
190 call putcs
191 popw %si
192 ret
193 putcs:
194 movb $0x20, %al
195 putslp:
196 call putc
197 puts:
198 lodsb
199 orb %al, %al
200 jnz putslp
201 ret
203 putx:
204 andb $0xF, %al
205 addb $0x90, %al
206 daa
207 adcb $0x40, %al
208 daa
209 putc:
210 movw $7, %bx
211 movb $0xE, %ah
212 int $0x10
213 ret
215 header_0088:
216 .byte 13,10
217 .ascii "BIOS-0088: "
218 .byte 0
219 header_e801:
220 .byte 13,10
221 .ascii "BIOS-e801: "
222 .byte 0
223 extended:
224 .ascii "(extended)"
225 .byte 0
226 configured:
227 .ascii "(configured)"
228 .byte 0
229 header_e820:
230 .byte 13,10
231 .ascii "BIOS-e820: "
232 .byte 0
233 middle:
234 .ascii "- "
235 .byte 0
236 usable: // 1
237 .ascii "(usable)"
238 .byte 0
239 reserved: // 2
240 .ascii "(reserved)"
241 .byte 0
242 acpi_reclaim: // 3
243 .ascii "(ACPI Reclaim)"
244 .byte 0
245 acpi_nvs: // 4
246 .ascii "(ACPI NVS)"
247 .byte 0
248 buffer:
249 .org 510
250 .word 0xAA55