Imported Upstream version 3.4
[debian/elilo] / fileops.h
1 /*
2  *  Copyright (C) 2001-2003 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  *  GNU EFI 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  *  GNU EFI 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 GNU EFI; 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 #ifndef __FILEOPS_H__
27 #define __FILEOPS_H__
28
29 #define FILEOPS_NAME_MAXLEN     32      /* length of filesystem name */
30
31 /*
32  * upper-level interface used by the bootloader
33  */
34 typedef UINTN   fops_fd_t;
35
36 extern EFI_STATUS fops_open(CHAR16 *name, fops_fd_t *fd);
37 extern EFI_STATUS fops_read(fops_fd_t fd,VOID *buf, UINTN *size);
38 extern EFI_STATUS fops_close(fops_fd_t fd);
39 extern EFI_STATUS fops_infosize(fops_fd_t fd, UINT64 *size);
40 extern EFI_STATUS fops_seek(fops_fd_t fd, UINT64 newpos);
41 extern EFI_STATUS fops_setdefaults(CHAR16 *config, CHAR16 *kname, UINTN maxlen, CHAR16 *devpath);
42 extern EFI_STATUS fops_getdefault_path(CHAR16 *path, UINTN maxlen);
43 extern CHAR16     *fops_bootdev_name(VOID);
44
45
46 /*
47  * fileops interface used by underlying filesystems layer
48  */
49 typedef EFI_STATUS (*fops_open_t)(VOID *intf, CHAR16 *name, fops_fd_t *fd);
50 typedef EFI_STATUS (*fops_read_t)(VOID *intf, fops_fd_t fd, VOID *buf, UINTN *size);
51 typedef EFI_STATUS (*fops_close_t)(VOID *intf, fops_fd_t fd);
52 typedef EFI_STATUS (*fops_infosize_t)(VOID *intf, fops_fd_t fd, UINT64 *size);
53 typedef EFI_STATUS (*fops_seek_t)(VOID *intf, fops_fd_t fd, UINT64 newpos);
54 typedef EFI_STATUS (*fops_setdefaults_t)(VOID *intf, CHAR16 *config, CHAR16 *kname, UINTN maxlen, CHAR16 *devpath);
55 typedef EFI_STATUS (*fops_getdefault_path_t)(CHAR16 *path, UINTN maxlen);
56
57 typedef struct {
58         VOID *intf;     /* pointer to underlying interface */
59
60         fops_open_t             open;
61         fops_read_t             read;
62         fops_close_t            close;
63         fops_infosize_t         infosize;
64         fops_seek_t             seek;
65         fops_setdefaults_t      setdefaults;
66         fops_getdefault_path_t  getdefault_path;
67
68         EFI_HANDLE dev; /* handle on device on which proto is installed */
69         CHAR16 name[FILEOPS_NAME_MAXLEN];
70 } fileops_t;
71
72 /* 
73  * used to register a new filsystem
74  */
75 typedef INTN (*fops_fs_glue_t)(fileops_t *this, VOID *intf);
76 typedef EFI_STATUS (*fops_fs_install_t)(VOID);
77 typedef EFI_STATUS (*fops_fs_uninstall_t)(VOID);
78
79 typedef struct {
80         EFI_GUID                proto;     /* GUID of filesystem */
81         fops_fs_glue_t          glue;      /* glue routine */
82         fops_fs_install_t       install;   /* to go away with real EFI drivers */
83         fops_fs_uninstall_t     uninstall; /* to go away with real EFI drivers */
84 } fileops_fs_t;
85
86
87 /*
88  * device description
89  */
90 #define FILEOPS_DEVNAME_MAXLEN  16
91
92 typedef struct {
93         EFI_HANDLE              dev;
94         fileops_t               *fops;
95         CHAR16                  name[FILEOPS_DEVNAME_MAXLEN];
96 } device_t;
97
98 extern INTN init_devices(EFI_HANDLE boot_handle);
99 extern INTN close_devices(VOID);
100 extern VOID print_devices(VOID);
101 extern EFI_STATUS fops_get_next_device(UINTN pidx, CHAR16 *type, UINTN maxlen, UINTN *idx, CHAR16 *name, EFI_HANDLE *dev);
102 extern INTN fops_split_path(CHAR16 *path, CHAR16 *dev);
103 extern EFI_STATUS fops_get_device_handle(CHAR16 *name, EFI_HANDLE *dev);
104
105 /*
106  * device naming schemes
107  *
108  * Interface:
109  *      the scheme() function arguments are:
110  *              - the list of detected bootable device
111  *              - the number of entries in that table as argument
112  *
113  *      There is no expected return value. If the scheme() cannot perform
114  *      its tasks, then IT MUST NOT OVERWRITE the generic naming scheme (devXXX) that
115  *      is ALWAYS installed by default. Partial modifications are possible, although
116  *      not recommended.
117  */
118 typedef struct {
119         CHAR16  *name;
120         INTN    (*install_scheme)(device_t *tab, UINTN ndev);
121 } devname_scheme_t;
122
123 #endif /* __FILEOPS_H__ */