分类: LINUX
2011-01-26 13:39:29
A block device is a storage device that supports reading and (optionally) writing data in fixed-size blocks, sectors, or clusters. These blocks are generally 512 bytes or a multiple thereof in size. The term is often used in contrast with a word-addressed device which supports reading and writing data a word at a time, where a word is usually 1 to 8 bytes in size.
A block device generally requires fewer pins and can thus be placed in a smaller package than a word-addressed device. In addition, a block device interface to slower forms of memory, such as rotating media and NAND flash, is much easier to build than a word-addressed interface.
DrawbacksFor some purposes, a block device based on a given solid-state memory is slower than a word-addressed device based on the same memory because a read or write must start at the beginning of the block. Therefore, to read any part of the block, one must seek to the start of the block, read the whole block, and discard the other data if it will not be used. To write part of the block, one must seek to the start of the block, read the whole block into memory, change the data, seek to the start of the block again, and write the whole block back to the device. This is in addition to the typically longer seek times of storage technologies used on block devices.
Simulating ROM using a block deviceBecause a CPU generally needs random access to individual bytes of program and data memory, a program stored on a block device needs to be copied to a word-addressed memory before it can be used. The N-Gage, GP32, and Nintendo DS systems, as well as all home computers and disc-based consoles, play games stored on block devices and have enough RAM to hold enough of a program in memory at once that loading rarely interrupts game play. Programs for those systems are designed to wait until the system finishes loading data before doing anything with the data, either by freezing game play briefly or by playing one part of a map while loading another.
But on a system expecting a large word-addressed read-only memory, such as an NES, a GBC, a GBA, or any of several other video game systems, an adapter for a block device needs to contain enough NOR flash or RAM to hold a program. Copying from a block device to RAM is quicker than copying it to NOR flash, but NOR flash generally uses less power than RAM and retains the last program copied to it even when the power is turned off.
Implementations in practiceThe first device that could copy programs from a block device to RAM and then run them on a GBA was the GBACD, an ATA interface designed by Michal Lysek and Tobias Persson, two students from Halmstad University in Sweden. A program running on a microcontroller could read games from a hard drive or CD and run them. It was designed as a proof of concept, not as an all-in-one piracy solution, but the foundation was laid for Supercard, especially as CompactFlash is electrically identical to ATA.
The Supercard and M3 adapters contain 32 MB of RAM and a slot for a CF or SD card. They can play nearly all homebrew and pirated GBA games by copying them from the NAND memory to the faster memory and then handing control over to the GBA, though some do require patching so that savegames can be copied to the NAND memory. The EZ-Flash III and EFA II contain 32 MB of NOR flash memory used in a similar way, along with a much larger built-in NAND memory that can be rewritten but not swapped.
The GBA Movie Player, on the other hand, was not designed to run pirated GBA games. It has only 512 kilobytes of NOR memory, enough to store the firmware, which reads from CF. This lets it run only multiboot programs on the GBA, although some multiboot programs such as the built-in audio and video players and special versions of PocketNES and Goomba use an ATA driver to read and write from the CF card, swapping data in and out of RAM as needed. However, this swapping can sometimes create game play delays, especially with larger games in PocketNES, as the original games were not designed to wait for loading.