wok-tiny diff x86test/stuff/unpack.S @ rev 172
Add x86test & tfttest
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat May 08 17:23:19 2021 +0000 (2021-05-08) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/x86test/stuff/unpack.S Sat May 08 17:23:19 2021 +0000 1.3 @@ -0,0 +1,286 @@ 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 LINUX_HEADER 0 1.10 +#define UPDATE_SYSSIZE 1 1.11 +#define HARDCODED_SYSSIZE 1 1.12 +#define HARDCODED_SETUPSIZE 1 1.13 +#define FLAT16 1 1.14 +#define FLAT16OUT 1 1.15 +#define SAVEREGS 0 1.16 +#define ELKS 0 1.17 + 1.18 +#define ONLY8086 1 1.19 + 1.20 + .text 1.21 + .code16 1.22 + .org 0 1.23 + 1.24 +#if ELKS 1.25 + .arch i8086 1.26 +#define FLAT16 1 1.27 +#define LINUX_HEADER 0 1.28 +#define SAVEREGS 0 1.29 +#define TOPSEG 0x2000 1.30 +#else 1.31 +#define TOPSEG 0x8000 1.32 +#endif 1.33 + 1.34 + .globl _start 1.35 +_start: 1.36 +#if LINUX_HEADER 1.37 + jmp start2 1.38 + .ascii "HdrS" // 202 magic 1.39 + .word 0x200 // 206 version 2.00 1.40 + .long 0 // 208 realmode_swtch 1.41 + .word SYSTEM/16 // 20C start_sys_seg 1.42 + .word 0 // 20E kernel_version 1.43 + .byte 0 // 210 type_of_loader 1.44 + .byte 0 // 211 loadflags 1.45 + .word 0 // 212 setup_move_size 1.46 + .long SYSTEM // 214 code32_start 1.47 + .long 0 // 218 ramdisk_image 1.48 + .long 0 // 21C ramdisk_size 1.49 + .long 0 // 220 bootsect_kludge 1.50 +start2: 1.51 +#endif 1.52 +#if SAVEREGS 1.53 + pushfw 1.54 + pushw %cs 1.55 + pushw $0 1.56 + pushal 1.57 + pushw %ds 1.58 + cld 1.59 +#else 1.60 + pushw %cs 1.61 +# if FLAT16 1.62 + xorw %di, %di 1.63 + pushw %di 1.64 +# else 1.65 + pushw $0 1.66 +# endif 1.67 +#endif 1.68 +#if ELKS 1.69 + movw $0x100, %ax 1.70 + pushw %ax 1.71 +#else 1.72 +#if UPDATE_SYSSIZE 1.73 + pushw %ds // <A> 1.74 +#else 1.75 + pushw %cs // <A> 1.76 +#endif 1.77 +#endif 1.78 +#if FLAT16 1.79 +# 1- move 9020..9020+stp -> TOPSEG 1.80 +#if ELKS 1.81 + movb $TOPSEG/256, %ah 1.82 + movw %ax, %es 1.83 +#else 1.84 + pushw $TOPSEG 1.85 + popw %es 1.86 +#endif 1.87 + movw $0x200, %si 1.88 +#if SAVEREGS == 0 1.89 + pushw %es 1.90 +#if ELKS 1.91 + movw $cont, %ax 1.92 + pushw %ax 1.93 +#else 1.94 + // pushw $cont 1.95 + .byte 0x6A, cont 1.96 +#endif 1.97 + jmp jumpinto 1.98 +#else 1.99 +# if HARDCODED_SETUPSIZE 1.100 +setup_word: 1.101 + movw $SETUP*256, %cx 1.102 +# else 1.103 + xorw %cx, %cx 1.104 + movb SETUPSIZE, %ch 1.105 + movw %cx, %dx 1.106 +# endif 1.107 + pushw %cx // <B> 1.108 + pushw %es 1.109 + pushw %di 1.110 + rep 1.111 + movsw 1.112 + lret 1.113 +#endif 1.114 +cont: 1.115 +# 2- move 1000..1000+sys -> TOPSEG+stp 1.116 +#if ELKS 1.117 + movw $0x1000, %ax 1.118 + movw %ax, %ds 1.119 +#else 1.120 + pushw $0x1000 1.121 + popw %ds 1.122 +#endif 1.123 + xorw %si, %si 1.124 + subw %di, %cx 1.125 + rep 1.126 + movsb 1.127 +# 3- unlz(TOPSEG+stp:end, 1000-stp:0) 1.128 + pushw %es // <C> 1.129 +# if HARDCODED_SETUPSIZE 1.130 +setup_seg: 1.131 +#if ELKS 1.132 +# if UPDATE_SYSSIZE 1.133 + movw $0x1000-(SETUP*32)-32, %ax 1.134 +# else 1.135 + movw $0x1000-(SETUP*32), %ax 1.136 +# endif 1.137 + movw %ax, %es 1.138 +#else 1.139 +# if UPDATE_SYSSIZE 1.140 + pushw $0x1000-(SETUP*32)-32 1.141 +# else 1.142 + pushw $0x1000-(SETUP*32) 1.143 +# endif 1.144 + popw %es 1.145 +#endif 1.146 +# else 1.147 +# if UPDATE_SYSSIZE 1.148 + incb %dh 1.149 +# endif 1.150 +#if ELKS 1.151 + shrw $1, %dx 1.152 + shrw $1, %dx 1.153 + shrw $1, %dx 1.154 +#else 1.155 + shrw $3, %dx 1.156 +#endif 1.157 + movw %ds, %ax 1.158 + subw %dx, %ax 1.159 + movw %ax, %es 1.160 +# endif 1.161 +#else // FLAT16 1.162 +# 1- move 1000..1000+sys -> 9000-sys 1.163 +# if HARDCODED_SYSSIZE 1.164 +packed_syssize: 1.165 + movw $0x1000+0, %ax 1.166 +# else 1.167 + movw SYSSIZE, %ax 1.168 + addw $0x1000, %ax 1.169 +# endif 1.170 + movw %ds, %dx 1.171 +mvsys: 1.172 + decw %ax 1.173 + decw %dx 1.174 + movw %ax, %ds 1.175 + movw %dx, %es 1.176 + xorw %si, %si 1.177 + xorw %di, %di 1.178 + movw $8, %cx 1.179 + rep 1.180 + movsw 1.181 + cmpw $0x1000, %ax 1.182 + jne mvsys 1.183 +# 2- move 9020..9020+stp -> 9000-sys-stp 1.184 + 1.185 +# if HARDCODED_SETUPSIZE 1.186 +setup_byte: 1.187 + movb $SETUP, %ch 1.188 +setup_para: 1.189 + subw $SETUP*32, %dx 1.190 +# else 1.191 + movb %ss:SETUPSIZE, %ch 1.192 + movw %cx, %ax 1.193 +#if ELKS 1.194 + shrw $1, %ax 1.195 + shrw $1, %ax 1.196 + shrw $1, %ax 1.197 +#else 1.198 + shrw $3, %ax 1.199 +#endif 1.200 + subw %ax, %dx 1.201 +# endif 1.202 + pushw %cx // <B> 1.203 + movw %dx, %es 1.204 + xorw %si, %si 1.205 + xorw %di, %di 1.206 + rep 1.207 + movsw %cs:(%si),%es:(%di) 1.208 + pushw %es 1.209 +# 3- reloc itself in 0x7C00 1.210 + pushw $0x07C0 1.211 + popw %es 1.212 + movw $cont, %si 1.213 + movw %si, %di 1.214 + movw $end-_start, %cx 1.215 + pushw %es 1.216 + pushw %di 1.217 + rep 1.218 + movsb %cs:(%si),%es:(%di) 1.219 + lret 1.220 +cont: 1.221 +# 4- unlz(9000-sys-stp:end, 1000-stp:0) 1.222 +# if HARDCODED_SETUPSIZE 1.223 +setup_seg: 1.224 +# if UPDATE_SYSSIZE 1.225 + pushw $0x1000-(SETUP*32)-32 1.226 +# else 1.227 + pushw $0x1000-(SETUP*32) 1.228 +# endif 1.229 + popw %es 1.230 +# else 1.231 + negw %ax 1.232 +# if UPDATE_SYSSIZE 1.233 + addw $0x1000-32, %ax 1.234 +# else 1.235 + addw $0x1000, %ax 1.236 +# endif 1.237 + movw %ax, %es 1.238 +# endif 1.239 +#endif // FLAT16 1.240 + popw %ds // <C> 1.241 + movw $end-_start, %si 1.242 +#if UPDATE_SYSSIZE 1.243 + movw $SYSSIZE, %di 1.244 +#else 1.245 + xorw %di, %di 1.246 +#endif 1.247 + pushw %di 1.248 + pushw %es 1.249 + call unpack 1.250 + popw %ds 1.251 + popw %si 1.252 + movw %si, %di 1.253 +# if SAVEREGS != 0 1.254 + popw %cx // <B> 1.255 +#if UPDATE_SYSSIZE 1.256 +// not need with memtest movb $(512-SYSSIZE)/2, %cl 1.257 +#endif 1.258 + popw %es // <A> 1.259 +# 5- move 1000-stp..1000 -> 9020 1.260 +# else 1.261 + popw %es // <A> 1.262 +jumpinto: 1.263 +# if HARDCODED_SETUPSIZE 1.264 +setup_word: 1.265 + movw $SETUP*256, %cx 1.266 +# else 1.267 + xorw %cx, %cx 1.268 + movb %ss:SETUPSIZE, %ch 1.269 + movw %cx, %dx 1.270 +# endif 1.271 +# endif 1.272 + rep 1.273 + movsw 1.274 +#if SAVEREGS 1.275 + popw %ds 1.276 + popal 1.277 + iret 1.278 +#else 1.279 + lret 1.280 +#endif 1.281 + 1.282 +unpack: 1.283 +#define NO_LZMA_HEADER 1.284 +#if ELKS 1.285 +#define ONLY8086 1 1.286 +#endif 1.287 +#include "unlzma.S" 1.288 + 1.289 +end: