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