2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
4 * Copyright (C) 2003,2007 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21 * This code was stolen from the files enter.sh, leave.sh, lzo1x_d.sh,
22 * lzo1x_f.s and lzo_asm.h in LZO version 1.08, and was heavily modified
23 * to adapt it to GRUB's requirement.
25 * See <http://www.oberhumer.com/opensource/lzo/>, for more information
29 #define INP 4+16(%esp)
30 #define INS 8+16(%esp)
31 #define OUTP 12+16(%esp)
35 #define LODSB movb (%esi), %al ; incl %esi
36 #define NOTL_3(r) xorl N_3, r
37 #define MOVSL(r1,r2,x) movl (r1), x ; addl $4, r1 ; movl x, (r2) ; addl $4, r2
38 #define COPYL_C(r1,r2,x,rc) 9: MOVSL(r1,r2,x) ; decl rc ; jnz 9b
39 #define COPYL(r1,r2,x) COPYL_C(r1,r2,x,%ecx)
55 xorl %ebx, %ebx /* high bits 9-32 stay 0 */
63 /***********************************************************************
65 ************************************************************************/
72 leal 18+NN(%eax,%ebx), %eax
101 /***********************************************************************
103 ************************************************************************/
107 leal -0x801(%edi), %edx
108 leal (%eax,%ebx,4), %eax
117 /***********************************************************************
119 ************************************************************************/
132 leal (%eax,%ebx,8), %eax
143 /***********************************************************************
145 ************************************************************************/
152 leal 33+NN(%eax,%ebx), %ecx
176 /***********************************************************************
178 ************************************************************************/
180 .LCOPYLONG: /* copy match using longwords */
181 leal -3(%edi,%ecx), %eax
183 COPYL(%edx,%edi,%ebx)
201 .LCOPYBYTE: /* copy match using bytes */
211 /***********************************************************************
213 ************************************************************************/
220 leal 9+NN(%ebx,%ecx), %ecx
231 shll $13, %eax /* save in bit 16 */
238 leal -0x4000(%edi), %edx
245 /***********************************************************************
247 ************************************************************************/
254 leal (%eax,%ebx,4), %eax
258 movb (%edx), %al /* we must use this because edx can be edi-1 */
266 /***********************************************************************
268 ************************************************************************/
271 /**** xorl %eax,%eax eax=0 from above */
273 cmpl $3+NN, %ecx /* ecx must be 3/6 */
276 /* check compressed size */
279 cmpl %edx, %esi /* check compressed size */
281 jb .L_input_not_consumed
287 subl OUTP, %edi /* write back the uncompressed size */
296 .L_input_not_consumed:
297 movl $8, %eax /* LZO_E_INPUT_NOT_CONSUMED */
301 movl $4, %eax /* LZO_E_INPUT_OVERRUN */