i wanted to make a code that will run before the mbr, so i moved the mbr to the second sector, my code to sector zero. in sector 1 I loaded the second sector(which contains the mbr) than i call to address 7c00 to begin the mbr code.
so hard disk looks like this:
sector 0: my program that does IO ans loads sector 1
sector 1: code that loads sector 2
sector 2 mbr code
when i boot i receive this message:
"could not open drive multi 0 disk 0 rdisk 0 partition 1"
its importent to say that i want windows xp to run after my code
What you describe is exactly how the MBR code works:
The MBR of a hard disk is located at the first sector of the hard disk. BIOS will load that sector.
The MBR sector will move itself to some other address and load the first sector of the bootable hard disk partition to address 7C00 (hex). Then it will jump to 7C00 (hex).
However:
The MBR also contains information about the hard disk partitions in the last 80 bytes. If you want to replace the MBR by your own boot sector you'll have to copy the data located in the last 80 bytes. Otherwise hard disk access won't work any longer because the OS will look for hard disk information in thes last 80 bytes of the first sector of the hard disk.
If you want to replace the boot sector of the bootable partition you have a similar problem. Depending on the file system used there is file system information stored in some bytes of the boot sector. For FAT or NTFS the first three bytes must be a "JMP" instruction and the following about 65 bytes contain file system information.
Related
Refer to here, IOCTL_STORAGE_QUERY_PROPERTY with StorageAdapterProperty can be used to get the max transfer size of per SCSI Read(10) command.
In this code, 16 sectors are read from start of lba. I tried to modify the number and in my Win7 environment, the max number is 256 sector through SATA and 128 sector through bridge (SATA-USB) to a SSD, which match the result using IOCTL_STORAGE_QUERY_PROPERTY with StorageAdapterProperty.
As far as I know, when installing OS (win7, win10, macOS), a device can receive a SCSI Read(10) command up to 2048 sector. I wonder which layer limits the transfer size (operating system/device driver...) and is there any way to bypass the layer to send a SCSI Read(10) command longer than the limitation at a time?
I'm planning to use Spansion (now Cypress) S25FL032P flash memory. ( datasheet : http://www.cypress.com/file/196861/download )
On the datasheet, it says,
Memory architecture
– Uniform 64 KB sectors
– Top or bottom parameter block (Two 64-KB sectors (top or
bottom) broken down into sixteen 4-KB sub-sectors each)
– 256-byte page size
...
Erase
– Bulk erase function
– Sector erase (SE) command (D8h) for 64 KB sectors
– Sub-sector erase (P4E) command (20h) for 4 KB sectors
– Sub-sector erase (P8E) command (40h) for 8 KB sectors
So, it can perform erase operation on 1. chip, 2. 64k sector, 3. 8k sector, 4k sector level.
My question is, In both cases equivalently consume single P/E cycle on the perspective of 64kb sector?
Single command for 64kb sector erase.
16 commands for 64kb sector erase using 4k sector erase command (P4E)
Otherwise, second method consumes 16x P/E cycle?
I'm asking this because I want to issue erase command on as small as possible size while maximizing cell endurance as long as possible.
Can anyone explains how CD/DVD Boot Sector works to me? I've extracted some boot sectors from ISO images and found out that some of them are 6 sectors long and some are 8. I tried to look it up but no results. What is the minimum(maximum) length of a CD/DVD boot sector? Does it have to end with 0x55 0xAA?
Bootable ISO 9660 images are very different from other media such as floppies and hard drives. In the latter case, the BIOS loads a single, 512-byte sector, verifies the final 55 AA bytes, and then jumps to what it loaded.
El Torito, the extension that defines bootable ISO 9660 images for PCs, supports various methods of booting. Four of the methods emulate floppy (1.2M, 1.44M, 2.88M) and hard disk boot sectors; the BIOS will map the first floppy or hard disk to the CD-ROM so that you can take bootable floppies or small, bootable hard disks and convert them to ISO images. The last method is called native booting. Native boot sectors can be anywhere from 1-65535 sectors in length, or up to 32 MiB. Native boot sectors do not have to end in 55 AA.
ISO 9660 native sectors are almost always 2048 bytes, so native boot sectors will usually be 4 sectors long (512 * 4 == 2048).
You can find more info including a link to the El Torito standard here:
http://wiki.osdev.org/ISO_9660
http://wiki.osdev.org/El-Torito
https://en.wikipedia.org/wiki/El_Torito_(CD-ROM_standard)
Also, this document shows the binary structure of El Torito:
http://fossies.org/linux/xorriso/doc/boot_sectors.txt
When viewing details of a file using Finder, different values are shown for how much space the file occupies. For example, a file takes up 28.8KB of RAM but, 33KB of the disk. Anyone know the explanation?
Disk space is allocated in blocks. Meaning, in multiples of a "block size".
For example, on my system a 1 byte file is 4096 bytes on disk.
That's 1 byte of content & 4095 bytes of unused space.
Is there any utility where I can exactly specify to which sector area the images are going to be burned ?
I need to burn an SD card according to a specific sector map,
e.g. bootloader should reside in 512K area from sector 57 to sector 1072 inclusively
kernel should reside in 4M area from sector 1073 to sector 9264 inclusively
and so on
SECTOR_SIZE=<sector size in bytes>
FLASH_DEV=/dev/sd??
sudo dd if=boot.bin of=$FLASH_DEV bs=$SECTOR_SIZE count=$((1072-57)) seek=57
sudo dd if=kernel of=$FLASH_DEV bs=$SECTOR_SIZE count=$((9264-1073)) seek=1073
Just man 1 dd, and you must determine name of your flash drive in /dev/sd* before.
You can use the dd utility and specify the sector offset with the 'seek' option