📄 storage_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>usbstack: /home/bene/projects/sl811/usbstack/drivers/class/storage.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.1 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> </ul></div><div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul></div><h1>/home/bene/projects/sl811/usbstack/drivers/class/storage.h</h1><a href="storage_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span><a name="l00002"></a>00002 <span class="comment"> * Copyright (c) 2007, Benedikt Sauter <sauter@ixbat.de></span><a name="l00003"></a>00003 <span class="comment"> * All rights reserved.</span><a name="l00004"></a>00004 <span class="comment"> *</span><a name="l00005"></a>00005 <span class="comment"> * Short descripton of file:</span><a name="l00006"></a>00006 <span class="comment"> *</span><a name="l00007"></a>00007 <span class="comment"> *</span><a name="l00008"></a>00008 <span class="comment"> * Redistribution and use in source and binary forms, with or without </span><a name="l00009"></a>00009 <span class="comment"> * modification, are permitted provided that the following conditions </span><a name="l00010"></a>00010 <span class="comment"> * are met:</span><a name="l00011"></a>00011 <span class="comment"> *</span><a name="l00012"></a>00012 <span class="comment"> * * Redistributions of source code must retain the above copyright </span><a name="l00013"></a>00013 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span><a name="l00014"></a>00014 <span class="comment"> * * Redistributions in binary form must reproduce the above </span><a name="l00015"></a>00015 <span class="comment"> * copyright notice, this list of conditions and the following </span><a name="l00016"></a>00016 <span class="comment"> * disclaimer in the documentation and/or other materials provided </span><a name="l00017"></a>00017 <span class="comment"> * with the distribution.</span><a name="l00018"></a>00018 <span class="comment"> * * Neither the name of the FH Augsburg nor the names of its </span><a name="l00019"></a>00019 <span class="comment"> * contributors may be used to endorse or promote products derived </span><a name="l00020"></a>00020 <span class="comment"> * from this software without specific prior written permission.</span><a name="l00021"></a>00021 <span class="comment"> *</span><a name="l00022"></a>00022 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS </span><a name="l00023"></a>00023 <span class="comment"> * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT </span><a name="l00024"></a>00024 <span class="comment"> * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR </span><a name="l00025"></a>00025 <span class="comment"> * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT </span><a name="l00026"></a>00026 <span class="comment"> * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, </span><a name="l00027"></a>00027 <span class="comment"> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT </span><a name="l00028"></a>00028 <span class="comment"> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, </span><a name="l00029"></a>00029 <span class="comment"> * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY </span><a name="l00030"></a>00030 <span class="comment"> * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT </span><a name="l00031"></a>00031 <span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE </span><a name="l00032"></a>00032 <span class="comment"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span><a name="l00033"></a>00033 <span class="comment"> */</span><a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keywordtype">void</span> <a class="code" href="storage_8c.html#0a6c6c3eb155433864323844b151598f">usb_storage_probe</a>();<a name="l00036"></a>00036 <span class="keywordtype">void</span> <a class="code" href="storage_8c.html#970ba00b5d6db799471427b0a3d3151f">usb_storage_check</a>();<a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="comment">/* CSW Status Definitions */</span><a name="l00039"></a><a class="code" href="storage_8h.html#003fe6041f1af12ae0e82bd653294389">00039</a> <span class="preprocessor">#define CSW_CMD_PASSED 0x00</span><a name="l00040"></a><a class="code" href="storage_8h.html#23b45004778ff0ce250cb515f18dad5c">00040</a> <span class="preprocessor"></span><span class="preprocessor">#define CSW_CMD_FAILED 0x01</span><a name="l00041"></a><a class="code" href="storage_8h.html#608103cbe99dcb4501bf74754adf17dd">00041</a> <span class="preprocessor"></span><span class="preprocessor">#define CSW_PHASE_ERROR 0x02</span><a name="l00042"></a>00042 <span class="preprocessor"></span><a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="comment">/* SCSI Commands */</span><a name="l00045"></a><a class="code" href="storage_8h.html#e9e768d850fcb29e45bab0df02a356d1">00045</a> <span class="preprocessor">#define SCSI_TEST_UNIT_READY 0x00</span><a name="l00046"></a><a class="code" href="storage_8h.html#c21bf0803bcdb4ade96e2eb6ce4ef847">00046</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_REQUEST_SENSE 0x03</span><a name="l00047"></a><a class="code" href="storage_8h.html#d699eaa4a55233cd0d8aed810ccb3996">00047</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_FORMAT_UNIT 0x04</span><a name="l00048"></a><a class="code" href="storage_8h.html#b4c8f5b2d1f25d97b00b9df156ccc283">00048</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_INQUIRY 0x12</span><a name="l00049"></a><a class="code" href="storage_8h.html#8df08cd2d2b645f319615d6ad78e86f0">00049</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_MODE_SELECT6 0x15</span><a name="l00050"></a><a class="code" href="storage_8h.html#31b2ec05301e98b1f9ab4e59c59772aa">00050</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_MODE_SENSE6 0x1A</span><a name="l00051"></a><a class="code" href="storage_8h.html#9dbe602f6f065f56340568451b4a9714">00051</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_START_STOP_UNIT 0x1B</span><a name="l00052"></a><a class="code" href="storage_8h.html#daebe7b81c3c81cff86563f4b1bfd7ea">00052</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_MEDIA_REMOVAL 0x1E</span><a name="l00053"></a><a class="code" href="storage_8h.html#960cfd4a1fcfa106b2dd51d406732b38">00053</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_READ_FORMAT_CAPACITIES 0x23</span><a name="l00054"></a><a class="code" href="storage_8h.html#3dc6f7fadac7bfeffb644345a3adc670">00054</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_READ_CAPACITY 0x25</span><a name="l00055"></a><a class="code" href="storage_8h.html#4f9d424a949ee51924aa88f283afb085">00055</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_READ10 0x28</span><a name="l00056"></a><a class="code" href="storage_8h.html#4a9efd10e4c1670e2c3546f937e9cb34">00056</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_WRITE10 0x2A</span><a name="l00057"></a><a class="code" href="storage_8h.html#4f799250b498efb9dc2378a7a1baa302">00057</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_VERIFY10 0x2F</span><a name="l00058"></a><a class="code" href="storage_8h.html#e3bf7ade89179f73ff189241aa7dd48a">00058</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_MODE_SELECT10 0x55</span><a name="l00059"></a><a class="code" href="storage_8h.html#c7a3a604d44ff9de57300f4720578fc9">00059</a> <span class="preprocessor"></span><span class="preprocessor">#define SCSI_MODE_SENSE10 0x5A</span><a name="l00060"></a>00060 <span class="preprocessor"></span><a name="l00061"></a>00061 <a name="l00062"></a><a class="code" href="storage_8h.html#00dcca05b811f4b988868c2fe5335fc5">00062</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structusb__storage__cbw__t.html">usb_storage_cbw_t</a> <a class="code" href="storage_8h.html#00dcca05b811f4b988868c2fe5335fc5">usb_storage_cbw</a>;<a name="l00063"></a><a class="code" href="structusb__storage__cbw__t.html">00063</a> <span class="keyword">struct </span><a class="code" href="structusb__storage__cbw__t.html">usb_storage_cbw_t</a> {<a name="l00064"></a><a class="code" href="structusb__storage__cbw__t.html#4a1c919590ce9f3415e4dc78e47a2f6f">00064</a> u32 <a class="code" href="structusb__storage__cbw__t.html#4a1c919590ce9f3415e4dc78e47a2f6f">dCBWSignature</a>;<a name="l00065"></a><a class="code" href="structusb__storage__cbw__t.html#171af10bdf8ae10d9f20c6c0e1ff7ff4">00065</a> u32 <a class="code" href="structusb__storage__cbw__t.html#171af10bdf8ae10d9f20c6c0e1ff7ff4">dCBWTag</a>;<a name="l00066"></a><a class="code" href="structusb__storage__cbw__t.html#03904c09dd6f942bec51cbf0dbc112e3">00066</a> u32 <a class="code" href="structusb__storage__cbw__t.html#03904c09dd6f942bec51cbf0dbc112e3">dCBWDataTransferLength</a>;<a name="l00067"></a><a class="code" href="structusb__storage__cbw__t.html#0b147ba046d8898bd3b64d709a6c12d4">00067</a> u8 <a class="code" href="structusb__storage__cbw__t.html#0b147ba046d8898bd3b64d709a6c12d4">bCWDFlags</a>;<a name="l00068"></a><a class="code" href="structusb__storage__cbw__t.html#5a30c52c921d8253a586c84207216997">00068</a> u8 <a class="code" href="structusb__storage__cbw__t.html#5a30c52c921d8253a586c84207216997">bCBWLun</a>;<a name="l00069"></a><a class="code" href="structusb__storage__cbw__t.html#4b27476d6594da8639355b86493f3a4e">00069</a> u8 <a class="code" href="structusb__storage__cbw__t.html#4b27476d6594da8639355b86493f3a4e">bCBWCBLength</a>;<a name="l00070"></a><a class="code" href="structusb__storage__cbw__t.html#47dfef9abc873791f72d8579af1e0387">00070</a> u8 <a class="code" href="structusb__storage__cbw__t.html#47dfef9abc873791f72d8579af1e0387">CBWCB</a>[16];<a name="l00071"></a>00071 };<a name="l00072"></a>00072 <a name="l00073"></a><a class="code" href="storage_8h.html#a1dd7d076cbff1f64ee876dfc93900ed">00073</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structusb__storage__csw__t.html">usb_storage_csw_t</a> <a class="code" href="storage_8h.html#a1dd7d076cbff1f64ee876dfc93900ed">usb_storage_csw</a>;<a name="l00074"></a><a class="code" href="structusb__storage__csw__t.html">00074</a> <span class="keyword">struct </span><a class="code" href="structusb__storage__csw__t.html">usb_storage_csw_t</a> {<a name="l00075"></a><a class="code" href="structusb__storage__csw__t.html#7650509b5265eca7c68ce06dd0bded17">00075</a> u32 <a class="code" href="structusb__storage__csw__t.html#7650509b5265eca7c68ce06dd0bded17">dCSWSignature</a>;<a name="l00076"></a><a class="code" href="structusb__storage__csw__t.html#40746de282fab1ebfda5e7b93eb1ed9e">00076</a> u32 <a class="code" href="structusb__storage__csw__t.html#40746de282fab1ebfda5e7b93eb1ed9e">dCSWTag</a>;<a name="l00077"></a><a class="code" href="structusb__storage__csw__t.html#d475590bd8f69d6fe8c9ad9e270af68b">00077</a> u32 <a class="code" href="structusb__storage__csw__t.html#d475590bd8f69d6fe8c9ad9e270af68b">dCSWDataResidue</a>;<a name="l00078"></a><a class="code" href="structusb__storage__csw__t.html#8fa73c56f5f661bc74f777f721229470">00078</a> u8 <a class="code" href="structusb__storage__csw__t.html#8fa73c56f5f661bc74f777f721229470">bCSWStatus</a>;<a name="l00079"></a>00079 };<a name="l00080"></a>00080 <a name="l00081"></a>00081 <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a name="l00084"></a>00084 <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="keywordtype">void</span> <a class="code" href="storage_8c.html#52045de442f01c1fa8498142802b2677">usb_storage_init</a>();<a name="l00087"></a>00087 <a name="l00088"></a>00088 u8 <a class="code" href="storage_8c.html#9cb488439837f7cc33205637dacd74bd">usb_storage_open</a>(u8 device);<a name="l00089"></a>00089 <a name="l00090"></a>00090 u8 <a class="code" href="storage_8c.html#2bfcaffcb1a2abc12372dac39bcbdf3b">usb_storage_read_capacity</a>(u8 device);<a name="l00091"></a>00091 u8 <a class="code" href="storage_8c.html#4d0f224bc7398d381944304e85b01cd2">usb_storage_inquiry</a>(u8 device);<a name="l00092"></a>00092 u8 <a class="code" href="storage_8c.html#c95fa60ab8bc84aa3c4c9cd7b8337c0d">usb_storage_read_sector</a>(u8 device, u32 sector, <span class="keywordtype">char</span> * buf);<a name="l00093"></a>00093 u8 <a class="code" href="storage_8c.html#33504a0f1a785365f956ee06fa97d49d">usb_storage_write_sector</a>(u8 device, u32 sector, <span class="keywordtype">char</span> * buf);</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 17 08:14:10 2007 for usbstack by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -