1 #ifndef _FSSH_DRIVERS_DRIVERS_H
2 #define _FSSH_DRIVERS_DRIVERS_H
5 #include "fssh_fs_interface.h"
13 these hooks are how the kernel accesses the device
16 typedef fssh_status_t (*fssh_device_open_hook
) (const char *name
,
17 uint32_t flags
, void **cookie
);
18 typedef fssh_status_t (*fssh_device_close_hook
) (void *cookie
);
19 typedef fssh_status_t (*fssh_device_free_hook
) (void *cookie
);
20 typedef fssh_status_t (*fssh_device_control_hook
) (void *cookie
, uint32_t op
,
21 void *data
, fssh_size_t len
);
22 typedef fssh_status_t (*fssh_device_read_hook
) (void *cookie
,
23 fssh_off_t position
, void *data
,
24 fssh_size_t
*numBytes
);
25 typedef fssh_status_t (*fssh_device_write_hook
) (void *cookie
,
26 fssh_off_t position
, const void *data
,
27 fssh_size_t
*numBytes
);
28 typedef fssh_status_t (*fssh_device_select_hook
) (void *cookie
, uint8_t event
,
29 uint32_t ref
, fssh_selectsync
*sync
);
30 typedef fssh_status_t (*fssh_device_deselect_hook
) (void *cookie
, uint8_t event
,
31 fssh_selectsync
*sync
);
32 typedef fssh_status_t (*fssh_device_read_pages_hook
)(void *cookie
,
33 fssh_off_t position
, const fssh_iovec
*vec
,
34 fssh_size_t count
, fssh_size_t
*_numBytes
);
35 typedef fssh_status_t (*fssh_device_write_pages_hook
) (void *cookie
,
36 fssh_off_t position
, const fssh_iovec
*vec
,
37 fssh_size_t count
, fssh_size_t
*_numBytes
);
39 #define FSSH_B_CUR_DRIVER_API_VERSION 2
42 the device_hooks structure is a descriptor for the device, giving its
47 fssh_device_open_hook open
; /* called to open the device */
48 fssh_device_close_hook close
; /* called to close the device */
49 fssh_device_free_hook free
; /* called to free the cookie */
50 fssh_device_control_hook control
; /* called to control the device */
51 fssh_device_read_hook read
; /* reads from the device */
52 fssh_device_write_hook write
; /* writes to the device */
53 fssh_device_select_hook select
; /* start select */
54 fssh_device_deselect_hook deselect
; /* stop select */
55 fssh_device_read_pages_hook read_pages
; /* scatter-gather physical read from the device */
56 fssh_device_write_pages_hook write_pages
; /* scatter-gather physical write to the device */
59 fssh_status_t
fssh_init_hardware(void);
60 const char **fssh_publish_devices(void);
61 fssh_device_hooks
*fssh_find_device(const char *name
);
62 fssh_status_t
fssh_init_driver(void);
63 void fssh_uninit_driver(void);
65 extern int32_t fssh_api_version
;
68 FSSH_B_GET_DEVICE_SIZE
= 1, /* get # bytes */
69 /* returns size_t in *data */
71 FSSH_B_SET_DEVICE_SIZE
, /* set # bytes */
72 /* passed size_t in *data */
74 FSSH_B_SET_NONBLOCKING_IO
, /* set to non-blocking i/o */
76 FSSH_B_SET_BLOCKING_IO
, /* set to blocking i/o */
78 FSSH_B_GET_READ_STATUS
, /* check if can read w/o blocking */
79 /* returns bool in *data */
81 FSSH_B_GET_WRITE_STATUS
, /* check if can write w/o blocking */
82 /* returns bool in *data */
84 FSSH_B_GET_GEOMETRY
, /* get info about device geometry */
85 /* returns struct geometry in *data */
87 FSSH_B_GET_DRIVER_FOR_DEVICE
, /* get the path of the executable serving that device */
89 FSSH_B_GET_PARTITION_INFO
, /* get info about a device partition */
90 /* returns struct partition_info in *data */
92 FSSH_B_SET_PARTITION
, /* create a user-defined partition */
94 FSSH_B_FORMAT_DEVICE
, /* low-level device format */
96 FSSH_B_EJECT_DEVICE
, /* eject the media if supported */
98 FSSH_B_GET_ICON
, /* return device icon (see struct below) */
100 FSSH_B_GET_BIOS_GEOMETRY
, /* get info about device geometry */
101 /* as reported by the bios */
102 /* returns struct geometry in *data */
104 FSSH_B_GET_MEDIA_STATUS
, /* get status of media. */
105 /* return fssh_status_t in *data: */
106 /* B_NO_ERROR: media ready */
107 /* B_DEV_NO_MEDIA: no media */
108 /* B_DEV_NOT_READY: device not ready */
109 /* B_DEV_MEDIA_CHANGED: media changed */
110 /* since open or last B_GET_MEDIA_STATUS */
111 /* B_DEV_MEDIA_CHANGE_REQUESTED: user */
112 /* pressed button on drive */
113 /* B_DEV_DOOR_OPEN: door open */
115 FSSH_B_LOAD_MEDIA
, /* load the media if supported */
117 FSSH_B_GET_BIOS_DRIVE_ID
, /* get bios id for this device */
119 FSSH_B_SET_UNINTERRUPTABLE_IO
, /* prevent cntl-C from interrupting i/o */
120 FSSH_B_SET_INTERRUPTABLE_IO
, /* allow cntl-C to interrupt i/o */
122 FSSH_B_FLUSH_DRIVE_CACHE
, /* flush drive cache */
123 FSSH_B_GET_PATH_FOR_DEVICE
, /* get the absolute path of the device */
124 FSSH_B_GET_ICON_NAME
, /* get an icon name identifier */
125 FSSH_B_GET_VECTOR_ICON
, /* retrieves the device's vector icon */
126 FSSH_B_GET_DEVICE_NAME
, /* get name, string buffer */
127 FSSH_B_TRIM_DEVICE
, /* trims blocks, see fs_trim_data */
129 FSSH_B_GET_NEXT_OPEN_DEVICE
= 1000, /* iterate through open devices */
130 FSSH_B_ADD_FIXED_DRIVER
, /* private */
131 FSSH_B_REMOVE_FIXED_DRIVER
, /* private */
133 FSSH_B_AUDIO_DRIVER_BASE
= 8000, /* base for codes in audio_driver.h */
134 FSSH_B_MIDI_DRIVER_BASE
= 8100, /* base for codes in midi_driver.h */
135 FSSH_B_JOYSTICK_DRIVER_BASE
= 8200, /* base for codes in joystick.h */
136 FSSH_B_GRAPHIC_DRIVER_BASE
= 8300, /* base for codes in graphic_driver.h */
138 FSSH_B_DEVICE_OP_CODES_END
= 9999 /* end of Be-defined contol id's */
142 geometry structure for the B_GET_GEOMETRY opcode
146 uint32_t bytes_per_sector
; /* sector size in bytes */
147 uint32_t sectors_per_track
; /* # sectors per track */
148 uint32_t cylinder_count
; /* # cylinders */
149 uint32_t head_count
; /* # heads */
150 uint8_t device_type
; /* type */
151 bool removable
; /* non-zero if removable */
152 bool read_only
; /* non-zero if read only */
153 bool write_once
; /* non-zero if write-once */
154 } fssh_device_geometry
;
158 Be-defined device types returned by B_GET_GEOMETRY. Use these if it makes
159 sense for your device.
163 FSSH_B_DISK
= 0, /* Hard disks, floppy disks, etc. */
164 FSSH_B_TAPE
, /* Tape drives */
165 FSSH_B_PRINTER
, /* Printers */
166 FSSH_B_CPU
, /* CPU devices */
167 FSSH_B_WORM
, /* Write-once, read-many devices */
168 FSSH_B_CD
, /* CD ROMS */
169 FSSH_B_SCANNER
, /* Scanners */
170 FSSH_B_OPTICAL
, /* Optical devices */
171 FSSH_B_JUKEBOX
, /* Jukeboxes */
172 FSSH_B_NETWORK
/* Network devices */
177 partition_info structure used by B_GET_PARTITION_INFO and B_SET_PARTITION
181 fssh_off_t offset
; /* offset (in bytes) */
182 fssh_off_t size
; /* size (in bytes) */
183 int32_t logical_block_size
; /* logical block size of partition */
184 int32_t session
; /* id of session */
185 int32_t partition
; /* id of partition */
186 char device
[256]; /* path to the physical device */
187 } fssh_partition_info
;
190 driver_path structure returned by the B_GET_DRIVER_FOR_DEVICE
193 typedef char fssh_driver_path
[256];
197 open_device_iterator structure used by the B_GET_NEXT_OPEN_DEVICE opcode
201 uint32_t cookie
; /* must be set to 0 before iterating */
202 char device
[256]; /* device path */
203 } fssh_open_device_iterator
;
207 icon structure for the B_GET_ICON opcode
211 int32_t icon_size
; /* icon size requested */
212 void *icon_data
; /* where to put 'em (usually BBitmap->Bits()) */
216 /* B_TRIM_DEVICE data structure */
218 uint32_t range_count
;
219 uint64_t trimmed_size
; /* filled on return */
221 uint64_t offset
; /* offset (in bytes) */
231 #endif /* _FSSH_DRIVERS_DRIVERS_H */