wok diff plop/stuff/unpack.S @ rev 25438
Update some web_site
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Sep 01 11:12:31 2022 +0000 (2022-09-01) |
parents | |
children | 7f7bd3c9775e |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/plop/stuff/unpack.S Thu Sep 01 11:12:31 2022 +0000 1.3 @@ -0,0 +1,364 @@ 1.4 +#define SYSTEM 0x10000 1.5 +#define SETUP 14 1.6 +#define SYSSIZE 0x1F4 1.7 +#define SETUPSIZE 0x1F1 1.8 + 1.9 +#define KEEP_BOOTSECTOR 1 1.10 +#define LINUX_HEADER 0 1.11 +#define UPDATE_SYSSIZE 1 1.12 +#define HARDCODED_SYSSIZE 1 1.13 +#define HARDCODED_SETUPSIZE 1 1.14 +#define FLAT16 1 1.15 +#define FLAT16OUT 1 1.16 +#define SAVEREGS 0 1.17 +#define ELKS 0 1.18 + 1.19 + .text 1.20 + .code16 1.21 + .org 0 1.22 + 1.23 +#if KEEP_BOOTSECTOR 1.24 +#undef UPDATE_SYSSIZE 1.25 +#define UPDATE_SYSSIZE 0 1.26 +#endif 1.27 +#if defined(FLAT16OUT) && FLAT16OUT == 0 1.28 +#undef FLAT16OUT 1.29 +#endif 1.30 +#if ELKS 1.31 + .arch i8086 1.32 +#define FLAT16 1 1.33 +#define LINUX_HEADER 0 1.34 +#define SAVEREGS 0 1.35 +#define TOPSEG 0x2000 1.36 +#else 1.37 +#define TOPSEG 0x8000 1.38 +#endif 1.39 + 1.40 + .globl _start 1.41 +_start: 1.42 +#if LINUX_HEADER 1.43 + jmp start2 1.44 + .ascii "HdrS" // 202 magic 1.45 + .word 0x200 // 206 version 2.00 1.46 + .long 0 // 208 realmode_swtch 1.47 + .word SYSTEM/16 // 20C start_sys_seg 1.48 + .word 0 // 20E kernel_version 1.49 + .byte 0 // 210 type_of_loader 1.50 + .byte 0 // 211 loadflags 1.51 + .word 0 // 212 setup_move_size 1.52 + .long SYSTEM // 214 code32_start 1.53 + .long 0 // 218 ramdisk_image 1.54 + .long 0 // 21C ramdisk_size 1.55 + .long 0 // 220 bootsect_kludge 1.56 +start2: 1.57 +#endif 1.58 +#if SAVEREGS 1.59 + pushfw 1.60 + pushw %cs 1.61 + pushw $0 1.62 + pushal 1.63 + pushw %ds 1.64 + cld 1.65 +#else 1.66 + pushw %cs 1.67 +# if FLAT16 1.68 + xorw %di, %di 1.69 + pushw %di 1.70 +# else 1.71 + pushw $0 1.72 +# endif 1.73 +#endif 1.74 +#if ELKS 1.75 + movw $0x100, %ax 1.76 + pushw %ax 1.77 +#else 1.78 +# if UPDATE_SYSSIZE || KEEP_BOOTSECTOR 1.79 + pushw %ds // <A> 1.80 +# else 1.81 + pushw %cs // <A> 1.82 +# endif 1.83 +#endif 1.84 +#if FLAT16 1.85 +# 1- move 9000/9020..9020+stp -> TOPSEG 1.86 +#if ELKS 1.87 + movb $TOPSEG/256, %ah 1.88 + movw %ax, %es 1.89 +#else 1.90 + pushw $TOPSEG 1.91 + popw %es 1.92 +#endif 1.93 +#if KEEP_BOOTSECTOR 1.94 + xorw %si, %si 1.95 +#else 1.96 + movw $0x200, %si 1.97 +#endif 1.98 +#if SAVEREGS == 0 1.99 + pushw %es 1.100 +#if ELKS 1.101 +# if KEEP_BOOTSECTOR 1.102 + movw $cont+0x200, %ax 1.103 +# else 1.104 + movw $cont, %ax 1.105 +# endif 1.106 + pushw %ax 1.107 +#else 1.108 +# if KEEP_BOOTSECTOR 1.109 + pushw $cont+0x200 1.110 +# else 1.111 + // pushw $cont 1.112 + .byte 0x6A, cont 1.113 +# endif 1.114 +#endif 1.115 + jmp jumpinto 1.116 +#else 1.117 +# if HARDCODED_SETUPSIZE 1.118 +setup_word: 1.119 +# if KEEP_BOOTSECTOR 1.120 +# else 1.121 + movw $SETUP*256, %cx 1.122 +# endif 1.123 +# else 1.124 +# if KEEP_BOOTSECTOR 1.125 + movw $0x100, %cx 1.126 + addb SETUPSIZE, %ch 1.127 +# else 1.128 + xorw %cx, %cx 1.129 + movb SETUPSIZE, %ch 1.130 +# endif 1.131 + movw %cx, %dx 1.132 +# endif 1.133 + pushw %cx // <B> 1.134 + pushw %es 1.135 + pushw %di 1.136 + rep 1.137 + movsw 1.138 + lret 1.139 +#endif 1.140 +cont: 1.141 +# 2- move 1000..1000+sys -> TOPSEG+stp 1.142 +#if ELKS 1.143 + movw $0x1000, %ax 1.144 + movw %ax, %ds 1.145 +#else 1.146 + pushw $0x1000 1.147 + popw %ds 1.148 +#endif 1.149 + xorw %si, %si 1.150 + subw %di, %cx 1.151 + rep 1.152 + movsb 1.153 +# 3- unlz(TOPSEG+stp:end, 1000-stp:0) 1.154 + pushw %es // <C> 1.155 +# if HARDCODED_SETUPSIZE 1.156 +setup_seg: 1.157 +#if ELKS 1.158 +# if KEEP_BOOTSECTOR 1.159 +# if UPDATE_SYSSIZE 1.160 + movw $0x1000-(SETUP*32)-32-32, %ax 1.161 +# else 1.162 + movw $0x1000-(SETUP*32)-32, %ax 1.163 +# endif 1.164 +# else 1.165 +# if UPDATE_SYSSIZE 1.166 + movw $0x1000-(SETUP*32)-32, %ax 1.167 +# else 1.168 + movw $0x1000-(SETUP*32), %ax 1.169 +# endif 1.170 +# endif 1.171 + movw %ax, %es 1.172 +#else 1.173 +# if KEEP_BOOTSECTOR 1.174 +# if UPDATE_SYSSIZE 1.175 + pushw $0x1000-(SETUP*32)-32-32 1.176 +# else 1.177 + pushw $0x1000-(SETUP*32)-32 1.178 +# endif 1.179 +# else 1.180 +# if UPDATE_SYSSIZE 1.181 + pushw $0x1000-(SETUP*32)-32 1.182 +# else 1.183 + pushw $0x1000-(SETUP*32) 1.184 +# endif 1.185 +# endif 1.186 + popw %es 1.187 +#endif 1.188 +# else 1.189 +# if UPDATE_SYSSIZE 1.190 + incb %dh 1.191 +# endif 1.192 +#if ELKS 1.193 + shrw $1, %dx 1.194 + shrw $1, %dx 1.195 + shrw $1, %dx 1.196 +#else 1.197 + shrw $3, %dx 1.198 +#endif 1.199 + movw %ds, %ax 1.200 + subw %dx, %ax 1.201 + movw %ax, %es 1.202 +# endif 1.203 +#else // FLAT16 1.204 +# 1- move 1000..1000+sys -> 9000-sys 1.205 +# if HARDCODED_SYSSIZE 1.206 +packed_syssize: 1.207 + movw $0x1000+0, %ax 1.208 +# else 1.209 + movw SYSSIZE, %ax 1.210 + addw $0x1000, %ax 1.211 +# endif 1.212 + movw %ds, %dx 1.213 +mvsys: 1.214 + decw %ax 1.215 + decw %dx 1.216 + movw %ax, %ds 1.217 + movw %dx, %es 1.218 + xorw %si, %si 1.219 + xorw %di, %di 1.220 + movw $8, %cx 1.221 + rep 1.222 + movsw 1.223 + cmpw $0x1000, %ax 1.224 + jne mvsys 1.225 +# 2- move 9000/9020..9020+stp -> 9000-sys-stp 1.226 + 1.227 +# if HARDCODED_SETUPSIZE 1.228 +# if KEEP_BOOTSECTOR 1.229 +setup_byte: 1.230 + movb $SETUP+1, %ch 1.231 +setup_para: 1.232 + subw $SETUP*32+32, %dx 1.233 +# else 1.234 +setup_byte: 1.235 + movb $SETUP, %ch 1.236 +setup_para: 1.237 + subw $SETUP*32, %dx 1.238 +# endif 1.239 +# else 1.240 + movb %ss:SETUPSIZE, %ch 1.241 +# if KEEP_BOOTSECTOR 1.242 + incb $ch 1.243 +# endif 1.244 + movw %cx, %ax 1.245 +#if ELKS 1.246 + shrw $1, %ax 1.247 + shrw $1, %ax 1.248 + shrw $1, %ax 1.249 +#else 1.250 + shrw $3, %ax 1.251 +#endif 1.252 + subw %ax, %dx 1.253 +# endif 1.254 + pushw %cx // <B> 1.255 + movw %dx, %es 1.256 + xorw %si, %si 1.257 + xorw %di, %di 1.258 + rep 1.259 + movsw %cs:(%si),%es:(%di) 1.260 + pushw %es 1.261 +# 3- reloc itself in 0x7C00 1.262 + pushw $0x07C0 1.263 + popw %es 1.264 + movw $cont, %si 1.265 + movw %si, %di 1.266 + movw $end-_start, %cx 1.267 + pushw %es 1.268 + pushw %di 1.269 + rep 1.270 + movsb %cs:(%si),%es:(%di) 1.271 + lret 1.272 +cont: 1.273 +# 4- unlz(9000-sys-stp:end, 1000-stp:0) 1.274 +# if HARDCODED_SETUPSIZE 1.275 +setup_seg: 1.276 +# if KEEP_BOOTSECTOR 1.277 +# if UPDATE_SYSSIZE 1.278 + pushw $0x1000-(SETUP*32)-32-32 1.279 +# else 1.280 + pushw $0x1000-(SETUP*32)-32 1.281 +# endif 1.282 +# else 1.283 +# if UPDATE_SYSSIZE 1.284 + pushw $0x1000-(SETUP*32)-32 1.285 +# else 1.286 + pushw $0x1000-(SETUP*32) 1.287 +# endif 1.288 +# endif 1.289 + popw %es 1.290 +# else 1.291 + negw %ax 1.292 +# if UPDATE_SYSSIZE 1.293 + addw $0x1000-32, %ax 1.294 +# else 1.295 + addw $0x1000, %ax 1.296 +# endif 1.297 + movw %ax, %es 1.298 +# endif 1.299 +#endif // FLAT16 1.300 + popw %ds // <C> 1.301 +#if KEEP_BOOTSECTOR 1.302 + movw $0x200+end-_start, %si 1.303 +#else 1.304 + movw $end-_start, %si 1.305 +#endif 1.306 +#if UPDATE_SYSSIZE 1.307 + movw $SYSSIZE, %di 1.308 +#else 1.309 + xorw %di, %di 1.310 +#endif 1.311 + pushw %di 1.312 + pushw %es 1.313 + call unpack 1.314 + popw %ds 1.315 + popw %si 1.316 +# if KEEP_BOOTSECTOR 1.317 +setup_keep: 1.318 + xorw %di, %di 1.319 +# else 1.320 + movw %si, %di 1.321 +# endif 1.322 +# if SAVEREGS != 0 1.323 + popw %cx // <B> 1.324 +#if UPDATE_SYSSIZE 1.325 +// not need with memtest movb $(512-SYSSIZE)/2, %cl 1.326 +#endif 1.327 + popw %es // <A> 1.328 +# 5- move 1000-stp..1000 -> 9020 1.329 +# else 1.330 + popw %es // <A> 1.331 +jumpinto: 1.332 +# if HARDCODED_SETUPSIZE 1.333 +setup_word: 1.334 +# if KEEP_BOOTSECTOR 1.335 + movw $SETUP*256+256, %cx 1.336 +# else 1.337 + movw $SETUP*256, %cx 1.338 +# endif 1.339 +# else 1.340 +# if KEEP_BOOTSECTOR 1.341 + movw $0x100, %cx 1.342 + addb %ss:SETUPSIZE, %ch 1.343 +# else 1.344 + xorw %cx, %cx 1.345 + movb %ss:SETUPSIZE, %ch 1.346 +# endif 1.347 + movw %cx, %dx 1.348 +# endif 1.349 +# endif 1.350 + rep 1.351 + movsw 1.352 +#if SAVEREGS 1.353 + popw %ds 1.354 + popal 1.355 + iret 1.356 +#else 1.357 + lret 1.358 +#endif 1.359 + 1.360 +unpack: 1.361 +#define NO_LZMA_HEADER 1.362 +#if ELKS 1.363 +#define ONLY8086 1 1.364 +#endif 1.365 +#include "unlzma.S" 1.366 + 1.367 +end: