|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2005-10-31 11:12 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2005-11-1 16:30 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
CHS和LBA确实不是同一个算法,但我认为并不是在BIOS层面上,而是在ATA接口层面上。ATA接口的硬盘寻址寄存器(现以28bit寻址为讨论基础,48bit暂不讨论)分别用了16位,4位和8位来分别表示柱面数、磁头数和扇区数;所以,如果以CHS方式来寻址的话,最大可寻址空间为 2^16 * 2^4 * (2^8-1) = 267386880 个扇区,也就是 136,902,082,560 byte;如果把整个28位用来作表示为一个LBA的线性地址的话,那就是可寻址 2^28 = 268435456 个扇区,也就是 137,438,953,472 byte。这也就是两种方式最大可寻址空间的区别。
具体到某个硬盘是否如你计算所表达的那样我表示怀疑。还是以那块60G的硬盘为例,为了简便起见我们就以扇区为计算单位(其实都一样)。假如按照CHS模式的话,三个参数都在允许的范围以内。但假如按照LBA模式的话 0111111111111111110100110100(B) => 134,217,012(D) 所表示的扇区数已经超出这块硬盘的实际实用扇区数了。反过来,这块硬盘的最大实用扇区数为 120,103,200 (D) => 0111001010001010000100100000(B) 28bit,这个数值无论怎么分割也凑不成该模式下CHS各个参数的。
我们再把那块60G的硬盘的参数的表格扩充计算一下:
LBA Sector count: 120,103,200 sectors
Head * Sector * Cylinder = Total Sectors | Remain | Sectors/Cylinder
| |
CHS 16 255 29437 120,102,960 | 240 | 4080
| |
LARGE 240 255 1962 120,074,400 | 28800 | 61200
| |
LBA 255 63 7476 120,101,940 | 1260 | 16065
通过上面这个例子可以看出,无论哪种模式下,逻辑上的CHS参数乘积所得到的总扇区数都小于LBA(注意,此LBA非彼LBA,下面会说明)所给出的总扇区数,而且剩余的扇区数都不到该模式下每柱面的扇区数,也就是不足以构成一个柱面。因此,我认为CHS和LBA算法的不同只是表现在ATA接口层面上,而在BIOS层面上所显示出的各个模式的各个CHS参数都是以ATA接口的LBA总扇区数为基础进行换算的,而且是以柱面为单位分配的,所有这些柱面相加的总扇区数不超过LBA给出的总的扇区数,不足的部分省略。
说了那么多的LBA和CHS,我认为有必要说明一下,不然的话很可能会引起混淆
我认为有两个LBA的概念,一个是ATA层次上的 LBA ,也就是这个硬盘内部的可线性寻址的最大扇区数,我认为这就是这块硬盘的最大可用扇区数;而另一个 LBA 是指在BIOS层面上,也就是BIOS向OS报告的它的寻址模式。
同样,有两个CHS概念,一个是指 CHS模式 ,也就是BIOS的一种寻址方式;而另一个是 CHS参数 ,是所有模式下都要用到的柱面、磁头、扇区数的参数。
到此为止,我认为我们可以暂且得出一个结论,也就是我在表格下面的第一段话。对于这个结论我没有什么理论依据和实际实验来证明其正确性,只能通过纸面上的一些数据来“自圆其说”。关于两个LBA和CHS的概念也是我自己分析的结论,同样没有什么理论基础。现在,尽管还有许多细节问题没有搞清楚,比如 PC Tools 5.0 的逻辑定位问题,但我认为我们还是取得了一定的进展。真是非常感谢所有参与讨论和关注此问题的朋友,特别是 fdsiuha 。同时也希望有更多的朋友能提供试验数据和提出理论假设,也希望有功底深厚的大师能不惜赐教。
Last edited by DOSforever on 2005-11-1 at 16:48 ]
CHS and LBA are indeed not the same algorithm, but I think it's not at the BIOS level, but at the ATA interface level. The ATA interface's hard disk addressing registers (taking 28-bit addressing as the basis for discussion, 48-bit is not discussed for the time being) use 16 bits, 4 bits, and 8 bits respectively to represent the number of cylinders, the number of heads, and the number of sectors; so, if addressing in CHS mode, the maximum addressable space is 2^16 * 2^4 * (2^8 - 1) = 267386880 sectors, which is 136,902,082,560 bytes; if the entire 28 bits are used as a linear address expressed as LBA, then it is addressable 2^28 = 268435456 sectors, which is 137,438,953,472 bytes. This is the difference in the maximum addressable space between the two methods.
I have doubts about whether a specific hard disk is as calculated by you. Still taking that 60G hard disk as an example, for the sake of simplicity, we will calculate in sectors (actually it's all the same). If according to the CHS mode, the three parameters are all within the allowable range. But if according to the LBA mode, 0111111111111111110100110100(B) => 134,217,012(D) the number of sectors represented has exceeded the actual usable number of sectors of this hard disk. Conversely, the maximum usable number of sectors of this hard disk is 120,103,200 (D) => 0111001010001010000100100000(B) 28bit, and this value can't be divided into the CHS parameters of this mode no matter how it is divided.
Let's expand and calculate the parameter table of that 60G hard disk:
LBA Sector count: 120,103,200 sectors
Head * Sector * Cylinder = Total Sectors | Remain | Sectors/Cylinder
| |
CHS 16 255 29437 120,102,960 | 240 | 4080
| |
LARGE 240 255 1962 120,074,400 | 28800 | 61200
| |
LBA 255 63 7476 120,101,940 | 1260 | 16065
From the above example, it can be seen that in any mode, the product of the logical CHS parameters to get the total number of sectors is less than the total number of sectors given by LBA (note that this LBA is not the same as the other LBA, which will be explained below), and the remaining number of sectors is less than the number of sectors per cylinder in this mode, that is, it is not enough to form one cylinder. Therefore, I think the difference between the CHS and LBA algorithms is only manifested at the ATA interface level, and the various CHS parameters of each mode displayed at the BIOS level are all converted based on the total number of LBA sectors of the ATA interface, and are allocated in units of cylinders, and the total number of sectors of all these cylinders does not exceed the total number of sectors given by LBA, and the insufficient part is omitted.
Having said so much about LBA and CHS, I think it is necessary to explain, otherwise it is likely to cause confusion
I think there are two concepts of LBA. One is LBA at the ATA level, that is, the maximum number of sectors that can be linearly addressed inside this hard disk. I think this is the maximum available number of sectors of this hard disk; and the other LBA refers to at the BIOS level, that is, the addressing mode reported by the BIOS to the OS.
Similarly, there are two concepts of CHS. One refers to CHS mode, that is, an addressing method of the BIOS; and the other is CHS parameters, which are the parameters of the number of cylinders, heads, and sectors used in all modes.
Up to this point, I think we can tentatively draw a conclusion, which is the first paragraph below the table. I have no theoretical basis and practical experiments to prove the correctness of this conclusion, and I can only "justify" it through some data on paper. The two concepts of LBA and CHS are also conclusions analyzed by myself, and there is no theoretical basis. Now, although there are still many details that are not clear, such as the logical positioning problem of PC Tools 5.0, I think we have made some progress. Thank you very much to all the friends who participated in the discussion and paid attention to this problem, especially fdsiuha. At the same time, I hope that more friends can provide test data and put forward theoretical assumptions, and I also hope that masters with profound skills can not hesitate to give instructions.
Last edited by DOSforever on 2005-11-1 at 16:48 ]
|

DOS倒下了,但永远不死
DOS NEVER DIES !
投票调查:
http://www.cn-dos.net/forum/viewthread.php?tid=46187
本人尚未解决的疑难问题:
http://www.cn-dos.net/forum/viewthread.php?tid=15135
http://www.cn-dos.net/forum/viewthread.php?tid=47663
http://www.cn-dos.net/forum/viewthread.php?tid=48747 |
|
2005-11-1 16:38 |
|
|
fdsiuha
高级用户
    闷
积分 587
发帖 302
注册 2005-7-25
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
但假如按照LBA模式的话 0111111111111111110100110100(B) => 134,217,012(D) 所表示的扇区数已经超出这块硬盘的实际实用扇区数了。反过来,这块硬盘的最大实用扇区数为 120,103,200 (D) => 0111001010001010000100100000(B) 28bit,这个数值无论怎么分割也凑不成该模式下CHS各个参数的
不是这个意思,LBA的存取确实把28位的寄存器作为一个统一的部分存取,但是使用这个寄存器的时候,仍然分为C、H、S这3部分相乘, 其中对于更大的硬盘来说,H更大些,另外两个参数是固定的(好好想一下3个参数的物理意义);此所谓地址线性增加,非我们所见的28位寄存器的大小,从0->n,而是硬盘内部的所有扇区都有一个从小到大的编号,这样做自然是把LBA看成是具有CHS参数的硬盘,保持兼容性。
所以你上面说的的B->D转换方式是不正确的。所以后面自然就“无法自圆其说”了。
PS:另外查了所谓LARGE,无非是在INT13的两个寄存器之间相互借4位来存取更多的空间罢了,与CHS没有本质区别。还有忘了说了,就是并不是LBA方式解决500MB的限制问题。
Last edited by fdsiuha on 2005-11-1 at 20:29 ]
But if according to the LBA mode, 0111111111111111110100110100(B) => 134,217,012(D) The number of sectors represented has exceeded the actual number of usable sectors of this hard disk. Conversely, the maximum number of usable sectors of this hard disk is 120,103,200 (D) => 0111001010001010000100100000(B) 28bit, and no matter how this value is divided, it cannot be composed into the CHS parameters under this mode.
It doesn't mean that. The access of LBA does indeed use the 28-bit register as a unified part for access, but when using this register, it is still divided into 3 parts of C, H, and S to multiply. Among them, for a larger hard disk, H is larger, and the other two parameters are fixed (think about the physical meaning of the 3 parameters carefully); this is the linear increase of the address, not the size of the 28-bit register we see. From 0->n, but all sectors inside the hard disk have a number from small to large. In this way, it is naturally to treat LBA as a hard disk with CHS parameters to maintain compatibility.
So the B->D conversion method you mentioned above is incorrect. So naturally it "can't hold water" later.
PS: In addition, checking the so-called LARGE is nothing more than borrowing 4 bits between the two registers of INT13 to access more space, which has no essential difference from CHS. Also, I forgot to say that the LBA mode does not solve the problem of the 500MB limit.
Last edited by fdsiuha on 2005-11-1 at 20:29 ]
|

欢迎造访DOS的小屋!
http://risky.ik8.com |
|
2005-11-1 19:21 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
我们先把讨论的基础确定下来,不然的话会陷入混乱。首先我们先确定有几件事是可以肯定的。一个是一个硬盘的最大可寻址扇区数是确定的,由厂商给出。另一个是要寻址的扇区地址是经过两次转换,一次是BIOS,另一次是ATA接口。假如这两件事是可以确定的,好,我们接着讨论。
我想你所说的寄存器应该是指ATA寄存器而不是Int 13h所用的寄存器吧,假如是的话,你说LBA模式使用这个寄存器的时候仍然是3部分相乘,那么这样一来岂不是和CHS模式没有区别了吗?怎么体现它的“整体”概念和CHS本质的区别呢?
另外,我认为随着硬盘容量的增加不是 H 值的增大而是 C 值的增大,H 反而是固定的,因为表示磁头的位数最少,最容易达到饱和。
我记得好象LARGE模式是最初突破504M限制的,后来才出现LBA模式的,由于这种模式现在也不常用,所以我们就不把它纳入讨论范围了。只要能搞清楚CHS和LBA也一样。
Last edited by DOSforever on 2005-11-2 at 01:17 ]
Let's first establish the basis of the discussion, otherwise we'll fall into chaos. First of all, we can be certain of a few things. One is that the maximum addressable sector number of a hard disk is determined and given by the manufacturer. Another is that the sector address to be addressed undergoes two conversions, one by the BIOS and the other by the ATA interface. If these two things can be confirmed, then we'll continue the discussion.
I think the register you mentioned should refer to the ATA register rather than the register used by Int 13h. If that's the case, you said that when the LBA mode uses this register, it's still multiplication of three parts, then in this way it's no different from the CHS mode. How does it reflect the "overall" concept and the essential difference from CHS?
In addition, I think with the increase in hard disk capacity, it's not the increase in the H value but the increase in the C value, and H is instead fixed because the number of bits representing the head is the least and is most likely to reach saturation.
I remember that the LARGE mode was the first to break through the 504M limit, and then the LBA mode appeared. Since this mode is not commonly used now, we won't include it in the discussion. As long as we can figure out CHS and LBA, it's the same.
Last edited by DOSforever on 2005-11-2 at 01:17 ]
|

DOS倒下了,但永远不死
DOS NEVER DIES !
投票调查:
http://www.cn-dos.net/forum/viewthread.php?tid=46187
本人尚未解决的疑难问题:
http://www.cn-dos.net/forum/viewthread.php?tid=15135
http://www.cn-dos.net/forum/viewthread.php?tid=47663
http://www.cn-dos.net/forum/viewthread.php?tid=48747 |
|
2005-11-2 01:16 |
|
|
fdsiuha
高级用户
    闷
积分 587
发帖 302
注册 2005-7-25
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
至于“整体”的概念,我说过了,它是硬盘内部的机制。现在的硬盘内部寻址是使用CHS的,而是把所有的扇区统统编号,直接靠这个编号来寻址。然后在硬盘的接口上它被转化为一个CHS参数。为什么要如此麻烦呢?第一,硬盘太大,里圈和外圈每道扇区数相差太大,用直接反映磁盘3维结构的CHS参数对于软件来说变化范围太大,而且不同的硬盘之间也不一样。这样做会使软件难以适应大部分的硬盘(譬如1头10柱面有128个扇区,由于你寻址到64为止,损失一半空间,在如1头1柱面只有32个扇区,由于寄存器可以寻址到64个,所以寻址就会经常出现越界),统一编号扇区后,逻辑上就只存在柱面的范围(就是盘片的直径乘密度,换句话,就是磁道密度的变化)的变化,不会越界,也不会损失空间。第二,虽然废除了CHS直接寻址,但是软件都使用固定的CHS格式来寻址,尤其微软的软件。所以对外还是要以CHS方式传递参数。
所以我的意思是:硬盘28位的寄存器,是软件和硬件之间的接口。就是当向硬盘提交了存取方式之后,硬盘内部寻址机构就会具此选择地址转换的模式。我在前面已经说过了,虽然LBA和CHS在硬盘的内部使用不同的方式寻址,所有的硬盘模式返回28位的都是CHS参数。这个转换过程由硬盘来完成,软件没有必要也操不到这个心。
LBA和CHS其实没有什么本质的区别。你去看你的电脑BIOS,它只有NORMAL、LARGE、LBA、AUTO而没有分成CHS、LBA、LARGE吧。因为LBA它就是用CHS的其中一个方式,只不过,他的28位全都可以为最大值,可以全是1。造成的影响就是每柱面的扇区多一些。
而我们以前那些所谓的限制只是由于软件-软件-软件之间的转换造成的。与CHS和LBA没有关系。只是到137G才是物理极限,新硬盘采用48位寄存器才能解决。
之后,才是软件--包括BIOS--负责接下来的工作,其中的I\O例程按照给定的C、H、S寻址,读写磁盘。
我们之所以软件看到的LBA、CHS设置以及不同的数值,只是硬盘内部按不同的寻址给出的。BIOS一般不做更进一步的变换(LARGE要稍微做一点变化,所以LARGE其实是软件实现的,因此兼容性不好)。
你还说过PC兔子的问题,不只是它,好多磁盘软件都出现过类似的问题,这种问题的根源就是地址的转换问题,就是因为它通过BIOS(通过DOS那就当然更不行了)存取磁盘。你把你现在使用的LBA或NORMAL换成NORMAL或LBA,再开机系统都启动不了,马上当机给你看--BIOS连操作系统的启动扇区都定位不到,你还能指望老版本的PC兔子能通过BIOS来做什么?我有一大把这样的DOS软件,十有八九,一打开就马上死机。
--------------------------------------------------
我的个人网站有关磁盘的详细介绍,还没做完估计到年底也做不完,唉
Last edited by fdsiuha on 2005-11-2 at 16:08 ]
As for the concept of "overall," I've mentioned it before; it's the mechanism inside the hard drive. Currently, the internal addressing of hard drives uses CHS, and all sectors are uniformly numbered, with addressing directly based on this number. Then, on the hard drive interface, it's converted into a CHS parameter. Why is this so cumbersome? First, hard drives are too large, and the number of sectors per track differs greatly between the inner and outer circles. Using CHS parameters that directly reflect the 3D structure of the disk is too wide-ranging for software, and it varies between different hard drives. This makes it difficult for software to adapt to most hard drives (for example, 1 head, 10 cylinders has 128 sectors, but since you address up to 64, half the space is lost; and for 1 head, 1 cylinder, there are only 32 sectors, but since the register can address up to 64, addressing often goes out of bounds). After uniformly numbering the sectors, logically, there's only the change in the range of cylinders (that is, the diameter of the disk multiplied by the density, in other words, the change in track density), there's no out-of-bounds or space loss. Second, although direct CHS addressing is abolished, software all uses the fixed CHS format for addressing, especially Microsoft's software. So externally, parameters still need to be passed in CHS mode.
So my point is: the 28-bit register of the hard drive is the interface between software and hardware. That is, after submitting the access method to the hard drive, the internal addressing mechanism of the hard drive will choose the mode of address conversion accordingly. I've already said earlier that although LBA and CHS use different methods for addressing inside the hard drive, all hard drive modes return 28-bit values that are CHS parameters. This conversion process is done by the hard drive, and software doesn't need to and can't interfere with this.
There's actually no essential difference between LBA and CHS. Look at your computer's BIOS; it only has NORMAL, LARGE, LBA, AUTO, not separated into CHS, LBA, LARGE. Because LBA is just one of the CHS methods, except that its 28 bits can all be at the maximum value, all can be 1. The impact is that there are more sectors per cylinder.
And those so-called restrictions we had before were just due to the conversion between software and software. It has nothing to do with CHS and LBA. Only up to 137G is the physical limit, and new hard drives need to use 48-bit registers to solve it.
Then, software—including BIOS—takes over the subsequent work, and the I/O routines address and read/write the disk according to the given C, H, S.
The reason we see different LBA, CHS settings and values in software is just that the hard drive internally addresses differently. BIOS generally doesn't make further conversions (LARGE needs a slight change, so LARGE is actually implemented by software, and thus has poor compatibility).
You also mentioned the issue with PC Rabbit. Not just it, many disk software have had similar problems. The root cause of this problem is the address conversion problem, because it accesses the disk through BIOS (and through DOS, of course, it's even worse). If you switch your current LBA or NORMAL to NORMAL or LBA and then boot, the system won't start and will immediately crash—BIOS can't even locate the boot sector of the operating system, so what can you expect from an old version of PC Rabbit to do through BIOS? I have a bunch of such DOS software, and nine times out of ten, they crash immediately when opened.
--------------------------------------------------
My personal website has a detailed introduction about disks, but it's not finished yet and probably won't be finished by the end of the year. Oh well
Last edited by fdsiuha on 2005-11-2 at 16:08 ]
|

欢迎造访DOS的小屋!
http://risky.ik8.com |
|
2005-11-2 15:44 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
『第 37 楼』:
使用 LLM 解释/回答一下
关于我的小硬盘(245M)请看 http://www.cn-dos.net/forum/viewthread.php?tid=17118&fpage,至于多出了0.21M是SPFDIS认出来的,不是计算出来的,200多兆的硬盘肯定支持LBA寻址模式,而且FDISK可以在LBA寻址模式分区,在外加硬盘时,pqmagic正常启动,没发现错误,也能分区。该硬盘上的DOS启动正常,就是除了在CHS模式下工作时SPFDISK正常,其他模式下工作时SPFDISK均不认识小硬盘的分区。BIOS的版本请看『第 20 楼』!
Regarding my small hard disk (245M), please see http://www.cn-dos.net/forum/viewthread.php?tid=17118&fpage. As for the extra 0.21M, it's recognized by SPFDIS, not calculated. A hard disk of over 200MB definitely supports LBA addressing mode, and FDISK can partition in LBA addressing mode. When adding an external hard disk, pqmagic starts normally, no errors are found, and it can also partition. The DOS boot on this hard disk is normal. It's just that SPFDIS is normal when working in CHS mode, but SPFDIS doesn't recognize the partition of the small hard disk when working in other modes. The BIOS version can be seen in 'Post #20'!
|

我的网络U盘 我的网络第2个U盘
论坛软件下载链接
灵雨飘零论坛
论坛新手必读,所有人的基本行为准则
刷QQ空间人气、留言的小软件 |
|
2005-11-3 09:58 |
|
|
fdsiuha
高级用户
    闷
积分 587
发帖 302
注册 2005-7-25
状态 离线
|
|
2005-11-4 21:27 |
|
|
zjnbwdj
中级用户
  
积分 300
发帖 137
注册 2005-11-4
状态 离线
|
『第 39 楼』:
使用 LLM 解释/回答一下
即便是用FDISK来分区,用SFDISK(一个我经常用的硬盘分区和格式化软件)来查看,还是有好多空闲的硬盘空间,也就是还没有100%的对硬盘进行分区.
Even when using FDISK for partitioning and checking with SFDISK (a hard disk partitioning and formatting software I often use), there are still a lot of free hard disk spaces, that is, the hard disk has not been 100% partitioned.
|
|
2005-11-6 13:39 |
|
|
rainhard
新手上路

积分 11
发帖 6
注册 2005-11-2
状态 离线
|
『第 40 楼』:
CHS应该是物理方式,而LBA是模拟方式在早期兼容更大容量的
使用 LLM 解释/回答一下
早期的BIOS/DOS在CHS方式下不支持比较大的Cylinder值,LBR就是通过算法将Cylinder值虚拟成header,LARGE也是一种虚拟的算法。
后来的BIOS和32位系统已经支持了更大的Cylinder,所以用哪种方式应都是差不多的。
Early BIOS/DOS in the early days did not support relatively large Cylinder values under the CHS mode. LBR is an algorithm that virtualizes the Cylinder value into a header, and LARGE is also a virtualization algorithm. Later BIOS and 32-bit systems have supported larger Cylinders, so it should be差不多 the same no matter which method is used.
(注:“差不多”保留英文“差不多”是因为在这种技术讨论场景下直接保留原意更合适,若要完全翻译为“about the same”也可,但根据要求尽量保留原意的非技术化表达,这里暂时保留“差不多”)
|
|
2005-11-7 11:27 |
|
|
weilong888
银牌会员
    
积分 1270
发帖 548
注册 2004-5-31
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
这种对硬盘的讨论是很有价值的。可惜我的认识没有各位的深刻。要知道,整台电脑,就是这硬盘上的数据最重要了。
This discussion about the hard disk is very valuable. It's a pity that my understanding isn't as profound as everyone else's. You know, for the entire computer, the data on this hard disk is the most important.
|
|
2006-10-6 08:34 |
|
|