lib.rs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //! Rust library with type definitions and parsing functions for Multiboot2
  2. //! headers, as well as a builder to build them at runtime. This library is
  3. //! `no_std` and can be used in bootloaders.
  4. //!
  5. //! # Example
  6. //!
  7. //! ```rust
  8. //! use multiboot2_header::builder::{InformationRequestHeaderTagBuilder, HeaderBuilder};
  9. //! use multiboot2_header::{HeaderTagFlag, HeaderTagISA, MbiTagType, RelocatableHeaderTag, RelocatableHeaderTagPreference, Multiboot2Header};
  10. //!
  11. //! // Small example that creates a Multiboot2 header and parses it afterwards.
  12. //!
  13. //! // We create a Multiboot2 header during runtime here. A practical example is that your
  14. //! // program gets the header from a file and parses it afterwards.
  15. //! let mb2_hdr_bytes = HeaderBuilder::new(HeaderTagISA::I386)
  16. //! .relocatable_tag(RelocatableHeaderTag::new(
  17. //! HeaderTagFlag::Required,
  18. //! 0x1337,
  19. //! 0xdeadbeef,
  20. //! 4096,
  21. //! RelocatableHeaderTagPreference::None,
  22. //! ))
  23. //! .information_request_tag(
  24. //! InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
  25. //! .add_irs(&[MbiTagType::Cmdline, MbiTagType::BootLoaderName]),
  26. //! )
  27. //! .build();
  28. //!
  29. //! // Cast bytes in vector to Multiboot2 information structure
  30. //! let mb2_hdr = unsafe { Multiboot2Header::load(mb2_hdr_bytes.as_ptr().cast()) };
  31. //! println!("{:#?}", mb2_hdr);
  32. //!
  33. //! ```
  34. //!
  35. //! ## MSRV
  36. //!
  37. //! The MSRV is 1.75.0 stable.
  38. #![no_std]
  39. #![cfg_attr(feature = "unstable", feature(error_in_core))]
  40. #![deny(rustdoc::all)]
  41. #![deny(clippy::all)]
  42. #![deny(clippy::missing_const_for_fn)]
  43. #![deny(missing_debug_implementations)]
  44. #[cfg(feature = "builder")]
  45. extern crate alloc;
  46. #[cfg_attr(test, macro_use)]
  47. #[cfg(test)]
  48. extern crate std;
  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.
  78. pub use multiboot2::{TagType as MbiTagType, TagTypeId as MbiTagTypeId};