2
* GRUB -- GRand Unified Bootloader
3
* Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
4
* Copyright (C) 2003 Free Software Foundation, Inc.
6
* This program 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 2 of the License, or
9
* (at your option) any later version.
11
* This program 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 this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
* This code was stolen from the files enter.sh, leave.sh, lzo1x_d.sh,
23
* lzo1x_f.s and lzo_asm.h in LZO version 1.08, and was heavily modified
24
* to adapt it to GRUB's requirement.
26
* See <http://www.oberhumer.com/opensource/lzo/>, for more information
30
#define INP 4+16(%esp)
31
#define INS 8+16(%esp)
32
#define OUTP 12+16(%esp)
36
#define LODSB movb (%esi), %al ; incl %esi
37
#define NOTL_3(r) xorl N_3, r
38
#define MOVSL(r1,r2,x) movl (r1), x ; addl $4, r1 ; movl x, (r2) ; addl $4, r2
39
#define COPYL_C(r1,r2,x,rc) 9: MOVSL(r1,r2,x) ; decl rc ; jnz 9b
40
#define COPYL(r1,r2,x) COPYL_C(r1,r2,x,%ecx)
56
xorl %ebx, %ebx /* high bits 9-32 stay 0 */
64
/***********************************************************************
66
************************************************************************/
73
leal 18+NN(%eax,%ebx), %eax
103
/***********************************************************************
105
************************************************************************/
109
leal -0x801(%edi), %edx
110
leal (%eax,%ebx,4), %eax
119
/***********************************************************************
121
************************************************************************/
135
leal (%eax,%ebx,8), %eax
146
/***********************************************************************
148
************************************************************************/
155
leal 33+NN(%eax,%ebx), %ecx
180
/***********************************************************************
182
************************************************************************/
185
.LCOPYLONG: /* copy match using longwords */
186
leal -3(%edi,%ecx), %eax
188
COPYL(%edx,%edi,%ebx)
207
.LCOPYBYTE: /* copy match using bytes */
217
/***********************************************************************
219
************************************************************************/
226
leal 9+NN(%ebx,%ecx), %ecx
238
shll $13, %eax /* save in bit 16 */
245
leal -0x4000(%edi), %edx
252
/***********************************************************************
254
************************************************************************/
262
leal (%eax,%ebx,4), %eax
266
movb (%edx), %al /* we must use this because edx can be edi-1 */
274
/***********************************************************************
276
************************************************************************/
279
/**** xorl %eax,%eax eax=0 from above */
281
cmpl $3+NN, %ecx /* ecx must be 3/6 */
284
/* check compressed size */
287
cmpl %edx, %esi /* check compressed size */
289
jb .L_input_not_consumed
295
subl OUTP, %edi /* write back the uncompressed size */
304
.L_input_not_consumed:
305
movl $8, %eax /* LZO_E_INPUT_NOT_CONSUMED */
309
movl $4, %eax /* LZO_E_INPUT_OVERRUN */