restore patches lost when merging NMU diff
[debian/elilo] / ia32 / gzip_loader.c
1 /*
2  *  Copyright (C) 2001-2002 Hewlett-Packard Co.
3  *      Contributed by Stephane Eranian <eranian@hpl.hp.com>
4  *
5  * This file is part of the ELILO, the EFI Linux boot loader.
6  *
7  *  ELILO is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  ELILO is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with ELILO; see the file COPYING.  If not, write to the Free
19  *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20  *  02111-1307, USA.
21  *
22  * Please check out the elilo.txt for complete documentation on how
23  * to use this program.
24  */
25
26 #include <efi.h>
27 #include <efilib.h>
28
29 #include "elilo.h"
30 #include "loader.h"
31 #include "gzip.h"
32
33 #define LD_NAME L"gzip_ia32"
34
35 static INTN
36 gzip_probe_format(CHAR16 *kname)
37 {
38         UINT8 buf[4];
39         EFI_STATUS status;
40         INTN ret = -1;
41         UINTN size;
42         fops_fd_t fd;
43
44         status = fops_open(kname, &fd);
45         if (EFI_ERROR(status)) return -1;
46
47         size = sizeof(buf);
48         status = fops_read(fd, buf, &size);
49
50         if (EFI_ERROR(status) || size != sizeof(buf)) goto error;
51
52         ret = gzip_probe(buf, sizeof(buf));
53 error:
54         fops_close(fd);
55         return ret;
56 }
57
58
59 static INTN
60 gzip_load_kernel(CHAR16 *kname, kdesc_t *kd)
61 {
62         EFI_STATUS status;
63         INT32 ret;
64         fops_fd_t fd;
65
66         status = fops_open(kname, &fd);
67         if (EFI_ERROR(status)) return ELILO_LOAD_ERROR;
68
69         ret = gunzip_kernel(fd, kd);
70        
71         fops_close(fd);
72
73         return ret; /* could be success, error, or abort */
74 }
75
76 loader_ops_t gzip_loader={
77         NULL,
78         LD_NAME,
79         gzip_probe_format,
80         gzip_load_kernel
81 };