~ubuntu-branches/debian/sid/grub2/sid-200907171837

« back to all changes in this revision

Viewing changes to kern/i386/pc/lzo1x.S

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2006-01-05 15:20:40 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060105152040-1ab076d4n3y2o5yf
Tags: 1.92-1
* New upstream release.
  - Add support for GPT partition table format.
  - Add a new command "play" to play an audio file on PC.
  - Add support for Linux/ADFS partition table format.
  - Add support for BASH-like scripting.
  - Add support for Apple HFS+ filesystems.
* 01_fix_grub-install.patch: Added. Fix grub-install to use
  /bin/grub-mkimage instead of /sbin/grub-mkimage. Closes: #338824
* Do not use CDBS tarball mode anymore. Closes: #344272  

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  GRUB  --  GRand Unified Bootloader
 
3
 *  Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
 
4
 *  Copyright (C) 2003  Free Software Foundation, Inc.
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
19
 */
 
20
        
 
21
/*
 
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.
 
25
 *
 
26
 * See <http://www.oberhumer.com/opensource/lzo/>, for more information
 
27
 * about LZO.
 
28
 */
 
29
 
 
30
#define INP     4+16(%esp)
 
31
#define INS     8+16(%esp)
 
32
#define OUTP    12+16(%esp)
 
33
#define NN      3
 
34
#define N_3     %ebp
 
35
#define N_255   $255
 
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)
 
41
        
 
42
lzo1x_decompress:
 
43
        pushl   %ebp
 
44
        pushl   %edi
 
45
        pushl   %esi
 
46
        pushl   %ebx
 
47
 
 
48
        cld
 
49
 
 
50
        movl    INP, %esi
 
51
        movl    OUTP, %edi
 
52
        movl    $3, %ebp
 
53
 
 
54
        
 
55
        xorl    %eax, %eax
 
56
        xorl    %ebx, %ebx      /* high bits 9-32 stay 0 */
 
57
        lodsb
 
58
        cmpb    $17, %al
 
59
        jbe     .L01
 
60
        subb    $17-NN, %al
 
61
        jmp     .LFLR
 
62
 
 
63
 
 
64
/***********************************************************************
 
65
// literal run
 
66
************************************************************************/
 
67
 
 
68
0:      addl    N_255, %eax
 
69
1:      movb    (%esi), %bl
 
70
        incl    %esi
 
71
        orb     %bl, %bl
 
72
        jz      0b
 
73
        leal    18+NN(%eax,%ebx), %eax
 
74
        jmp     3f
 
75
 
 
76
 
 
77
        .align  8
 
78
.L00:
 
79
        LODSB
 
80
.L01:
 
81
        cmpb    $16, %al
 
82
        jae     .LMATCH
 
83
 
 
84
        /* a literal run */
 
85
        orb     %al, %al
 
86
        jz      1b
 
87
        addl    $3+NN, %eax
 
88
3:
 
89
.LFLR:
 
90
        movl    %eax, %ecx
 
91
        NOTL_3(%eax)
 
92
        shrl    $2, %ecx
 
93
        andl    N_3, %eax
 
94
        COPYL(%esi,%edi,%edx)
 
95
        subl    %eax, %esi
 
96
        subl    %eax, %edi
 
97
 
 
98
        LODSB
 
99
        cmpb    $16, %al
 
100
        jae     .LMATCH
 
101
 
 
102
 
 
103
/***********************************************************************
 
104
// R1
 
105
************************************************************************/
 
106
 
 
107
        shrl    $2, %eax
 
108
        movb    (%esi), %bl
 
109
        leal    -0x801(%edi), %edx
 
110
        leal    (%eax,%ebx,4), %eax
 
111
        incl    %esi
 
112
        subl    %eax, %edx
 
113
        movl    (%edx), %ecx
 
114
        movl    %ecx, (%edi)
 
115
        addl    N_3, %edi
 
116
        jmp     .LMDONE
 
117
 
 
118
 
 
119
/***********************************************************************
 
120
// M2
 
121
************************************************************************/
 
122
 
 
123
        .align  8
 
124
.LMATCH:
 
125
        cmpb    $64, %al
 
126
        jb      .LM3MATCH
 
127
 
 
128
        /* a M2 match */
 
129
        movl    %eax, %ecx
 
130
        shrl    $2, %eax
 
131
        leal    -1(%edi), %edx
 
132
        andl    $7, %eax
 
133
        movb    (%esi), %bl
 
134
        shrl    $5, %ecx
 
135
        leal    (%eax,%ebx,8), %eax
 
136
        incl    %esi
 
137
        subl    %eax, %edx
 
138
 
 
139
        addl    $1+3, %ecx
 
140
 
 
141
        cmpl    N_3, %eax
 
142
        jae     .LCOPYLONG
 
143
        jmp     .LCOPYBYTE
 
144
 
 
145
 
 
146
/***********************************************************************
 
147
// M3
 
148
************************************************************************/
 
149
 
 
150
0:      addl    N_255, %eax
 
151
1:      movb    (%esi), %bl
 
152
        incl    %esi
 
153
        orb     %bl, %bl
 
154
        jz      0b
 
155
        leal    33+NN(%eax,%ebx), %ecx
 
156
        xorl    %eax, %eax
 
157
        jmp     3f
 
158
 
 
159
 
 
160
        .align  8
 
161
.LM3MATCH:
 
162
        cmpb    $32, %al
 
163
        jb      .LM4MATCH
 
164
 
 
165
        /* a M3 match */
 
166
        andl    $31, %eax
 
167
        jz      1b
 
168
        lea     2+NN(%eax), %ecx
 
169
3:
 
170
        movw    (%esi), %ax
 
171
        leal    -1(%edi), %edx
 
172
        shrl    $2, %eax
 
173
        addl    $2, %esi
 
174
        subl    %eax, %edx
 
175
 
 
176
        cmpl    N_3, %eax
 
177
        jb      .LCOPYBYTE
 
178
 
 
179
 
 
180
/***********************************************************************
 
181
// copy match
 
182
************************************************************************/
 
183
 
 
184
        .align  2
 
185
.LCOPYLONG:                      /* copy match using longwords */
 
186
        leal    -3(%edi,%ecx), %eax
 
187
        shrl    $2, %ecx
 
188
        COPYL(%edx,%edi,%ebx)
 
189
        movl    %eax, %edi
 
190
        xorl    %ebx, %ebx
 
191
 
 
192
.LMDONE:
 
193
        movb    -2(%esi), %al
 
194
        andl    N_3, %eax
 
195
        jz      .L00
 
196
.LFLR3:
 
197
        movl    (%esi), %edx
 
198
        addl    %eax, %esi
 
199
        movl    %edx, (%edi)
 
200
        addl    %eax, %edi
 
201
 
 
202
        LODSB
 
203
        jmp     .LMATCH
 
204
 
 
205
 
 
206
        .align  8
 
207
.LCOPYBYTE:                      /* copy match using bytes */
 
208
        xchgl   %edx,%esi
 
209
        subl    N_3,%ecx
 
210
 
 
211
        rep
 
212
        movsb
 
213
        movl    %edx, %esi
 
214
        jmp     .LMDONE
 
215
 
 
216
 
 
217
/***********************************************************************
 
218
// M4
 
219
************************************************************************/
 
220
 
 
221
0:      addl    N_255, %ecx
 
222
1:      movb    (%esi), %bl
 
223
        incl    %esi
 
224
        orb     %bl, %bl
 
225
        jz      0b
 
226
        leal    9+NN(%ebx,%ecx), %ecx
 
227
        jmp     3f
 
228
 
 
229
 
 
230
        .align  8
 
231
.LM4MATCH:
 
232
        cmpb    $16, %al
 
233
        jb      .LM1MATCH
 
234
 
 
235
        /* a M4 match */
 
236
        movl    %eax, %ecx
 
237
        andl    $8, %eax
 
238
        shll    $13, %eax       /* save in bit 16 */
 
239
        andl    $7, %ecx
 
240
        jz      1b
 
241
        addl    $2+NN, %ecx
 
242
3:
 
243
        movw    (%esi), %ax
 
244
        addl    $2, %esi
 
245
        leal    -0x4000(%edi), %edx
 
246
        shrl    $2, %eax
 
247
        jz      .LEOF
 
248
        subl    %eax, %edx
 
249
        jmp     .LCOPYLONG
 
250
 
 
251
 
 
252
/***********************************************************************
 
253
// M1
 
254
************************************************************************/
 
255
 
 
256
        .align  8
 
257
.LM1MATCH:
 
258
        /* a M1 match */
 
259
        shrl    $2, %eax
 
260
        movb    (%esi), %bl
 
261
        leal    -1(%edi), %edx
 
262
        leal    (%eax,%ebx,4), %eax
 
263
        incl    %esi
 
264
        subl    %eax, %edx
 
265
 
 
266
        movb    (%edx), %al     /* we must use this because edx can be edi-1 */
 
267
        movb    %al, (%edi)
 
268
        movb    1(%edx), %bl
 
269
        movb    %bl, 1(%edi)
 
270
        addl    $2, %edi
 
271
        jmp     .LMDONE
 
272
 
 
273
 
 
274
/***********************************************************************
 
275
//
 
276
************************************************************************/
 
277
 
 
278
.LEOF:
 
279
/****   xorl    %eax,%eax          eax=0 from above */
 
280
 
 
281
        cmpl    $3+NN, %ecx     /* ecx must be 3/6 */
 
282
        setnz   %al
 
283
 
 
284
        /* check compressed size */
 
285
        movl    INP, %edx
 
286
        addl    INS, %edx
 
287
        cmpl    %edx, %esi       /* check compressed size */
 
288
        ja      .L_input_overrun
 
289
        jb      .L_input_not_consumed
 
290
 
 
291
.L_leave:
 
292
        negl    %eax
 
293
        jnz     1f
 
294
        
 
295
        subl    OUTP, %edi       /* write back the uncompressed size */
 
296
        movl    %edi, %eax
 
297
 
 
298
1:      popl    %ebx
 
299
        popl    %esi
 
300
        popl    %edi
 
301
        popl    %ebp
 
302
        ret
 
303
 
 
304
.L_input_not_consumed:
 
305
        movl    $8, %eax         /* LZO_E_INPUT_NOT_CONSUMED */
 
306
        jmp     .L_leave
 
307
 
 
308
.L_input_overrun:
 
309
        movl    $4, %eax         /* LZO_E_INPUT_OVERRUN */
 
310
        jmp     .L_leave
 
311
 
 
312
#undef INP
 
313
#undef INS
 
314
#undef OUTP
 
315
#undef NN
 
316
#undef NN
 
317
#undef N_3
 
318
#undef N_255
 
319
#undef LODSB
 
320
#undef NOTL_3
 
321
#undef MOVSL
 
322
#undef COPYL_C
 
323
#undef COPYL