lib.rs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.56.1 stable.
  35. #![no_std]
  36. #![cfg_attr(feature = "unstable", feature(error_in_core))]
  37. #![deny(rustdoc::all)]
  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. mod address;
  47. mod console;
  48. mod end;
  49. mod entry_address;
  50. mod entry_efi_32;
  51. mod entry_efi_64;
  52. mod framebuffer;
  53. mod header;
  54. mod information_request;
  55. mod module_align;
  56. mod relocatable;
  57. mod tags;
  58. mod uefi_bs;
  59. #[cfg(feature = "builder")]
  60. pub mod builder;
  61. pub use self::address::*;
  62. pub use self::console::*;
  63. pub use self::end::*;
  64. pub use self::entry_address::*;
  65. pub use self::entry_efi_32::*;
  66. pub use self::entry_efi_64::*;
  67. pub use self::framebuffer::*;
  68. pub use self::header::*;
  69. pub use self::information_request::*;
  70. pub use self::module_align::*;
  71. pub use self::relocatable::*;
  72. pub use self::tags::*;
  73. pub use self::uefi_bs::*;
  74. /// Re-export of [`multiboot2::TagType`] from `multiboot2`-crate.
  75. pub use multiboot2::{TagType as MbiTagType, TagTypeId as MbiTagTypeId};