📄 dospartlibata.c
字号:
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 dosPartMountAta,0,0 or -> taskSpawn ("pMount", 20, 0, 20000, dosPartMountAta,0,0) or -> sp dosPartShowAta,0,0 or -> taskSpawn ("pShow", 20, 0, 20000, dosPartShowAta,0,0) Do not call it directly from the shell ala: -> dosPartMountAta 0,0 -- WRONG!, may overflow default stack. -> dosPartShowAta 0,0 -- 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 expected. 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 ataDrv() INFORMATION:--------------------------The VxWorks ataDrv() drivers ATA parameters in (setup in the BSP file $WIND_BASE/target/config/pc486/pc.h) for ATA0_CONFIG and ATA1_CONFIG must be setup appropriately for the particularsystem.At the ataDrv driver level:If ATA_GEO_CURRENT is used, ataDrv() uses current drives(PCHS) geometry parameters, if possible.If ATA_GEO_PHYSICAL is used, the ata driver uses the physicalgeometry parameters stored on the drive, if possible. If ATA_GEO_FORCE is used, the ata driver uses values stored in the "ataTypes[][]" table in sysLib.c. The geometry parametersare the number of sectors per track, the number of heads, andthe number of cylinders. The ataTypes[][] table has two entries:the first is for drive 0, the second is for drive 1. The table has two other members which are used by the driver. They are thenumber of bytes per sector and the write pre-compensation cylinder.These two members should also be set to properly match the BIOS/OSsetting used. These settings will be attempted to be translatedby dosPartRdLChsAta().For the PC x86 BSP's ATA_GEO_CURRENT is the default for VxWorks5.3.1 FCS. ATA_GEO_CURRENT is the recommended setting for newerdrives and BIOS's and when using this code. Else ataTypes mustprecisely match what the other BIOS/OS/Controller uses for PCHS.By default, with INCLUDE_ATA, vxWorks is setup for one ATA deviceon the first controller. The others are disabled to prevent timeouts.If you have more than one hard disk (two per controller max.) or morethan one controller (two max) then you must modify the ataResourcesstruct array in sysLib.c to support more drives.For example, to support two controllers, each with two drives:(4 drives total) I defined ataResources as follows:ATA_RESOURCE ataResources[ATA_MAX_CTRLS] = { { { 5, 0, {ATA0_IO_START0, ATA0_IO_START1}, {ATA0_IO_STOP0, ATA0_IO_STOP1}, 0, 0, 0, 0, 0, 0 }, IDE_LOCAL, ATA0_NUM_DRIVES, ATA0_INT_VEC, ATA0_INT_LVL, ATA0_CONFIG, ATA_SEM_TIMEOUT, ATA_WDG_TIMEOUT, 0, 0 }, { { 5, 0, {ATA1_IO_START0, ATA1_IO_START1}, {ATA1_IO_STOP0, ATA1_IO_STOP1}, 0, 0, 0, 0, 0, 0 }, IDE_LOCAL, ATA1_NUM_DRIVES, ATA1_INT_VEC, ATA1_INT_LVL, ATA1_CONFIG, ATA_SEM_TIMEOUT, ATA_WDG_TIMEOUT, 0, 0 } };Where:ATA0_NUM_DRIVES and ATA1_NUM_DRIVES are defined as 2.ATA0_INT_LVL is defined as 0x0e.ATA1_INT_LVL is defined as 0x0f.And all other macros are defined per the default values as shipped with pc386/pc486 BSP's.SOME 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 | +-----------------------------+-------------------+---------+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -