|
27 | 27 | // ============================================================================ |
28 | 28 |
|
29 | 29 | pub mod audio; |
| 30 | +pub mod block_dev; |
30 | 31 | pub mod bus; |
31 | 32 | pub mod hid; |
32 | 33 | pub mod i2c; |
@@ -514,6 +515,70 @@ pub struct Api { |
514 | 515 | /// set when the interrupt is pending. There is no masking - ignore the bits |
515 | 516 | /// you don't care about. |
516 | 517 | pub bus_interrupt_status: extern "C" fn() -> u32, |
| 518 | + |
| 519 | + // ======================================================================== |
| 520 | + // Block Device Support |
| 521 | + // ======================================================================== |
| 522 | + /// Get information about the Block Devices in the system. |
| 523 | + /// |
| 524 | + /// Block Devices are also known as *disk drives*. They can be read from |
| 525 | + /// (and often written to) but only in units called *blocks* or *sectors*. |
| 526 | + /// |
| 527 | + /// The BIOS should enumerate removable devices first, followed by fixed |
| 528 | + /// devices. |
| 529 | + /// |
| 530 | + /// The set of devices is not expected to change at run-time - removal of |
| 531 | + /// media is indicated with a boolean field in the |
| 532 | + /// `block_dev::DeviceInfo` structure. |
| 533 | + pub block_dev_get_info: extern "C" fn(device: u8) -> crate::Option<block_dev::DeviceInfo>, |
| 534 | + /// Eject a disk from the drive. |
| 535 | + /// |
| 536 | + /// Will return an error if this device is not removable. Does not return an |
| 537 | + /// error if the drive is already empty. |
| 538 | + pub block_dev_eject: extern "C" fn(device: u8) -> crate::Result<()>, |
| 539 | + /// Write one or more sectors to a block device. |
| 540 | + /// |
| 541 | + /// The function will block until all data is written. The array pointed |
| 542 | + /// to by `data` must be `num_blocks * block_size` in length, where |
| 543 | + /// `block_size` is given by `block_dev_get_info`. |
| 544 | + /// |
| 545 | + /// There are no requirements on the alignment of `data` but if it is |
| 546 | + /// aligned, the BIOS may be able to use a higher-performance code path. |
| 547 | + pub block_write: extern "C" fn( |
| 548 | + device: u8, |
| 549 | + start_block: block_dev::BlockIdx, |
| 550 | + num_blocks: u8, |
| 551 | + data: ApiByteSlice, |
| 552 | + ) -> crate::Result<()>, |
| 553 | + /// Read one or more sectors to a block device. |
| 554 | + /// |
| 555 | + /// The function will block until all data is read. The array pointed |
| 556 | + /// to by `data` must be `num_blocks * block_size` in length, where |
| 557 | + /// `block_size` is given by `block_dev_get_info`. |
| 558 | + /// |
| 559 | + /// There are no requirements on the alignment of `data` but if it is |
| 560 | + /// aligned, the BIOS may be able to use a higher-performance code path. |
| 561 | + pub block_read: extern "C" fn( |
| 562 | + device: u8, |
| 563 | + start_block: block_dev::BlockIdx, |
| 564 | + num_blocks: u8, |
| 565 | + data: ApiBuffer, |
| 566 | + ) -> crate::Result<()>, |
| 567 | + /// Verify one or more sectors on a block device (that is read them and |
| 568 | + /// check they match the given data). |
| 569 | + /// |
| 570 | + /// The function will block until all data is verified. The array pointed |
| 571 | + /// to by `data` must be `num_blocks * block_size` in length, where |
| 572 | + /// `block_size` is given by `block_dev_get_info`. |
| 573 | + /// |
| 574 | + /// There are no requirements on the alignment of `data` but if it is |
| 575 | + /// aligned, the BIOS may be able to use a higher-performance code path. |
| 576 | + pub block_verify: extern "C" fn( |
| 577 | + device: u8, |
| 578 | + start_block: block_dev::BlockIdx, |
| 579 | + num_blocks: u8, |
| 580 | + data: ApiByteSlice, |
| 581 | + ) -> crate::Result<()>, |
517 | 582 | } |
518 | 583 |
|
519 | 584 | // ============================================================================ |
|
0 commit comments