⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dospartlibscsi.c

📁 Vxworks 官方demo源代码,对于嵌入式系统开发学习的人
💻 C
📖 第 1 页 / 共 5 页
字号:
should anyone need to implement it:LBA = (((cylinder * heads_per_cylinder + heads )         * sectors_per_track ) + sector - 1)Both of these can also be used with either LCHS or PCHS.If using LCHS, then you must use LCHS drive parameters.If using PCHS, then you must use PCHS drive parameters.The "N-Shift" Algorithm used for LCHS to PCHS translation is:   PCHS_cylinder = ( LCHS_cylinder * N ) + ( Lhead / NPH );   PCHS_head = ( LCHS_head % NPH );   PCHS_sector = LCHS_sector;DEBUGGING:----------This code may be compiled with -g and debugged within Tornado.Also the routine dosPartShowAta will show all partition datafor all partition table entries.  SUPPORT:--------This code was written in my "spare" time.  I would feel it to beviable code, so please send me (John Fabiani, johnx@wrs.com) anycomment or bug report, email only please.  This does not imply support for this code from Wind River Systems.  If you try to use this code without a thorough review, you are taking a risk.This is considered only an example.  I will endeavor to keep itworking well. KNOWN LIMITATIONS-----------------1.) This code does not write partition tables, ala MSDOS FDISK.exe.    This is the next thing I will be doing.  I have structured    this code accordingly in anticipation of coding VxFdisk().2.) This code must be spawned with an adequate stack size.    dosPartParse is recursive and could use a lot of stack:    To correctly spawn its routines from the shell:    -> sp dosPartMountScsi, pSysScsiCtrl    or    -> taskSpawn ("pMount",20,0,20000,dosPartMountScsi,pSysScsiCtrl)    or    -> sp dosPartShowScsi,pScsiPhysDev    or    -> taskSpawn ("pShow", 20, 0, 20000, dosPartShowScsi,pScsiPhysDev)    Do not call it directly from the shell ala:    -> dosPartMountScsi pSysScsiCtrl -- WRONG!, may overflow default stack.    -> dosPartShowScsi pScsiPhysDev  -- WRONG!, may overflow default stack.    Or else you will most likely overflow your stack if you have    not increased the default sp stack size.  This can be set    with the WindShell via:    -> ?         tcl> set spStackSize 100000    100000    tcl> ?    -> 3.) This code has only been tested with VxWorks 5.3.1 FCS.COMPILING THIS CODE:-------------------Standard vxWorks makes are expect.  Should work with any arch.Here are some examples:68K:----cc68k -BD:\10168k/host/x86-win32/lib/gcc-lib/ -m68040 -ansi -nostdinc -O -fvolatile -fno-builtin -Wall -I/h   -I. -ID:\10168k\target\config\all -ID:\10168k\target/h -ID:\10168k\target/src/config -ID:\10168k\target/src/drv -DCPU=MC68040      -c dosPartLibAta.ccc68k -BD:\10168k/host/x86-win32/lib/gcc-lib/ -m68040 -ansi -nostdinc -O -fvolatile -fno-builtin -Wall -I/h   -I. -ID:\10168k\target\config\all -ID:\10168k\target/h -ID:\10168k\target/src/config -ID:\10168k\target/src/drv -DCPU=MC68040-c dosPartLibScsi.cI960:-----cc960 -BC:\Sirocco/host/x86-win32/lib/gcc-lib/ -mca -mstrict-align -ansi -nostdinc -O -fvolatile -fno-builtin  -Wall -I/h   -I. -IC:\Sirocco\target\config\all -IC:\Sirocco\target/h -IC:\Sirocco\target/src/config -IC:\Sirocco\target/src/drv -DCPU=I960CA -DVX_IGNORE_GNU_LIBS     -c dosPartLibScsi.c80x86:------cc386 -BC:\Sirocco/host/x86-win32/lib/gcc-lib/ -m486 -ansi -nostdinc -O -fvolatile -nostdlib -fno-builtin -fno-defer-pop -Wall -I/h   -I. -IC:\Sirocco\target\config\all -IC:\Sirocco\target/h -IC:\Sirocco\target/src/config -IC:\Sirocco\target/src/drv -DCPU=I80486      -c dosPartLibScsi.cSOME GENERIC USAGE EXAMPLES:------------------------------------------------------------------------------    ***********************************************************1.) EXAMPLE OF USING "dosPartMountAta (ctrl, drive)" ON A DRIVE    CONTAINING TEN PARTITIONS OF VARIOUS SIZES: MSDOS C: - L:     ***********************************************************    -> ld < c:\dosPartLib\dosPartLibAta.o    value = 14364680 = 0xdb3008    -> sp dosPartMountAta,0,0                task spawned: id = 1fb4788, name = u1    value = 33245064 = 0x1fb4788    ->     Mounting partition 00 - VxWorks device Name "/ataCtrl0Drive0Part0"    Absolute sector: 0x0000003f  Number of sectors: 0x00005e41    Approximate Partition size: 11 MBs    Mounting partition 01 - VxWorks device Name "/ataCtrl0Drive0Part1"    Absolute sector: 0x00005ebf  Number of sectors: 0x00018981    Approximate Partition size: 49 MBs    Mounting partition 02 - VxWorks device Name "/ataCtrl0Drive0Part2"    Absolute sector: 0x0001e87f  Number of sectors: 0x0003b0c1    Approximate Partition size: 118 MBs    Mounting partition 03 - VxWorks device Name "/ataCtrl0Drive0Part3"    Absolute sector: 0x0005997f  Number of sectors: 0x00001f41    Approximate Partition size: 3 MBs    Mounting partition 04 - VxWorks device Name "/ataCtrl0Drive0Part4"    Absolute sector: 0x0005b8ff  Number of sectors: 0x00022701    Approximate Partition size: 68 MBs    Mounting partition 05 - VxWorks device Name "/ataCtrl0Drive0Part5"    Absolute sector: 0x0007e03f  Number of sectors: 0x00018981    Approximate Partition size: 49 MBs    Mounting partition 06 - VxWorks device Name "/ataCtrl0Drive0Part6"    Absolute sector: 0x000969ff  Number of sectors: 0x00013ac1    Approximate Partition size: 39 MBs    Mounting partition 07 - VxWorks device Name "/ataCtrl0Drive0Part7"    Absolute sector: 0x000aa4ff  Number of sectors: 0x00044e41    Approximate Partition size: 137 MBs    Mounting partition 08 - VxWorks device Name "/ataCtrl0Drive0Part8"    Absolute sector: 0x000ef37f  Number of sectors: 0x000a6581    Approximate Partition size: 332 MBs    Mounting partition 09 - VxWorks device Name "/ataCtrl0Drive0Part9"    Absolute sector: 0x0019593f  Number of sectors: 0x00071301    Approximate Partition size: 226 MBs    -> devs    drv name      0 /null      1 /tyCo/0      1 /tyCo/1      2 /pcConsole/0      2 /pcConsole/1      7 eno:      8 /vio      4 /ataCtrl0Drive0Part0      4 /ataCtrl0Drive0Part1      4 /ataCtrl0Drive0Part2      4 /ataCtrl0Drive0Part3      4 /ataCtrl0Drive0Part4      4 /ataCtrl0Drive0Part5      4 /ataCtrl0Drive0Part6      4 /ataCtrl0Drive0Part7      4 /ataCtrl0Drive0Part8      4 /ataCtrl0Drive0Part9    value = 0 = 0x0    ->     -> dosFsConfigShow "/ataCtrl0Drive0Part6"    device name:               /ataCtrl0Drive0Part6    total number of sectors:   80577    bytes per sector:          512    media byte:                0xf8    # of sectors per cluster:  4    # of reserved sectors:     1    # of FAT tables:           2    # of sectors per FAT:      79    max # of root dir entries: 512    # of hidden sectors:       63    removable medium:          TRUE    disk change w/out warning: not enabled    auto-sync mode:            not enabled    long file names:           not enabled    exportable file system:    not enabled    lowercase-only filenames:  not enabled    volume mode:               O_RDWR (read/write)    available space:           41148416 bytes    max avail. contig space:   32360448 bytes    value = 0 = 0x0    -> ------------------------------------------------------------------------------    ***********************************************************2.) EXAMPLE OF USING "dosPartShowAta (ctrl, drive) ON DISK WITH    MULTIPLE PARTITIONS. (some output deleted to save space)    ***********************************************************        -> sp (dosPartShowAta,0,0)                     task spawned: id = 1fb47b0, name = u1    value = 33245104 = 0x1fb47b0    ->     +--------------------------------------+    | Master Boot Record - Partition Table |    +--------------------------------------+----------+    | Current LCHS Cylinder 0000, Head 000, Sector 00 |    +-----------------------------+-------------------+---------+    | Partition Entry number 04   | Partition Entry offset 0x1be|    +-----------------------------+-----------------------------+    | Status field = 0x80         | Primary (bootable) Partition|    +-----------------------------+-----------------------------+    | Type 0x01: MSDOS Partition 12-bit FAT                     |    +-----------------------------------------------------------+    | Partition start LCHS: Cylinder 0000, Head 001, Sector 01  |    +-----------------------------------------------------------+    | Partition end   LCHS: Cylinder 0005, Head 063, Sector 63  |    +-----------------------------------------------------------+    | Sectors offset from MBR partition 0x0000003f              |    +-----------------------------------------------------------+    | Number of sectors in partition 0x00005e41                 |    +-----------------------------------------------------------+    | Sectors offset from start of disk 0x0000003f              |    +-----------------------------------------------------------+    +--------------------------------------+    | Master Boot Record - Partition Table |    +--------------------------------------+----------+    | Current LCHS Cylinder 0000, Head 000, Sector 00 |    +-----------------------------+-------------------+---------+    | Partition Entry number 03   | Partition Entry offset 0x1ce|    +-----------------------------+-----------------------------+    | Status field = 0x00         | Non-bootable Partition      |    +-----------------------------+-----------------------------+    | Type 0x05: MSDOS Extended Partition                       |    +-----------------------------------------------------------+    | Partition start LCHS: Cylinder 0006, Head 000, Sector 01  |    +-----------------------------------------------------------+    | Partition end   LCHS: Cylinder 0014, Head 063, Sector 63  |    +-----------------------------------------------------------+    | Sectors offset from MBR partition 0x00005e80              |    +-----------------------------------------------------------+    | Number of sectors in partition 0x00200dc0                 |    +-----------------------------------------------------------+    | Sectors offset from start of disk 0x00005e80              |    +-----------------------------------------------------------+    +--------------------------------------+    | Master Boot Record - Partition Table |    +--------------------------------------+----------+    | Current LCHS Cylinder 0000, Head 000, Sector 00 |    +-----------------------------+-------------------+---------+    | Partition Entry number 02   | Partition Entry offset 0x1de|    +-----------------------------+-----------------------------+    | Status field = 0x00         | Non-bootable Partition      |    +-----------------------------+-----------------------------+    | Type 0x00: Empty (NULL) Partition                         |    +-----------------------------------------------------------+    ....(REST of OUTPUT DELETED FOR SPACE).....        There is going to be a lot more output than above.  The above     is simply an example of the format.  dosPartShowAta will display    all four partition table entries for each partition sector.      For example, a disk with 4 logical drives (C,D,E, & F) will     contain 5 partition sectors and dosPartShowAta() will display    20 partition table entries.      Utilities such as Norton Utilities DISKEDIT (TM) do not    automaticly display extended partition data.  This must    be done manually.  That is not a restriction with dosPartShowAta.    dosPartShowAta will automatically display all extended partitions.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -