- Implemented execp*.
[planlOS.git] / system / include / fs / scsi.h
blob4bda660d9e3071bfd4c29199254a8c88f8239400
1 /*
2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 /**
22 * \file scsi.h
23 * SCSI device interface.
26 #ifndef FS_SCSI_H_INCLUDED
27 #define FS_SCSI_H_INCLUDED
29 #include "ke/spinlock.h"
31 /**
32 * SCSI packet direction.
34 typedef enum
36 FS_SCSI_NO_DATA,
37 FS_SCSI_READ,
38 FS_SCSI_WRITE
39 } FsSCSIDirection;
41 /**
42 * SCSI packet data
44 typedef struct
46 /**
47 * Packet direction.
49 FsSCSIDirection direction;
50 /**
51 * Data buffer.
53 void *buffer;
54 /**
55 * Number of bytes to be read/written.
57 uint32_t length;
59 /**
60 * SCSI command.
62 uint8_t command[16];
63 /**
64 * Size of the SCSI command.
66 uint8_t commandsize;
67 } FsSCSIPacket;
69 /**
70 * SCSI device information.
72 typedef struct FsSCSIDevice
74 /**
75 * Callback for file system requests.
77 int (*request)(struct FsSCSIDevice *device, FsSCSIPacket *packet);
78 /**
79 * Lock to protect device agains multiple simultaneous accesses.
81 KeSpinlock opened;
82 } FsSCSIDevice;
84 /**
85 * Registers a new SCSI device.
87 int fsRegisterSCSIDevice(FsSCSIDevice *device);
88 /**
89 * Removes an SCSI device from the system.
91 int fsRemoveSCSIDevice(FsSCSIDevice *device);
93 /**
94 * Returns the number of registered SCSI devices.
96 uint32_t fsGetSCSIDeviceCount(void);
97 /**
98 * Opens a single SCSI device.
100 FsSCSIDevice *fsOpenSCSIDevice(uint32_t index);
102 * Closes an SCSI device.
104 void fsCloseSCSIDevice(FsSCSIDevice *device);
106 #endif