`
lobin
  • 浏览: 425487 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
阅读更多

 

文件系统

FAT

关于fat文件系统:https://www.iteye.com/blog/lobin-2433943

 

多任务

 

 

遍址

不同的架构会采用不同的遍址方式。目前主要有两种遍址方式。

 

遍址方式

1、独立遍址方式

2、统一遍址方式

x86架构采用的是独立变址方式。采用统一遍址方式的有ARM,MIPS等架构。

 

独立遍址方式

 

统一遍址方式

 

x86遍址方式

独立遍址

 

IO端口

 

内存映射IO

 

显卡

 

显卡IO端口

 

显卡内存映射

 

VGA

VGA(Video Graphies Array, 视频图形阵列), Video Graphies Adapter, 视频图形适配器

 

SVGA

SVGA(Super VGA)

 

 

显示器

 

键盘鼠标

 

 

磁盘

硬盘

软盘

 

声卡

 

 

网卡

网卡驱动

 

ARP(Address Resolution Protocol,地址解析协议)是一个位于TCP/IP协议栈中的网络层,负责将某个IP地址解析成对应的MAC地址。

 

主引导程序

关于主引导程序参考另一篇:https://www.iteye.com/blog/lobin-2345973

 

从一个简单的主引导程序开始

	.code16
	.global start
	.text

start:
	jmpl	$0x07c0, $entry
entry:
	mov %cs, %ax
	mov %ax, %es

	push $0x00
	call print_message
	pop  %bx

	push $0x01
	call print_message
	pop  %bx

	mov %cr0, %eax 
	bts $0, %eax
	mov %eax, %cr0

	push $0x02
	call print_message
	pop  %bx

	push $0x03
	call print_message
	pop  %bx
endl:  
	hlt  
	jmp endl 

print_message:
	push %bp
	mov %sp, %bp

	mov $0x13, %ah
	mov $0x01, %al

	mov $0x00, %bh
	mov $0x1f, %bl

	mov 4(%bp), %dh # mov $0x00, %dh
	mov $0x0f, %dl

	mov $message, %bp
	mov $length, %cx

	int $0x10

	pop %bp
	ret

message:
	.ascii "Hello, This is AS!"
	.byte 0x0d, 0x0a

	length = . - message

	.org 510

mbr_flag:
	.word 0xaa55

FAT文件系统中主引导记录结构

FAT文件系统中主引导记录结构的描述,在FAT文件系统中称为引导扇区(Boot Sector

在引导扇区(Boot Sector)中有一个很重要的结构:BPB (BIOS Parameter Block),也就是BIOS参数块。

FAT12/16/32 common field (offset from 0 to 35) Field name Offset Size Description
BS_JmpBoot 0 3 Jump instruction to the bootstrap code (x86 instruction) used by OS boot sequence. There are two type of formats for this field and the former format is prefered.
0xEB, 0x??, 0x90 (Short jump + NOP)
0xE9, 0x??, 0x?? (Near jump)
?? is the arbitrary value depends on where to jump is. In case of any format out of these formats, the volume will not be recognized by Windows.
BS_OEMName 3 8 "MSWIN 4.1" is recommended but also "MSDOS 5.0" is often used. There are many misconceptions about this field. This is only a name. Microsoft's OS does not pay any attention to this field, but some FAT drivers do some reference. This string is recommended because it is considered to minimize compatibility problems. You can set something else, but some FAT drivers may not recognize that volume. This field usually indicates name of the system created the volume.
BPB_BytsPerSec 11 2 Sector size in unit of byte. Valid values for this field are 512, 1024, 2048 or 4096. Microsoft's OS properly supports these sector sizes, but many FAT drivers assume the sector size is 512 and do not check this field. For this reason, 512 should be used for maximum compatibility. However, you should not misunderstand that it is only related to compatibility. This value must be the same as the sector size of the storage contains the FAT volume.
BPB_SecPerClus 13 1 Number of sectors per allocation unit. In the FAT file system, the allocation unit is called Cluster. This is a block of one or more consecutive sectors and the data area is managed in this unit. The number of sectors per cluster must be a power of 2. Therefore, valid values are 1, 2, 4,... and 128. However, any value whose cluster size (BPB_BytsPerSec * BPB_SecPerClus) exceeds 32 KB should not be used. Recent systems, such as Windows, supprts cluster size larger than 32 KB, such as 64 KB, 128 KB, and 256 KB, but such volumes will not be recognized correctly by MS-DOS or old disk utilities.
BPB_RsvdSecCnt 14 2 Number of sectors in reserved area. This field must not be 0 because there is the boot sector itself contains this BPB in the reserved area. To avoid compatibility problems, it should be 1 on FAT12/16 volume. This is because some old FAT drivers ignore this field and assume that the size of reserved area is 1. On the FAT32 volume, it is typically 32. Microsoft's OS properly supports any value of 1 or larger.
BPB_NumFATs 16 1 Number of FATs. The value of this field should always be 2. Also any value eaual to or greater than 1 is valid but it is strongly recommended not to use values other than 2 to avoid compatibility problem. Microsoft's FAT driver properly supports the values other than 2 but some tools and FAT drivers ignore this field and operate with number of FAT is 2.
The standard value for this field 2 is to provide redudancy for the FAT data. The value of FAT entry is typically read from the first FAT and any change to the FAT entry is refrected to each FATs. If a sector in the FAT area is damaged, the data will not be lost because it is duplicated in another FAT. Therefore it can minimize risk of data loss. On the non-disk based storages, such as memory card, such redundancy is a useless feature, so that it may be 1 to save the disk space. But some FAT driver may not recognize such a volume properly.
BPB_RootEntCnt 17 2 On the FAT12/16 volumes, this field indicates number of 32-byte directory entries in the root directory. The value should be set a value that the size of root directory is aligned to the 2-sector boundary,BPB_RootEntCnt * 32 becomes even multiple ofBPB_BytsPerSec. For maximum compatibility, this field should be set to 512 on the FAT16 volume. For FAT32 volumes, this field must be 0.
BPB_TotSec16 19 2 Total number of sectors of the volume in old 16-bit field. This value is the number of sectors including all four areas of the volume. When the number of sectors of the FAT12/16 volumes is 0x10000 or larger, an invalid value 0 is set in this field, and the true value is set to BPB_TotSec32. For FAT32 volumes, this field must always be 0.
BPB_Media 21 1 The valid values for this field is 0xF0, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE and 0xFF. 0xF8 is the standard value for non-removable disks and 0xF0 is often used for non partitioned removable disks. Other important point is that the same value must be put in the lower 8-bits of FAT[0]. This comes from the media determination of MS-DOS Ver.1 and not used for any purpose any longer.
BPB_FATSz16 22 2 Number of sectors occupied by a FAT. This field is used for only FAT12/16 volumes. On the FAT32 volumes, it must be an invalid value 0 and BPB_FATSz32 is used instead. The size of the FAT area becomes BPB_FATSz?? *BPB_NumFATs sectors.
BPB_SecPerTrk 24 2 Number of sectors per track. This field is relevant only for media that have geometry and used for only disk BIOS of IBM PC.
BPB_NumHeads 26 2 Number of heads. This field is relevant only for media that have geometry and used for only disk BIOS of IBM PC.
BPB_HiddSec 28 4 Number of hidden physical sectors preceding the FAT volume. It is generally related to storage accessed by disk BIOS of IBM PC, and what kind of value is set is platform dependent. This field should always be 0 if the volume starts at the beginning of the storage, e.g. non-partitioned disks, such as floppy disk.
BPB_TotSec32 32 4 Total number of sectors of the FAT volume in new 32-bit field. This value is the number of sectors including all four areas of the volume. When the value on the FAT12/16 volume is less than 0x10000, this field must be invalid value 0 and the true value is set to BPB_TotSec16. On the FAT32 volume, this field is always valid and old field is not used.

 

Fields for FAT12/16 volumes (offset from 36) Field name Offset Size Description
BS_DrvNum 36 1 Drive number used by disk BIOS of IBM PC. This field is used in MS-DOS bootstrap, 0x00 for floppy disk and 0x80 for fixed disk. Actually it depends on the OS.
BS_Reserved1 37 1 Reserved (used by Windows NT). It should be set 0 when create the volume.
BS_BootSig 38 1 Extended boot signature (0x29). This is a signature byte indicates that the following three fields are present.
BS_VolID 39 4 Volume serial number used with BS_VolLab to track a volume on the removable storage. It enables to detect a wrong media change by FAT driver. This value is typically generated with current time and date on formatting.
BS_VolLab 43 11 This field is the 11-byte volume label and it matches volume label recorded in the root directory. FAT driver should update this field when the volume label in the root directory is changed. MS-DOS does it but Windows does not do it. When volume label is not present, "NO NAME " should be set in this field.
BS_FilSysType 54 8 "FAT12   ""FAT16   " or "FAT     ". Many people think that this string has any effect in determination of the FAT type but it is clearly a misrecognization. From the name of this field, you will find that this is not a part of BPB. Since this string is often incorrect or not set, Microsoft's FAT driver does not use this field to determine the FAT type. However, some old FAT drivers use this string to determine the FAT type, so that it should be set based on the FAT type of the volume to avoid compatibility problems.
BS_BootCode 62 448 Bootstrap program. It is platform dependent and filled with zero when not used.
BS_BootSign 510 2 0xAA55. A boot signature indicating that this is a valid boot sector.
  512   When the sector size is larger than 512 bytes, rest field in the sector should be filled with zero.

 

<tr style="margin: 0px; padding: 0px; border-width

Fields for FAT32 volumes (offset from 36) Field name Offset Size Description
BPB_FATSz32 36 4 Size of a FAT in unit of sector. The size of the FAT area is BPB_FATSz32 * BPB_NumFATs sector. This is an only field needs to be referred prior to determine the FAT type while this field exists in only FAT32 volume. But this is not a problem because BPB_FATSz16 is always invalid in FAT32 volume.
BPB_ExtFlags 40 2 Bit3-0: Active FAT starting from 0. Valid when bit7 is 1.
Bit6-4: Reserved (0).
Bit7: 0 means that each FAT are active and mirrored. 1 means that only one FAT indicated by bit3-0 is active.
Bit15-8-4: Reserved (0).
BPB_FSVer 42 2 FAT32 version. Upper byte is major version number and lower byte is minor version number. This document describes FAT32 version 0.0. This field is for futuer extension of FAT32 volume to manage the filesystem verison. However, FAT32 volume will not be updated any longer.
BPB_RootClus 44 4 First cluster number of the root directory. It is usually set to 2, the first cluster of the volume, but it does not need to always be 2.
BPB_FSInfo 48 2 Sector of FSInfo structure in offset from top of the FAT32 volume. It is usually set to 1, next to the boot sector.
BPB_BkBootSec 50 2 Sector of backup boot sector in offset from top of the FAT32 volume. It is usually set to 6, next to the boot sector but 6 and any other value is not recommended.
BPB_Reserved 52 12 Reserved (0).
BS_DrvNum 64 1 Same as the description of FAT12/16 field.
BS_Reserved1 65 1 Same as the description of FAT12/16 field.
BS_BootSig 66 1 Same as the description of FAT12/16 field.
BS_VolID 67 4 Same as the description of FAT12/16 field.
BS_VolLab 71 11 Same as the description of FAT12/16 field.
BS_FilSysType 82 8 Always "FAT32   " and has not any effect in determination of FAT type.

   

 

                       

 

 

 

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics