lib.rs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //! Library with type definitions and parsing functions for Multiboot2 headers.
  2. //! This library is `no_std` and can be used in bootloaders.
  3. //!
  4. //! # Example
  5. //! ```rust
  6. //! use multiboot2_header::builder::{InformationRequestHeaderTagBuilder, Multiboot2HeaderBuilder};
  7. //! use multiboot2_header::{HeaderTagFlag, HeaderTagISA, MbiTagType, RelocatableHeaderTag, RelocatableHeaderTagPreference, Multiboot2Header};
  8. //!
  9. //! // Small example that creates a Multiboot2 header and parses it afterwards.
  10. //!
  11. //! // We create a Multiboot2 header during runtime here. A practical example is that your
  12. //! // program gets the header from a file and parses it afterwards.
  13. //! let mb2_hdr_bytes = Multiboot2HeaderBuilder::new(HeaderTagISA::I386)
  14. //! .relocatable_tag(RelocatableHeaderTag::new(
  15. //! HeaderTagFlag::Required,
  16. //! 0x1337,
  17. //! 0xdeadbeef,
  18. //! 4096,
  19. //! RelocatableHeaderTagPreference::None,
  20. //! ))
  21. //! .information_request_tag(
  22. //! InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
  23. //! .add_irs(&[MbiTagType::Cmdline, MbiTagType::BootLoaderName]),
  24. //! )
  25. //! .build();
  26. //!
  27. //! // Cast bytes in vector to Multiboot2 information structure
  28. //! let mb2_hdr = unsafe { Multiboot2Header::from_addr(mb2_hdr_bytes.as_ptr() as usize) };
  29. //! println!("{:#?}", mb2_hdr);
  30. //!
  31. //! ```
  32. //!
  33. //! ## MSRV
  34. //! The MSRV is 1.52.1 stable.
  35. #![no_std]
  36. #![deny(rustdoc::all)]
  37. #![allow(rustdoc::missing_doc_code_examples)]
  38. #![deny(clippy::all)]
  39. #![deny(clippy::missing_const_for_fn)]
  40. #![deny(missing_debug_implementations)]
  41. #[cfg(feature = "builder")]
  42. extern crate alloc;
  43. #[cfg_attr(test, macro_use)]
  44. #[cfg(test)]
  45. extern crate std;
  46. #[cfg_attr(test, macro_use)]
  47. #[cfg(test)]
  48. pub(crate) mod test_utils;
  49. mod address;
  50. mod console;
  51. mod end;
  52. mod entry_address;
  53. mod entry_efi_32;
  54. mod entry_efi_64;
  55. mod framebuffer;
  56. mod header;
  57. mod information_request;
  58. mod module_align;
  59. mod relocatable;
  60. mod tags;
  61. mod uefi_bs;
  62. #[cfg(feature = "builder")]
  63. pub mod builder;
  64. pub use self::address::*;
  65. pub use self::console::*;
  66. pub use self::end::*;
  67. pub use self::entry_address::*;
  68. pub use self::entry_efi_32::*;
  69. pub use self::entry_efi_64::*;
  70. pub use self::framebuffer::*;
  71. pub use self::header::*;
  72. pub use self::information_request::*;
  73. pub use self::module_align::*;
  74. pub use self::relocatable::*;
  75. pub use self::tags::*;
  76. pub use self::uefi_bs::*;
  77. /// Re-export of [`multiboot2::TagType`] from `multiboot2`-crate as `MbiTagType`, i.e. tags that
  78. /// describe the entries in the Multiboot2 Information Structure (MBI).
  79. pub use multiboot2::TagType as MbiTagType;