/* dosPartLibAta.c - show & mount ATA HDD MSDOS partitions */
/*
modification history
--------------------
01c,15sep97,jkf removed LCHS support. Only useful for MSDOS versions
before 3.3, not likely anyone needs LCHS support.
Added support for big endian arches and arches without
dynamic bus sizing, which involved byte swapping macro
and reading sector data with macro offsets. Now supports
80x86, 68k, SPARC, MIPS, PPC, i960, etc.) Revised docs.
01b,01sep97,jkf fixed check for LBA support in dosPartRdLbaAta().
fixed stdlib.h filename case for Unix.
fixed args to ataDevCreate in example comments.
fixed cosmetics in sector and show routines.
01a,01sep97,jkf written.
*/
/*
DESCRIPTION:
This library is provided by Wind River Systems Customer
Support strictly as an educational example.
This code supports both mounting and displaying partition
tables written by MSDOS FDISK.exe or by any other MSDOS
FDISK.exe compatible partitioning software.
The first partition table is contained within a hard drives
Master Boot Record (MBR) sector, which is defined as sector
one, cylinder zero, head zero or logical block address zero.
The mounting and displaying routines within this code will
first parse the MBR partition tables entries (defined below)
and also recursively parse any "extended" partition tables,
which may reside within another Cylinder, Head, and Sector
(CHS) combination further into the hard disk. (Also known
as extended partition tables chained from the MBR's partition
table. MSDOS file systems within extended partitions are known
to those familiar with the MSDOS FDISK.exe utility as "Logical
drives within the extended partition".
Since MSDOS file systems have a fixed number of clusters, 64Kb,
and clusters are the minimum allocation unit at the file system
level, using partitions can help optimize cluster size for a given
hard disk, improving performance and resource usage. For example,
a 1-gigabyte hard disk with a single MSDOS file system has the
following minimum allocation unit at the dosFsLib open/read/write
level interface:
1GB/64KB = Minimum allocation unit.
This may produce a minimum allocation unit that is larger than
what the developer desires (for cluster boundary buffer alignment,
or other buffering, ect).
One solution is to sub-divide the disk into smaller partitions
or "logical disks" on the single physical disk and format file
systems over each of the partitions. (Then using this code you
may mount them.) If you used four equal sized partitions, then
this method produces:
256MB/64KB = Minimum allocation unit.
256MB/64KB = Minimum allocation unit.
256MB/64KB = Minimum allocation unit.
256MB/64KB = Minimum allocation unit.
This produces a smaller minimum allocation unit and may be
better suited for optimal application file system performance.
Each partition contains its own unique file system. As far
as the file system level is concerned it is on a unique disk.
Here is a picture showing the layout of a single disk containing
multiple MSDOS file systems:
(Note, all ASCII pictures herein are best viewed with
an 'equally sized characters' or 'fixed width' style font)
+---------------------------------------------------------+
|<---------------------The entire disk------------------->|
|M |
|B<---C:---> |
|R /---- First extended partition--------------\|
| E<---D:---><-Rest of the ext part------------>|
|P x |
|A t E<---E:--->E<Rest of the ext part->|
|R x x |
|T t t<---------F:---------->|
+---------------------------------------------------------+
(Ext == extended partition sector)
A MS-DOS partition table resides within one sector on a hard
disk. There is always one in the first sector of a hard disk
partitioned with FDISK.exe. There first partition table may
contain references to "extended" partition tables residing on
other sectors if there are multiple partitions. The first
sector of the disk is the starting point. Partition tables
are of the format:
Offset from
the beginning
of the sector Description
------------- -------------------------
0x1be Partition 1 table entry (16 bytes)
0x1ce Partition 2 table entry (16 bytes)
0x1de Partition 3 table entry (16 bytes)
0x1ee Partition 4 table entry (16 bytes)
0x1fe Signature (0x55aa, 2 bytes)
Individual MSDOS partition table entries are of the format:
Offset Size Description
------ ---- ------------------------------
0x0 8 bits boot type
0x1 8 bits beginning sector head value
0x2 8 bits beginning sector (2 high bits of cylinder#)
0x3 8 bits beginning cylinder# (low order bits of cylinder#)
0x4 8 bits system indicator
0x5 8 bits ending sector head value
0x6 8 bits ending sector (2 high bits of cylinder#)
0x7 8 bits ending cylinder# (low order bits of cylinder#)
0x8 32 bits number of sectors preceding the partition
0xc 32 bits number of sectors in the partition
In the partition table entry, the Sector/Cylinder (16bits)
(offset 0x2 & 0x3) fields data are stored in the format:
|7|6|5|4|3|2|1|0| The first 8 bits of offset 0x2.
| | `------------ 6 least significant bit's contain the sector
| | offset within cylinder. sector == 6 bits.
| |
`-`-------------- Two most significant (high order) bits of the
cylinder value.
|7|6|5|4|3|2|1|0| 2nd 8 bits (cylinder 0x3)
`---------------- Eight least significant (low order) bits of the
cylinder value.
This format restricts partition entries to 10 cylinder bits & 6 sector
bits and 8 head bits. This is also the format used by the PC-AT BIOS
Int13h functions, which is used by FDISK.exe
dosPartLibAta/Scsi.c uses the following method of parsing the CHS values
stored in the 0x2 & 0x3 partition table offsets into distinct values:
Cyl = ((((dospt_startSec) & 0x00c0) << 2) |
(((dospt_startSec) & 0xff00) >> 8));
Hd = pPartTbl->dospt_startHead;
Sec = (pPartTbl->dospt_startSec & 0x003f);
(see DOS_PART_TBL struct typedef in dosFsLib.h)
This produces individual CHS value from the values that
are contained within the MSDOS partition table entry.
Definitions of CHS terms:
CHS - Cylinder/Head/Sector.
L-CHS - Logical - CHS (used by INT 13 AxH/FDISK.exe)
256 heads, 1024 cylinders, 63 sectors. max.
LCHS allow ~8.4 GB addressable space.
P-CHS - Physical CHS (used by physical ATA device)
16 heads, 65535 cylinders, 63 sectors.
PCHS allow ~137GB addressable space.
(VxWorks ataRawio() uses PCHS)
LBA - Logical Block Address. ATA/SCSI absolute sector
numbering scheme. LBA sector 0 == addresses the
first sector on a device by definition. ATA devices
may also support LBA at the device interface. ATA
standard says that cylinder 0, head 0, sector 1 == LBA 0.
LBA allows (~137GB) on an ATA device.
The MSDOS "logical CHS" (LCHS) format combined with the
Physical IDE/ATA CHS interface (PCHS) gives MSDOS the
following addressing limitation:
+------------+----------+----------------+
| BIOS INT13 | IDE/ATA | Combined Limit |
+-----------------+------------+----------+----------------+
|Max Sectors/Track| 63 | 255 | 63 |
+-----------------+------------+----------+----------------+
|Max Heads | 256 | 16 | 16 |
+--
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
VxWorks 下PCI 驱动编程 (575个子文件)
snmp-faq-1.1.ascii 65KB
rsscache(1).aspx 2KB
Relation.aspx 0B
RandomColumnContentJS.aspx 0B
rsscache.aspx 0B
WebResource(2).axd 21KB
WebResource.axd 20KB
WebResource(1).axd 2KB
windrvr.h.bak 47KB
plxdrv.c.bak 18KB
pci_diag_lib.c.bak 8KB
plxdrv.h.bak 419B
dosPartLibAta.c 127KB
dosPartLibScsi.c 124KB
toucan.c 77KB
i82527.c 69KB
plx9030.c 58KB
sja1000.c 55KB
plx9054.c 55KB
CANDrv.c 52KB
CANDrv.c 52KB
CANDrv.c 52KB
v_vxdemo.c 52KB
tcp_input.c 50KB
if_ppp.c 49KB
pppLib.c 48KB
can_api.c 45KB
lcp.c 44KB
options.c 36KB
if_ether.c 34KB
ip_input.c 33KB
p9050_lib.c 33KB
p9050_lib.c 33KB
ip_output.c 31KB
ipcp.c 31KB
crypt.c 29KB
sja1000_OK.c 28KB
uipc_sock.c 28KB
k_vxdemo.c 27KB
if_subr.c 27KB
plx9030_diag.c 26KB
in.c 25KB
radix.c 24KB
rtsock.c 24KB
route.c 23KB
uipc_mbuf.c 23KB
auth.c 23KB
uipc_sock2.c 22KB
if.c 22KB
ip_mroute.c 21KB
udp_usrreq.c 21KB
chap.c 21KB
plx9054_diag.c 20KB
plxdrv.c 20KB
plxdrv.c 20KB
tcp_output.c 20KB
snmpTask.c 20KB
in_pcb.c 18KB
ppp_vxworks.c 18KB
p9050_diag.c 18KB
fsm.c 17KB
RyDrv_Ht09.c 16KB
wnCAN.c 16KB
ip_icmp.c 16KB
来自网络上的CAN源程序.c 15KB
sl_compress.c 15KB
flash.c 15KB
tcp_usrreq.c 14KB
Hard_Can.c 13KB
random.c 13KB
pppShow.c 13KB
tcp_subr.c 13KB
upap.c 13KB
SJA1000_Drv.c 12KB
raw_ip.c 12KB
esd_pc104_200.c 11KB
ppp_md5.c 11KB
unixLib.c 11KB
tcp_timer.c 11KB
vxPing.c 10KB
pppSecretLib.c 10KB
igmp.c 10KB
kgl.c 9KB
kgl.c 9KB
demo.c 9KB
echoClient.c 9KB
selectDemo.c 9KB
setTimeOfDay.c 9KB
pci_diag_lib.c 8KB
mutexSemDemo.c 8KB
cpciMultiInt.c 8KB
echoServer.c 8KB
ppc5xxCAN.c 7KB
raw_usrreq.c 7KB
uipc_dom.c 7KB
deadlineWdDemo.c 7KB
esd_pci_200.c 7KB
msmcan.c 7KB
tcp_debug.c 7KB
posixTimerStartDemo.c 7KB
共 575 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- tiKros2019-07-02还是很不错哦
井中月_QCJ
- 粉丝: 23
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功